Pārlūkot izejas kodu

Merge branch 'devel' of git.shilov.pp.ua:Heaven/MNC-IN2x5 into devel

Vladimir N. Shilov 2 gadi atpakaļ
vecāks
revīzija
8a2b1f996e
3 mainītis faili ar 59 papildinājumiem un 41 dzēšanām
  1. 3 0
      Inc/board.h
  2. 31 22
      Src/board.c
  3. 25 19
      Src/clock.c

+ 3 - 0
Inc/board.h

@@ -108,6 +108,8 @@ typedef union {
 #define TIM17_PSC            (24 - 1)
 #define TIM17_ARR            (1000 - 1)
 
+#define TUBE_BLANK            0xa
+
 /* Defines */
 #define BTN1_GPIO_Port GPIOB
 #define BTN1_Pin GPIO_PIN_2
@@ -179,6 +181,7 @@ void Board_Init(void);
 void Blink_Start(void);
 void Blink_Stop(void);
 void showDigits(tube4_t dig);
+void lShiftDigits(const tube4_t old, const tube4_t dig);
 void slideDigits(tube4_t dig);
 void tube_PowerOn(tube_pos_t tube);
 void tube_PowerOff(tube_pos_t tube);

+ 31 - 22
Src/board.c

@@ -18,11 +18,11 @@
  * {3.3 3.2 3.1 3.0 2.7 2.6 2.5 2.4 2.3 2.2} VL2/B
  * {2.1 2.0 1.7 1.6 1.5 1.4 1.3 1.2 1.1 1.0} VL1/A
  */
-static const uint16_t nixieCathodeMap[4][10] = {
-  {0x8000, 0x0040, 0x0080, 0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000},
-  {0x2000, 0x0010, 0x0020, 0x0040, 0x0080, 0x0100, 0x0200, 0x0400, 0x0800, 0x1000},
-  {0x0800, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080, 0x0100, 0x0200, 0x0400},
-  {0x0200, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080, 0x0100}
+static const uint16_t nixieCathodeMap[4][11] = {
+  {0x8000, 0x0040, 0x0080, 0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000, 0x0000},
+  {0x2000, 0x0010, 0x0020, 0x0040, 0x0080, 0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x0000},
+  {0x0800, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080, 0x0100, 0x0200, 0x0400, 0x0000},
+  {0x0200, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080, 0x0100, 0x0000}
 };
 //static const uint8_t nixieCathodeMask[4][2] = {{0x00, 0x3f}, {0xc0, 0x0f}, {0xf0, 0x03}, {0xc0, 0x00}};
 static uint8_t tubesBuffer[SPI_BUFFER_SIZE] = {0};
@@ -130,19 +130,28 @@ void showDigits(tube4_t dig)
   } // End of if-else
 }
 
