mirror of
https://github.com/Ikatono/stream_pad.git
synced 2025-10-29 04:56:01 -05:00
a bunch of misc updates
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1 +1,3 @@
|
||||
*.code-workspace
|
||||
*.code-workspace
|
||||
*.kate-swp
|
||||
build/*
|
||||
|
||||
42
RP2040_Deck_Demo.proto
Normal file
42
RP2040_Deck_Demo.proto
Normal file
@@ -0,0 +1,42 @@
|
||||
syntax = "proto3";
|
||||
|
||||
enum WheelAction {
|
||||
None = 0;
|
||||
Volume = 1;
|
||||
MicVolume = 2;
|
||||
}
|
||||
|
||||
message Pixel {
|
||||
uint32 red = 1;
|
||||
uint32 green = 2;
|
||||
uint32 blue = 3;
|
||||
}
|
||||
|
||||
message Config {
|
||||
message Page {
|
||||
message Button
|
||||
{
|
||||
string button_text = 1;
|
||||
bytes keys = 2;
|
||||
Pixel led = 3;
|
||||
optional uint32 goto_page = 4;
|
||||
optional uint32 action_id = 5;
|
||||
}
|
||||
string page_text = 1;
|
||||
Button button1 = 2;
|
||||
Button button2 = 3;
|
||||
Button button3 = 4;
|
||||
Button button4 = 5;
|
||||
Button button5 = 6;
|
||||
Button button6 = 7;
|
||||
Button button7 = 8;
|
||||
Button button8 = 9;
|
||||
Button button9 = 10;
|
||||
Button button10 = 11;
|
||||
Button button11 = 12;
|
||||
Button button12 = 13;
|
||||
WheelAction wheel_action = 14;
|
||||
}
|
||||
repeated Page pages = 1;
|
||||
optional WheelAction = 2;
|
||||
}
|
||||
49
RP2040_Deck_Demo.yaml
Normal file
49
RP2040_Deck_Demo.yaml
Normal file
@@ -0,0 +1,49 @@
|
||||
#important reference: https://www.usb.org/sites/default/files/hut1_4.pdf
|
||||
|
||||
config:
|
||||
#the
|
||||
pages:
|
||||
#main purpose of the name is for internal reference
|
||||
- name: first_page
|
||||
#action of rotary encoder
|
||||
wheel: volume
|
||||
#text when no key is held
|
||||
text: FIRST PAGE
|
||||
keys:
|
||||
0:
|
||||
#mutes the system speaker
|
||||
#see "System Speaker Mute" under Generic(0x01)
|
||||
action: Mute
|
||||
#text that displays while this key is held
|
||||
#if the key is held, it won't do
|
||||
text: MUTE
|
||||
#color of the LED for this key
|
||||
color: blue
|
||||
#use a number or string for the key, doesn't matter
|
||||
"1":
|
||||
action:
|
||||
#presses each of these keys in sequence, then releases them all
|
||||
- ctrl
|
||||
- alt
|
||||
- del
|
||||
text: TASK MANAGER
|
||||
#specify color in hex
|
||||
color: '0x01ab45'
|
||||
#after performing action (or instead if there is no action), change the page
|
||||
goto: second_page
|
||||
#presumably most pages define all 12 keys
|
||||
- name: second_page
|
||||
wheel: mic_volume
|
||||
text:
|
||||
#use an array of strings to separate lines
|
||||
- SECOND
|
||||
- PAGE
|
||||
keys:
|
||||
0:
|
||||
action:
|
||||
#start a process
|
||||
exec: ./scripts/do_cool_think.sh
|
||||
#optional, used to kill (interact?) with process later
|
||||
name: cool_thing_doer
|
||||
#possible format for decimal RGB
|
||||
color: "12,13,14"
|
||||
11
src/ActionId.hpp
Normal file
11
src/ActionId.hpp
Normal file
@@ -0,0 +1,11 @@
|
||||
#ifndef H_C91B532FD0D0486EAE4B48A326F9CA8C
|
||||
#define H_C91B532FD0D0486EAE4B48A326F9CA8C
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
struct ActionId
|
||||
{
|
||||
uint32_t value;
|
||||
};
|
||||
|
||||
#endif //H_C91B532FD0D0486EAE4B48A326F9CA8C
|
||||
37
src/Button.hpp
Normal file
37
src/Button.hpp
Normal file
@@ -0,0 +1,37 @@
|
||||
#ifndef H_B4D7EE1A3D57466AA444F3FC912641B9
|
||||
#define H_B4D7EE1A3D57466AA444F3FC912641B9
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
#include "Pixel.hpp"
|
||||
#include "ActionId.hpp"
|
||||
|
||||
class Page;
|
||||
|
||||
class Button
|
||||
{
|
||||
friend class Page;
|
||||
|
||||
//text on screen when holding the button
|
||||
std::string hold_text;
|
||||
//series of keycodes pressed in order then all released
|
||||
std::vector<uint8_t> keycodes;
|
||||
//color of this button
|
||||
Pixel color;
|
||||
//is set, make this page active after press
|
||||
Page *goto_page;
|
||||
//for custom actions, this tells the host what to do
|
||||
ActionId action_id;
|
||||
public:
|
||||
Button(Button&& other)
|
||||
{
|
||||
hold_text = std::move(other.hold_text);
|
||||
keycodes = std::move(other.keycodes);
|
||||
color = other.color;
|
||||
goto_page = other.goto_page;
|
||||
action_id = other.action_id;
|
||||
}
|
||||
};
|
||||
|
||||
#endif //H_B4D7EE1A3D57466AA444F3FC912641B9
|
||||
0
src/Config.cpp
Normal file
0
src/Config.cpp
Normal file
17
src/Config.hpp
Normal file
17
src/Config.hpp
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef H_AE095F749CEA4FC29AC38902BC5FD5D1
|
||||
#define H_AE095F749CEA4FC29AC38902BC5FD5D1
|
||||
|
||||
#include <vector>
|
||||
#include "Page.hpp"
|
||||
|
||||
class Config
|
||||
{
|
||||
std::vector<Page> pages;
|
||||
public:
|
||||
Page& page(size_t index)
|
||||
{
|
||||
return pages[index];
|
||||
}
|
||||
};
|
||||
|
||||
#endif //H_AE095F749CEA4FC29AC38902BC5FD5D1
|
||||
9
src/Page.cpp
Normal file
9
src/Page.cpp
Normal file
@@ -0,0 +1,9 @@
|
||||
#include "Page.hpp"
|
||||
|
||||
std::array<Pixel, 12> Page::led_rgb;
|
||||
|
||||
void Page::update_leds()
|
||||
{
|
||||
for (int i = 0; i < 12; i++)
|
||||
led_rgb[i] = buttons[i].color;
|
||||
}
|
||||
21
src/Page.hpp
Normal file
21
src/Page.hpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#ifndef H_1AAB801F01BA49D0BB2AAB917C307E50
|
||||
#define H_1AAB801F01BA49D0BB2AAB917C307E50
|
||||
|
||||
#include <array>
|
||||
#include "Button.hpp"
|
||||
|
||||
class Page
|
||||
{
|
||||
static std::array<Pixel, 12> led_rgb;
|
||||
std::array<Button, 12> buttons;
|
||||
std::string distplay_text;
|
||||
public:
|
||||
Page(Page&& other) : buttons(std::move(other.buttons)) { }
|
||||
void update_leds();
|
||||
Button& button(std::size_t index)
|
||||
{
|
||||
return buttons[index];
|
||||
}
|
||||
};
|
||||
|
||||
#endif //H_1AAB801F01BA49D0BB2AAB917C307E50
|
||||
24
src/Pixel.hpp
Normal file
24
src/Pixel.hpp
Normal file
@@ -0,0 +1,24 @@
|
||||
#ifndef H_FF2FF9A6BC114C719F44441B6FD238C2
|
||||
#define H_FF2FF9A6BC114C719F44441B6FD238C2
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
struct Pixel
|
||||
{
|
||||
uint32_t value;
|
||||
//should check for endianness I think
|
||||
//but there is no fully compliant way to test at compile time
|
||||
#if defined(__BYTE_ORDER__)&&(__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
|
||||
uint8_t& green() { return *(reinterpret_cast<uint8_t*>(value)+0); }
|
||||
uint8_t& red() { return *(reinterpret_cast<uint8_t*>(value)+1); }
|
||||
uint8_t& blue() { return *(reinterpret_cast<uint8_t*>(value)+2); }
|
||||
uint8_t& white() { return *(reinterpret_cast<uint8_t*>(value)+3); }
|
||||
#else
|
||||
uint8_t& green() { return *(reinterpret_cast<uint8_t*>(value)+3); }
|
||||
uint8_t& red() { return *(reinterpret_cast<uint8_t*>(value)+2); }
|
||||
uint8_t& blue() { return *(reinterpret_cast<uint8_t*>(value)+1); }
|
||||
uint8_t& white() { return *(reinterpret_cast<uint8_t*>(value)+0); }
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif //H_FF2FF9A6BC114C719F44441B6FD238C2
|
||||
Reference in New Issue
Block a user