summaryrefslogtreecommitdiff
path: root/lib/usbhost/USB_Host_Shield_2.0/examples/HID/scale/scale_rptparser.h
diff options
context:
space:
mode:
authorNick Brassel <nick@tzarc.org>2021-08-29 08:20:25 +1000
committerNick Brassel <nick@tzarc.org>2021-08-29 08:20:25 +1000
commitf061ca497464fe85284906fb163a33eaee7a91ef (patch)
tree33ef1bfb529aed382e8526c607c4e18717f92571 /lib/usbhost/USB_Host_Shield_2.0/examples/HID/scale/scale_rptparser.h
parentff65185dec6f97be1eb49f17cea526a0d0bbf3d6 (diff)
parent4bad375d7c09d949a9dcdd4feba147c9c7a67ec6 (diff)
Breaking changes develop merge to master, 2021Q3 edition. (#14196)
Diffstat (limited to 'lib/usbhost/USB_Host_Shield_2.0/examples/HID/scale/scale_rptparser.h')
-rw-r--r--lib/usbhost/USB_Host_Shield_2.0/examples/HID/scale/scale_rptparser.h55
1 files changed, 55 insertions, 0 deletions
diff --git a/lib/usbhost/USB_Host_Shield_2.0/examples/HID/scale/scale_rptparser.h b/lib/usbhost/USB_Host_Shield_2.0/examples/HID/scale/scale_rptparser.h
new file mode 100644
index 0000000000..57fbb033bf
--- /dev/null
+++ b/lib/usbhost/USB_Host_Shield_2.0/examples/HID/scale/scale_rptparser.h
@@ -0,0 +1,55 @@
+#if !defined(__SCALERPTPARSER_H__)
+#define __SCALERPTPARSER_H__
+
+#include <max_LCD.h>
+#include <hid.h>
+
+/* Scale status constants */
+#define REPORT_FAULT 0x01
+#define ZEROED 0x02
+#define WEIGHING 0x03
+#define WEIGHT_VALID 0x04
+#define WEIGHT_NEGATIVE 0x05
+#define OVERWEIGHT 0x06
+#define CALIBRATE_ME 0x07
+#define ZERO_ME 0x08
+
+/* input data report */
+struct ScaleEventData
+{
+ uint8_t reportID; //must be 3
+ uint8_t status;
+ uint8_t unit;
+ int8_t exp; //scale factor for the weight
+ uint16_t weight; //
+};
+
+class ScaleEvents
+{
+
+ Max_LCD* pLcd;
+
+ void LcdPrint( const char* str );
+
+public:
+
+ ScaleEvents( Max_LCD* pLCD );
+
+ virtual void OnScaleChanged(const ScaleEventData *evt);
+};
+
+#define RPT_SCALE_LEN sizeof(ScaleEventData)/sizeof(uint8_t)
+
+class ScaleReportParser : public HIDReportParser
+{
+ ScaleEvents *scaleEvents;
+
+ uint8_t oldScale[RPT_SCALE_LEN];
+
+public:
+ ScaleReportParser(ScaleEvents *evt);
+
+ virtual void Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf);
+};
+
+#endif // __SCALERPTPARSER_H__