From 0445129e48329ffbd7a645a6fe26f7a38977782e Mon Sep 17 00:00:00 2001 From: Pavel Brychta Date: Tue, 5 Jan 2021 13:42:40 +0100 Subject: [PATCH] Switch element pro UI --- src/elements/switch.cpp | 13 +++++++++++++ src/elements/switch.h | 7 +++++++ src/graphics/switch.h | 21 +++++++++++++++++++++ src/graphics/switch_off.xbm | 10 ++++++++++ src/graphics/switch_on.xbm | 10 ++++++++++ 5 files changed, 61 insertions(+) create mode 100644 src/elements/switch.cpp create mode 100644 src/elements/switch.h create mode 100644 src/graphics/switch.h create mode 100644 src/graphics/switch_off.xbm create mode 100644 src/graphics/switch_on.xbm diff --git a/src/elements/switch.cpp b/src/elements/switch.cpp new file mode 100644 index 0000000..abfed20 --- /dev/null +++ b/src/elements/switch.cpp @@ -0,0 +1,13 @@ +#include "switch.h" +#include "../graphics/glyphs.h" + +void drawSwitch(OLEDDisplay *display, int16_t x, int16_t y, bool state) +{ + String str = F("0"); + + if (state) + str = F("1"); + display->setFont(CHECKBOX); + display->setTextAlignment(TEXT_ALIGN_CENTER); + display->drawString(x, y, str); +} diff --git a/src/elements/switch.h b/src/elements/switch.h new file mode 100644 index 0000000..b70945d --- /dev/null +++ b/src/elements/switch.h @@ -0,0 +1,7 @@ +#ifndef _SWITCH_H_ +#define _SWITCH_H_ +#include "OLEDUIPlus.h" + +void drawSwitch(OLEDDisplay *display, int16_t x, int16_t y, bool state); + +#endif diff --git a/src/graphics/switch.h b/src/graphics/switch.h new file mode 100644 index 0000000..98b15cc --- /dev/null +++ b/src/graphics/switch.h @@ -0,0 +1,21 @@ +#define switch_on_width 34 +#define switch_on_height 16 +const uint8_t switch_on_bits[] PROGMEM = { + 0xff, 0x00, 0x00, 0xfc, 0x03, 0x3f, 0x00, 0x00, 0xf0, 0x03, 0x1f, 0x00, + 0x00, 0xe0, 0x03, 0x0f, 0x00, 0xe0, 0xc3, 0x03, 0x07, 0x00, 0xf0, 0x87, + 0x03, 0x07, 0x00, 0xf8, 0x8f, 0x03, 0x07, 0x00, 0xf8, 0x9f, 0x03, 0x07, + 0x00, 0xfc, 0x9f, 0x03, 0x03, 0x00, 0xf8, 0x0f, 0x03, 0x07, 0x00, 0xf8, + 0x9f, 0x03, 0x07, 0x00, 0xf8, 0x8f, 0x03, 0x07, 0x00, 0xf0, 0x87, 0x03, + 0x0f, 0x00, 0xe0, 0xc3, 0x03, 0x1f, 0x00, 0x00, 0xe0, 0x03, 0x3f, 0x00, + 0x00, 0xf0, 0x03, 0xff, 0x00, 0x00, 0xfc, 0x03 }; + +#define switch_off_width 34 +#define switch_off_height 16 +const uint8_t switch_off_bits[] PROGMEM = { + 0xff, 0x00, 0x00, 0xfc, 0x03, 0x3f, 0x48, 0xa9, 0xf0, 0x03, 0x9f, 0xff, + 0xff, 0xe7, 0x03, 0x4f, 0xe0, 0xff, 0xcf, 0x03, 0x27, 0x80, 0xff, 0x9f, + 0x03, 0x27, 0x80, 0xff, 0x9f, 0x03, 0x17, 0x00, 0xff, 0xbf, 0x03, 0x13, + 0x00, 0xff, 0x3f, 0x03, 0x17, 0x00, 0xff, 0xbf, 0x03, 0x17, 0x00, 0xff, + 0xbf, 0x03, 0x27, 0x80, 0xff, 0x9f, 0x03, 0x27, 0xc0, 0xff, 0x9f, 0x03, + 0xcf, 0xe0, 0xff, 0xcf, 0x03, 0x9f, 0xff, 0xff, 0xe7, 0x03, 0x3f, 0x40, + 0x92, 0xf0, 0x03, 0xff, 0x00, 0x00, 0xfc, 0x03 }; diff --git a/src/graphics/switch_off.xbm b/src/graphics/switch_off.xbm new file mode 100644 index 0000000..c14c9a4 --- /dev/null +++ b/src/graphics/switch_off.xbm @@ -0,0 +1,10 @@ +#define switch_off_width 34 +#define switch_off_height 16 +static unsigned char switch_off_bits[] = { + 0xff, 0x00, 0x00, 0xfc, 0x03, 0x3f, 0x48, 0xa9, 0xf0, 0x03, 0x9f, 0xff, + 0xff, 0xe7, 0x03, 0x4f, 0xe0, 0xff, 0xcf, 0x03, 0x27, 0x80, 0xff, 0x9f, + 0x03, 0x27, 0x80, 0xff, 0x9f, 0x03, 0x17, 0x00, 0xff, 0xbf, 0x03, 0x13, + 0x00, 0xff, 0x3f, 0x03, 0x17, 0x00, 0xff, 0xbf, 0x03, 0x17, 0x00, 0xff, + 0xbf, 0x03, 0x27, 0x80, 0xff, 0x9f, 0x03, 0x27, 0xc0, 0xff, 0x9f, 0x03, + 0xcf, 0xe0, 0xff, 0xcf, 0x03, 0x9f, 0xff, 0xff, 0xe7, 0x03, 0x3f, 0x40, + 0x92, 0xf0, 0x03, 0xff, 0x00, 0x00, 0xfc, 0x03 }; diff --git a/src/graphics/switch_on.xbm b/src/graphics/switch_on.xbm new file mode 100644 index 0000000..ec63abc --- /dev/null +++ b/src/graphics/switch_on.xbm @@ -0,0 +1,10 @@ +#define switch_on_width 34 +#define switch_on_height 16 +static unsigned char switch_on_bits[] = { + 0xff, 0x00, 0x00, 0xfc, 0x03, 0x3f, 0x00, 0x00, 0xf0, 0x03, 0x1f, 0x00, + 0x00, 0xe0, 0x03, 0x0f, 0x00, 0xe0, 0xc3, 0x03, 0x07, 0x00, 0xf0, 0x87, + 0x03, 0x07, 0x00, 0xf8, 0x8f, 0x03, 0x07, 0x00, 0xf8, 0x9f, 0x03, 0x07, + 0x00, 0xfc, 0x9f, 0x03, 0x03, 0x00, 0xf8, 0x0f, 0x03, 0x07, 0x00, 0xf8, + 0x9f, 0x03, 0x07, 0x00, 0xf8, 0x8f, 0x03, 0x07, 0x00, 0xf0, 0x87, 0x03, + 0x0f, 0x00, 0xe0, 0xc3, 0x03, 0x1f, 0x00, 0x00, 0xe0, 0x03, 0x3f, 0x00, + 0x00, 0xf0, 0x03, 0xff, 0x00, 0x00, 0xfc, 0x03 };