You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

scale_rptparser.h 1.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #if !defined(__SCALERPTPARSER_H__)
  2. #define __SCALERPTPARSER_H__
  3. #include <max_LCD.h>
  4. #include <hid.h>
  5. /* Scale status constants */
  6. #define REPORT_FAULT 0x01
  7. #define ZEROED 0x02
  8. #define WEIGHING 0x03
  9. #define WEIGHT_VALID 0x04
  10. #define WEIGHT_NEGATIVE 0x05
  11. #define OVERWEIGHT 0x06
  12. #define CALIBRATE_ME 0x07
  13. #define ZERO_ME 0x08
  14. /* input data report */
  15. struct ScaleEventData
  16. {
  17. uint8_t reportID; //must be 3
  18. uint8_t status;
  19. uint8_t unit;
  20. int8_t exp; //scale factor for the weight
  21. uint16_t weight; //
  22. };
  23. class ScaleEvents
  24. {
  25. Max_LCD* pLcd;
  26. void LcdPrint( const char* str );
  27. public:
  28. ScaleEvents( Max_LCD* pLCD );
  29. virtual void OnScaleChanged(const ScaleEventData *evt);
  30. };
  31. #define RPT_SCALE_LEN sizeof(ScaleEventData)/sizeof(uint8_t)
  32. class ScaleReportParser : public HIDReportParser
  33. {
  34. ScaleEvents *scaleEvents;
  35. uint8_t oldScale[RPT_SCALE_LEN];
  36. public:
  37. ScaleReportParser(ScaleEvents *evt);
  38. virtual void Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf);
  39. };
  40. #endif // __SCALERPTPARSER_H__