You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be nice to have some sort of battery status keybinding that lights up across the top row with how charged the keyboard is and indicate whether the keyboard is currently charging or discharging. Using the top row is just an idea, this could be implemented in a number of different ways.
The text was updated successfully, but these errors were encountered:
The important bits are (might need some imports depending on how you organize your code):
from time import sleep
charger_in = digitalio.DigitalInOut(microcontroller.pin.P0_03) # NOTE: low/False=charging, high/True=not_charging
charger_in.pull = digitalio.Pull.UP
def battery_charge():
return not charger_in.value
# code.py
def macro_handler_batt(dev, is_down): # invoke this in your macro_handler
if is_down:
is_charging = battery_charge()
level = int(round(battery_level() / 7.14))
dev.backlight.off()
for i in range(level):
if i == 0 and is_charging:
dev.backlight.pixel(i, 255, 0, 0)
else:
dev.backlight.pixel(i, 0, 255, 0)
if i != level - 1:
sleep(0.03)
dev.backlight.update()
else:
dev.backlight.set_mode(dev.backlight.mode)
So whenever you press this macro it does the following:
Turns off the backlight upon macro press.
Sets "esc" to red if charging, green otherwise.
Animates a bar along the top of your keyboard in green with the current charge level.
I also just committed more changes, like having the macro handlers be aware if shift or ctrl has been also pushed. I have it so that if I have shift pressed while pressing my battery macro, it will type the exact battery percentage.
It would be nice to have some sort of battery status keybinding that lights up across the top row with how charged the keyboard is and indicate whether the keyboard is currently charging or discharging. Using the top row is just an idea, this could be implemented in a number of different ways.
The text was updated successfully, but these errors were encountered: