weight.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #ifndef __weight_H
  2. #define __weight_H
  3. #include "usart.h"
  4. //时间的结构
  5. struct datetime_t
  6. {
  7. uint32_t ss:6;
  8. uint32_t mm:6;
  9. uint32_t hh:5;
  10. uint32_t date:5;
  11. uint32_t month:4;
  12. uint32_t year:6;
  13. }__attribute__((packed));
  14. //按键重量的结构
  15. union timekeyweight_t
  16. {
  17. struct {
  18. uint8_t reserved:4; // 保留
  19. uint8_t WeightRun:1;
  20. uint8_t WeightWS:2;
  21. uint8_t WeightZF:1;
  22. int16_t WeightLast:16;
  23. int16_t WeightBegin:16;
  24. struct datetime_t datetime;
  25. }__attribute__((packed)) data;
  26. uint8_t Buffer[9];
  27. };
  28. //准备发送重量的结构
  29. union timeweight_t
  30. {
  31. struct {
  32. uint8_t reserved:4; // 保留
  33. uint8_t WeightRun:1;
  34. uint8_t WeightWS:2;
  35. uint8_t WeightZF:1;
  36. int16_t Weight:16;
  37. struct datetime_t datetime;
  38. }__attribute__((packed)) data;
  39. uint8_t Buffer[7];
  40. };
  41. //保存到flash中的结构
  42. union timeweight_save_t
  43. {
  44. struct {
  45. uint8_t reserved:4; // 保留
  46. uint8_t WeightRun:1;
  47. uint8_t WeightWS:2;
  48. uint8_t WeightZF:1;
  49. int16_t Weight4:16;
  50. int16_t Weight3:16;
  51. int16_t Weight2:16;
  52. int16_t Weight1:16;
  53. struct datetime_t datetime;
  54. }__attribute__((packed)) data;
  55. uint8_t Buffer[13];
  56. };
  57. extern unsigned char isn; //是否新大屏
  58. extern unsigned char isWeight;
  59. extern signed long WeightConst_WeightCurTem; //当前临时重量
  60. extern signed short WeightConst_WeightCur;
  61. extern unsigned char WeightConst_WeightWS; //小数位数
  62. extern unsigned char WeightConst_Weight_ZWS; //整数位数
  63. extern unsigned char WeightConst_WeightHaveBegin; //已经确认开始
  64. extern signed short WeightConst_WeightLast; //上次按键重量 1S一次
  65. extern unsigned char WeightConst_oksum; //符合目标重量数
  66. extern unsigned char WeightConst_allsum; //总重量值数
  67. extern signed short WeightConst_WeightOK;
  68. extern unsigned char WeightConst_AutoSingleNSecondNum[30][3]; //自动跳转每秒值的数组
  69. extern void ReadWeight(void);
  70. extern unsigned long mypow(unsigned char x,unsigned char y);
  71. extern void weight_usart_Init(UART_HandleTypeDef* uartHandle);
  72. extern union timekeyweight_t getTimeWeight(int i) ;
  73. extern rt_sem_t weight_lock;
  74. extern void CheckWeight_thread(void);
  75. extern void ReadWeight_thread(void);
  76. extern void ReadEID_thread(void);
  77. extern uint16_t tempWeighttime;
  78. #endif