1
0
Fork 0

Sync activity timestamps between sides. (#20192)

Co-authored-by: Stefan Kerkmann <karlk90@pm.me>
This commit is contained in:
Nick Brassel 2023-03-21 20:16:11 +11:00 committed by GitHub
parent 0e1e543836
commit a518e1e5d8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 78 additions and 25 deletions

View file

@ -1,4 +1,4 @@
// Copyright 2018-2022 Nick Brassel (@tzarc)
// Copyright 2018-2023 Nick Brassel (@tzarc)
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
@ -16,6 +16,7 @@
#define SPLIT_LED_STATE_ENABLE
#define SPLIT_MODS_ENABLE
#define SPLIT_WPM_ENABLE
#define SPLIT_ACTIVITY_ENABLE
// SPI Configuration
#define SPI_DRIVER SPID3

View file

@ -1,4 +1,4 @@
// Copyright 2018-2022 Nick Brassel (@tzarc)
// Copyright 2018-2023 Nick Brassel (@tzarc)
// SPDX-License-Identifier: GPL-2.0-or-later
#include <string.h>
#include "quantum.h"
@ -74,7 +74,6 @@ void keyboard_post_init_kb(void) {
qp_init(lcd, QP_ROTATION_0);
// Turn on the LCD and clear the display
kb_state.lcd_power = 1;
qp_power(lcd, true);
qp_rect(lcd, 0, 0, 239, 319, HSV_BLACK, true);
@ -187,18 +186,14 @@ void housekeeping_task_kb(void) {
}
// Turn on/off the LCD
static bool lcd_on = false;
if (lcd_on != (bool)kb_state.lcd_power) {
lcd_on = (bool)kb_state.lcd_power;
qp_power(lcd, lcd_on);
}
bool peripherals_on = last_input_activity_elapsed() < LCD_ACTIVITY_TIMEOUT;
// Enable/disable RGB
if (lcd_on) {
if (peripherals_on) {
// Turn on RGB
writePinHigh(RGB_POWER_ENABLE_PIN);
// Modify the RGB state if different to the LCD state
if (rgb_matrix_is_enabled() != lcd_on) {
if (rgb_matrix_is_enabled() != peripherals_on) {
// Wait for a small amount of time to allow the RGB capacitors to charge, before enabling RGB output
wait_ms(10);
// Enable RGB
@ -208,21 +203,21 @@ void housekeeping_task_kb(void) {
// Turn off RGB
writePinLow(RGB_POWER_ENABLE_PIN);
// Disable the PWM output for the RGB
if (rgb_matrix_is_enabled() != lcd_on) {
if (rgb_matrix_is_enabled() != peripherals_on) {
rgb_matrix_disable_noeeprom();
}
}
// Match the backlight to the LCD state
if (is_keyboard_master() && is_backlight_enabled() != lcd_on) {
if (lcd_on)
if (is_keyboard_master() && is_backlight_enabled() != peripherals_on) {
if (peripherals_on)
backlight_enable();
else
backlight_disable();
}
// Draw the UI
if (kb_state.lcd_power) {
if (peripherals_on) {
draw_ui_user(false);
}

View file

@ -1,4 +1,4 @@
// Copyright 2018-2022 Nick Brassel (@tzarc)
// Copyright 2018-2023 Nick Brassel (@tzarc)
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "quantum.h"
@ -20,7 +20,6 @@ const char* usbpd_str(usbpd_allowance_t allowance);
#pragma pack(push)
#pragma pack(1)
typedef struct kb_runtime_config {
unsigned lcd_power : 1;
usbpd_allowance_t current_setting : 2;
} kb_runtime_config;
#pragma pack(pop)

View file

@ -1,4 +1,4 @@
// Copyright 2018-2022 Nick Brassel (@tzarc)
// Copyright 2018-2023 Nick Brassel (@tzarc)
// SPDX-License-Identifier: GPL-2.0-or-later
#include <string.h>
#include "quantum.h"
@ -13,9 +13,6 @@ void kb_state_update(void) {
if (is_keyboard_master()) {
// Modify allowed current limits
usbpd_update();
// Turn off the LCD if there's been no matrix activity
kb_state.lcd_power = (last_input_activity_elapsed() < LCD_ACTIVITY_TIMEOUT) ? 1 : 0;
}
}