only build sensor features if sensor is available
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user