Merge remote-tracking branch 'origin/halcyon' into halcyon-elora-rev2

This commit is contained in:
VeyPatch 2025-01-14 14:14:13 +01:00
commit 76b9c763af
48 changed files with 179 additions and 124 deletions

View file

@ -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 <your_keyboard> -km <your_keymap> -e <halcyon_module>=1 -e TARGET=<filename>`.
* This will automatically update your `qmk.json` file
* Corresponding `qmk userspace-remove -kb <your_keyboard> -km <your_keymap> -e <halcyon_module>=1 -e TARGET=<filename>`.
@ -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`

View file

@ -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"

4
qmk_empty.json Normal file
View file

@ -0,0 +1,4 @@
{
"userspace_version": "1.1",
"build_targets": []
}

View file

@ -1,3 +0,0 @@
CURRENT_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
CONFIG_H += $(CURRENT_DIR)/config.h

View file

@ -1,4 +0,0 @@
CURRENT_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
SRC += $(CURRENT_DIR)/hlc_encoder.c
CONFIG_H += $(CURRENT_DIR)/config.h

View file

@ -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

View file

@ -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

View file

@ -5,13 +5,6 @@
#define SPLIT_TRANSACTION_IDS_KB MODULE_SYNC
#include_next <mcuconf.h>
#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 <halconf.h>
//// 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

View file

@ -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 <halconf.h>

View file

@ -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 = {

View file

@ -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

View file

@ -0,0 +1 @@
POST_CONFIG_H += $(USER_PATH)/splitkb/hlc_cirque_trackpad/config.h

View file

@ -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

View file

@ -0,0 +1,2 @@
SRC += $(USER_PATH)/splitkb/hlc_encoder/hlc_encoder.c
POST_CONFIG_H += $(USER_PATH)/splitkb/hlc_encoder/config.h

View file

@ -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

View file

@ -4,8 +4,7 @@
#include "halcyon.h"
#include "hlc_tft_display.h"
#include "qp_surface.h"
#include <time.h>
#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;
}

View file

@ -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

View file

@ -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

View file

@ -0,0 +1,9 @@
// Copyright 2024 splitkb.com (support@splitkb.com)
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include_next <mcuconf.h>
#undef RP_PWM_USE_PWM5
#define RP_PWM_USE_PWM5 TRUE

View file

@ -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 <module_name>=1` to your compile command where <module_name> can be: HLC_NONE, HLC_CIRQUE_TRACKPAD, HLC_ENCODER or HLC_TFT_DISPLAY)
endif