Giter Site home page Giter Site logo

joshuag1000 / raspberry-pi-pico-macropad Goto Github PK

View Code? Open in Web Editor NEW
12.0 4.0 1.0 406 KB

This code allows you to use the Pimoroni RGB Keypad for the Raspberry Pi Pico as a macro keypad in C++

License: MIT License

CMake 21.48% C++ 46.92% C 31.61%
raspberry-pi-pico pimoroni-rgb-keypad pico macro-keypad rp2040 tinyusb raspberry-pi

raspberry-pi-pico-macropad's Introduction

Raspberry Pi Pico MacroPad

Compile For the Pico.
This code allows you to use the Pimoroni RGB Keypad for the Pico as a macro keypad in C++
Setting what keybind each key is really easy to do and the code is written in a way that makes it easy to change what each key does.

Downloading

It is advised that you clone the latest version of the code when you want to use this project rather than using the latest release. The latest release might not contain the latest version of the code.

HTTP

The latest version of the code can be downloaded here: Download
Just dont forget to include the RGB Keypad library in libs/pimoroni-pico which can be downloaded here: Pimoroni-Pico

Git

Clone the repo:

git clone https://github.com/joshuag1000/Raspberry-Pi-Pico-MacroPad.git

Initialise submodules:

git submodule update --init --recursive

TinyUSB

This code uses the TinyUSB library in order to perform the hid keyboard responses.
To find the possible keys that can be used visit here: TinyUSB hid.h
ONLY KEYS FROM THE NORMAL KEYBOARD AND THE CONSUMER KEYBOARD are supported by default you will have to add any other keyboards yourself. Modifier keys such as CTRL and ALT can only be used with the normal keyboard.
The Code cannot be published pre-compiled because all of the keybinds are set in the code.

If you run into any bugs please open an issue.

Building

For building see:

# Install Dependencies
- name: Install Dependencies
run: |
sudo apt update
sudo apt install git cmake gcc-arm-none-eabi gcc g++ gdb-multiarch automake autoconf build-essential texinfo libtool libftdi-dev libusb-1.0-0-dev minicom openocd
# Setup the SDK
- name: Setup the SDK
run: |
mkdir /home/runner/work/Raspberry-Pi-Pico-MacroPad/Raspberry-Pi-Pico-MacroPad/pico/
git -C /home/runner/work/Raspberry-Pi-Pico-MacroPad/Raspberry-Pi-Pico-MacroPad/pico/ clone https://github.com/raspberrypi/pico-sdk.git
git -C /home/runner/work/Raspberry-Pi-Pico-MacroPad/Raspberry-Pi-Pico-MacroPad/pico/pico-sdk submodule update --init --recursive
# Clone Pimorini's Librarys needed for the code
- name: Clone Pimoroni librarys
run: |
git clone https://github.com/pimoroni/pimoroni-pico.git ./libs/pimoroni-pico
git -C ./libs/pimoroni-pico submodule update --init --recursive
# Builds the code
- name: Build the Code
run: |
export PICO_SDK_PATH='/home/runner/work/Raspberry-Pi-Pico-MacroPad/Raspberry-Pi-Pico-MacroPad/pico/pico-sdk'
mkdir build
cd build
cmake ..
make

If you have not used the Pico SDK before I recommend you read this to get started: https://rptl.io/pico-get-started

Links

The Pi Hut - Raspberry Pi Pico
Pimoroni - Raspberry Pi Pico
Pimoroni - RGB Keypad Base

Testing

This has been tested on:

License

The MIT License (MIT)

Copyright (c) 2022 Joshua Glass (SuperNinja_4965)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

raspberry-pi-pico-macropad's People

Contributors

superninja-4965 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

alussier

raspberry-pi-pico-macropad's Issues

Scroll Lock LED does not function

Scroll Lock LED does not function.
For now the code has been commented.
If anyone knows how to get this working please create a pr or contribute here.

Below is the code that handles status keys:

