satisfaction75.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. #pragma once
  2. #include "quantum.h"
  3. #ifdef KEYBOARD_cannonkeys_satisfaction75_prototype
  4. #include "prototype.h"
  5. #else
  6. #include "rev1.h"
  7. #endif
  8. #include "via.h" // only for EEPROM address
  9. #define EEPROM_ENABLED_ENCODER_MODES (VIA_EEPROM_CUSTOM_CONFIG_ADDR)
  10. #define EEPROM_CUSTOM_BACKLIGHT (VIA_EEPROM_CUSTOM_CONFIG_ADDR+1)
  11. #define EEPROM_DEFAULT_OLED (VIA_EEPROM_CUSTOM_CONFIG_ADDR+2)
  12. #define EEPROM_CUSTOM_ENCODER (VIA_EEPROM_CUSTOM_CONFIG_ADDR+3)
  13. /* screen off after this many milliseconds */
  14. #define ScreenOffInterval 60000 /* milliseconds */
  15. typedef union {
  16. uint8_t raw;
  17. struct {
  18. bool enable :1;
  19. bool breathing : 1;
  20. uint8_t level :6;
  21. };
  22. } backlight_config_t;
  23. // Start these at the USER code range in VIA
  24. enum my_keycodes {
  25. ENC_PRESS = 0x5F80,
  26. CLOCK_SET,
  27. OLED_TOGG
  28. };
  29. enum s75_keyboard_value_id {
  30. id_encoder_modes = 0x80,
  31. id_oled_default_mode,
  32. id_encoder_custom,
  33. id_oled_mode
  34. };
  35. enum encoder_modes {
  36. ENC_MODE_VOLUME,
  37. ENC_MODE_MEDIA,
  38. ENC_MODE_SCROLL,
  39. ENC_MODE_BRIGHTNESS,
  40. ENC_MODE_BACKLIGHT,
  41. ENC_MODE_CUSTOM0,
  42. ENC_MODE_CUSTOM1,
  43. ENC_MODE_CUSTOM2,
  44. _NUM_ENCODER_MODES,
  45. ENC_MODE_CLOCK_SET // This shouldn't be included in the default modes, so we put it after NUM_ENCODER_MODES
  46. };
  47. enum custom_encoder_behavior {
  48. ENC_CUSTOM_CW = 0,
  49. ENC_CUSTOM_CCW,
  50. ENC_CUSTOM_PRESS
  51. };
  52. enum oled_modes {
  53. OLED_DEFAULT,
  54. OLED_TIME,
  55. OLED_OFF,
  56. _NUM_OLED_MODES
  57. };
  58. // Keyboard Information
  59. extern volatile uint8_t led_numlock;
  60. extern volatile uint8_t led_capslock;
  61. extern volatile uint8_t led_scrolllock;
  62. extern uint8_t layer;
  63. // OLED Behavior
  64. extern uint16_t last_flush;
  65. extern bool queue_for_send;
  66. extern uint8_t oled_mode;
  67. extern bool oled_sleeping;
  68. // Encoder Behavior
  69. extern uint8_t encoder_value;
  70. extern uint8_t encoder_mode;
  71. extern uint8_t enabled_encoder_modes;
  72. // RTC
  73. extern RTCDateTime last_timespec;
  74. extern uint16_t last_minute;
  75. // RTC Configuration
  76. extern bool clock_set_mode;
  77. extern uint8_t time_config_idx;
  78. extern int8_t hour_config;
  79. extern int16_t minute_config;
  80. extern int8_t year_config;
  81. extern int8_t month_config;
  82. extern int8_t day_config;
  83. extern uint8_t previous_encoder_mode;
  84. // Backlighting
  85. extern backlight_config_t kb_backlight_config;
  86. extern bool kb_backlight_breathing;
  87. void pre_encoder_mode_change(void);
  88. void post_encoder_mode_change(void);
  89. void change_encoder_mode(bool negative);
  90. uint16_t handle_encoder_clockwise(void);
  91. uint16_t handle_encoder_ccw(void);
  92. uint16_t handle_encoder_press(void);
  93. uint16_t retrieve_custom_encoder_config(uint8_t encoder_idx, uint8_t behavior);
  94. void set_custom_encoder_config(uint8_t encoder_idx, uint8_t behavior, uint16_t new_code);
  95. void update_time_config(int8_t increment);
  96. __attribute__ ((weak))
  97. void draw_ui(void);
  98. void draw_default(void);
  99. void draw_clock(void);
  100. void backlight_init_ports(void);
  101. void backlight_set(uint8_t level);
  102. bool is_breathing(void);
  103. void breathing_enable(void);
  104. void breathing_disable(void);
  105. void custom_config_load(void);
  106. void backlight_config_save(void);