From 71b58e22eebff674e03145bc2c0f9dabe68157c2 Mon Sep 17 00:00:00 2001 From: Vaarai Date: Wed, 2 Oct 2024 21:12:29 +0200 Subject: [PATCH] [Cornia] Move I2C stuff to keyboard level --- .../fire/oled_routines.h => cornia.c} | 14 +++-- keyboards/cornia/cornia.h | 21 +++++++ keyboards/cornia/keymaps/fire/callback_oled.c | 29 +++++++-- .../cornia/keymaps/fire/callback_system.c | 10 +++- keyboards/cornia/keymaps/fire/config.h | 5 -- keyboards/cornia/keymaps/fire/oled_routines.c | 59 ------------------- keyboards/cornia/keymaps/fire/rules.mk | 4 -- keyboards/cornia/v0_6/config.h | 5 ++ .../cornia/{keymaps/fire => v0_6}/mcuconf.h | 0 keyboards/cornia/v0_6/rules.mk | 17 ++++++ keyboards/cornia/v1/config.h | 5 ++ keyboards/cornia/v1/mcuconf.h | 25 ++++++++ keyboards/cornia/v1/rules.mk | 17 ++++++ 13 files changed, 131 insertions(+), 80 deletions(-) rename keyboards/cornia/{keymaps/fire/oled_routines.h => cornia.c} (89%) create mode 100644 keyboards/cornia/cornia.h delete mode 100644 keyboards/cornia/keymaps/fire/oled_routines.c rename keyboards/cornia/{keymaps/fire => v0_6}/mcuconf.h (100%) create mode 100644 keyboards/cornia/v0_6/rules.mk create mode 100644 keyboards/cornia/v1/mcuconf.h create mode 100644 keyboards/cornia/v1/rules.mk diff --git a/keyboards/cornia/keymaps/fire/oled_routines.h b/keyboards/cornia/cornia.c similarity index 89% rename from keyboards/cornia/keymaps/fire/oled_routines.h rename to keyboards/cornia/cornia.c index 1180a000adf..3d8d90cf292 100644 --- a/keyboards/cornia/keymaps/fire/oled_routines.h +++ b/keyboards/cornia/cornia.c @@ -14,10 +14,9 @@ * along with this program. If not, see . */ -#pragma once - #include QMK_KEYBOARD_H -#include "./keymap.h" + +#include "./cornia.h" // 'Cornia', 32x32px #define OLED_LOGO_CORNIA {\ @@ -31,6 +30,9 @@ 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x0e, 0x00 \ } -void render_logo(void); -void render_layer_status(void); -void render_boot(bool bootloader); +void cornia_render_logo(void) { +#ifdef OLED_ENABLE + static const char PROGMEM logo[] = OLED_LOGO_CORNIA; + oled_write_raw_P(logo, sizeof(logo)); +#endif +} diff --git a/keyboards/cornia/cornia.h b/keyboards/cornia/cornia.h new file mode 100644 index 00000000000..264ddd63930 --- /dev/null +++ b/keyboards/cornia/cornia.h @@ -0,0 +1,21 @@ +/* Copyright 2024 Vaarai + * + * 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 . + */ + +#pragma once + +#include QMK_KEYBOARD_H + +void cornia_render_logo(void); diff --git a/keyboards/cornia/keymaps/fire/callback_oled.c b/keyboards/cornia/keymaps/fire/callback_oled.c index b8f292ea70d..2c3422477b3 100644 --- a/keyboards/cornia/keymaps/fire/callback_oled.c +++ b/keyboards/cornia/keymaps/fire/callback_oled.c @@ -17,16 +17,37 @@ #include QMK_KEYBOARD_H #include "./keymap.h" -#include "./oled_routines.h" +#include "./cornia.h" oled_rotation_t oled_init_user(oled_rotation_t rotation) { return OLED_ROTATION_270; } bool oled_task_user(void) { - oled_set_cursor(0, 0); - render_logo(); + /* Print cornia logo */ + cornia_render_logo(); + + /* Print layer status */ oled_set_cursor(0, 7); - render_layer_status(); + switch (get_highest_layer(layer_state)) { + case _ALPHA: + oled_write_ln("ALPHA", 0); + break; + case _NAV: + oled_write_ln("NAV", 0); + break; + case _NUM: + oled_write_ln("NUM", 0); + break; + case _ADJUST: + oled_write_ln("ADJUS", 0); + break; + case _G0: + oled_write_ln("GAME0", 0); + break; + case _G1: + oled_write_ln("GAME1", 0); + break; + } return false; } diff --git a/keyboards/cornia/keymaps/fire/callback_system.c b/keyboards/cornia/keymaps/fire/callback_system.c index 018e74f5d7d..16f1980856f 100644 --- a/keyboards/cornia/keymaps/fire/callback_system.c +++ b/keyboards/cornia/keymaps/fire/callback_system.c @@ -17,9 +17,15 @@ #include QMK_KEYBOARD_H #include "./keymap.h" -#include "./oled_routines.h" bool shutdown_user(bool jump_to_bootloader) { - render_boot(jump_to_bootloader); + oled_clear(); + oled_set_cursor(0, 2); + if (jump_to_bootloader) { + oled_write_P(PSTR("FLASH"), false); + } else { + oled_write_P(PSTR("RESET"), false); + } + oled_render_dirty(true); return false; } diff --git a/keyboards/cornia/keymaps/fire/config.h b/keyboards/cornia/keymaps/fire/config.h index 24cb4fade60..a40a881bf5b 100644 --- a/keyboards/cornia/keymaps/fire/config.h +++ b/keyboards/cornia/keymaps/fire/config.h @@ -16,11 +16,6 @@ #pragma once -/* I²C config */ -#define I2C_DRIVER I2CD1 -#define I2C1_SDA_PIN GP10 -#define I2C1_SCL_PIN GP11 - /* Split */ #define SPLIT_ACTIVITY_ENABLE #define SPLIT_LAYER_STATE_ENABLE diff --git a/keyboards/cornia/keymaps/fire/oled_routines.c b/keyboards/cornia/keymaps/fire/oled_routines.c deleted file mode 100644 index cb8fea96d6a..00000000000 --- a/keyboards/cornia/keymaps/fire/oled_routines.c +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright 2024 Vaarai - * - * 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 QMK_KEYBOARD_H - -#include "./keymap.h" -#include "./oled_routines.h" - -void render_logo(void) { - static const char PROGMEM logo[] = OLED_LOGO_CORNIA; - oled_write_raw_P(logo, sizeof(logo)); -} - -void render_layer_status(void) { - switch (get_highest_layer(layer_state)) { - case _ALPHA: - oled_write_ln("ALPHA", 0); - break; - case _NAV: - oled_write_ln("NAV", 0); - break; - case _NUM: - oled_write_ln("NUM", 0); - break; - case _ADJUST: - oled_write_ln("ADJUS", 0); - break; - case _G0: - oled_write_ln("GAME0", 0); - break; - case _G1: - oled_write_ln("GAME1", 0); - break; - } -} - -void render_boot(bool bootloader) { - oled_clear(); - oled_set_cursor(0, 2); - if (bootloader) { - oled_write_P(PSTR("FLASH"), false); - } else { - oled_write_P(PSTR("RESET"), false); - } - oled_render_dirty(true); -} diff --git a/keyboards/cornia/keymaps/fire/rules.mk b/keyboards/cornia/keymaps/fire/rules.mk index dedd42c4487..6253f6673d0 100644 --- a/keyboards/cornia/keymaps/fire/rules.mk +++ b/keyboards/cornia/keymaps/fire/rules.mk @@ -13,7 +13,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -SRC += oled_routines.c SRC += callback_oled.c SRC += callback_pointing_device.c SRC += callback_record.c @@ -32,6 +31,3 @@ OLED_TRANSPORT = i2c # Cirque Trackpad I²C configuration POINTING_DEVICE_ENABLE = yes POINTING_DEVICE_DRIVER = cirque_pinnacle_i2c - -# Add I²C HAL dependencies -OPT_DEFS += -DHAL_USE_I2C=TRUE diff --git a/keyboards/cornia/v0_6/config.h b/keyboards/cornia/v0_6/config.h index ab72146bd6c..4e2ac9ddab8 100644 --- a/keyboards/cornia/v0_6/config.h +++ b/keyboards/cornia/v0_6/config.h @@ -21,5 +21,10 @@ #define MASTER_RIGHT // #define EE_HANDS +/* I²C config */ +#define I2C_DRIVER I2CD1 +#define I2C1_SDA_PIN GP10 +#define I2C1_SCL_PIN GP11 + #define RP2040_BOOTLOADER_DOUBLE_TAP_RESET // Activates the double-tap behavior #define RP2040_BOOTLOADER_DOUBLE_TAP_RESET_TIMEOUT 200U // Timeout window in ms in which the double tap can occur. diff --git a/keyboards/cornia/keymaps/fire/mcuconf.h b/keyboards/cornia/v0_6/mcuconf.h similarity index 100% rename from keyboards/cornia/keymaps/fire/mcuconf.h rename to keyboards/cornia/v0_6/mcuconf.h diff --git a/keyboards/cornia/v0_6/rules.mk b/keyboards/cornia/v0_6/rules.mk new file mode 100644 index 00000000000..0a8e43f4efa --- /dev/null +++ b/keyboards/cornia/v0_6/rules.mk @@ -0,0 +1,17 @@ +# Copyright 2024 Vaarai +# +# 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 . + +# Add I²C HAL dependencies +OPT_DEFS += -DHAL_USE_I2C=TRUE diff --git a/keyboards/cornia/v1/config.h b/keyboards/cornia/v1/config.h index 52086ac2eb2..5fbfae2e26a 100644 --- a/keyboards/cornia/v1/config.h +++ b/keyboards/cornia/v1/config.h @@ -16,5 +16,10 @@ #pragma once +/* I²C config */ +#define I2C_DRIVER I2CD1 +#define I2C1_SDA_PIN GP10 +#define I2C1_SCL_PIN GP11 + #define RP2040_BOOTLOADER_DOUBLE_TAP_RESET // Activates the double-tap behavior #define RP2040_BOOTLOADER_DOUBLE_TAP_RESET_TIMEOUT 200U // Timeout window in ms in which the double tap can occur. diff --git a/keyboards/cornia/v1/mcuconf.h b/keyboards/cornia/v1/mcuconf.h new file mode 100644 index 00000000000..a1bfd10d0ff --- /dev/null +++ b/keyboards/cornia/v1/mcuconf.h @@ -0,0 +1,25 @@ +/* Copyright 2024 Vaarai + * + * 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 . + */ + +#pragma once + +#include_next + +#undef RP_I2C_USE_I2C0 +#define RP_I2C_USE_I2C0 FALSE + +#undef RP_I2C_USE_I2C1 +#define RP_I2C_USE_I2C1 TRUE diff --git a/keyboards/cornia/v1/rules.mk b/keyboards/cornia/v1/rules.mk new file mode 100644 index 00000000000..0a8e43f4efa --- /dev/null +++ b/keyboards/cornia/v1/rules.mk @@ -0,0 +1,17 @@ +# Copyright 2024 Vaarai +# +# 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 . + +# Add I²C HAL dependencies +OPT_DEFS += -DHAL_USE_I2C=TRUE