void tud_hid_set_report_cb(uint8_t instance, uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize)
{
(void) instance;
if (report_type == HID_REPORT_TYPE_OUTPUT)
{
// Set keyboard LED e.g Capslock, Numlock etc...
if (report_id == REPORT_ID_KEYBOARD)
{
// bufsize should be (at least) 1
if ( bufsize < 1 ) return;
uint8_t const kbd_leds = buffer[0];
// Handle Caps Lock
if (kbd_leds & KEYBOARD_LED_CAPSLOCK)
{
if (LockKeysOrigionalColours[0][3] == 0) return;
// Caps lock is on if the user has a caps lock button light the Button light
ColourAssignments[LockKeysOrigionalColours[0][3]][0] = 0x20;
ColourAssignments[LockKeysOrigionalColours[0][3]][1] = 0x20;
ColourAssignments[LockKeysOrigionalColours[0][3]][2] = 0x20;
}else
{
if (LockKeysOrigionalColours[0][3] == 0) return;
// Caps Lock is not on
ColourAssignments[LockKeysOrigionalColours[0][3]][0] = LockKeysOrigionalColours[0][0];
ColourAssignments[LockKeysOrigionalColours[0][3]][1] = LockKeysOrigionalColours[0][1];
ColourAssignments[LockKeysOrigionalColours[0][3]][2] = LockKeysOrigionalColours[0][2];
}
// Handle Num Lock
if (kbd_leds & KEYBOARD_LED_NUMLOCK) {
if (LockKeysOrigionalColours[1][3] == 0) return;
// Numlock is on
ColourAssignments[LockKeysOrigionalColours[1][3]][0] = 0x20;
ColourAssignments[LockKeysOrigionalColours[1][3]][1] = 0x20;
ColourAssignments[LockKeysOrigionalColours[1][3]][2] = 0x20;
} else {
if (LockKeysOrigionalColours[1][3] == 0) return;
// Numlock is off
ColourAssignments[LockKeysOrigionalColours[1][3]][0] = LockKeysOrigionalColours[1][0];
ColourAssignments[LockKeysOrigionalColours[1][3]][1] = LockKeysOrigionalColours[1][1];
ColourAssignments[LockKeysOrigionalColours[1][3]][2] = LockKeysOrigionalColours[1][2];
}
// Handle Scroll Lock
// if (kbd_leds & KEYBOARD_LED_SCROLLLOCK) {
// if (LockKeysOrigionalColours[2][3] == 0) return;
// // Scroll lock is on
// ColourAssignments[LockKeysOrigionalColours[2][3]][0] = 0x20;
// ColourAssignments[LockKeysOrigionalColours[2][3]][1] = 0x20;
// ColourAssignments[LockKeysOrigionalColours[2][3]][2] = 0x20;
// } else {
// if (LockKeysOrigionalColours[2][3] == 0) return;
// // Scroll lock is off
// ColourAssignments[LockKeysOrigionalColours[2][3]][0] = LockKeysOrigionalColours[2][0];
// ColourAssignments[LockKeysOrigionalColours[2][3]][1] = LockKeysOrigionalColours[2][1];
// ColourAssignments[LockKeysOrigionalColours[2][3]][2] = LockKeysOrigionalColours[2][2];
// }
// Set the key colours
PicoKeypad.illuminate(LockKeysOrigionalColours[0][3], ColourAssignments[LockKeysOrigionalColours[0][3]][0], ColourAssignments[LockKeysOrigionalColours[0][3]][1], ColourAssignments[LockKeysOrigionalColours[0][3]][2]);
PicoKeypad.illuminate(LockKeysOrigionalColours[1][3], ColourAssignments[LockKeysOrigionalColours[1][3]][0], ColourAssignments[LockKeysOrigionalColours[1][3]][1], ColourAssignments[LockKeysOrigionalColours[1][3]][2]);
//PicoKeypad.illuminate(LockKeysOrigionalColours[2][3], ColourAssignments[LockKeysOrigionalColours[2][3]][0], ColourAssignments[LockKeysOrigionalColours[2][3]][1], ColourAssignments[LockKeysOrigionalColours[2][3]][2]);
PicoKeypad.update();
}
}
}

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.