bunch of updates

This commit is contained in:
2024-01-18 23:54:57 -06:00
parent 266c262ff5
commit dda3344a7f
11 changed files with 399 additions and 5 deletions

4
.gitignore vendored
View File

@@ -1,3 +1,7 @@
*.code-workspace
*.kate-swp
build/*
#these are the generated source files for the embedded protobuf
src/protogen/*
#python virtual environment
*/venv/*

View File

@@ -1,4 +1,5 @@
syntax = "proto3";
package Messaging;
enum WheelAction {
None = 0;
@@ -38,5 +39,4 @@ message Config {
WheelAction wheel_action = 14;
}
repeated Page pages = 1;
optional WheelAction wheel_action = 2;
}

View File

@@ -3,9 +3,12 @@
#include <cstdint>
namespace Configuration
{
struct ActionId
{
uint32_t value;
};
}
#endif //H_C91B532FD0D0486EAE4B48A326F9CA8C

View File

@@ -6,7 +6,10 @@
#include <cstdint>
#include "Pixel.hpp"
#include "ActionId.hpp"
#include "ProtoConfig.h"
namespace Configuration
{
class Page;
class Button
@@ -24,7 +27,28 @@ class Button
//for custom actions, this tells the host what to do
ActionId action_id;
public:
Button(Button&& other)
inline Button()
{
}
inline Button(const Button& other)
{
hold_text = other.hold_text;
keycodes = other.keycodes;
color = other.color;
goto_page = other.goto_page;
action_id = other.action_id;
}
inline Button& operator=(const Button& other)
{
hold_text = other.hold_text;
keycodes = other.keycodes;
color = other.color;
goto_page = other.goto_page;
action_id = other.action_id;
return *this;
}
inline Button(Button&& other)
{
hold_text = std::move(other.hold_text);
keycodes = std::move(other.keycodes);
@@ -32,6 +56,100 @@ class Button
goto_page = other.goto_page;
action_id = other.action_id;
}
template<
uint32_t Config_pages_REP_LENGTH,
uint32_t Config_pages_Page_page_text_LENGTH,
uint32_t Config_pages_Page_button1_Button_button_text_LENGTH,
uint32_t Config_pages_Page_button1_Button_keys_LENGTH,
uint32_t Config_pages_Page_button2_Button_button_text_LENGTH,
uint32_t Config_pages_Page_button2_Button_keys_LENGTH,
uint32_t Config_pages_Page_button3_Button_button_text_LENGTH,
uint32_t Config_pages_Page_button3_Button_keys_LENGTH,
uint32_t Config_pages_Page_button4_Button_button_text_LENGTH,
uint32_t Config_pages_Page_button4_Button_keys_LENGTH,
uint32_t Config_pages_Page_button5_Button_button_text_LENGTH,
uint32_t Config_pages_Page_button5_Button_keys_LENGTH,
uint32_t Config_pages_Page_button6_Button_button_text_LENGTH,
uint32_t Config_pages_Page_button6_Button_keys_LENGTH,
uint32_t Config_pages_Page_button7_Button_button_text_LENGTH,
uint32_t Config_pages_Page_button7_Button_keys_LENGTH,
uint32_t Config_pages_Page_button8_Button_button_text_LENGTH,
uint32_t Config_pages_Page_button8_Button_keys_LENGTH,
uint32_t Config_pages_Page_button9_Button_button_text_LENGTH,
uint32_t Config_pages_Page_button9_Button_keys_LENGTH,
uint32_t Config_pages_Page_button10_Button_button_text_LENGTH,
uint32_t Config_pages_Page_button10_Button_keys_LENGTH,
uint32_t Config_pages_Page_button11_Button_button_text_LENGTH,
uint32_t Config_pages_Page_button11_Button_keys_LENGTH,
uint32_t Config_pages_Page_button12_Button_button_text_LENGTH,
uint32_t Config_pages_Page_button12_Button_keys_LENGTH>
void load(const typename Messaging::Config<Config_pages_REP_LENGTH,
Config_pages_Page_page_text_LENGTH,
Config_pages_Page_button1_Button_button_text_LENGTH,
Config_pages_Page_button1_Button_keys_LENGTH,
Config_pages_Page_button2_Button_button_text_LENGTH,
Config_pages_Page_button2_Button_keys_LENGTH,
Config_pages_Page_button3_Button_button_text_LENGTH,
Config_pages_Page_button3_Button_keys_LENGTH,
Config_pages_Page_button4_Button_button_text_LENGTH,
Config_pages_Page_button4_Button_keys_LENGTH,
Config_pages_Page_button5_Button_button_text_LENGTH,
Config_pages_Page_button5_Button_keys_LENGTH,
Config_pages_Page_button6_Button_button_text_LENGTH,
Config_pages_Page_button6_Button_keys_LENGTH,
Config_pages_Page_button7_Button_button_text_LENGTH,
Config_pages_Page_button7_Button_keys_LENGTH,
Config_pages_Page_button8_Button_button_text_LENGTH,
Config_pages_Page_button8_Button_keys_LENGTH,
Config_pages_Page_button9_Button_button_text_LENGTH,
Config_pages_Page_button9_Button_keys_LENGTH,
Config_pages_Page_button10_Button_button_text_LENGTH,
Config_pages_Page_button10_Button_keys_LENGTH,
Config_pages_Page_button11_Button_button_text_LENGTH,
Config_pages_Page_button11_Button_keys_LENGTH,
Config_pages_Page_button12_Button_button_text_LENGTH,
Config_pages_Page_button12_Button_keys_LENGTH>::Page
<Config_pages_Page_page_text_LENGTH,
Config_pages_Page_button1_Button_button_text_LENGTH,
Config_pages_Page_button1_Button_keys_LENGTH,
Config_pages_Page_button2_Button_button_text_LENGTH,
Config_pages_Page_button2_Button_keys_LENGTH,
Config_pages_Page_button3_Button_button_text_LENGTH,
Config_pages_Page_button3_Button_keys_LENGTH,
Config_pages_Page_button4_Button_button_text_LENGTH,
Config_pages_Page_button4_Button_keys_LENGTH,
Config_pages_Page_button5_Button_button_text_LENGTH,
Config_pages_Page_button5_Button_keys_LENGTH,
Config_pages_Page_button6_Button_button_text_LENGTH,
Config_pages_Page_button6_Button_keys_LENGTH,
Config_pages_Page_button7_Button_button_text_LENGTH,
Config_pages_Page_button7_Button_keys_LENGTH,
Config_pages_Page_button8_Button_button_text_LENGTH,
Config_pages_Page_button8_Button_keys_LENGTH,
Config_pages_Page_button9_Button_button_text_LENGTH,
Config_pages_Page_button9_Button_keys_LENGTH,
Config_pages_Page_button10_Button_button_text_LENGTH,
Config_pages_Page_button10_Button_keys_LENGTH,
Config_pages_Page_button11_Button_button_text_LENGTH,
Config_pages_Page_button11_Button_keys_LENGTH,
Config_pages_Page_button12_Button_button_text_LENGTH,
Config_pages_Page_button12_Button_keys_LENGTH>::Button
<Config_pages_Page_button1_Button_button_text_LENGTH,
Config_pages_Page_button1_Button_keys_LENGTH> &ser)
{
hold_text.assign(ser.button_text());
for (int i = 0; i++; i < ser.get_keys().get_length())
keycodes.emplace_back(ser.get_keys()[i]);
{
auto c = ser.get_led();
color.red() = static_cast<uint8_t>(c.get_red());
color.green() = static_cast<uint8_t>(c.get_green());
color.blue() = static_cast<uint8_t>(c.get_blue());
}
//goto_page = ser.get_goto_page();
action_id.value = ser.get_action_id();
}
};
}
#endif //H_B4D7EE1A3D57466AA444F3FC912641B9

View File

@@ -0,0 +1,6 @@
#include "Config.hpp"
namespace Configuration
{
}

View File

@@ -3,7 +3,10 @@
#include <vector>
#include "Page.hpp"
#include "ProtoConfig.h"
namespace Configuration
{
class Config
{
std::vector<Page> pages;
@@ -12,6 +15,100 @@ class Config
{
return pages[index];
}
void append(const Page& new_page)
{
pages.push_back(new_page);
}
template<
uint32_t Config_pages_REP_LENGTH,
uint32_t Config_pages_Page_page_text_LENGTH,
uint32_t Config_pages_Page_button1_Button_button_text_LENGTH,
uint32_t Config_pages_Page_button1_Button_keys_LENGTH,
uint32_t Config_pages_Page_button2_Button_button_text_LENGTH,
uint32_t Config_pages_Page_button2_Button_keys_LENGTH,
uint32_t Config_pages_Page_button3_Button_button_text_LENGTH,
uint32_t Config_pages_Page_button3_Button_keys_LENGTH,
uint32_t Config_pages_Page_button4_Button_button_text_LENGTH,
uint32_t Config_pages_Page_button4_Button_keys_LENGTH,
uint32_t Config_pages_Page_button5_Button_button_text_LENGTH,
uint32_t Config_pages_Page_button5_Button_keys_LENGTH,
uint32_t Config_pages_Page_button6_Button_button_text_LENGTH,
uint32_t Config_pages_Page_button6_Button_keys_LENGTH,
uint32_t Config_pages_Page_button7_Button_button_text_LENGTH,
uint32_t Config_pages_Page_button7_Button_keys_LENGTH,
uint32_t Config_pages_Page_button8_Button_button_text_LENGTH,
uint32_t Config_pages_Page_button8_Button_keys_LENGTH,
uint32_t Config_pages_Page_button9_Button_button_text_LENGTH,
uint32_t Config_pages_Page_button9_Button_keys_LENGTH,
uint32_t Config_pages_Page_button10_Button_button_text_LENGTH,
uint32_t Config_pages_Page_button10_Button_keys_LENGTH,
uint32_t Config_pages_Page_button11_Button_button_text_LENGTH,
uint32_t Config_pages_Page_button11_Button_keys_LENGTH,
uint32_t Config_pages_Page_button12_Button_button_text_LENGTH,
uint32_t Config_pages_Page_button12_Button_keys_LENGTH>
void load(const Messaging::Config<
Config_pages_REP_LENGTH,
Config_pages_Page_page_text_LENGTH,
Config_pages_Page_button1_Button_button_text_LENGTH,
Config_pages_Page_button1_Button_keys_LENGTH,
Config_pages_Page_button2_Button_button_text_LENGTH,
Config_pages_Page_button2_Button_keys_LENGTH,
Config_pages_Page_button3_Button_button_text_LENGTH,
Config_pages_Page_button3_Button_keys_LENGTH,
Config_pages_Page_button4_Button_button_text_LENGTH,
Config_pages_Page_button4_Button_keys_LENGTH,
Config_pages_Page_button5_Button_button_text_LENGTH,
Config_pages_Page_button5_Button_keys_LENGTH,
Config_pages_Page_button6_Button_button_text_LENGTH,
Config_pages_Page_button6_Button_keys_LENGTH,
Config_pages_Page_button7_Button_button_text_LENGTH,
Config_pages_Page_button7_Button_keys_LENGTH,
Config_pages_Page_button8_Button_button_text_LENGTH,
Config_pages_Page_button8_Button_keys_LENGTH,
Config_pages_Page_button9_Button_button_text_LENGTH,
Config_pages_Page_button9_Button_keys_LENGTH,
Config_pages_Page_button10_Button_button_text_LENGTH,
Config_pages_Page_button10_Button_keys_LENGTH,
Config_pages_Page_button11_Button_button_text_LENGTH,
Config_pages_Page_button11_Button_keys_LENGTH,
Config_pages_Page_button12_Button_button_text_LENGTH,
Config_pages_Page_button12_Button_keys_LENGTH> &ser)
{
auto _pages = ser.get_pages();
for (uint32_t i = 0; i++; i < _pages.get_length())
{
pages.emplace_back(Page());
pages.back().load<
Config_pages_REP_LENGTH,
Config_pages_Page_page_text_LENGTH,
Config_pages_Page_button1_Button_button_text_LENGTH,
Config_pages_Page_button1_Button_keys_LENGTH,
Config_pages_Page_button2_Button_button_text_LENGTH,
Config_pages_Page_button2_Button_keys_LENGTH,
Config_pages_Page_button3_Button_button_text_LENGTH,
Config_pages_Page_button3_Button_keys_LENGTH,
Config_pages_Page_button4_Button_button_text_LENGTH,
Config_pages_Page_button4_Button_keys_LENGTH,
Config_pages_Page_button5_Button_button_text_LENGTH,
Config_pages_Page_button5_Button_keys_LENGTH,
Config_pages_Page_button6_Button_button_text_LENGTH,
Config_pages_Page_button6_Button_keys_LENGTH,
Config_pages_Page_button7_Button_button_text_LENGTH,
Config_pages_Page_button7_Button_keys_LENGTH,
Config_pages_Page_button8_Button_button_text_LENGTH,
Config_pages_Page_button8_Button_keys_LENGTH,
Config_pages_Page_button9_Button_button_text_LENGTH,
Config_pages_Page_button9_Button_keys_LENGTH,
Config_pages_Page_button10_Button_button_text_LENGTH,
Config_pages_Page_button10_Button_keys_LENGTH,
Config_pages_Page_button11_Button_button_text_LENGTH,
Config_pages_Page_button11_Button_keys_LENGTH,
Config_pages_Page_button12_Button_button_text_LENGTH,
Config_pages_Page_button12_Button_keys_LENGTH>
(_pages.get_const(i));
}
}
};
}
#endif //H_AE095F749CEA4FC29AC38902BC5FD5D1

View File

@@ -1,5 +1,7 @@
#include "Page.hpp"
namespace Configuration
{
std::array<Pixel, 12> Page::led_rgb;
void Page::update_leds()
@@ -7,3 +9,4 @@ void Page::update_leds()
for (int i = 0; i < 12; i++)
led_rgb[i] = buttons[i].color;
}
}

View File

@@ -3,19 +3,136 @@
#include <array>
#include "Button.hpp"
#include "ProtoConfig.h"
namespace Configuration
{
class Page
{
static std::array<Pixel, 12> led_rgb;
std::array<Button, 12> buttons;
std::string distplay_text;
std::string display_text;
public:
Page(Page&& other) : buttons(std::move(other.buttons)) { }
inline Page() { }
inline Page(const Page& other)
{
buttons = other.buttons;
display_text = other.display_text;
}
inline Page(Page&& other) : buttons(std::move(other.buttons)) { }
template<
uint32_t Config_pages_REP_LENGTH,
uint32_t Config_pages_Page_page_text_LENGTH,
uint32_t Config_pages_Page_button1_Button_button_text_LENGTH,
uint32_t Config_pages_Page_button1_Button_keys_LENGTH,
uint32_t Config_pages_Page_button2_Button_button_text_LENGTH,
uint32_t Config_pages_Page_button2_Button_keys_LENGTH,
uint32_t Config_pages_Page_button3_Button_button_text_LENGTH,
uint32_t Config_pages_Page_button3_Button_keys_LENGTH,
uint32_t Config_pages_Page_button4_Button_button_text_LENGTH,
uint32_t Config_pages_Page_button4_Button_keys_LENGTH,
uint32_t Config_pages_Page_button5_Button_button_text_LENGTH,
uint32_t Config_pages_Page_button5_Button_keys_LENGTH,
uint32_t Config_pages_Page_button6_Button_button_text_LENGTH,
uint32_t Config_pages_Page_button6_Button_keys_LENGTH,
uint32_t Config_pages_Page_button7_Button_button_text_LENGTH,
uint32_t Config_pages_Page_button7_Button_keys_LENGTH,
uint32_t Config_pages_Page_button8_Button_button_text_LENGTH,
uint32_t Config_pages_Page_button8_Button_keys_LENGTH,
uint32_t Config_pages_Page_button9_Button_button_text_LENGTH,
uint32_t Config_pages_Page_button9_Button_keys_LENGTH,
uint32_t Config_pages_Page_button10_Button_button_text_LENGTH,
uint32_t Config_pages_Page_button10_Button_keys_LENGTH,
uint32_t Config_pages_Page_button11_Button_button_text_LENGTH,
uint32_t Config_pages_Page_button11_Button_keys_LENGTH,
uint32_t Config_pages_Page_button12_Button_button_text_LENGTH,
uint32_t Config_pages_Page_button12_Button_keys_LENGTH>
void load(const typename Messaging::Config<Config_pages_REP_LENGTH,
Config_pages_Page_page_text_LENGTH,
Config_pages_Page_button1_Button_button_text_LENGTH,
Config_pages_Page_button1_Button_keys_LENGTH,
Config_pages_Page_button2_Button_button_text_LENGTH,
Config_pages_Page_button2_Button_keys_LENGTH,
Config_pages_Page_button3_Button_button_text_LENGTH,
Config_pages_Page_button3_Button_keys_LENGTH,
Config_pages_Page_button4_Button_button_text_LENGTH,
Config_pages_Page_button4_Button_keys_LENGTH,
Config_pages_Page_button5_Button_button_text_LENGTH,
Config_pages_Page_button5_Button_keys_LENGTH,
Config_pages_Page_button6_Button_button_text_LENGTH,
Config_pages_Page_button6_Button_keys_LENGTH,
Config_pages_Page_button7_Button_button_text_LENGTH,
Config_pages_Page_button7_Button_keys_LENGTH,
Config_pages_Page_button8_Button_button_text_LENGTH,
Config_pages_Page_button8_Button_keys_LENGTH,
Config_pages_Page_button9_Button_button_text_LENGTH,
Config_pages_Page_button9_Button_keys_LENGTH,
Config_pages_Page_button10_Button_button_text_LENGTH,
Config_pages_Page_button10_Button_keys_LENGTH,
Config_pages_Page_button11_Button_button_text_LENGTH,
Config_pages_Page_button11_Button_keys_LENGTH,
Config_pages_Page_button12_Button_button_text_LENGTH,
Config_pages_Page_button12_Button_keys_LENGTH>::Page
<Config_pages_Page_page_text_LENGTH,
Config_pages_Page_button1_Button_button_text_LENGTH,
Config_pages_Page_button1_Button_keys_LENGTH,
Config_pages_Page_button2_Button_button_text_LENGTH,
Config_pages_Page_button2_Button_keys_LENGTH,
Config_pages_Page_button3_Button_button_text_LENGTH,
Config_pages_Page_button3_Button_keys_LENGTH,
Config_pages_Page_button4_Button_button_text_LENGTH,
Config_pages_Page_button4_Button_keys_LENGTH,
Config_pages_Page_button5_Button_button_text_LENGTH,
Config_pages_Page_button5_Button_keys_LENGTH,
Config_pages_Page_button6_Button_button_text_LENGTH,
Config_pages_Page_button6_Button_keys_LENGTH,
Config_pages_Page_button7_Button_button_text_LENGTH,
Config_pages_Page_button7_Button_keys_LENGTH,
Config_pages_Page_button8_Button_button_text_LENGTH,
Config_pages_Page_button8_Button_keys_LENGTH,
Config_pages_Page_button9_Button_button_text_LENGTH,
Config_pages_Page_button9_Button_keys_LENGTH,
Config_pages_Page_button10_Button_button_text_LENGTH,
Config_pages_Page_button10_Button_keys_LENGTH,
Config_pages_Page_button11_Button_button_text_LENGTH,
Config_pages_Page_button11_Button_keys_LENGTH,
Config_pages_Page_button12_Button_button_text_LENGTH,
Config_pages_Page_button12_Button_keys_LENGTH> &ser)
{
buttons[0].load<Config_pages_REP_LENGTH,
Config_pages_Page_page_text_LENGTH,
Config_pages_Page_button1_Button_button_text_LENGTH,
Config_pages_Page_button1_Button_keys_LENGTH,
Config_pages_Page_button2_Button_button_text_LENGTH,
Config_pages_Page_button2_Button_keys_LENGTH,
Config_pages_Page_button3_Button_button_text_LENGTH,
Config_pages_Page_button3_Button_keys_LENGTH,
Config_pages_Page_button4_Button_button_text_LENGTH,
Config_pages_Page_button4_Button_keys_LENGTH,
Config_pages_Page_button5_Button_button_text_LENGTH,
Config_pages_Page_button5_Button_keys_LENGTH,
Config_pages_Page_button6_Button_button_text_LENGTH,
Config_pages_Page_button6_Button_keys_LENGTH,
Config_pages_Page_button7_Button_button_text_LENGTH,
Config_pages_Page_button7_Button_keys_LENGTH,
Config_pages_Page_button8_Button_button_text_LENGTH,
Config_pages_Page_button8_Button_keys_LENGTH,
Config_pages_Page_button9_Button_button_text_LENGTH,
Config_pages_Page_button9_Button_keys_LENGTH,
Config_pages_Page_button10_Button_button_text_LENGTH,
Config_pages_Page_button10_Button_keys_LENGTH,
Config_pages_Page_button11_Button_button_text_LENGTH,
Config_pages_Page_button11_Button_keys_LENGTH,
Config_pages_Page_button12_Button_button_text_LENGTH,
Config_pages_Page_button12_Button_keys_LENGTH>
(ser.get_button1());
}
void update_leds();
Button& button(std::size_t index)
{
return buttons[index];
}
};
}
#endif //H_1AAB801F01BA49D0BB2AAB917C307E50

View File

@@ -3,6 +3,8 @@
#include <cstdint>
namespace Configuration
{
struct Pixel
{
uint32_t value;
@@ -20,5 +22,6 @@ struct Pixel
uint8_t& white() { return *(reinterpret_cast<uint8_t*>(value)+0); }
#endif
};
}
#endif //H_FF2FF9A6BC114C719F44441B6FD238C2

43
src/main.cpp Normal file
View File

@@ -0,0 +1,43 @@
#include "Config.hpp"
#include "Page.hpp"
#include "ProtoConfig.h"
#include "ReadBufferInterface.h"
#include "ReadBufferFixedSize.h"
//#include <stdio.h>
#include "pico/stdlib.h"
#include <cstring>
constexpr uint32_t MAX_KEY_PRESSES = 5;
constexpr uint32_t MAX_STR_LENGTH = 50;
constexpr uint32_t MAX_PAGES = 12;
constexpr uint32_t BUFFER_SIZE = 1024;
using ConfigDeser = Messaging::Config<MAX_PAGES, MAX_STR_LENGTH, MAX_STR_LENGTH,
MAX_KEY_PRESSES, MAX_STR_LENGTH, MAX_KEY_PRESSES, MAX_STR_LENGTH,
MAX_KEY_PRESSES, MAX_STR_LENGTH, MAX_KEY_PRESSES, MAX_STR_LENGTH,
MAX_KEY_PRESSES, MAX_STR_LENGTH, MAX_KEY_PRESSES, MAX_STR_LENGTH,
MAX_KEY_PRESSES, MAX_STR_LENGTH, MAX_KEY_PRESSES, MAX_STR_LENGTH,
MAX_KEY_PRESSES, MAX_STR_LENGTH, MAX_KEY_PRESSES, MAX_STR_LENGTH,
MAX_KEY_PRESSES, MAX_STR_LENGTH, MAX_KEY_PRESSES>;
Configuration::Config config;
Configuration::Page *active_page;
char config_buffer[1024];
extern "C"
int main()
{
stdio_init_all();
{
EmbeddedProto::ReadBufferFixedSize<BUFFER_SIZE> buffer;
ConfigDeser config_message;
if (!gets(reinterpret_cast<char*>(buffer.get_data())))
{
//read failed
}
buffer.set_bytes_written(std::strlen(reinterpret_cast<char*>(buffer.get_data())));
config_message.deserialize(buffer);
config.load(config_message);
}
while (true);
}