lotus: Add host SLEEP# detection
Signed-off-by: Daniel Schaefer <git@danielschaefer.me>
This commit is contained in:
@@ -4,16 +4,6 @@
|
|||||||
#include "quantum.h"
|
#include "quantum.h"
|
||||||
#include "lotus.h"
|
#include "lotus.h"
|
||||||
|
|
||||||
#define MUX_ENABLE_GPIO GP4
|
|
||||||
#define BOOT_DONE_GPIO GP5
|
|
||||||
// Pin SDB to enable the RGB controller
|
|
||||||
#ifdef PICO_LOTUS
|
|
||||||
// 22 only on RPi Pico because it doesn't have GP29
|
|
||||||
#define IS31FL3743A_ENABLE_GPIO GP22
|
|
||||||
#else
|
|
||||||
#define IS31FL3743A_ENABLE_GPIO GP29
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void keyboard_post_init_kb(void) {
|
void keyboard_post_init_kb(void) {
|
||||||
keyboard_post_init_user();
|
keyboard_post_init_user();
|
||||||
|
|
||||||
@@ -40,7 +30,30 @@ void keyboard_pre_init_kb(void) {
|
|||||||
writePinHigh(MUX_ENABLE_GPIO);
|
writePinHigh(MUX_ENABLE_GPIO);
|
||||||
|
|
||||||
#ifdef RGB_MATRIX_ENABLE
|
#ifdef RGB_MATRIX_ENABLE
|
||||||
//// TODO: Do we ever need to disable it to save power?
|
setPinOutput(IS31FL3743A_ENABLE_GPIO);
|
||||||
|
writePinHigh(IS31FL3743A_ENABLE_GPIO);
|
||||||
|
#endif
|
||||||
|
setPinInput(SLEEP_GPIO);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by QMK when the keyboard suspends
|
||||||
|
*/
|
||||||
|
void suspend_power_down_kb(void) {
|
||||||
|
suspend_power_down_user();
|
||||||
|
|
||||||
|
#ifdef RGB_MATRIX_ENABLE
|
||||||
|
writePinLow(IS31FL3743A_ENABLE_GPIO);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by QMK when the keyboard wakes up from suspend
|
||||||
|
*/
|
||||||
|
void suspend_wakeup_init_kb(void) {
|
||||||
|
suspend_wakeup_init_user();
|
||||||
|
|
||||||
|
#ifdef RGB_MATRIX_ENABLE
|
||||||
setPinOutput(IS31FL3743A_ENABLE_GPIO);
|
setPinOutput(IS31FL3743A_ENABLE_GPIO);
|
||||||
writePinHigh(IS31FL3743A_ENABLE_GPIO);
|
writePinHigh(IS31FL3743A_ENABLE_GPIO);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -21,3 +21,15 @@ enum lotus_keycodes {
|
|||||||
// Custom keycode to change screen modes (e.g. enable external screen)
|
// Custom keycode to change screen modes (e.g. enable external screen)
|
||||||
KC_SCRN = SAFE_RANGE,
|
KC_SCRN = SAFE_RANGE,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define SLEEP_GPIO GP0
|
||||||
|
#define MUX_ENABLE_GPIO GP4
|
||||||
|
#define BOOT_DONE_GPIO GP5
|
||||||
|
// Pin SDB to enable the RGB controller
|
||||||
|
#ifdef PICO_LOTUS
|
||||||
|
// 22 only on RPi Pico because it doesn't have GP29
|
||||||
|
#define IS31FL3743A_ENABLE_GPIO GP22
|
||||||
|
#else
|
||||||
|
#define IS31FL3743A_ENABLE_GPIO GP29
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -4,13 +4,14 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "matrix.h"
|
|
||||||
#include "analog.h"
|
#include "analog.h"
|
||||||
#include "print.h"
|
#include "print.h"
|
||||||
#include "quantum.h"
|
#include "quantum.h"
|
||||||
#include "hal_adc.h"
|
#include "hal_adc.h"
|
||||||
#include "chprintf.h"
|
#include "chprintf.h"
|
||||||
|
|
||||||
#include "matrix.h"
|
#include "matrix.h"
|
||||||
|
#include "lotus.h"
|
||||||
|
|
||||||
// Use raw ChibiOS ADC functions instead of those from QMK
|
// Use raw ChibiOS ADC functions instead of those from QMK
|
||||||
// Using the QMK functions doesn't work yet
|
// Using the QMK functions doesn't work yet
|
||||||
@@ -361,6 +362,19 @@ static void read_adc(void) {
|
|||||||
print_float(adc_voltage);
|
print_float(adc_voltage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the host going to sleep or the keyboard being idle
|
||||||
|
* If the host is asleep the keyboard should reduce the scan rate and turn backlight off.
|
||||||
|
*
|
||||||
|
* If the host is awake but the keyboard is idle it should enter a low-power state
|
||||||
|
*/
|
||||||
|
void handle_idle(void) {
|
||||||
|
bool asleep = readPin(SLEEP_GPIO);
|
||||||
|
uprintf("Host asleep: %d\n", asleep);
|
||||||
|
|
||||||
|
// TODO: Implement idle behavior
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Overriding behavior of matrix_scan from quantum/matrix.c
|
* Overriding behavior of matrix_scan from quantum/matrix.c
|
||||||
*/
|
*/
|
||||||
@@ -369,6 +383,8 @@ bool matrix_scan_custom(matrix_row_t current_matrix[]) {
|
|||||||
|
|
||||||
print("scan\n");
|
print("scan\n");
|
||||||
|
|
||||||
|
handle_idle();
|
||||||
|
|
||||||
for (int col = 0; col < MATRIX_COLS; col++) {
|
for (int col = 0; col < MATRIX_COLS; col++) {
|
||||||
// Drive column low so we can measure the resistors on each row in this column
|
// Drive column low so we can measure the resistors on each row in this column
|
||||||
drive_col(col, false);
|
drive_col(col, false);
|
||||||
|
|||||||
Reference in New Issue
Block a user