mirror of
https://github.com/Lemonochrme/clover.git
synced 2025-06-08 08:40:50 +02:00
Screen: Added multiple frames for the boot screen. Fixed delay issues when in main loop. Showing bootscreen after setup.
This commit is contained in:
parent
7e1d7f1526
commit
c2b18fc052
20 changed files with 229 additions and 14 deletions
|
@ -20,9 +20,9 @@ void Components::Add(std::vector<std::shared_ptr<Box>> 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()
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Display
|
|||
Components();
|
||||
void Add(std::shared_ptr<Box> box);
|
||||
void Add(std::vector<std::shared_ptr<Box>> boxes);
|
||||
void Update(size_t index, String text);
|
||||
void Update(size_t index, std::any modified);
|
||||
void Display();
|
||||
private:
|
||||
size_t GetSize(StyleHeight sh);
|
||||
|
|
|
@ -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<unsigned char*>(data);
|
||||
const auto pic = std::any_cast<Picture>(data);
|
||||
_height = pic.height;
|
||||
_width = pic.width;
|
||||
_sprite = pic.data;
|
||||
Calculate();
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,11 @@
|
|||
|
||||
namespace Display
|
||||
{
|
||||
struct Picture {
|
||||
unsigned char* data;
|
||||
uint16_t width;
|
||||
uint16_t height;
|
||||
};
|
||||
|
||||
class SpriteBox : public Box
|
||||
{
|
||||
|
|
|
@ -3,13 +3,11 @@
|
|||
#include <memory>
|
||||
|
||||
// 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>(TextBox("Connected to Wi-Fi !", StyleWidth::LEFT, StyleHeight::CENTERED, U8G2_BTN_BW0, 0, 2)),
|
||||
std::make_shared<TextBox>(TextBox("IP address: ", StyleWidth::LEFT, StyleHeight::CENTERED, U8G2_BTN_BW0, 0, 2)),
|
||||
std::make_shared<TextBox>(TextBox("addr", StyleWidth::CENTERED, StyleHeight::CENTERED, U8G2_BTN_BW0, 0, 2))});
|
||||
loopWindow.Add(std::make_shared<SpriteBox>(SpriteBox(clover_bits, clover_height, clover_width, StyleWidth::CENTERED, StyleHeight::CENTERED)));
|
||||
bootWindow.Add(std::make_shared<SpriteBox>(SpriteBox(clover_frames[0].data, clover_frames[0].height, clover_frames[0].width, StyleWidth::CENTERED, StyleHeight::CENTERED)));
|
||||
loopWindow.Add(std::make_shared<TextBox>(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); }
|
||||
uint16_t Screen::getTextWidth(const char *str) { return _screen->getStrWidth(str); }
|
||||
bool Screen::isBooting() { return (_bootFrame<=20); }
|
|
@ -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;
|
||||
};
|
||||
}
|
||||
|
|
14
embedded/lib/Pictures/clover1.xbm
Normal file
14
embedded/lib/Pictures/clover1.xbm
Normal file
|
@ -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 };
|
14
embedded/lib/Pictures/clover10.xbm
Normal file
14
embedded/lib/Pictures/clover10.xbm
Normal file
|
@ -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 };
|
14
embedded/lib/Pictures/clover11.xbm
Normal file
14
embedded/lib/Pictures/clover11.xbm
Normal file
|
@ -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 };
|
14
embedded/lib/Pictures/clover2.xbm
Normal file
14
embedded/lib/Pictures/clover2.xbm
Normal file
|
@ -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 };
|
14
embedded/lib/Pictures/clover3.xbm
Normal file
14
embedded/lib/Pictures/clover3.xbm
Normal file
|
@ -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 };
|
14
embedded/lib/Pictures/clover4.xbm
Normal file
14
embedded/lib/Pictures/clover4.xbm
Normal file
|
@ -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 };
|
14
embedded/lib/Pictures/clover5.xbm
Normal file
14
embedded/lib/Pictures/clover5.xbm
Normal file
|
@ -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 };
|
14
embedded/lib/Pictures/clover6.xbm
Normal file
14
embedded/lib/Pictures/clover6.xbm
Normal file
|
@ -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 };
|
14
embedded/lib/Pictures/clover7.xbm
Normal file
14
embedded/lib/Pictures/clover7.xbm
Normal file
|
@ -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 };
|
14
embedded/lib/Pictures/clover8.xbm
Normal file
14
embedded/lib/Pictures/clover8.xbm
Normal file
|
@ -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 };
|
14
embedded/lib/Pictures/clover9.xbm
Normal file
14
embedded/lib/Pictures/clover9.xbm
Normal file
|
@ -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 };
|
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -23,6 +23,7 @@ public:
|
|||
// Return if the screen needs to be changed.
|
||||
bool showNext();
|
||||
bool isConnected();
|
||||
bool showBoot();
|
||||
|
||||
private:
|
||||
// Singleton
|
||||
|
|
|
@ -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<float>(std::any_cast<int>(humidity.getValue())));
|
||||
Serial.println(dataHandler.getJsonData());
|
||||
// When showing IP, delay is faster.
|
||||
delay(serverHandler.showNext() ? 1000 : 250);
|
||||
delay(serverHandler.showNext() ? 0 : 250);
|
||||
|
||||
serverHandler.loop();
|
||||
}
|
Loading…
Add table
Reference in a new issue