Skip to content

Commit 3060efa

Browse files
committed
Update PresentStatus fields to match usage names
Change casing and spell out the PresentStatus fields, so that they matches the corresponding HID usage names in HIDPowerDevice.cpp. Done to make the code a bit easier to follow.
1 parent 563febd commit 3060efa

File tree

2 files changed

+29
-29
lines changed

2 files changed

+29
-29
lines changed

examples/UPS/UPS.ino

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -110,43 +110,43 @@ void loop() {
110110
iRunTimeToEmpty = (uint16_t)round((float)iAvgTimeToEmpty*iRemaining/100);
111111

112112
// Charging
113-
iPresentStatus.CHARGING = bCharging;
114-
iPresentStatus.ACPRESENT = bACPresent;
115-
iPresentStatus.FULLCHARGE = (iRemaining == iFullChargeCapacity);
113+
iPresentStatus.Charging = bCharging;
114+
iPresentStatus.ACPresent = bACPresent;
115+
iPresentStatus.FullyCharged = (iRemaining == iFullChargeCapacity);
116116

117117
// Discharging
118118
if(bDischarging) {
119-
iPresentStatus.DISCHARGING = 1;
120-
// if(iRemaining < iRemnCapacityLimit) iPresentStatus.BELOWRCL = 1;
119+
iPresentStatus.Discharging = 1;
120+
// if(iRemaining < iRemnCapacityLimit) iPresentStatus.BelowRemainingCapacityLimit = 1;
121121

122-
iPresentStatus.RTLEXPIRED = (iRunTimeToEmpty < iRemainTimeLimit);
122+
iPresentStatus.RemainingTimeLimitExpired = (iRunTimeToEmpty < iRemainTimeLimit);
123123

124124
}
125125
else {
126-
iPresentStatus.DISCHARGING = 0;
127-
iPresentStatus.RTLEXPIRED = 0;
126+
iPresentStatus.Discharging = 0;
127+
iPresentStatus.RemainingTimeLimitExpired = 0;
128128
}
129129

130130
// Shutdown requested
131131
if(iDelayBe4ShutDown > 0 ) {
132-
iPresentStatus.SHUTDOWNREQ = 1;
132+
iPresentStatus.ShutdownRequested = 1;
133133
Serial.println("shutdown requested");
134134
}
135135
else
136-
iPresentStatus.SHUTDOWNREQ = 0;
136+
iPresentStatus.ShutdownRequested = 0;
137137

138138
// Shutdown imminent
139-
if((iPresentStatus.SHUTDOWNREQ) ||
140-
(iPresentStatus.RTLEXPIRED)) {
141-
iPresentStatus.SHUTDOWNIMNT = 1;
139+
if((iPresentStatus.ShutdownRequested) ||
140+
(iPresentStatus.RemainingTimeLimitExpired)) {
141+
iPresentStatus.ShutdownImminent = 1;
142142
Serial.println("shutdown imminent");
143143
}
144144
else
145-
iPresentStatus.SHUTDOWNIMNT = 0;
145+
iPresentStatus.ShutdownImminent = 0;
146146

147147

148148

149-
iPresentStatus.BATTPRESENT = 1;
149+
iPresentStatus.BatteryPresent = 1;
150150

151151

152152

src/HIDPowerDevice.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -74,21 +74,21 @@
7474

7575
// PresentStatus dynamic flags
7676
struct PresentStatus {
77-
uint8_t CHARGING : 1; // bit 0x00
78-
uint8_t DISCHARGING : 1; // bit 0x01
79-
uint8_t ACPRESENT : 1; // bit 0x02
80-
uint8_t BATTPRESENT : 1; // bit 0x03
81-
uint8_t BELOWRCL : 1; // bit 0x04
82-
uint8_t RTLEXPIRED : 1; // bit 0x05
83-
uint8_t NEEDREPLACE : 1; // bit 0x06
84-
uint8_t VOLTAGENR : 1; // bit 0x07
77+
uint8_t Charging : 1; // bit 0x00
78+
uint8_t Discharging : 1; // bit 0x01
79+
uint8_t ACPresent : 1; // bit 0x02
80+
uint8_t BatteryPresent : 1; // bit 0x03
81+
uint8_t BelowRemainingCapacityLimit : 1;// bit 0x04
82+
uint8_t RemainingTimeLimitExpired : 1; // bit 0x05
83+
uint8_t NeedReplacement : 1; // bit 0x06
84+
uint8_t VoltageNotRegulated : 1; // bit 0x07
8585

86-
uint8_t FULLCHARGE : 1; // bit 0x08
87-
uint8_t FULLDISCHARGE : 1;// bit 0x09
88-
uint8_t SHUTDOWNREQ : 1; // bit 0x0A
89-
uint8_t SHUTDOWNIMNT : 1; // bit 0x0B
90-
uint8_t COMMLOST : 1; // bit 0x0C
91-
uint8_t OVERLOAD : 1; // bit 0x0D
86+
uint8_t FullyCharged : 1; // bit 0x08
87+
uint8_t FullyDischarged : 1; // bit 0x09
88+
uint8_t ShutdownRequested : 1; // bit 0x0A
89+
uint8_t ShutdownImminent : 1; // bit 0x0B
90+
uint8_t CommunicationLost : 1; // bit 0x0C
91+
uint8_t Overload : 1; // bit 0x0D
9292
uint8_t unused1 : 1;
9393
uint8_t unused2 : 1;
9494

0 commit comments

Comments
 (0)