mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
clean up boolean, move to MQTT screen
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user