mirror of
https://github.com/whowechina/mai_pico.git
synced 2024-11-27 21:10:48 +01:00
Feature: Add map_raw_to_zones(), minor code structure modification
This commit is contained in:
parent
a3e90fb696
commit
2aca017d13
@ -22,8 +22,6 @@
|
||||
#define SENSE_LIMIT_MAX 9
|
||||
#define SENSE_LIMIT_MIN -9
|
||||
|
||||
static uint8_t touch_map[] = TOUCH_MAP;
|
||||
|
||||
static void disp_rgb()
|
||||
{
|
||||
printf("[RGB]\n");
|
||||
@ -408,14 +406,10 @@ static void print_readings(const char *title, const uint16_t *raw, int num)
|
||||
|
||||
static void handle_raw()
|
||||
{
|
||||
static uint16_t zones[36] = {0};
|
||||
const uint16_t *raw = touch_raw();
|
||||
const uint16_t *zones = map_raw_to_zones(raw);
|
||||
|
||||
printf("Touch raw readings:\n");
|
||||
const uint16_t *raw = touch_raw();
|
||||
|
||||
for (int i = 0; i < 34; i++) {
|
||||
zones[touch_map[i]] = raw[i];
|
||||
}
|
||||
|
||||
printf(" Sensor: 0: %s, 1: %s 2: %s\n",
|
||||
touch_sensor_ok(0) ? "OK" : "ERR",
|
||||
|
@ -167,6 +167,16 @@ const uint16_t *touch_raw()
|
||||
return readout;
|
||||
}
|
||||
|
||||
const uint16_t *map_raw_to_zones(const uint16_t* raw) {
|
||||
static uint16_t zones[36];
|
||||
|
||||
for (int i = 0; i < 34; i++) {
|
||||
zones[touch_map[i]] = raw[i];
|
||||
}
|
||||
|
||||
return zones;
|
||||
}
|
||||
|
||||
bool touch_touched(unsigned key)
|
||||
{
|
||||
if (key >= 34) {
|
||||
|
@ -29,6 +29,7 @@ uint64_t touch_touchmap();
|
||||
void touch_set_map(unsigned sensor, unsigned key);
|
||||
|
||||
const uint16_t *touch_raw();
|
||||
const uint16_t *map_raw_to_zones(const uint16_t *raw);
|
||||
bool touch_sensor_ok(unsigned i);
|
||||
|
||||
void touch_update_config();
|
||||
|
Loading…
Reference in New Issue
Block a user