Răsfoiți Sursa

Fix non-digit sugn output.

Vladimir N. Shilov 1 an în urmă
părinte
comite
0cfb6943aa
2 a modificat fișierele cu 31 adăugiri și 7 ștergeri
  1. 19 5
      lib/led.c
  2. 12 2
      lib/led.h

+ 19 - 5
lib/led.c

@@ -9,8 +9,8 @@
 #define GPIO_LOW(a,b)     a->ODR &= ~b
 #define GPIO_TOGGLE(a,b)  a->ODR ^= b
 
-uint8_t LedDigits[8] = {1, 2, 3, 4, 5, 6, 7, 8}; // digits to dsplay
-uint8_t LedPoint[8] = {0, 0, 1, 0, 0, 0, 1, 0}; // dots for digits
+uint8_t LedDigits[LED_DIGITS_NUM] = {1, 2, 3, 4, 5, 6, 7, 8}; // digits to dsplay
+uint8_t LedPoint[LED_DIGITS_NUM] = {0, 1, 0, 0, 0, 1, 0, 0}; // dots for digits
 
 static const uint16_t led_num[8] = {0x10, 0x20, 0x80, 0x40, 0x01, 0x02, 0x08, 0x04};
 
@@ -60,16 +60,30 @@ void led_OutputValue(void) {
     case 9:
       LED_OUT_9;
       break;
+    case led_Plus:
+      LED_OUT_PL;
+      break;
+    case led_Minus:
+      LED_OUT_MM;
+      break;
+    case led_H:
+      LED_OUT_H;
+      break;
+    case led_O:
+      LED_OUT_O;
+      break;
+    case led_Off:
+      break;
     default:
       LED_OUT_MM;
   }
-  /*
+
   if(LedPoint[ledn] != 0) {
     LED_OUT_DP;
   }
-  */
+
   ledn ++;
-  if (ledn > 7) {
+  if (ledn >= LED_DIGITS_NUM) {
     ledn = 0;
   }
 }

+ 12 - 2
lib/led.h

@@ -4,6 +4,7 @@
 
 // time to show one led digit, ms
 #define LED_ONE_PERIOD  2
+#define LED_DIGITS_NUM  8
 
 /* LED
  AAA
@@ -46,14 +47,23 @@ E   C
 #define LED_OUT_9     GPIOC->ODR &= ~(LED_SEG_A|LED_SEG_B|LED_SEG_F|LED_SEG_G); GPIOD->ODR &= ~(LED_SEG2_PINS)
 #define LED_OUT_H     GPIOC->ODR &= ~(LED_SEG_B|LED_SEG_E|LED_SEG_F|LED_SEG_G); GPIOD->ODR &= ~(LED_SEG_C)
 #define LED_OUT_PL    GPIOC->ODR &= ~(LED_SEG_B|LED_SEG_G); GPIOD->ODR &= ~(LED_SEG_C)
+#define LED_OUT_O     GPIOC->ODR &= ~(LED_SEG_A|LED_SEG_B|LED_SEG_F|LED_SEG_G);
 
 /* shift register control pins */
 #define SPI_PORT      GPIOA
 #define SPI_SCK       GPIO_PIN_1
 #define SPI_DATA      GPIO_PIN_2
 
-extern uint8_t LedDigits[8];
-extern uint8_t LedPoint[8];
+typedef enum {
+  led_Plus = 0xa,
+  led_Minus = 0xb,
+  led_H = 0xc,
+  led_O = 0xd,
+  led_Off = 0xff
+} led_sym_t;
+
+extern uint8_t LedDigits[];
+extern uint8_t LedPoint[];
 
 void led_OutputValue(void);