Skip to content

Commit

Permalink
add rounding test
Browse files Browse the repository at this point in the history
  • Loading branch information
proddy committed Sep 19, 2021
1 parent 1159006 commit 78b2efd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/test/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down
3 changes: 2 additions & 1 deletion src/test/test.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 78b2efd

Please sign in to comment.