3232
3333#include < ChronosESP32.h>
3434
35+ #define LED_PIN 2
36+
3537ChronosESP32 watch;
3638// ChronosESP32 watch("Chronos Watch"); // set the bluetooth name
3739// ChronosESP32 watch("Chronos Watch", CS_360x360_130_CTF); // set the bluetooth name and screen configuration
@@ -329,6 +331,8 @@ void setup()
329331{
330332 Serial.begin (115200 );
331333
334+ pinMode (LED_PIN, OUTPUT);
335+
332336 // set the callbacks before calling begin funtion
333337 watch.setConnectionCallback (connectionCallback);
334338 watch.setNotificationCallback (notificationCallback);
@@ -364,7 +368,7 @@ void loop()
364368
365369 String time = watch.getHourC () + watch.getTime (" :%M " ) + watch.getAmPmC ();
366370 Serial.println (time);
367- delay (5000 );
371+ delay (500 );
368372
369373 /*
370374 // access available notifications
@@ -389,7 +393,7 @@ void loop()
389393
390394 /*
391395 // read the alarms, 8 available
392- // the alarms are only stored as received from the app, there is no function to trigger it yet
396+ // the alarms are only stored as received from the app
393397 for (int j = 0; j < 8; j++){
394398 Alarm a = watch.getAlarm(j);
395399 Serial.print("Alarm: ");
@@ -401,8 +405,23 @@ void loop()
401405 Serial.print("\tState: ");
402406 Serial.println(a.enabled ? "Enabled": "Disabled");
403407 }
408+
409+ // you need to save alarms after receiving them from the app and restore them during setup
410+ // otherwise they will be lost when the esp32 is restarted
411+ Alarm a1;
412+ a1.hour = 7;
413+ a1.minute = 30;
414+ a1.repeat = 0b0111110; // repeat from Monday to Friday
415+ a1.enabled = true;
416+ watch.setAlarm(0, a1); // save alarm at index 0
417+
418+ watch.isAlarmActive(0); // check if alarm at index 0 is active
419+ watch.isAlarmActive(watch.getAlarm(0)); // check if a specific alarm is active
420+ watch.isAnyAlarmActive(); // check if any alarm is active
404421 */
405422
423+ digitalWrite (LED_PIN, watch.isAnyAlarmActive ());
424+
406425 /* // access weather forecast details
407426 int n = watch.getWeatherCount();
408427 String updateTime = watch.getWeatherTime();
0 commit comments