diff --git a/README.md b/README.md index dcfac62b..14648f0b 100644 --- a/README.md +++ b/README.md @@ -10,9 +10,11 @@ If the keyboard has not been merged yet to the main branch of QMK you may need t 1. Run the normal `qmk setup` procedure if you haven't already done so -- see [QMK Docs](https://docs.qmk.fm/#/newbs) for details. 1. Fork this repository +1. If you have already forked the `qmk/qmk_userspace` repository before you can add this repository manually following the [steps below](#adding-splitkb-fork-to-an-existing-fork). 1. Clone your fork to your local machine 1. Enable userspace in QMK config using `qmk config user.overlay_dir="$(realpath qmk_userspace)"` 1. Add a new keymap for your board by copy, pasting and renaming the `default_hlc` keymap within the `keyboards/splitkb/halcyon/$KB$/keymaps` folder. +1. You may want to replace the `qmk.json` with the empty `qmk_empty.json` if you want to start from scratch as it will otherwise compile all default options. 1. Add your keymap(s) to the build by running `qmk userspace-add -kb -km -e =1 -e TARGET=`. * This will automatically update your `qmk.json` file * Corresponding `qmk userspace-remove -kb -km -e =1 -e TARGET=`. @@ -53,12 +55,13 @@ Alternatively, if you configured your build targets above, you can use `qmk user If you wish to point GitHub actions to a different repository, a different branch, or even a different keymap name, you can modify `.github/workflows/build_binaries.yml` to suit your needs. -To override the `build` job, you can change the following parameters to use a different QMK repository or branch, this can be useful if you want to use a different QMK or vial branch for example: +To override the `build` job, you can change the following parameters to use a different QMK repository or branch, this can be useful if you want to use a the main QMK repository or a different vial branch. For example: ``` with: qmk_repo: qmk/qmk_firmware qmk_ref: master ``` +Our halcyon module code should work fine with the main QMK repository but it may break if there are any breaking changes from QMK in the future. We will try our best to keep this repository up-to-date. If you wish to manually manage `qmk_firmware` using git within the userspace repository, you can add `qmk_firmware` as a submodule in the userspace directory instead. GitHub Actions will automatically use the submodule at the pinned revision if it exists, otherwise it will use the default latest revision of `qmk_firmware` from the main repository. This will not work when using vial. @@ -67,3 +70,13 @@ This can also be used to control which fork is used. 1. (First time only) `git submodule add https://github.com/qmk/qmk_firmware.git` 1. (To update) `git submodule update --init --recursive` 1. Commit your changes to your userspace repository + + +## Adding splitkb fork to an existing fork + +If you have already forked the qmk/qmk_userspace repository before you may need to manually add the `halcyon` branch. + +1. Add a new upstream `git remote add upstream https://github.com/splitkb/qmk_userspace.git` +1. Fetch the upstream `git fetch upstream` +1. Create a new branch based on the upstream `git checkout -b halcyon upstream/halcyon` +1. Make any changes you want and push it to github `git push -u origin halcyon` diff --git a/examples/display/display.c b/examples/display/display.c index d5312cdf..65df98bc 100644 --- a/examples/display/display.c +++ b/examples/display/display.c @@ -1,9 +1,6 @@ // Include the main display functions so we don't have to initialize the display again #include "hlc_tft_display/hlc_tft_display.h" -// Include the QP api -#include "qp_surface.h" - // Add a font, this font is generated using the QP CLI tools (https://docs.qmk.fm/quantum_painter#quantum-painter-cli) #include "graphics/thintel15.qff.h" diff --git a/qmk_empty.json b/qmk_empty.json new file mode 100644 index 00000000..2d195ba0 --- /dev/null +++ b/qmk_empty.json @@ -0,0 +1,4 @@ +{ + "userspace_version": "1.1", + "build_targets": [] +} diff --git a/users/halcyon_modules/hlc_cirque_trackpad/rules.mk b/users/halcyon_modules/hlc_cirque_trackpad/rules.mk deleted file mode 100644 index a4983b87..00000000 --- a/users/halcyon_modules/hlc_cirque_trackpad/rules.mk +++ /dev/null @@ -1,3 +0,0 @@ -CURRENT_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) - -CONFIG_H += $(CURRENT_DIR)/config.h diff --git a/users/halcyon_modules/hlc_encoder/rules.mk b/users/halcyon_modules/hlc_encoder/rules.mk deleted file mode 100644 index 0db09e4c..00000000 --- a/users/halcyon_modules/hlc_encoder/rules.mk +++ /dev/null @@ -1,4 +0,0 @@ -CURRENT_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) - -SRC += $(CURRENT_DIR)/hlc_encoder.c -CONFIG_H += $(CURRENT_DIR)/config.h diff --git a/users/halcyon_modules/hlc_tft_display/rules.mk b/users/halcyon_modules/hlc_tft_display/rules.mk deleted file mode 100644 index 34319ae9..00000000 --- a/users/halcyon_modules/hlc_tft_display/rules.mk +++ /dev/null @@ -1,9 +0,0 @@ -CURRENT_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) - -SRC += $(CURRENT_DIR)/hlc_tft_display.c -CONFIG_H += $(CURRENT_DIR)/config.h - -# Fonts -SRC += $(CURRENT_DIR)/graphics/fonts/Retron2000-27.qff.c $(CURRENT_DIR)/graphics/fonts/Retron2000-underline-27.qff.c -# Numbers in image format -SRC += $(CURRENT_DIR)/graphics/numbers/0.qgf.c $(CURRENT_DIR)/graphics/numbers/1.qgf.c $(CURRENT_DIR)/graphics/numbers/2.qgf.c $(CURRENT_DIR)/graphics/numbers/3.qgf.c $(CURRENT_DIR)/graphics/numbers/4.qgf.c $(CURRENT_DIR)/graphics/numbers/5.qgf.c $(CURRENT_DIR)/graphics/numbers/6.qgf.c $(CURRENT_DIR)/graphics/numbers/7.qgf.c $(CURRENT_DIR)/graphics/numbers/8.qgf.c $(CURRENT_DIR)/graphics/numbers/9.qgf.c $(CURRENT_DIR)/graphics/numbers/undef.qgf.c diff --git a/users/halcyon_modules/rules.mk b/users/halcyon_modules/rules.mk index 8136ecc4..a8c7c54c 100644 --- a/users/halcyon_modules/rules.mk +++ b/users/halcyon_modules/rules.mk @@ -1,34 +1,4 @@ -CURRENT_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) - -SRC += halcyon.c - -LTO_ENABLE ?= yes - -# May need to be changed when adding more pointing devices -POINTING_DEVICE_ENABLE = yes -POINTING_DEVICE_DRIVER = cirque_pinnacle_spi - -# May need to be changed when adding more displays -QUANTUM_PAINTER_ENABLE = yes -QUANTUM_PAINTER_DRIVERS += st7789_spi surface - -BACKLIGHT_ENABLE = yes -BACKLIGHT_DRIVER = pwm - -ifdef HLC_ENCODER - include $(CURRENT_DIR)/hlc_encoder/rules.mk -endif - -ifdef HLC_TFT_DISPLAY - include $(CURRENT_DIR)/hlc_tft_display/rules.mk -endif - -ifdef HLC_CIRQUE_TRACKPAD - include $(CURRENT_DIR)/hlc_cirque_trackpad/rules.mk -endif - -HLC_OPTIONS := $(HLC_NONE) $(HLC_CIRQUE_TRACKPAD) $(HLC_ENCODER) $(HLC_TFT_DISPLAY) - -ifeq ($(filter 1, $(HLC_OPTIONS)), ) -$(error Wrong or no module specified. Please specify one of the following: HLC_NONE, HLC_CIRQUE_TRACKPAD, HLC_ENCODER or HLC_TFT_DISPLAY.) +# Add this to your existing rules.mk if you have one +ifneq ($(filter $(strip $(KEYBOARD)), splitkb/halcyon/kyria/rev4),) + include $(USER_PATH)/splitkb/rules.mk endif diff --git a/users/halcyon_modules/config.h b/users/halcyon_modules/splitkb/config.h similarity index 86% rename from users/halcyon_modules/config.h rename to users/halcyon_modules/splitkb/config.h index fb356e6b..0f241da5 100644 --- a/users/halcyon_modules/config.h +++ b/users/halcyon_modules/splitkb/config.h @@ -5,13 +5,6 @@ #define SPLIT_TRANSACTION_IDS_KB MODULE_SYNC -#include_next - -#undef RP_PWM_USE_PWM5 -#define RP_PWM_USE_PWM5 TRUE - -#define HAL_USE_PWM TRUE - #define SPLIT_POINTING_ENABLE #define POINTING_DEVICE_COMBINED @@ -21,31 +14,20 @@ #define BACKLIGHT_LEVELS 10 #define BACKLIGHT_PWM_CHANNEL RP2040_PWM_CHANNEL_B -#if !defined(HLC_TFT_DISPLAY) - #define BACKLIGHT_PIN NO_PIN -#endif - -#if !defined(HLC_CIRQUE_TRACKPAD) - #define POINTING_DEVICE_CS_PIN GP2 //NOT CONNECTED -#endif - -#include_next - //// Keyboard redefines // Always the same +#define BACKLIGHT_PIN GP2 //NOT CONNECTED +#define POINTING_DEVICE_CS_PIN GP2 //NOT CONNECTED +#define HLC_ENCODER_A NO_PIN +#define HLC_ENCODER_B NO_PIN + #define SPLIT_MODS_ENABLE #define SPLIT_LED_STATE_ENABLE #define SPLIT_LAYER_STATE_ENABLE -#ifndef HLC_ENCODER_A -# define HLC_ENCODER_A NO_PIN -#endif -#ifndef HLC_ENCODER_B -# define HLC_ENCODER_B NO_PIN -#endif // Kyria -#if PRODUCT_ID == 0x7FCE +#if defined(KEYBOARD_splitkb_halcyon_kyria_rev4) #undef ENCODER_A_PINS #define ENCODER_A_PINS { GP23, HLC_ENCODER_A } #undef ENCODER_B_PINS diff --git a/users/halcyon_modules/splitkb/halconf.h b/users/halcyon_modules/splitkb/halconf.h new file mode 100644 index 00000000..296d308b --- /dev/null +++ b/users/halcyon_modules/splitkb/halconf.h @@ -0,0 +1,8 @@ +// Copyright 2024 splitkb.com (support@splitkb.com) +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#define HAL_USE_PWM TRUE + +#include_next diff --git a/users/halcyon_modules/halcyon.c b/users/halcyon_modules/splitkb/halcyon.c similarity index 85% rename from users/halcyon_modules/halcyon.c rename to users/halcyon_modules/splitkb/halcyon.c index 954b2b1d..d2cd76b7 100644 --- a/users/halcyon_modules/halcyon.c +++ b/users/halcyon_modules/splitkb/halcyon.c @@ -1,9 +1,14 @@ // Copyright 2024 splitkb.com (support@splitkb.com) // SPDX-License-Identifier: GPL-2.0-or-later +#include QMK_KEYBOARD_H #include "halcyon.h" #include "transactions.h" #include "split_util.h" +#include "_wait.h" + +__attribute__((weak)) void module_suspend_power_down_kb(void); +__attribute__((weak)) void module_suspend_wakeup_init_kb(void); __attribute__((weak)) bool module_post_init_kb(void) { return module_post_init_user(); @@ -63,6 +68,18 @@ void module_sync_slave_handler(uint8_t initiator2target_buffer_size, const void* } } +void suspend_power_down_kb(void) { + module_suspend_power_down_kb(); + + suspend_power_down_user(); +} + +void suspend_wakeup_init_kb(void) { + module_suspend_wakeup_init_kb(); + + suspend_wakeup_init_user(); +} + void keyboard_post_init_kb(void) { // Register module sync split transaction transaction_register_rpc(MODULE_SYNC, module_sync_slave_handler); @@ -76,29 +93,34 @@ void keyboard_post_init_kb(void) { void housekeeping_task_kb(void) { if (is_keyboard_master()) { - static bool synced = 0; - if(is_transport_connected() && synced == 0) { - transaction_rpc_send(MODULE_SYNC, sizeof(module), &module); // Sync to slave - // Good moment to make sure the backlight wakes up after boot for both halves - backlight_wakeup(); - synced = 1; + static bool synced = false; + + if (!synced) { + if(is_transport_connected()) { + transaction_rpc_send(MODULE_SYNC, sizeof(module), &module); // Sync to slave + wait_ms(10); + // Good moment to make sure the backlight wakes up after boot for both halves + backlight_wakeup(); + synced = true; + } } + display_module_housekeeping_task_kb(false); // Is master so can never be the second display } + if (!is_keyboard_master()) { - if (module_master == hlc_tft_display) { - display_module_housekeeping_task_kb(true); // If there is a display on master, become the second display - } else { - display_module_housekeeping_task_kb(false); // Otherwise be the main display - } + display_module_housekeeping_task_kb(module_master == hlc_tft_display); } // Backlight feature - if (backlight_off && last_input_activity_elapsed() <= HLC_BACKLIGHT_TIMEOUT) { - backlight_wakeup(); - } - if (!backlight_off && last_input_activity_elapsed() > HLC_BACKLIGHT_TIMEOUT) { - backlight_suspend(); + if (last_input_activity_elapsed() <= HLC_BACKLIGHT_TIMEOUT) { + if (backlight_off) { + backlight_wakeup(); + } + } else { + if (!backlight_off) { + backlight_suspend(); + } } module_housekeeping_task_kb(); @@ -119,7 +141,7 @@ report_mouse_t pointing_device_task_combined_kb(report_mouse_t left_report, repo } // Kyria -#if PRODUCT_ID == 0x7FCE +#if defined(KEYBOARD_splitkb_halcyon_kyria_rev4) #ifdef RGB_MATRIX_ENABLE #include "rgb_matrix.h" led_config_t g_led_config = { diff --git a/users/halcyon_modules/halcyon.h b/users/halcyon_modules/splitkb/halcyon.h similarity index 100% rename from users/halcyon_modules/halcyon.h rename to users/halcyon_modules/splitkb/halcyon.h diff --git a/users/halcyon_modules/hlc_cirque_trackpad/config.h b/users/halcyon_modules/splitkb/hlc_cirque_trackpad/config.h similarity index 94% rename from users/halcyon_modules/hlc_cirque_trackpad/config.h rename to users/halcyon_modules/splitkb/hlc_cirque_trackpad/config.h index e93ae55e..0377ba12 100644 --- a/users/halcyon_modules/hlc_cirque_trackpad/config.h +++ b/users/halcyon_modules/splitkb/hlc_cirque_trackpad/config.h @@ -8,6 +8,7 @@ #define HLC_CIRQUE_TRACKPAD #define CIRQUE_PINNACLE_DIAMETER_MM 35 +#undef POINTING_DEVICE_CS_PIN #define POINTING_DEVICE_CS_PIN GP13 #define POINTING_DEVICE_ROTATION_180 #define CIRQUE_PINNACLE_CURVED_OVERLAY diff --git a/users/halcyon_modules/splitkb/hlc_cirque_trackpad/rules.mk b/users/halcyon_modules/splitkb/hlc_cirque_trackpad/rules.mk new file mode 100644 index 00000000..2b83721b --- /dev/null +++ b/users/halcyon_modules/splitkb/hlc_cirque_trackpad/rules.mk @@ -0,0 +1 @@ +POST_CONFIG_H += $(USER_PATH)/splitkb/hlc_cirque_trackpad/config.h diff --git a/users/halcyon_modules/hlc_encoder/config.h b/users/halcyon_modules/splitkb/hlc_encoder/config.h similarity index 85% rename from users/halcyon_modules/hlc_encoder/config.h rename to users/halcyon_modules/splitkb/hlc_encoder/config.h index 0eed0c0f..0c52cebf 100644 --- a/users/halcyon_modules/hlc_encoder/config.h +++ b/users/halcyon_modules/splitkb/hlc_encoder/config.h @@ -8,5 +8,7 @@ #define HLC_ENCODER #define HLC_ENCODER_BUTTON GP16 +#undef HLC_ENCODER_A #define HLC_ENCODER_A GP27 +#undef HLC_ENCODER_B #define HLC_ENCODER_B GP26 diff --git a/users/halcyon_modules/hlc_encoder/hlc_encoder.c b/users/halcyon_modules/splitkb/hlc_encoder/hlc_encoder.c similarity index 100% rename from users/halcyon_modules/hlc_encoder/hlc_encoder.c rename to users/halcyon_modules/splitkb/hlc_encoder/hlc_encoder.c diff --git a/users/halcyon_modules/splitkb/hlc_encoder/rules.mk b/users/halcyon_modules/splitkb/hlc_encoder/rules.mk new file mode 100644 index 00000000..ce1d5d1b --- /dev/null +++ b/users/halcyon_modules/splitkb/hlc_encoder/rules.mk @@ -0,0 +1,2 @@ +SRC += $(USER_PATH)/splitkb/hlc_encoder/hlc_encoder.c +POST_CONFIG_H += $(USER_PATH)/splitkb/hlc_encoder/config.h diff --git a/users/halcyon_modules/hlc_tft_display/config.h b/users/halcyon_modules/splitkb/hlc_tft_display/config.h similarity index 90% rename from users/halcyon_modules/hlc_tft_display/config.h rename to users/halcyon_modules/splitkb/hlc_tft_display/config.h index 41b61ac9..ea8b79ef 100644 --- a/users/halcyon_modules/hlc_tft_display/config.h +++ b/users/halcyon_modules/splitkb/hlc_tft_display/config.h @@ -13,7 +13,6 @@ #define LCD_DC_PIN GP16 #define LCD_SPI_DIVISOR 0 #define LCD_SPI_MODE 3 -#define LCD_WAIT_TIME 150 #define LCD_WIDTH 135 #define LCD_HEIGHT 240 #define LCD_ROTATION QP_ROTATION_0 @@ -21,13 +20,14 @@ #define LCD_OFFSET_Y 40 // QP Configuration -#define QUANTUM_PAINTER_SUPPORTS_NATIVE_COLORS FALSE +#define QUANTUM_PAINTER_SUPPORTS_NATIVE_COLORS TRUE #define ST7789_NO_AUTOMATIC_VIEWPORT_OFFSETS #define ST7789_NUM_DEVICES 1 #define SURFACE_NUM_DEVICES 1 // Backlight configuration +#undef BACKLIGHT_PIN #define BACKLIGHT_PIN GP27 // Timeout configuration diff --git a/users/halcyon_modules/hlc_tft_display/graphics/fonts/Retron2000-27.qff.c b/users/halcyon_modules/splitkb/hlc_tft_display/graphics/fonts/Retron2000-27.qff.c similarity index 100% rename from users/halcyon_modules/hlc_tft_display/graphics/fonts/Retron2000-27.qff.c rename to users/halcyon_modules/splitkb/hlc_tft_display/graphics/fonts/Retron2000-27.qff.c diff --git a/users/halcyon_modules/hlc_tft_display/graphics/fonts/Retron2000-27.qff.h b/users/halcyon_modules/splitkb/hlc_tft_display/graphics/fonts/Retron2000-27.qff.h similarity index 100% rename from users/halcyon_modules/hlc_tft_display/graphics/fonts/Retron2000-27.qff.h rename to users/halcyon_modules/splitkb/hlc_tft_display/graphics/fonts/Retron2000-27.qff.h diff --git a/users/halcyon_modules/hlc_tft_display/graphics/fonts/Retron2000-underline-27.qff.c b/users/halcyon_modules/splitkb/hlc_tft_display/graphics/fonts/Retron2000-underline-27.qff.c similarity index 100% rename from users/halcyon_modules/hlc_tft_display/graphics/fonts/Retron2000-underline-27.qff.c rename to users/halcyon_modules/splitkb/hlc_tft_display/graphics/fonts/Retron2000-underline-27.qff.c diff --git a/users/halcyon_modules/hlc_tft_display/graphics/fonts/Retron2000-underline-27.qff.h b/users/halcyon_modules/splitkb/hlc_tft_display/graphics/fonts/Retron2000-underline-27.qff.h similarity index 100% rename from users/halcyon_modules/hlc_tft_display/graphics/fonts/Retron2000-underline-27.qff.h rename to users/halcyon_modules/splitkb/hlc_tft_display/graphics/fonts/Retron2000-underline-27.qff.h diff --git a/users/halcyon_modules/hlc_tft_display/graphics/numbers/0.qgf.c b/users/halcyon_modules/splitkb/hlc_tft_display/graphics/numbers/0.qgf.c similarity index 100% rename from users/halcyon_modules/hlc_tft_display/graphics/numbers/0.qgf.c rename to users/halcyon_modules/splitkb/hlc_tft_display/graphics/numbers/0.qgf.c diff --git a/users/halcyon_modules/hlc_tft_display/graphics/numbers/0.qgf.h b/users/halcyon_modules/splitkb/hlc_tft_display/graphics/numbers/0.qgf.h similarity index 100% rename from users/halcyon_modules/hlc_tft_display/graphics/numbers/0.qgf.h rename to users/halcyon_modules/splitkb/hlc_tft_display/graphics/numbers/0.qgf.h diff --git a/users/halcyon_modules/hlc_tft_display/graphics/numbers/1.qgf.c b/users/halcyon_modules/splitkb/hlc_tft_display/graphics/numbers/1.qgf.c similarity index 100% rename from users/halcyon_modules/hlc_tft_display/graphics/numbers/1.qgf.c rename to users/halcyon_modules/splitkb/hlc_tft_display/graphics/numbers/1.qgf.c diff --git a/users/halcyon_modules/hlc_tft_display/graphics/numbers/1.qgf.h b/users/halcyon_modules/splitkb/hlc_tft_display/graphics/numbers/1.qgf.h similarity index 100% rename from users/halcyon_modules/hlc_tft_display/graphics/numbers/1.qgf.h rename to users/halcyon_modules/splitkb/hlc_tft_display/graphics/numbers/1.qgf.h diff --git a/users/halcyon_modules/hlc_tft_display/graphics/numbers/2.qgf.c b/users/halcyon_modules/splitkb/hlc_tft_display/graphics/numbers/2.qgf.c similarity index 100% rename from users/halcyon_modules/hlc_tft_display/graphics/numbers/2.qgf.c rename to users/halcyon_modules/splitkb/hlc_tft_display/graphics/numbers/2.qgf.c diff --git a/users/halcyon_modules/hlc_tft_display/graphics/numbers/2.qgf.h b/users/halcyon_modules/splitkb/hlc_tft_display/graphics/numbers/2.qgf.h similarity index 100% rename from users/halcyon_modules/hlc_tft_display/graphics/numbers/2.qgf.h rename to users/halcyon_modules/splitkb/hlc_tft_display/graphics/numbers/2.qgf.h diff --git a/users/halcyon_modules/hlc_tft_display/graphics/numbers/3.qgf.c b/users/halcyon_modules/splitkb/hlc_tft_display/graphics/numbers/3.qgf.c similarity index 100% rename from users/halcyon_modules/hlc_tft_display/graphics/numbers/3.qgf.c rename to users/halcyon_modules/splitkb/hlc_tft_display/graphics/numbers/3.qgf.c diff --git a/users/halcyon_modules/hlc_tft_display/graphics/numbers/3.qgf.h b/users/halcyon_modules/splitkb/hlc_tft_display/graphics/numbers/3.qgf.h similarity index 100% rename from users/halcyon_modules/hlc_tft_display/graphics/numbers/3.qgf.h rename to users/halcyon_modules/splitkb/hlc_tft_display/graphics/numbers/3.qgf.h diff --git a/users/halcyon_modules/hlc_tft_display/graphics/numbers/4.qgf.c b/users/halcyon_modules/splitkb/hlc_tft_display/graphics/numbers/4.qgf.c similarity index 100% rename from users/halcyon_modules/hlc_tft_display/graphics/numbers/4.qgf.c rename to users/halcyon_modules/splitkb/hlc_tft_display/graphics/numbers/4.qgf.c diff --git a/users/halcyon_modules/hlc_tft_display/graphics/numbers/4.qgf.h b/users/halcyon_modules/splitkb/hlc_tft_display/graphics/numbers/4.qgf.h similarity index 100% rename from users/halcyon_modules/hlc_tft_display/graphics/numbers/4.qgf.h rename to users/halcyon_modules/splitkb/hlc_tft_display/graphics/numbers/4.qgf.h diff --git a/users/halcyon_modules/hlc_tft_display/graphics/numbers/5.qgf.c b/users/halcyon_modules/splitkb/hlc_tft_display/graphics/numbers/5.qgf.c similarity index 100% rename from users/halcyon_modules/hlc_tft_display/graphics/numbers/5.qgf.c rename to users/halcyon_modules/splitkb/hlc_tft_display/graphics/numbers/5.qgf.c diff --git a/users/halcyon_modules/hlc_tft_display/graphics/numbers/5.qgf.h b/users/halcyon_modules/splitkb/hlc_tft_display/graphics/numbers/5.qgf.h similarity index 100% rename from users/halcyon_modules/hlc_tft_display/graphics/numbers/5.qgf.h rename to users/halcyon_modules/splitkb/hlc_tft_display/graphics/numbers/5.qgf.h diff --git a/users/halcyon_modules/hlc_tft_display/graphics/numbers/6.qgf.c b/users/halcyon_modules/splitkb/hlc_tft_display/graphics/numbers/6.qgf.c similarity index 100% rename from users/halcyon_modules/hlc_tft_display/graphics/numbers/6.qgf.c rename to users/halcyon_modules/splitkb/hlc_tft_display/graphics/numbers/6.qgf.c diff --git a/users/halcyon_modules/hlc_tft_display/graphics/numbers/6.qgf.h b/users/halcyon_modules/splitkb/hlc_tft_display/graphics/numbers/6.qgf.h similarity index 100% rename from users/halcyon_modules/hlc_tft_display/graphics/numbers/6.qgf.h rename to users/halcyon_modules/splitkb/hlc_tft_display/graphics/numbers/6.qgf.h diff --git a/users/halcyon_modules/hlc_tft_display/graphics/numbers/7.qgf.c b/users/halcyon_modules/splitkb/hlc_tft_display/graphics/numbers/7.qgf.c similarity index 100% rename from users/halcyon_modules/hlc_tft_display/graphics/numbers/7.qgf.c rename to users/halcyon_modules/splitkb/hlc_tft_display/graphics/numbers/7.qgf.c diff --git a/users/halcyon_modules/hlc_tft_display/graphics/numbers/7.qgf.h b/users/halcyon_modules/splitkb/hlc_tft_display/graphics/numbers/7.qgf.h similarity index 100% rename from users/halcyon_modules/hlc_tft_display/graphics/numbers/7.qgf.h rename to users/halcyon_modules/splitkb/hlc_tft_display/graphics/numbers/7.qgf.h diff --git a/users/halcyon_modules/hlc_tft_display/graphics/numbers/8.qgf.c b/users/halcyon_modules/splitkb/hlc_tft_display/graphics/numbers/8.qgf.c similarity index 100% rename from users/halcyon_modules/hlc_tft_display/graphics/numbers/8.qgf.c rename to users/halcyon_modules/splitkb/hlc_tft_display/graphics/numbers/8.qgf.c diff --git a/users/halcyon_modules/hlc_tft_display/graphics/numbers/8.qgf.h b/users/halcyon_modules/splitkb/hlc_tft_display/graphics/numbers/8.qgf.h similarity index 100% rename from users/halcyon_modules/hlc_tft_display/graphics/numbers/8.qgf.h rename to users/halcyon_modules/splitkb/hlc_tft_display/graphics/numbers/8.qgf.h diff --git a/users/halcyon_modules/hlc_tft_display/graphics/numbers/9.qgf.c b/users/halcyon_modules/splitkb/hlc_tft_display/graphics/numbers/9.qgf.c similarity index 100% rename from users/halcyon_modules/hlc_tft_display/graphics/numbers/9.qgf.c rename to users/halcyon_modules/splitkb/hlc_tft_display/graphics/numbers/9.qgf.c diff --git a/users/halcyon_modules/hlc_tft_display/graphics/numbers/9.qgf.h b/users/halcyon_modules/splitkb/hlc_tft_display/graphics/numbers/9.qgf.h similarity index 100% rename from users/halcyon_modules/hlc_tft_display/graphics/numbers/9.qgf.h rename to users/halcyon_modules/splitkb/hlc_tft_display/graphics/numbers/9.qgf.h diff --git a/users/halcyon_modules/hlc_tft_display/graphics/numbers/undef.qgf.c b/users/halcyon_modules/splitkb/hlc_tft_display/graphics/numbers/undef.qgf.c similarity index 100% rename from users/halcyon_modules/hlc_tft_display/graphics/numbers/undef.qgf.c rename to users/halcyon_modules/splitkb/hlc_tft_display/graphics/numbers/undef.qgf.c diff --git a/users/halcyon_modules/hlc_tft_display/graphics/numbers/undef.qgf.h b/users/halcyon_modules/splitkb/hlc_tft_display/graphics/numbers/undef.qgf.h similarity index 100% rename from users/halcyon_modules/hlc_tft_display/graphics/numbers/undef.qgf.h rename to users/halcyon_modules/splitkb/hlc_tft_display/graphics/numbers/undef.qgf.h diff --git a/users/halcyon_modules/hlc_tft_display/hlc_tft_display.c b/users/halcyon_modules/splitkb/hlc_tft_display/hlc_tft_display.c similarity index 93% rename from users/halcyon_modules/hlc_tft_display/hlc_tft_display.c rename to users/halcyon_modules/splitkb/hlc_tft_display/hlc_tft_display.c index 28166951..6ed0be53 100644 --- a/users/halcyon_modules/hlc_tft_display/hlc_tft_display.c +++ b/users/halcyon_modules/splitkb/hlc_tft_display/hlc_tft_display.c @@ -4,8 +4,7 @@ #include "halcyon.h" #include "hlc_tft_display.h" -#include "qp_surface.h" -#include +#include "hardware/structs/rosc.h" // Fonts mono2 #include "graphics/fonts/Retron2000-27.qff.h" @@ -31,9 +30,8 @@ static const char *scroll = "Scroll"; static painter_font_handle_t Retron27; static painter_font_handle_t Retron27_underline; static painter_image_handle_t layer_number; -backlight_config_t backlight_config; -static uint16_t lcd_surface_fb[135*240]; +static uint8_t lcd_surface_fb[SURFACE_REQUIRED_BUFFER_BYTE_SIZE(135, 240, 16)]; int color_value = 0; @@ -55,6 +53,15 @@ bool grid[GRID_HEIGHT][GRID_WIDTH]; // Current state bool new_grid[GRID_HEIGHT][GRID_WIDTH]; // Next state bool changed_grid[GRID_HEIGHT][GRID_WIDTH]; // Tracks changed cells +uint32_t get_random_32bit(void) { + uint32_t random_value = 0; + for (int i = 0; i < 32; i++) { + wait_ms(1); + random_value = (random_value << 1) | (rosc_hw->randombit & 1); + } + return random_value; +} + void init_grid() { // Initialize grid with alive cells for (int y = 0; y < GRID_HEIGHT; y++) { @@ -236,40 +243,39 @@ void update_display(void) { } } -// Quantum function -void suspend_power_down_kb(void) { +// Called from halcyon.c +void module_suspend_power_down_kb(void) { qp_power(lcd, false); - suspend_power_down_user(); } -// Quantum function -void suspend_wakeup_init_kb(void) { +// Called from halcyon.c +void module_suspend_wakeup_init_kb(void) { qp_power(lcd, true); - suspend_wakeup_init_user(); } // Called from halcyon.c bool module_post_init_kb(void) { - setPinOutput(LCD_RST_PIN); - writePinHigh(LCD_RST_PIN); - - // Initialise the LCD - lcd = qp_st7789_make_spi_device(LCD_WIDTH, LCD_HEIGHT, LCD_CS_PIN, LCD_DC_PIN, LCD_RST_PIN, LCD_SPI_DIVISOR, LCD_SPI_MODE); - qp_init(lcd, LCD_ROTATION); - qp_set_viewport_offsets(lcd, LCD_OFFSET_X, LCD_OFFSET_Y); - - // Initialise surface - lcd_surface = qp_make_rgb565_surface(LCD_WIDTH, LCD_HEIGHT, lcd_surface_fb); - qp_init(lcd_surface, LCD_ROTATION); - - // Turn on the LCD and clear the display - qp_power(lcd, true); - qp_rect(lcd, 0, 0, LCD_WIDTH - 1, LCD_HEIGHT - 1, HSV_BLACK, true); - qp_flush(lcd); - // Turn on backlight backlight_enable(); + // Make the devices + lcd = qp_st7789_make_spi_device(LCD_WIDTH, LCD_HEIGHT, LCD_CS_PIN, LCD_DC_PIN, LCD_RST_PIN, LCD_SPI_DIVISOR, LCD_SPI_MODE); + lcd_surface = qp_make_rgb565_surface(LCD_WIDTH, LCD_HEIGHT, lcd_surface_fb); + + // Initialise the LCD + qp_init(lcd, LCD_ROTATION); + qp_set_viewport_offsets(lcd, LCD_OFFSET_X, LCD_OFFSET_Y); + qp_clear(lcd); + qp_rect(lcd, 0, 0, LCD_WIDTH - 1, LCD_HEIGHT - 1, HSV_BLACK, true); + qp_power(lcd, true); + qp_flush(lcd); + + // Initialise the LCD surface + qp_init(lcd_surface, LCD_ROTATION); + qp_rect(lcd_surface, 0, 0, LCD_WIDTH - 1, LCD_HEIGHT - 1, HSV_BLACK, true); + qp_surface_draw(lcd_surface, lcd, 0, 0, 0); + qp_flush(lcd); + if(!module_post_init_user()) { return false; } return true; @@ -285,7 +291,7 @@ bool display_module_housekeeping_task_kb(bool second_display) { static uint32_t previous_matrix_activity_time = 0; if(!second_display_set) { - srand(time(NULL)); + srand(get_random_32bit()); init_grid(); color_value = rand() % 8; second_display_set = true; @@ -312,6 +318,7 @@ bool display_module_housekeeping_task_kb(bool second_display) { // Move surface to lcd qp_surface_draw(lcd_surface, lcd, 0, 0, 0); + qp_flush(lcd); return true; } diff --git a/users/halcyon_modules/hlc_tft_display/hlc_tft_display.h b/users/halcyon_modules/splitkb/hlc_tft_display/hlc_tft_display.h similarity index 97% rename from users/halcyon_modules/hlc_tft_display/hlc_tft_display.h rename to users/halcyon_modules/splitkb/hlc_tft_display/hlc_tft_display.h index 45bab704..8973bf03 100644 --- a/users/halcyon_modules/hlc_tft_display/hlc_tft_display.h +++ b/users/halcyon_modules/splitkb/hlc_tft_display/hlc_tft_display.h @@ -4,6 +4,7 @@ #pragma once #include "qp.h" +#include "qp_surface.h" // All values (including hue) are scaled to 0-255 #define HSV_SPLITKB 145, 235, 155 diff --git a/users/halcyon_modules/splitkb/hlc_tft_display/rules.mk b/users/halcyon_modules/splitkb/hlc_tft_display/rules.mk new file mode 100644 index 00000000..e072d834 --- /dev/null +++ b/users/halcyon_modules/splitkb/hlc_tft_display/rules.mk @@ -0,0 +1,19 @@ +SRC += $(USER_PATH)/splitkb/hlc_tft_display/hlc_tft_display.c +POST_CONFIG_H += $(USER_PATH)/splitkb/hlc_tft_display/config.h + +# Fonts +SRC += $(USER_PATH)/splitkb/hlc_tft_display/graphics/fonts/Retron2000-27.qff.c \ + $(USER_PATH)/splitkb/hlc_tft_display/graphics/fonts/Retron2000-underline-27.qff.c + +# Numbers in image format +SRC += $(USER_PATH)/splitkb/hlc_tft_display/graphics/numbers/0.qgf.c \ + $(USER_PATH)/splitkb/hlc_tft_display/graphics/numbers/1.qgf.c \ + $(USER_PATH)/splitkb/hlc_tft_display/graphics/numbers/2.qgf.c \ + $(USER_PATH)/splitkb/hlc_tft_display/graphics/numbers/3.qgf.c \ + $(USER_PATH)/splitkb/hlc_tft_display/graphics/numbers/4.qgf.c \ + $(USER_PATH)/splitkb/hlc_tft_display/graphics/numbers/5.qgf.c \ + $(USER_PATH)/splitkb/hlc_tft_display/graphics/numbers/6.qgf.c \ + $(USER_PATH)/splitkb/hlc_tft_display/graphics/numbers/7.qgf.c \ + $(USER_PATH)/splitkb/hlc_tft_display/graphics/numbers/8.qgf.c \ + $(USER_PATH)/splitkb/hlc_tft_display/graphics/numbers/9.qgf.c \ + $(USER_PATH)/splitkb/hlc_tft_display/graphics/numbers/undef.qgf.c diff --git a/users/halcyon_modules/splitkb/mcuconf.h b/users/halcyon_modules/splitkb/mcuconf.h new file mode 100644 index 00000000..28af3d98 --- /dev/null +++ b/users/halcyon_modules/splitkb/mcuconf.h @@ -0,0 +1,9 @@ +// Copyright 2024 splitkb.com (support@splitkb.com) +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include_next + +#undef RP_PWM_USE_PWM5 +#define RP_PWM_USE_PWM5 TRUE diff --git a/users/halcyon_modules/splitkb/rules.mk b/users/halcyon_modules/splitkb/rules.mk new file mode 100644 index 00000000..f2d7fa53 --- /dev/null +++ b/users/halcyon_modules/splitkb/rules.mk @@ -0,0 +1,33 @@ +# May need to be changed when adding more pointing devices +POINTING_DEVICE_ENABLE = yes +POINTING_DEVICE_DRIVER = cirque_pinnacle_spi + +# May need to be changed when adding more displays +QUANTUM_PAINTER_ENABLE = yes +QUANTUM_PAINTER_DRIVERS += st7789_spi surface + +BACKLIGHT_ENABLE = yes +BACKLIGHT_DRIVER = pwm + +VPATH += $(USER_PATH)/splitkb/ +SRC += $(USER_PATH)/splitkb/halcyon.c +HALCONFDIR += $(USER_PATH)/splitkb/halconf.h +POST_CONFIG_H += $(USER_PATH)/splitkb/config.h + +ifdef HLC_ENCODER + include $(USER_PATH)/splitkb/hlc_encoder/rules.mk +endif + +ifdef HLC_TFT_DISPLAY + include $(USER_PATH)/splitkb/hlc_tft_display/rules.mk +endif + +ifdef HLC_CIRQUE_TRACKPAD + include $(USER_PATH)/splitkb/hlc_cirque_trackpad/rules.mk +endif + +HLC_OPTIONS := $(HLC_NONE) $(HLC_CIRQUE_TRACKPAD) $(HLC_ENCODER) $(HLC_TFT_DISPLAY) + +ifeq ($(filter 1, $(HLC_OPTIONS)), ) +$(error Halcyon_modules used but wrong or no module specified. Please specify one by adding `-e =1` to your compile command where can be: HLC_NONE, HLC_CIRQUE_TRACKPAD, HLC_ENCODER or HLC_TFT_DISPLAY) +endif