40
40
#define NOTIF_SIZE 10
41
41
#define WEATHER_SIZE 7
42
42
#define ALARM_SIZE 8
43
+ #define DATA_SIZE 512
43
44
44
45
#define MUSIC_PLAY 0x9D00
45
46
#define MUSIC_PAUSE 0x9D01
46
47
#define MUSIC_PREVIOUS 0x9D02
47
48
#define MUSIC_NEXT 0x9D03
48
49
#define MUSIC_TOGGLE 0x9900
49
50
51
+ #define VOLUME_UP 0x99A1
52
+ #define VOLUME_DOWN 0x99A2
53
+ #define VOLUME_MUTE 0x99A3
54
+
50
55
struct Notification
51
56
{
52
57
int icon;
@@ -60,15 +65,23 @@ struct Weather
60
65
int icon;
61
66
int day;
62
67
int temp;
68
+ int high;
69
+ int low;
63
70
};
64
71
65
- struct ChronosESP32Timer
72
+ struct ChronosTimer
66
73
{
67
74
unsigned long time;
68
75
long duration = 5000 ;
69
76
bool active;
70
77
};
71
78
79
+ struct ChronosData
80
+ {
81
+ int length;
82
+ uint8_t data[DATA_SIZE];
83
+ };
84
+
72
85
struct Alarm
73
86
{
74
87
uint8_t hour;
@@ -98,15 +111,55 @@ enum Config
98
111
CF_CAMERA // camera config, (ready state)
99
112
};
100
113
114
+ /*
115
+ The screen configurations below is only used for identification on the Chronos app.
116
+ Under the watch tab, when you click on watch info you can see the detected screen configuration.
117
+ The primary purpose of this configuration is to aid in loading watchfaces on supported watches with the correct resolution.
118
+ ChronosESP32 library is implementing this for future development
119
+ */
120
+ enum ChronosScreen
121
+ {
122
+ // Resolution(240x240), Size in inches(1.3), Type(0 - Round [C], 1 - Square [S], 2 - Rectangular [R])
123
+ CS_0x0_000_CFF = 0 , // default no config
124
+ CS_240x240_130_STF = 1 , // 240x240, 1.3 inches, Square, True, False
125
+ CS_240x240_130_STT = 2 , // 240x240, 1.3 inches, Square, True, True
126
+ CS_80x160_096_RTF = 3 , // 80x160, 0.96 inches, Rectangular, True, False
127
+ CS_80x160_096_RTT = 4 , // 80x160, 0.96 inches, Rectangular, True, True
128
+ CS_135x240_114_RTF = 5 , // 135x240, 1.14 inches, Rectangular, True, False
129
+ CS_135x240_114_RTT = 6 , // 135x240, 1.14 inches, Rectangular, True, True
130
+ CS_240x240_128_CTF = 7 , // 240x240, 1.28 inches, Round, True, False
131
+ CS_240x240_128_CTT = 8 , // 240x240, 1.28 inches, Round, True, True
132
+ CS_240x288_157_RTF = 9 , // 240x288, 1.57 inches, Rectangular, True, False
133
+ CS_240x288_157_RTT = 10 , // 240x288, 1.57 inches, Rectangular, True, True
134
+ CS_240x283_172_RTF = 11 , // 240x283, 1.72 inches, Rectangular, True, False
135
+ CS_240x283_172_RTT = 12 , // 240x283, 1.72 inches, Rectangular, True, True
136
+ CS_360x360_130_CTF = 13 , // 360x360, 1.3 inches, Round, True, False
137
+ CS_360x360_130_CTT = 14 , // 360x360, 1.3 inches, Round, True, True
138
+ CS_320x380_177_RTF = 15 , // 320x380, 1.77 inches, Rectangular, True, False
139
+ CS_320x380_177_RTT = 16 , // 320x380, 1.77 inches, Rectangular, True, True
140
+ CS_320x385_175_RTF = 17 , // 320x385, 1.75 inches, Rectangular, True, False
141
+ CS_320x385_175_RTT = 18 , // 320x385, 1.75 inches, Rectangular, True, True
142
+ CS_320x360_160_RTF = 19 , // 320x360, 1.6 inches, Rectangular, True, False
143
+ CS_320x360_160_RTT = 20 , // 320x360, 1.6 inches, Rectangular, True, True
144
+ CS_240x296_191_RTF = 21 , // 240x296, 1.91 inches, Rectangular, True, False
145
+ CS_240x296_191_RTT = 22 , // 240x296, 1.91 inches, Rectangular, True, True
146
+ CS_412x412_145_CTF = 23 , // 412x412, 1.45 inches, Round, True, False
147
+ CS_412x412_145_CTT = 24 , // 412x412, 1.45 inches, Round, True, True
148
+ CS_410x494_200_RTF = 25 , // 410x494, 2.0 inches, Rectangular, True, False
149
+ CS_410x494_200_RTT = 32 , // 410x494, 2.0 inches, Rectangular, True, True
150
+ CS_466x466_143_CTF = 33 , // 466x466, 1.43 inches, Round, True, False
151
+ CS_466x466_143_CTT = 34 // 466x466, 1.43 inches, Round, True, True
152
+ };
153
+
154
+
101
155
class ChronosESP32 : public BLEServerCallbacks , public BLECharacteristicCallbacks , public ESP32Time
102
156
{
103
157
104
158
public:
105
159
ChronosESP32 ();
106
- ChronosESP32 (String name); // set the BLE name
160
+ ChronosESP32 (String name, ChronosScreen screen = CS_240x240_128_CTF ); // set the BLE name
107
161
void begin (); // initializes BLE
108
162
void loop (); // handles routine functions
109
- void setLogging (bool state); // to view raw data receive over BLE
110
163
111
164
// watch
112
165
bool isConnected ();
@@ -134,6 +187,7 @@ class ChronosESP32 : public BLEServerCallbacks, public BLECharacteristicCallback
134
187
// control
135
188
void sendCommand (uint8_t *command, size_t length);
136
189
void musicControl (uint16_t command);
190
+ void setVolume (uint8_t level);
137
191
bool capturePhoto ();
138
192
void findPhone (bool state);
139
193
@@ -145,24 +199,22 @@ class ChronosESP32 : public BLEServerCallbacks, public BLECharacteristicCallback
145
199
// callbacks
146
200
void setConnectionCallback (void (*callback)(bool ));
147
201
void setNotificationCallback (void (*callback)(Notification));
202
+ void setRingerCallback (void (*callback)(String, bool ));
148
203
void setConfigurationCallback (void (*callback)(Config, uint32_t , uint32_t ));
149
204
void setDataCallback (void (*callback)(uint8_t *, int ));
205
+ void setRawDataCallback (void (*callback)(uint8_t *, int ));
150
206
151
207
private:
152
208
String watchName = " Chronos ESP32" ;
153
209
String address;
154
210
uint8_t batteryLevel;
155
211
bool connected;
156
212
bool batteryChanged;
157
- bool logging;
158
213
bool hour24;
159
214
bool cameraReady;
160
215
161
- bool receiving;
162
-
163
216
Notification notifications[NOTIF_SIZE];
164
217
int notificationIndex;
165
- int msgLen = 0 ;
166
218
167
219
Weather weather[WEATHER_SIZE];
168
220
String weatherCity;
@@ -171,13 +223,20 @@ class ChronosESP32 : public BLEServerCallbacks, public BLECharacteristicCallback
171
223
172
224
Alarm alarms[ALARM_SIZE];
173
225
174
- ChronosESP32Timer infoTimer;
175
- ChronosESP32Timer findTimer;
226
+ ChronosTimer infoTimer;
227
+ ChronosTimer findTimer;
228
+ ChronosTimer ringerTimer;
229
+
230
+ ChronosData incomingData;
231
+
232
+ ChronosScreen screenConf = CS_240x240_128_CTF;
176
233
177
234
void (*connectionChangeCallback)(bool ) = nullptr ;
178
235
void (*notificationReceivedCallback)(Notification) = nullptr ;
236
+ void (*ringerAlertCallback)(String, bool ) = nullptr ;
179
237
void (*configurationReceivedCallback)(Config, uint32_t , uint32_t ) = nullptr ;
180
238
void (*dataReceivedCallback)(uint8_t *, int ) = nullptr ;
239
+ void (*rawDataReceivedCallback)(uint8_t *, int ) = nullptr ;
181
240
182
241
void sendInfo ();
183
242
void sendBattery ();
@@ -190,6 +249,9 @@ class ChronosESP32 : public BLEServerCallbacks, public BLECharacteristicCallback
190
249
191
250
// from BLECharacteristicCallbacks
192
251
virtual void onWrite (BLECharacteristic *pCharacteristic);
252
+
253
+ void dataReceived ();
254
+
193
255
};
194
256
195
257
#endif
0 commit comments