From cf01a8bf585ce79b3cd3622cd350fc515f49b690 Mon Sep 17 00:00:00 2001 From: Evgenii Meshcheriakov Date: Tue, 18 Oct 2022 12:15:26 +0300 Subject: [PATCH] PressureWrapper: getPressure() improvments --- esp-vent-main/src/PressureWrapper.cpp | 6 +++--- esp-vent-main/src/esp-vent-main.cpp | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/esp-vent-main/src/PressureWrapper.cpp b/esp-vent-main/src/PressureWrapper.cpp index f7a0d90..79e2d78 100644 --- a/esp-vent-main/src/PressureWrapper.cpp +++ b/esp-vent-main/src/PressureWrapper.cpp @@ -42,14 +42,14 @@ int PressureWrapper::getPressure() { getRawPressure (); i = 0; } -// do { -// getRawPressure (); -// } while (crc8(data.rBuffer, 2) != data.crc); + if(crc8(data.rBuffer, 2) != data.crc){ pressure = data.rBuffer[0]; pressure = pressure << 8; pressure |= data.rBuffer[1]; float result = (float) pressure * 0.95 / 240; return (int) result; + } + return -255; } bool PressureWrapper::getRawPressure () { diff --git a/esp-vent-main/src/esp-vent-main.cpp b/esp-vent-main/src/esp-vent-main.cpp index 6e8783a..2ed9296 100644 --- a/esp-vent-main/src/esp-vent-main.cpp +++ b/esp-vent-main/src/esp-vent-main.cpp @@ -72,8 +72,11 @@ main (void) SwitchController sw_toggle (&b_toggle, &glob_time, &ventMachine, BUTTON_CONTROL_TOG_MODE); + PressureWrapper sens(); + + while (1) { @@ -84,7 +87,7 @@ main (void) * TODO: * - Update current pressure to eTick */ - ventMachine.HandleState (Event (Event::eTick, 0)); + ventMachine.HandleState (Event (Event::eTick)); glob_time.tickCounter (1); }