diff --git a/keyboards/cheapino/cheapino.c b/keyboards/cheapino/cheapino.c new file mode 100644 index 0000000000..eb7c251f10 --- /dev/null +++ b/keyboards/cheapino/cheapino.c @@ -0,0 +1,75 @@ +#include "wait.h" +#include "quantum.h" + +// This is to keep state between callbacks, when it is 0 the +// initial RGB flash is finished +uint8_t _hue_countdown = 25; + +// These are to keep track of user selected color, so we +// can restore it after RGB flash +uint8_t _hue; +uint8_t _saturation; +uint8_t _value; + +// Do a little 2.5 seconds display of the different colors +// Use the deferred executor so the LED flash dance does not +// stop us from using the keyboard. +// https://docs.qmk.fm/#/custom_quantum_functions?id=deferred-executor-registration +uint32_t flash_led(uint32_t next_trigger_time, void *cb_arg) { + rgblight_sethsv(_hue_countdown * 10, 230, 70); + _hue_countdown--; + if (_hue_countdown == 0) { + // Finished, reset to user chosen led color + rgblight_sethsv(_hue, _saturation, _value); + return 0; + } else { + return 100; + } +} + +void keyboard_post_init_user(void) { + //debug_enable=true; + //debug_matrix=true; + //debug_keyboard=true; + //debug_mouse=true; + + // Store user selected rgb hsv: + _hue = rgblight_get_hue(); + _saturation = rgblight_get_sat(); + _value = rgblight_get_val(); + + // Flash a little on start + defer_exec(100, flash_led, NULL); +} + +// Make the builtin RGB led show different colors per layer: +// This seemed like a good idea but turned out pretty annoying, +// to me at least... Uncomment the lines below to enable +/* +uint8_t get_hue(uint8_t layer) { + switch (layer) { + case 6: + return 169; + case 5: + return 43; + case 4: + return 85; + case 3: + return 120; + case 2: + return 180; + case 1: + return 220; + default: + return 0; + } +} + +layer_state_t layer_state_set_user(layer_state_t state) { + uint8_t sat = rgblight_get_sat(); + uint8_t val = rgblight_get_val(); + uint8_t hue = get_hue(get_highest_layer(state)); + rgblight_sethsv(hue, sat, val); + return state; +} +*/ \ No newline at end of file diff --git a/keyboards/cheapino/config.h b/keyboards/cheapino/config.h index 7d64c39134..27ebeb8ebd 100644 --- a/keyboards/cheapino/config.h +++ b/keyboards/cheapino/config.h @@ -20,7 +20,6 @@ //#define NO_ACTION_ONESHOT #define BOTH_SHIFTS_TURNS_ON_CAPS_WORD -#define RGB_MATRIX_MAXIMUM_BRIGHTNESS 128 #define WS2812_PIO_USE_PIO1 // Force the usage of PIO1 peripheral, by default the WS2812 implementation uses the PIO0 peripheral //#define WS2812_TRST_US 80 #define WS2812_BYTE_ORDER WS2812_BYTE_ORDER_RGB @@ -34,10 +33,8 @@ #define TAPPING_FORCE_HOLD //#define RETRO_TAPPING -#ifdef RGB_MATRIX_ENABLE -// #define NOP_FUDGE 0.4 - #define RGB_DI_PIN GP16 // The pin connected to the data pin of the LEDs - #define RGB_MATRIX_LED_COUNT 1 // The number of LEDs connected - #define ENABLE_RGB_MATRIX_SINGLE_COLOR // Single hue brightness cycling animation - #define ENABLE_RGB_MATRIX_BREATHING -#endif + #define RGB_DI_PIN GP16 // The pin connected to the data pin of the LEDs + #define RGBLED_NUM 1 // The number of LEDs connected + + +#define MAX_DEFERRED_EXECUTORS 32 \ No newline at end of file diff --git a/keyboards/cheapino/info.json b/keyboards/cheapino/info.json index b54caa0572..333726d590 100644 --- a/keyboards/cheapino/info.json +++ b/keyboards/cheapino/info.json @@ -10,8 +10,7 @@ "console": true, "extrakey": true, "mousekey": true, - "nkro": false, - "rgb_matrix": true + "nkro": false }, "matrix_pins": { "cols": ["GP0", "GP0", "GP1", "GP1", "GP2", "GP2", "GP29", "GP29", "GP28", "GP28", "GP27", "GP27"], @@ -24,11 +23,6 @@ "pid": "0x0000", "vid": "0xFEED" }, - "rgb_matrix": { - "driver": "WS2812", - "layout": [ - { "flags": 4, "matrix": [0, 0] , "x": 4 , "y": 0.25 } - ]}, "layouts": { "LAYOUT_split_3x5_3": { "layout": [ diff --git a/keyboards/cheapino/matrix.c b/keyboards/cheapino/matrix.c index d4aa8ee247..74f3493c6a 100644 --- a/keyboards/cheapino/matrix.c +++ b/keyboards/cheapino/matrix.c @@ -33,14 +33,6 @@ static const pin_t row_pins[] = MATRIX_ROW_PINS; static const pin_t col_pins[] = MATRIX_COL_PINS; static matrix_row_t previous_matrix[MATRIX_ROWS]; -void keyboard_post_init_user(void) { - // Customise these values to desired behaviour - debug_enable=true; - debug_matrix=true; - debug_keyboard=true; - //debug_mouse=true; -} - static void select_row(uint8_t row) { setPinOutput(row_pins[row]); writePinLow(row_pins[row]); @@ -150,3 +142,4 @@ bool matrix_scan_custom(matrix_row_t current_matrix[]) { return has_matrix_changed(current_matrix); } + diff --git a/keyboards/cheapino/rules.mk b/keyboards/cheapino/rules.mk index 517fcd02af..3123102472 100644 --- a/keyboards/cheapino/rules.mk +++ b/keyboards/cheapino/rules.mk @@ -1,5 +1,7 @@ CAPS_WORD_ENABLE = yes CUSTOM_MATRIX = lite WS2812_DRIVER = vendor +RGBLIGHT_ENABLE = yes +DEFERRED_EXEC_ENABLE = yes SRC += encoder.c SRC += matrix.c \ No newline at end of file