main.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745
  1. /**
  2. ******************************************************************************
  3. * @file VAPC-meter
  4. * @author Vladimir N. Shilov <shilow@ukr.net>
  5. * @version V0.0.1
  6. * @date 2015.05.15
  7. * @brief Main program body
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * ----------------------------------------------------------------------------
  12. * "THE BEER-WARE LICENSE" (Revision 42):
  13. * <shilow@ukr.net> wrote this file. As long as you retain this notice you
  14. * can do whatever you want with this stuff. If we meet some day, and you think
  15. * this stuff is worth it, you can buy me a beer in return. Shilov V.N.
  16. * ----------------------------------------------------------------------------
  17. *
  18. ******************************************************************************
  19. */
  20. /* Includes ------------------------------------------------------------------*/
  21. #include "stm8l15x.h"
  22. #include "rtos.h"
  23. #include "max7219.h"
  24. #include "adc.h"
  25. /** @addtogroup STM8L15x_StdPeriph_Template
  26. * @{
  27. */
  28. /* Private typedef -----------------------------------------------------------*/
  29. typedef enum _modes_led {
  30. dispNoState = 0x00,
  31. displayU,
  32. displayI,
  33. displayP,
  34. displayAH,
  35. displayWH,
  36. displayT
  37. } mode_led_t;
  38. typedef enum _events {
  39. eventNoEvent = 0x00,
  40. eventShortPress,
  41. eventLongPress
  42. } event_t;
  43. /* Private define ------------------------------------------------------------*/
  44. #define LED_RED_PORT GPIOB
  45. #define LED_RED_PIN GPIO_Pin_7
  46. #define LED_GREEN_PORT GPIOC
  47. #define LED_GREEN_PIN GPIO_Pin_4
  48. #define BTNs_PORT GPIOC
  49. #define BTN1_PIN GPIO_Pin_0
  50. #define BTN2_PIN GPIO_Pin_1
  51. #define BTN_SCAN_PERIOD 10
  52. // кнопка считается нажатой через BTN_FACTOR * BTN_SCAN_PERIOD ms
  53. #define BTN_FACTOR 5
  54. /*
  55. #define BTNs_PORT GPIOA
  56. #define BTN1_PIN GPIO_Pin_2
  57. #define BTN2_PIN GPIO_Pin_3
  58. */
  59. #define VALUES_BUFFER_SIZE 10
  60. /* Private macro -------------------------------------------------------------*/
  61. #define LED_RED_ON LED_RED_PORT->ODR &= (uint8_t)(~LED_RED_PIN)
  62. #define LED_RED_OFF LED_RED_PORT->ODR |= LED_RED_PIN
  63. #define LED_GREEN_ON LED_GREEN_PORT->ODR &= (uint8_t)(~LED_GREEN_PIN)
  64. #define LED_GREEN_OFF LED_GREEN_PORT->ODR |= LED_GREEN_PIN
  65. /* Private constant ----------------------------------------------------------*/
  66. // перевод числа 0-7 в номер индикатора
  67. static const max7219_reg_t dig[8] = {
  68. RegDigit0, RegDigit1, RegDigit2, RegDigit3,
  69. RegDigit4, RegDigit5, RegDigit6, RegDigit7
  70. };
  71. // перевод значения 0x00 - 0x0F в код индикатора
  72. static const max7219_sym_t num[16] = {
  73. Sym_0, Sym_1, Sym_2, Sym_3, Sym_4, Sym_5, Sym_6, Sym_7,
  74. Sym_8, Sym_9, Sym_A, Sym_b, Sym_C, Sym_d, Sym_E, Sym_F
  75. };
  76. /* Private variables ---------------------------------------------------------*/
  77. static uint16_t bufVoltage[VALUES_BUFFER_SIZE];
  78. static uint16_t bufCurrent[VALUES_BUFFER_SIZE];
  79. /* averaged values for 1 sek */
  80. static uint16_t Voltage;
  81. static uint16_t Current;
  82. static uint32_t Power;
  83. static uint32_t CapacityAH = 0;
  84. static uint32_t CapacityWH = 0;
  85. static struct _timer {
  86. uint8_t hh;
  87. uint8_t mm;
  88. uint8_t ss;
  89. } Timer;
  90. static uint8_t btn1Cnt;
  91. static uint8_t btn2Cnt;
  92. static mode_led_t displayTopLine, displayBotLine;
  93. /* Private function prototypes -----------------------------------------------*/
  94. static void GPIO_Config(void);
  95. static void CLK_Config(void);
  96. static void showValue(uint32_t val, uint8_t pos);
  97. static void showU(uint8_t pos);
  98. static void showI(uint8_t pos);
  99. static void showP(uint8_t pos);
  100. static void showAH(uint8_t pos);
  101. static void showWH(uint8_t pos);
  102. static void showT(uint8_t pos);
  103. static void showLabelU(uint8_t pos);
  104. static void showLabelI(uint8_t pos);
  105. static void showLabelP(uint8_t pos);
  106. static void showLabelAH(uint8_t pos);
  107. static void showLabelWH(uint8_t pos);
  108. static void showLabelT(uint8_t pos);
  109. static void displayMode(mode_led_t * disp, event_t event, uint8_t pos);
  110. /* RTOS function prototypes -----------------------------------------------*/
  111. static void getADCValues(void);
  112. static void calculateValues(void);
  113. static void showTopLineU(void);
  114. static void showTopLineI(void);
  115. static void showTopLineP(void);
  116. static void showTopLineAH(void);
  117. static void showTopLineWH(void);
  118. static void showTopLineT(void);
  119. static void showBotLineU(void);
  120. static void showBotLineI(void);
  121. static void showBotLineP(void);
  122. static void showBotLineAH(void);
  123. static void showBotLineWH(void);
  124. static void showBotLineT(void);
  125. static void btnScan(void);
  126. static void btnTest(uint8_t btnPin, uint8_t *pressCount, void (*taskShortPress)(void), void (*taskLongPress)(void));
  127. static void btn1Short(void);
  128. static void btn1Long(void);
  129. static void btn2Short(void);
  130. static void btn2Long(void);
  131. /* Private functions ---------------------------------------------------------*/
  132. /**
  133. * @brief Main program.
  134. * @param None
  135. * @retval None
  136. */
  137. void main(void)
  138. {
  139. /* Clock configuration -----------------------------------------*/
  140. CLK_Config();
  141. /* GPIO Configuration -----------------------------------------*/
  142. GPIO_Config();
  143. /* RTOS Configuration */
  144. RTOS_Config();
  145. /* ADC Configuration and start */
  146. ADC_Config();
  147. /* MAX7219 Configuration */
  148. MAX7219_Config();
  149. /* ROTS tasks */
  150. RTOS_SetTask(btnScan, 0, BTN_SCAN_PERIOD);
  151. RTOS_SetTask(getADCValues, 100, 100);
  152. RTOS_SetTask(calculateValues, 101, 1000);
  153. RTOS_SetTask(showTopLineU, 102, 200);
  154. RTOS_SetTask(showBotLineI, 103, 200);
  155. displayTopLine = displayU;
  156. displayBotLine = displayI;
  157. /* Infinite loop */
  158. while (1) {
  159. RTOS_DispatchTask();
  160. wfi();
  161. }
  162. } // End of main()
  163. /**
  164. * Забираем обработанные данные из быстрого буфера
  165. * и складываем в медленный.
  166. */
  167. static void getADCValues(void) {
  168. static uint8_t bufIdx = 0;
  169. uint16_t * avgVal;
  170. avgVal = ADC_GetValues();
  171. bufVoltage[bufIdx] = *avgVal;
  172. bufCurrent[bufIdx] = *(avgVal + 1);
  173. bufIdx ++;
  174. if (bufIdx == VALUES_BUFFER_SIZE) {
  175. bufIdx = 0;
  176. }
  177. }
  178. /**
  179. * Average values from slow buffer.
  180. * Calculate Power, Capacitance IH and WH.
  181. */
  182. static void calculateValues(void) {
  183. uint8_t i;
  184. uint16_t c=0;
  185. uint32_t v=0;
  186. for (i=0; i<VALUES_BUFFER_SIZE; i++) {
  187. v += bufVoltage[i];
  188. c += bufCurrent[i];
  189. }
  190. Current = (c + (VALUES_BUFFER_SIZE/2)) / VALUES_BUFFER_SIZE;
  191. Voltage = (v + (VALUES_BUFFER_SIZE/2)) / VALUES_BUFFER_SIZE;
  192. if (Current > 4) {
  193. Power = ((Voltage * Current) + 500) / 1000;
  194. CapacityAH += Current;
  195. CapacityWH += Power;
  196. Timer.ss ++;
  197. if (Timer.ss > 59) {
  198. Timer.ss = 0;
  199. Timer.mm ++;
  200. if (Timer.mm > 59) {
  201. Timer.hh ++;
  202. }
  203. }
  204. }
  205. }
  206. /**
  207. * вывод инфы на верхнем индикаторе
  208. */
  209. static void showTopLineU(void) {
  210. showU(0);
  211. }
  212. static void showTopLineI(void) {
  213. showI(0);
  214. }
  215. static void showTopLineP(void) {
  216. showP(0);
  217. }
  218. static void showTopLineAH(void) {
  219. showAH(0);
  220. }
  221. static void showTopLineWH(void) {
  222. showWH(0);
  223. }
  224. static void showTopLineT(void) {
  225. showT(0);
  226. }
  227. /**
  228. * вывод инфы на нижнем индикаторе
  229. */
  230. static void showBotLineU(void) {
  231. showU(4);
  232. }
  233. static void showBotLineI(void) {
  234. showI(4);
  235. }
  236. static void showBotLineP(void) {
  237. showP(4);
  238. }
  239. static void showBotLineAH(void) {
  240. showAH(4);
  241. }
  242. static void showBotLineWH(void) {
  243. showWH(4);
  244. }
  245. static void showBotLineT(void) {
  246. showT(4);
  247. }
  248. /**
  249. * Output given value to given indicator
  250. * param1: value to show, from '0.000' to '999.9'
  251. * param2: starting position -- 0 for top
  252. * any other for bottom.
  253. */
  254. static void showValue(uint32_t val, uint8_t pos) {
  255. uint8_t tmp;
  256. if (pos > 0) {
  257. pos = 4;
  258. }
  259. if (val >= 100000) { // 000.0
  260. tmp = (uint8_t)(val / 100000);
  261. val %= 100000;
  262. MAX7219_WriteData(dig[pos], num[tmp]);
  263. tmp = (uint8_t)(val / 10000);
  264. val %= 10000;
  265. pos ++;
  266. MAX7219_WriteData(dig[pos], num[tmp]);
  267. tmp = (uint8_t)(val / 1000);
  268. val %= 1000;
  269. pos ++;
  270. MAX7219_WriteData(dig[pos], (num[tmp] | Sym_Dot));
  271. tmp = (uint8_t)(val / 100);
  272. pos ++;
  273. MAX7219_WriteData(dig[pos], num[tmp]);
  274. } else if(val >= 10000){ // 00.00
  275. tmp = (uint8_t)(val / 10000);
  276. val %= 10000;
  277. MAX7219_WriteData(dig[pos], num[tmp]);
  278. tmp = (uint8_t)(val / 1000);
  279. val %= 1000;
  280. pos ++;
  281. MAX7219_WriteData(dig[pos], (num[tmp] | Sym_Dot));
  282. tmp = (uint8_t)(val / 100);
  283. val %= 100;
  284. pos ++;
  285. MAX7219_WriteData(dig[pos], num[tmp]);
  286. tmp = (uint8_t)(val / 10);
  287. pos ++;
  288. MAX7219_WriteData(dig[pos], num[tmp]);
  289. } else { // 0.000
  290. tmp = (uint8_t)(val / 1000);
  291. val %= 1000;
  292. MAX7219_WriteData(dig[pos], (num[tmp] | Sym_Dot));
  293. tmp = (uint8_t)(val / 100);
  294. val %= 100;
  295. pos ++;
  296. MAX7219_WriteData(dig[pos], num[tmp]);
  297. tmp = (uint8_t)(val / 10);
  298. val %= 10;
  299. pos ++;
  300. MAX7219_WriteData(dig[pos], num[tmp]);
  301. pos ++;
  302. tmp = val;
  303. MAX7219_WriteData(dig[pos], num[tmp]);
  304. }
  305. }
  306. /**
  307. * Output voltage values to given indicator
  308. * param: starting position -- 0 for top
  309. * any other for bottom.
  310. */
  311. static void showU(uint8_t pos) {
  312. uint32_t vlt = 0;
  313. uint8_t tmp;
  314. for (tmp=0; tmp<VALUES_BUFFER_SIZE; tmp++) {
  315. vlt += bufVoltage[tmp];
  316. }
  317. vlt /= VALUES_BUFFER_SIZE;
  318. showValue(vlt, pos);
  319. }
  320. /**
  321. * Output current values to given indicator
  322. * param: starting position -- 0 for top
  323. * any other for bottom.
  324. */
  325. static void showI(uint8_t pos) {
  326. uint32_t crnt = 0;
  327. uint8_t tmp;
  328. for (tmp=0; tmp<VALUES_BUFFER_SIZE; tmp++) {
  329. crnt += bufCurrent[tmp];
  330. }
  331. crnt /= VALUES_BUFFER_SIZE;
  332. showValue(crnt, pos);
  333. }
  334. /**
  335. * Output power values to given indicator
  336. * param: starting position -- 0 for top
  337. * any other for bottom.
  338. */
  339. static void showP(uint8_t pos) {
  340. showValue(Power, pos);
  341. }
  342. /**
  343. * Output current capacity values to given indicator
  344. * param: starting position -- 0 for top
  345. * any other for bottom.
  346. */
  347. static void showAH(uint8_t pos) {
  348. showValue(CapacityAH, pos);
  349. }
  350. /**
  351. * Output power capacity values to given indicator
  352. * param: starting position -- 0 for top
  353. * any other for bottom.
  354. */
  355. static void showWH(uint8_t pos) {
  356. showValue(CapacityWH, pos);
  357. }
  358. /**
  359. * Output time values to given indicator
  360. * param: starting position -- 0 for top
  361. * any other for bottom.
  362. */
  363. static void showT(uint8_t pos) {
  364. static uint8_t halfsek = 0;
  365. uint8_t tmp;
  366. if (Timer.hh > 0) {
  367. tmp = Timer.hh / 10;
  368. MAX7219_WriteData(dig[pos], num[tmp]);
  369. pos ++;
  370. tmp = Timer.hh % 10;
  371. if (halfsek == 0) {
  372. MAX7219_WriteData(dig[pos], num[tmp]);
  373. } else {
  374. MAX7219_WriteData(dig[pos], (num[tmp] | Sym_Dot));
  375. }
  376. pos ++;
  377. tmp = Timer.mm / 10;
  378. MAX7219_WriteData(dig[pos], num[tmp]);
  379. pos ++;
  380. tmp = Timer.mm % 10;
  381. MAX7219_WriteData(dig[pos], num[tmp]);
  382. } else {
  383. tmp = Timer.mm / 10;
  384. MAX7219_WriteData(dig[pos], num[Timer.mm >> 4]);
  385. pos ++;
  386. tmp = Timer.mm % 10;
  387. MAX7219_WriteData(dig[pos], (num[tmp] | Sym_Dot));
  388. pos ++;
  389. tmp = Timer.ss / 10;
  390. MAX7219_WriteData(dig[pos], num[tmp]);
  391. pos ++;
  392. tmp = Timer.ss % 10;
  393. MAX7219_WriteData(dig[pos], num[tmp]);
  394. }
  395. if (halfsek == 0) {
  396. halfsek = 1;
  397. } else {
  398. halfsek = 0;
  399. }
  400. }
  401. /**
  402. * @brief Configure GPIO for button available on the VAPC board
  403. * @param None
  404. * @retval None
  405. */
  406. static void GPIO_Config(void)
  407. {
  408. /* Configure GPIO used to drive LEDs */
  409. GPIO_Init(LED_RED_PORT, LED_RED_PIN, GPIO_Mode_Out_PP_High_Fast);
  410. GPIO_Init(LED_GREEN_PORT, LED_GREEN_PIN, GPIO_Mode_Out_PP_High_Fast);
  411. /* Configure GPIO used for buttons */
  412. GPIO_Init(BTNs_PORT, BTN1_PIN, GPIO_Mode_In_FL_No_IT);
  413. GPIO_Init(BTNs_PORT, BTN2_PIN, GPIO_Mode_In_FL_No_IT);
  414. /* Enable general interrupts */
  415. enableInterrupts();
  416. }
  417. /**
  418. * @brief Configure system clock to run at Maximum clock speed
  419. * @param None
  420. * @retval None
  421. */
  422. static void CLK_Config(void)
  423. {
  424. CLK_DeInit();
  425. /* Configure the clock source */
  426. CLK_SYSCLKSourceConfig(CLK_SYSCLKSource_HSI);
  427. /* Configure the System clock frequency to run at 16Mhz */
  428. CLK_SYSCLKDivConfig(CLK_SYSCLKDiv_1);
  429. CLK_HSICmd(ENABLE);
  430. }
  431. /** опрос кнопок */
  432. static void btnScan(void) {
  433. btnTest(BTN1_PIN, &btn1Cnt, btn1Short, btn1Long);
  434. btnTest(BTN2_PIN, &btn2Cnt, btn2Short, btn2Long);
  435. }
  436. /** проверка конкретной кнопки */
  437. static void btnTest(uint8_t btnPin, uint8_t *pressCount, void (*taskShortPress)(void), void (*taskLongPress)(void)) {
  438. if ((BTNs_PORT->IDR & btnPin) == 0) {
  439. if (*pressCount < 255) {
  440. *pressCount = *pressCount + 1;
  441. }
  442. /*
  443. if (*pressCount == BTN_FACTOR) {
  444. // short
  445. } else if(*pressCount == (BTN_FACTOR * 10)) {
  446. // long
  447. }
  448. */
  449. } else {
  450. if (*pressCount >= (BTN_FACTOR * 10)) {
  451. RTOS_SetTask(taskLongPress, 1, 0); // вызов функции при длительном нажатии
  452. } else if (*pressCount >= BTN_FACTOR) {
  453. RTOS_SetTask(taskShortPress, 2, 0); // вызов функции при коротком нажатии
  454. }
  455. *pressCount = 0;
  456. }
  457. }
  458. /** переключение режимов отображения */
  459. static void displayMode(mode_led_t * disp, event_t event, uint8_t pos) {
  460. if (pos > 0) {
  461. pos = 4;
  462. }
  463. if (event == eventShortPress) {
  464. switch (*disp) {
  465. case dispNoState:
  466. showLabelU(pos);
  467. if (pos == 0) {
  468. RTOS_SetTask(showTopLineU, 1000, 250);
  469. } else {
  470. RTOS_SetTask(showBotLineU, 1000, 250);
  471. }
  472. *disp = displayU;
  473. break;
  474. case displayU:
  475. if (pos == 0) {
  476. RTOS_DeleteTask(showTopLineU);
  477. RTOS_SetTask(showTopLineI, 1000, 250);
  478. } else {
  479. RTOS_DeleteTask(showBotLineU);
  480. RTOS_SetTask(showBotLineI, 1000, 250);
  481. }
  482. showLabelI(pos);
  483. *disp = displayI;
  484. break;
  485. case displayI:
  486. if (pos == 0) {
  487. RTOS_DeleteTask(showTopLineI);
  488. RTOS_SetTask(showTopLineP, 1000, 250);
  489. } else {
  490. RTOS_DeleteTask(showBotLineI);
  491. RTOS_SetTask(showBotLineP, 1000, 250);
  492. }
  493. showLabelP(pos);
  494. *disp = displayP;
  495. break;
  496. case displayP:
  497. if (pos == 0) {
  498. RTOS_DeleteTask(showTopLineP);
  499. RTOS_SetTask(showTopLineAH, 1000, 250);
  500. } else {
  501. RTOS_DeleteTask(showBotLineP);
  502. RTOS_SetTask(showBotLineAH, 1000, 250);
  503. }
  504. showLabelAH(pos);
  505. *disp = displayAH;
  506. break;
  507. case displayAH:
  508. if (pos == 0) {
  509. RTOS_DeleteTask(showTopLineAH);
  510. RTOS_SetTask(showTopLineWH, 1000, 250);
  511. } else {
  512. RTOS_DeleteTask(showBotLineAH);
  513. RTOS_SetTask(showBotLineWH, 1000, 250);
  514. }
  515. showLabelWH(pos);
  516. *disp = displayWH;
  517. break;
  518. case displayWH:
  519. if (pos == 0) {
  520. RTOS_DeleteTask(showTopLineWH);
  521. RTOS_SetTask(showTopLineT, 1000, 500);
  522. } else {
  523. RTOS_DeleteTask(showBotLineWH);
  524. RTOS_SetTask(showBotLineT, 1000, 500);
  525. }
  526. showLabelT(pos);
  527. *disp = displayT;
  528. break;
  529. case displayT:
  530. if (pos == 0) {
  531. RTOS_DeleteTask(showTopLineT);
  532. RTOS_SetTask(showTopLineU, 1000, 250);
  533. } else {
  534. RTOS_DeleteTask(showBotLineT);
  535. RTOS_SetTask(showBotLineU, 1000, 250);
  536. }
  537. showLabelU(pos);
  538. *disp = displayU;
  539. break;
  540. }
  541. }
  542. }
  543. /** обработчик короткого нажатия первой кнопки */
  544. static void btn1Short(void) {
  545. displayMode(&displayTopLine, eventShortPress, 0);
  546. }
  547. /** обработчик длинного нажатия первой кнопки */
  548. static void btn1Long(void) {
  549. }
  550. /** обработчик короткого нажатия второй кнопки */
  551. static void btn2Short(void) {
  552. displayMode(&displayBotLine, eventShortPress, 4);
  553. }
  554. /** обработчик длинного нажатия второй кнопки */
  555. static void btn2Long(void) {
  556. Timer.ss = 0;
  557. Timer.mm = 0;
  558. Timer.hh = 0;
  559. CapacityAH = 0;
  560. CapacityWH = 0;
  561. }
  562. /**
  563. * show label for selected mode
  564. */
  565. static void showLabelU(uint8_t pos) {
  566. MAX7219_WriteData(dig[pos], Sym_Minus);
  567. pos ++;
  568. MAX7219_WriteData(dig[pos], Sym_U);
  569. pos ++;
  570. MAX7219_WriteData(dig[pos], Sym_Minus);
  571. pos ++;
  572. MAX7219_WriteData(dig[pos], Sym_BLANK);
  573. }
  574. static void showLabelI(uint8_t pos) {
  575. MAX7219_WriteData(dig[pos], Sym_Minus);
  576. pos ++;
  577. MAX7219_WriteData(dig[pos], Sym_1);
  578. pos ++;
  579. MAX7219_WriteData(dig[pos], Sym_Minus);
  580. pos ++;
  581. MAX7219_WriteData(dig[pos], Sym_BLANK);
  582. }
  583. static void showLabelP(uint8_t pos) {
  584. MAX7219_WriteData(dig[pos], Sym_Minus);
  585. pos ++;
  586. MAX7219_WriteData(dig[pos], Sym_P);
  587. pos ++;
  588. MAX7219_WriteData(dig[pos], Sym_Minus);
  589. pos ++;
  590. MAX7219_WriteData(dig[pos], Sym_BLANK);
  591. }
  592. static void showLabelAH(uint8_t pos) {
  593. MAX7219_WriteData(dig[pos], Sym_Minus);
  594. pos ++;
  595. MAX7219_WriteData(dig[pos], Sym_A);
  596. pos ++;
  597. MAX7219_WriteData(dig[pos], Sym_H);
  598. pos ++;
  599. MAX7219_WriteData(dig[pos], Sym_Minus);
  600. }
  601. static void showLabelWH(uint8_t pos) {
  602. MAX7219_WriteData(dig[pos], Sym_Minus);
  603. pos ++;
  604. MAX7219_WriteData(dig[pos], Sym_P);
  605. pos ++;
  606. MAX7219_WriteData(dig[pos], Sym_H);
  607. pos ++;
  608. MAX7219_WriteData(dig[pos], Sym_Minus);
  609. }
  610. static void showLabelT(uint8_t pos) {
  611. MAX7219_WriteData(dig[pos], Sym_Minus);
  612. pos ++;
  613. MAX7219_WriteData(dig[pos], Sym_t);
  614. pos ++;
  615. MAX7219_WriteData(dig[pos], Sym_Minus);
  616. pos ++;
  617. MAX7219_WriteData(dig[pos], Sym_BLANK);
  618. }
  619. #ifdef USE_FULL_ASSERT
  620. /**
  621. * @brief Reports the name of the source file and the source line number
  622. * where the assert_param error has occurred.
  623. * @param file: pointer to the source file name
  624. * @param line: assert_param error line source number
  625. * @retval None
  626. */
  627. void assert_failed(uint8_t* file, uint32_t line)
  628. {
  629. /* User can add his own implementation to report the file name and line number,
  630. ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  631. /* Infinite loop */
  632. while (1)
  633. {
  634. }
  635. }
  636. #endif
  637. /**
  638. * @}
  639. */
  640. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/