diff --git a/Makefile b/Makefile index 02be7a12..80e42b5b 100644 --- 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 += \ diff --git a/gossamer b/gossamer index 3e036d9e..81cf378f 160000 --- a/gossamer +++ b/gossamer @@ -1 +1 @@ -Subproject commit 3e036d9ea3e857ea1c1adb3eae7be048dbc0e889 +Subproject commit 81cf378fb8d49e8ed73cc6c2bac1033df593e53e diff --git a/movement.c b/movement.c index c1bb9c23..9d219aeb 100644 --- a/movement.c +++ b/movement.c @@ -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"); diff --git a/movement_config.h b/movement_config.h index f2abc311..49071a88 100644 --- a/movement_config.h +++ b/movement_config.h @@ -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, }; diff --git a/watch-faces/demo/accel_interrupt_count_face.c b/watch-faces/demo/accel_interrupt_count_face.c index 5714f0eb..921892d6 100644 --- a/watch-faces/demo/accel_interrupt_count_face.c +++ b/watch-faces/demo/accel_interrupt_count_face.c @@ -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 diff --git a/watch-faces/demo/accel_interrupt_count_face.h b/watch-faces/demo/accel_interrupt_count_face.h index 3361976c..70b03dda 100644 --- a/watch-faces/demo/accel_interrupt_count_face.h +++ b/watch-faces/demo/accel_interrupt_count_face.h @@ -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 diff --git a/watch-faces/demo/light_sensor_face.c b/watch-faces/demo/light_sensor_face.c index 29724b15..c0661193 100644 --- a/watch-faces/demo/light_sensor_face.c +++ b/watch-faces/demo/light_sensor_face.c @@ -22,6 +22,8 @@ * SOFTWARE. */ +#ifdef HAS_IR_SENSOR + #include #include #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 diff --git a/watch-faces/demo/light_sensor_face.h b/watch-faces/demo/light_sensor_face.h index d7601837..4e4bc608 100644 --- a/watch-faces/demo/light_sensor_face.h +++ b/watch-faces/demo/light_sensor_face.h @@ -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 diff --git a/watch-faces/sensor/temperature_display_face.c b/watch-faces/sensor/temperature_display_face.c index 9ba21d14..1fe1dd13 100644 --- a/watch-faces/sensor/temperature_display_face.c +++ b/watch-faces/sensor/temperature_display_face.c @@ -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 diff --git a/watch-faces/sensor/temperature_display_face.h b/watch-faces/sensor/temperature_display_face.h index 1c5fb8d2..6dfdb53a 100644 --- a/watch-faces/sensor/temperature_display_face.h +++ b/watch-faces/sensor/temperature_display_face.h @@ -22,8 +22,11 @@ * 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 diff --git a/watch-faces/sensor/temperature_logging_face.c b/watch-faces/sensor/temperature_logging_face.c index 227ca8f5..14ab6336 100644 --- a/watch-faces/sensor/temperature_logging_face.c +++ b/watch-faces/sensor/temperature_logging_face.c @@ -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 diff --git a/watch-faces/sensor/temperature_logging_face.h b/watch-faces/sensor/temperature_logging_face.h index ecea625d..cda44bbc 100644 --- a/watch-faces/sensor/temperature_logging_face.h +++ b/watch-faces/sensor/temperature_logging_face.h @@ -22,8 +22,11 @@ * 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 diff --git a/watch-library/hardware/watch/watch_i2c.c b/watch-library/hardware/watch/watch_i2c.c index 05833304..709c63b7 100644 --- a/watch-library/hardware/watch/watch_i2c.c +++ b/watch-library/hardware/watch/watch_i2c.c @@ -25,13 +25,11 @@ #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 diff --git a/watch-library/shared/driver/thermistor_driver.c b/watch-library/shared/driver/thermistor_driver.c index 661f6f14..8a9b20d5 100644 --- a/watch-library/shared/driver/thermistor_driver.c +++ b/watch-library/shared/driver/thermistor_driver.c @@ -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 -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 diff --git a/watch-library/shared/driver/thermistor_driver.h b/watch-library/shared/driver/thermistor_driver.h index 66bec6e9..e929e805 100644 --- a/watch-library/shared/driver/thermistor_driver.h +++ b/watch-library/shared/driver/thermistor_driver.h @@ -22,13 +22,14 @@ * 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