bring in Chirpy face
This commit is contained in:
parent
e8b4d4d010
commit
c0514ad39a
3
Makefile
3
Makefile
@ -44,6 +44,7 @@ INCLUDES += \
|
|||||||
-I./filesystem \
|
-I./filesystem \
|
||||||
-I./shell \
|
-I./shell \
|
||||||
-I./movement/lib/sunriset \
|
-I./movement/lib/sunriset \
|
||||||
|
-I./movement/lib/chirpy_tx \
|
||||||
-I./watch-library/shared/watch \
|
-I./watch-library/shared/watch \
|
||||||
-I./watch-library/shared/driver \
|
-I./watch-library/shared/driver \
|
||||||
-I./watch-faces/clock \
|
-I./watch-faces/clock \
|
||||||
@ -51,6 +52,7 @@ INCLUDES += \
|
|||||||
-I./watch-faces/demo \
|
-I./watch-faces/demo \
|
||||||
-I./watch-faces/sensor \
|
-I./watch-faces/sensor \
|
||||||
-I./watch-faces/settings \
|
-I./watch-faces/settings \
|
||||||
|
-I./watch-faces/io \
|
||||||
|
|
||||||
# Add your source files here.
|
# Add your source files here.
|
||||||
SRCS += \
|
SRCS += \
|
||||||
@ -62,6 +64,7 @@ SRCS += \
|
|||||||
./shell/shell.c \
|
./shell/shell.c \
|
||||||
./shell/shell_cmd_list.c \
|
./shell/shell_cmd_list.c \
|
||||||
./movement/lib/sunriset/sunriset.c \
|
./movement/lib/sunriset/sunriset.c \
|
||||||
|
./movement/lib/chirpy_tx/chirpy_tx.c \
|
||||||
./watch-library/shared/driver/thermistor_driver.c \
|
./watch-library/shared/driver/thermistor_driver.c \
|
||||||
./watch-library/shared/watch/watch_common_buzzer.c \
|
./watch-library/shared/watch/watch_common_buzzer.c \
|
||||||
./watch-library/shared/watch/watch_common_display.c \
|
./watch-library/shared/watch/watch_common_display.c \
|
||||||
|
|||||||
@ -44,4 +44,5 @@
|
|||||||
#include "light_sensor_face.h"
|
#include "light_sensor_face.h"
|
||||||
#include "accelerometer_sleep_state_face.h"
|
#include "accelerometer_sleep_state_face.h"
|
||||||
#include "irda_demo_face.h"
|
#include "irda_demo_face.h"
|
||||||
|
#include "chirpy_demo_face.h"
|
||||||
// New includes go above this line.
|
// New includes go above this line.
|
||||||
|
|||||||
@ -19,4 +19,5 @@ SRCS += \
|
|||||||
./watch-faces/demo/light_sensor_face.c \
|
./watch-faces/demo/light_sensor_face.c \
|
||||||
./watch-faces/demo/accelerometer_sleep_state_face.c \
|
./watch-faces/demo/accelerometer_sleep_state_face.c \
|
||||||
./watch-faces/demo/irda_demo_face.c \
|
./watch-faces/demo/irda_demo_face.c \
|
||||||
|
./watch-faces/io/chirpy_demo_face.c \
|
||||||
# New watch faces go above this line.
|
# New watch faces go above this line.
|
||||||
|
|||||||
@ -91,10 +91,10 @@ static uint8_t short_data[] = {
|
|||||||
0x00,
|
0x00,
|
||||||
};
|
};
|
||||||
|
|
||||||
#define NANOSEC_INI_FILE_NAME "nanosec.ini"
|
#define ACTIVITY_DATA_FILE_NAME "activity.dat"
|
||||||
|
|
||||||
static uint8_t *nanosec_buffer = 0;
|
static uint8_t *activity_buffer = 0;
|
||||||
static uint16_t nanosec_buffer_size = 0;
|
static uint16_t activity_buffer_size = 0;
|
||||||
|
|
||||||
void chirpy_demo_face_setup(uint8_t watch_face_index, void **context_ptr) {
|
void chirpy_demo_face_setup(uint8_t watch_face_index, void **context_ptr) {
|
||||||
(void)watch_face_index;
|
(void)watch_face_index;
|
||||||
@ -113,39 +113,39 @@ void chirpy_demo_face_activate(void *context) {
|
|||||||
state->mode = CDM_CHOOSE;
|
state->mode = CDM_CHOOSE;
|
||||||
state->program = CDP_SCALE;
|
state->program = CDP_SCALE;
|
||||||
|
|
||||||
// Do we have nanosec data? Load it.
|
// Do we have activity data? Load it.
|
||||||
int32_t sz = filesystem_get_file_size(NANOSEC_INI_FILE_NAME);
|
int32_t sz = filesystem_get_file_size(ACTIVITY_DATA_FILE_NAME);
|
||||||
if (sz > 0) {
|
if (sz > 0) {
|
||||||
// We will free this in resign.
|
// We will free this in resign.
|
||||||
// I don't like any kind of dynamic allocation in long-running embedded software...
|
// I don't like any kind of dynamic allocation in long-running embedded software...
|
||||||
// But there's no way around it here; I don't want to hard-wire (and squat) any fixed size structure
|
// But there's no way around it here; I don't want to hard-wire (and squat) any fixed size structure
|
||||||
// Nanosec data may change in the future too
|
// Nanosec data may change in the future too
|
||||||
nanosec_buffer_size = sz + 2;
|
activity_buffer_size = sz + 2;
|
||||||
nanosec_buffer = malloc(nanosec_buffer_size);
|
activity_buffer = malloc(activity_buffer_size);
|
||||||
// First two bytes of prefix, so Chirpy RX can recognize this data type
|
// First two bytes of prefix, so Chirpy RX can recognize this data type
|
||||||
nanosec_buffer[0] = 0xc0;
|
activity_buffer[0] = 0xc0;
|
||||||
nanosec_buffer[1] = 0x00;
|
activity_buffer[1] = 0x00;
|
||||||
// Read file
|
// Read file
|
||||||
filesystem_read_file(NANOSEC_INI_FILE_NAME, (char*)&nanosec_buffer[2], sz);
|
filesystem_read_file(ACTIVITY_DATA_FILE_NAME, (char*)&activity_buffer[2], sz);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// To create / check test file in emulator:
|
// To create / check test file in emulator:
|
||||||
// echo TestData > nanosec.ini
|
// echo TestData > activity.ini
|
||||||
// cat nanosec.ini
|
// cat activity.ini
|
||||||
|
|
||||||
static void _cdf_update_lcd(chirpy_demo_state_t *state) {
|
static void _cdf_update_lcd(chirpy_demo_state_t *state) {
|
||||||
watch_display_string("CH", 0);
|
watch_display_text_with_fallback(WATCH_POSITION_TOP_LEFT, "CH", "Chirp");
|
||||||
if (state->program == CDP_SCALE)
|
if (state->program == CDP_SCALE)
|
||||||
watch_display_string(" SCALE", 4);
|
watch_display_text(WATCH_POSITION_BOTTOM, " SCALE");
|
||||||
else if (state->program == CDP_INFO_SHORT)
|
else if (state->program == CDP_INFO_SHORT)
|
||||||
watch_display_string("SHORT ", 4);
|
watch_display_text(WATCH_POSITION_BOTTOM, "SHORT ");
|
||||||
else if (state->program == CDP_INFO_LONG)
|
else if (state->program == CDP_INFO_LONG)
|
||||||
watch_display_string(" LOng ", 4);
|
watch_display_text(WATCH_POSITION_BOTTOM, " LOng ");
|
||||||
else if (state->program == CDP_INFO_NANOSEC)
|
else if (state->program == CDP_INFO_NANOSEC)
|
||||||
watch_display_string("nAnO ", 4);
|
watch_display_text(WATCH_POSITION_BOTTOM, " ACtIV");
|
||||||
else
|
else
|
||||||
watch_display_string("---- ", 4);
|
watch_display_text(WATCH_POSITION_BOTTOM, "---- ");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _cdf_quit_chirping(chirpy_demo_state_t *state) {
|
static void _cdf_quit_chirping(chirpy_demo_state_t *state) {
|
||||||
@ -224,8 +224,8 @@ static void _cdf_countdown_tick(void *context) {
|
|||||||
curr_data_ptr = long_data_str;
|
curr_data_ptr = long_data_str;
|
||||||
curr_data_len = strlen((const char *)long_data_str);
|
curr_data_len = strlen((const char *)long_data_str);
|
||||||
} else if (state->program == CDP_INFO_NANOSEC) {
|
} else if (state->program == CDP_INFO_NANOSEC) {
|
||||||
curr_data_ptr = nanosec_buffer;
|
curr_data_ptr = activity_buffer;
|
||||||
curr_data_len = nanosec_buffer_size;
|
curr_data_len = activity_buffer_size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -276,7 +276,7 @@ bool chirpy_demo_face_loop(movement_event_t event, void *context) {
|
|||||||
else if (state->program == CDP_INFO_SHORT)
|
else if (state->program == CDP_INFO_SHORT)
|
||||||
state->program = CDP_INFO_LONG;
|
state->program = CDP_INFO_LONG;
|
||||||
else if (state->program == CDP_INFO_LONG) {
|
else if (state->program == CDP_INFO_LONG) {
|
||||||
if (nanosec_buffer_size > 0)
|
if (activity_buffer_size > 0)
|
||||||
state->program = CDP_INFO_NANOSEC;
|
state->program = CDP_INFO_NANOSEC;
|
||||||
else
|
else
|
||||||
state->program = CDP_SCALE;
|
state->program = CDP_SCALE;
|
||||||
@ -323,9 +323,9 @@ bool chirpy_demo_face_loop(movement_event_t event, void *context) {
|
|||||||
void chirpy_demo_face_resign(void *context) {
|
void chirpy_demo_face_resign(void *context) {
|
||||||
(void)context;
|
(void)context;
|
||||||
|
|
||||||
if (nanosec_buffer != 0) {
|
if (activity_buffer != 0) {
|
||||||
free(nanosec_buffer);
|
free(activity_buffer);
|
||||||
nanosec_buffer = 0;
|
activity_buffer = 0;
|
||||||
nanosec_buffer_size = 0;
|
activity_buffer_size = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user