2022-01-26 06:12:56 +08:00
|
|
|
/*
|
|
|
|
* MIT License
|
|
|
|
*
|
|
|
|
* Copyright (c) <#year#> <#author_name#>
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
|
|
* copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
* SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2022-01-27 07:59:48 +08:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2022-01-26 06:12:56 +08:00
|
|
|
#include "<#watch_face_name#>_face.h"
|
|
|
|
|
|
|
|
void <#watch_face_name#>_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
|
|
|
|
(void) settings;
|
|
|
|
if (*context_ptr == NULL) {
|
|
|
|
*context_ptr = malloc(sizeof(<#watch_face_name#>_state_t));
|
2022-01-27 07:59:48 +08:00
|
|
|
memset(*context_ptr, 0, sizeof(<#watch_face_name#>_state_t));
|
2022-01-26 06:12:56 +08:00
|
|
|
// Do any one-time tasks in here; the inside of this conditional happens only at boot.
|
|
|
|
}
|
|
|
|
// Do any pin or peripheral setup here; this will be called whenever the watch wakes from deep sleep.
|
|
|
|
}
|
|
|
|
|
|
|
|
void <#watch_face_name#>_face_activate(movement_settings_t *settings, void *context) {
|
|
|
|
(void) settings;
|
|
|
|
<#watch_face_name#>_state_t *state = (<#watch_face_name#>_state_t *)context;
|
|
|
|
|
|
|
|
// Handle any tasks related to your watch face coming on screen.
|
|
|
|
}
|
|
|
|
|
|
|
|
bool <#watch_face_name#>_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
|
|
|
<#watch_face_name#>_state_t *state = (<#watch_face_name#>_state_t *)context;
|
|
|
|
|
|
|
|
switch (event.event_type) {
|
|
|
|
case EVENT_ACTIVATE:
|
|
|
|
// Show your initial UI here.
|
|
|
|
break;
|
|
|
|
case EVENT_TICK:
|
|
|
|
// If needed, update your display here.
|
2022-04-20 23:40:55 +08:00
|
|
|
break;
|
2022-01-26 06:12:56 +08:00
|
|
|
case EVENT_LIGHT_BUTTON_UP:
|
2023-01-15 03:21:04 +08:00
|
|
|
// You can use the Light button for your own purposes. Note that by default, Movement will also
|
|
|
|
// illuminatethe LED in response to EVENT_LIGHT_BUTTON_DOWN; to suppress that behavior, add an
|
|
|
|
// empty case for EVENT_LIGHT_BUTTON_DOWN.
|
2022-01-26 06:12:56 +08:00
|
|
|
break;
|
|
|
|
case EVENT_ALARM_BUTTON_UP:
|
|
|
|
// Just in case you have need for another button.
|
|
|
|
break;
|
|
|
|
case EVENT_TIMEOUT:
|
|
|
|
// Your watch face will receive this event after a period of inactivity. If it makes sense to resign,
|
|
|
|
// you may uncomment this line to move back to the first watch face in the list:
|
|
|
|
// movement_move_to_face(0);
|
|
|
|
break;
|
|
|
|
case EVENT_LOW_ENERGY_UPDATE:
|
|
|
|
// If you did not resign in EVENT_TIMEOUT, you can use this event to update the display once a minute.
|
|
|
|
// Avoid displaying fast-updating values like seconds, since the display won't update again for 60 seconds.
|
|
|
|
// You should also consider starting the tick animation, to show the wearer that this is sleep mode:
|
|
|
|
// watch_start_tick_animation(500);
|
|
|
|
break;
|
|
|
|
default:
|
2023-01-15 03:21:04 +08:00
|
|
|
// Movement's default loop handler will step in for any cases you don't handle above:
|
|
|
|
// * EVENT_LIGHT_BUTTON_DOWN lights the LED
|
2023-01-15 23:31:12 +08:00
|
|
|
// * EVENT_MODE_BUTTON_UP moves to the next watch face in the list
|
|
|
|
// * EVENT_MODE_LONG_PRESS returns to the first watch face (or skips to the secondary watch face, if configured)
|
2023-01-15 03:21:04 +08:00
|
|
|
// You can override any of these behaviors by adding a case for these events to this switch statement.
|
|
|
|
return movement_default_loop_handler(event, settings);
|
2022-01-26 06:12:56 +08:00
|
|
|
}
|
|
|
|
|
2022-01-27 08:15:16 +08:00
|
|
|
// return true if the watch can enter standby mode. If you are PWM'ing an LED or buzzing the buzzer here,
|
2022-01-26 06:12:56 +08:00
|
|
|
// you should return false since the PWM driver does not operate in standby mode.
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void <#watch_face_name#>_face_resign(movement_settings_t *settings, void *context) {
|
|
|
|
(void) settings;
|
|
|
|
(void) context;
|
|
|
|
|
|
|
|
// handle any cleanup before your watch face goes off-screen.
|
|
|
|
}
|
2022-01-27 08:12:12 +08:00
|
|
|
|