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
./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 += \
-Subproject commit 3e036d9ea3e857ea1c1adb3eae7be048dbc0e889
+Subproject commit 81cf378fb8d49e8ed73cc6c2bac1033df593e53e
void cb_fast_tick(void);
void cb_tick(void);
-#ifdef MOTION_BOARD_INSTALLED
+#ifdef HAS_ACCELEROMETER
void cb_motion_interrupt_1(void);
#endif
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)
}
}
-#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");
sunrise_sunset_face,
countdown_face,
beats_face,
- accel_interrupt_count_face,
voltage_face,
- temperature_display_face,
preferences_face,
set_time_face,
};
#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];
return retval;
}
+
+#endif // HAS_ACCELEROMETER
#include "movement.h"
#include "watch.h"
+#ifdef HAS_ACCELEROMETER
+
typedef struct {
uint8_t new_threshold;
uint8_t threshold;
accel_interrupt_count_face_resign, \
accel_interrupt_count_face_advise, \
})
+
+#endif // HAS_ACCELEROMETER
* SOFTWARE.
*/
+#ifdef HAS_IR_SENSOR
+
#include <stdlib.h>
#include <string.h>
#include "light_sensor_face.h"
// handle any cleanup before your watch face goes off-screen.
}
+
+#endif // HAS_IR_SENSOR
#pragma once
+#ifdef HAS_IR_SENSOR
+
#include "movement.h"
/*
light_sensor_face_resign, \
NULL, \
})
+
+#endif // HAS_IR_SENSOR
#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();
void temperature_display_face_resign(void *context) {
(void) context;
}
+
+#endif
* 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)
NULL, \
})
-#endif // TEMPERATURE_DISPLAY_FACE_H_
+#endif // HAS_TEMPERATURE_SENSOR
#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();
return retval;
}
+
+#endif
* 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)
temperature_logging_face_advise, \
})
-#endif // TEMPERATURE_LOGGING_FACE_H_
+#endif // HAS_TEMPERATURE_SENSOR
#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();
}
return data;
}
+
+#endif // I2C_SERCOM
#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();
// 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);
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
* 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)
void thermistor_driver_disable(void);
float thermistor_driver_get_temperature(void);
-#endif // THERMISTOR_DRIVER_H_
+#endif // HAS_TEMPERATURE_SENSOR