tidied up print_value to use a Template. only show values which have data

This commit is contained in:
proddy
2020-06-16 22:04:01 +02:00
parent 7499c9dee6
commit 29d74d7b67
11 changed files with 246 additions and 152 deletions

View File

@@ -279,22 +279,18 @@ void EMSdevice::read_command(const uint16_t type_id) {
EMSESP::send_read_request(type_id, device_id());
}
// prints a value to the console
void EMSdevice::print_value(uuid::console::Shell & shell, uint8_t padding, const __FlashStringHelper * name, const __FlashStringHelper * suffix, const char * value) {
// prints a string value to the console
void EMSdevice::print_value(uuid::console::Shell & shell, uint8_t padding, const __FlashStringHelper * name, const __FlashStringHelper * value) {
print_value(shell, padding, name, uuid::read_flash_string(value).c_str());
}
void EMSdevice::print_value(uuid::console::Shell & shell, uint8_t padding, const __FlashStringHelper * name, const char * value) {
uint8_t i = padding;
while (i-- > 0) {
shell.print(F(" "));
}
shell.printf(PSTR("%s: %s"), uuid::read_flash_string(name).c_str(), value);
if (suffix != nullptr) {
shell.print(uuid::read_flash_string(suffix).c_str());
}
shell.println();
}
// prints a value to the console - with no prefix
void EMSdevice::print_value(uuid::console::Shell & shell, uint8_t padding, const __FlashStringHelper * name, const char * value) {
print_value(shell, padding, name, nullptr, value);
shell.printfln(PSTR("%s: %s"), uuid::read_flash_string(name).c_str(), value);
}
} // namespace emsesp