|
@@ -16,16 +16,14 @@ static rtc_t setClock;
|
|
|
static btn_t Button[BTN_NUM] = {
|
|
|
{0, evBTN1Pressed, evBTN1Holded, BTN1_PIN},
|
|
|
{0, evBTN2Pressed, evBTN2Pressed, BTN2_PIN},
|
|
|
- {0, evBTN3Pressed, evBTN3Pressed, BTN3_PIN},
|
|
|
- {0, evBTN4Pressed, evBTN4Holded, BTN4_PIN}
|
|
|
+ {0, evBTN3Pressed, evBTN3Pressed, BTN3_PIN} //,
|
|
|
+ //{0, evBTN4Pressed, evBTN4Holded, BTN4_PIN}
|
|
|
};
|
|
|
//convert linear bright level to logariphmic
|
|
|
const uint8_t cie[MAX_BRIGHT_LVL + 1] = {
|
|
|
0, 2, 4, 8, 13, 20, 29, 40, 54, 72, 92, 116, 145, 177, 214, 255
|
|
|
};
|
|
|
volatile static uint8_t dispWDT = 0;
|
|
|
-volatile in15_pin_t SymbolIN15 = sym_None;
|
|
|
-static in15_pin_t symToFade = 0;
|
|
|
static uint8_t LightingBright;
|
|
|
static light_mode_t LightingMode;
|
|
|
static uint8_t LightingColour;
|
|
@@ -34,13 +32,6 @@ static flash_data_t Lighting, setLighting;
|
|
|
/* function prototypes */
|
|
|
static void check_DayNight(void);
|
|
|
static void HSV2LED(const uint8_t hue, const uint8_t val);
|
|
|
-static void MinusFadeIn(void);
|
|
|
-static void MinusFadeOut(void);
|
|
|
-static void PlusFadeIn(void);
|
|
|
-static void PercentFadeIn(void);
|
|
|
-static void PressureFadeIn(void);
|
|
|
-static void IN15_FadeIn(void);
|
|
|
-static void IN15_FadeOut(void);
|
|
|
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);
|
|
@@ -142,197 +133,31 @@ void new_Second(void) {
|
|
|
*/
|
|
|
void in15Off(void) {
|
|
|
IN15_OFF;
|
|
|
- //TUBE_C_OFF;
|
|
|
- //while (SymbolIN15 != sym_None) {}
|
|
|
- //SymbolIN15 = sym_Off;
|
|
|
+ TUBE_C_OFF;
|
|
|
}
|
|
|
|
|
|
void in15Minus(void) {
|
|
|
- //IN15_OFF;
|
|
|
- //IN15_Minus;
|
|
|
- //TUBE_C_ON;
|
|
|
- while (SymbolIN15 != sym_None) {}
|
|
|
- SymbolIN15 = sym_Minus;
|
|
|
+ IN15_OFF;
|
|
|
+ IN15_Minus;
|
|
|
+ TUBE_C_ON;
|
|
|
}
|
|
|
|
|
|
void in15Plus(void) {
|
|
|
IN15_OFF;
|
|
|
- //IN15_Plus;
|
|
|
- //TUBE_C_ON;
|
|
|
- SymbolIN15 = sym_Plus;
|
|
|
+ IN15_Plus;
|
|
|
+ TUBE_C_ON;
|
|
|
}
|
|
|
|
|
|
void in15Percent(void) {
|
|
|
IN15_OFF;
|
|
|
- //IN15_Percent;
|
|
|
- //TUBE_C_ON;
|
|
|
- SymbolIN15 = sym_Percent;
|
|
|
+ IN15_Percent;
|
|
|
+ TUBE_C_ON;
|
|
|
}
|
|
|
|
|
|
void in15P(void) {
|
|
|
IN15_OFF;
|
|
|
- //IN15_P;
|
|
|
- //TUBE_C_ON;
|
|
|
- SymbolIN15 = sym_Pressure;
|
|
|
-}
|
|
|
-
|
|
|
-/** 'Faded' funcions */
|
|
|
-static void MinusFadeIn(void) {
|
|
|
- static uint8_t on = FADE_START;
|
|
|
- static uint8_t off = FADE_STOP;
|
|
|
- static uint8_t st = 0;
|
|
|
-
|
|
|
- if (st == 0) {
|
|
|
- st = 1;
|
|
|
- IN15_Minus;
|
|
|
- on += FADE_STEP;
|
|
|
- if (on < FADE_STOP) {
|
|
|
- RTOS_SetTask(MinusFadeIn, on, 0);
|
|
|
- } else {
|
|
|
- on = FADE_START; off = FADE_STOP; st = 0;
|
|
|
- }
|
|
|
- } else {
|
|
|
- st = 0;
|
|
|
- IN15_OFF;
|
|
|
- off -= FADE_STEP;
|
|
|
- RTOS_SetTask(MinusFadeIn, off, 0);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-static void MinusFadeOut(void) {
|
|
|
- static uint8_t off = FADE_START;
|
|
|
- static uint8_t on = FADE_STOP;
|
|
|
- static uint8_t st = 0;
|
|
|
-
|
|
|
- if (st == 0) {
|
|
|
- st = 1;
|
|
|
- IN15_OFF;
|
|
|
- off += FADE_STEP;
|
|
|
- if (off < FADE_STOP) {
|
|
|
- RTOS_SetTask(MinusFadeOut, off, 0);
|
|
|
- } else {
|
|
|
- off = FADE_START; on = FADE_STOP; st = 0;
|
|
|
- }
|
|
|
- } else {
|
|
|
- st = 0;
|
|
|
- IN15_Minus;
|
|
|
- on -= FADE_STEP;
|
|
|
- RTOS_SetTask(MinusFadeOut, on, 0);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-static void PlusFadeIn(void) {
|
|
|
- static uint8_t on = FADE_START;
|
|
|
- static uint8_t off = FADE_STOP;
|
|
|
- static uint8_t st = 0;
|
|
|
-
|
|
|
- if (st == 0) {
|
|
|
- st = 1;
|
|
|
- IN15_Plus;
|
|
|
- on += FADE_STEP;
|
|
|
- if (on < FADE_STOP) {
|
|
|
- RTOS_SetTask(PlusFadeIn, on, 0);
|
|
|
- } else {
|
|
|
- on = FADE_START; off = FADE_STOP; st = 0;
|
|
|
- }
|
|
|
- } else {
|
|
|
- st = 0;
|
|
|
- IN15_OFF;
|
|
|
- off -= FADE_STEP;
|
|
|
- RTOS_SetTask(PlusFadeIn, off, 0);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-static void PercentFadeIn(void) {
|
|
|
- static uint8_t on = FADE_START;
|
|
|
- static uint8_t off = FADE_STOP;
|
|
|
- static uint8_t st = 0;
|
|
|
-
|
|
|
- if (st == 0) {
|
|
|
- st = 1;
|
|
|
- IN15_Percent;
|
|
|
- on += FADE_STEP;
|
|
|
- if (on < FADE_STOP) {
|
|
|
- RTOS_SetTask(PercentFadeIn, on, 0);
|
|
|
- } else {
|
|
|
- on = FADE_START; off = FADE_STOP; st = 0;
|
|
|
- }
|
|
|
- } else {
|
|
|
- st = 0;
|
|
|
- IN15_OFF;
|
|
|
- off -= FADE_STEP;
|
|
|
- RTOS_SetTask(PercentFadeIn, off, 0);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-static void PressureFadeIn(void) {
|
|
|
- static uint8_t on = FADE_START;
|
|
|
- static uint8_t off = FADE_STOP;
|
|
|
- static uint8_t st = 0;
|
|
|
-
|
|
|
- if (st == 0) {
|
|
|
- st = 1;
|
|
|
- IN15_P;
|
|
|
- on += FADE_STEP;
|
|
|
- if (on < FADE_STOP) {
|
|
|
- RTOS_SetTask(PressureFadeIn, on, 0);
|
|
|
- } else {
|
|
|
- on = FADE_START; off = FADE_STOP; st = 0;
|
|
|
- }
|
|
|
- } else {
|
|
|
- st = 0;
|
|
|
- IN15_OFF;
|
|
|
- off -= FADE_STEP;
|
|
|
- RTOS_SetTask(PressureFadeIn, off, 0);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-static void IN15_FadeIn(void) {
|
|
|
- static uint8_t on = FADE_START;
|
|
|
- static uint8_t off = FADE_STOP;
|
|
|
- static uint8_t st = 0;
|
|
|
-
|
|
|
- if (symToFade != 0) {
|
|
|
- if (st == 0) {
|
|
|
- st = 1;
|
|
|
- GPIOA->BSRR = symToFade;
|
|
|
- on += FADE_STEP;
|
|
|
- if (on < FADE_STOP) {
|
|
|
- RTOS_SetTask(IN15_FadeIn, on, 0);
|
|
|
- } else {
|
|
|
- on = FADE_START; off = FADE_STOP; st = 0; symToFade = 0;
|
|
|
- }
|
|
|
- } else {
|
|
|
- st = 0;
|
|
|
- IN15_OFF;
|
|
|
- off -= FADE_STEP;
|
|
|
- RTOS_SetTask(IN15_FadeIn, off, 0);
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-static void IN15_FadeOut(void) {
|
|
|
- static uint8_t off = FADE_START;
|
|
|
- static uint8_t on = FADE_STOP;
|
|
|
- static uint8_t st = 0;
|
|
|
-
|
|
|
- if (symToFade != 0) {
|
|
|
- if (st == 0) {
|
|
|
- st = 1;
|
|
|
- IN15_OFF;
|
|
|
- off += FADE_STEP;
|
|
|
- if (off < FADE_STOP) {
|
|
|
- RTOS_SetTask(IN15_FadeOut, off, 0);
|
|
|
- } else {
|
|
|
- off = FADE_START; on = FADE_STOP; st = 0; symToFade = 0;
|
|
|
- }
|
|
|
- } else {
|
|
|
- st = 0;
|
|
|
- GPIOA->BSRR = symToFade;
|
|
|
- on -= FADE_STEP;
|
|
|
- RTOS_SetTask(IN15_FadeOut, on, 0);
|
|
|
- }
|
|
|
- }
|
|
|
+ IN15_P;
|
|
|
+ TUBE_C_ON;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -386,7 +211,6 @@ static void HSV2LED(const uint8_t hue, const uint8_t val) {
|
|
|
*/
|
|
|
void showTime(void) {
|
|
|
uint8_t hue;
|
|
|
- //MinusFadeIn();
|
|
|
in15Minus();
|
|
|
RTOS_SetTask(in15Off, 500, 0);
|
|
|
|
|
@@ -414,8 +238,7 @@ void showTime(void) {
|
|
|
}
|
|
|
|
|
|
void showMMSS(void) {
|
|
|
- RTOS_DeleteTask(MinusFadeOut);
|
|
|
- IN15_Minus;
|
|
|
+ in15Minus();
|
|
|
|
|
|
uint8_t hue = bcd2bin(Clock.Sec);
|
|
|
HSV2LED(hue, LightingBright);
|
|
@@ -430,7 +253,7 @@ void showMMSS(void) {
|
|
|
|
|
|
void showWD(void) {
|
|
|
dispWDT = DISP_WDT_TIME;
|
|
|
- IN15_OFF;
|
|
|
+ in15Off();
|
|
|
|
|
|
tube4_t buf;
|
|
|
buf.s8.tA = TUBE_BLANK;
|
|
@@ -442,7 +265,7 @@ void showWD(void) {
|
|
|
|
|
|
void showDayMon(void) {
|
|
|
dispWDT = DISP_WDT_TIME;
|
|
|
- IN15_OFF;
|
|
|
+ in15Off();
|
|
|
|
|
|
tube4_t buf;
|
|
|
buf.s8.tA = Clock.Day >> 4;
|
|
@@ -454,7 +277,7 @@ void showDayMon(void) {
|
|
|
|
|
|
void showYear(void) {
|
|
|
dispWDT = DISP_WDT_TIME;
|
|
|
- IN15_OFF;
|
|
|
+ in15Off();
|
|
|
|
|
|
tube4_t buf;
|
|
|
buf.s8.tA = 2;
|
|
@@ -467,8 +290,7 @@ void showYear(void) {
|
|
|
void showHumidity(void) {
|
|
|
dispWDT = DISP_WDT_TIME/2;
|
|
|
HSV2LED(COLOUR_BLUE, LightingBright);
|
|
|
- symToFade = sym_Percent;
|
|
|
- IN15_FadeIn();
|
|
|
+ in15Percent();
|
|
|
|
|
|
tube4_t buf;
|
|
|
buf.s8.tA = Humidity / 10;
|
|
@@ -481,10 +303,7 @@ void showHumidity(void) {
|
|
|
void showTemperature(void) {
|
|
|
dispWDT = DISP_WDT_TIME/2;
|
|
|
HSV2LED(COLOUR_RED, LightingBright);
|
|
|
- RTOS_DeleteTask(MinusFadeIn);
|
|
|
- RTOS_DeleteTask(MinusFadeOut);
|
|
|
- symToFade = sym_Plus;
|
|
|
- IN15_FadeIn();
|
|
|
+ in15Plus();
|
|
|
|
|
|
tube4_t buf;
|
|
|
buf.s8.tA = TUBE_BLANK;
|
|
@@ -497,8 +316,7 @@ void showTemperature(void) {
|
|
|
void showPressure(void) {
|
|
|
dispWDT = DISP_WDT_TIME/2;
|
|
|
HSV2LED(COLOUR_GREEN, LightingBright);
|
|
|
- symToFade = sym_Pressure;
|
|
|
- IN15_FadeIn();
|
|
|
+ in15P();
|
|
|
|
|
|
tube4_t buf;
|
|
|
int tmp;
|
|
@@ -512,7 +330,7 @@ void showPressure(void) {
|
|
|
|
|
|
/* Simple function for cyclic show all sensor data */
|
|
|
void showSensorData(void) {
|
|
|
- RTOS_DeleteTask(MinusFadeOut);
|
|
|
+ in15Off();
|
|
|
|
|
|
showTemperature();
|
|
|
tdelay_ms(3000);
|
|
@@ -524,7 +342,6 @@ void showSensorData(void) {
|
|
|
tdelay_ms(2700);
|
|
|
|
|
|
ES_SetState(stShowTime);
|
|
|
-// showTime();
|
|
|
}
|
|
|
|
|
|
void setTimeShow(void) {
|
|
@@ -539,7 +356,6 @@ void setTimeShow(void) {
|
|
|
}
|
|
|
|
|
|
void setTimeBegin(void) {
|
|
|
- RTOS_DeleteTask(MinusFadeOut);
|
|
|
in15Minus();
|
|
|
HSV2LED(COLOUR_NIXIE, LightingBright);
|
|
|
RTOS_SetTask(btnProcess, BTN_TIME_HOLDED, BTN_SCAN_PERIOD);
|
|
@@ -593,7 +409,7 @@ void setTimeEnd(void) {
|
|
|
}
|
|
|
|
|
|
void setDateBegin(void) {
|
|
|
- IN15_OFF;
|
|
|
+ in15Off();
|
|
|
HSV2LED(COLOUR_NIXIE, LightingBright);
|
|
|
RTOS_SetTask(btnProcess, BTN_TIME_HOLDED, BTN_SCAN_PERIOD);
|
|
|
RTC_ReadAll(&setClock);
|
|
@@ -794,7 +610,7 @@ void showDNcolour(void) {
|
|
|
}
|
|
|
|
|
|
void setDNbegin(void) {
|
|
|
- IN15_OFF;
|
|
|
+ in15Off();
|
|
|
RTOS_SetTask(btnProcess, BTN_TIME_HOLDED, BTN_SCAN_PERIOD);
|
|
|
setLighting.u64 = Lighting.u64;
|
|
|
//Flash_Read(&setLighting.u64);
|