Skip to content

Commit 98dab30

Browse files
committed
Extend sample to also set ManufacturerDate
Make the sample more complete by also setting ManufacturerDate to October 12. 2024 (today). I've already verified that it's possible to retrieve the same date back through IOCTL_BATTERY_QUERY_INFORMATION IOCTL calls on Windows.
1 parent 91f641b commit 98dab30

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

examples/UPS/UPS.ino

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ uint16_t iAvgTimeToEmpty = 7200;
3131
uint16_t iRemainTimeLimit = 600;
3232
int16_t iDelayBe4Reboot = -1;
3333
int16_t iDelayBe4ShutDown = -1;
34-
34+
uint16_t iManufacturerDate = 0; // initialized in setup function
3535
byte iAudibleAlarmCtrl = 2; // 1 - Disabled, 2 - Enabled, 3 - Muted
3636

3737

@@ -92,6 +92,9 @@ void setup() {
9292
PowerDevice.setFeature(HID_PD_CPCTYGRANULARITY1, &bCapacityGranularity1, sizeof(bCapacityGranularity1));
9393
PowerDevice.setFeature(HID_PD_CPCTYGRANULARITY2, &bCapacityGranularity2, sizeof(bCapacityGranularity2));
9494

95+
uint16_t year = 2024, month = 10, day = 12;
96+
iManufacturerDate = (year - 1980)*512 + month*32 + day; // from 4.2.6 Battery Settings in "Universal Serial Bus Usage Tables for HID Power Devices"
97+
PowerDevice.setFeature(HID_PD_MANUFACTUREDATE, &iManufacturerDate, sizeof(iManufacturerDate));
9598
}
9699

97100
void loop() {

0 commit comments

Comments
 (0)