2013-09-07 01:03:19 +02:00
|
|
|
#if !defined(__SCALERPTPARSER_H__)
|
|
|
|
#define __SCALERPTPARSER_H__
|
|
|
|
|
2014-11-10 07:35:13 +01:00
|
|
|
#include <max_LCD.h>
|
2016-01-16 20:01:11 +01:00
|
|
|
#include <usbhid.h>
|
2013-09-07 01:03:19 +02:00
|
|
|
|
|
|
|
/* 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;
|
2014-11-10 07:35:13 +01:00
|
|
|
uint8_t unit;
|
2013-09-07 01:03:19 +02:00
|
|
|
int8_t exp; //scale factor for the weight
|
|
|
|
uint16_t weight; //
|
|
|
|
};
|
|
|
|
|
|
|
|
class ScaleEvents
|
|
|
|
{
|
2014-11-10 07:35:13 +01:00
|
|
|
|
2013-09-07 01:03:19 +02:00
|
|
|
Max_LCD* pLcd;
|
2014-11-10 07:35:13 +01:00
|
|
|
|
2013-09-07 01:03:19 +02:00
|
|
|
void LcdPrint( const char* str );
|
2014-11-10 07:35:13 +01:00
|
|
|
|
2013-09-07 01:03:19 +02:00
|
|
|
public:
|
2014-11-10 07:35:13 +01:00
|
|
|
|
2013-09-07 01:03:19 +02:00
|
|
|
ScaleEvents( Max_LCD* pLCD );
|
2014-11-10 07:35:13 +01:00
|
|
|
|
2013-09-07 01:03:19 +02:00
|
|
|
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);
|
|
|
|
|
2016-01-16 20:01:11 +01:00
|
|
|
virtual void Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf);
|
2013-09-07 01:03:19 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // __SCALERPTPARSER_H__
|