]> git.gir.st - tmk_keyboard.git/blob - tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/scale/scale_rptparser.h
Merge branch 'master' into chibios
[tmk_keyboard.git] / tmk_core / protocol / usb_hid / USB_Host_Shield_2.0 / examples / HID / scale / scale_rptparser.h
1 #if !defined(__SCALERPTPARSER_H__)
2 #define __SCALERPTPARSER_H__
3
4 #include <max_LCD.h>
5 #include <hid.h>
6
7 /* Scale status constants */
8 #define REPORT_FAULT 0x01
9 #define ZEROED 0x02
10 #define WEIGHING 0x03
11 #define WEIGHT_VALID 0x04
12 #define WEIGHT_NEGATIVE 0x05
13 #define OVERWEIGHT 0x06
14 #define CALIBRATE_ME 0x07
15 #define ZERO_ME 0x08
16
17 /* input data report */
18 struct ScaleEventData
19 {
20 uint8_t reportID; //must be 3
21 uint8_t status;
22 uint8_t unit;
23 int8_t exp; //scale factor for the weight
24 uint16_t weight; //
25 };
26
27 class ScaleEvents
28 {
29
30 Max_LCD* pLcd;
31
32 void LcdPrint( const char* str );
33
34 public:
35
36 ScaleEvents( Max_LCD* pLCD );
37
38 virtual void OnScaleChanged(const ScaleEventData *evt);
39 };
40
41 #define RPT_SCALE_LEN sizeof(ScaleEventData)/sizeof(uint8_t)
42
43 class ScaleReportParser : public HIDReportParser
44 {
45 ScaleEvents *scaleEvents;
46
47 uint8_t oldScale[RPT_SCALE_LEN];
48
49 public:
50 ScaleReportParser(ScaleEvents *evt);
51
52 virtual void Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf);
53 };
54
55 #endif // __SCALERPTPARSER_H__
Imprint / Impressum