diff options
Diffstat (limited to 'quantum/led_matrix.c')
| -rw-r--r-- | quantum/led_matrix.c | 226 |
1 files changed, 112 insertions, 114 deletions
diff --git a/quantum/led_matrix.c b/quantum/led_matrix.c index 4f1f06c7a..ec8ff852d 100644 --- a/quantum/led_matrix.c +++ b/quantum/led_matrix.c | |||
| @@ -17,9 +17,6 @@ | |||
| 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 | */ | 18 | */ |
| 19 | 19 | ||
| 20 | #include <stdint.h> | ||
| 21 | #include <stdbool.h> | ||
| 22 | #include "quantum.h" | ||
| 23 | #include "led_matrix.h" | 20 | #include "led_matrix.h" |
| 24 | #include "progmem.h" | 21 | #include "progmem.h" |
| 25 | #include "config.h" | 22 | #include "config.h" |
| @@ -27,6 +24,8 @@ | |||
| 27 | #include <string.h> | 24 | #include <string.h> |
| 28 | #include <math.h> | 25 | #include <math.h> |
| 29 | 26 | ||
| 27 | #include <lib/lib8tion/lib8tion.h> | ||
| 28 | |||
| 30 | led_eeconfig_t led_matrix_eeconfig; | 29 | led_eeconfig_t led_matrix_eeconfig; |
| 31 | 30 | ||
| 32 | #ifndef MAX | 31 | #ifndef MAX |
| @@ -37,20 +36,41 @@ led_eeconfig_t led_matrix_eeconfig; | |||
| 37 | # define MIN(a, b) ((a) < (b) ? (a) : (b)) | 36 | # define MIN(a, b) ((a) < (b) ? (a) : (b)) |
| 38 | #endif | 37 | #endif |
| 39 | 38 | ||
| 40 | #ifndef LED_DISABLE_AFTER_TIMEOUT | 39 | #if defined(LED_DISABLE_AFTER_TIMEOUT) && !defined(LED_DISABLE_TIMEOUT) |
| 41 | # define LED_DISABLE_AFTER_TIMEOUT 0 | 40 | # define LED_DISABLE_TIMEOUT (LED_DISABLE_AFTER_TIMEOUT * 1200UL) |
| 41 | #endif | ||
| 42 | |||
| 43 | #ifndef LED_DISABLE_TIMEOUT | ||
| 44 | # define LED_DISABLE_TIMEOUT 0 | ||
| 42 | #endif | 45 | #endif |
| 43 | 46 | ||
| 44 | #ifndef LED_DISABLE_WHEN_USB_SUSPENDED | 47 | #ifndef LED_DISABLE_WHEN_USB_SUSPENDED |
| 45 | # define LED_DISABLE_WHEN_USB_SUSPENDED false | 48 | # define LED_DISABLE_WHEN_USB_SUSPENDED false |
| 46 | #endif | 49 | #endif |
| 47 | 50 | ||
| 48 | #ifndef EECONFIG_LED_MATRIX | 51 | #if !defined(LED_MATRIX_MAXIMUM_BRIGHTNESS) || LED_MATRIX_MAXIMUM_BRIGHTNESS > UINT8_MAX |
| 49 | # define EECONFIG_LED_MATRIX EECONFIG_RGBLIGHT | 52 | # undef LED_MATRIX_MAXIMUM_BRIGHTNESS |
| 53 | # define LED_MATRIX_MAXIMUM_BRIGHTNESS UINT8_MAX | ||
| 54 | #endif | ||
| 55 | |||
| 56 | #if !defined(LED_MATRIX_VAL_STEP) | ||
| 57 | # define LED_MATRIX_VAL_STEP 8 | ||
| 58 | #endif | ||
| 59 | |||
| 60 | #if !defined(LED_MATRIX_SPD_STEP) | ||
| 61 | # define LED_MATRIX_SPD_STEP 16 | ||
| 62 | #endif | ||
| 63 | |||
| 64 | #if !defined(LED_MATRIX_STARTUP_MODE) | ||
| 65 | # define LED_MATRIX_STARTUP_MODE LED_MATRIX_UNIFORM_BRIGHTNESS | ||
| 66 | #endif | ||
| 67 | |||
| 68 | #if !defined(LED_MATRIX_STARTUP_VAL) | ||
| 69 | # define LED_MATRIX_STARTUP_VAL LED_MATRIX_MAXIMUM_BRIGHTNESS | ||
| 50 | #endif | 70 | #endif |
| 51 | 71 | ||
| 52 | #if !defined(LED_MATRIX_MAXIMUM_BRIGHTNESS) || LED_MATRIX_MAXIMUM_BRIGHTNESS > 255 | 72 | #if !defined(LED_MATRIX_STARTUP_SPD) |
| 53 | # define LED_MATRIX_MAXIMUM_BRIGHTNESS 255 | 73 | # define LED_MATRIX_STARTUP_SPD UINT8_MAX / 2 |
| 54 | #endif | 74 | #endif |
| 55 | 75 | ||
| 56 | bool g_suspend_state = false; | 76 | bool g_suspend_state = false; |
| @@ -64,21 +84,21 @@ uint8_t g_key_hit[DRIVER_LED_TOTAL]; | |||
| 64 | // Ticks since any key was last hit. | 84 | // Ticks since any key was last hit. |
| 65 | uint32_t g_any_key_hit = 0; | 85 | uint32_t g_any_key_hit = 0; |
| 66 | 86 | ||
| 67 | uint32_t eeconfig_read_led_matrix(void) { return eeprom_read_dword(EECONFIG_LED_MATRIX); } | 87 | void eeconfig_read_led_matrix(void) { eeprom_read_block(&led_matrix_eeconfig, EECONFIG_LED_MATRIX, sizeof(led_matrix_eeconfig)); } |
| 68 | 88 | ||
| 69 | void eeconfig_update_led_matrix(uint32_t config_value) { eeprom_update_dword(EECONFIG_LED_MATRIX, config_value); } | 89 | void eeconfig_update_led_matrix(void) { eeprom_update_block(&led_matrix_eeconfig, EECONFIG_LED_MATRIX, sizeof(led_matrix_eeconfig)); } |
| 70 | 90 | ||
| 71 | void eeconfig_update_led_matrix_default(void) { | 91 | void eeconfig_update_led_matrix_default(void) { |
| 72 | dprintf("eeconfig_update_led_matrix_default\n"); | 92 | dprintf("eeconfig_update_led_matrix_default\n"); |
| 73 | led_matrix_eeconfig.enable = 1; | 93 | led_matrix_eeconfig.enable = 1; |
| 74 | led_matrix_eeconfig.mode = LED_MATRIX_UNIFORM_BRIGHTNESS; | 94 | led_matrix_eeconfig.mode = LED_MATRIX_STARTUP_MODE; |
| 75 | led_matrix_eeconfig.val = 128; | 95 | led_matrix_eeconfig.val = LED_MATRIX_STARTUP_VAL; |
| 76 | led_matrix_eeconfig.speed = 0; | 96 | led_matrix_eeconfig.speed = LED_MATRIX_STARTUP_SPD; |
| 77 | eeconfig_update_led_matrix(led_matrix_eeconfig.raw); | 97 | eeconfig_update_led_matrix(); |
| 78 | } | 98 | } |
| 79 | 99 | ||
| 80 | void eeconfig_debug_led_matrix(void) { | 100 | void eeconfig_debug_led_matrix(void) { |
| 81 | dprintf("led_matrix_eeconfig eeprom\n"); | 101 | dprintf("led_matrix_eeconfig EEPROM\n"); |
| 82 | dprintf("led_matrix_eeconfig.enable = %d\n", led_matrix_eeconfig.enable); | 102 | dprintf("led_matrix_eeconfig.enable = %d\n", led_matrix_eeconfig.enable); |
| 83 | dprintf("led_matrix_eeconfig.mode = %d\n", led_matrix_eeconfig.mode); | 103 | dprintf("led_matrix_eeconfig.mode = %d\n", led_matrix_eeconfig.mode); |
| 84 | dprintf("led_matrix_eeconfig.val = %d\n", led_matrix_eeconfig.val); | 104 | dprintf("led_matrix_eeconfig.val = %d\n", led_matrix_eeconfig.val); |
| @@ -135,7 +155,7 @@ void led_matrix_set_suspend_state(bool state) { g_suspend_state = state; } | |||
| 135 | void led_matrix_all_off(void) { led_matrix_set_index_value_all(0); } | 155 | void led_matrix_all_off(void) { led_matrix_set_index_value_all(0); } |
| 136 | 156 | ||
| 137 | // Uniform brightness | 157 | // Uniform brightness |
| 138 | void led_matrix_uniform_brightness(void) { led_matrix_set_index_value_all(LED_MATRIX_MAXIMUM_BRIGHTNESS / BACKLIGHT_LEVELS * led_matrix_eeconfig.val); } | 158 | void led_matrix_uniform_brightness(void) { led_matrix_set_index_value_all(led_matrix_eeconfig.val); } |
| 139 | 159 | ||
| 140 | void led_matrix_custom(void) {} | 160 | void led_matrix_custom(void) {} |
| 141 | 161 | ||
| @@ -161,7 +181,7 @@ void led_matrix_task(void) { | |||
| 161 | 181 | ||
| 162 | // Ideally we would also stop sending zeros to the LED driver PWM buffers | 182 | // Ideally we would also stop sending zeros to the LED driver PWM buffers |
| 163 | // while suspended and just do a software shutdown. This is a cheap hack for now. | 183 | // while suspended and just do a software shutdown. This is a cheap hack for now. |
| 164 | bool suspend_backlight = ((g_suspend_state && LED_DISABLE_WHEN_USB_SUSPENDED) || (LED_DISABLE_AFTER_TIMEOUT > 0 && g_any_key_hit > LED_DISABLE_AFTER_TIMEOUT * 60 * 20)); | 184 | bool suspend_backlight = ((g_suspend_state && LED_DISABLE_WHEN_USB_SUSPENDED) || (LED_DISABLE_TIMEOUT > 0 && g_any_key_hit > LED_DISABLE_TIMEOUT)); |
| 165 | uint8_t effect = suspend_backlight ? 0 : led_matrix_eeconfig.mode; | 185 | uint8_t effect = suspend_backlight ? 0 : led_matrix_eeconfig.mode; |
| 166 | 186 | ||
| 167 | // this gets ticked at 20 Hz. | 187 | // this gets ticked at 20 Hz. |
| @@ -193,23 +213,6 @@ __attribute__((weak)) void led_matrix_indicators_kb(void) {} | |||
| 193 | 213 | ||
| 194 | __attribute__((weak)) void led_matrix_indicators_user(void) {} | 214 | __attribute__((weak)) void led_matrix_indicators_user(void) {} |
| 195 | 215 | ||
| 196 | // void led_matrix_set_indicator_index(uint8_t *index, uint8_t row, uint8_t column) | ||
| 197 | // { | ||
| 198 | // if (row >= MATRIX_ROWS) | ||
| 199 | // { | ||
| 200 | // // Special value, 255=none, 254=all | ||
| 201 | // *index = row; | ||
| 202 | // } | ||
| 203 | // else | ||
| 204 | // { | ||
| 205 | // // This needs updated to something like | ||
| 206 | // // uint8_t led[8]; | ||
| 207 | // // uint8_t led_count = map_row_column_to_led(row, column, led); | ||
| 208 | // // for(uint8_t i = 0; i < led_count; i++) | ||
| 209 | // map_row_column_to_led(row, column, index); | ||
| 210 | // } | ||
| 211 | // } | ||
| 212 | |||
| 213 | void led_matrix_init(void) { | 216 | void led_matrix_init(void) { |
| 214 | led_matrix_driver.init(); | 217 | led_matrix_driver.init(); |
| 215 | 218 | ||
| @@ -227,122 +230,117 @@ void led_matrix_init(void) { | |||
| 227 | eeconfig_update_led_matrix_default(); | 230 | eeconfig_update_led_matrix_default(); |
| 228 | } | 231 | } |
| 229 | 232 | ||
| 230 | led_matrix_eeconfig.raw = eeconfig_read_led_matrix(); | 233 | eeconfig_read_led_matrix(); |
| 231 | |||
| 232 | if (!led_matrix_eeconfig.mode) { | 234 | if (!led_matrix_eeconfig.mode) { |
| 233 | dprintf("led_matrix_init_drivers led_matrix_eeconfig.mode = 0. Write default values to EEPROM.\n"); | 235 | dprintf("led_matrix_init_drivers led_matrix_eeconfig.mode = 0. Write default values to EEPROM.\n"); |
| 234 | eeconfig_update_led_matrix_default(); | 236 | eeconfig_update_led_matrix_default(); |
| 235 | led_matrix_eeconfig.raw = eeconfig_read_led_matrix(); | ||
| 236 | } | 237 | } |
| 237 | 238 | ||
| 238 | eeconfig_debug_led_matrix(); // display current eeprom values | 239 | eeconfig_debug_led_matrix(); // display current eeprom values |
| 239 | } | 240 | } |
| 240 | 241 | ||
| 241 | // Deals with the messy details of incrementing an integer | ||
| 242 | static uint8_t increment(uint8_t value, uint8_t step, uint8_t min, uint8_t max) { | ||
| 243 | int16_t new_value = value; | ||
| 244 | new_value += step; | ||
| 245 | return MIN(MAX(new_value, min), max); | ||
| 246 | } | ||
| 247 | |||
| 248 | static uint8_t decrement(uint8_t value, uint8_t step, uint8_t min, uint8_t max) { | ||
| 249 | int16_t new_value = value; | ||
| 250 | new_value -= step; | ||
| 251 | return MIN(MAX(new_value, min), max); | ||
| 252 | } | ||
| 253 | |||
| 254 | // void *backlight_get_custom_key_value_eeprom_address(uint8_t led) { | ||
| 255 | // // 3 bytes per value | ||
| 256 | // return EECONFIG_LED_MATRIX + (led * 3); | ||
| 257 | // } | ||
| 258 | |||
| 259 | // void backlight_get_key_value(uint8_t led, uint8_t *value) { | ||
| 260 | // void *address = backlight_get_custom_key_value_eeprom_address(led); | ||
| 261 | // value = eeprom_read_byte(address); | ||
| 262 | // } | ||
| 263 | |||
| 264 | // void backlight_set_key_value(uint8_t row, uint8_t column, uint8_t value) { | ||
| 265 | // uint8_t led[8]; | ||
| 266 | // uint8_t led_count = map_row_column_to_led(row, column, led); | ||
| 267 | // for(uint8_t i = 0; i < led_count; i++) { | ||
| 268 | // if (led[i] < DRIVER_LED_TOTAL) { | ||
| 269 | // void *address = backlight_get_custom_key_value_eeprom_address(led[i]); | ||
| 270 | // eeprom_update_byte(address, value); | ||
| 271 | // } | ||
| 272 | // } | ||
| 273 | // } | ||
| 274 | |||
| 275 | uint32_t led_matrix_get_tick(void) { return g_tick; } | 242 | uint32_t led_matrix_get_tick(void) { return g_tick; } |
| 276 | 243 | ||
| 277 | void led_matrix_toggle(void) { | 244 | void led_matrix_toggle_eeprom_helper(bool write_to_eeprom) { |
| 278 | led_matrix_eeconfig.enable ^= 1; | 245 | led_matrix_eeconfig.enable ^= 1; |
| 279 | eeconfig_update_led_matrix(led_matrix_eeconfig.raw); | 246 | if (write_to_eeprom) { |
| 247 | eeconfig_update_led_matrix(); | ||
| 248 | } | ||
| 249 | dprintf("led matrix toggle [%s]: led_matrix_eeconfig.enable = %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", led_matrix_eeconfig.enable); | ||
| 280 | } | 250 | } |
| 251 | void led_matrix_toggle_noeeprom(void) { led_matrix_toggle_eeprom_helper(false); } | ||
| 252 | void led_matrix_toggle(void) { led_matrix_toggle_eeprom_helper(true); } | ||
| 281 | 253 | ||
| 282 | void led_matrix_enable(void) { | 254 | void led_matrix_enable(void) { |
| 283 | led_matrix_eeconfig.enable = 1; | 255 | led_matrix_enable_noeeprom(); |
| 284 | eeconfig_update_led_matrix(led_matrix_eeconfig.raw); | 256 | eeconfig_update_led_matrix(); |
| 285 | } | 257 | } |
| 286 | 258 | ||
| 287 | void led_matrix_enable_noeeprom(void) { led_matrix_eeconfig.enable = 1; } | 259 | void led_matrix_enable_noeeprom(void) { led_matrix_eeconfig.enable = 1; } |
| 288 | 260 | ||
| 289 | void led_matrix_disable(void) { | 261 | void led_matrix_disable(void) { |
| 290 | led_matrix_eeconfig.enable = 0; | 262 | led_matrix_disable_noeeprom(); |
| 291 | eeconfig_update_led_matrix(led_matrix_eeconfig.raw); | 263 | eeconfig_update_led_matrix(); |
| 292 | } | 264 | } |
| 293 | 265 | ||
| 294 | void led_matrix_disable_noeeprom(void) { led_matrix_eeconfig.enable = 0; } | 266 | void led_matrix_disable_noeeprom(void) { led_matrix_eeconfig.enable = 0; } |
| 295 | 267 | ||
| 296 | void led_matrix_step(void) { | 268 | uint8_t led_matrix_is_enabled(void) { return led_matrix_eeconfig.enable; } |
| 297 | led_matrix_eeconfig.mode++; | ||
| 298 | if (led_matrix_eeconfig.mode >= LED_MATRIX_EFFECT_MAX) { | ||
| 299 | led_matrix_eeconfig.mode = 1; | ||
| 300 | } | ||
| 301 | eeconfig_update_led_matrix(led_matrix_eeconfig.raw); | ||
| 302 | } | ||
| 303 | 269 | ||
| 304 | void led_matrix_step_reverse(void) { | 270 | void led_matrix_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom) { |
| 305 | led_matrix_eeconfig.mode--; | 271 | if (!led_matrix_eeconfig.enable) { |
| 306 | if (led_matrix_eeconfig.mode < 1) { | 272 | return; |
| 273 | } | ||
| 274 | if (mode < 1) { | ||
| 275 | led_matrix_eeconfig.mode = 1; | ||
| 276 | } else if (mode >= LED_MATRIX_EFFECT_MAX) { | ||
| 307 | led_matrix_eeconfig.mode = LED_MATRIX_EFFECT_MAX - 1; | 277 | led_matrix_eeconfig.mode = LED_MATRIX_EFFECT_MAX - 1; |
| 278 | } else { | ||
| 279 | led_matrix_eeconfig.mode = mode; | ||
| 308 | } | 280 | } |
| 309 | eeconfig_update_led_matrix(led_matrix_eeconfig.raw); | 281 | if (write_to_eeprom) { |
| 310 | } | 282 | eeconfig_update_led_matrix(); |
| 311 | 283 | } | |
| 312 | void led_matrix_increase_val(void) { | 284 | dprintf("led matrix mode [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", led_matrix_eeconfig.mode); |
| 313 | led_matrix_eeconfig.val = increment(led_matrix_eeconfig.val, 8, 0, LED_MATRIX_MAXIMUM_BRIGHTNESS); | ||
| 314 | eeconfig_update_led_matrix(led_matrix_eeconfig.raw); | ||
| 315 | } | 285 | } |
| 286 | void led_matrix_mode_noeeprom(uint8_t mode) { led_matrix_mode_eeprom_helper(mode, false); } | ||
| 287 | void led_matrix_mode(uint8_t mode) { led_matrix_mode_eeprom_helper(mode, true); } | ||
| 316 | 288 | ||
| 317 | void led_matrix_decrease_val(void) { | 289 | uint8_t led_matrix_get_mode(void) { return led_matrix_eeconfig.mode; } |
| 318 | led_matrix_eeconfig.val = decrement(led_matrix_eeconfig.val, 8, 0, LED_MATRIX_MAXIMUM_BRIGHTNESS); | ||
| 319 | eeconfig_update_led_matrix(led_matrix_eeconfig.raw); | ||
| 320 | } | ||
| 321 | 290 | ||
| 322 | void led_matrix_increase_speed(void) { | 291 | void led_matrix_step_helper(bool write_to_eeprom) { |
| 323 | led_matrix_eeconfig.speed = increment(led_matrix_eeconfig.speed, 1, 0, 3); | 292 | uint8_t mode = led_matrix_eeconfig.mode + 1; |
| 324 | eeconfig_update_led_matrix(led_matrix_eeconfig.raw); // EECONFIG needs to be increased to support this | 293 | led_matrix_mode_eeprom_helper((mode < LED_MATRIX_EFFECT_MAX) ? mode : 1, write_to_eeprom); |
| 325 | } | 294 | } |
| 295 | void led_matrix_step_noeeprom(void) { led_matrix_step_helper(false); } | ||
| 296 | void led_matrix_step(void) { led_matrix_step_helper(true); } | ||
| 326 | 297 | ||
| 327 | void led_matrix_decrease_speed(void) { | 298 | void led_matrix_step_reverse_helper(bool write_to_eeprom) { |
| 328 | led_matrix_eeconfig.speed = decrement(led_matrix_eeconfig.speed, 1, 0, 3); | 299 | uint8_t mode = led_matrix_eeconfig.mode - 1; |
| 329 | eeconfig_update_led_matrix(led_matrix_eeconfig.raw); // EECONFIG needs to be increased to support this | 300 | led_matrix_mode_eeprom_helper((mode < 1) ? LED_MATRIX_EFFECT_MAX - 1 : mode, write_to_eeprom); |
| 330 | } | 301 | } |
| 302 | void led_matrix_step_reverse_noeeprom(void) { led_matrix_step_reverse_helper(false); } | ||
| 303 | void led_matrix_step_reverse(void) { led_matrix_step_reverse_helper(true); } | ||
| 331 | 304 | ||
| 332 | void led_matrix_mode(uint8_t mode, bool eeprom_write) { | 305 | void led_matrix_set_val_eeprom_helper(uint8_t val, bool write_to_eeprom) { |
| 333 | led_matrix_eeconfig.mode = mode; | 306 | if (!led_matrix_eeconfig.enable) { |
| 334 | if (eeprom_write) { | 307 | return; |
| 335 | eeconfig_update_led_matrix(led_matrix_eeconfig.raw); | 308 | } |
| 309 | led_matrix_eeconfig.val = (val > LED_MATRIX_MAXIMUM_BRIGHTNESS) ? LED_MATRIX_MAXIMUM_BRIGHTNESS : val; | ||
| 310 | if (write_to_eeprom) { | ||
| 311 | eeconfig_update_led_matrix(); | ||
| 336 | } | 312 | } |
| 313 | dprintf("led matrix set val [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", led_matrix_eeconfig.val); | ||
| 337 | } | 314 | } |
| 315 | void led_matrix_set_val_noeeprom(uint8_t val) { led_matrix_set_val_eeprom_helper(val, false); } | ||
| 316 | void led_matrix_set_val(uint8_t val) { led_matrix_set_val_eeprom_helper(val, true); } | ||
| 338 | 317 | ||
| 339 | uint8_t led_matrix_get_mode(void) { return led_matrix_eeconfig.mode; } | 318 | uint8_t led_matrix_get_val(void) { return led_matrix_eeconfig.val; } |
| 319 | |||
| 320 | void led_matrix_increase_val_helper(bool write_to_eeprom) { led_matrix_set_val_eeprom_helper(qadd8(led_matrix_eeconfig.val, LED_MATRIX_VAL_STEP), write_to_eeprom); } | ||
| 321 | void led_matrix_increase_val_noeeprom(void) { led_matrix_increase_val_helper(false); } | ||
| 322 | void led_matrix_increase_val(void) { led_matrix_increase_val_helper(true); } | ||
| 340 | 323 | ||
| 341 | void led_matrix_set_value_noeeprom(uint8_t val) { led_matrix_eeconfig.val = val; } | 324 | void led_matrix_decrease_val_helper(bool write_to_eeprom) { led_matrix_set_val_eeprom_helper(qsub8(led_matrix_eeconfig.val, LED_MATRIX_VAL_STEP), write_to_eeprom); } |
| 325 | void led_matrix_decrease_val_noeeprom(void) { led_matrix_decrease_val_helper(false); } | ||
| 326 | void led_matrix_decrease_val(void) { led_matrix_decrease_val_helper(true); } | ||
| 342 | 327 | ||
| 343 | void led_matrix_set_value(uint8_t val) { | 328 | void led_matrix_set_speed_eeprom_helper(uint8_t speed, bool write_to_eeprom) { |
| 344 | led_matrix_set_value_noeeprom(val); | 329 | led_matrix_eeconfig.speed = speed; |
| 345 | eeconfig_update_led_matrix(led_matrix_eeconfig.raw); | 330 | if (write_to_eeprom) { |
| 331 | eeconfig_update_led_matrix(); | ||
| 332 | } | ||
| 333 | dprintf("led matrix set speed [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", led_matrix_eeconfig.speed); | ||
| 346 | } | 334 | } |
| 335 | void led_matrix_set_speed_noeeprom(uint8_t speed) { led_matrix_set_speed_eeprom_helper(speed, false); } | ||
| 336 | void led_matrix_set_speed(uint8_t speed) { led_matrix_set_speed_eeprom_helper(speed, true); } | ||
| 337 | |||
| 338 | uint8_t led_matrix_get_speed(void) { return led_matrix_eeconfig.speed; } | ||
| 339 | |||
| 340 | void led_matrix_increase_speed_helper(bool write_to_eeprom) { led_matrix_set_speed_eeprom_helper(qadd8(led_matrix_eeconfig.speed, LED_MATRIX_SPD_STEP), write_to_eeprom); } | ||
| 341 | void led_matrix_increase_speed_noeeprom(void) { led_matrix_increase_speed_helper(false); } | ||
| 342 | void led_matrix_increase_speed(void) { led_matrix_increase_speed_helper(true); } | ||
| 347 | 343 | ||
| 348 | void backlight_set(uint8_t val) { led_matrix_set_value(val); } | 344 | void led_matrix_decrease_speed_helper(bool write_to_eeprom) { led_matrix_set_speed_eeprom_helper(qsub8(led_matrix_eeconfig.speed, LED_MATRIX_SPD_STEP), write_to_eeprom); } |
| 345 | void led_matrix_decrease_speed_noeeprom(void) { led_matrix_decrease_speed_helper(false); } | ||
| 346 | void led_matrix_decrease_speed(void) { led_matrix_decrease_speed_helper(true); } | ||
