Skip to content

Commit 5e56c0b

Browse files
committed
wip: would be nice to have it working someday
1 parent 9dd4144 commit 5e56c0b

5 files changed

Lines changed: 35 additions & 12 deletions

File tree

firmware/esp32-s3/main/macrolev.c

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ struct key_config default_key_config = {
1414
.switch_magnetic_profile_id = 0,
1515
},
1616
.deadzones = {
17-
.start_offset = 0,
18-
.end_offset = 0,
17+
.top_offset = 0,
18+
.bottom_offset = 0,
1919
},
2020
.actuation_distance = 128,
2121
.release_distance = 50,
@@ -34,9 +34,9 @@ struct key_config default_key_config = {
3434
} }
3535
};
3636

37-
struct user_config config;
38-
39-
uint8_t is_calibrating;
37+
struct user_config config = {
38+
.key_configs_length = 1,
39+
};
4040

4141
// store it into a matrix ??
4242
// store it into a matrix ??
@@ -57,7 +57,11 @@ void init_config() {
5757

5858
for (uint8_t i = 0; i < config.key_configs_length; i++) {
5959
config.key_configs[i] = default_key_config;
60-
config.key_configs[i].layers[0].keycodes[0] = default_keycode;
60+
for (uint8_t j = 0; j < config.key_configs[i].layers_length; j++) {
61+
for (uint8_t k = 0; k < config.key_configs[i].layers[j].keycodes_length; k++) {
62+
config.key_configs[i].layers[j].keycodes[k] = default_keycode;
63+
}
64+
}
6165
}
6266
};
6367

@@ -77,17 +81,26 @@ void init_key_states() {
7781
};
7882

7983
void mlev_set_switch_value(uint8_t adc_channel, uint8_t amux_channel, uint32_t value) {
80-
84+
for (uint8_t i = 0; i < config.key_configs_length; i++) {
85+
if (config.key_configs[i].hardware.adc_channel == adc_channel && config.key_configs[i].hardware.mux_channel == amux_channel) {
86+
key_states[i].raw_adc_value = value;
87+
break;
88+
}
89+
}
8190
};
8291

8392
void mlev_init() {
8493
// check config present
8594
// check config validity (version ?)
8695
// calibrate switches
96+
97+
init_config();
98+
init_key_states();
8799
};
88100

89101
void mlev_task() {
90102
// tud_task
91103
// update keys states
92104
// send hid reports
105+
93106
};

firmware/esp32-s3/main/macrolev.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ enum magnet_direction {
1717
};
1818

1919
struct deadzones {
20-
uint8_t start_offset;
21-
uint8_t end_offset;
20+
uint8_t top_offset;
21+
uint8_t bottom_offset;
2222
};
2323

2424
struct rapid_trigger {

firmware/esp32-s3/main/main.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#include "config_storage.h"
22
#include "esp_log.h"
33
#include "freertos/FreeRTOS.h"
4+
#include "macrolev.h"
5+
#include "sensors.h"
46
#include "usb.h"
57
#include <stdio.h>
68
#include <string.h>
@@ -18,11 +20,10 @@
1820

1921
static const char *TAG = "MACROLEV";
2022

21-
#define BOOT_MODE_PIN GPIO_NUM_0
22-
2323
void app_main(void) {
2424
usb_init();
25-
config_storage_init();
25+
sensors_init();
26+
mlev_init();
2627

2728
// Main loop
2829
while (1) {

firmware/esp32-s3/main/sensors.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "freertos/task.h"
77
#include "macrolev.h"
88
#include "sdkconfig.h"
9+
#include <sensors.h>
910
#include <stdio.h>
1011
#include <string.h>
1112

@@ -166,6 +167,11 @@ void adc_task(void *pvParameters) {
166167
}
167168
}
168169

170+
void sensors_init() {
171+
gpio_init();
172+
adc_init();
173+
}
174+
169175
// void debug_task(void *pvParameters) {
170176
// while (1) {
171177
// printf("\033[H\033[J");

firmware/esp32-s3/main/sensors.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#pragma once
2+
3+
void sensors_init();

0 commit comments

Comments
 (0)