From 2ce80356fb8dc3d26cc0399cbf517c25cb102913 Mon Sep 17 00:00:00 2001 From: Fredrik Orderud Date: Mon, 9 Sep 2024 11:00:17 +0200 Subject: [PATCH 1/3] Remove unreferenced and empty HIDPowerDevice_::end Proposal to simplify the implementation by removing dead code. --- src/HIDPowerDevice.cpp | 3 --- src/HIDPowerDevice.h | 3 --- 2 files changed, 6 deletions(-) diff --git a/src/HIDPowerDevice.cpp b/src/HIDPowerDevice.cpp index 5217e04..06d7acf 100755 --- a/src/HIDPowerDevice.cpp +++ b/src/HIDPowerDevice.cpp @@ -246,9 +246,6 @@ void HIDPowerDevice_::setSerial(const char* s) { HID().setSerial(s); } -void HIDPowerDevice_::end(void) { -} - int HIDPowerDevice_::sendDate(uint16_t id, uint16_t year, uint8_t month, uint8_t day) { uint16_t bval = (year - 1980)*512 + month * 32 + day; return HID().SendReport(id, &bval, sizeof (bval)); diff --git a/src/HIDPowerDevice.h b/src/HIDPowerDevice.h index 888b860..3447f52 100755 --- a/src/HIDPowerDevice.h +++ b/src/HIDPowerDevice.h @@ -118,9 +118,6 @@ class HIDPowerDevice_ { void setSerial(const char*); - - void end(void); - int sendDate(uint16_t id, uint16_t year, uint8_t month, uint8_t day); int sendReport(uint16_t id, const void* bval, int len); From 6079ef1e8a0da3079755f304f03dacbfb92f2da0 Mon Sep 17 00:00:00 2001 From: Fredrik Orderud Date: Mon, 9 Sep 2024 11:02:29 +0200 Subject: [PATCH 2/3] Remove empty HID_::begin method Proposal to simplify the implementation by removing dead code. --- src/HID/HID.cpp | 5 ----- src/HID/HID.h | 1 - src/HIDPowerDevice.cpp | 2 -- 3 files changed, 8 deletions(-) diff --git a/src/HID/HID.cpp b/src/HID/HID.cpp index e9b969a..49152c9 100644 --- a/src/HID/HID.cpp +++ b/src/HID/HID.cpp @@ -263,9 +263,4 @@ HID_::HID_(void) : PluggableUSBModule(2, 1, epType), PluggableUSB().plug(this); } -int HID_::begin(void) -{ - return 0; -} - #endif /* if defined(USBCON) */ diff --git a/src/HID/HID.h b/src/HID/HID.h index bb55aa2..3eb7f08 100644 --- a/src/HID/HID.h +++ b/src/HID/HID.h @@ -114,7 +114,6 @@ class HID_ : public PluggableUSBModule { public: HID_(void); - int begin(void); int SendReport(uint16_t id, const void* data, int len); int SetFeature(uint16_t id, const void* data, int len); bool LockFeature(uint16_t id, bool lock); diff --git a/src/HIDPowerDevice.cpp b/src/HIDPowerDevice.cpp index 06d7acf..64bb019 100755 --- a/src/HIDPowerDevice.cpp +++ b/src/HIDPowerDevice.cpp @@ -228,8 +228,6 @@ HIDPowerDevice_::HIDPowerDevice_(void) { } void HIDPowerDevice_::begin(void) { - HID().begin(); - // set string ID here HID().SetFeature(HID_PD_IPRODUCT, &bProduct, sizeof(bProduct)); From a6816b0a11133f2169626e2795dbd66676507ce0 Mon Sep 17 00:00:00 2001 From: Fredrik Orderud Date: Mon, 9 Sep 2024 11:08:22 +0200 Subject: [PATCH 3/3] Move HIDPowerDevice_::begin impl. to constructor Proposal to simplify the implementation by avoiding the need for manually calling begin() before using HIDPowerDevice_. --- examples/UPS/UPS.ino | 2 -- src/HIDPowerDevice.cpp | 4 ---- src/HIDPowerDevice.h | 1 - 3 files changed, 7 deletions(-) diff --git a/examples/UPS/UPS.ino b/examples/UPS/UPS.ino index e908b1b..ce48327 100644 --- a/examples/UPS/UPS.ino +++ b/examples/UPS/UPS.ino @@ -51,8 +51,6 @@ int iRes=0; void setup() { Serial.begin(57600); - - PowerDevice.begin(); // Serial No is set in a special way as it forms Arduino port name PowerDevice.setSerial(STRING_SERIAL); diff --git a/src/HIDPowerDevice.cpp b/src/HIDPowerDevice.cpp index 64bb019..56920db 100755 --- a/src/HIDPowerDevice.cpp +++ b/src/HIDPowerDevice.cpp @@ -225,15 +225,11 @@ HIDPowerDevice_::HIDPowerDevice_(void) { static HIDSubDescriptor node(_hidReportDescriptor, sizeof (_hidReportDescriptor)); HID().AppendDescriptor(&node); -} -void HIDPowerDevice_::begin(void) { // set string ID here - HID().SetFeature(HID_PD_IPRODUCT, &bProduct, sizeof(bProduct)); HID().SetFeature(HID_PD_SERIAL, &bSerial, sizeof(bSerial)); HID().SetFeature(HID_PD_MANUFACTURER, &bManufacturer, sizeof(bManufacturer)); - } void HIDPowerDevice_::setOutput(Serial_& out) { diff --git a/src/HIDPowerDevice.h b/src/HIDPowerDevice.h index 3447f52..8f3ef75 100755 --- a/src/HIDPowerDevice.h +++ b/src/HIDPowerDevice.h @@ -112,7 +112,6 @@ class HIDPowerDevice_ { public: HIDPowerDevice_(void); - void begin(void); void setOutput(Serial_&);