GithubHelp home page GithubHelp logo

caksoylar / zmk-rgbled-widget Goto Github PK

View Code? Open in Web Editor NEW
35.0 3.0 5.0 26 KB

A ZMK module to add battery & BT indicators using an RGB LED (like in Xiao BLEs)

License: MIT License

CMake 0.64% C 99.36%
zmk-config zmk-module

zmk-rgbled-widget's Introduction

LED indicators using an RGB LED

This is a ZMK module containing a simple widget that utilizes a (typically built-in) RGB LED controlled by three separate GPIOs. It is used to indicate battery level and BLE connection status in a minimalist way.

Usage

To use, first add this module to your config/west.yml by adding a new entry to remotes and projects:

manifest:
  remotes:
    - name: zmkfirmware
      url-base: https://github.com/zmkfirmware
    - name: caksoylar
      url-base: https://github.com/caksoylar
  projects:
    - name: zmk
      remote: zmkfirmware
      revision: main
      import: app/west.yml
    - name: zmk-rgbled-widget
      remote: caksoylar
      revision: main
  self:
    path: config

If you are building locally, see the instructions for building with external modules in ZMK docs.

Then, if you are using one of the boards supported by the rgbled_adapter shield such as Xiao BLE, just add the rgbled_adapter as an additional shield to your build, e.g. in build.yaml:

---
include:
  - board: seeeduino_xiao_ble
    shield: hummingbird rgbled_adapter

For other keyboards, see the "Adding support" section below.

Features

Short video demo See below video for a short demo, running through power on, profile switching and power offs.
rgbled_widget.mp4

Currently the widget does the following:

  • Blink ๐ŸŸข/๐ŸŸก/๐Ÿ”ด on boot depending on battery level (for both central/peripherals), thresholds set by CONFIG_RGBLED_WIDGET_BATTERY_LEVEL_HIGH and CONFIG_RGBLED_WIDGET_BATTERY_LEVEL_LOW
  • Blink ๐Ÿ”ด on every battery level change if below critical battery level (CONFIG_RGBLED_WIDGET_BATTERY_LEVEL_CRITICAL)
  • Blink ๐Ÿ”ต for connected, ๐ŸŸก for open (advertising), ๐Ÿ”ด for disconnected profiles on every BT profile switch (on central side for splits)
  • Blink ๐Ÿ”ต for connected, ๐Ÿ”ด for disconnected on peripheral side of splits

In addition, you can enable CONFIG_RGBLED_WIDGET_SHOW_LAYER_CHANGE to show the highest active layer on every layer activation using a sequence of N cyan color blinks, where N is the zero-based index of the layer.

Configuration

Blink durations can also be adjusted, see the Kconfig file for available config properties. You can add these settings to your keyboard conf file to modify the config values, e.g. in config/hummingbird.conf:

CONFIG_RGBLED_WIDGET_INTERVAL_MS=250
CONFIG_RGBLED_WIDGET_BATTERY_LEVEL_HIGH=50
CONFIG_RGBLED_WIDGET_BATTERY_LEVEL_CRITICAL=10

Adding support in custom boards/shields

To be able to use this widget, you need three LEDs controlled by GPIOs (not smart LEDs), ideally red, green and blue colors. Once you have these LED definitions in your board/shield, simply set the appropriate aliases to the RGB LED node labels.

As an example, here is a definition for three LEDs connected to VCC and separate GPIOs for a nRF52840 controller:

/ {
    aliases {
        led-red = &led0;
        led-green = &led1;
        led-blue = &led2;
    };

    leds {
        compatible = "gpio-leds";
        status = "okay";
        led0: led_0 {
            gpios = <&gpio0 26 GPIO_ACTIVE_LOW>;  // red LED, connected to P0.26
        };
        led1: led_1 {
            gpios = <&gpio0 30 GPIO_ACTIVE_LOW>;  // green LED, connected to P0.30
        };
        led2: led_2 {
            gpios = <&gpio0 6 GPIO_ACTIVE_LOW>;  // blue LED, connected to P0.06
        };
    };
};

(If the LEDs are wired between GPIO and GND instead, use GPIO_ACTIVE_HIGH flag.)

Finally, turn on the widget in the configuration:

CONFIG_RGBLED_WIDGET=y

zmk-rgbled-widget's People

Contributors

caksoylar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

zmk-rgbled-widget's Issues

Add debouncing for layer change

If we add debouncing with a very short period, we can avoid the extraneous blinks due to multiple events raised by conditional layer changes.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.