move accelerometer interrupt demo to Second Movement

This commit is contained in:
joeycastillo 2024-10-08 22:17:30 -04:00
parent 0b793f1d1c
commit e966131d89
5 changed files with 13 additions and 7 deletions

View File

@ -51,6 +51,7 @@ SRCS += \
./shell/shell.c \
./shell/shell_cmd_list.c \
./movement/lib/sunriset/sunriset.c \
./watch-library/shared/driver/lis2dw.c \
./watch-library/shared/driver/thermistor_driver.c \
./watch-library/shared/watch/watch_common_buzzer.c \
./watch-library/shared/watch/watch_common_display.c \

View File

@ -32,6 +32,7 @@
#include "fast_stopwatch_face.h"
#include "sunrise_sunset_face.h"
#include "character_set_face.h"
#include "accel_interrupt_count_face.h"
#include "all_segments_face.h"
#include "float_demo_face.h"
#include "temperature_display_face.h"

View File

@ -6,6 +6,7 @@ SRCS += \
./watch-faces/complication/countdown_face.c \
./watch-faces/complication/fast_stopwatch_face.c \
./watch-faces/complication/sunrise_sunset_face.c \
./watch-faces/demo/accel_interrupt_count_face.c \
./watch-faces/demo/all_segments_face.c \
./watch-faces/demo/character_set_face.c \
./watch-faces/demo/float_demo_face.c \

View File

@ -37,7 +37,7 @@ void accel_interrupt_handler(void) {
}
static void _accel_interrupt_count_face_update_display(accel_interrupt_count_state_t *state) {
char buf[11];
char buf[7];
if (state->running) {
watch_set_indicator(WATCH_INDICATOR_SIGNAL);
@ -46,8 +46,10 @@ static void _accel_interrupt_count_face_update_display(accel_interrupt_count_sta
}
// "AC"celerometer "IN"terrupts
snprintf(buf, 11, "AC1N%6ld", state->count);
watch_display_string(buf, 0);
watch_display_text(WATCH_POSITION_TOP_LEFT, "AC");
watch_display_text(WATCH_POSITION_TOP_RIGHT, "1N");
snprintf(buf, 7, "%6ld", state->count);
watch_display_text(WATCH_POSITION_BOTTOM, buf);
printf("%s\n", buf);
}
@ -95,8 +97,9 @@ bool accel_interrupt_count_face_loop(movement_event_t event, void *context) {
case EVENT_TICK:
{
char buf[11];
snprintf(buf, 11, "TH %4d ", state->new_threshold);
watch_display_string(buf, 0);
watch_display_text(WATCH_POSITION_TOP_RIGHT, " ");
watch_display_text_with_fallback(WATCH_POSITION_TOP, "W_THS", "TH");
watch_display_float_with_best_effort(state->new_threshold * 0.125, " G");
printf("%s\n", buf);
}
break;
@ -123,10 +126,10 @@ bool accel_interrupt_count_face_loop(movement_event_t event, void *context) {
case EVENT_ALARM_BUTTON_UP:
if (state->running) {
state->running = false;
watch_register_interrupt_callback(A4, NULL, INTERRUPT_TRIGGER_RISING);
watch_register_interrupt_callback(HAL_GPIO_A4_pin(), NULL, INTERRUPT_TRIGGER_RISING);
} else {
state->running = true;
watch_register_interrupt_callback(A4, accel_interrupt_handler, INTERRUPT_TRIGGER_RISING);
watch_register_interrupt_callback(HAL_GPIO_A4_pin(), accel_interrupt_handler, INTERRUPT_TRIGGER_RISING);
}
_accel_interrupt_count_face_update_display(state);
break;