only build sensor features if sensor is available
This commit is contained in:
parent
378ba85b58
commit
4795818098
12
Makefile
12
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 += \
|
||||
|
||||
2
gossamer
2
gossamer
@ -1 +1 @@
|
||||
Subproject commit 3e036d9ea3e857ea1c1adb3eae7be048dbc0e889
|
||||
Subproject commit 81cf378fb8d49e8ed73cc6c2bac1033df593e53e
|
||||
@ -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");
|
||||
|
||||
@ -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,
|
||||
};
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user