Feng Hong / Mbed OS Nucleo_rtos_basic
Committer:
hi1000
Date:
Tue Sep 24 14:05:58 2019 +0000
Revision:
19:0356e54240cc
Parent:
18:e6ed582f7022
Child:
20:ec9d4f6a16ac
First Version of YODA2; -Buttons; -Menu; -LCD; -Scale; -CAN Bus; -EEPROM; work

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hi1000 19:0356e54240cc 1 //#define RASPBERRY_PI_CAN_ADDRESS 0x01
hi1000 19:0356e54240cc 2 #define YODA2
hi1000 19:0356e54240cc 3 #define RASPBERRY_PI_CAN_TYPE 0x07
hi1000 19:0356e54240cc 4 #define RASPBERRY_PI_CAN_ID 0x01
hi1000 19:0356e54240cc 5 #define RASPBERRY_PI_CAN_ADDRESS ((RASPBERRY_PI_CAN_TYPE<<8) | RASPBERRY_PI_CAN_ID)
hi1000 19:0356e54240cc 6
hi1000 19:0356e54240cc 7 #ifdef OWN_SOLDER_BOARD
hi1000 19:0356e54240cc 8 #define BUTTON1 PB_4 // right // up
hi1000 19:0356e54240cc 9 #define BUTTON2 PC_1 // left // down
hi1000 19:0356e54240cc 10 #define BUTTON3 PC_7 // enter // next
hi1000 19:0356e54240cc 11 #define BUTTON4 PA_9 // menu // back
hi1000 19:0356e54240cc 12 #endif
hi1000 19:0356e54240cc 13
hi1000 19:0356e54240cc 14 #ifdef YODA2
hi1000 19:0356e54240cc 15 #define BUTTON1 PA_8 // right // up
hi1000 19:0356e54240cc 16 #define BUTTON2 PB_10 // left // down
hi1000 19:0356e54240cc 17 #define BUTTON3 PB_4 // enter // next
hi1000 19:0356e54240cc 18 #define BUTTON4 PB_5 // menu // back
hi1000 19:0356e54240cc 19 #endif
hi1000 19:0356e54240cc 20
hi1000 14:2e17a27f56b2 21 #define BUTTON1_HOLD_EVENT 0x0001
hi1000 14:2e17a27f56b2 22 #define BUTTON1_PRESSED_EVENT 0x0002
hi1000 14:2e17a27f56b2 23 #define BUTTON2_HOLD_EVENT 0x0004
hi1000 14:2e17a27f56b2 24 #define BUTTON2_PRESSED_EVENT 0x0008
hi1000 14:2e17a27f56b2 25 #define BUTTON3_HOLD_EVENT 0x0010
hi1000 14:2e17a27f56b2 26 #define BUTTON3_PRESSED_EVENT 0x0020
hi1000 14:2e17a27f56b2 27 #define BUTTON4_HOLD_EVENT 0x0040
hi1000 14:2e17a27f56b2 28 #define BUTTON4_PRESSED_EVENT 0x0080
hi1000 19:0356e54240cc 29 #define NEXT_HOLD_EVENT BUTTON4_HOLD_EVENT
hi1000 19:0356e54240cc 30 #define NEXT_PRESSED_EVENT BUTTON4_PRESSED_EVENT
hi1000 19:0356e54240cc 31 #define BACK_HOLD_EVENT BUTTON3_HOLD_EVENT
hi1000 19:0356e54240cc 32 #define BACK_PRESSED_EVENT BUTTON3_PRESSED_EVENT
hi1000 19:0356e54240cc 33 #define DOWN_HOLD_EVENT BUTTON2_HOLD_EVENT
hi1000 19:0356e54240cc 34 #define DOWN_PRESSED_EVENT BUTTON2_PRESSED_EVENT
hi1000 19:0356e54240cc 35 #define UP_HOLD_EVENT BUTTON1_HOLD_EVENT
hi1000 19:0356e54240cc 36 #define UP_PRESSED_EVENT BUTTON1_PRESSED_EVENT
hi1000 14:2e17a27f56b2 37 #define LCD_DISPLAY_HOLD_EVENT 0x0001
hi1000 17:faa4d4976d22 38 #define LCD_DISPLAY_RELEASE_EVENT 0x0002
hi1000 17:faa4d4976d22 39
hi1000 17:faa4d4976d22 40 #define COMMAND_INIT 0 // all the devices return to the point 0 and return the current possition or current weight
hi1000 17:faa4d4976d22 41 #define COMMAND_PLUS 1 // for the devices to plus weight return the weight
hi1000 17:faa4d4976d22 42 #define COMMAND_MINUS 2 // for the devices to minus weight return the weight
hi1000 17:faa4d4976d22 43 #define COMMAND_MOVE_ABSOLUTE 3 // for the devices to move to the absolute position return the current absolute position
hi1000 17:faa4d4976d22 44 #define COMMAND_MOVE_RELATIVE 4 // for the devices to move relative distance return the current absolute position
hi1000 17:faa4d4976d22 45 #define COMMAND_REPORT_WEIGHT 5 // for the devices to report the current weight
hi1000 17:faa4d4976d22 46 #define COMMAND_REPORT_POSITION 6 // for the devices to report the current absolute position
hi1000 17:faa4d4976d22 47 #define COMMAND_CLEAN 7 // for the devices to clean the cups return done or failed
hi1000 17:faa4d4976d22 48 #define COMMAND_TARE 8 // for the devices to tare the scale return done or failed
hi1000 17:faa4d4976d22 49 #define COMMAND_SHAKE_CUP 9 // for the device to shake the cups return done or failed
hi1000 17:faa4d4976d22 50 #define COMMAND_POUR_TEA 10 // for the device to pour the tea return done or failed
hi1000 17:faa4d4976d22 51 #define COMMAND_FINISH 11 // for everything finished return done or failed
hi1000 18:e6ed582f7022 52 #define COMMAND_RESET 12 // for the devices return to the point 0 and clean themselvies
hi1000 19:0356e54240cc 53 #define COMMAND_REGISTER 13 // for device to register itself to raspberry pi
hi1000 18:e6ed582f7022 54
hi1000 18:e6ed582f7022 55
hi1000 18:e6ed582f7022 56 #define WEIGHT_DIFFERENCE 200 // 10g ADC value minimum difference
hi1000 18:e6ed582f7022 57 #define CALIBRATION_WEIGHT 2000 // calibration weight
hi1000 18:e6ed582f7022 58 #define MAXIMUM_CALIBRATION_WEIGHT 5000
hi1000 18:e6ed582f7022 59 #define MINIMUM_CALIBRATION_WEIGHT 100
hi1000 18:e6ed582f7022 60
hi1000 19:0356e54240cc 61 #ifdef OWN_SOLDER_BOARD
hi1000 19:0356e54240cc 62 #define EEPROM_ADDR 0x0 // I2c EEPROM address is 0x00
hi1000 19:0356e54240cc 63 #endif
hi1000 19:0356e54240cc 64 #ifdef YODA2
hi1000 19:0356e54240cc 65 #define EEPROM_ADDR 0x57
hi1000 19:0356e54240cc 66 #endif
hi1000 19:0356e54240cc 67 #ifdef STM32F207xx
hi1000 19:0356e54240cc 68 #define SDA PB_9 // I2C SDA pin
hi1000 19:0356e54240cc 69 #define SCL PB_8 // I2C SCL pin
hi1000 19:0356e54240cc 70 #endif
hi1000 19:0356e54240cc 71
hi1000 19:0356e54240cc 72 #ifdef STM32F303xE
hi1000 19:0356e54240cc 73 #ifdef OWN_SOLDER_BOARD
hi1000 19:0356e54240cc 74 #define SDA PC_9//D2//D2//PB_9 //PF_0 // I2C SDA pin
hi1000 19:0356e54240cc 75 #define SCL D7//D8//D8//PB_8 //PF_1 // I2C SCL pin
hi1000 19:0356e54240cc 76 #endif
hi1000 19:0356e54240cc 77 #ifdef YODA2
hi1000 19:0356e54240cc 78 #define SDA PA_10//D2//D2//PB_9 //PF_0 // I2C SDA pin
hi1000 19:0356e54240cc 79 #define SCL PA_9//D8//D8//PB_8 //PF_1 // I2C SCL pin
hi1000 19:0356e54240cc 80 #endif
hi1000 19:0356e54240cc 81 #endif
hi1000 19:0356e54240cc 82
hi1000 19:0356e54240cc 83 #define MIN(X,Y) ((X) < (Y) ? (X) : (Y))
hi1000 19:0356e54240cc 84 #define MAX(X,Y) ((X) > (Y) ? (X) : (Y))
hi1000 19:0356e54240cc 85
hi1000 19:0356e54240cc 86 #define EEPROM_DEVICE_ADDRESS_ADDRESS 0x40
hi1000 19:0356e54240cc 87 #define DEVICE_DEFAULT_ADDRESS 12
hi1000 19:0356e54240cc 88
hi1000 19:0356e54240cc 89
hi1000 18:e6ed582f7022 90 enum Device_Type_d
hi1000 18:e6ed582f7022 91 {
hi1000 18:e6ed582f7022 92 CupTrack=0,
hi1000 18:e6ed582f7022 93 JamTrack=1,
hi1000 18:e6ed582f7022 94 TeaTrack=2,
hi1000 18:e6ed582f7022 95 Tea=3,
hi1000 18:e6ed582f7022 96 Jam=4,
hi1000 19:0356e54240cc 97 Shaker=5,
hi1000 19:0356e54240cc 98 IceMaker=6
hi1000 18:e6ed582f7022 99 };
hi1000 18:e6ed582f7022 100
hi1000 18:e6ed582f7022 101 struct ScaleCalibrationData {
hi1000 18:e6ed582f7022 102 unsigned int calibrationWeight; // the weight (g) used for calibration for example 1000g or 10g. The maximum value is 3000.
hi1000 18:e6ed582f7022 103 long offsetValue; // the value for scale offset
hi1000 18:e6ed582f7022 104 float scaleValue; // the ADC increment for 1g
hi1000 18:e6ed582f7022 105 uint8_t checksum;
hi1000 19:0356e54240cc 106 };
hi1000 19:0356e54240cc 107
hi1000 19:0356e54240cc 108 // because memcpy is 16 byte alignment no byte in struct
hi1000 19:0356e54240cc 109 struct data_field_d {
hi1000 19:0356e54240cc 110 uint16_t cmd;
hi1000 19:0356e54240cc 111 uint16_t value1;
hi1000 19:0356e54240cc 112 uint16_t value2;
hi1000 19:0356e54240cc 113 uint16_t value3;
hi1000 19:0356e54240cc 114 };