summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoey Castillo <jose.castillo@gmail.com>2021-10-21 17:28:59 -0400
committerJoey Castillo <jose.castillo@gmail.com>2021-10-21 17:28:59 -0400
commitf1a706792e995f45b6b6f2ef70b2318253002249 (patch)
treef39b0640cbd40fe85105112decd19929af59c53e
parent4df23ea9f9292ab9371302f69e5192b91cbce620 (diff)
downloadSensor-Watch-f1a706792e995f45b6b6f2ef70b2318253002249.tar.gz
Sensor-Watch-f1a706792e995f45b6b6f2ef70b2318253002249.tar.bz2
Sensor-Watch-f1a706792e995f45b6b6f2ef70b2318253002249.zip
movement: add character set demo
-rwxr-xr-xmovement/make/Makefile2
-rw-r--r--movement/movement_config.h1
-rw-r--r--movement/watch_faces/demos/character_set_face.c51
-rw-r--r--movement/watch_faces/demos/character_set_face.h19
-rw-r--r--watch-library/watch/watch_slcd.c1
5 files changed, 74 insertions, 0 deletions
diff --git a/movement/make/Makefile b/movement/make/Makefile
index 2ed06d96..b65d1a47 100755
--- a/movement/make/Makefile
+++ b/movement/make/Makefile
@@ -15,6 +15,7 @@ INCLUDES += \
-I../watch_faces/settings/ \
-I../watch_faces/complications/ \
-I../watch_faces/thermistor/ \
+ -I../watch_faces/demos/ \
# If you add any other source files you wish to compile, add them after ../app.c
# Note that you will need to add a backslash at the end of any line you wish to continue, i.e.
@@ -30,6 +31,7 @@ SRCS += \
../watch_faces/complications/pulsometer_face.c \
../watch_faces/thermistor/thermistor_driver.c \
../watch_faces/thermistor/thermistor_readout_face.c \
+ ../watch_faces/demos/character_set_face.c \
# Leave this line at the bottom of the file; it has all the targets for making your project.
include $(TOP)/rules.mk
diff --git a/movement/movement_config.h b/movement/movement_config.h
index 92539a3f..99bffdd2 100644
--- a/movement/movement_config.h
+++ b/movement/movement_config.h
@@ -6,6 +6,7 @@
#include "set_time_face.h"
#include "pulsometer_face.h"
#include "thermistor_readout_face.h"
+#include "character_set_face.h"
const watch_face_t watch_faces[] = {
simple_clock_face,
diff --git a/movement/watch_faces/demos/character_set_face.c b/movement/watch_faces/demos/character_set_face.c
new file mode 100644
index 00000000..7daea5a9
--- /dev/null
+++ b/movement/watch_faces/demos/character_set_face.c
@@ -0,0 +1,51 @@
+#include <stdlib.h>
+#include <string.h>
+#include "character_set_face.h"
+#include "watch.h"
+
+void character_set_face_setup(movement_settings_t *settings, void ** context_ptr) {
+ (void) settings;
+ if (*context_ptr == NULL) *context_ptr = malloc(sizeof(char));
+}
+
+void character_set_face_activate(movement_settings_t *settings, void *context) {
+ (void) settings;
+ char *c = (char *)context;
+ *c = '@';
+}
+
+bool character_set_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
+ (void) settings;
+ char *c = (char *)context;
+ char buf[11];
+ switch (event.event_type) {
+ case EVENT_MODE_BUTTON_UP:
+ movement_move_to_next_face();
+ break;
+ case EVENT_LIGHT_BUTTON_DOWN:
+ movement_illuminate_led();
+ break;
+ case EVENT_ALARM_BUTTON_UP:
+ *c = (*c) + 1;
+ if (*c & 0x80) *c = ' ';
+ // fall through
+ case EVENT_ACTIVATE:
+ sprintf(buf, "%c%c%c%c%c%c%c%c%c%c", *c, *c, *c, *c, *c, *c, *c, *c, *c, *c);
+ watch_display_string(buf, 0);
+ break;
+ case EVENT_TICK:
+ break;
+ case EVENT_TIMEOUT:
+ movement_move_to_face(0);
+ break;
+ default:
+ break;
+ }
+
+ return true;
+}
+
+void character_set_face_resign(movement_settings_t *settings, void *context) {
+ (void) settings;
+ (void) context;
+}
diff --git a/movement/watch_faces/demos/character_set_face.h b/movement/watch_faces/demos/character_set_face.h
new file mode 100644
index 00000000..b27a8359
--- /dev/null
+++ b/movement/watch_faces/demos/character_set_face.h
@@ -0,0 +1,19 @@
+#ifndef CHARACTER_SET_FACE_H_
+#define CHARACTER_SET_FACE_H_
+
+#include "movement.h"
+
+void character_set_face_setup(movement_settings_t *settings, void ** context_ptr);
+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
+};
+
+#endif // CHARACTER_SET_FACE_H_ \ No newline at end of file
diff --git a/watch-library/watch/watch_slcd.c b/watch-library/watch/watch_slcd.c
index 6c63d966..63ba7988 100644
--- a/watch-library/watch/watch_slcd.c
+++ b/watch-library/watch/watch_slcd.c
@@ -204,6 +204,7 @@ void watch_display_character(uint8_t character, uint8_t position) {
}
if (character == 'T' && position == 1) slcd_sync_seg_on(&SEGMENT_LCD_0, SLCD_SEGID(1, 12)); // add descender
else if (position == 0 && (character == 'B' || character == 'D')) slcd_sync_seg_on(&SEGMENT_LCD_0, SLCD_SEGID(0, 15)); // add funky ninth segment
+ else if (position == 0 && (character == 'B' || character == 'D' || character == '@')) slcd_sync_seg_on(&SEGMENT_LCD_0, SLCD_SEGID(0, 15)); // add funky ninth segment
}
void watch_display_string(char *string, uint8_t position) {