Nicer implementation while waiting for DynamicNumber() class

This commit is contained in:
3djc
2019-12-11 13:57:46 +01:00
parent 6fcac62959
commit b7d10dd339
+14 -14
View File
@@ -30,29 +30,29 @@
#define SWITCH_TYPE_MAX(sw) (SWITCH_3POS) #define SWITCH_TYPE_MAX(sw) (SWITCH_3POS)
#endif #endif
class RTCBattValue: public StaticText class RTCBattValue: public Window
{ {
public: public:
RTCBattValue(Window * parent, const rect_t & rect): RTCBattValue(Window * parent, const rect_t & rect):
StaticText(parent, rect) Window(parent, rect)
{ {
} }
void paint(BitmapBuffer * dc) override
{
dc->drawNumber(0, 0, getRTCBatteryVoltage(), PREC2, 2, "", "V");
}
void checkEvents() override void checkEvents() override
{ {
div_t qr = div(getRTCBatteryVoltage(), 100); if (lastValue != getRTCBatteryVoltage()) {
char * tmp; lastValue = getRTCBatteryVoltage();
tmp = strAppendUnsigned(reusableBuffer.hardwareAndSettings.msg, qr.quot);
tmp = strAppend(tmp, ".", 1);
tmp = strAppendUnsigned(tmp, qr.rem, 2);
tmp = strAppend(tmp, " V", 2);
if (text != reusableBuffer.hardwareAndSettings.msg) {
setText(reusableBuffer.hardwareAndSettings.msg);
invalidate(); invalidate();
} }
} }
protected: protected:
uint16_t lastValue;
}; };
class SwitchDynamicLabel : public StaticText { class SwitchDynamicLabel : public StaticText {
@@ -202,12 +202,12 @@ void RadioHardwarePage::build(FormWindow * window)
// Debugs // Debugs
new StaticText(window, grid.getLabelSlot(), STR_DEBUG, 0, FONT(BOLD)); new StaticText(window, grid.getLabelSlot(), STR_DEBUG, 0, FONT(BOLD));
auto analogs = new TextButton(window, grid.getFieldSlot(2, 0), STR_ANALOGS_BTN); auto debugAnalogs = new TextButton(window, grid.getFieldSlot(2, 0), STR_ANALOGS_BTN);
analogs->setPressHandler([=]() -> uint8_t { debugAnalogs->setPressHandler([=]() -> uint8_t {
//TODO //TODO
}); });
auto keys = new TextButton(window, grid.getFieldSlot(2, 1), STR_KEYS_BTN); auto debugKeys = new TextButton(window, grid.getFieldSlot(2, 1), STR_KEYS_BTN);
keys->setPressHandler([=]() -> uint8_t { debugKeys->setPressHandler([=]() -> uint8_t {
//TODO //TODO
}); });
grid.nextLine(); grid.nextLine();