mirror of
https://github.com/soypat/lora.git
synced 2026-08-19 12:03:55 +00:00
add tests for power management
This commit is contained in:
@@ -58,3 +58,24 @@ func TestTimeOnAir(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestTemperature(t *testing.T) {
|
||||
for _, cs := range []struct {
|
||||
tempVal uint8
|
||||
expect uint8
|
||||
celsius int
|
||||
}{
|
||||
{tempVal: 63, expect: 0, celsius: -40},
|
||||
{tempVal: 33, expect: 36, celsius: -15},
|
||||
{tempVal: 0, expect: 100, celsius: 15},
|
||||
{tempVal: 245, expect: 128, celsius: 10},
|
||||
{tempVal: 211, expect: 220, celsius: 55},
|
||||
{tempVal: 181, expect: 255, celsius: 85},
|
||||
} {
|
||||
val := cs.tempVal
|
||||
val -= 64
|
||||
val = uint8(255 - 14*uint16(val)/8)
|
||||
// val += 128
|
||||
t.Errorf("regTemp=%d val=%d expect=%d celsius=%d", cs.tempVal, val, cs.expect, cs.celsius)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user