update check lights + meas error handling

This commit is contained in:
2022-09-23 14:41:48 +02:00
parent ebdbb04041
commit bc21b1ee2d
9 changed files with 68 additions and 11 deletions

View File

@@ -89,6 +89,7 @@ void c_onScreenButton::handle()
else if (_stateFn != NULL) else if (_stateFn != NULL)
{ {
_state = _stateFn(); _state = _stateFn();
_displayState = _state;
} }
log_d("item(%s)=%d",_name.c_str(), _state); log_d("item(%s)=%d",_name.c_str(), _state);
} }

View File

@@ -14,6 +14,7 @@
#define FONT8 u8g2_font_helvR08_tf #define FONT8 u8g2_font_helvR08_tf
#define FONT16 u8g2_font_7x14_tf #define FONT16 u8g2_font_7x14_tf
#define FONT24 u8g2_font_freedoomr25_tn //u8g2_font_logisoso24_tf #define FONT24 u8g2_font_freedoomr25_tn //u8g2_font_logisoso24_tf
#define FONT25 u8g2_font_helvR24_tf
class U8G2_SSD1322 : public U8G2 { class U8G2_SSD1322 : public U8G2 {
public: public:

View File

@@ -43,6 +43,23 @@ float getValue(void)
return getMeasurement(); return getMeasurement();
} }
String getErrorString()
{
if(getOpenState())
{
return "OPEN";
}
else if(getValue() < 0)
{
return "POL";
}
else
{
return "";
}
}
void clearStats(void) void clearStats(void)
{ {
clearAverages(); clearAverages();

View File

@@ -19,5 +19,6 @@ double getMax(void);
double getRms(void); double getRms(void);
uint8_t getBar(void); uint8_t getBar(void);
float getValue(void); float getValue(void);
String getErrorString();
void clearStats(void); void clearStats(void);

View File

@@ -24,18 +24,40 @@ bool getErrorState(void)
bool getOkState(void) bool getOkState(void)
{ {
return measureOK; return measureOK;
} }
bool getOpenState(void) bool getOpenState(void)
{ {
if(getValue() > 3.2F) if(getValue() > 2.4F)
{ {
measureOK = false;
return true; return true;
} }
return false; 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) void initMeasureMode(void)
{ {
log_i("init measure mode"); log_i("init measure mode");

View File

@@ -12,6 +12,8 @@ void setMeasureMode(e_measureMode newMode);
bool getErrorState(void); bool getErrorState(void);
bool getOkState(void); bool getOkState(void);
bool getOpenState(void); bool getOpenState(void);
bool getPolarity(void);
void setMeasurementOK();
void setMeasurementNOK();
void initMeasureMode(void); void initMeasureMode(void);
void handleMeasureMode(void); void handleMeasureMode(void);

View File

@@ -61,10 +61,10 @@ c_onScreenButton ma200("200m", mA200, LocBottom, BUTTON2, &button2);
c_onScreenButton ma1000("1A", mA1000, LocBottom, BUTTON3, &button3); c_onScreenButton ma1000("1A", mA1000, LocBottom, BUTTON3, &button3);
c_onScreenButton mauto("Reset", 4, LocBottom, BUTTON4, &button4); c_onScreenButton mauto("Reset", 4, LocBottom, BUTTON4, &button4);
c_onScreenButton bsetup("Conf", 5, LocBottom, BUTTON5, &button5); 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 okState("OK", 7, LocRight, &getOkState);
c_onScreenButton openState("Open", 8, LocRight, &getOpenState); 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) void screenMainSetWarning(bool warning)
{ {
@@ -101,7 +101,7 @@ void initDisplayMain(void)
mainScreen.addItem(&errorState); mainScreen.addItem(&errorState);
mainScreen.addItem(&okState); mainScreen.addItem(&okState);
mainScreen.addItem(&openState); mainScreen.addItem(&openState);
mainScreen.addItem(&wifiState); mainScreen.addItem(&polState);
mainScreen.begin(); mainScreen.begin();
@@ -116,18 +116,31 @@ void screenMainDrawLayout(void)
float rate = getSampleRate(); float rate = getSampleRate();
getDisplay()->setCursor(5, 8); getDisplay()->setCursor(5, 8);
getDisplay()->printf("Fs:%4.0fHz", rate); getDisplay()->printf("Fs:%4.0fHz", rate);
getDisplay()->setCursor(170, 8); // getDisplay()->setCursor(170, 8);
getDisplay()->printf("loop=%dms", timer); // getDisplay()->printf("loop=%dms", timer);
} }
void ScreenMainDrawValues(void) void ScreenMainDrawValues(void)
{ {
getDisplay()->setFont(FONT24); getDisplay()->setFont(FONT24);
getDisplay()->setCursor(60, 45); getDisplay()->setCursor(60, 45);
String errorstr = getErrorString();
if(errorstr == "")
{
setMeasurementOK();
getDisplay()->printf("%4.3f", getValue()); getDisplay()->printf("%4.3f", getValue());
uint16_t stringwidth = getDisplay()->getStrWidth(drawValue("", getValue(), "").c_str()); uint16_t stringwidth = getDisplay()->getStrWidth(drawValue("", getValue(), "").c_str());
getDisplay()->setFont(u8g2_font_8x13_t_symbols); getDisplay()->setFont(u8g2_font_8x13_t_symbols);
getDisplay()->drawUTF8(78 + stringwidth + 4, 43, ""); 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()->setFont(FONT8);
// getDisplay()->drawUTF8(60 + stringwidth + 3, 43, "v"); // getDisplay()->drawUTF8(60 + stringwidth + 3, 43, "v");