clean up boolean, move to MQTT screen

This commit is contained in:
proddy
2021-02-23 17:45:48 +01:00
parent 1d64285f09
commit b2e85ee026
16 changed files with 53 additions and 68 deletions

View File

@@ -17,11 +17,10 @@
*/
#include "helpers.h"
#include "mqtt.h"
namespace emsesp {
uint8_t Helpers::bool_format_ = BOOL_FORMAT_ONOFF; // on/off
// like itoa but for hex, and quicker
// note: only for single byte hex values
char * Helpers::hextoa(char * result, const uint8_t value) {
@@ -125,9 +124,10 @@ char * Helpers::smallitoa(char * result, const uint16_t value) {
// work out how to display booleans
char * Helpers::render_boolean(char * result, bool value) {
if (bool_format() == BOOL_FORMAT_ONOFF) {
uint8_t bool_format_ = Mqtt::bool_format();
if (bool_format_ == BOOL_FORMAT_ONOFF) {
strlcpy(result, value ? "on" : "off", 5);
} else if (bool_format() == BOOL_FORMAT_TRUEFALSE) {
} else if (bool_format_ == BOOL_FORMAT_TRUEFALSE) {
strlcpy(result, value ? "true" : "false", 7);
} else {
strlcpy(result, value ? "1" : "0", 2);