Skip to content

Commit e114efb

Browse files
committed
Remove Fully(Dis)Charged flags to simplify.
1 parent 75cd5cd commit e114efb

File tree

3 files changed

+5
-23
lines changed

3 files changed

+5
-23
lines changed

examples/UPS/UPS.ino

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ void loop() {
7878
// Charging
7979
iPresentStatus.Charging = bCharging;
8080
iPresentStatus.ACPresent = bCharging; // assume charging implies AC present
81-
iPresentStatus.FullyCharged = (iRemaining == iFullChargeCapacity);
8281

8382
// Discharging
8483
if(!bCharging) { // assume not charging implies discharging

src/HIDPowerDevice.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,7 @@ static const uint8_t _hidReportDescriptor[] PROGMEM = {
122122
0x81, 0xA3, // INPUT (Constant, Variable, Absolute, No Wrap, Linear, No Preferred, No Null Position, Bitfield)
123123
0x09, 0xDB, // USAGE (VoltageNotRegulated)
124124
0xB1, 0xA3, // FEATURE (Constant, Variable, Absolute, No Wrap, Linear, No Preferred, No Null Position, Volatile, Bitfield)
125-
0x09, 0x46, // USAGE (FullyCharged)
126-
0x81, 0xA3, // INPUT (Constant, Variable, Absolute, No Wrap, Linear, No Preferred, No Null Position, Bitfield)
127-
0x09, 0x46, // USAGE (FullyCharged)
128-
0xB1, 0xA3, // FEATURE (Constant, Variable, Absolute, No Wrap, Linear, No Preferred, No Null Position, Volatile, Bitfield)
129-
0x09, 0x47, // USAGE (FullyDischarged)
130-
0x81, 0xA3, // INPUT (Constant, Variable, Absolute, No Wrap, Linear, No Preferred, No Null Position, Bitfield)
131-
0x09, 0x47, // USAGE (FullyDischarged)
132-
0xB1, 0xA3, // FEATURE (Constant, Variable, Absolute, No Wrap, Linear, No Preferred, No Null Position, Volatile, Bitfield)
133-
0x95, 0x07, // REPORT_COUNT (7) // padding bits to make the report byte aligned
125+
0x95, 0x01, // REPORT_COUNT (1) // padding bits to make the report byte aligned
134126
0x81, 0x01, // INPUT (Constant, Array, Absolute)
135127
0xB1, 0x01, // FEATURE (Constant, Array, Absolute, No Wrap, Linear, Preferred State, No Null Position, Nonvolatile, Bitfield)
136128
0xC0, // END_COLLECTION

src/HIDPowerDevice.h

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -64,22 +64,13 @@ struct PresentStatus {
6464
uint8_t RemainingTimeLimitExpired : 1; // bit 0x04
6565
uint8_t NeedReplacement : 1; // bit 0x05
6666
uint8_t VoltageNotRegulated : 1; // bit 0x06
67-
uint8_t FullyCharged : 1; // bit 0x07
67+
uint8_t unused1 : 1; // bit 0x07
6868

69-
uint8_t FullyDischarged : 1; // bit 0x08
70-
uint8_t unused1 : 1;
71-
uint8_t unused2 : 1;
72-
uint8_t unused3 : 1;
73-
uint8_t unused4 : 1;
74-
uint8_t unused5 : 1;
75-
uint8_t unused6 : 1;
76-
uint8_t unused7 : 1;
77-
78-
operator uint16_t () {
79-
return *(uint16_t*)(this); // switch to std::bit_cast after migrating to C++20
69+
operator uint8_t () {
70+
return *(uint8_t*)(this); // switch to std::bit_cast after migrating to C++20
8071
}
8172
};
82-
static_assert(sizeof(PresentStatus) == sizeof(uint16_t));
73+
static_assert(sizeof(PresentStatus) == sizeof(uint8_t));
8374

8475

8576

0 commit comments

Comments
 (0)