From a056a1748c54ca9bfbb1161066126885a6a1a236 Mon Sep 17 00:00:00 2001 From: Stanislav Date: Fri, 12 Apr 2024 13:27:16 +0300 Subject: [PATCH] some updates, move code in rp2040.c --- keyboards/handwired/set_st/rp2040/config.h | 2 +- keyboards/handwired/set_st/rp2040/halconf.h | 2 +- .../set_st/rp2040/keymaps/default/keymap.c | 101 --------------- .../set_st/rp2040/keymaps/via/keymap.c | 103 +-------------- keyboards/handwired/set_st/rp2040/mcuconf.h | 2 +- keyboards/handwired/set_st/rp2040/rp2040.c | 117 ++++++++++++++++++ 6 files changed, 121 insertions(+), 206 deletions(-) create mode 100644 keyboards/handwired/set_st/rp2040/rp2040.c diff --git a/keyboards/handwired/set_st/rp2040/config.h b/keyboards/handwired/set_st/rp2040/config.h index b9beddeacb4..62639f649f8 100644 --- a/keyboards/handwired/set_st/rp2040/config.h +++ b/keyboards/handwired/set_st/rp2040/config.h @@ -1,4 +1,4 @@ -/* Copyright 2022 Jose Pablo Ramirez +/* Copyright 2024 set_st * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/keyboards/handwired/set_st/rp2040/halconf.h b/keyboards/handwired/set_st/rp2040/halconf.h index b0eaceeb8be..0e14afb52e2 100644 --- a/keyboards/handwired/set_st/rp2040/halconf.h +++ b/keyboards/handwired/set_st/rp2040/halconf.h @@ -1,4 +1,4 @@ -/* Copyright 2022 Jose Pablo Ramirez +/* Copyright 2024 set_st * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/keyboards/handwired/set_st/rp2040/keymaps/default/keymap.c b/keyboards/handwired/set_st/rp2040/keymaps/default/keymap.c index a744de16686..900a910393e 100644 --- a/keyboards/handwired/set_st/rp2040/keymaps/default/keymap.c +++ b/keyboards/handwired/set_st/rp2040/keymaps/default/keymap.c @@ -66,104 +66,3 @@ const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = { [LIGHT] = { ENCODER_CCW_CW(_______, _______) } }; #endif - - -#ifdef OLED_ENABLE - -bool oled_task_user(void) { - // Set cursor position - oled_set_cursor(0, 0); - // Switch on current active layer - switch (get_highest_layer(layer_state)) { - case BASE : - oled_write_ln_P("1:Base", false); - break; - case FN : - oled_write_ln_P("2:Functions", false); - break; - case MEDIA : - oled_write_ln_P("3:Media", false); - break; - case LIGHT : - oled_write_ln_P("4:Lights controll", false); - break; - } - - - oled_set_cursor(0, 1); - oled_write(PSTR("Keys: "), false); - - os_variant_t os = detected_host_os(); - switch (os){ - case OS_MACOS: - oled_write("MAC", false); - break; - case OS_LINUX: - oled_write("LIN", false); - break; - case OS_WINDOWS: - oled_write("WIN", false); - break; - default: - break; - } - oled_write_ln("", false); - - for (int i = 0; i < MATRIX_ROWS; i++) { - for (int j = 0; j < MATRIX_COLS; j++) { - uint16_t keycode = keymaps[get_highest_layer(layer_state)][i][j]; - if(keycode == KC_NO || keycode == KC_TRANSPARENT){ - oled_write(" ", false); - } - else{ - oled_write("(", false); - if (KEYCODE2CONSUMER(keycode)) { - oled_write("M", false); - } - else if (IS_ANY(keycode)) - { - oled_write("A", false); - } - else{ - oled_write("D", false); - } - oled_write(") ", false); - } - } - oled_write_ln("", false); - } - - return false; -} - -bool process_record_user(uint16_t keycode, keyrecord_t *record) { - switch (keycode) { - case KC_CYCLE_LAYERS: - if (!record->event.pressed) { - return false; - } - - uint8_t current_layer = get_highest_layer(layer_state); - if (current_layer > LAYER_CYCLE_END || current_layer < LAYER_CYCLE_START) { - return false; - } - - uint8_t next_layer = current_layer + 1; - if (next_layer >= LAYER_CYCLE_END) { - next_layer = LAYER_CYCLE_START; - } - layer_move(next_layer); - return false; - default: - oled_clear(); - oled_set_cursor(0, 6); - oled_write("Keycode: ", false); - char keycode_str[6]; - itoa(keycode, keycode_str, 10); - oled_write(keycode_str, false); - oled_write_ln("", false); - return true; - } -} - -#endif diff --git a/keyboards/handwired/set_st/rp2040/keymaps/via/keymap.c b/keyboards/handwired/set_st/rp2040/keymaps/via/keymap.c index a744de16686..fcf3373fdcf 100644 --- a/keyboards/handwired/set_st/rp2040/keymaps/via/keymap.c +++ b/keyboards/handwired/set_st/rp2040/keymaps/via/keymap.c @@ -65,105 +65,4 @@ const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = { [MEDIA] = { ENCODER_CCW_CW(_______, _______) }, [LIGHT] = { ENCODER_CCW_CW(_______, _______) } }; -#endif - - -#ifdef OLED_ENABLE - -bool oled_task_user(void) { - // Set cursor position - oled_set_cursor(0, 0); - // Switch on current active layer - switch (get_highest_layer(layer_state)) { - case BASE : - oled_write_ln_P("1:Base", false); - break; - case FN : - oled_write_ln_P("2:Functions", false); - break; - case MEDIA : - oled_write_ln_P("3:Media", false); - break; - case LIGHT : - oled_write_ln_P("4:Lights controll", false); - break; - } - - - oled_set_cursor(0, 1); - oled_write(PSTR("Keys: "), false); - - os_variant_t os = detected_host_os(); - switch (os){ - case OS_MACOS: - oled_write("MAC", false); - break; - case OS_LINUX: - oled_write("LIN", false); - break; - case OS_WINDOWS: - oled_write("WIN", false); - break; - default: - break; - } - oled_write_ln("", false); - - for (int i = 0; i < MATRIX_ROWS; i++) { - for (int j = 0; j < MATRIX_COLS; j++) { - uint16_t keycode = keymaps[get_highest_layer(layer_state)][i][j]; - if(keycode == KC_NO || keycode == KC_TRANSPARENT){ - oled_write(" ", false); - } - else{ - oled_write("(", false); - if (KEYCODE2CONSUMER(keycode)) { - oled_write("M", false); - } - else if (IS_ANY(keycode)) - { - oled_write("A", false); - } - else{ - oled_write("D", false); - } - oled_write(") ", false); - } - } - oled_write_ln("", false); - } - - return false; -} - -bool process_record_user(uint16_t keycode, keyrecord_t *record) { - switch (keycode) { - case KC_CYCLE_LAYERS: - if (!record->event.pressed) { - return false; - } - - uint8_t current_layer = get_highest_layer(layer_state); - if (current_layer > LAYER_CYCLE_END || current_layer < LAYER_CYCLE_START) { - return false; - } - - uint8_t next_layer = current_layer + 1; - if (next_layer >= LAYER_CYCLE_END) { - next_layer = LAYER_CYCLE_START; - } - layer_move(next_layer); - return false; - default: - oled_clear(); - oled_set_cursor(0, 6); - oled_write("Keycode: ", false); - char keycode_str[6]; - itoa(keycode, keycode_str, 10); - oled_write(keycode_str, false); - oled_write_ln("", false); - return true; - } -} - -#endif +#endif \ No newline at end of file diff --git a/keyboards/handwired/set_st/rp2040/mcuconf.h b/keyboards/handwired/set_st/rp2040/mcuconf.h index aae1fb04657..6469029f2e2 100644 --- a/keyboards/handwired/set_st/rp2040/mcuconf.h +++ b/keyboards/handwired/set_st/rp2040/mcuconf.h @@ -1,4 +1,4 @@ -/* Copyright 2022 Jose Pablo Ramirez +/* Copyright 2024 set_st * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/keyboards/handwired/set_st/rp2040/rp2040.c b/keyboards/handwired/set_st/rp2040/rp2040.c new file mode 100644 index 00000000000..915da28484e --- /dev/null +++ b/keyboards/handwired/set_st/rp2040/rp2040.c @@ -0,0 +1,117 @@ +/* Copyright 2024 set_st + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "quantum.h" + +#ifdef OLED_ENABLE + +bool oled_task_user(void) { + // Set cursor position + oled_set_cursor(0, 0); + // Switch on current active layer + switch (get_highest_layer(layer_state)) { + case BASE : + oled_write_ln_P("1:Base", false); + break; + case FN : + oled_write_ln_P("2:Functions", false); + break; + case MEDIA : + oled_write_ln_P("3:Media", false); + break; + case LIGHT : + oled_write_ln_P("4:Lights controll", false); + break; + } + + + oled_set_cursor(0, 1); + oled_write(PSTR("Keys: "), false); + + os_variant_t os = detected_host_os(); + switch (os){ + case OS_MACOS: + oled_write("MAC", false); + break; + case OS_LINUX: + oled_write("LIN", false); + break; + case OS_WINDOWS: + oled_write("WIN", false); + break; + default: + break; + } + oled_write_ln("", false); + + for (int i = 0; i < MATRIX_ROWS; i++) { + for (int j = 0; j < MATRIX_COLS; j++) { + uint16_t keycode = keymaps[get_highest_layer(layer_state)][i][j]; + if(keycode == KC_NO || keycode == KC_TRANSPARENT){ + oled_write(" ", false); + } + else{ + oled_write("(", false); + if (KEYCODE2CONSUMER(keycode)) { + oled_write("M", false); + } + else if (IS_ANY(keycode)) + { + oled_write("A", false); + } + else{ + oled_write("D", false); + } + oled_write(") ", false); + } + } + oled_write_ln("", false); + } + + return false; +} + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + case KC_CYCLE_LAYERS: + if (!record->event.pressed) { + return false; + } + + uint8_t current_layer = get_highest_layer(layer_state); + if (current_layer > LAYER_CYCLE_END || current_layer < LAYER_CYCLE_START) { + return false; + } + + uint8_t next_layer = current_layer + 1; + if (next_layer >= LAYER_CYCLE_END) { + next_layer = LAYER_CYCLE_START; + } + layer_move(next_layer); + return false; + default: + oled_clear(); + oled_set_cursor(0, 6); + oled_write("Keycode: ", false); + char keycode_str[6]; + itoa(keycode, keycode_str, 10); + oled_write(keycode_str, false); + oled_write_ln("", false); + return true; + } +} + +#endif