From 78b2efd1481ae59c035c6b0f6a0b640810f96008 Mon Sep 17 00:00:00 2001 From: proddy Date: Sun, 19 Sep 2021 11:20:54 +0200 Subject: [PATCH] add rounding test --- src/test/test.cpp | 11 +++++++++++ src/test/test.h | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/test/test.cpp b/src/test/test.cpp index 892fb31f8..512a06f50 100644 --- a/src/test/test.cpp +++ b/src/test/test.cpp @@ -270,6 +270,17 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd) { char result[100]; Helpers::render_value(result, test_float, 2); shell.printfln("Float test from %f to %s", test_float, result); + + uint16_t temp; + double doub; + temp = 0x0201; // decimal 513 + doub = Helpers::round2(temp, 10); // divide by 10 + shell.printfln("Round test from x%02X to %d to %f", temp, temp, doub); + doub = Helpers::round2(temp, 10); // divide by 10 + shell.printfln("Round test div10 from x%02X to %d to %f", temp, temp, doub); + temp = 0x63; + doub = Helpers::round2(temp, 2); // divide by 2 + shell.printfln("Round test div2 from x%02X to %d to %f", temp, temp, doub); } if (command == "devices") { diff --git a/src/test/test.h b/src/test/test.h index 87e0c6bf0..e8268cea2 100644 --- a/src/test/test.h +++ b/src/test/test.h @@ -38,7 +38,8 @@ namespace emsesp { // #define EMSESP_DEBUG_DEFAULT "board_profile" // #define EMSESP_DEBUG_DEFAULT "shower_alert" // #define EMSESP_DEBUG_DEFAULT "310" -#define EMSESP_DEBUG_DEFAULT "api" +#define EMSESP_DEBUG_DEFAULT "render" +// #define EMSESP_DEBUG_DEFAULT "api" // #define EMSESP_DEBUG_DEFAULT "crash" class Test {