-
Notifications
You must be signed in to change notification settings - Fork 20
/
temp_dummy.c
51 lines (44 loc) · 971 Bytes
/
temp_dummy.c
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
#include "temp.h"
/**
This driver implements eight fancy sawtooth-ish pseudo reading.
It oscillates between -5 and 45 °C.
*/
static uint8_t updown;
static uint8_t delay;
static uint16_t val[8];
void temp_init_dummy(void)
{
updown = 0;
}
void temp_setup_dummy(uint8_t dev)
{
val[dev&7] = (20+dev)<<5; // start with different values
}
int16_t temp_poll_dummy(uint8_t dev)
{
uint8_t p = (dev&7);
uint8_t mp = 1<<p;
int16_t v = val[p];
#if 0
if (dev > 7) {
if (delay & mp)
delay &=~ mp;
else {
delay |= mp;
return TEMP_AGAIN;
}
}
#endif
if (updown & mp) {
v += 1<<3; // 0.25K
if (v > 45<<5)
updown &=~ mp;
} else {
//v -= ((dev>>3)+1)<<2; // downspeed depends on devnum's high bits
v -= 1<<2; // downspeed depends on devnum's high bits
if (v < (-5)<<5)
updown |= mp;
}
val[p] = v;
return v;
}