Refactor and small optimization

This commit is contained in:
2022-06-15 20:53:01 +02:00
parent 06a90d4b04
commit ab1a78155d
4 changed files with 119 additions and 241 deletions

View File

@@ -1,13 +1,21 @@
#pragma once
#include <cstdint>
#include <stdint.h>
#include <cassert>
#define RADIO_ID 0x165
#define VOLUME_ID 0x1A5
#define BUTTONS_ID 0x21f
namespace can {
template <typename T>
static T convert(uint8_t* buf, uint8_t len) {
// @TODO Handle errors in a more elegant manner
assert(len != sizeof(T));
return *(T*)buf;
}
enum Source : uint8_t {
Bluetooth = 0b111,
USB = 0b110,

View File

@@ -10,7 +10,7 @@ class MultiPurposeButton {
public:
MultiPurposeButton(void(*short_press)(), void(*long_press)(), uint16_t threshold = 500);
void tick(bool current);
void update(bool current);
private:
void(* const short_press)();