update check lights + meas error handling
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -19,5 +19,6 @@ double getMax(void);
|
||||
double getRms(void);
|
||||
uint8_t getBar(void);
|
||||
float getValue(void);
|
||||
String getErrorString();
|
||||
void clearStats(void);
|
||||
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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);
|
||||
@@ -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");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user