-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathconfig.hpp
113 lines (97 loc) · 3.46 KB
/
config.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#ifndef CONFIG_CPP
#define CONFIG_CPP
#include "types.hpp"
#include <U8g2lib.h>
#include <cstddef>
#include <driver/gpio.h>
#include <driver/spi_master.h>
#include <string>
#include <unordered_map>
#include <vector>
#define COMPONENTS_IN_MESH 1 // n - 1
// #include <nlohmann/json.hpp>
// for convenience
// using json = nlohmann::json;
// layer_t c({{s, b}});
// layout keycode (16 bits):
//- 8 bits of keycodes
//- 4 bits of layer info
//- 4 bits of special keys
#define LAYER_TAP 0b0001
#define MOD_TAP 0b0010
#define ONESHOT 0b0011
// TODO: move these to a "normal" key range
// TODO: check if this define does not cause an issue
#define KC_SLEEP 0x88
#define KC_TRNS 0x89
#define LAYER_TAP_DELAY_MS 150
#define ONESHOT_TIMEOUT 100
// read layer, shift it in the 4 bits of layer
#define LT(layer, kc) (kc | (LAYER_TAP << 12) | ((layer & 0xF) << 8))
// mods start from > 128. This is outside the common ascii range
// We only look at the first 6 bits and shift it into the proper range
#define MT(mod, kc) (kc | (MOD_TAP << 12) | (((mod)&0x1F) << 8))
// --- Configuration ---
// TODO: tmp defs to use the features
// #define USE_SLEEP
#define USE_ENCODER
#define USE_LED
#define USE_OLED
// battery voltage divider
#define R1 100.0 // in kOhm
#define R2 100.0 // in kOhm
#define ADC_REF 1.1 // V
#define VMAX 4200.0 // mV
#define VMIN 3300.0 // mV
#define VTOADC(in) ((ADC_REF * (in) / 4096.0))
#define VOUT(vin) (((vin)*R2) / (R1 + R2)) // conversion to dividor voltage
#define BAT_MAX_ADC VTOADC(VOUT(VMAX))
#define BAT_MIN_ADC VTOADC(VOUT(VMIN))
class Config { // see constructor in cpp file
public:
Config();
// pin configuration
std::vector<uint8_t> col_pins = {18, 23, 19, 22, 21, 26};
std::vector<uint8_t> row_pins = {0, 13, 12, 14, 27};
std::string scan_source = "col"; // diode direction
// battery pin
// IMPORTANT: the pin needs to be connected to a voltage divider
// Connecting the battery directly to a pin, will damage the GPIO.
// Any ADC pin can be used.
static const uint8_t batt_pin = 37;
// deep sleep settings
const size_t deep_sleep_timeout = 10;
// 300000; // 5 minutes
// const size_t deep_sleep_timeout = 3000; // 5 minutes
// led settings
static const uint8_t led_pin = 25;
uint8_t num_led = 27;
std::vector<uint8_t> led_col_bins = {0, 5, 10, 15,
19, 23, 27}; // count from the LED11 pin
// add the final number of
// keys for good binning
std::vector<uint8_t> frame_buffer = std::vector<uint8_t>(num_led, 0);
std::vector<uint8_t> draw_buffer = std::vector<uint8_t>(num_led, 0);
// info advertising bluetooth
std::string device_manufacturer = "Casper van Elteren";
std::string device_name = "SplitBoard";
// display settings
std::string name = "SplitBoard";
uint8_t pin_sda = GPIO_NUM_4;
uint8_t pin_scl = GPIO_NUM_15;
uint8_t pin_reset = GPIO_NUM_16;
// rotation 0 is horizontal
const u8g2_cb_t *display_rotation = U8G2_R3;
uint baud_rate = 115200;
uint8_t rot_a_pin = 17;
uint8_t rot_b_pin = 5;
uint8_t rot_button_pin = 37;
uint8_t rot_output_pin = 0; // set to -1 to use vcc
uint8_t rot_encoder_steps = 4;
uint8_t rot_accel = 250;
// change this for your device
uint8_t serv_add[6] = {0x80, 0x7D, 0x3A, 0xD4, 0x2C, 0x9E};
// uint8_t serv_add[6] = {0x80, 0x7D, 0x3A, 0xD4, 0x2C, 0x9E};
// uint8_t serv_add[6] = {0x7C, 0x9E, 0xBD, 0xFB, 0xD9, 0x7A};
};
#endif