-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathClockface.h
61 lines (52 loc) · 1.98 KB
/
Clockface.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#pragma once
#include <Arduino.h>
#include <Adafruit_GFX.h>
#include <Locator.h>
#include <ArduinoJson.h>
#include <vector>
#include <CWPreferences.h>
#include <StatusController.h>
// Commons
#include "IClockface.h"
#include "Icons.h"
#include "picopixel.h"
#include "fonts/atari.h"
#include "fonts/hour8pt7b.h"
#include "fonts/minute7pt7b.h"
#include "PNGRender.h"
#include "CustomSprite.h"
#include "CWHttpClient.h"
#define CLOCKFACE_NAME "cw-cf-0x07"
const uint8_t CW_ICON_CANVAS[] PROGMEM = {
0x00, 0x0e, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00,
0x00, 0x3f, 0x80, 0x00, 0x00, 0x40, 0x40, 0x00, 0x1f, 0xc0, 0x7f, 0x00, 0x20, 0x3f, 0x80, 0x80,
0x20, 0x00, 0x00, 0x80, 0x20, 0x00, 0x00, 0x80, 0x20, 0x00, 0x00, 0x80, 0x20, 0x00, 0x00, 0x80,
0x20, 0x00, 0x00, 0x80, 0x20, 0x00, 0x00, 0x80, 0x20, 0x00, 0x00, 0x80, 0x20, 0x00, 0x00, 0x80,
0x20, 0x00, 0x00, 0x80, 0x20, 0x00, 0x00, 0x80, 0x20, 0x00, 0x00, 0x80, 0x20, 0x00, 0x00, 0x80,
0x20, 0x00, 0x00, 0x80, 0x7f, 0xff, 0xff, 0xc0, 0x80, 0x00, 0x00, 0x20, 0x7f, 0xff, 0xff, 0xc0,
0x0e, 0x1f, 0x0e, 0x00, 0x0e, 0x1f, 0x0e, 0x00, 0x1f, 0xff, 0xff, 0x00, 0x1e, 0x1f, 0x0f, 0x00,
0x3f, 0xff, 0xff, 0x80, 0x3c, 0x1f, 0x07, 0x80, 0x3c, 0x1f, 0x07, 0x80, 0x18, 0x0e, 0x03, 0x00
};
class Clockface : public IClockface
{
private:
Adafruit_GFX *_display;
CWDateTime *_dateTime;
uint16_t delay;
void setFont(const char *fontName);
bool deserializeDefinition();
void clockfaceSetup();
void clockfaceLoop();
void renderElements(JsonArrayConst elements);
void renderText(String text, JsonVariantConst value);
void createSprites();
void refreshDateTime();
void drawSplashScreen(uint16_t color, const char *msg);
void handleSpriteAnimation(std::shared_ptr<CustomSprite> &sprite);
void handleSpriteMovement(std::shared_ptr<CustomSprite> &sprite);
std::vector<std::shared_ptr<CustomSprite>> sprites;
public:
Clockface(Adafruit_GFX *display);
void setup(CWDateTime *dateTime);
void update();
};