-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
754 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/* | ||
* MIT License | ||
* | ||
* Copyright (c) 2024 Joey Castillo | ||
* | ||
* 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. | ||
*/ | ||
|
||
#include <stdlib.h> | ||
#include <string.h> | ||
#include "accelerometer_sleep_state_face.h" | ||
|
||
void accelerometer_sleep_state_face_setup(uint8_t watch_face_index, void ** context_ptr) { | ||
(void) watch_face_index; | ||
(void) context_ptr; | ||
} | ||
|
||
void accelerometer_sleep_state_face_activate(void *context) { | ||
(void) context; | ||
movement_request_tick_frequency(8); | ||
} | ||
|
||
bool accelerometer_sleep_state_face_loop(movement_event_t event, void *context) { | ||
(void) context; | ||
char buf[7]; | ||
char state[4]; | ||
|
||
switch (event.event_type) { | ||
case EVENT_ACTIVATE: | ||
watch_display_text(WATCH_POSITION_TOP_LEFT, "A3"); | ||
watch_set_colon(); | ||
// fall through | ||
case EVENT_TICK: | ||
if (HAL_GPIO_A3_read()) { | ||
strcpy(state, "SLP"); | ||
printf("1\n"); | ||
} else { | ||
strcpy(state, "Act"); | ||
printf("0\n"); | ||
} | ||
sprintf(buf, "ac %s", state); | ||
// printf("%s\n", buf); | ||
watch_display_text(WATCH_POSITION_BOTTOM, buf); | ||
// If needed, update your display here. | ||
break; | ||
case EVENT_LIGHT_BUTTON_UP: | ||
// You can use the Light button for your own purposes. Note that by default, Movement will also | ||
// illuminate the LED in response to EVENT_LIGHT_BUTTON_DOWN; to suppress that behavior, add an | ||
// empty case for EVENT_LIGHT_BUTTON_DOWN. | ||
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_sleep_animation(500); | ||
break; | ||
default: | ||
// Movement's default loop handler will step in for any cases you don't handle above: | ||
// * EVENT_LIGHT_BUTTON_DOWN lights the LED | ||
// * 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) | ||
// You can override any of these behaviors by adding a case for these events to this switch statement. | ||
return movement_default_loop_handler(event); | ||
} | ||
|
||
// return true if the watch can enter standby mode. Generally speaking, you should always return true. | ||
// Exceptions: | ||
// * If you are displaying a color using the low-level watch_set_led_color function, you should return false. | ||
// * If you are sounding the buzzer using the low-level watch_set_buzzer_on function, you should return false. | ||
// Note that if you are driving the LED or buzzer using Movement functions like movement_illuminate_led or | ||
// movement_play_alarm, you can still return true. This guidance only applies to the low-level watch_ functions. | ||
return true; | ||
} | ||
|
||
void accelerometer_sleep_state_face_resign(void *context) { | ||
(void) context; | ||
} | ||
|
Oops, something went wrong.