-void lShiftDigits(tube4_t dig) {
+void lShiftDigits(const tube4_t old, const tube4_t dig) {
   uint32_t * buf;
-  uint8_t sbuf[12] = {0xf};
-  sbuf[4] = dig.ar[0];
-  sbuf[5] = dig.ar[1];
-  sbuf[6] = dig.ar[2];
-  sbuf[7] = dig.ar[3];
+  uint8_t sbuf[12];
+
+  sbuf[0] = old.ar[0];
+  sbuf[1] = old.ar[1];
+  sbuf[2] = old.ar[2];
+  sbuf[3] = old.ar[3];
+  sbuf[4] = TUBE_BLANK;
+  sbuf[5] = TUBE_BLANK;
+  sbuf[6] = TUBE_BLANK;
+  sbuf[7] = TUBE_BLANK;
+  sbuf[8] = dig.ar[0];
+  sbuf[9] = dig.ar[1];
+  sbuf[10] = dig.ar[2];
+  sbuf[11] = dig.ar[3];
 
   int i;
   for (i=0; i<9; i++) {
     buf = (uint32_t *)&sbuf[i];
     _show_digits(* buf);
-    tdelay_ms(100);
+    tdelay_ms(200);
   }
 }
 
@@ -150,10 +159,10 @@ void slideDigits(tube4_t dig) {
   tube4_t buf;
   const uint8_t pause = 100;;
 
-    buf.s8.tA = 0xf;
-    buf.s8.tB = 0xf;
-    buf.s8.tD = 0xf;
-    buf.s8.tE = 0xf;
+    buf.s8.tA = TUBE_BLANK;
+    buf.s8.tB = TUBE_BLANK;
+    buf.s8.tD = TUBE_BLANK;
+    buf.s8.tE = TUBE_BLANK;
     _show_digits(buf.u32);
     tdelay_ms(pause);
 
@@ -182,22 +191,22 @@ void slideDigits(tube4_t dig) {
     buf.s8.tA = dig.s8.tB;
     buf.s8.tB = dig.s8.tD;
     buf.s8.tD = dig.s8.tE;
-    buf.s8.tE = 0xf;
+    buf.s8.tE = TUBE_BLANK;
     _show_digits(buf.u32);
     tdelay_ms(pause);
 
     buf.s8.tA = dig.s8.tD;
     buf.s8.tB = dig.s8.tE;
-    buf.s8.tD = 0xf;
+    buf.s8.tD = TUBE_BLANK;
     _show_digits(buf.u32);
     tdelay_ms(pause);
 
     buf.s8.tA = dig.s8.tE;
-    buf.s8.tB = 0xf;
+    buf.s8.tB = TUBE_BLANK;
     _show_digits(buf.u32);
     tdelay_ms(pause);
 
-    buf.s8.tA = 0xf;
+    buf.s8.tA = TUBE_BLANK;
     _show_digits(buf.u32);
     tdelay_ms(pause);
 }
@@ -218,7 +227,7 @@ static void _show_digits(const uint32_t digits)
   int i;
   for (i=0; i<4; i++) {
     if (dig.ar[i] > 9) {
-      if (dig.ar[i] != 0xf) {
+      if (dig.ar[i] != TUBE_BLANK) {
         dig.ar[i] = 0;
       }
     }
@@ -240,7 +249,7 @@ static void _show_digits(const uint32_t digits)
 
   /* On/Off tube power */
   for (i=0; i<4; i++) {
-    if (dig.ar[i] == 0xf) {
+    if (dig.ar[i] == TUBE_BLANK) {
       tube_PowerOff((tube_pos_t)i);
     } else {
       tube_PowerOn((tube_pos_t)i);

+ 25 - 19
Src/clock.c

@@ -78,7 +78,7 @@ static void check_DayNight(void) {
     LightingColour = Lighting.name.NightColour;
   }
 
-  tube_BrightLevel(Tube_All, LightingBright);
+  //tube_BrightLevel(Tube_All, LightingBright);
   TUBES_BRIGHT(LightingBright);
 }
 
@@ -377,6 +377,7 @@ static void HSV2LED(const uint8_t hue, const uint8_t val) {
   * Show info on tubes.
   */
 void showTime(void) {
+  static tube4_t old_buf;
   uint8_t hue;
   MinusFadeIn();
   RTOS_SetTask(MinusFadeOut, 500, 0);
@@ -402,7 +403,8 @@ void showTime(void) {
   buf.s8.tD = Clock.Min >> 4;
   buf.s8.tE = Clock.Min & 0xf;
   if (Clock.Min == 0) {
-    slideDigits(buf);
+    lShiftDigits(old_buf, buf);
+    old_buf = buf;
   } else {
     showDigits(buf);
   }
@@ -428,10 +430,10 @@ void showWD(void) {
   IN15_OFF;
 
   tube4_t buf;
-  buf.s8.tA = 0xf;
+  buf.s8.tA = TUBE_BLANK;
   buf.s8.tB = Clock.WD & 0xf;
-  buf.s8.tD = 0xf;
-  buf.s8.tE = 0xf;
+  buf.s8.tD = TUBE_BLANK;
+  buf.s8.tE = TUBE_BLANK;
   showDigits(buf);
 }
 
@@ -468,8 +470,8 @@ void showHumidity(void) {
   tube4_t buf;
   buf.s8.tA = Humidity / 10;
   buf.s8.tB = Humidity % 10;
-  buf.s8.tD = 0xf;
-  buf.s8.tE = 0xf;
+  buf.s8.tD = TUBE_BLANK;
+  buf.s8.tE = TUBE_BLANK;
   showDigits(buf);
 }
 
@@ -482,8 +484,8 @@ void showTemperature(void) {
   IN15_FadeIn();
 
   tube4_t buf;
-  buf.s8.tA = 0xf;
-  buf.s8.tB = 0xf;
+  buf.s8.tA = TUBE_BLANK;
+  buf.s8.tB = TUBE_BLANK;
   buf.s8.tD = Temperature / 10;
   buf.s8.tE = Temperature % 10;
   showDigits(buf);
@@ -497,7 +499,7 @@ void showPressure(void) {
 
   tube4_t buf;
   int tmp;
-  buf.s8.tA = 0xf;
+  buf.s8.tA = TUBE_BLANK;
   buf.s8.tB = Pressure / 100;
   tmp = Pressure % 100;
   buf.s8.tD = tmp / 10;
@@ -618,10 +620,10 @@ void setWDShow(void) {
 	dispWDT = DISP_WDT_TIME;
 
   tube4_t buf;
-  buf.s8.tA = 0xf;
+  buf.s8.tA = TUBE_BLANK;
   buf.s8.tB = setClock.WD & 0xf;
-  buf.s8.tD = 0xf;
-  buf.s8.tE = 0xf;
+  buf.s8.tD = TUBE_BLANK;
+  buf.s8.tE = TUBE_BLANK;
   showDigits(buf);
 }
 
@@ -761,9 +763,9 @@ void showDNmode(void) {
     nm = setLighting.name.NightMode;
   }
 
-  buf.s8.tA = 0xf;
+  buf.s8.tA = TUBE_BLANK;
   buf.s8.tB = dm & 0xf;
-  buf.s8.tD = 0xf;
+  buf.s8.tD = TUBE_BLANK;
   buf.s8.tE = nm & 0xf;
   showDigits(buf);
 }
@@ -886,7 +888,8 @@ void setIncDayHour(void) {
 
 void setIncDayBright(void) {
   dvalIncrease(&setLighting.name.DayBright, MAX_BRIGHT_LVL);
-  tube_BrightLevel(Tube_All, setLighting.name.DayBright);
+  //tube_BrightLevel(Tube_All, setLighting.name.DayBright);
+  TUBES_BRIGHT(setLighting.name.DayBright);
 }
 
 void setIncDayMode(void) {
@@ -909,7 +912,8 @@ void setDecDayHour(void) {
 
 void setDecDayBright(void) {
   dvalDecrease(&setLighting.name.DayBright, MAX_BRIGHT_LVL);
-  tube_BrightLevel(Tube_All, setLighting.name.DayBright);
+  //tube_BrightLevel(Tube_All, setLighting.name.DayBright);
+  TUBES_BRIGHT(setLighting.name.DayBright);
 }
 
 void setDecDayMode(void) {
@@ -932,7 +936,8 @@ void setIncNightHour(void) {
 
 void setIncNightBright(void) {
   dvalIncrease(&setLighting.name.NightBright, MAX_BRIGHT_LVL);
-  tube_BrightLevel(Tube_All, setLighting.name.NightBright);
+  //tube_BrightLevel(Tube_All, setLighting.name.NightBright);
+  TUBES_BRIGHT(setLighting.name.NightBright);
 }
 
 void setIncNightMode(void) {
@@ -955,7 +960,8 @@ void setDecNightHour(void) {
 
 void setDecNightBright(void) {
   dvalDecrease(&setLighting.name.NightBright, MAX_BRIGHT_LVL);
-  tube_BrightLevel(Tube_All, setLighting.name.NightBright);
+  //tube_BrightLevel(Tube_All, setLighting.name.NightBright);
+  TUBES_BRIGHT(setLighting.name.NightBright);
 }
 
 void setDecNightMode(void) {