hud.c 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507
  1. /*
  2. This is an example of how to write a library that allows user to pass in an I2C port
  3. Nathan Seidle
  4. SparkFun Electronics
  5. License: Public domain
  6. */
  7. #include "hud.h"
  8. //Initialize the I2C port
  9. bool begin(TwoWire & wirePort) {
  10. _i2cPort = & wirePort; //Grab which port the user wants us to use
  11. _i2cPort - > begin();
  12. initializeHUD231();
  13. }
  14. void AdjustIconLevel(uint16_t IconNo, uint16_t IconLevel) {
  15. uint16_t Temp;
  16. uint16_t Temp_I;
  17. uint8_t StartBytePos;
  18. uint8_t StartRGBPos;
  19. uint8_t EndBytePos;
  20. uint8_t EndRGBPos;
  21. uint8_t BumpNoTemp;
  22. uint8_t Counter;
  23. // uint8_t Result;
  24. if (IconLevel > 31) return; //If the IconLevel parameter is greater than 31, skip this function
  25. BumpNoTemp = IconData[IconNo].BumpNo;
  26. Temp = IconData[IconNo].StartBumpLocation; //Bump Location counts from 0
  27. StartBytePos = Temp / 3;
  28. StartRGBPos = Temp % 3; //A remainder of 0 means that the beginning Bump position is R, 1 means G, and 2 means B
  29. //==================================================================================================================================================================
  30. // Processing the first data
  31. // Maybe it's only this one, maybe there's more
  32. //==================================================================================================================================================================
  33. switch (StartRGBPos) {
  34. case 0: //Location in R
  35. if (BumpNoTemp == 1) {
  36. IconRamMap[IconData[IconNo].DriverNo][StartBytePos] = ChangeRedValue(IconRamMap[IconData[IconNo].DriverNo][StartBytePos], IconLevel);
  37. //Set the position setting to write
  38. SendDataBuffer[0] = 0x0A;
  39. SendDataBuffer[1] = StartBytePos >> 4; //X Start
  40. SendDataBuffer[2] = StartBytePos & 0x0F;
  41. SendDataBuffer[3] = 0x07; //X End
  42. SendDataBuffer[4] = 0x0F;
  43. SendDataBuffer[5] = 0; //Y Start
  44. SendDataBuffer[6] = 0;
  45. SendDataBuffer[7] = 0; //Y End
  46. SendDataBuffer[8] = 0;
  47. IIC_Write_Command1(IIC_Addr[IconData[IconNo].DriverNo], 9, SendDataBuffer);
  48. //Only 1 RGB data, go directly to the Data Send
  49. SendDataBuffer[0] = (IconRamMap[IconData[IconNo].DriverNo][StartBytePos] & 0xFF00) >> 8;
  50. SendDataBuffer[1] = IconRamMap[IconData[IconNo].DriverNo][StartBytePos] & 0xFF;
  51. IIC_Write_Data1(IIC_Addr[IconData[IconNo].DriverNo], 2, SendDataBuffer);
  52. return;
  53. } else if (BumpNoTemp == 2) {
  54. IconRamMap[IconData[IconNo].DriverNo][StartBytePos] = ChangeRG_Value(IconRamMap[IconData[IconNo].DriverNo][StartBytePos], IconLevel);
  55. //Set the position setting to write
  56. SendDataBuffer[0] = 0x0A;
  57. SendDataBuffer[1] = StartBytePos >> 4; //X Start
  58. SendDataBuffer[2] = StartBytePos & 0x0F;
  59. SendDataBuffer[3] = 0x07; //X End
  60. SendDataBuffer[4] = 0x0F;
  61. SendDataBuffer[5] = 0; //Y Start
  62. SendDataBuffer[6] = 0;
  63. SendDataBuffer[7] = 0; //Y End
  64. SendDataBuffer[8] = 0;
  65. IIC_Write_Command1(IIC_Addr[IconData[IconNo].DriverNo], 9, SendDataBuffer);
  66. //Only 1 RGB data, go directly to the Data Send
  67. SendDataBuffer[0] = (IconRamMap[IconData[IconNo].DriverNo][StartBytePos] & 0xFF00) >> 8;
  68. SendDataBuffer[1] = IconRamMap[IconData[IconNo].DriverNo][StartBytePos] & 0xFF;
  69. IIC_Write_Data1(IIC_Addr[IconData[IconNo].DriverNo], 2, SendDataBuffer);
  70. return;
  71. } else if (BumpNoTemp == 3) {
  72. IconRamMap[IconData[IconNo].DriverNo][StartBytePos] = SetRGB_Value(IconLevel);
  73. //Set the position setting to write
  74. SendDataBuffer[0] = 0x0A;
  75. SendDataBuffer[1] = StartBytePos >> 4; //X Start
  76. SendDataBuffer[2] = StartBytePos & 0x0F;
  77. SendDataBuffer[3] = 0x07; //X End
  78. SendDataBuffer[4] = 0x0F;
  79. SendDataBuffer[5] = 0; //Y Start
  80. SendDataBuffer[6] = 0;
  81. SendDataBuffer[7] = 0; //Y End
  82. SendDataBuffer[8] = 0;
  83. IIC_Write_Command1(IIC_Addr[IconData[IconNo].DriverNo], 9, SendDataBuffer);
  84. //Only 1 RGB data, go directly to the Data Send
  85. SendDataBuffer[0] = (IconRamMap[IconData[IconNo].DriverNo][StartBytePos] & 0xFF00) >> 8;
  86. SendDataBuffer[1] = IconRamMap[IconData[IconNo].DriverNo][StartBytePos] & 0xFF;
  87. IIC_Write_Data1(IIC_Addr[IconData[IconNo].DriverNo], 2, SendDataBuffer);
  88. return;
  89. } else if (BumpNoTemp > 3) //Said that Bump is greater than 3 (more than 1 RGB16bit data)
  90. {
  91. IconRamMap[IconData[IconNo].DriverNo][StartBytePos] = SetRGB_Value(IconLevel);
  92. //Set the position setting to write
  93. SendDataBuffer[0] = 0x0A;
  94. SendDataBuffer[1] = StartBytePos >> 4; //X Start
  95. SendDataBuffer[2] = StartBytePos & 0x0F;
  96. SendDataBuffer[3] = 0x07; //X End
  97. SendDataBuffer[4] = 0x0F;
  98. SendDataBuffer[5] = 0; //Y Start
  99. SendDataBuffer[6] = 0;
  100. SendDataBuffer[7] = 0; //Y End
  101. SendDataBuffer[8] = 0;
  102. IIC_Write_Command1(IIC_Addr[IconData[IconNo].DriverNo], 9, SendDataBuffer);
  103. //Store the first SEG data in Buffer
  104. SendDataBuffer[0] = (IconRamMap[IconData[IconNo].DriverNo][StartBytePos] & 0xFF00) >> 8; //Store the first data in Buffer 0 & 1
  105. SendDataBuffer[1] = IconRamMap[IconData[IconNo].DriverNo][StartBytePos] & 0xFF;
  106. BumpNoTemp = BumpNoTemp - 3;
  107. }
  108. break;
  109. case 1: //Location in G
  110. if (BumpNoTemp == 1) {
  111. IconRamMap[IconData[IconNo].DriverNo][StartBytePos] = ChangeGreenValue(IconRamMap[IconData[IconNo].DriverNo][StartBytePos], IconLevel);
  112. //Set the position setting to write
  113. SendDataBuffer[0] = 0x0A;
  114. SendDataBuffer[1] = StartBytePos >> 4; //X Start
  115. SendDataBuffer[2] = StartBytePos & 0x0F;
  116. SendDataBuffer[3] = 0x07; //X End
  117. SendDataBuffer[4] = 0x0F;
  118. SendDataBuffer[5] = 0; //Y Start
  119. SendDataBuffer[6] = 0;
  120. SendDataBuffer[7] = 0; //Y End
  121. SendDataBuffer[8] = 0;
  122. IIC_Write_Command1(IIC_Addr[IconData[IconNo].DriverNo], 9, SendDataBuffer);
  123. //Only 1 RGB data, go directly to the Data Send
  124. SendDataBuffer[0] = (IconRamMap[IconData[IconNo].DriverNo][StartBytePos] & 0xFF00) >> 8;
  125. SendDataBuffer[1] = IconRamMap[IconData[IconNo].DriverNo][StartBytePos] & 0xFF;
  126. IIC_Write_Data1(IIC_Addr[IconData[IconNo].DriverNo], 2, SendDataBuffer);
  127. return;
  128. } else if (BumpNoTemp == 2) {
  129. IconRamMap[IconData[IconNo].DriverNo][StartBytePos] = ChangeGB_Value(IconRamMap[IconData[IconNo].DriverNo][StartBytePos], IconLevel);
  130. //Set the position setting to write
  131. SendDataBuffer[0] = 0x0A;
  132. SendDataBuffer[1] = StartBytePos >> 4; //X Start
  133. SendDataBuffer[2] = StartBytePos & 0x0F;
  134. SendDataBuffer[3] = 0x07; //X End
  135. SendDataBuffer[4] = 0x0F;
  136. SendDataBuffer[5] = 0; //Y Start
  137. SendDataBuffer[6] = 0;
  138. SendDataBuffer[7] = 0; //Y End
  139. SendDataBuffer[8] = 0;
  140. IIC_Write_Command1(IIC_Addr[IconData[IconNo].DriverNo], 9, SendDataBuffer);
  141. //Only 1 RGB data, go directly to the Data Send
  142. SendDataBuffer[0] = (IconRamMap[IconData[IconNo].DriverNo][StartBytePos] & 0xFF00) >> 8;
  143. SendDataBuffer[1] = IconRamMap[IconData[IconNo].DriverNo][StartBytePos] & 0xFF;
  144. IIC_Write_Data1(IIC_Addr[IconData[IconNo].DriverNo], 2, SendDataBuffer);
  145. return;
  146. } else if (BumpNoTemp > 2) //Said that Bump is greater than 3 (more than 1 RGB16bit data)
  147. {
  148. IconRamMap[IconData[IconNo].DriverNo][StartBytePos] = ChangeGB_Value(IconRamMap[IconData[IconNo].DriverNo][StartBytePos], IconLevel);
  149. //Set the position setting to write
  150. SendDataBuffer[0] = 0x0A;
  151. SendDataBuffer[1] = StartBytePos >> 4; //X Start
  152. SendDataBuffer[2] = StartBytePos & 0x0F;
  153. SendDataBuffer[3] = 0x07; //X End
  154. SendDataBuffer[4] = 0x0F;
  155. SendDataBuffer[5] = 0; //Y Start
  156. SendDataBuffer[6] = 0;
  157. SendDataBuffer[7] = 0; //Y End
  158. SendDataBuffer[8] = 0;
  159. IIC_Write_Command1(IIC_Addr[IconData[IconNo].DriverNo], 9, SendDataBuffer);
  160. //Store the first SEG data in Buffer
  161. SendDataBuffer[0] = (IconRamMap[IconData[IconNo].DriverNo][StartBytePos] & 0xFF00) >> 8; //Store the first data in Buffer 0 & 1
  162. SendDataBuffer[1] = IconRamMap[IconData[IconNo].DriverNo][StartBytePos] & 0xFF;
  163. BumpNoTemp = BumpNoTemp - 2;
  164. }
  165. break;
  166. case 2: //Location in B
  167. if (BumpNoTemp == 1) {
  168. IconRamMap[IconData[IconNo].DriverNo][StartBytePos] = ChangeBlueValue(IconRamMap[IconData[IconNo].DriverNo][StartBytePos], IconLevel);
  169. //Set the position setting to write
  170. SendDataBuffer[0] = 0x0A;
  171. SendDataBuffer[1] = StartBytePos >> 4; //X Start
  172. SendDataBuffer[2] = StartBytePos & 0x0F;
  173. SendDataBuffer[3] = 0x07; //X End
  174. SendDataBuffer[4] = 0x0F;
  175. SendDataBuffer[5] = 0; //Y Start
  176. SendDataBuffer[6] = 0;
  177. SendDataBuffer[7] = 0; //Y End
  178. SendDataBuffer[8] = 0;
  179. IIC_Write_Command1(IIC_Addr[IconData[IconNo].DriverNo], 9, SendDataBuffer);
  180. //Only 1 RGB data, go directly to the Data Send
  181. SendDataBuffer[0] = (IconRamMap[IconData[IconNo].DriverNo][StartBytePos] & 0xFF00) >> 8;
  182. SendDataBuffer[1] = IconRamMap[IconData[IconNo].DriverNo][StartBytePos] & 0xFF;
  183. IIC_Write_Data1(IIC_Addr[IconData[IconNo].DriverNo], 2, SendDataBuffer);
  184. return;
  185. } else //Said that Bump is greater than 3 (more than 1 RGB16bit data)
  186. {
  187. IconRamMap[IconData[IconNo].DriverNo][StartBytePos] = ChangeBlueValue(IconRamMap[IconData[IconNo].DriverNo][StartBytePos], IconLevel);
  188. //Set the position setting to write
  189. SendDataBuffer[0] = 0x0A;
  190. SendDataBuffer[1] = StartBytePos >> 4; //X Start
  191. SendDataBuffer[2] = StartBytePos & 0x0F;
  192. SendDataBuffer[3] = 0x07; //X End
  193. SendDataBuffer[4] = 0x0F;
  194. SendDataBuffer[5] = 0; //Y Start
  195. SendDataBuffer[6] = 0;
  196. SendDataBuffer[7] = 0; //Y End
  197. SendDataBuffer[8] = 0;
  198. IIC_Write_Command1(IIC_Addr[IconData[IconNo].DriverNo], 9, SendDataBuffer);
  199. //Store the first SEG data in Buffer
  200. SendDataBuffer[0] = (IconRamMap[IconData[IconNo].DriverNo][StartBytePos] & 0xFF00) >> 8; //Store the first data in Buffer 0 & 1
  201. SendDataBuffer[1] = IconRamMap[IconData[IconNo].DriverNo][StartBytePos] & 0xFF;
  202. BumpNoTemp = BumpNoTemp - 1;
  203. }
  204. break;
  205. }
  206. //==================================================================================================================================================================
  207. //Processing later information
  208. //==================================================================================================================================================================
  209. EndBytePos = BumpNoTemp / 3;
  210. EndRGBPos = BumpNoTemp % 3;
  211. Counter = 1; //Previous [0], [1] store the data of the first SEG
  212. if (EndBytePos >= 1) //Process complete
  213. {
  214. //So far there are several complete RGB (16bit) data
  215. for (Temp_I = 1; Temp_I <= EndBytePos; Temp_I++) {
  216. IconRamMap[IconData[IconNo].DriverNo][StartBytePos + Temp_I] = SetRGB_Value(IconLevel);
  217. Counter = Counter + 1;
  218. SendDataBuffer[Counter] = (IconRamMap[IconData[IconNo].DriverNo][StartBytePos + Temp_I] & 0xFF00) >> 8; //Save High byte data in the following Buffer
  219. Counter = Counter + 1;
  220. SendDataBuffer[Counter] = IconRamMap[IconData[IconNo].DriverNo][StartBytePos + Temp_I] & 0xFF; //Save Low byte data in the following Buffer
  221. }
  222. if (EndRGBPos == 0) {
  223. //If there is no remainder, there is no need to process the remaining R, G, B bits. After exiting the entire batch of data, exit.
  224. IIC_Write_Data1(IIC_Addr[IconData[IconNo].DriverNo], Counter + 1, SendDataBuffer);
  225. return;
  226. }
  227. }
  228. //=================================================================================================================================================================
  229. //Check the remaining number of Bits
  230. switch (EndRGBPos) {
  231. case 1: //Location in R
  232. IconRamMap[IconData[IconNo].DriverNo][StartBytePos + EndBytePos + 1] = ChangeRedValue(IconRamMap[IconData[IconNo].DriverNo][StartBytePos + EndBytePos + 1], IconLevel);
  233. Counter = Counter + 1;
  234. //With this last data send out
  235. SendDataBuffer[Counter] = (IconRamMap[IconData[IconNo].DriverNo][StartBytePos + EndBytePos + 1] & 0xFF00) >> 8;
  236. Counter = Counter + 1;
  237. SendDataBuffer[Counter] = IconRamMap[IconData[IconNo].DriverNo][StartBytePos + EndBytePos + 1] & 0xFF;
  238. IIC_Write_Data1(IIC_Addr[IconData[IconNo].DriverNo], Counter + 1, SendDataBuffer);
  239. break;
  240. case 2: //Location in G
  241. IconRamMap[IconData[IconNo].DriverNo][StartBytePos + EndBytePos + 1] = ChangeRG_Value(IconRamMap[IconData[IconNo].DriverNo][StartBytePos + EndBytePos + 1], IconLevel);
  242. Counter = Counter + 1;
  243. //Together with this last data send out
  244. SendDataBuffer[Counter] = (IconRamMap[IconData[IconNo].DriverNo][StartBytePos + EndBytePos + 1] & 0xFF00) >> 8;
  245. Counter = Counter + 1;
  246. SendDataBuffer[Counter] = IconRamMap[IconData[IconNo].DriverNo][StartBytePos + EndBytePos + 1] & 0xFF;
  247. IIC_Write_Data1(IIC_Addr[IconData[IconNo].DriverNo], Counter + 1, SendDataBuffer);
  248. break;
  249. }
  250. }
  251. uint16_t ChangeRedValue(uint16_t OriginalValue, uint16_t R_Value) {
  252. uint16_t Temp;
  253. if (R_Value > 31) return 0; //If R value is greater than 31, return 0
  254. Temp = OriginalValue & 0x7FF; //Clear R (high 5 bits) to 0
  255. Temp = Temp | (R_Value << 11); //Set R new value back
  256. return Temp;
  257. }
  258. uint16_t ChangeGreenValue(uint16_t OriginalValue, uint16_t G_Value) {
  259. uint16_t Temp;
  260. if (G_Value > 31) return 0; //If the G value is greater than 31, return 0
  261. Temp = OriginalValue & 0xF81F; //Clear the G value (6 bits) to 0
  262. Temp = Temp | (G_Value << 6); //Set G high 5bit new value back
  263. if (G_Value > 0x0f)
  264. Temp = Temp | 0x20; //Set bit0 of G to 1
  265. else
  266. Temp = Temp & 0xFFDF; //Set bit0 of G to 0
  267. return Temp;
  268. }
  269. uint16_t ChangeBlueValue(uint16_t OriginalValue, uint16_t B_Value) {
  270. uint16_t Temp;
  271. if (B_Value > 31) return 0; //If the B value is greater than 31, then return 0
  272. Temp = OriginalValue & 0xFFE0; //Clear the B value (5 bits) to 0
  273. Temp = Temp | B_Value; //Set the new value of B 5bit back
  274. return Temp;
  275. }
  276. uint16_t ChangeRG_Value(uint16_t OriginalValue, uint16_t RG_Value) {
  277. uint16_t Temp;
  278. if (RG_Value > 31) return 0; //If the value is greater than 31, return 0
  279. Temp = OriginalValue & 0x1F; //Clear the RG value (11 bits) to 0
  280. Temp = Temp | (RG_Value << 11) | (RG_Value << 6); //Set R 5bit, G 6bit new value back
  281. if (RG_Value > 0x0f)
  282. Temp = Temp | 0x20; //Set bit0 of G to 1
  283. else
  284. Temp = Temp & 0xFFDF; //Set bit0 of G to 0
  285. return Temp;
  286. }
  287. uint16_t ChangeGB_Value(uint16_t OriginalValue, uint16_t GB_Value) {
  288. uint16_t Temp;
  289. if (GB_Value > 31) return 0; //If the value is greater than 31, return 0
  290. Temp = OriginalValue & 0xF800; //Clear the GB value (11 bits) to 0
  291. Temp = Temp | (GB_Value << 6) | GB_Value; //Set G 6bit, B 5bit new value back
  292. if (GB_Value > 0x0f)
  293. Temp = Temp | 0x20; //Set bit0 of G to 1
  294. else
  295. Temp = Temp & 0xFFDF; //Set bit0 of G to 0
  296. return Temp;
  297. }
  298. uint16_t SetRGB_Value(uint16_t RGB_Value) {
  299. uint16_t Temp;
  300. if (RGB_Value > 31) return 0; //If the value is greater than 31, return 0
  301. Temp = (RGB_Value << 11) | (RGB_Value << 6) | RGB_Value;
  302. if (RGB_Value > 0x0f)
  303. Temp = Temp | 0x20; //Set bit0 of G to 1
  304. else
  305. Temp = Temp & 0xFFDF; //Set bit0 of G to 0
  306. return Temp;
  307. }
  308. void NumericalTo4BCD(uint16_t S_Number, uint8_t * BCD_Ptr) {
  309. uint8_t i;
  310. uint16_t Quotient;
  311. uint16_t QuotienNav;
  312. Quotient = S_Number;
  313. for (i = 0; i <= 3; i++) {
  314. QuotienNav = Quotient / 10;
  315. BCD_Ptr[i] = Quotient % 10;
  316. Quotient = QuotienNav;
  317. }
  318. }
  319. //=======================================================================================================
  320. //The following for HUD231 standard products
  321. //=======================================================================================================
  322. void AdjustIconAction(uint16_t IconNo, bool Action) {
  323. if (Action) {
  324. AdjustIconLevel(IconNo, IconData[IconNo].Level);
  325. } else {
  326. AdjustIconLevel(IconNo, 0x00);
  327. }
  328. }
  329. #define D01(Action) AdjustIconAction(0, Action)
  330. #define D02(Action) AdjustIconAction(2, Action)
  331. #define D03(Action) AdjustIconAction(4, Action)
  332. #define D04(Action) AdjustIconAction(9, Action)
  333. #define D05(Action) AdjustIconAction(18, Action)
  334. #define D06(Action) AdjustIconAction(26, Action)
  335. #define D07(Action) AdjustIconAction(29, Action)
  336. #define D08(Action) AdjustIconAction(31, Action)
  337. #define CC1(Action) AdjustIconAction(1, Action)
  338. #define CC2(Action) AdjustIconAction(3, Action)
  339. #define CC3(Action) AdjustIconAction(5, Action)
  340. #define CC4(Action) AdjustIconAction(8, Action)
  341. #define CC5(Action) AdjustIconAction(17, Action)
  342. #define CC6(Action) AdjustIconAction(27, Action)
  343. #define CC7(Action) AdjustIconAction(28, Action)
  344. #define CC8(Action) AdjustIconAction(30, Action)
  345. //0-9 00-full off 1-8 => specify which CCx goes off 9-all bright 10-17=> specifies which CCx is on (inverse with 1-8)
  346. void compassCircle(uint8_t Select) {
  347. switch (Select) {
  348. case 0: CC1(0); CC2(0); CC3(0); CC4(0); CC5(0); CC6(0); CC7(0); CC8(0); break;
  349. case 1: CC1(1); CC2(0); CC3(0); CC4(0); CC5(0); CC6(0); CC7(0); CC8(0); break;
  350. case 2: CC1(0); CC2(1); CC3(0); CC4(0); CC5(0); CC6(0); CC7(0); CC8(0); break;
  351. case 3: CC1(0); CC2(0); CC3(1); CC4(0); CC5(0); CC6(0); CC7(0); CC8(0); break;
  352. case 4: CC1(0); CC2(0); CC3(0); CC4(1); CC5(0); CC6(0); CC7(0); CC8(0); break;
  353. case 5: CC1(0); CC2(0); CC3(0); CC4(0); CC5(1); CC6(0); CC7(0); CC8(0); break;
  354. case 6: CC1(0); CC2(0); CC3(0); CC4(0); CC5(0); CC6(1); CC7(0); CC8(0); break;
  355. case 7: CC1(0); CC2(0); CC3(0); CC4(0); CC5(0); CC6(0); CC7(1); CC8(0); break;
  356. case 8: CC1(0); CC2(0); CC3(0); CC4(0); CC5(0); CC6(0); CC7(0); CC8(1); break;
  357. case 9: CC1(1); CC2(1); CC3(1); CC4(1); CC5(1); CC6(1); CC7(1); CC8(1); break;
  358. case 10: CC1(0); CC2(1); CC3(1); CC4(1); CC5(1); CC6(1); CC7(1); CC8(1); break;
  359. case 11: CC1(1); CC2(0); CC3(1); CC4(1); CC5(1); CC6(1); CC7(1); CC8(1); break;
  360. case 12: CC1(1); CC2(1); CC3(0); CC4(1); CC5(1); CC6(1); CC7(1); CC8(1); break;
  361. case 13: CC1(1); CC2(1); CC3(1); CC4(0); CC5(1); CC6(1); CC7(1); CC8(1); break;
  362. case 14: CC1(1); CC2(1); CC3(1); CC4(1); CC5(0); CC6(1); CC7(1); CC8(1); break;
  363. case 15: CC1(1); CC2(1); CC3(1); CC4(1); CC5(1); CC6(0); CC7(1); CC8(1); break;
  364. case 16: CC1(1); CC2(1); CC3(1); CC4(1); CC5(1); CC6(1); CC7(0); CC8(1); break;
  365. case 17: CC1(1); CC2(1); CC3(1); CC4(1); CC5(1); CC6(1); CC7(1); CC8(0); break;
  366. }
  367. }
  368. void D0x(uint8_t Action) {
  369. if (Action) {
  370. D01(1); D02(1); D03(1); D04(1); D05(1); D06(1); D07(1); D08(1);
  371. } else {
  372. D01(0); D02(0); D03(0); D04(0); D05(0); D06(0); D07(0); D08(0);
  373. }
  374. }
  375. //0-9 00-full off 1-8 => specify which one is off D0x 9-all bright 10-17=> specify which one D0x is on (inverse with 1-8)
  376. void compassArrows(uint8_t Select) {
  377. switch (Select) {
  378. case 0: D01(0); D02(0); D03(0); D04(0); D05(0); D06(0); D07(0); D08(0); break;
  379. case 1: D01(1); D02(0); D03(0); D04(0); D05(0); D06(0); D07(0); D08(0); break;
  380. case 2: D01(0); D02(1); D03(0); D04(0); D05(0); D06(0); D07(0); D08(0); break;
  381. case 3: D01(0); D02(0); D03(1); D04(0); D05(0); D06(0); D07(0); D08(0); break;
  382. case 4: D01(0); D02(0); D03(0); D04(1); D05(0); D06(0); D07(0); D08(0); break;
  383. case 5: D01(0); D02(0); D03(0); D04(0); D05(1); D06(0); D07(0); D08(0); break;
  384. case 6: D01(0); D02(0); D03(0); D04(0); D05(0); D06(1); D07(0); D08(0); break;
  385. case 7: D01(0); D02(0); D03(0); D04(0); D05(0); D06(0); D07(1); D08(0); break;
  386. case 8: D01(0); D02(0); D03(0); D04(0); D05(0); D06(0); D07(0); D08(1); break;
  387. case 9: D01(1); D02(1); D03(1); D04(1); D05(1); D06(1); D07(1); D08(1); break;
  388. case 10: D01(0); D02(1); D03(1); D04(1); D05(1); D06(1); D07(1); D08(1); break;
  389. case 11: D01(1); D02(0); D03(1); D04(1); D05(1); D06(1); D07(1); D08(1); break;
  390. case 12: D01(1); D02(1); D03(0); D04(1); D05(1); D06(1); D07(1); D08(1); break;
  391. case 13: D01(1); D02(1); D03(1); D04(0); D05(1); D06(1); D07(1); D08(1); break;
  392. case 14: D01(1); D02(1); D03(1); D04(1); D05(0); D06(1); D07(1); D08(1); break;
  393. case 15: D01(1); D02(1); D03(1); D04(1); D05(1); D06(0); D07(1); D08(1); break;
  394. case 16: D01(1); D02(1); D03(1); D04(1); D05(1); D06(1); D07(0); D08(1); break;
  395. case 17: D01(1); D02(1); D03(1); D04(1); D05(1); D06(1); D07(1); D08(0); break;
  396. }
  397. }
  398. #define radarDistanceUnits(Action) AdjustIconAction(80, Action)
  399. #define flag(Action) AdjustIconAction(32, Action)
  400. #define C01(Action) AdjustIconAction(40, Action)
  401. #define C02(Action) AdjustIconAction(48, Action)
  402. #define H01(Action) AdjustIconAction(58, Action)
  403. #define K01(Action) AdjustIconAction(56, Action)
  404. #define M01(Action) AdjustIconAction(57, Action)
  405. #define C03(Action) AdjustIconAction(145, Action)
  406. #define K02(Action) AdjustIconAction(153, Action)
  407. #define M03(Action) AdjustIconAction(154, Action)
  408. #define P01(Action) AdjustIconAction(211, Action)
  409. #define P02(Action) AdjustIconAction(212, Action)
  410. #define P03(Action) AdjustIconAction(213, Action)
  411. #define T01(Action) AdjustIconAction(189, Action)
  412. #define T02(Action) AdjustIconAction(197, Action)
  413. void tirePressureAlert(uint8_t Action) {
  414. switch (Action) {
  415. case 0: // Blank
  416. T01(0); // "tire"
  417. T02(0); // "TPMS"
  418. break;
  419. case 1: // TPMS
  420. T01(0); // "tire"
  421. T02(1); // "TPMS"
  422. break;
  423. case 2: // Tire
  424. T01(1); // "tire"
  425. T02(0); // "TPMS"
  426. break;
  427. case 3: // Both
  428. T01(1); // "tire"
  429. T02(1); // "TPMS"
  430. break;
  431. }
  432. }
  433. #define speedometerUnits(Action) AdjustIconAction(230, Action)
  434. void destinationDistanceUnits(uint8_t iconUnits) {
  435. switch (iconUnits) {
  436. case 0: // Blank
  437. H01(0); // hours
  438. K01(0); // kilo
  439. M01(0); // meters
  440. break;
  441. case 1: // hours
  442. H01(1); // hours
  443. K01(0); // kilo
  444. M01(0); // meters
  445. break;
  446. case 2: // meters
  447. H01(0); // hours
  448. K01(0); // kilo
  449. M01(1); // meters
  450. break;
  451. case 3: // kilometers
  452. H01(0); // hours
  453. K01(1); // kilo
  454. M01(1); // meters
  455. break;
  456. }
  457. }
  458. void turnDistanceUnits(uint8_t iconUnits) {
  459. switch (iconUnits) {
  460. case 0: // Blank
  461. K02(0); // kilo
  462. M03(0); // meters
  463. break;
  464. case 1: // meters
  465. K02(0); // kilo
  466. M03(1); // meters
  467. break;
  468. case 2: // kilometers
  469. K02(1); // kilo
  470. M03(1); // meters
  471. break;
  472. }
  473. }
  474. void leftTunnel(uint8_t Action) {
  475. if (Action) {
  476. AdjustIconLevel(91, IconData[91].Level);
  477. AdjustIconLevel(92, IconData[92].Level);
  478. AdjustIconLevel(93, IconData[93].Level);
  479. AdjustIconLevel(94, IconData[94].Level);
  480. AdjustIconLevel(95, IconData[95].Level);
  481. AdjustIconLevel(96, IconData[96].Level);
  482. AdjustIconLevel(97, IconData[97].Level);
  483. AdjustIconLevel(98, IconData[98].Level);
  484. AdjustIconLevel(99, IconData[99].Level);
  485. } else {
  486. AdjustIconLevel(91, 0x00);
  487. AdjustIconLevel(92, 0x00);
  488. AdjustIconLevel(93, 0x00);
  489. AdjustIconLevel(94, 0x00);
  490. AdjustIconLevel(95, 0x00);
  491. AdjustIconLevel(96, 0x00);
  492. AdjustIconLevel(97, 0x00);
  493. AdjustIconLevel(98, 0x00);
  494. AdjustIconLevel(99, 0x00);
  495. }
  496. }
  497. void middleTunnel(uint8_t Action) {
  498. if (Action) {
  499. AdjustIconLevel(89, IconData[89].Level);
  500. AdjustIconLevel(90, IconData[90].Level);
  501. AdjustIconLevel(100, IconData[100].Level);
  502. AdjustIconLevel(101, IconData[101].Level);
  503. AdjustIconLevel(102, IconData[102].Level);
  504. AdjustIconLevel(198, IconData[198].Level);
  505. AdjustIconLevel(199, IconData[199].Level);
  506. AdjustIconLevel(209, IconData[209].Level);
  507. AdjustIconLevel(210, IconData[210].Level);
  508. } else {
  509. AdjustIconLevel(89, 0x00);
  510. AdjustIconLevel(90, 0x00);
  511. AdjustIconLevel(100, 0x00);
  512. AdjustIconLevel(101, 0x00);
  513. AdjustIconLevel(102, 0x00);
  514. AdjustIconLevel(198, 0x00);
  515. AdjustIconLevel(199, 0x00);
  516. AdjustIconLevel(209, 0x00);
  517. AdjustIconLevel(210, 0x00);
  518. }
  519. }
  520. void rightTunnel(uint8_t Action) {
  521. if (Action) {
  522. AdjustIconLevel(200, IconData[200].Level);
  523. AdjustIconLevel(201, IconData[201].Level);
  524. AdjustIconLevel(202, IconData[202].Level);
  525. AdjustIconLevel(203, IconData[203].Level);
  526. AdjustIconLevel(204, IconData[204].Level);
  527. AdjustIconLevel(205, IconData[205].Level);
  528. AdjustIconLevel(206, IconData[206].Level);
  529. AdjustIconLevel(207, IconData[207].Level);
  530. AdjustIconLevel(208, IconData[208].Level);
  531. } else {
  532. AdjustIconLevel(200, 0x00);
  533. AdjustIconLevel(201, 0x00);
  534. AdjustIconLevel(202, 0x00);
  535. AdjustIconLevel(203, 0x00);
  536. AdjustIconLevel(204, 0x00);
  537. AdjustIconLevel(205, 0x00);
  538. AdjustIconLevel(206, 0x00);
  539. AdjustIconLevel(207, 0x00);
  540. AdjustIconLevel(208, 0x00);
  541. }
  542. }
  543. void leftRoad(uint8_t Action) {
  544. if (Action) {
  545. AdjustIconLevel(91, IconData[91].Level);
  546. AdjustIconLevel(94, IconData[94].Level);
  547. AdjustIconLevel(95, IconData[95].Level);
  548. AdjustIconLevel(99, IconData[99].Level);
  549. } else {
  550. AdjustIconLevel(91, 0x00);
  551. AdjustIconLevel(94, 0x00);
  552. AdjustIconLevel(95, 0x00);
  553. AdjustIconLevel(99, 0x00);
  554. }
  555. }
  556. void middleRoad(uint8_t Action) {
  557. if (Action) {
  558. AdjustIconLevel(90, IconData[90].Level);
  559. AdjustIconLevel(100, IconData[100].Level);
  560. AdjustIconLevel(199, IconData[199].Level);
  561. AdjustIconLevel(209, IconData[209].Level);
  562. } else {
  563. AdjustIconLevel(90, 0x00);
  564. AdjustIconLevel(100, 0x00);
  565. AdjustIconLevel(199, 0x00);
  566. AdjustIconLevel(209, 0x00);
  567. }
  568. }
  569. void rightRoad(uint8_t Action) {
  570. if (Action) {
  571. AdjustIconLevel(200, IconData[200].Level);
  572. AdjustIconLevel(204, IconData[204].Level);
  573. AdjustIconLevel(205, IconData[205].Level);
  574. AdjustIconLevel(208, IconData[208].Level);
  575. } else {
  576. AdjustIconLevel(200, 0x00);
  577. AdjustIconLevel(204, 0x00);
  578. AdjustIconLevel(205, 0x00);
  579. AdjustIconLevel(208, 0x00);
  580. }
  581. }
  582. void nav_Group(uint8_t Action) {
  583. uint8_t i;
  584. if (Action) {
  585. for (i = 103; i <= 130; i++) {
  586. AdjustIconLevel(i, IconData[i].Level);
  587. }
  588. for (i = 155; i <= 181; i++) {
  589. AdjustIconLevel(i, IconData[i].Level);
  590. }
  591. } else {
  592. for (i = 103; i <= 130; i++) {
  593. AdjustIconLevel(i, 0x00);
  594. }
  595. for (i = 155; i <= 181; i++) {
  596. AdjustIconLevel(i, 0x00);
  597. }
  598. }
  599. }
  600. void nav_KeepLeft(uint8_t Action) {
  601. if (Action) {
  602. AdjustIconLevel(107, IconData[107].Level);
  603. AdjustIconLevel(108, IconData[108].Level);
  604. AdjustIconLevel(109, IconData[109].Level);
  605. AdjustIconLevel(106, IconData[106].Level);
  606. AdjustIconLevel(111, IconData[111].Level);
  607. AdjustIconLevel(112, IconData[112].Level);
  608. AdjustIconLevel(105, IconData[105].Level);
  609. AdjustIconLevel(128, IconData[128].Level);
  610. AdjustIconLevel(129, IconData[129].Level);
  611. AdjustIconLevel(155, IconData[155].Level);
  612. AdjustIconLevel(130, IconData[130].Level);
  613. } else {
  614. AdjustIconLevel(107, 0x00);
  615. AdjustIconLevel(108, 0x00);
  616. AdjustIconLevel(109, 0x00);
  617. AdjustIconLevel(106, 0x00);
  618. AdjustIconLevel(111, 0x00);
  619. AdjustIconLevel(112, 0x00);
  620. AdjustIconLevel(105, 0x00);
  621. AdjustIconLevel(128, 0x00);
  622. AdjustIconLevel(129, 0x00);
  623. AdjustIconLevel(155, 0x00);
  624. AdjustIconLevel(130, 0x00);
  625. }
  626. }
  627. void nav_TurnLeft(uint8_t Action) {
  628. if (Action) {
  629. AdjustIconLevel(113, IconData[113].Level);
  630. AdjustIconLevel(114, IconData[114].Level);
  631. AdjustIconLevel(121, IconData[121].Level);
  632. AdjustIconLevel(111, IconData[111].Level);
  633. AdjustIconLevel(112, IconData[112].Level);
  634. AdjustIconLevel(115, IconData[116].Level);
  635. AdjustIconLevel(128, IconData[128].Level);
  636. AdjustIconLevel(129, IconData[129].Level);
  637. AdjustIconLevel(155, IconData[155].Level);
  638. AdjustIconLevel(130, IconData[130].Level);
  639. } else {
  640. AdjustIconLevel(113, 0x00);
  641. AdjustIconLevel(114, 0x00);
  642. AdjustIconLevel(121, 0x00);
  643. AdjustIconLevel(111, 0x00);
  644. AdjustIconLevel(112, 0x00);
  645. AdjustIconLevel(115, 0x00);
  646. AdjustIconLevel(128, 0x00);
  647. AdjustIconLevel(129, 0x00);
  648. AdjustIconLevel(155, 0x00);
  649. AdjustIconLevel(130, 0x00);
  650. }
  651. }
  652. void nav_TurnRight(uint8_t Action) {
  653. if (Action) {
  654. AdjustIconLevel(171, IconData[171].Level);
  655. AdjustIconLevel(170, IconData[170].Level);
  656. AdjustIconLevel(163, IconData[163].Level);
  657. AdjustIconLevel(173, IconData[173].Level);
  658. AdjustIconLevel(172, IconData[172].Level);
  659. AdjustIconLevel(169, IconData[169].Level);
  660. AdjustIconLevel(156, IconData[156].Level);
  661. AdjustIconLevel(129, IconData[129].Level);
  662. AdjustIconLevel(155, IconData[155].Level);
  663. AdjustIconLevel(130, IconData[130].Level);
  664. } else {
  665. AdjustIconLevel(171, 0x00);
  666. AdjustIconLevel(170, 0x00);
  667. AdjustIconLevel(163, 0x00);
  668. AdjustIconLevel(173, 0x00);
  669. AdjustIconLevel(172, 0x00);
  670. AdjustIconLevel(169, 0x00);
  671. AdjustIconLevel(156, 0x00);
  672. AdjustIconLevel(129, 0x00);
  673. AdjustIconLevel(155, 0x00);
  674. AdjustIconLevel(130, 0x00);
  675. }
  676. }
  677. void nav_HardRight(uint8_t Action) {
  678. if (Action) {
  679. AdjustIconLevel(165, IconData[165].Level);
  680. AdjustIconLevel(159, IconData[159].Level);
  681. AdjustIconLevel(163, IconData[163].Level);
  682. AdjustIconLevel(160, IconData[160].Level);
  683. AdjustIconLevel(158, IconData[158].Level);
  684. AdjustIconLevel(166, IconData[166].Level);
  685. AdjustIconLevel(156, IconData[156].Level);
  686. AdjustIconLevel(129, IconData[129].Level);
  687. AdjustIconLevel(155, IconData[155].Level);
  688. AdjustIconLevel(130, IconData[130].Level);
  689. } else {
  690. AdjustIconLevel(165, 0x00);
  691. AdjustIconLevel(159, 0x00);
  692. AdjustIconLevel(163, 0x00);
  693. AdjustIconLevel(160, 0x00);
  694. AdjustIconLevel(158, 0x00);
  695. AdjustIconLevel(166, 0x00);
  696. AdjustIconLevel(156, 0x00);
  697. AdjustIconLevel(129, 0x00);
  698. AdjustIconLevel(155, 0x00);
  699. AdjustIconLevel(130, 0x00);
  700. }
  701. }
  702. void nav_HardLeft(uint8_t Action) {
  703. if (Action) {
  704. AdjustIconLevel(119, IconData[119].Level);
  705. AdjustIconLevel(125, IconData[125].Level);
  706. AdjustIconLevel(121, IconData[121].Level);
  707. AdjustIconLevel(124, IconData[124].Level);
  708. AdjustIconLevel(126, IconData[126].Level);
  709. AdjustIconLevel(118, IconData[118].Level);
  710. AdjustIconLevel(128, IconData[128].Level);
  711. AdjustIconLevel(129, IconData[129].Level);
  712. AdjustIconLevel(155, IconData[155].Level);
  713. AdjustIconLevel(130, IconData[130].Level);
  714. } else {
  715. AdjustIconLevel(119, 0x00);
  716. AdjustIconLevel(125, 0x00);
  717. AdjustIconLevel(121, 0x00);
  718. AdjustIconLevel(124, 0x00);
  719. AdjustIconLevel(126, 0x00);
  720. AdjustIconLevel(118, 0x00);
  721. AdjustIconLevel(128, 0x00);
  722. AdjustIconLevel(129, 0x00);
  723. AdjustIconLevel(155, 0x00);
  724. AdjustIconLevel(130, 0x00);
  725. }
  726. }
  727. void nav_UTurnLeft(uint8_t Action) {
  728. if (Action) {
  729. AdjustIconLevel(162, IconData[162].Level);
  730. AdjustIconLevel(166, IconData[166].Level);
  731. AdjustIconLevel(167, IconData[167].Level);
  732. AdjustIconLevel(168, IconData[168].Level);
  733. AdjustIconLevel(170, IconData[170].Level);
  734. AdjustIconLevel(174, IconData[174].Level);
  735. AdjustIconLevel(176, IconData[176].Level);
  736. AdjustIconLevel(179, IconData[179].Level);
  737. AdjustIconLevel(180, IconData[180].Level);
  738. AdjustIconLevel(104, IconData[104].Level);
  739. AdjustIconLevel(108, IconData[108].Level);
  740. AdjustIconLevel(110, IconData[110].Level);
  741. AdjustIconLevel(114, IconData[114].Level);
  742. AdjustIconLevel(116, IconData[116].Level);
  743. AdjustIconLevel(117, IconData[117].Level);
  744. AdjustIconLevel(118, IconData[118].Level);
  745. AdjustIconLevel(122, IconData[122].Level);
  746. AdjustIconLevel(123, IconData[123].Level);
  747. } else {
  748. AdjustIconLevel(162, 0x00);
  749. AdjustIconLevel(166, 0x00);
  750. AdjustIconLevel(167, 0x00);
  751. AdjustIconLevel(168, 0x00);
  752. AdjustIconLevel(170, 0x00);
  753. AdjustIconLevel(174, 0x00);
  754. AdjustIconLevel(176, 0x00);
  755. AdjustIconLevel(179, 0x00);
  756. AdjustIconLevel(180, 0x00);
  757. AdjustIconLevel(104, 0x00);
  758. AdjustIconLevel(108, 0x00);
  759. AdjustIconLevel(110, 0x00);
  760. AdjustIconLevel(114, 0x00);
  761. AdjustIconLevel(116, 0x00);
  762. AdjustIconLevel(117, 0x00);
  763. AdjustIconLevel(118, 0x00);
  764. AdjustIconLevel(122, 0x00);
  765. AdjustIconLevel(123, 0x00);
  766. }
  767. }
  768. void nav_UTurnRight(uint8_t Action) {
  769. if (Action) {
  770. AdjustIconLevel(162, IconData[162].Level);
  771. AdjustIconLevel(166, IconData[166].Level);
  772. AdjustIconLevel(167, IconData[167].Level);
  773. AdjustIconLevel(168, IconData[168].Level);
  774. AdjustIconLevel(170, IconData[170].Level);
  775. AdjustIconLevel(174, IconData[174].Level);
  776. AdjustIconLevel(176, IconData[176].Level);
  777. AdjustIconLevel(179, IconData[179].Level);
  778. AdjustIconLevel(180, IconData[180].Level);
  779. AdjustIconLevel(104, IconData[104].Level);
  780. AdjustIconLevel(108, IconData[108].Level);
  781. AdjustIconLevel(110, IconData[110].Level);
  782. AdjustIconLevel(114, IconData[114].Level);
  783. AdjustIconLevel(116, IconData[116].Level);
  784. AdjustIconLevel(117, IconData[117].Level);
  785. AdjustIconLevel(118, IconData[118].Level);
  786. AdjustIconLevel(122, IconData[122].Level);
  787. AdjustIconLevel(161, IconData[161].Level);
  788. } else {
  789. AdjustIconLevel(162, 0x00);
  790. AdjustIconLevel(166, 0x00);
  791. AdjustIconLevel(167, 0x00);
  792. AdjustIconLevel(168, 0x00);
  793. AdjustIconLevel(170, 0x00);
  794. AdjustIconLevel(174, 0x00);
  795. AdjustIconLevel(176, 0x00);
  796. AdjustIconLevel(179, 0x00);
  797. AdjustIconLevel(180, 0x00);
  798. AdjustIconLevel(104, 0x00);
  799. AdjustIconLevel(108, 0x00);
  800. AdjustIconLevel(110, 0x00);
  801. AdjustIconLevel(114, 0x00);
  802. AdjustIconLevel(116, 0x00);
  803. AdjustIconLevel(117, 0x00);
  804. AdjustIconLevel(118, 0x00);
  805. AdjustIconLevel(122, 0x00);
  806. AdjustIconLevel(161, 0x00);
  807. }
  808. }
  809. void nav_ContinueStraight(uint8_t Action) {
  810. // uint8_t i;
  811. if (Action) {
  812. AdjustIconLevel(181, IconData[181].Level);
  813. AdjustIconLevel(180, IconData[180].Level);
  814. AdjustIconLevel(103, IconData[103].Level);
  815. AdjustIconLevel(178, IconData[178].Level);
  816. AdjustIconLevel(105, IconData[105].Level);
  817. AdjustIconLevel(106, IconData[106].Level);
  818. AdjustIconLevel(173, IconData[173].Level);
  819. AdjustIconLevel(111, IconData[111].Level);
  820. AdjustIconLevel(129, IconData[129].Level);
  821. AdjustIconLevel(155, IconData[155].Level);
  822. AdjustIconLevel(130, IconData[130].Level);
  823. } else {
  824. AdjustIconLevel(181, 0x00);
  825. AdjustIconLevel(180, 0x00);
  826. AdjustIconLevel(103, 0x00);
  827. AdjustIconLevel(178, 0x00);
  828. AdjustIconLevel(105, 0x00);
  829. AdjustIconLevel(106, 0x00);
  830. AdjustIconLevel(173, 0x00);
  831. AdjustIconLevel(111, 0x00);
  832. AdjustIconLevel(129, 0x00);
  833. AdjustIconLevel(155, 0x00);
  834. AdjustIconLevel(130, 0x00);
  835. }
  836. }
  837. void nav_KeepRight(uint8_t Action) {
  838. // uint8_t i;
  839. if (Action) {
  840. AdjustIconLevel(105, IconData[105].Level);
  841. AdjustIconLevel(177, IconData[177].Level);
  842. AdjustIconLevel(176, IconData[176].Level);
  843. AdjustIconLevel(175, IconData[175].Level);
  844. AdjustIconLevel(172, IconData[172].Level);
  845. AdjustIconLevel(173, IconData[173].Level);
  846. AdjustIconLevel(178, IconData[178].Level);
  847. AdjustIconLevel(156, IconData[156].Level);
  848. AdjustIconLevel(129, IconData[129].Level);
  849. AdjustIconLevel(155, IconData[155].Level);
  850. AdjustIconLevel(130, IconData[130].Level);
  851. } else {
  852. AdjustIconLevel(105, 0x00);
  853. AdjustIconLevel(177, 0x00);
  854. AdjustIconLevel(176, 0x00);
  855. AdjustIconLevel(175, 0x00);
  856. AdjustIconLevel(172, 0x00);
  857. AdjustIconLevel(173, 0x00);
  858. AdjustIconLevel(178, 0x00);
  859. AdjustIconLevel(156, 0x00);
  860. AdjustIconLevel(129, 0x00);
  861. AdjustIconLevel(155, 0x00);
  862. AdjustIconLevel(130, 0x00);
  863. }
  864. }
  865. void radarDetector(uint8_t Level) //00-08 00-全滅 01-主體 02-08 =>Level
  866. {
  867. switch (Level) {
  868. case 0:
  869. AdjustIconLevel(81, 0x00); //R01
  870. AdjustIconLevel(82, 0x00); //R02
  871. AdjustIconLevel(83, 0x00); //R03
  872. AdjustIconLevel(84, 0x00); //R04
  873. AdjustIconLevel(85, 0x00); //R05
  874. AdjustIconLevel(86, 0x00); //R06
  875. AdjustIconLevel(87, 0x00); //R07
  876. AdjustIconLevel(88, 0x00); //R08
  877. break;
  878. case 1:
  879. AdjustIconLevel(81, IconData[81].Level); //R01
  880. AdjustIconLevel(82, 0x00); //R02
  881. AdjustIconLevel(83, 0x00); //R03
  882. AdjustIconLevel(84, 0x00); //R04
  883. AdjustIconLevel(85, 0x00); //R05
  884. AdjustIconLevel(86, 0x00); //R06
  885. AdjustIconLevel(87, 0x00); //R07
  886. AdjustIconLevel(88, 0x00); //R08
  887. break;
  888. case 2:
  889. AdjustIconLevel(81, IconData[81].Level); //R01
  890. AdjustIconLevel(82, IconData[82].Level); //R02
  891. AdjustIconLevel(83, 0x00); //R03
  892. AdjustIconLevel(84, 0x00); //R04
  893. AdjustIconLevel(85, 0x00); //R05
  894. AdjustIconLevel(86, 0x00); //R06
  895. AdjustIconLevel(87, 0x00); //R07
  896. AdjustIconLevel(88, 0x00); //R08
  897. break;
  898. case 3:
  899. AdjustIconLevel(81, IconData[81].Level); //R01
  900. AdjustIconLevel(82, IconData[82].Level); //R02
  901. AdjustIconLevel(83, IconData[83].Level); //R03
  902. AdjustIconLevel(84, 0x00); //R04
  903. AdjustIconLevel(85, 0x00); //R05
  904. AdjustIconLevel(86, 0x00); //R06
  905. AdjustIconLevel(87, 0x00); //R07
  906. AdjustIconLevel(88, 0x00); //R08
  907. break;
  908. case 4:
  909. AdjustIconLevel(81, IconData[81].Level); //R01
  910. AdjustIconLevel(82, IconData[82].Level); //R02
  911. AdjustIconLevel(83, IconData[83].Level); //R03
  912. AdjustIconLevel(84, IconData[84].Level); //R04
  913. AdjustIconLevel(85, 0x00); //R05
  914. AdjustIconLevel(86, 0x00); //R06
  915. AdjustIconLevel(87, 0x00); //R07
  916. AdjustIconLevel(88, 0x00); //R08
  917. break;
  918. case 5:
  919. AdjustIconLevel(81, IconData[81].Level); //R01
  920. AdjustIconLevel(82, IconData[82].Level); //R02
  921. AdjustIconLevel(83, IconData[83].Level); //R03
  922. AdjustIconLevel(84, IconData[84].Level); //R04
  923. AdjustIconLevel(85, IconData[85].Level); //R05
  924. AdjustIconLevel(86, 0x00); //R06
  925. AdjustIconLevel(87, 0x00); //R07
  926. AdjustIconLevel(88, 0x00); //R08
  927. break;
  928. case 6:
  929. AdjustIconLevel(81, IconData[81].Level); //R01
  930. AdjustIconLevel(82, IconData[82].Level); //R02
  931. AdjustIconLevel(83, IconData[83].Level); //R03
  932. AdjustIconLevel(84, IconData[84].Level); //R04
  933. AdjustIconLevel(85, IconData[85].Level); //R05
  934. AdjustIconLevel(86, IconData[86].Level); //R06
  935. AdjustIconLevel(87, 0x00); //R07
  936. AdjustIconLevel(88, 0x00); //R08
  937. break;
  938. case 7:
  939. AdjustIconLevel(81, IconData[81].Level); //R01
  940. AdjustIconLevel(82, IconData[82].Level); //R02
  941. AdjustIconLevel(83, IconData[83].Level); //R03
  942. AdjustIconLevel(84, IconData[84].Level); //R04
  943. AdjustIconLevel(85, IconData[85].Level); //R05
  944. AdjustIconLevel(86, IconData[86].Level); //R06
  945. AdjustIconLevel(87, IconData[87].Level); //R07
  946. AdjustIconLevel(88, 0x00); //R08
  947. break;
  948. case 8:
  949. AdjustIconLevel(81, IconData[81].Level); //R01
  950. AdjustIconLevel(82, IconData[82].Level); //R02
  951. AdjustIconLevel(83, IconData[83].Level); //R03
  952. AdjustIconLevel(84, IconData[84].Level); //R04
  953. AdjustIconLevel(85, IconData[85].Level); //R05
  954. AdjustIconLevel(86, IconData[86].Level); //R06
  955. AdjustIconLevel(87, IconData[87].Level); //R07
  956. AdjustIconLevel(88, IconData[88].Level); //R08
  957. break;
  958. };
  959. }
  960. void DispNumber(const uint16_t * SegIconPtr, uint8_t DispNo) {
  961. uint8_t Cnt;
  962. uint16_t tmp;
  963. uint32_t DispData;
  964. DispData = NumberSegTable[DispNo];
  965. Cnt = 0;
  966. do {
  967. tmp = SegIconPtr[Cnt];
  968. if ((tmp != 0) && ((DispData & 1) == 1)) {
  969. AdjustIconLevel(tmp, IconData[tmp].Level);
  970. } else {
  971. AdjustIconLevel(tmp, 0x00);
  972. }
  973. DispData >>= 1;
  974. Cnt++;
  975. } while (Cnt <= 6);
  976. }
  977. void setSegmentedDisplay(uint8_t Display, uint8_t SpeedNo, bool Mode) {
  978. uint8_t BCDcode[4];
  979. if (SpeedNo > DisplayLimit[Display])
  980. SpeedNo = DisplayLimit[Display];
  981. NumericalTo4BCD(SpeedNo, BCDcode);
  982. if (BCDcode[2] == 0 && BCDcode[1] == 0 && Mode) {
  983. DispNumber(SegIconTable[Display][0], 10);
  984. } else {
  985. DispNumber(SegIconTable[Display][0], BCDcode[2]);
  986. }
  987. if (BCDcode[2] == 0 && Mode) {
  988. DispNumber(SegIconTable[Display][1], 10);
  989. } else {
  990. DispNumber(SegIconTable[Display][1], BCDcode[1]);
  991. }
  992. DispNumber(SegIconTable[Display][2], BCDcode[0]);
  993. }
  994. void setHeading(uint8_t SpeedNo) {
  995. uint8_t BCDcode[4];
  996. if (SpeedNo > S1_2_3_Limit) SpeedNo = S1_2_3_Limit;
  997. NumericalTo4BCD(SpeedNo, BCDcode);
  998. if (BCDcode[2] == 0 && BCDcode[1] == 0) {
  999. S01_BAR(0); //Number 1 Icon Clear
  1000. DispNumber(S02SegIconTable, 10); //Clear
  1001. DispNumber(S03SegIconTable, BCDcode[0]);
  1002. return;
  1003. }
  1004. if (BCDcode[2] == 0) {
  1005. S01_BAR(0); //Number 1 Icon Clear
  1006. DispNumber(S02SegIconTable, BCDcode[1]);
  1007. DispNumber(S03SegIconTable, BCDcode[0]);
  1008. return;
  1009. }
  1010. S01_BAR(1); //Number 1 Icon Clear
  1011. DispNumber(S02SegIconTable, BCDcode[1]);
  1012. DispNumber(S03SegIconTable, BCDcode[0]);
  1013. }
  1014. void setDestinationDistance(uint16_t SpeedNo, uint8_t Mode) {
  1015. uint8_t BCDcode[4];
  1016. if (SpeedNo > S4_5_6_Limit) SpeedNo = S4_5_6_Limit;
  1017. NumericalTo4BCD(SpeedNo, BCDcode);
  1018. if (Mode) //1
  1019. {
  1020. if (BCDcode[2] == 0 && BCDcode[1] == 0) {
  1021. DispNumber(S04SegIconTable, 10); //Clear
  1022. DispNumber(S05SegIconTable, 10); //Clear
  1023. DispNumber(S06SegIconTable, BCDcode[0]);
  1024. return;
  1025. }
  1026. if (BCDcode[2] == 0) {
  1027. DispNumber(S04SegIconTable, 10); //Clear
  1028. DispNumber(S05SegIconTable, BCDcode[1]);
  1029. DispNumber(S06SegIconTable, BCDcode[0]);
  1030. return;
  1031. }
  1032. } //0
  1033. DispNumber(S04SegIconTable, BCDcode[2]);
  1034. DispNumber(S05SegIconTable, BCDcode[1]);
  1035. DispNumber(S06SegIconTable, BCDcode[0]);
  1036. }
  1037. void setRadarDistance(uint16_t SpeedNo, uint8_t Mode) {
  1038. uint8_t BCDcode[4];
  1039. if (SpeedNo > S7_8_9_Limit) SpeedNo = S7_8_9_Limit;
  1040. NumericalTo4BCD(SpeedNo, BCDcode);
  1041. if (Mode) //1
  1042. {
  1043. if (BCDcode[2] == 0 && BCDcode[1] == 0) {
  1044. DispNumber(S07SegIconTable, 10); //Clear
  1045. DispNumber(S08SegIconTable, 10); //Clear
  1046. DispNumber(S09SegIconTable, BCDcode[0]);
  1047. return;
  1048. }
  1049. if (BCDcode[2] == 0) {
  1050. DispNumber(S07SegIconTable, 10); //Clear
  1051. DispNumber(S08SegIconTable, BCDcode[1]);
  1052. DispNumber(S09SegIconTable, BCDcode[0]);
  1053. return;
  1054. }
  1055. } //0
  1056. DispNumber(S07SegIconTable, BCDcode[2]);
  1057. DispNumber(S08SegIconTable, BCDcode[1]);
  1058. DispNumber(S09SegIconTable, BCDcode[0]);
  1059. }
  1060. void setTurnDistance(uint16_t SpeedNo, uint8_t Mode) {
  1061. uint8_t BCDcode[4];
  1062. if (SpeedNo > S10_11_12_Limit) SpeedNo = S10_11_12_Limit;
  1063. NumericalTo4BCD(SpeedNo, BCDcode);
  1064. if (Mode) //1
  1065. {
  1066. if (BCDcode[2] == 0 && BCDcode[1] == 0) {
  1067. DispNumber(S10SegIconTable, 10); //Clear
  1068. DispNumber(S11SegIconTable, 10); //Clear
  1069. DispNumber(S12SegIconTable, BCDcode[0]);
  1070. return;
  1071. }
  1072. if (BCDcode[2] == 0) {
  1073. DispNumber(S10SegIconTable, 10); //Clear
  1074. DispNumber(S11SegIconTable, BCDcode[1]);
  1075. DispNumber(S12SegIconTable, BCDcode[0]);
  1076. return;
  1077. }
  1078. } //0
  1079. DispNumber(S10SegIconTable, BCDcode[2]);
  1080. DispNumber(S11SegIconTable, BCDcode[1]);
  1081. DispNumber(S12SegIconTable, BCDcode[0]);
  1082. }
  1083. void setTirePressure(uint8_t SpeedNo, uint8_t Mode) {
  1084. uint8_t BCDcode[4];
  1085. if (SpeedNo > S13_14_Limit) SpeedNo = S13_14_Limit;
  1086. NumericalTo4BCD(SpeedNo, BCDcode);
  1087. if (Mode) //1
  1088. {
  1089. if (BCDcode[1] == 0) {
  1090. DispNumber(S13SegIconTable, 10); //Clear
  1091. DispNumber(S14SegIconTable, BCDcode[0]);
  1092. return;
  1093. }
  1094. } //0
  1095. DispNumber(S13SegIconTable, BCDcode[1]);
  1096. DispNumber(S14SegIconTable, BCDcode[0]);
  1097. }
  1098. void setSpeedometer(uint8_t SpeedNo) {
  1099. uint8_t BCDcode[4];
  1100. if (SpeedNo > S15_16_17_Limit) SpeedNo = S15_16_17_Limit;
  1101. NumericalTo4BCD(SpeedNo, BCDcode);
  1102. if (BCDcode[2] == 0 && BCDcode[1] == 0) {
  1103. S15_BAR(0); //Number 1 Icon Clear
  1104. DispNumber(S16SegIconTable, 10); //Clear
  1105. DispNumber(S17SegIconTable, BCDcode[0]);
  1106. return;
  1107. }
  1108. if (BCDcode[2] == 0) {
  1109. S15_BAR(0); //Number 1 Icon Clear
  1110. DispNumber(S16SegIconTable, BCDcode[1]);
  1111. DispNumber(S17SegIconTable, BCDcode[0]);
  1112. return;
  1113. }
  1114. S15_BAR(1); //Number 1 Icon Clear
  1115. DispNumber(S16SegIconTable, BCDcode[1]);
  1116. DispNumber(S17SegIconTable, BCDcode[0]);
  1117. }
  1118. void setCallIcon(uint8_t iconStatus) {
  1119. switch (iconStatus) {
  1120. case 0: // Blank
  1121. P01(0); // Call Outline
  1122. P02(0); // Call Phone Icon
  1123. P03(0); // Call Text
  1124. break;
  1125. case 1: // Outline Only
  1126. P01(1); // Call Outline
  1127. P02(0); // Call Phone Icon
  1128. P03(0); // Call Text
  1129. break;
  1130. case 2: // Outline w/ Phone
  1131. P01(1); // Call Outline
  1132. P02(1); // Call Phone Icon
  1133. P03(0); // Call Text
  1134. break;
  1135. case 3: // All
  1136. P01(1); // Call Outline
  1137. P02(1); // Call Phone Icon
  1138. P03(1); // Call Text
  1139. break;
  1140. }
  1141. }
  1142. void SoftReset(unsigned char DriverNo) {
  1143. ReceiveData[0] = 0x01; //SoftReset Command No.
  1144. IIC_Write_Command1(IIC_Addr[DriverNo], 1, ReceiveData);
  1145. }
  1146. void SetOscControl(unsigned char DriverNo, unsigned char mode) {
  1147. ReceiveData[0] = 0x04; //Set Osc Control Command No.
  1148. ReceiveData[1] = mode;
  1149. IIC_Write_Command1(IIC_Addr[DriverNo], 2, ReceiveData);
  1150. }
  1151. void SetGraphicsRAMWritingDirection(unsigned char DriverNo, unsigned char mode) {
  1152. ReceiveData[0] = 0x05; //Set Graphics RAM Writing Direction Command No.
  1153. ReceiveData[1] = mode;
  1154. IIC_Write_Command1(IIC_Addr[DriverNo], 2, ReceiveData);
  1155. }
  1156. void SetInterface(unsigned char DriverNo, unsigned char mode) {
  1157. ReceiveData[0] = 0x08; //Set Interface Command No.
  1158. ReceiveData[1] = mode;
  1159. IIC_Write_Command1(IIC_Addr[DriverNo], 2, ReceiveData);
  1160. }
  1161. void DisplayOnOff(unsigned char DriverNo, unsigned char Val) {
  1162. ReceiveData[0] = 0x02; //DisplayOnOff Command No.
  1163. ReceiveData[1] = Val;
  1164. IIC_Write_Command1(IIC_Addr[DriverNo], 2, ReceiveData);
  1165. }
  1166. void DisplayStandbyOnOff(unsigned char DriverNo, unsigned char Val) {
  1167. ReceiveData[0] = 0x03; //DisplayStandbyOnOff Command No.
  1168. ReceiveData[1] = Val;
  1169. IIC_Write_Command1(IIC_Addr[DriverNo], 2, ReceiveData);
  1170. }
  1171. void SetDisplaySize(unsigned char DriverNo, unsigned char Xstart, unsigned char Xend, unsigned char Ystart, unsigned char Yend) {
  1172. ReceiveData[0] = 0x07; //SetDisplaySize Command No.
  1173. ReceiveData[1] = Xstart >> 4;
  1174. ReceiveData[2] = Xstart & 0x0f;
  1175. ReceiveData[3] = Xend >> 4;
  1176. ReceiveData[4] = Xend & 0x0f;
  1177. ReceiveData[5] = Ystart >> 4;
  1178. ReceiveData[6] = Ystart & 0x0f;
  1179. ReceiveData[7] = Yend >> 4;
  1180. ReceiveData[8] = Yend & 0x0f;
  1181. IIC_Write_Command1(IIC_Addr[DriverNo], 9, ReceiveData);
  1182. }
  1183. void SetDotCurrent(unsigned char DriverNo, unsigned char Rlevel, unsigned char Glevel, unsigned char Blevel) {
  1184. ReceiveData[0] = 0x0e; //SetDotCurrent Level Command No.
  1185. ReceiveData[1] = Rlevel >> 4;
  1186. ReceiveData[2] = Rlevel & 0x0f;
  1187. ReceiveData[3] = Glevel >> 4;
  1188. ReceiveData[4] = Glevel & 0x0f;
  1189. ReceiveData[5] = Blevel >> 4;
  1190. ReceiveData[6] = Blevel & 0x0f;
  1191. IIC_Write_Command1(IIC_Addr[DriverNo], 7, ReceiveData);
  1192. }
  1193. void SetSystemClockDivisionRatio(unsigned char DriverNo, unsigned char mode) {
  1194. ReceiveData[0] = 0x10; //Set System Clock Division Ratio Command No.
  1195. ReceiveData[1] = mode;
  1196. IIC_Write_Command1(IIC_Addr[DriverNo], 2, ReceiveData);
  1197. }
  1198. void SetPreChargeWidth(unsigned char DriverNo, unsigned char Val) {
  1199. ReceiveData[0] = 0x1C; //SetPreChargeWidth Command No.
  1200. ReceiveData[1] = Val;
  1201. IIC_Write_Command1(IIC_Addr[DriverNo], 2, ReceiveData);
  1202. }
  1203. void SetPeakPulseWidth(unsigned char DriverNo, unsigned char Rlevel, unsigned char Glevel, unsigned char Blevel) {
  1204. ReceiveData[0] = 0x1d; //SetPeakPulseWidthl Command No.
  1205. ReceiveData[1] = Rlevel >> 4;
  1206. ReceiveData[2] = Rlevel & 0x0f;
  1207. ReceiveData[3] = Glevel >> 4;
  1208. ReceiveData[4] = Glevel & 0x0f;
  1209. ReceiveData[5] = Blevel >> 4;
  1210. ReceiveData[6] = Blevel & 0x0f;
  1211. IIC_Write_Command1(IIC_Addr[DriverNo], 7, ReceiveData);
  1212. }
  1213. void SetPeakPulseDelay(unsigned char DriverNo, unsigned char Val) {
  1214. ReceiveData[0] = 0x1e; //SetPeakPulseDelay Command No.
  1215. ReceiveData[1] = Val;
  1216. IIC_Write_Command1(IIC_Addr[DriverNo], 2, ReceiveData);
  1217. }
  1218. void SetRowScanOperation(unsigned char DriverNo, unsigned char mode) {
  1219. ReceiveData[0] = 0x1f; //SetRowScanOperation Command No.
  1220. ReceiveData[1] = mode;
  1221. IIC_Write_Command1(IIC_Addr[DriverNo], 2, ReceiveData);
  1222. }
  1223. void SetInternalRegulatorforRowScan(unsigned char DriverNo, unsigned char mode) {
  1224. ReceiveData[0] = 0x30; //SetInternalRegulatorforRowScan Command No.
  1225. ReceiveData[1] = mode;
  1226. IIC_Write_Command1(IIC_Addr[DriverNo], 2, ReceiveData);
  1227. }
  1228. void DumpDataToDriver(unsigned char DriverNo, unsigned int SData) {
  1229. unsigned int Cnt, CnNav;
  1230. unsigned char Nav, t2;
  1231. // unsigned char tmp;
  1232. //Set the position setting to write Row-0
  1233. ReceiveData[0] = 0x0a;
  1234. ReceiveData[1] = 0x00; //X Start
  1235. ReceiveData[2] = 0x00;
  1236. ReceiveData[3] = 0x07; //X End
  1237. ReceiveData[4] = 0x0f;
  1238. ReceiveData[5] = 0x00; //Y Start
  1239. ReceiveData[6] = 0x00;
  1240. ReceiveData[7] = 0x00; //Y End
  1241. ReceiveData[8] = 0x00;
  1242. IIC_Write_Command1(IIC_Addr[DriverNo], 9, ReceiveData);
  1243. Nav = SData >> 8;
  1244. t2 = SData & 0xff;
  1245. CnNav = 0;
  1246. for (Cnt = 0; Cnt <= 127; Cnt++) {
  1247. ReceiveData[CnNav] = Nav;
  1248. CnNav++;
  1249. ReceiveData[CnNav] = t2;
  1250. CnNav++;
  1251. }
  1252. IIC_Write_Data1(IIC_Addr[DriverNo], CnNav, ReceiveData);
  1253. }
  1254. //---------------------------------INITIALIZE (HUDBEGIN)-----------------------------------//
  1255. void initializeHUD231(void) {
  1256. uint8_t i, j;
  1257. SoftReset(0);
  1258. SoftReset(1);
  1259. SetOscControl(0, 3); // Internal OSC. 105hz
  1260. SetOscControl(1, 3);
  1261. SetGraphicsRAMWritingDirection(0, 2); //RGB, Left->Right, Bottom->Top
  1262. SetGraphicsRAMWritingDirection(1, 2);
  1263. SetSystemClockDivisionRatio(0, 0x0B); // 1/128
  1264. SetSystemClockDivisionRatio(1, 0x0B);
  1265. SetInterface(0, 1);
  1266. SetInterface(1, 1);
  1267. DisplayOnOff(0, 0);
  1268. DisplayOnOff(1, 0);
  1269. SetDisplaySize(0, 0, 127, 0, 0);
  1270. SetDisplaySize(1, 0, 127, 0, 0);
  1271. SetDotCurrent(0, 220, 230, 230);
  1272. SetDotCurrent(1, 230, 230, 230);
  1273. SetPreChargeWidth(0, 1); //1
  1274. SetPreChargeWidth(1, 1);
  1275. SetPeakPulseWidth(0, 0, 0, 0); //0,0,0
  1276. SetPeakPulseWidth(1, 0, 0, 0);
  1277. SetPeakPulseDelay(0, 1); //1
  1278. SetPeakPulseDelay(1, 1);
  1279. SetRowScanOperation(0, 0x2a); //Pre-Charge + Peak Delay Timing,All Row are in GND, Mode3
  1280. SetRowScanOperation(1, 0x2a);
  1281. SetInternalRegulatorforRowScan(0, 0x10); //Internal scan requlator Enable, VCC_Cx0.85
  1282. SetInternalRegulatorforRowScan(1, 0x10);
  1283. DisplayStandbyOnOff(0, 1);
  1284. DisplayStandbyOnOff(0, 0);
  1285. DisplayStandbyOnOff(1, 1);
  1286. DisplayStandbyOnOff(1, 0);
  1287. DumpDataToDriver(0, 0x0000);
  1288. DumpDataToDriver(1, 0x0000);
  1289. DisplayOnOff(0, 1);
  1290. DisplayOnOff(1, 1);
  1291. for (i = 0; i < 2; i++) {
  1292. for (j = 0; j < 128; j++) {
  1293. IconRamMap[i][j] = 0;
  1294. }
  1295. }
  1296. }
  1297. //---------------------------------I2C FUNCTIONS-----------------------------------//
  1298. void IIC_Write_Command1(uint8_t IIC_Addr, uint16_t DataLen, uint8_t * DataPtr) {
  1299. uint16_t Cnt;
  1300. _i2cPort - > beginTransmission(IIC_Addr);
  1301. for (Cnt = 0; Cnt < DataLen; Cnt++) {
  1302. _i2cPort - > write(DataPtr[Cnt]);
  1303. }
  1304. _i2cPort - > endTransmission();
  1305. }
  1306. void IIC_Write_Data1(uint8_t IIC_Addr, uint16_t DataLen, uint8_t * DataPtr) {
  1307. uint16_t Cnt;
  1308. _i2cPort - > beginTransmission(IIC_Addr);
  1309. _i2cPort - > write(0x0C);
  1310. for (Cnt = 0; Cnt < DataLen; Cnt++) {
  1311. _i2cPort - > write(DataPtr[Cnt]);
  1312. }
  1313. _i2cPort - > endTransmission();
  1314. }
  1315. void IIC_Write_Data2(uint8_t IIC_Addr, uint16_t DataLen,
  1316. const uint8_t * DataPtr) {
  1317. uint16_t Cnt;
  1318. uint8_t tmp;
  1319. _i2cPort - > beginTransmission(IIC_Addr);
  1320. _i2cPort - > write(0x0C);
  1321. for (Cnt = 0; Cnt < DataLen; Cnt++) {
  1322. tmp = DataPtr[Cnt];
  1323. _i2cPort - > write(tmp);
  1324. }
  1325. _i2cPort - > endTransmission();
  1326. }
  1327. //---------------------------------CLEAR DISPLAY-----------------------------------//
  1328. void clearAll(void) {
  1329. for (uint16_t i; i < 230; i++) {
  1330. AdjustIconLevel(i, 0x00);
  1331. }
  1332. }