Sensor Watch Simulator (#35)

* Put something on screen

* Use the 32bit watch_date_time repr to pass from JS

* Implement periodic callbacks

* Clear display on enabling

* Hook up watch_set_led_color() to SVG (green-only)

* Make debug output full-width

* Remove default Emscripten canvas

* Implement sleep and button clicks

* Fix time zone conversion bug in beats-time app

* Clean up warnings

* Fix pin levels

* Set time zone to browser value (if available)

* Add basic backup data saving

* Silence format specifier warnings in both targets

* Remove unnecessary, copied files

* Use RTC pointer to clear callbacks (if available)

* Use preprocessor define to avoid hardcoding MOVEMENT_NUM_FACES

* Change each face to const preprocessor definition

* Remove Intl.DateTimeFormat usage

* Update shell.html title, header

* Add touch start/end event handlers on SVG buttons

* Update shell.html

* Update folder structure (shared, simulator, hardware under watch-library)

* Tease out shared components from watch_slcd

* Clean up simulator watch_slcd.c inline JS calls

* Fix missing newlines at end of file

* Add simulator warnings (except format, unused-paremter)

* Implement remaining watch_rtc functions

* Fix button bug on mouse down then drag out

* Implement remaining watch_slcd functions

* Link keyboard events to buttons (for keys A, L, M)

* Rewrite event handling (mouse, touch, keyboard) in C

* Set explicit text UTF-8 charset in shell.html

* Address PR comments

* Remove unused directories from include paths
This commit is contained in:
Alexsander Akers
2022-01-25 15:03:22 -05:00
committed by GitHub
parent 9e24f6c336
commit b8de35658f
327 changed files with 2303 additions and 570 deletions

View File

@@ -32,12 +32,12 @@ void character_set_face_activate(movement_settings_t *settings, void *context);
bool character_set_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
void character_set_face_resign(movement_settings_t *settings, void *context);
static const watch_face_t character_set_face = {
character_set_face_setup,
character_set_face_activate,
character_set_face_loop,
character_set_face_resign,
NULL
};
#define character_set_face ((const watch_face_t){ \
character_set_face_setup, \
character_set_face_activate, \
character_set_face_loop, \
character_set_face_resign, \
NULL, \
})
#endif // CHARACTER_SET_FACE_H_
#endif // CHARACTER_SET_FACE_H_

View File

@@ -32,12 +32,12 @@ void demo_face_activate(movement_settings_t *settings, void *context);
bool demo_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
void demo_face_resign(movement_settings_t *settings, void *context);
static const watch_face_t demo_face = {
demo_face_setup,
demo_face_activate,
demo_face_loop,
demo_face_resign,
NULL
};
#define demo_face ((const watch_face_t){ \
demo_face_setup, \
demo_face_activate, \
demo_face_loop, \
demo_face_resign, \
NULL, \
})
#endif // DEMO_FACE_H_
#endif // DEMO_FACE_H_

View File

@@ -37,12 +37,12 @@ void hello_there_face_activate(movement_settings_t *settings, void *context);
bool hello_there_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
void hello_there_face_resign(movement_settings_t *settings, void *context);
static const watch_face_t hello_there_face = {
hello_there_face_setup,
hello_there_face_activate,
hello_there_face_loop,
hello_there_face_resign,
NULL
};
#define hello_there_face ((const watch_face_t){ \
hello_there_face_setup, \
hello_there_face_activate, \
hello_there_face_loop, \
hello_there_face_resign, \
NULL, \
})
#endif // HELLO_THERE_FACE_H_

View File

