File tree Expand file tree Collapse file tree 3 files changed +66
-0
lines changed Expand file tree Collapse file tree 3 files changed +66
-0
lines changed Original file line number Diff line number Diff line change 1+ import ..protocol as protocol
2+
3+ class CPU2Sleep extends protocol .Data :
4+ static MT := 47
5+ static INTERVAL := 1
6+ static WAKE-ON-EVENT := 2
7+
8+ static do-msg --interval / int --wake-on-event / bool= false -> protocol.Message :
9+ msg := protocol .Message MT
10+ msg .data .add-data-uint32 INTERVAL interval
11+ msg .data .add-data-uint8 WAKE-ON-EVENT ( wake-on-event ? 1 : 0 )
12+ msg .header .data .add-data-uint8 protocol .Header .TYPE-MESSAGE-METHOD protocol .Header .METHOD-DO
13+ return msg
14+
15+ constructor .from-data data / protocol.Data :
16+ super .from-data data
17+
18+ constructor --interval / int --wake-on-event / int :
19+ this .add-data-uint32 INTERVAL interval
20+ this .add-data-uint8 WAKE-ON-EVENT wake-on-event
21+
22+ interval -> int :
23+ return get-data-uint32 INTERVAL
24+
25+ wake-on-event -> int :
26+ return get-data-uint8 WAKE-ON-EVENT
27+
28+ stringify -> string :
29+ return {
30+ "Interval" : interval ,
31+ "Wake on Event" : wake-on-event ,
32+ } .stringify
Original file line number Diff line number Diff line change 1+ import ..protocol as protocol
2+
3+ class PowerProfile extends protocol .Data :
4+ static MT := 48
5+ static TOTAL-POWER := 3
6+ static CURRENT-NOW := 4
7+
8+ static subscribe-msg --interval / int= 300 -> protocol.Message :
9+ msg := protocol .Message MT
10+ msg .header .data .add-data-uint8 protocol .Header .TYPE-MESSAGE-METHOD protocol .Header .METHOD-SUBSCRIBE
11+ msg .header .data .add-data-uint32 protocol .Header .TYPE_SUBSCRIPTION_INTERVAL interval
12+ return msg
13+
14+ static unsubscribe-msg -> protocol.Message :
15+ msg := protocol .Message MT
16+ msg .header .data .add-data-uint8 protocol .Header .TYPE-MESSAGE-METHOD protocol .Header .METHOD-UNSUBSCRIBE
17+ return msg
18+
19+ constructor .from-data data / protocol.Data :
20+ super .from-data data
21+
22+ total-power -> float :
23+ return get-data-float32 TOTAL-POWER
24+
25+ current-now -> float :
26+ return get-data-float32 CURRENT-NOW
27+
28+ stringify -> string :
29+ return {
30+ "Total Power" : total-power ,
31+ "Current Now" : current-now ,
32+ } .stringify
Original file line number Diff line number Diff line change @@ -16,6 +16,8 @@ import .m43-battery-status show BatteryStatus
1616import .m44-pressure show Pressure
1717import .m45-alarm-control show AlarmControl
1818import .m46-buzzer-sequence show BuzzerSequence
19+ import .m47-cpu2-sleep show CPU2Sleep
20+ import .m48-power-profile show PowerProfile
1921import .m50-link-control show LinkControl
2022import .m1004-lora show Lora
2123import .m10008-preset-page show PresetPage
You can’t perform that action at this time.
0 commit comments