Touch map in config

This commit is contained in:
whowechina 2024-04-05 11:12:53 +08:00
parent 329e6a20da
commit c026cee40a
6 changed files with 24 additions and 14 deletions

View File

@ -66,7 +66,7 @@ static void disp_hid()
static void disp_aime()
{
printf("[AIME]\n");
printf(" Virtual AIC: %s\n", mai_cfg->virtual_aic ? "ON" : "OFF");
printf(" Virtual AIC: %s\n", mai_cfg->aime.virtual_aic ? "ON" : "OFF");
}
static void disp_gpio()
@ -471,9 +471,9 @@ static void handle_virtual(int argc, char *argv[])
return;
}
mai_cfg->virtual_aic = (match == 0);
mai_cfg->aime.virtual_aic = (match == 0);
aime_virtual_aic(mai_cfg->virtual_aic);
aime_virtual_aic(mai_cfg->aime.virtual_aic);
config_changed();
}

View File

@ -8,6 +8,7 @@
#include "config.h"
#include "save.h"
#include "touch.h"
mai_cfg_t *mai_cfg;
@ -32,8 +33,11 @@ static mai_cfg_t default_cfg = {
},
.alt = {
.buttons = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
.touch = TOUCH_MAP,
},
.virtual_aic = false,
.aime = {
.virtual_aic = false,
}
};
mai_runtime_t *mai_runtime;

View File

@ -9,6 +9,8 @@
#include <stdint.h>
#include <stdbool.h>
#include "board_defs.h"
typedef struct __attribute__((packed)) {
struct {
uint32_t key_on;
@ -32,8 +34,11 @@ typedef struct __attribute__((packed)) {
} rgb;
struct {
uint8_t buttons[12];
uint8_t touch[34];
} alt;
bool virtual_aic;
struct {
bool virtual_aic;
} aime;
} mai_cfg_t;
typedef struct {

View File

@ -131,7 +131,7 @@ void init()
nfc_attach_i2c(I2C_PORT);
nfc_init();
aime_init(cdc_aime_putc);
aime_virtual_aic(mai_cfg->virtual_aic);
aime_virtual_aic(mai_cfg->aime.virtual_aic);
cli_init("mai_pico>", "\n << Mai Pico Controller >>\n"
" https://github.com/whowechina\n\n");

View File

@ -25,14 +25,7 @@
static uint16_t touch[3];
static unsigned touch_counts[36];
enum touch_pads {
A1 = 0, A2, A3, A4, A5, A6, A7, A8,
B1, B2, B3, B4, B5, B6, B7, B8,
C1, C2, D1, D2, D3, D4, D5, D6, D7, D8,
E1, E2, E3, E4, E5, E6, E7, E8,
};
static unsigned touch_map[] = TOUCH_MAP;
static uint8_t touch_map[] = TOUCH_MAP;
void touch_init()
{
@ -46,6 +39,7 @@ void touch_init()
mpr121_init(MPR121_ADDR + m);
}
touch_update_config();
memcpy(touch_map, mai_cfg->alt.touch, sizeof(touch_map));
}
static uint64_t touch_reading;

View File

@ -9,6 +9,13 @@
#include <stdint.h>
#include <stdbool.h>
enum touch_pads {
A1 = 0, A2, A3, A4, A5, A6, A7, A8,
B1, B2, B3, B4, B5, B6, B7, B8,
C1, C2, D1, D2, D3, D4, D5, D6, D7, D8,
E1, E2, E3, E4, E5, E6, E7, E8,
};
void touch_init();
void touch_update();
bool touch_touched(unsigned key);