|
@@ -25,7 +25,9 @@ const uint8_t cie[MAX_BRIGHT_LVL + 1] = {
|
|
|
};
|
|
|
volatile static uint8_t dispWDT = 0;
|
|
|
static in15_pin_t symToFade = 0;
|
|
|
-static uint8_t BrightLevel;
|
|
|
+static uint8_t LightingBright;
|
|
|
+static light_mode_t LightingMode;
|
|
|
+static uint8_t LightingColour;
|
|
|
static flash_data_t Lighting, setLighting;
|
|
|
|
|
|
/* function prototypes */
|
|
@@ -42,6 +44,7 @@ static void valIncrease(uint8_t * val, const uint8_t max);
|
|
|
static void valDecrease(uint8_t * val, const uint8_t max);
|
|
|
static void dvalIncrease(uint8_t * val, const uint8_t max);
|
|
|
static void dvalDecrease(uint8_t * val, const uint8_t max);
|
|
|
+static void showRainbow(void);
|
|
|
|
|
|
/* funcions */
|
|
|
void Clock_Init(void) {
|
|
@@ -49,7 +52,7 @@ void Clock_Init(void) {
|
|
|
showTime();
|
|
|
|
|
|
flash_result_t flash_res = Flash_Read(&Lighting.u64);
|
|
|
- if ( flash_res != Flash_Ok) {
|
|
|
+ if ((flash_res != Flash_Ok) || (Lighting.name.DayHour == 0xff)) {
|
|
|
Lighting.name.DayHour = MORNING_HOUR;
|
|
|
Lighting.name.NightHour = EVENING_HOUR;
|
|
|
Lighting.name.DayBright = DAY_BR_LVL;
|
|
@@ -57,14 +60,6 @@ void Clock_Init(void) {
|
|
|
Lighting.name.DayMode = light_Rainbow;
|
|
|
Lighting.name.NightMode = light_Colour;
|
|
|
Lighting.name.NightColour = COLOUR_NIXIE;
|
|
|
- } else {
|
|
|
- if (Lighting.name.DayHour == 0xff) {
|
|
|
- /* launch set parameters
|
|
|
- ES_SetState(stSetDayHour);
|
|
|
- setDNbegin();
|
|
|
- setDayHourBegin();
|
|
|
- white (ES_GetState() != ???); */
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
check_DayNight();
|
|
@@ -73,14 +68,18 @@ void Clock_Init(void) {
|
|
|
static void check_DayNight(void) {
|
|
|
if ((Clock.Hr >= Lighting.name.DayHour) && (Clock.Hr < Lighting.name.NightHour)) {
|
|
|
Flag.Now_Day = 1;
|
|
|
- BrightLevel = cie[Lighting.name.DayBright];
|
|
|
+ LightingBright = cie[Lighting.name.DayBright];
|
|
|
+ LightingMode = Lighting.name.DayMode;
|
|
|
+ LightingColour = Lighting.name.DayColour;
|
|
|
} else {
|
|
|
Flag.Now_Day = 0;
|
|
|
- BrightLevel = cie[Lighting.name.NightBright];
|
|
|
+ LightingBright = cie[Lighting.name.NightBright];
|
|
|
+ LightingMode = Lighting.name.NightMode;
|
|
|
+ LightingColour = Lighting.name.NightColour;
|
|
|
}
|
|
|
|
|
|
- tube_BrightLevel(Tube_All, BrightLevel);
|
|
|
- //TUBES_BRIGHT(BrightLevel);
|
|
|
+ tube_BrightLevel(Tube_All, LightingBright);
|
|
|
+ TUBES_BRIGHT(LightingBright);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -378,14 +377,23 @@ static void HSV2LED(const uint8_t hue, const uint8_t val) {
|
|
|
* Show info on tubes.
|
|
|
*/
|
|
|
void showTime(void) {
|
|
|
+ uint8_t hue;
|
|
|
MinusFadeIn();
|
|
|
RTOS_SetTask(MinusFadeOut, 500, 0);
|
|
|
|
|
|
- if (Flag.Now_Day != 0) {
|
|
|
- uint8_t hue = bcd2bin(Clock.Sec);
|
|
|
- HSV2LED(hue, BrightLevel);
|
|
|
- } else {
|
|
|
- HSV2LED(COLOUR_NIXIE, BrightLevel);
|
|
|
+ switch (LightingMode) {
|
|
|
+ case light_Rainbow:
|
|
|
+ hue = bcd2bin(Clock.Sec);
|
|
|
+ HSV2LED(hue, LightingBright);
|
|
|
+ break;
|
|
|
+
|
|
|
+ case light_Colour:
|
|
|
+ HSV2LED(LightingColour, LightingBright);
|
|
|
+ break;
|
|
|
+
|
|
|
+ default:
|
|
|
+ LEDS_OFF;
|
|
|
+ break;
|
|
|
}
|
|
|
|
|
|
tube4_t buf;
|
|
@@ -393,7 +401,11 @@ void showTime(void) {
|
|
|
buf.s8.tB = Clock.Hr & 0xf;
|
|
|
buf.s8.tD = Clock.Min >> 4;
|
|
|
buf.s8.tE = Clock.Min & 0xf;
|
|
|
- showDigits(buf);
|
|
|
+ if (Clock.Min == 0) {
|
|
|
+ slideDigits(buf);
|
|
|
+ } else {
|
|
|
+ showDigits(buf);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void showMMSS(void) {
|
|
@@ -401,7 +413,7 @@ void showMMSS(void) {
|
|
|
IN15_Minus;
|
|
|
|
|
|
uint8_t hue = bcd2bin(Clock.Sec);
|
|
|
- HSV2LED(hue, BrightLevel);
|
|
|
+ HSV2LED(hue, LightingBright);
|
|
|
|
|
|
tube4_t buf;
|
|
|
buf.s8.tA = Clock.Min >> 4;
|
|
@@ -448,8 +460,8 @@ void showYear(void) {
|
|
|
}
|
|
|
|
|
|
void showHumidity(void) {
|
|
|
- dispWDT = DISP_WDT_TIME;
|
|
|
- HSV2LED(COLOUR_BLUE, BrightLevel);
|
|
|
+ dispWDT = DISP_WDT_TIME/2;
|
|
|
+ HSV2LED(COLOUR_BLUE, LightingBright);
|
|
|
symToFade = sym_Percent;
|
|
|
IN15_FadeIn();
|
|
|
|
|
@@ -462,8 +474,8 @@ void showHumidity(void) {
|
|
|
}
|
|
|
|
|
|
void showTemperature(void) {
|
|
|
- dispWDT = DISP_WDT_TIME;
|
|
|
- HSV2LED(COLOUR_RED, BrightLevel);
|
|
|
+ dispWDT = DISP_WDT_TIME/2;
|
|
|
+ HSV2LED(COLOUR_RED, LightingBright);
|
|
|
RTOS_DeleteTask(MinusFadeIn);
|
|
|
RTOS_DeleteTask(MinusFadeOut);
|
|
|
symToFade = sym_Plus;
|
|
@@ -478,8 +490,8 @@ void showTemperature(void) {
|
|
|
}
|
|
|
|
|
|
void showPressure(void) {
|
|
|
- dispWDT = DISP_WDT_TIME;
|
|
|
- HSV2LED(COLOUR_GREEN, BrightLevel);
|
|
|
+ dispWDT = DISP_WDT_TIME/2;
|
|
|
+ HSV2LED(COLOUR_GREEN, LightingBright);
|
|
|
symToFade = sym_Pressure;
|
|
|
IN15_FadeIn();
|
|
|
|
|
@@ -524,7 +536,7 @@ void setTimeShow(void) {
|
|
|
void setTimeBegin(void) {
|
|
|
RTOS_DeleteTask(MinusFadeOut);
|
|
|
in15Minus();
|
|
|
- HSV2LED(COLOUR_NIXIE, BrightLevel);
|
|
|
+ HSV2LED(COLOUR_NIXIE, LightingBright);
|
|
|
RTOS_SetTask(btnProcess, BTN_TIME_HOLDED, BTN_SCAN_PERIOD);
|
|
|
RTC_ReadAll(&setClock);
|
|
|
}
|
|
@@ -577,7 +589,7 @@ void setTimeEnd(void) {
|
|
|
|
|
|
void setDateBegin(void) {
|
|
|
IN15_OFF;
|
|
|
- HSV2LED(COLOUR_NIXIE, BrightLevel);
|
|
|
+ HSV2LED(COLOUR_NIXIE, LightingBright);
|
|
|
RTOS_SetTask(btnProcess, BTN_TIME_HOLDED, BTN_SCAN_PERIOD);
|
|
|
RTC_ReadAll(&setClock);
|
|
|
}
|
|
@@ -737,20 +749,22 @@ void showDNbright(void) {
|
|
|
void showDNmode(void) {
|
|
|
dispWDT = DISP_WDT_TIME;
|
|
|
|
|
|
+ uint8_t dm, nm;
|
|
|
tube4_t buf;
|
|
|
es_state_t e_st = ES_GetState();
|
|
|
|
|
|
if (e_st == stShowDNmode){
|
|
|
- buf.s8.tA = Lighting.name.DayMode / 10;
|
|
|
- buf.s8.tB = Lighting.name.DayMode % 10;
|
|
|
- buf.s8.tD = Lighting.name.NightMode / 10;
|
|
|
- buf.s8.tE = Lighting.name.NightMode % 10;
|
|
|
+ dm = Lighting.name.DayMode;
|
|
|
+ nm = Lighting.name.NightMode;
|
|
|
} else {
|
|
|
- buf.s8.tA = setLighting.name.DayMode / 10;
|
|
|
- buf.s8.tB = setLighting.name.DayMode % 10;
|
|
|
- buf.s8.tD = setLighting.name.NightMode / 10;
|
|
|
- buf.s8.tE = setLighting.name.NightMode % 10;
|
|
|
+ dm = setLighting.name.DayMode;
|
|
|
+ nm = setLighting.name.NightMode;
|
|
|
}
|
|
|
+
|
|
|
+ buf.s8.tA = 0xf;
|
|
|
+ buf.s8.tB = dm & 0xf;
|
|
|
+ buf.s8.tD = 0xf;
|
|
|
+ buf.s8.tE = nm & 0xf;
|
|
|
showDigits(buf);
|
|
|
}
|
|
|
|
|
@@ -852,7 +866,7 @@ void setDayColourBegin(void) {
|
|
|
Flag.Blink_4 = 0;
|
|
|
Flag.Blink_5 = 0;
|
|
|
Blink_Start();
|
|
|
- HSV2LED(setLighting.name.DayColour, BrightLevel);
|
|
|
+ HSV2LED(setLighting.name.DayColour, LightingBright);
|
|
|
showDNcolour();
|
|
|
}
|
|
|
|
|
@@ -862,7 +876,7 @@ void setNightColourBegin(void) {
|
|
|
Flag.Blink_4 = 1;
|
|
|
Flag.Blink_5 = 1;
|
|
|
Blink_Start();
|
|
|
- HSV2LED(setLighting.name.NightColour, BrightLevel);
|
|
|
+ HSV2LED(setLighting.name.NightColour, LightingBright);
|
|
|
showDNcolour();
|
|
|
}
|
|
|
|
|
@@ -877,11 +891,16 @@ void setIncDayBright(void) {
|
|
|
|
|
|
void setIncDayMode(void) {
|
|
|
dvalIncrease(&setLighting.name.DayMode, MAX_LIGHT_MODE);
|
|
|
+ if (setLighting.name.DayMode == light_Rainbow) {
|
|
|
+ RTOS_SetTask(showRainbow, 0, 20);
|
|
|
+ } else {
|
|
|
+ RTOS_DeleteTask(showRainbow);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void setIncDayColour(void) {
|
|
|
dvalIncrease(&setLighting.name.DayColour, MAX_COLOR_VAL);
|
|
|
- HSV2LED(setLighting.name.DayColour, BrightLevel);
|
|
|
+ HSV2LED(setLighting.name.DayColour, LightingBright);
|
|
|
}
|
|
|
|
|
|
void setDecDayHour(void) {
|
|
@@ -895,11 +914,16 @@ void setDecDayBright(void) {
|
|
|
|
|
|
void setDecDayMode(void) {
|
|
|
dvalDecrease(&setLighting.name.DayMode, MAX_LIGHT_MODE);
|
|
|
+ if (setLighting.name.DayMode == light_Rainbow) {
|
|
|
+ RTOS_SetTask(showRainbow, 0, 20);
|
|
|
+ } else {
|
|
|
+ RTOS_DeleteTask(showRainbow);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void setDecDayColour(void) {
|
|
|
dvalDecrease(&setLighting.name.DayColour, MAX_COLOR_VAL);
|
|
|
- HSV2LED(setLighting.name.DayColour, BrightLevel);
|
|
|
+ HSV2LED(setLighting.name.DayColour, LightingBright);
|
|
|
}
|
|
|
|
|
|
void setIncNightHour(void) {
|
|
@@ -913,11 +937,16 @@ void setIncNightBright(void) {
|
|
|
|
|
|
void setIncNightMode(void) {
|
|
|
dvalIncrease(&setLighting.name.NightMode, MAX_LIGHT_MODE);
|
|
|
+ if (setLighting.name.NightMode == light_Rainbow) {
|
|
|
+ RTOS_SetTask(showRainbow, 0, 20);
|
|
|
+ } else {
|
|
|
+ RTOS_DeleteTask(showRainbow);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void setIncNightColour(void) {
|
|
|
dvalIncrease(&setLighting.name.NightColour, MAX_COLOR_VAL);
|
|
|
- HSV2LED(setLighting.name.NightColour, BrightLevel);
|
|
|
+ HSV2LED(setLighting.name.NightColour, LightingBright);
|
|
|
}
|
|
|
|
|
|
void setDecNightHour(void) {
|
|
@@ -931,11 +960,16 @@ void setDecNightBright(void) {
|
|
|
|
|
|
void setDecNightMode(void) {
|
|
|
dvalDecrease(&setLighting.name.NightMode, MAX_LIGHT_MODE);
|
|
|
+ if (setLighting.name.NightMode == light_Rainbow) {
|
|
|
+ RTOS_SetTask(showRainbow, 0, 20);
|
|
|
+ } else {
|
|
|
+ RTOS_DeleteTask(showRainbow);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void setDecNightColour(void) {
|
|
|
dvalDecrease(&setLighting.name.NightColour, MAX_COLOR_VAL);
|
|
|
- HSV2LED(setLighting.name.NightColour, BrightLevel);
|
|
|
+ HSV2LED(setLighting.name.NightColour, LightingBright);
|
|
|
}
|
|
|
|
|
|
void setDNbreak(void) {
|
|
@@ -994,3 +1028,16 @@ static void dvalDecrease(uint8_t * val, uint8_t max) {
|
|
|
*val = max;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+static void showRainbow(void) {
|
|
|
+ static uint8_t hue = 0;
|
|
|
+
|
|
|
+ HSV2LED(hue, LightingBright);
|
|
|
+
|
|
|
+ if (hue < 59) {
|
|
|
+ hue ++;
|
|
|
+ } else {
|
|
|
+ hue = 0;
|
|
|
+ RTOS_DeleteTask(showRainbow);
|
|
|
+ }
|
|
|
+}
|