From 40d71e81e7a80a563366a2bd7622d02c0c29a5c2 Mon Sep 17 00:00:00 2001 From: Oleg Khovayko Date: Fri, 4 Aug 2023 16:08:36 -0400 Subject: [PATCH] ADD: lbs/oz, grams --- usbscale.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/usbscale.c b/usbscale.c index 895976c..6dab81b 100644 --- a/usbscale.c +++ b/usbscale.c @@ -77,6 +77,9 @@ static int print_scale_data(unsigned char*); // uint8_t get_first_endpoint_address(libusb_device* dev); + + + // // **UNITS** is an array of all the unit abbreviations as set forth by *HID // Point of Sale Usage Tables*, version 1.02, by the USB Implementers' Forum. @@ -350,7 +353,13 @@ static int print_scale_data(unsigned char* dat) { // the `UNITS` lookup table for unit names. // case 0x04: - printf("%g %s\n", weight, UNITS[unit]); + if(unit == 11) { + // stamps.com scale, defult "oz" unit + int lbs = weight / 16; + double remain = weight - lbs * 16; + printf("%g oz (%d lbs %g oz), %g grams\n", weight, lbs, remain, weight * 28.3495); + } else + printf("%g %s\n", weight, UNITS[unit]); return 0; case 0x05: if(status != lastStatus)