]> git.earman.xyz Git - sensor-watch.git/commitdiff
only build sensor features if sensor is available
authorjoeycastillo <joeycastillo@utexas.edu>
Sat, 12 Oct 2024 14:55:10 +0000 (10:55 -0400)
committerjoeycastillo <joeycastillo@utexas.edu>
Sat, 12 Oct 2024 15:16:01 +0000 (11:16 -0400)
15 files changed:
Makefile
gossamer
movement.c
movement_config.h
watch-faces/demo/accel_interrupt_count_face.c
watch-faces/demo/accel_interrupt_count_face.h
watch-faces/demo/light_sensor_face.c
watch-faces/demo/light_sensor_face.h
watch-faces/sensor/temperature_display_face.c
watch-faces/sensor/temperature_display_face.h
watch-faces/sensor/temperature_logging_face.c
watch-faces/sensor/temperature_logging_face.h
watch-library/hardware/watch/watch_i2c.c
watch-library/shared/driver/thermistor_driver.c
watch-library/shared/driver/thermistor_driver.h

index 02be7a1295abc827e5f1798632349ec8d54419a1..80e42b5bafb3927ddb04736041833d2114de4da1 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -17,7 +17,11 @@ TINYUSB_CDC=1
 include $(GOSSAMER_PATH)/make.mk
 
 ifeq ($(SENSOR), MOTION)
-  DEFINES += -DMOTION_BOARD_INSTALLED
+  DEFINES += -DHAS_ACCELEROMETER
+endif
+
+ifeq ($(SENSOR), TEMPERATURE)
+  DEFINES += -DTEMPERATURE_BOARD_INSTALLED
 endif
 
 ifdef EMSCRIPTEN
@@ -58,12 +62,16 @@ 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 \
   ./watch-library/shared/watch/watch_utility.c \
 
+
+ifeq ($(SENSOR), MOTION)
+SRCS += ./watch-library/shared/driver/lis2dw.c
+endif
+
 ifdef EMSCRIPTEN
 
 INCLUDES += \
index 3e036d9ea3e857ea1c1adb3eae7be048dbc0e889..81cf378fb8d49e8ed73cc6c2bac1033df593e53e 160000 (submodule)
--- a/gossamer
+++ b/gossamer
@@ -1 +1 @@
-Subproject commit 3e036d9ea3e857ea1c1adb3eae7be048dbc0e889
+Subproject commit 81cf378fb8d49e8ed73cc6c2bac1033df593e53e
index c1bb9c23e966d447c60cc3c8451808da2a624564..9d219aeb605ce6fa4a111caf29eab0b178b53469 100644 (file)
@@ -74,7 +74,7 @@ void cb_alarm_fired(void);
 void cb_fast_tick(void);
 void cb_tick(void);
 
-#ifdef MOTION_BOARD_INSTALLED
+#ifdef HAS_ACCELEROMETER
 void cb_motion_interrupt_1(void);
 #endif
 