@@ -36,10 +36,11 @@
// Pressing the alarm button enters the log mode, where the main display shows the number of interrupts detected in each of the last
// 24 hours (the hour is shown in the top right digit and AM/PM indicator, if the clock is set to 12 hour mode)
static void _lis2dh_logging_face_update_display(movement_settings_t *settings, lis2dh_logger_state_t *logger_state, lis2dh_interrupt_state interrupt_state, watch_date_time date_time) {
static void _lis2dh_logging_face_update_display(movement_settings_t *settings, lis2dh_logger_state_t *logger_state, lis2dh_interrupt_state interrupt_state) {
char buf[14];
char time_indication_character;
int8_t pos;
watch_date_time date_time;
if (logger_state->log_ticks) {
pos = (logger_state->data_points - 1 - logger_state->display_index) % LIS2DH_LOGGING_NUM_DATA_POINTS;
@@ -58,16 +59,16 @@ static void _lis2dh_logging_face_update_display(movement_settings_t *settings, l
}
switch (logger_state->axis_index) {
case 0:
sprintf(buf, "3A%2d%02d%4ld", date_time.unit.hour, date_time.unit.minute, logger_state->data[pos].x_interrupts + logger_state->data[pos].y_interrupts + logger_state->data[pos].z_interrupts);
sprintf(buf, "3A%2d%02d%4lu", date_time.unit.hour, date_time.unit.minute, logger_state->data[pos].x_interrupts + logger_state->data[pos].y_interrupts + logger_state->data[pos].z_interrupts);
break;
case 1:
sprintf(buf, "XA%2d%02d%4ld", date_time.unit.hour, date_time.unit.minute, logger_state->data[pos].x_interrupts);
sprintf(buf, "XA%2d%02d%4lu", date_time.unit.hour, date_time.unit.minute, logger_state->data[pos].x_interrupts);
break;
case 2:
sprintf(buf, "YA%2d%02d%4ld", date_time.unit.hour, date_time.unit.minute, logger_state->data[pos].y_interrupts);
sprintf(buf, "YA%2d%02d%4lu", date_time.unit.hour, date_time.unit.minute, logger_state->data[pos].y_interrupts);
break;
case 3:
sprintf(buf, "ZA%2d%02d%4ld", date_time.unit.hour, date_time.unit.minute, logger_state->data[pos].z_interrupts);
sprintf(buf, "ZA%2d%02d%4lu", date_time.unit.hour, date_time.unit.minute, logger_state->data[pos].z_interrupts);
break;
}
}
@@ -145,7 +146,6 @@ void lis2dh_logging_face_activate(movement_settings_t *settings, void *context)
bool lis2dh_logging_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
lis2dh_logger_state_t *logger_state = (lis2dh_logger_state_t *)context;
lis2dh_interrupt_state interrupt_state = 0;
watch_date_time date_time;
switch (event.event_type) {
case EVENT_MODE_BUTTON_UP:
@@ -157,13 +157,13 @@ bool lis2dh_logging_face_loop(movement_event_t event, movement_settings_t *setti
case EVENT_LIGHT_BUTTON_DOWN:
logger_state->axis_index = (logger_state->axis_index + 1) % 4;
logger_state->log_ticks = 255;
_lis2dh_logging_face_update_display(settings, logger_state, interrupt_state, date_time);
_lis2dh_logging_face_update_display(settings, logger_state, interrupt_state);
break;
case EVENT_ALARM_BUTTON_UP:
if (logger_state->log_ticks) logger_state->display_index = (logger_state->display_index + 1) % LIS2DH_LOGGING_NUM_DATA_POINTS;
logger_state->log_ticks = 255;
logger_state->axis_index = 0;
_lis2dh_logging_face_update_display(settings, logger_state, interrupt_state, date_time);
_lis2dh_logging_face_update_display(settings, logger_state, interrupt_state);
break;
case EVENT_ACTIVATE:
case EVENT_TICK:
@@ -182,7 +182,7 @@ bool lis2dh_logging_face_loop(movement_event_t event, movement_settings_t *setti
} else {
watch_clear_indicator(WATCH_INDICATOR_SIGNAL);
}
_lis2dh_logging_face_update_display(settings, logger_state, interrupt_state, date_time);
_lis2dh_logging_face_update_display(settings, logger_state, interrupt_state);
break;
case EVENT_BACKGROUND_TASK:
_lis2dh_logging_face_log_data(logger_state);

View File

@@ -55,12 +55,12 @@ bool lis2dh_logging_face_loop(movement_event_t event, movement_settings_t *setti
void lis2dh_logging_face_resign(movement_settings_t *settings, void *context);
bool lis2dh_logging_face_wants_background_task(movement_settings_t *settings, void *context);
static const watch_face_t lis2dh_logging_face = {
lis2dh_logging_face_setup,
lis2dh_logging_face_activate,
lis2dh_logging_face_loop,
lis2dh_logging_face_resign,
lis2dh_logging_face_wants_background_task
};
#define lis2dh_logging_face ((const watch_face_t){ \
lis2dh_logging_face_setup, \
lis2dh_logging_face_activate, \
lis2dh_logging_face_loop, \
lis2dh_logging_face_resign, \
lis2dh_logging_face_wants_background_task, \
})
#endif // LIS2DH_LOGGING_FACE_H_

View File

@@ -86,6 +86,6 @@ void voltage_face_resign(movement_settings_t *settings, void *context) {
(void) settings;
(void) context;
// make sure to restore the default in the end.
watch_set_analog_reference_voltage(ADC_REFCTRL_REFSEL_INTVCC2_Val);
watch_set_analog_reference_voltage(ADC_REFERENCE_VCC);
watch_disable_adc();
}

View File

@@ -32,12 +32,12 @@ void voltage_face_activate(movement_settings_t *settings, void *context);
bool voltage_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
void voltage_face_resign(movement_settings_t *settings, void *context);
static const watch_face_t voltage_face = {
voltage_face_setup,
voltage_face_activate,
voltage_face_loop,
voltage_face_resign,
NULL
};
#define voltage_face ((const watch_face_t){ \
voltage_face_setup, \
voltage_face_activate, \
voltage_face_loop, \
voltage_face_resign, \
NULL, \
})
#endif // VOLTAGE_FACE_H_
#endif // VOLTAGE_FACE_H_