#include "project.h" #define N_SENSORS 2 #define SENSOR_INDEX_CH_RETURN 0 #define SENSOR_INDEX_SUPPLY_INLET 1 static const Onewire_addr s_addr[N_SENSORS] = { [0] = {{0x28, 0x60, 0x06, 0x53, 0x03, 0x00, 0x00, 0xf5}}, [1] = {{0x28, 0xa4, 0x08, 0x53, 0x03, 0x00, 0x00, 0x14}}, }; static int s_temp[N_SENSORS]; static unsigned poke; void temp_tick (void) { static unsigned ticker; ticker++; if (ticker < 3000) return; ticker = 0; poke = 1; } void temp_dispatch (void) { static unsigned sensor; if (!poke) return; poke = 0; if (sensor < N_SENSORS) { if (ds1820_read (&s_addr[sensor], &s_temp[sensor])) s_temp[sensor] = 0; printf ("Q1W: sensor %d temp %d\r\n", sensor, (s_temp[sensor] * 100) / 256); sensor++; } else { #if 0 onewire_search(); #endif } if (sensor == N_SENSORS) sensor = 0; } uint16_t temp_ch_return (void) { return s_temp[SENSOR_INDEX_CH_RETURN]; } uint16_t temp_supply_inlet (void) { return s_temp[SENSOR_INDEX_SUPPLY_INLET]; }