4040#define NOTIF_SIZE 10
4141#define WEATHER_SIZE 7
4242#define ALARM_SIZE 8
43+ #define DATA_SIZE 512
4344
4445#define MUSIC_PLAY 0x9D00
4546#define MUSIC_PAUSE 0x9D01
4647#define MUSIC_PREVIOUS 0x9D02
4748#define MUSIC_NEXT 0x9D03
4849#define MUSIC_TOGGLE 0x9900
4950
51+ #define VOLUME_UP 0x99A1
52+ #define VOLUME_DOWN 0x99A2
53+ #define VOLUME_MUTE 0x99A3
54+
5055struct Notification
5156{
5257 int icon;
@@ -60,15 +65,23 @@ struct Weather
6065 int icon;
6166 int day;
6267 int temp;
68+ int high;
69+ int low;
6370};
6471
65- struct ChronosESP32Timer
72+ struct ChronosTimer
6673{
6774 unsigned long time;
6875 long duration = 5000 ;
6976 bool active;
7077};
7178
79+ struct ChronosData
80+ {
81+ int length;
82+ uint8_t data[DATA_SIZE];
83+ };
84+
7285struct Alarm
7386{
7487 uint8_t hour;
@@ -98,15 +111,55 @@ enum Config
98111 CF_CAMERA // camera config, (ready state)
99112};
100113
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+
101155class ChronosESP32 : public BLEServerCallbacks , public BLECharacteristicCallbacks , public ESP32Time
102156{
103157
104158public:
105159 ChronosESP32 ();
106- ChronosESP32 (String name); // set the BLE name
160+ ChronosESP32 (String name, ChronosScreen screen = CS_240x240_128_CTF ); // set the BLE name
107161 void begin (); // initializes BLE
108162 void loop (); // handles routine functions
109- void setLogging (bool state); // to view raw data receive over BLE
110163
111164 // watch
112165 bool isConnected ();
@@ -134,6 +187,7 @@ class ChronosESP32 : public BLEServerCallbacks, public BLECharacteristicCallback
134187 // control
135188 void sendCommand (uint8_t *command, size_t length);
136189 void musicControl (uint16_t command);
190+ void setVolume (uint8_t level);
137191 bool capturePhoto ();
138192 void findPhone (bool state);
139193
@@ -145,24 +199,22 @@ class ChronosESP32 : public BLEServerCallbacks, public BLECharacteristicCallback
145199 // callbacks
146200 void setConnectionCallback (void (*callback)(bool ));
147201 void setNotificationCallback (void (*callback)(Notification));
202+ void setRingerCallback (void (*callback)(String, bool ));
148203 void setConfigurationCallback (void (*callback)(Config, uint32_t , uint32_t ));
149204 void setDataCallback (void (*callback)(uint8_t *, int ));
205+ void setRawDataCallback (void (*callback)(uint8_t *, int ));
150206
151207private:
152208 String watchName = " Chronos ESP32" ;
153209 String address;
154210 uint8_t batteryLevel;
155211 bool connected;
156212 bool batteryChanged;
157- bool logging;
158213 bool hour24;
159214 bool cameraReady;
160215
161- bool receiving;
162-
163216 Notification notifications[NOTIF_SIZE];
164217 int notificationIndex;
165- int msgLen = 0 ;
166218
167219 Weather weather[WEATHER_SIZE];
168220 String weatherCity;
@@ -171,13 +223,20 @@ class ChronosESP32 : public BLEServerCallbacks, public BLECharacteristicCallback
171223
172224 Alarm alarms[ALARM_SIZE];
173225
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;
176233
177234 void (*connectionChangeCallback)(bool ) = nullptr ;
178235 void (*notificationReceivedCallback)(Notification) = nullptr ;
236+ void (*ringerAlertCallback)(String, bool ) = nullptr ;
179237 void (*configurationReceivedCallback)(Config, uint32_t , uint32_t ) = nullptr ;
180238 void (*dataReceivedCallback)(uint8_t *, int ) = nullptr ;
239+ void (*rawDataReceivedCallback)(uint8_t *, int ) = nullptr ;
181240
182241 void sendInfo ();
183242 void sendBattery ();
@@ -190,6 +249,9 @@ class ChronosESP32 : public BLEServerCallbacks, public BLECharacteristicCallback
190249
191250 // from BLECharacteristicCallbacks
192251 virtual void onWrite (BLECharacteristic *pCharacteristic);
252+
253+ void dataReceived ();
254+
193255};
194256
195257#endif
0 commit comments