lcmComm_dgus.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. /*
  2. * lcmComm_dwin.h
  3. *
  4. * Created on : 2020-10-20
  5. * Update on : 2021-06-23
  6. * Author : Folus Wen, Eason Yang
  7. * Version : D0.01
  8. *
  9. */
  10. #ifndef LCMCOMM_DGUS_H_
  11. #define LCMCOMM_DGUS_H_
  12. #include <sys/time.h>
  13. #include <sys/timeb.h>
  14. #include <sys/types.h>
  15. #include <sys/stat.h>
  16. #include <sys/types.h>
  17. #include <sys/ioctl.h>
  18. #include <sys/socket.h>
  19. #include <sys/ipc.h>
  20. #include <sys/shm.h>
  21. #include <sys/shm.h>
  22. #include <sys/mman.h>
  23. #include <linux/wireless.h>
  24. #include <arpa/inet.h>
  25. #include <netinet/in.h>
  26. #include <unistd.h>
  27. #include <stdarg.h>
  28. #include <stdio.h>
  29. #include <stdlib.h>
  30. #include <unistd.h>
  31. #include <fcntl.h>
  32. #include <termios.h>
  33. #include <errno.h>
  34. #include <errno.h>
  35. #include <string.h>
  36. #include <time.h>
  37. #include <ctype.h>
  38. #include <ifaddrs.h>
  39. #define DEBUG_INFO(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__), __LINE__, __FUNCTION__, ##args)
  40. #define DEBUG_WARN(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__), __LINE__, __FUNCTION__, ##args)
  41. #define DEBUG_ERROR(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__), __LINE__, __FUNCTION__, ##args)
  42. #define ARRAY_SIZE(A) (sizeof(A) / sizeof(A[0]))
  43. #define PASS 1
  44. #define FAIL -1
  45. #define YES 1
  46. #define NO 0
  47. #define ON 1
  48. #define OFF 0
  49. #define PAGE_DISPLAY_PERIOD 3
  50. //=======================================
  51. // Register Control type
  52. //=======================================
  53. #define REG_TYPE_CONTROL 0x00
  54. #define REG_TYPE_RAM 0x01
  55. #define REG_TYPE_SPECIAL_CONTROL 0x02
  56. //=======================================
  57. // Register content (Variable storage)
  58. //=======================================
  59. #define REG_ADDRESS_READ_VERSION 0x0F
  60. #define REG_ADDRESS_READ_RTC 0x10
  61. #define REG_ADDRESS_READ_PAGE_ID 0x14
  62. #define REG_ADDRESS_READ_BRIGHTNESS 0x31
  63. #define REG_ADDRESS_WRITE_BRIGHTNESS 0X82
  64. #define REG_ADDRESS_SET_PAGE_ID 0x84
  65. #define REG_ADDRESS_SET_RTC 0x9C
  66. //=======================================
  67. // LCD command constant
  68. //=======================================
  69. #define CMD_HEADER_1 0x5A
  70. #define CMD_HEADER_2 0xA5
  71. #define CMD_REG_WRITE 0x80
  72. #define CMD_REG_READ 0x81
  73. #define CMD_REG_WRITE_DATA 0x82
  74. #define CMD_REG_READ_DATA 0x83
  75. #define CMD_ACK_VALUE_1 0x4F
  76. #define CMD_ACK_VALUE_2 0x4B
  77. //=======================================
  78. // LCD system screen
  79. //=======================================
  80. #define SYSTEM_SCREEN_BOOTING 0x00
  81. #define SYSTEM_SCREEN_IDLE 0x01
  82. #define SYSTEM_SCREEN_PREPARING 0x02
  83. #define SYSTEM_SCREEN_PREPARE_FOR_EVSE 0x03
  84. #define SYSTEM_SCREEN_CHARGING 0x04
  85. #define SYSTEM_SCREEN_COMPLETE 0x05
  86. #define SYSTEM_SCREEN_MAINTAIN 0x06
  87. #define SYSTEM_SCREEN_AUTH_PASS 0x07
  88. #define SYSTEM_SCREEN_AUTH_FAIL 0x08
  89. #define SYSTEM_SCREEN_AUTH_UNKNOW 0x09
  90. #define SYSTEM_SCREEN_TERMINATING 0X0A
  91. #define SYSTEM_SCREEN_EMERGENCY 0x0B
  92. #define SYSTEM_SCREEN_SLEEP 0x0C
  93. #define SYSTEM_SCREEN_POWER_CONSUMPTION 0x0D
  94. //=======================================
  95. // Parameter to change icon status
  96. //=======================================
  97. #define DISAPPEAR 0x00
  98. #define APPEAR 0x01
  99. #define BACKEND_OFFLINE 0x01
  100. #define BACKEND_ONLINE 0x02
  101. #define ETHERENT_OFFLINE 0x03
  102. #define EHTERNET_ONLINE 0x04
  103. #define WIFI_OFFLINE 0x05
  104. #define WIFI_ONLINE 0x06
  105. #define TELECOM_OFFLINE 0x07
  106. #define TELECOM_ONLINE 0x08
  107. #define RFID_DISABLE 0x01
  108. #define RFID_ENABLE 0x02
  109. #define VISA_DISABLE 0x03
  110. #define VISA_ENABLE 0x04
  111. #define PLUGIN_ARROW_1 0x01
  112. #define PLUGIN_ARROW_2 0x02
  113. #define BATTERY_MAP 0x01
  114. #define BATTERY_CAPACITY_EMPTY 0x02
  115. #define BATTERY_CAPACITY_20 0x03
  116. #define BATTERY_CAPACITY_40 0x04
  117. #define BATTERY_CAPACITY_60 0x05
  118. #define BATTERY_CAPACITY_80 0x06
  119. #define BATTERY_CAPACITY_100 0x07
  120. #define CONNECTION_QUESTION_MARK_1 0x01
  121. #define CONNECTION_QUESTION_MARK_2 0x02
  122. #define CONNECTION_ELECTRIC_MARK_1 0x03
  123. #define CONNECTION_ELECTRIC_MARK_2 0x04
  124. #define TIMER_DARK 0x01
  125. #define TIMER_LIGHT 0x02
  126. #define POWER_DARK 0x01
  127. #define POWER_LIGHT 0x02
  128. #define ENERGY_DARK 0x01
  129. #define ENERGY_LIGHT 0x02
  130. #define ELECTRICITY_DIRECTION_RIGHT 0x01
  131. #define ELECTRICITY_DIRECTION_LEFT 0x02
  132. #define BATTERY_SOC_EMPTY 0x01
  133. #define BATTERY_SOC_20 0x02
  134. #define BATTERY_SOC_40 0x03
  135. #define BATTERY_SOC_60 0x04
  136. #define BATTERY_SOC_80 0x05
  137. #define BATTERY_SOC_100 0x06
  138. #define CONNECTION_COMPLETE_MARK 0x01
  139. #define QRCODE_BANDED 0x01
  140. #define QRCODE_ENABLE 0x02
  141. #define QRCODE_DISABLE 0x03
  142. //=======================================
  143. // Icon variable address start from 1000
  144. //=======================================
  145. #define ICON_ALARM_1 0x1000
  146. #define ICON_ALARM_2 0x1001
  147. #define ICON_ALARM_3 0x1002
  148. #define ICON_ALARM_4 0x1003
  149. #define ICON_4G_CONNECTION 0x1004
  150. #define ICON_WIFI_CONNECTION 0x1005
  151. #define ICON_ETHERENT_CONNECTION 0x1006
  152. #define ICON_BACKEND_CONNECTION 0x1007
  153. #define ICON_PRICE 0x1008
  154. #define ICON_RFID 0x1009
  155. #define ICON_QRCODE 0x100A
  156. #define ICON_PLUGIN_ARROW 0x100B
  157. #define ICON_BATTERY_PRECHARGING 0x100C
  158. #define ICON_CONNECTION_PRECHARGING 0x100D
  159. #define ICON_TIMER_PRECHARGING 0x100E
  160. #define ICON_POWER_PRECHARGING 0x100F
  161. #define ICON_ENERGY_PRECHARGING 0x1010
  162. #define ICON_BATTERY_CHARGING 0x1011
  163. #define ICON_CONNECTION_CHARGING 0x1012
  164. #define ICON_ELECTRICITY_DIRECTION 0x1013
  165. #define ICON_TIMER_CHARGING 0x1014
  166. #define ICON_POWER_CHARGING 0x1015
  167. #define ICON_ENERGY_CHARGING 0x1016
  168. #define ICON_WALLER_COMPLETE 0x1017
  169. #define ICON_BATTERY_COMPLETE 0x1018
  170. #define ICON_CONNECTION_COMPLETE 0x1019
  171. #define ICON_TIMER_COMPLETE 0x101A
  172. #define ICON_COST_COMPLETE 0X101B
  173. #define ICON_ENERGY_COMPLETE 0X101C
  174. #define ICON_BALANCE_WALLET 0x101D
  175. #define ICON_DEFAULT_START_PRICE 0x101E
  176. #define ICON_DEFAULT_ENERGY 0x101F
  177. #define ICON_START_BUTTON 0x1020
  178. #define ICON_POWER_CONSUMPTION 0x1021
  179. #define ICON_THE_CHARGE_COMPLETE 0x1022
  180. #define ICON_LOGO 0x1500
  181. #define ICON_LOGO_CHARGING 0x1501
  182. //=======================================
  183. // Text content address start from 2000
  184. //=======================================
  185. #define TEXT_ALARM_CODE_1 0x2000 // size 6
  186. #define TEXT_ALARM_CODE_2 0x2006 // size 6
  187. #define TEXT_ALARM_CODE_3 0x200C // size 6
  188. #define TEXT_ALARM_CODE_4 0x2012 // size 6
  189. #define TEXT_PRICE 0x2018 // size 16
  190. #define TEXT_CURRENCY_UNIT 0x2028 // size 16
  191. #define TEXT_TIMER_PRECHARGING 0x2038 // size 16
  192. #define TEXT_POWER_PRECHARGING 0x2048 // size 16
  193. #define TEXT_ENERGY_PRECHARGING 0x2058 // size 16
  194. #define TEXT_TIMER_CHARGING 0x2068 // size 16
  195. #define TEXT_POWER_CHARGING 0x2078 // size 16
  196. #define TEXT_ENERGY_CHARGING 0x2088 // size 16
  197. #define TEXT_COST_COMPLETE 0x2098 // size 16
  198. #define TEXT_ACCOUNT_COMPLETE 0x20A8 // size 16
  199. #define TEXT_BALANCE 0x20B8 // size 16
  200. #define TEXT_PERCENTAGE 0x20C8 // size 6
  201. #define TEXT_CURRENCY_COMPLETE 0x20CE // size 16
  202. #define TEXT_DEFUALT_START_PRICE 0x20DE // size 16
  203. #define TEXT_DEFAULT_ENERGY 0x20EE // size 16
  204. #define TEXT_POWER_CONSUMPTION 0x20FE // size 32
  205. #define TEXT_RTC 0X2500 // size 32
  206. //=======================================
  207. // QR Code content address start from 3000
  208. //=======================================
  209. #define TEXT_QRCODE_CONTENT 0x3000 // size 256
  210. #define TEXT_QRCODE_RECEIPT 0x3100 // size 256
  211. //=======================================
  212. // QR Code mode define
  213. //=======================================
  214. #define QRCODE_FOR_IDLE 1
  215. #define QRCODE_FOR_COMPLETE 2
  216. //=======================================
  217. // 4G + WIFI connection flags (Header)
  218. //=======================================
  219. #define DISABLE_4G 0x00
  220. #define ENABLE_4G 0x01
  221. #define DISABLE_WIFI 0x00
  222. #define WIFI_STATION 0x01
  223. #define WIFI_ACCESS_POINT 0x02
  224. //=======================================
  225. // Battery level status (Charging)
  226. //=======================================
  227. #define BATTERY_LEVEL_0 0x00
  228. #define BATTERY_LEVEL_1 0x01
  229. #define BATTERY_LEVEL_2 0x02
  230. #define BATTERY_LEVEL_3 0x03
  231. #define BATTERY_LEVEL_4 0x04
  232. #define BATTERY_LEVEL_5 0x05
  233. //=======================================
  234. // Connection level status (Charging)
  235. //=======================================
  236. #define CONNECTION_LEVEL_0 0x00
  237. #define CONNECTION_LEVEL_1 0x01
  238. //=======================================
  239. // Gun plug-in level status (Preparing)
  240. //=======================================
  241. #define GUN_PLUGING_LEVEL_0 0x00
  242. #define GUN_PLUGING_LEVEL_1 0x01
  243. //=======================================
  244. // Start button level status (Sleep in Idle)
  245. //=======================================
  246. #define START_BUTTON_LEVEL_0 0x00
  247. #define START_BUTTON_LEVEL_1 0x01
  248. //=======================================
  249. // RFID authorization constant
  250. //=======================================
  251. #define DEFAULT_RFID 0
  252. #define VALIDATED_RFID 1
  253. #define UNVALIDATED_RFID 2
  254. #define UNKNOW_RFID 3
  255. //=======================================
  256. // Normal mode or CCS mode constant
  257. //=======================================
  258. #define BASIC_MODE 0x00
  259. #define CCS_MODE 0x01
  260. //=======================================
  261. // Price type
  262. //=======================================
  263. #define DEFAULT_VALUE 0
  264. #define CONNECTION_FEE 1
  265. #define CURRENT_RATE 2
  266. #define OCCUPANCY_FEE 3
  267. #define SESSION_FEE 4
  268. #define TOTAL_COST 5
  269. #define ACCOUNT_BALANCE 6
  270. //=======================================
  271. // Currency type
  272. //=======================================
  273. #define DEFAULE_PRICE 1
  274. #define SET_USER_PRICE 2
  275. #define FINAL_COST 3
  276. //=======================================
  277. // LCM brightness percentage
  278. //=======================================
  279. #define BRIGHTNESS_0 0x00
  280. #define BRIGHTNESS_10 0x0A
  281. #define BRIGHTNESS_20 0x14
  282. #define BRIGHTNESS_30 0x1E
  283. #define BRIGHTNESS_40 0x28
  284. #define BRIGHTNESS_50 0x32
  285. #define BRIGHTNESS_60 0x3C
  286. #define BRIGHTNESS_70 0x46
  287. #define BRIGHTNESS_80 0x50
  288. #define BRIGHTNESS_90 0x5A
  289. #define BRIGHTNESS_100 0x64
  290. extern int StoreLogMsg(const char *fmt, ...);
  291. extern int8_t lcdRegisterWrite(int32_t fd, uint8_t regType, uint16_t address, uint8_t *data, uint16_t dataLen);
  292. extern int8_t lcdRegisterRead(int32_t fd, uint8_t regType, uint16_t address, uint8_t *data, uint16_t dataLen);
  293. #endif /* LCMCOMM_DGUS_H_ */