clock.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #pragma once
  2. #ifndef _CLOCK_H
  3. #define _CLOCK_H
  4. /* Includes */
  5. #include "main.h"
  6. /* type defs */
  7. typedef union {
  8. uint64_t u64;
  9. uint32_t u32[2];
  10. uint8_t u8[8];
  11. struct {
  12. uint8_t DayHour;
  13. uint8_t NightHour;
  14. uint8_t DayBright;
  15. uint8_t NightBright;
  16. uint8_t DayMode;
  17. uint8_t NightMode;
  18. uint8_t DayColour;
  19. uint8_t NightColour;
  20. } name;
  21. } flash_data_t;
  22. typedef enum {
  23. light_Off = 0x0,
  24. light_Rainbow = 0x1,
  25. light_Colour = 0x2
  26. } light_mode_t;
  27. /* macro */
  28. #define FADE_START 0
  29. #define FADE_STOP 15
  30. #define FADE_STEP 1
  31. // Day/Night mode
  32. #define MORNING_HOUR 0x06
  33. #define EVENING_HOUR 0x22
  34. #define DAY_BR_LVL 11
  35. #define NIGHT_BR_LVL 5
  36. #define MAX_BRIGHT_LVL 15
  37. #define MAX_LIGHT_MODE 2
  38. #define MAX_COLOR_VAL 59
  39. // Color HUE angle
  40. #define COLOUR_RED 0
  41. #define COLOUR_GREEN 20
  42. #define COLOUR_BLUE 40
  43. #define COLOUR_NIXIE 1
  44. /* time constant in ms */
  45. #define BTN_SCAN_PERIOD 10
  46. #define BTN_SCAN_PAUSE 200
  47. #define BTN_TIME_PRESSED 30
  48. #define BTN_TIME_HOLDED 500
  49. #define BTN_TIME_REPEATED 50
  50. /* Display timeout, sec */
  51. #define DISP_WDT_TIME 15
  52. /* variables */
  53. extern rtc_t Clock;
  54. /* function prototypes */
  55. void Clock_Init(void);
  56. void btnProcess(void);
  57. void new_Second(void);
  58. #endif /* _CLOCK_H */