summaryrefslogtreecommitdiffstats
path: root/boiler-monster/stm32/app/temp.c
blob: 4548d01e8e8084200c868a9bd48bad6f48aefb80 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#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];
}