diff --git a/embedded/lib/Display/Components/Components.cpp b/embedded/lib/Display/Components/Components.cpp index d23913b..d13a3b4 100644 --- a/embedded/lib/Display/Components/Components.cpp +++ b/embedded/lib/Display/Components/Components.cpp @@ -20,9 +20,9 @@ void Components::Add(std::vector> boxes) } } -void Components::Update(size_t index, String text) +void Components::Update(size_t index, std::any modified) { - _boxes[index]->Update(text); + _boxes[index]->Update(modified); } void Components::Display() diff --git a/embedded/lib/Display/Components/Components.hpp b/embedded/lib/Display/Components/Components.hpp index 0f1ef8c..d0c6212 100644 --- a/embedded/lib/Display/Components/Components.hpp +++ b/embedded/lib/Display/Components/Components.hpp @@ -12,7 +12,7 @@ namespace Display Components(); void Add(std::shared_ptr box); void Add(std::vector> boxes); - void Update(size_t index, String text); + void Update(size_t index, std::any modified); void Display(); private: size_t GetSize(StyleHeight sh); diff --git a/embedded/lib/Display/Components/SpriteBox.cpp b/embedded/lib/Display/Components/SpriteBox.cpp index 683da52..ad77b37 100644 --- a/embedded/lib/Display/Components/SpriteBox.cpp +++ b/embedded/lib/Display/Components/SpriteBox.cpp @@ -19,7 +19,10 @@ SpriteBox::SpriteBox(unsigned char *sprite, uint16_t width, uint16_t height, Sty void SpriteBox::Update(std::any data) { - _sprite = std::any_cast(data); + const auto pic = std::any_cast(data); + _height = pic.height; + _width = pic.width; + _sprite = pic.data; Calculate(); } diff --git a/embedded/lib/Display/Components/SpriteBox.hpp b/embedded/lib/Display/Components/SpriteBox.hpp index 1471114..0aea01f 100644 --- a/embedded/lib/Display/Components/SpriteBox.hpp +++ b/embedded/lib/Display/Components/SpriteBox.hpp @@ -4,6 +4,11 @@ namespace Display { + struct Picture { + unsigned char* data; + uint16_t width; + uint16_t height; + }; class SpriteBox : public Box { diff --git a/embedded/lib/Display/Screen.cpp b/embedded/lib/Display/Screen.cpp index 244c979..4b5497d 100644 --- a/embedded/lib/Display/Screen.cpp +++ b/embedded/lib/Display/Screen.cpp @@ -3,13 +3,11 @@ #include // XBM Files -#include "Components/SpriteBox.hpp" -#include "../Pictures/clover.xbm" #include "../Pictures/failed.xbm" using namespace Display; -Screen::Screen() +Screen::Screen() : _booted(0), _bootFrame(0) { _screen = new U8G2_SSD1306_128X64_NONAME_F_HW_I2C(U8G2_R0, U8X8_PIN_NONE, SCL, SDA); _screen->begin(); @@ -38,7 +36,8 @@ void Screen::Setup(uint8_t *font) std::make_shared(TextBox("Connected to Wi-Fi !", StyleWidth::LEFT, StyleHeight::CENTERED, U8G2_BTN_BW0, 0, 2)), std::make_shared(TextBox("IP address: ", StyleWidth::LEFT, StyleHeight::CENTERED, U8G2_BTN_BW0, 0, 2)), std::make_shared(TextBox("addr", StyleWidth::CENTERED, StyleHeight::CENTERED, U8G2_BTN_BW0, 0, 2))}); - loopWindow.Add(std::make_shared(SpriteBox(clover_bits, clover_height, clover_width, StyleWidth::CENTERED, StyleHeight::CENTERED))); + bootWindow.Add(std::make_shared(SpriteBox(clover_frames[0].data, clover_frames[0].height, clover_frames[0].width, StyleWidth::CENTERED, StyleHeight::CENTERED))); + loopWindow.Add(std::make_shared(TextBox("Welcome to Clover!", StyleWidth::CENTERED, StyleHeight::CENTERED, U8G2_BTN_BW0, 0, 2))); } void Screen::connecting(uint8_t state) @@ -61,7 +60,7 @@ void Screen::connecting(uint8_t state) _screen->clearBuffer(); // Component - connectingWindow.Update(1, connectText); + connectingWindow.Update(1, String(connectText)); connectingWindow.Display(); // Displaying _screen->sendBuffer(); @@ -80,7 +79,7 @@ void Screen::connected(const char *ipaddress, uint8_t timing) { _screen->clearBuffer(); // Component - connectedWindow.Update(3, ipaddress); + connectedWindow.Update(3, String(ipaddress)); // Displaying connectedWindow.Display(); @@ -95,6 +94,16 @@ void Screen::connected(const char *ipaddress, uint8_t timing) _screen->sendBuffer(); } +void Screen::boot() +{ + _screen->clearBuffer(); + // Component + bootWindow.Display(); + _bootFrame++; + bootWindow.Update(0,clover_frames[(_bootFrame >= 10 ? 10 : _bootFrame)]); + _screen->sendBuffer(); +} + void Screen::loop() { _screen->clearBuffer(); @@ -107,4 +116,5 @@ void Screen::loop() uint16_t Screen::getHeight() { return _height; } uint16_t Screen::getWidth() { return _width; } U8G2_SSD1306_128X64_NONAME_F_HW_I2C &Screen::getScreen() { return *_screen; } -uint16_t Screen::getTextWidth(const char *str) { return _screen->getStrWidth(str); } \ No newline at end of file +uint16_t Screen::getTextWidth(const char *str) { return _screen->getStrWidth(str); } +bool Screen::isBooting() { return (_bootFrame<=20); } \ No newline at end of file diff --git a/embedded/lib/Display/Screen.hpp b/embedded/lib/Display/Screen.hpp index c7731cd..0fb39d1 100644 --- a/embedded/lib/Display/Screen.hpp +++ b/embedded/lib/Display/Screen.hpp @@ -5,9 +5,37 @@ #include "Components/Components.hpp" #include "Components/TextBox.hpp" +#include "Components/SpriteBox.hpp" + +// Frame for booting +#include "../Pictures/clover1.xbm" +#include "../Pictures/clover2.xbm" +#include "../Pictures/clover3.xbm" +#include "../Pictures/clover4.xbm" +#include "../Pictures/clover5.xbm" +#include "../Pictures/clover6.xbm" +#include "../Pictures/clover7.xbm" +#include "../Pictures/clover8.xbm" +#include "../Pictures/clover9.xbm" +#include "../Pictures/clover10.xbm" +#include "../Pictures/clover11.xbm" namespace Display { + constexpr Picture clover_frames[] = { + {clover1_bits, clover1_width, clover1_height}, + {clover2_bits, clover2_width, clover2_height}, + {clover3_bits, clover3_width, clover3_height}, + {clover4_bits, clover4_width, clover4_height}, + {clover5_bits, clover5_width, clover5_height}, + {clover6_bits, clover6_width, clover6_height}, + {clover7_bits, clover7_width, clover7_height}, + {clover8_bits, clover8_width, clover8_height}, + {clover9_bits, clover9_width, clover9_height}, + {clover10_bits, clover10_width, clover10_height}, + {clover11_bits, clover11_width, clover11_height}, + }; + class Screen { public: @@ -22,12 +50,14 @@ namespace Display void connecting(uint8_t state=0); void notConnected(); void connected(const char *ipaddress, uint8_t timing); + void boot(); void loop(); // Getters uint16_t getHeight(); uint16_t getWidth(); U8G2_SSD1306_128X64_NONAME_F_HW_I2C& getScreen(); uint16_t getTextWidth(const char * str); + bool isBooting(); private: // Singleton Screen(); @@ -41,12 +71,16 @@ namespace Display uint16_t _width; uint16_t _height; String _loading; + // Extern + uint8_t _bootFrame; + bool _booted; // Static Components TextBox headerSetup; Components connectingWindow; Components connectionfailedWindow; Components connectedWindow; + Components bootWindow; Components loopWindow; }; } diff --git a/embedded/lib/Pictures/clover1.xbm b/embedded/lib/Pictures/clover1.xbm new file mode 100644 index 0000000..07243b1 --- /dev/null +++ b/embedded/lib/Pictures/clover1.xbm @@ -0,0 +1,14 @@ +#define clover1_width 26 +#define clover1_height 32 +static unsigned char clover1_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x30, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, + 0x00, 0x78, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, + 0x00, 0xfc, 0x00, 0x00, 0x60, 0xfc, 0x18, 0x00, 0xe0, 0x79, 0x1e, 0x00, + 0xe0, 0x33, 0x1f, 0x00, 0xc0, 0x87, 0x0f, 0x00, 0xc0, 0x87, 0x0f, 0x00, + 0x80, 0xcf, 0x07, 0x00, 0x00, 0xcf, 0x03, 0x00, 0x00, 0x78, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; diff --git a/embedded/lib/Pictures/clover10.xbm b/embedded/lib/Pictures/clover10.xbm new file mode 100644 index 0000000..607ec59 --- /dev/null +++ b/embedded/lib/Pictures/clover10.xbm @@ -0,0 +1,14 @@ +#define clover10_width 26 +#define clover10_height 32 +static unsigned char clover10_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, + 0x00, 0x78, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, + 0x00, 0xfc, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x60, 0xfc, 0x18, 0x00, + 0xe0, 0x79, 0x1e, 0x00, 0xe0, 0x33, 0x1f, 0x00, 0xc0, 0x87, 0x0f, 0x00, + 0xc0, 0x87, 0x0f, 0x00, 0x80, 0xcf, 0x07, 0x00, 0x00, 0xcf, 0x03, 0x00, + 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x40, 0x00, 0x00, 0x44, 0x54, 0xa5, 0x00, 0x44, 0x54, 0x6d, 0x00, + 0x44, 0x54, 0xa5, 0x00, 0x98, 0x89, 0xac, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; diff --git a/embedded/lib/Pictures/clover11.xbm b/embedded/lib/Pictures/clover11.xbm new file mode 100644 index 0000000..3671396 --- /dev/null +++ b/embedded/lib/Pictures/clover11.xbm @@ -0,0 +1,14 @@ +#define clover11_width 26 +#define clover11_height 32 +static unsigned char clover11_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, + 0x00, 0x78, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, + 0x00, 0xfc, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x60, 0xfc, 0x18, 0x00, + 0xe0, 0x79, 0x1e, 0x00, 0xe0, 0x33, 0x1f, 0x00, 0xc0, 0x87, 0x0f, 0x00, + 0xc0, 0x87, 0x0f, 0x00, 0x80, 0xcf, 0x07, 0x00, 0x00, 0xcf, 0x03, 0x00, + 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x58, 0x48, 0x6d, 0x00, 0x44, 0x54, 0xa5, 0x00, 0x44, 0x54, 0x6d, 0x00, + 0x44, 0x54, 0xa5, 0x00, 0x98, 0x89, 0xac, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; diff --git a/embedded/lib/Pictures/clover2.xbm b/embedded/lib/Pictures/clover2.xbm new file mode 100644 index 0000000..65cb462 --- /dev/null +++ b/embedded/lib/Pictures/clover2.xbm @@ -0,0 +1,14 @@ +#define clover2_width 26 +#define clover2_height 32 +static unsigned char clover2_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x30, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, + 0x00, 0x78, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, + 0x60, 0xfc, 0x00, 0x00, 0xe0, 0xfc, 0x1c, 0x00, 0xe0, 0x79, 0x1e, 0x00, + 0xe0, 0x03, 0x1f, 0x00, 0xc0, 0x87, 0x0f, 0x00, 0xc0, 0xcf, 0x0f, 0x00, + 0x80, 0xcf, 0x03, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; diff --git a/embedded/lib/Pictures/clover3.xbm b/embedded/lib/Pictures/clover3.xbm new file mode 100644 index 0000000..e340366 --- /dev/null +++ b/embedded/lib/Pictures/clover3.xbm @@ -0,0 +1,14 @@ +#define clover3_width 26 +#define clover3_height 32 +static unsigned char clover3_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, + 0x00, 0x30, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, + 0x00, 0xfc, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, + 0xe0, 0xfc, 0x0c, 0x00, 0xe0, 0x79, 0x1e, 0x00, 0xe0, 0x03, 0x1f, 0x00, + 0xc0, 0x87, 0x1f, 0x00, 0x80, 0xcf, 0x07, 0x00, 0x00, 0xcf, 0x03, 0x00, + 0x00, 0xd8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; diff --git a/embedded/lib/Pictures/clover4.xbm b/embedded/lib/Pictures/clover4.xbm new file mode 100644 index 0000000..4777054 --- /dev/null +++ b/embedded/lib/Pictures/clover4.xbm @@ -0,0 +1,14 @@ +#define clover4_width 26 +#define clover4_height 32 +static unsigned char clover4_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, + 0x00, 0x78, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, + 0x00, 0xfc, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, + 0xc0, 0x78, 0x0e, 0x00, 0xe0, 0x01, 0x1f, 0x00, 0xe0, 0x83, 0x1f, 0x00, + 0xe0, 0xcf, 0x1f, 0x00, 0x80, 0xcf, 0x07, 0x00, 0x00, 0xce, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; diff --git a/embedded/lib/Pictures/clover5.xbm b/embedded/lib/Pictures/clover5.xbm new file mode 100644 index 0000000..e4c1351 --- /dev/null +++ b/embedded/lib/Pictures/clover5.xbm @@ -0,0 +1,14 @@ +#define clover5_width 26 +#define clover5_height 32 +static unsigned char clover5_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, + 0x00, 0x78, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, + 0x00, 0xfc, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, + 0xe0, 0x00, 0x0e, 0x00, 0xf0, 0x03, 0x1f, 0x00, 0xf0, 0x87, 0x1f, 0x00, + 0xe0, 0xcf, 0x0f, 0x00, 0x80, 0xcf, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; diff --git a/embedded/lib/Pictures/clover6.xbm b/embedded/lib/Pictures/clover6.xbm new file mode 100644 index 0000000..84e4383 --- /dev/null +++ b/embedded/lib/Pictures/clover6.xbm @@ -0,0 +1,14 @@ +#define clover6_width 26 +#define clover6_height 32 +static unsigned char clover6_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, + 0x00, 0x30, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, + 0x00, 0xfc, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, + 0x00, 0xfc, 0x00, 0x00, 0xe0, 0x78, 0x0e, 0x00, 0xf0, 0x01, 0x1f, 0x00, + 0xf0, 0x83, 0x1f, 0x00, 0xe0, 0xc7, 0x0f, 0x00, 0xc0, 0xcf, 0x07, 0x00, + 0x00, 0xdf, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; diff --git a/embedded/lib/Pictures/clover7.xbm b/embedded/lib/Pictures/clover7.xbm new file mode 100644 index 0000000..ff0324d --- /dev/null +++ b/embedded/lib/Pictures/clover7.xbm @@ -0,0 +1,14 @@ +#define clover7_width 26 +#define clover7_height 32 +static unsigned char clover7_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, + 0x00, 0x30, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, + 0x00, 0xfc, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, + 0x30, 0xfc, 0x18, 0x00, 0xf0, 0x30, 0x1e, 0x00, 0xf0, 0x01, 0x1f, 0x00, + 0xf0, 0x83, 0x0f, 0x00, 0xe0, 0xc7, 0x07, 0x00, 0xc0, 0xcf, 0x03, 0x00, + 0x00, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x10, 0x01, 0x00, 0x90, 0x89, 0xac, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; diff --git a/embedded/lib/Pictures/clover8.xbm b/embedded/lib/Pictures/clover8.xbm new file mode 100644 index 0000000..4c66ade --- /dev/null +++ b/embedded/lib/Pictures/clover8.xbm @@ -0,0 +1,14 @@ +#define clover8_width 26 +#define clover8_height 32 +static unsigned char clover8_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, + 0x00, 0x30, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, + 0x00, 0xfc, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, + 0x20, 0xfc, 0x18, 0x00, 0xe0, 0x30, 0x1e, 0x00, 0xe0, 0x03, 0x1f, 0x00, + 0xe0, 0x87, 0x0f, 0x00, 0xc0, 0xc7, 0x07, 0x00, 0x00, 0xcf, 0x03, 0x00, + 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, + 0x44, 0x54, 0xa5, 0x00, 0x98, 0x89, 0xac, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; diff --git a/embedded/lib/Pictures/clover9.xbm b/embedded/lib/Pictures/clover9.xbm new file mode 100644 index 0000000..b7e5c38 --- /dev/null +++ b/embedded/lib/Pictures/clover9.xbm @@ -0,0 +1,14 @@ +#define clover9_width 26 +#define clover9_height 32 +static unsigned char clover9_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, + 0x00, 0x78, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, + 0x00, 0xfc, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, + 0xe0, 0xfc, 0x1c, 0x00, 0xe0, 0x33, 0x1f, 0x00, 0xc0, 0x87, 0x0f, 0x00, + 0xc0, 0x87, 0x0f, 0x00, 0x80, 0xcf, 0x07, 0x00, 0x00, 0xcf, 0x03, 0x00, + 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x44, 0x54, 0x6d, 0x00, + 0x44, 0x54, 0xa5, 0x00, 0x98, 0x89, 0xac, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; diff --git a/embedded/lib/ServerHandler/ServerHandler.cpp b/embedded/lib/ServerHandler/ServerHandler.cpp index 8da17e4..64aad9a 100644 --- a/embedded/lib/ServerHandler/ServerHandler.cpp +++ b/embedded/lib/ServerHandler/ServerHandler.cpp @@ -44,6 +44,7 @@ void ServerHandler::loop() bool ServerHandler::showNext() { return (display_time >= MAX_TIME); } bool ServerHandler::isConnected() { return _connected; } +bool ServerHandler::showBoot() { return (display_time >= MAX_TIME); } void ServerHandler::handleRoot() { diff --git a/embedded/lib/ServerHandler/ServerHandler.hpp b/embedded/lib/ServerHandler/ServerHandler.hpp index 20a390b..068e755 100644 --- a/embedded/lib/ServerHandler/ServerHandler.hpp +++ b/embedded/lib/ServerHandler/ServerHandler.hpp @@ -23,6 +23,7 @@ public: // Return if the screen needs to be changed. bool showNext(); bool isConnected(); + bool showBoot(); private: // Singleton diff --git a/embedded/src/main.cpp b/embedded/src/main.cpp index 83b1a66..09121e3 100644 --- a/embedded/src/main.cpp +++ b/embedded/src/main.cpp @@ -28,15 +28,22 @@ void loop() auto& dataHandler = DataHandler::GetInstance(); auto& screen = Display::Screen::GetInstance(); - // If could not connect, show screen failure + // Could not connect, show screen failure if(!serverHandler.isConnected()) { screen.notConnected(); return; } + // Is booting + if(screen.isBooting() && serverHandler.showBoot()) + { + screen.boot(); + delay(166); + } + // If serverHandler finished showing ip. - if (serverHandler.showNext()) + if (!screen.isBooting()) screen.loop(); dataHandler.updateTemperatureData(random(1800, 2200) / 100.0); @@ -44,7 +51,7 @@ void loop() dataHandler.updateHumidityData(static_cast(std::any_cast(humidity.getValue()))); Serial.println(dataHandler.getJsonData()); // When showing IP, delay is faster. - delay(serverHandler.showNext() ? 1000 : 250); + delay(serverHandler.showNext() ? 0 : 250); serverHandler.loop(); } \ No newline at end of file