forked from mirror/qmk_firmware
Implement battery level interface (#24666)
Co-authored-by: Nick Brassel <nick@tzarc.org>
This commit is contained in:
6
keyboards/handwired/onekey/keymaps/battery/config.h
Normal file
6
keyboards/handwired/onekey/keymaps/battery/config.h
Normal file
@@ -0,0 +1,6 @@
|
||||
// Copyright 2024 QMK
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#define BATTERY_PIN ADC_PIN
|
||||
28
keyboards/handwired/onekey/keymaps/battery/keymap.c
Normal file
28
keyboards/handwired/onekey/keymaps/battery/keymap.c
Normal file
@@ -0,0 +1,28 @@
|
||||
// Copyright 2024 QMK
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include QMK_KEYBOARD_H
|
||||
#include "battery.h"
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
LAYOUT_ortho_1x1(KC_A)
|
||||
};
|
||||
|
||||
void keyboard_post_init_user(void) {
|
||||
// Customise these values to desired behaviour
|
||||
debug_enable=true;
|
||||
// debug_matrix=false;
|
||||
// debug_keyboard=true;
|
||||
// debug_mouse=false;
|
||||
|
||||
battery_init();
|
||||
}
|
||||
|
||||
void housekeeping_task_user(void) {
|
||||
static uint32_t last = 0;
|
||||
if (timer_elapsed32(last) > 2000) {
|
||||
uprintf("Bat: %d!\n", battery_get_percent());
|
||||
|
||||
last = timer_read32();
|
||||
}
|
||||
}
|
||||
7
keyboards/handwired/onekey/keymaps/battery/keymap.json
Normal file
7
keyboards/handwired/onekey/keymaps/battery/keymap.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"config": {
|
||||
"features": {
|
||||
"console": true
|
||||
}
|
||||
}
|
||||
}
|
||||
1
keyboards/handwired/onekey/keymaps/battery/rules.mk
Normal file
1
keyboards/handwired/onekey/keymaps/battery/rules.mk
Normal file
@@ -0,0 +1 @@
|
||||
BATTERY_DRIVER_REQUIRED = yes
|
||||
Reference in New Issue
Block a user