diff --git a/CAD/MiliOhmMeter/MiliOhmMeter-backups/MiliOhmMeter-2022-02-16_161814.zip b/CAD/MiliOhmMeter/MiliOhmMeter-backups/MiliOhmMeter-2022-02-16_161814.zip deleted file mode 100644 index cf72810..0000000 Binary files a/CAD/MiliOhmMeter/MiliOhmMeter-backups/MiliOhmMeter-2022-02-16_161814.zip and /dev/null differ diff --git a/CAD/MiliOhmMeter/MiliOhmMeter-backups/MiliOhmMeter-2022-09-23_144032.zip b/CAD/MiliOhmMeter/MiliOhmMeter-backups/MiliOhmMeter-2022-09-23_144032.zip new file mode 100644 index 0000000..390e673 Binary files /dev/null and b/CAD/MiliOhmMeter/MiliOhmMeter-backups/MiliOhmMeter-2022-09-23_144032.zip differ diff --git a/MilliOhmMeter_FW/src/display_buttons.cpp b/MilliOhmMeter_FW/src/display_buttons.cpp index c805ce7..b45d251 100644 --- a/MilliOhmMeter_FW/src/display_buttons.cpp +++ b/MilliOhmMeter_FW/src/display_buttons.cpp @@ -89,6 +89,7 @@ void c_onScreenButton::handle() else if (_stateFn != NULL) { _state = _stateFn(); + _displayState = _state; } log_d("item(%s)=%d",_name.c_str(), _state); } diff --git a/MilliOhmMeter_FW/src/display_hall.h b/MilliOhmMeter_FW/src/display_hall.h index b924e37..c83d7f8 100644 --- a/MilliOhmMeter_FW/src/display_hall.h +++ b/MilliOhmMeter_FW/src/display_hall.h @@ -14,6 +14,7 @@ #define FONT8 u8g2_font_helvR08_tf #define FONT16 u8g2_font_7x14_tf #define FONT24 u8g2_font_freedoomr25_tn //u8g2_font_logisoso24_tf +#define FONT25 u8g2_font_helvR24_tf class U8G2_SSD1322 : public U8G2 { public: diff --git a/MilliOhmMeter_FW/src/measure.cpp b/MilliOhmMeter_FW/src/measure.cpp index 05f5c43..679fe15 100644 --- a/MilliOhmMeter_FW/src/measure.cpp +++ b/MilliOhmMeter_FW/src/measure.cpp @@ -43,6 +43,23 @@ float getValue(void) return getMeasurement(); } + +String getErrorString() +{ + if(getOpenState()) + { + return "OPEN"; + } + else if(getValue() < 0) + { + return "POL"; + } + else + { + return ""; + } +} + void clearStats(void) { clearAverages(); diff --git a/MilliOhmMeter_FW/src/measure.h b/MilliOhmMeter_FW/src/measure.h index 35c8012..5529c7e 100644 --- a/MilliOhmMeter_FW/src/measure.h +++ b/MilliOhmMeter_FW/src/measure.h @@ -19,5 +19,6 @@ double getMax(void); double getRms(void); uint8_t getBar(void); float getValue(void); +String getErrorString(); void clearStats(void); diff --git a/MilliOhmMeter_FW/src/measure_mode.cpp b/MilliOhmMeter_FW/src/measure_mode.cpp index ddd7e87..67cd359 100644 --- a/MilliOhmMeter_FW/src/measure_mode.cpp +++ b/MilliOhmMeter_FW/src/measure_mode.cpp @@ -24,18 +24,40 @@ bool getErrorState(void) bool getOkState(void) { + return measureOK; } bool getOpenState(void) { - if(getValue() > 3.2F) + if(getValue() > 2.4F) { + measureOK = false; return true; } return false; } +bool getPolarity(void) +{ + if(getValue() < 0) + { + measureOK = false; + return true; + } + return false; +} + +void setMeasurementOK() +{ + measureOK = true; +} + +void setMeasuremoteNOK() +{ + measureOK = false; +} + void initMeasureMode(void) { log_i("init measure mode"); diff --git a/MilliOhmMeter_FW/src/measure_mode.h b/MilliOhmMeter_FW/src/measure_mode.h index ba05084..6004a6d 100644 --- a/MilliOhmMeter_FW/src/measure_mode.h +++ b/MilliOhmMeter_FW/src/measure_mode.h @@ -12,6 +12,8 @@ void setMeasureMode(e_measureMode newMode); bool getErrorState(void); bool getOkState(void); bool getOpenState(void); - +bool getPolarity(void); +void setMeasurementOK(); +void setMeasurementNOK(); void initMeasureMode(void); void handleMeasureMode(void); \ No newline at end of file diff --git a/MilliOhmMeter_FW/src/screen_main.cpp b/MilliOhmMeter_FW/src/screen_main.cpp index 3f6d23a..49f2bdc 100644 --- a/MilliOhmMeter_FW/src/screen_main.cpp +++ b/MilliOhmMeter_FW/src/screen_main.cpp @@ -61,10 +61,10 @@ c_onScreenButton ma200("200m", mA200, LocBottom, BUTTON2, &button2); c_onScreenButton ma1000("1A", mA1000, LocBottom, BUTTON3, &button3); c_onScreenButton mauto("Reset", 4, LocBottom, BUTTON4, &button4); c_onScreenButton bsetup("Conf", 5, LocBottom, BUTTON5, &button5); -c_onScreenButton errorState("ER", 6, LocRight, &getErrorState); +c_onScreenButton errorState("", 6, LocRight, NULL); c_onScreenButton okState("OK", 7, LocRight, &getOkState); c_onScreenButton openState("Open", 8, LocRight, &getOpenState); -c_onScreenButton wifiState("Wifi", 9, LocRight, &getWifiState); +c_onScreenButton polState("Pol", 9, LocRight, &getPolarity); void screenMainSetWarning(bool warning) { @@ -101,7 +101,7 @@ void initDisplayMain(void) mainScreen.addItem(&errorState); mainScreen.addItem(&okState); mainScreen.addItem(&openState); - mainScreen.addItem(&wifiState); + mainScreen.addItem(&polState); mainScreen.begin(); @@ -116,18 +116,31 @@ void screenMainDrawLayout(void) float rate = getSampleRate(); getDisplay()->setCursor(5, 8); getDisplay()->printf("Fs:%4.0fHz", rate); - getDisplay()->setCursor(170, 8); - getDisplay()->printf("loop=%dms", timer); + // getDisplay()->setCursor(170, 8); + // getDisplay()->printf("loop=%dms", timer); } void ScreenMainDrawValues(void) { getDisplay()->setFont(FONT24); getDisplay()->setCursor(60, 45); - getDisplay()->printf("%4.3f", getValue()); - uint16_t stringwidth = getDisplay()->getStrWidth(drawValue("", getValue(), "").c_str()); - getDisplay()->setFont(u8g2_font_8x13_t_symbols); - getDisplay()->drawUTF8(78 + stringwidth + 4, 43, "Ω"); + String errorstr = getErrorString(); + + if(errorstr == "") + { + setMeasurementOK(); + getDisplay()->printf("%4.3f", getValue()); + uint16_t stringwidth = getDisplay()->getStrWidth(drawValue("", getValue(), "").c_str()); + getDisplay()->setFont(u8g2_font_8x13_t_symbols); + getDisplay()->drawUTF8(70 + stringwidth + 10, 43, "Ω"); + } + else + { + getDisplay()->setFont(FONT25); + log_d("get errorstring: %s",errorstr); + getDisplay()->printf("%s", errorstr.c_str()); + } + getDisplay()->setFont(FONT8); // getDisplay()->drawUTF8(60 + stringwidth + 3, 43, "v");