summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorJoey Castillo <joeycastillo@utexas.edu>2022-08-03 10:57:39 -0700
committerJoey Castillo <joeycastillo@utexas.edu>2022-08-03 10:57:39 -0700
commit0c8a81bb5df099210c531bb793479403fab319b9 (patch)
tree9364ed8102f6f25c4447fdbc1260717c27f23a65 /apps
parentcc4275694be97f365096eefb9b7513b41bcfdcd4 (diff)
parente790a025787e0e1aa59b98b95e194cf4318d1578 (diff)
downloadSensor-Watch-0c8a81bb5df099210c531bb793479403fab319b9.tar.gz
Sensor-Watch-0c8a81bb5df099210c531bb793479403fab319b9.tar.bz2
Sensor-Watch-0c8a81bb5df099210c531bb793479403fab319b9.zip
Merge branch 'main' of github.com:joeycastillo/Sensor-Watch into totp-lfstotp-lfs
Diffstat (limited to 'apps')
-rw-r--r--apps/functional-test/app.c104
-rw-r--r--apps/sensor-board-test/app.c75
-rwxr-xr-xapps/sensor-board-test/make/Makefile10
3 files changed, 121 insertions, 68 deletions
diff --git a/apps/functional-test/app.c b/apps/functional-test/app.c
index b4ee0412..179bea8b 100644
--- a/apps/functional-test/app.c
+++ b/apps/functional-test/app.c
@@ -2,15 +2,6 @@
#include <string.h>
#include "watch.h"
-bool even = false;
-bool beep = false;
-uint32_t i = 0;
-
-static void cb_tick(void) {
- beep = true;
- even = !even;
-}
-
void app_init(void) {
}
@@ -22,30 +13,14 @@ void app_setup(void) {
watch_enable_buzzer();
- watch_enable_digital_output(A0);
- watch_enable_digital_output(SCL);
- watch_enable_digital_output(SDA);
- watch_enable_digital_output(A1);
- watch_enable_digital_output(A2);
- watch_enable_digital_output(A3);
- watch_enable_digital_output(A4);
-
+ watch_enable_digital_output(RED);
+ watch_enable_digital_output(GREEN);
watch_enable_digital_input(BTN_ALARM);
watch_enable_digital_input(BTN_LIGHT);
watch_enable_digital_input(BTN_MODE);
watch_enable_pull_down(BTN_ALARM);
watch_enable_pull_down(BTN_LIGHT);
watch_enable_pull_down(BTN_MODE);
-
- watch_set_pin_level(A0, false);
- watch_set_pin_level(SCL, false);
- watch_set_pin_level(SDA, false);
- watch_set_pin_level(A1, false);
- watch_set_pin_level(A2, false);
- watch_set_pin_level(A3, false);
- watch_set_pin_level(A4, false);
-
- watch_rtc_register_periodic_callback(cb_tick, 2);
}
void app_prepare_for_standby(void) {
@@ -55,51 +30,44 @@ void app_wake_from_standby(void) {
}
bool app_loop(void) {
- char buf[14];
+ static int last_button = 0;
+ static int button = 0;
+ static int8_t loop = 0;
- if (beep) watch_buzzer_play_note(BUZZER_NOTE_E5, 100);
-
- if (even) {
- printf("Flashing even lights\n");
- #ifdef WATCH_SWAP_LED_PINS
- sprintf(buf, "WT%2d'blu_E", (uint8_t)(i++ % 40));
- #else
- sprintf(buf, "WT%2d'Grn_E", (uint8_t)(i++ % 40));
- #endif
- watch_set_led_green();
- watch_set_pin_level(A0, true);
- watch_set_pin_level(SCL, false);
- watch_set_pin_level(SDA, true);
- watch_set_pin_level(A1, false);
- watch_set_pin_level(A2, true);
- watch_set_pin_level(A3, false);
- watch_set_pin_level(A4, true);
- } else {
- printf("Flashing odd lights\n");
- sprintf(buf, "WT%2d-red~O", (uint8_t)(i++ % 40));
- watch_display_string(buf, 0);
- watch_set_led_red();
- watch_set_pin_level(A0, false);
- watch_set_pin_level(SCL, true);
- watch_set_pin_level(SDA, false);
- watch_set_pin_level(A1, true);
- watch_set_pin_level(A2, false);
- watch_set_pin_level(A3, true);
- watch_set_pin_level(A4, false);
- }
+ watch_set_pin_level(GREEN, false);
+ watch_set_pin_level(RED, false);
if (watch_get_pin_level(BTN_ALARM)) {
- buf[2] = 'a';
- buf[3] = 'L';
+ watch_set_pin_level(GREEN, true);
+ button = 1;
+ } else if (watch_get_pin_level(BTN_LIGHT)) {
+ watch_set_pin_level(RED, true);
+ button = 2;
+ } else if (watch_get_pin_level(BTN_MODE)) {
+ watch_set_pin_level(GREEN, true);
+ watch_set_pin_level(RED, true);
+ button = 3;
}
- if (watch_get_pin_level(BTN_LIGHT)) {
- buf[2] = '1';
- buf[3] = 'i';
+
+ if (button != last_button) {
+ last_button = button;
+ watch_buzzer_play_note(BUZZER_NOTE_C8, 100);
}
- if (watch_get_pin_level(BTN_MODE)) {
- buf[2] = '-';
- buf[3] = 'O';
+
+ static const bool segmap[3][24] = {
+ //0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
+ {0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0},
+ {0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1},
+ {1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1}
+ };
+
+ for(int com = 0; com < 3; com++) {
+ for(int seg = 0; seg < 24; seg++) {
+ if (segmap[com][seg]) (loop >= 0) ? watch_set_pixel(com, seg) : watch_clear_pixel(com, seg);
+ else (loop < 0) ? watch_set_pixel(com, seg) : watch_clear_pixel(com, seg);
+ }
}
- watch_display_string(buf, 0);
- return true;
+ loop++;
+
+ return false;
}
diff --git a/apps/sensor-board-test/app.c b/apps/sensor-board-test/app.c
new file mode 100644
index 00000000..d7da190a
--- /dev/null
+++ b/apps/sensor-board-test/app.c
@@ -0,0 +1,75 @@
+#include <stdio.h>
+#include <string.h>
+#include "watch.h"
+
+bool even = false;
+
+static void cb_tick(void) {
+ even = !even;
+}
+
+void app_init(void) {
+}
+
+void app_wake_from_backup(void) {
+}
+
+void app_setup(void) {
+ watch_enable_digital_output(RED);
+ watch_enable_digital_output(GREEN);
+ watch_enable_digital_output(A0);
+ watch_enable_digital_output(SCL);
+ watch_enable_digital_output(SDA);
+ watch_enable_digital_output(A1);
+ watch_enable_digital_output(A2);
+ watch_enable_digital_output(A3);
+ watch_enable_digital_output(A4);
+
+ watch_set_pin_level(A0, false);
+ watch_set_pin_level(SCL, false);
+ watch_set_pin_level(SDA, false);
+ watch_set_pin_level(A1, false);
+ watch_set_pin_level(A2, false);
+ watch_set_pin_level(A3, false);
+ watch_set_pin_level(A4, false);
+
+ watch_rtc_register_periodic_callback(cb_tick, 2);
+}
+
+void app_prepare_for_standby(void) {
+}
+
+void app_wake_from_standby(void) {
+}
+
+bool app_loop(void) {
+ watch_date_time date_time = watch_rtc_get_date_time();
+ char buf[16];
+ sprintf(buf, "%2d:%02d:%02d: ", date_time.unit.hour, date_time.unit.minute, date_time.unit.second);
+ printf(buf);
+ if (even) {
+ printf("Even\n");
+ watch_set_pin_level(RED, false);
+ watch_set_pin_level(GREEN, true);
+ watch_set_pin_level(A0, true);
+ watch_set_pin_level(SCL, false);
+ watch_set_pin_level(SDA, true);
+ watch_set_pin_level(A1, false);
+ watch_set_pin_level(A2, true);
+ watch_set_pin_level(A3, false);
+ watch_set_pin_level(A4, true);
+ } else {
+ printf("Odd\n");
+ watch_set_pin_level(RED, true);
+ watch_set_pin_level(GREEN, false);
+ watch_set_pin_level(A0, false);
+ watch_set_pin_level(SCL, true);
+ watch_set_pin_level(SDA, false);
+ watch_set_pin_level(A1, true);
+ watch_set_pin_level(A2, false);
+ watch_set_pin_level(A3, true);
+ watch_set_pin_level(A4, false);
+ }
+
+ return true;
+}
diff --git a/apps/sensor-board-test/make/Makefile b/apps/sensor-board-test/make/Makefile
new file mode 100755
index 00000000..c66ad20c
--- /dev/null
+++ b/apps/sensor-board-test/make/Makefile
@@ -0,0 +1,10 @@
+TOP = ../../..
+include $(TOP)/make.mk
+
+INCLUDES += \
+ -I../
+
+SRCS += \
+ ../app.c
+
+include $(TOP)/rules.mk