@@ -615,7 +615,7 @@ void app_setup(void) {
         watch_register_interrupt_callback(HAL_GPIO_BTN_LIGHT_pin(), cb_light_btn_interrupt, INTERRUPT_TRIGGER_BOTH);
         watch_register_interrupt_callback(HAL_GPIO_BTN_ALARM_pin(), cb_alarm_btn_interrupt, INTERRUPT_TRIGGER_BOTH);
 
-#ifdef MOTION_BOARD_INSTALLED
+#ifdef HAS_ACCELEROMETER
         watch_enable_i2c();
         if (lis2dw_begin()) {
             lis2dw_set_mode(LIS2DW_MODE_LOW_POWER);         // select low power (not high performance)
@@ -917,7 +917,7 @@ void cb_tick(void) {
     }
 }
 
-#ifdef MOTION_BOARD_INSTALLED
+#ifdef HAS_ACCELEROMETER
 void cb_motion_interrupt_1(void) {
     // TODO: Find out what motion event woke us up.
     printf("INT1\n");
index f2abc311fd3627e9c9e307c335d1d071adcf26c3..49071a880ae06a1b2773b57d4e2b673129d3f54f 100644 (file)
@@ -33,9 +33,7 @@ const watch_face_t watch_faces[] = {
     sunrise_sunset_face,
     countdown_face,
     beats_face,
-    accel_interrupt_count_face,
     voltage_face,
-    temperature_display_face,
     preferences_face,
     set_time_face,
 };
index 5714f0eb62788ae77074c5456440534d98d05af6..921892d63bbd699a57fa661c48af4a9febdb4c95 100644 (file)
@@ -29,6 +29,8 @@
 #include "tc.h"
 #include "watch.h"
 
+#ifdef HAS_ACCELEROMETER
+
 static void _accel_interrupt_count_face_update_display(accel_interrupt_count_state_t *state) {
     (void) state;
     char buf[7];
@@ -119,3 +121,5 @@ movement_watch_face_advisory_t accel_interrupt_count_face_advise(void *context)
 
     return retval;
 }
+
+#endif // HAS_ACCELEROMETER
index 3361976c06c80231c4c2c712268a49b88440a443..70b03ddabc80a5b9b96f583d3fce373a45a7ec7d 100644 (file)
@@ -35,6 +35,8 @@
 #include "movement.h"
 #include "watch.h"
 
+#ifdef HAS_ACCELEROMETER
+
 typedef struct {
     uint8_t new_threshold;
     uint8_t threshold;
@@ -54,3 +56,5 @@ movement_watch_face_advisory_t accel_interrupt_count_face_advise(void *context);
     accel_interrupt_count_face_resign, \
     accel_interrupt_count_face_advise, \
 })
+
+#endif // HAS_ACCELEROMETER
index 29724b15e4e8fdc78f7b3fd16b3c28f10b75540c..c0661193a71b1146100d4e4f9669456827ed76a2 100644 (file)
@@ -22,6 +22,8 @@
  * SOFTWARE.
  */
 
+#ifdef HAS_IR_SENSOR
+
 #include <stdlib.h>
 #include <string.h>
 #include "light_sensor_face.h"
@@ -116,3 +118,5 @@ void light_sensor_face_resign(void *context) {
 
     // handle any cleanup before your watch face goes off-screen.
 }
+
+#endif // HAS_IR_SENSOR
index d7601837e18dce5afcbf49569222d7b6a4ad7b4b..4e4bc608749afd0db1e58a7da6558847059c97c6 100644 (file)
@@ -24,6 +24,8 @@
 
 #pragma once
 
+#ifdef HAS_IR_SENSOR
+
 #include "movement.h"
 
 /*
@@ -50,3 +52,5 @@ void light_sensor_face_resign(void *context);
     light_sensor_face_resign, \
     NULL, \
 })
+
+#endif // HAS_IR_SENSOR
index 9ba21d14ca09e384a31c27b8a3457455dc843833..1fe1dd13c9e80e4ca2d39a54139e85dda61cc949 100644 (file)
@@ -28,6 +28,8 @@
 #include "thermistor_driver.h"
 #include "watch.h"
 
+#ifdef HAS_TEMPERATURE_SENSOR
+
 static void _temperature_display_face_update_display(bool in_fahrenheit) {
     thermistor_driver_enable();
     float temperature_c = thermistor_driver_get_temperature();
@@ -94,3 +96,5 @@ bool temperature_display_face_loop(movement_event_t event, void *context) {
 void temperature_display_face_resign(void *context) {
     (void) context;
 }
+
+#endif
index 1c5fb8d2956d8eb5815a668cf8973165d642d822..6dfdb53a970265699f0bf3590f0dbe7efaea34fd 100644 (file)
  * SOFTWARE.
  */
 
-#ifndef TEMPERATURE_DISPLAY_FACE_H_
-#define TEMPERATURE_DISPLAY_FACE_H_
+#pragma once
+
+#include "pins.h"
+
+#ifdef HAS_TEMPERATURE_SENSOR
 
 /*
  * THERMISTOR READOUT (aka Temperature Display)
@@ -63,4 +66,4 @@ void temperature_display_face_resign(void *context);
     NULL, \
 })
 
-#endif // TEMPERATURE_DISPLAY_FACE_H_
+#endif // HAS_TEMPERATURE_SENSOR
index 227ca8f52d33295b0df61ba43fb025472bf0949f..14ab6336501eaf4e44a93a68420d786273ac8d0b 100644 (file)
@@ -28,6 +28,8 @@
 #include "thermistor_driver.h"
 #include "watch.h"
 
+#ifdef HAS_TEMPERATURE_SENSOR
+
 static void _temperature_logging_face_log_data(thermistor_logger_state_t *logger_state) {
     thermistor_driver_enable();
     watch_date_time_t date_time = watch_rtc_get_date_time();
@@ -148,3 +150,5 @@ movement_watch_face_advisory_t temperature_logging_face_advise(void *context) {
 
     return retval;
 }
+
+#endif
index ecea625d21a7cdb3fbabb0f6e32854bae02533fb..cda44bbc4127cee7e16e0dab3bd32287add07fe1 100644 (file)
  * SOFTWARE.
  */
 
-#ifndef TEMPERATURE_LOGGING_FACE_H_
-#define TEMPERATURE_LOGGING_FACE_H_
+#pragma once
+
+#include "pins.h"
+
+#ifdef HAS_TEMPERATURE_SENSOR
 
 /*
  * THERMISTOR LOGGING (aka Temperature Log)
@@ -84,4 +87,4 @@ movement_watch_face_advisory_t temperature_logging_face_advise(void *context);
     temperature_logging_face_advise, \
 })
 
-#endif // TEMPERATURE_LOGGING_FACE_H_
+#endif // HAS_TEMPERATURE_SENSOR
index 05833304204672ef359d7e736f9afd130a8a820a..709c63b7e7752a561a74fc477d9a1d5f49b61b02 100644 (file)
 #include "watch_i2c.h"
 #include "i2c.h"
 
-void watch_enable_i2c(void) {
-    // NOTE: I2C sensors are not supported on Sensor Watch Lite, so there are no SDA/SCL pin definitions.
-    // This ifdef is here to prevent the build from failing.
 #ifdef I2C_SERCOM
+
+void watch_enable_i2c(void) {
     HAL_GPIO_SDA_pmuxen(HAL_GPIO_PMUX_SERCOM);
     HAL_GPIO_SCL_pmuxen(HAL_GPIO_PMUX_SERCOM);
-#endif
     i2c_init();
     i2c_enable();
 }
@@ -92,3 +90,5 @@ uint32_t watch_i2c_read32(int16_t addr, uint8_t reg) {
 
     return data;
 }
+
+#endif // I2C_SERCOM
index 661f6f148d171bdf3e45f2796d8c17fb2dadbe1b..8a9b20d50511ae3c4a82aae7a6ea7fbe245677b5 100644 (file)
@@ -27,6 +27,8 @@
 #include "watch.h"
 #include "watch_utility.h"
 
+#ifdef HAS_TEMPERATURE_SENSOR
+
 void thermistor_driver_enable(void) {
     // Enable the ADC peripheral, which we'll use to read the thermistor value.
     watch_enable_adc();
@@ -48,15 +50,7 @@ void thermistor_driver_disable(void) {
     // Disable the enable pin's output circuitry.
     HAL_GPIO_TS_ENABLE_off();
 }
-#if __EMSCRIPTEN__
-#include <emscripten.h>
-float thermistor_driver_get_temperature(void)
-{
-    return EM_ASM_DOUBLE({
-        return temp_c || 25.0;
-    });
-}
-#else
+
 float thermistor_driver_get_temperature(void) {
     // set the enable pin to the level that powers the thermistor circuit.
     HAL_GPIO_TS_ENABLE_write(THERMISTOR_ENABLE_VALUE);
@@ -67,4 +61,5 @@ float thermistor_driver_get_temperature(void) {
 
     return watch_utility_thermistor_temperature(value, THERMISTOR_HIGH_SIDE, THERMISTOR_B_COEFFICIENT, THERMISTOR_NOMINAL_TEMPERATURE, THERMISTOR_NOMINAL_RESISTANCE, THERMISTOR_SERIES_RESISTANCE);
 }
-#endif
+
+#endif // HAS_TEMPERATURE_SENSOR
\ No newline at end of file
index 66bec6e931d3110037ed86705914c2047d60db87..e929e8051de28e2ad5d0c690a61e3f4509bdeea1 100644 (file)
  * SOFTWARE.
  */
 
-#ifndef THERMISTOR_DRIVER_H_
-#define THERMISTOR_DRIVER_H_
+#pragma once
+
+#include "pins.h"
+
+#ifdef HAS_TEMPERATURE_SENSOR
 
 // TODO: Do these belong in movement_config.h? In settings we can set on the watch? In an EEPROM configuration area?
 // Think on this. [joey 11/22]
-#define THERMISTOR_SENSE_PIN (A2)
-#define THERMISTOR_ENABLE_PIN (A0)
 #define THERMISTOR_ENABLE_VALUE (false)
 #define THERMISTOR_HIGH_SIDE (true)
 #define THERMISTOR_B_COEFFICIENT (3380.0)
@@ -40,4 +41,4 @@ void thermistor_driver_enable(void);
 void thermistor_driver_disable(void);
 float thermistor_driver_get_temperature(void);
 
-#endif // THERMISTOR_DRIVER_H_
+#endif // HAS_TEMPERATURE_SENSOR