HT16C22.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. #ifndef __HT16C22_H
  2. #define __HT16C22_H
  3. #include "sys.h"
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <string.h>
  7. #include "gd32f30x.h"
  8. #define LCD_IRQ_READ() gpio_input_bit_get(GPIOD, GPIO_PIN_2) // LCD部分
  9. #define SET_LCD_DATA() gpio_bit_write(GPIOB, GPIO_PIN_4, SET)
  10. #define CLR_LCD_DATA() gpio_bit_write(GPIOB, GPIO_PIN_4, RESET)
  11. #define SET_LCD_WR() gpio_bit_write(GPIOB, GPIO_PIN_2, SET)
  12. #define CLR_LCD_WR() gpio_bit_write(GPIOB, GPIO_PIN_2, RESET)
  13. #define SET_LCD_RD() gpio_bit_write(GPIOC, GPIO_PIN_12, SET)
  14. #define CLR_LCD_RD() gpio_bit_write(GPIOC, GPIO_PIN_12, RESET)
  15. #define SET_LCD_CS() gpio_bit_write(GPIOB, GPIO_PIN_3, SET)
  16. #define CLR_LCD_CS() gpio_bit_write(GPIOB, GPIO_PIN_3, RESET)
  17. #define SET_LCD_BL_LIGHT() gpio_bit_write(GPIOA, GPIO_PIN_0, SET)
  18. #define CLR_LCD_BL_LIGHT() gpio_bit_write(GPIOA, GPIO_PIN_0, RESET)
  19. #define Blink 0xC0 //关闭闪烁
  20. extern uint16_t ram1;
  21. extern uint16_t ram2;
  22. extern uint16_t ram3;
  23. extern uint16_t ram4;
  24. extern u8 OD_Value,OE_Value,OF_Value,IO_Value,II_Value,IE_Value,IS_Value;
  25. //char LCD_Table[] = {0x7B, 0x03, 0x3D, 0x1F, 0x47, 0x5E, 0x7E, 0x13, 0x7F, 0x5F};
  26. #define OD_addr 0x0D
  27. #define OE_addr 0x0E
  28. #define OF_addr 0x0F
  29. #define IO_addr 0x10
  30. #define II_addr 0x11
  31. #define IE_addr 0x12
  32. #define IS_addr 0x13
  33. //湿度RH%图标
  34. #define RH_ON ht16c22_display(3,3,ram3|=0x0008);
  35. #define RH_OFF ht16c22_display(3,3,ram3&=~0x0008);
  36. //VCC图标
  37. //#define VOC_ON ht16c22_display(OE_addr,OE_Value|=0X01);
  38. //#define VOC_OFF ht16c22_display(OE_addr,OE_Value&=0XFE);
  39. //新风模式图标
  40. #define ZY_ON ht16c22_display(0,4,ram4|=0x0001);
  41. #define ZY_OFF ht16c22_display(0,4,ram4&=~0x0001);
  42. //空调模式图标
  43. #define ZE_ON ht16c22_display(5,4,ram4|=0x0020);
  44. #define ZE_OFF ht16c22_display(5,4,ram4&=~0x0020);
  45. //PM2.5图标
  46. //#define PM_ON ht16c22_display(IS_addr,IS_Value|=0X01);
  47. //#define PM_OFF ht16c22_display(IS_addr,IS_Value&=0XFE);
  48. //一根竖杠图标 打开广播模式图标
  49. //#define YS_ON ht16c22_display(IS_addr,IS_Value|=0X04);
  50. //#define YS_OFF ht16c22_display(IS_addr,IS_Value&=0XFB);
  51. //两根竖杠图标
  52. //#define ES_ON ht16c22_display(IS_addr,IS_Value|=0X02);
  53. //#define ES_OFF ht16c22_display(IS_addr,IS_Value&=0XFD);
  54. //三根竖杠图标
  55. //#define SS_ON ht16c22_display(IS_addr,IS_Value|=0X08);
  56. //#define SS_OFF ht16c22_display(IS_addr,IS_Value&=0XF7);
  57. //风速高
  58. #define HW_ON ht16c22_display(4,2,ram2|=0x0010);
  59. #define HW_OFF ht16c22_display(4,2,ram2&=~0x0010);
  60. //风速中
  61. #define MW_ON ht16c22_display(4,1,ram1|=0x0010);
  62. #define MW_OFF ht16c22_display(4,1,ram1&=~0x0010);
  63. //风速低
  64. #define LW_ON ht16c22_display(3,1,ram1|=0x0008);
  65. #define LW_OFF ht16c22_display(3,1,ram1&=~0x0008);
  66. //自动标志
  67. #define AUTO_ON ht16c22_display(3,4,ram4|=0x0008);
  68. #define AUTO_OFF ht16c22_display(3,4,ram4&=~0x0008);
  69. //风扇标志
  70. #define FS_ON ht16c22_display(5,1,ram1|=0x0020);
  71. #define FS_OFF ht16c22_display(5,1,ram1&=~0x0020);
  72. //制冷标志
  73. #define ZL_ON ht16c22_display(1,1,ram1|=0x0002);
  74. #define ZL_OFF ht16c22_display(1,1,ram1&=~0x0002);
  75. //制热标志
  76. #define ZR_ON ht16c22_display(2,1,ram1|=0x0004);
  77. #define ZR_OFF ht16c22_display(2,1,ram1&=~0x0004);
  78. //除湿标志
  79. #define CS_ON ht16c22_display(10,1,ram1|=0x0400);
  80. #define CS_OFF ht16c22_display(10,1,ram1&=~0x0400);
  81. //地暖模式图标
  82. #define ZS_ON ht16c22_display(1,4,ram4|=0x0002);
  83. #define ZS_OFF ht16c22_display(1,4,ram4&=~0x0002);
  84. //中间2点图标
  85. //#define MH_ON ht16c22_display(IO_addr,IO_Value|=0X08);
  86. //#define MH_OFF ht16c22_display(IO_addr,IO_Value&=0XF7);
  87. //小数点
  88. #define DH_ON ht16c22_display(7,1,ram1|=0x0080);
  89. #define DH_OFF ht16c22_display(7,1,ram1&=~0x0080);
  90. //度标志
  91. #define DU_ON ht16c22_display(5,3,ram3|=0x0020);
  92. #define DU_OFF ht16c22_display(5,3,ram3&=~0x0020);
  93. void Delay_SS();
  94. void Delay_Ms();
  95. //开机动画
  96. void Animation(void);
  97. //显示温度界面 摄氏度
  98. void Display_temp(int16_t temp,uint8_t type); //温度显示
  99. //显示温度界面 华氏度
  100. //void Display_H_temp(int16_t temp);
  101. //湿度
  102. //void Dis_hum(u8 hum);
  103. //void Display_Multidigit(u16 num); //显示多位数,不能超过四位
  104. void ht16c22_clear(void);
  105. void ht16c22_init(void);
  106. void ht16c22_display(uint8_t add,uint8_t ram_num,uint16_t ram_temp);
  107. //显示字母
  108. void Dis_letter(u8 wei, u8 num);
  109. //显示数字
  110. void Display_num(u8 wei, u8 num);
  111. #endif