瀏覽代碼

Small fixes. HSV2RGB result the same.

Vladimir N. Shilov 2 年之前
父節點
當前提交
9948d0b58f
共有 2 個文件被更改,包括 6 次插入9 次删除
  1. 1 1
      MDK-ARM/MNC-IN12x5.uvoptx
  2. 5 8
      Src/clock.c

+ 1 - 1
MDK-ARM/MNC-IN12x5.uvoptx

@@ -145,7 +145,7 @@
         <SetRegEntry>
           <Number>0</Number>
           <Key>JL2CM3</Key>
-          <Name>-U4294967295 -O78 -S2 -ZTIFSpeedSel5000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(0BC11477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8008 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO15 -FD20000000 -FC1000 -FN1 -FF0STM32G0xx_64.FLM -FS08000000 -FL010000 -FP0($$Device:STM32G030K8Tx$CMSIS\Flash\STM32G0xx_64.FLM)</Name>
+          <Name>-U805251123 -O78 -S0 -ZTIFSpeedSel20000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(0BC11477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8008 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO15 -FD20000000 -FC1000 -FN1 -FF0STM32G0xx_64.FLM -FS08000000 -FL010000 -FP0($$Device:STM32G030K8Tx$CMSIS\Flash\STM32G0xx_64.FLM)</Name>
         </SetRegEntry>
         <SetRegEntry>
           <Number>0</Number>

+ 5 - 8
Src/clock.c

@@ -308,19 +308,18 @@ static void IN15_FadeOut(void) {
  * @param  hue: 0-59, sat: 0-255, val (lightness): 0-255
  * @return none. RGB value output direct to LED.
  */
-#define HUE_DEGREE    60
 static void HSV2LED(const int hue, const uint8_t sat, const uint8_t val) {
   uint8_t r, g, b;
 
   int h = hue;
   int s = sat;
   int v = val;
-  int i = h / (60 * HUE_DEGREE);
+  int i = h / 60;
   int p = (256 * v - s * v) / 256;
 
   if (i & 1)
   {
-    int q = (256 * 60 * HUE_DEGREE * v - h * s * v + 60 * HUE_DEGREE * s * v * i) / (256 * 60 * HUE_DEGREE);
+    int q = (256 * 60 * v - h * s * v + 60 * s * v * i) / (256 * 60);
     switch (i)
     {
     case 1:
@@ -342,7 +341,7 @@ static void HSV2LED(const int hue, const uint8_t sat, const uint8_t val) {
   }
   else
   {
-    int t = (256 * 60 * HUE_DEGREE * v + h * s * v - 60 * HUE_DEGREE * s * v * (i + 1)) / (256 * 60 * HUE_DEGREE);
+    int t = (256 * 60 * v + h * s * v - 60 * s * v * (i + 1)) / (256 * 60);
     switch (i)
     {
     case 0:
@@ -427,9 +426,7 @@ void showTime(void) {
   RTOS_SetTask(MinusFadeOut, 500, 0);
 
   if (Flag.Now_Day != 0) {
-    // new hsv2led
-    //uint16_t hue = (uint16_t)(bcd2bin(Clock.Sec) * 256) / 10;
-    uint8_t hue = bcd2bin(Clock.Sec);
+    int hue = 6 * bcd2bin(Clock.Sec);
     HSV2LED(hue, 255, BrightLevel);
   } else {
     HSV2LED(COLOUR_NIXIE, 255, BrightLevel);
@@ -447,7 +444,7 @@ void showMMSS(void) {
   RTOS_DeleteTask(MinusFadeOut);
   IN15_Minus;
 
-  uint8_t hue = bcd2bin(Clock.Sec);
+  int hue = 6 * bcd2bin(Clock.Sec);
   HSV2LED(hue, 255, BrightLevel);
 
   tube4_t buf;