mirror of
https://github.com/whowechina/chu_pico.git
synced 2025-02-17 18:49:18 +01:00
SFI, FFI and ESI config
This commit is contained in:
parent
92fecac5c0
commit
d5ecafa203
Binary file not shown.
@ -98,7 +98,9 @@ static void disp_tof()
|
||||
static void disp_sense()
|
||||
{
|
||||
printf("[Sense]\n");
|
||||
printf(" Filter: %d, %d\n", chu_cfg->sense.filter >> 4, chu_cfg->sense.filter & 0xf);
|
||||
printf(" Filter: %u, %u, %u\n", chu_cfg->sense.filter >> 6,
|
||||
(chu_cfg->sense.filter >> 4) & 0x03,
|
||||
chu_cfg->sense.filter & 0x07);
|
||||
printf(" Sensitivity (global: %+d):\n", chu_cfg->sense.global);
|
||||
printf(" | 1| 2| 3| 4| 5| 6| 7| 8| 9|10|11|12|13|14|15|16|\n");
|
||||
printf(" ---------------------------------------------------\n");
|
||||
@ -285,22 +287,29 @@ static void handle_tof(int argc, char *argv[])
|
||||
|
||||
static void handle_filter(int argc, char *argv[])
|
||||
{
|
||||
const char *usage = "Usage: filter <first> <second>\n"
|
||||
" first, second: 0..3\n";
|
||||
if ((argc < 2) || (argc > 2)) {
|
||||
const char *usage = "Usage: filter <first> <second> [interval]\n"
|
||||
" first: First iteration [0..3]\n"
|
||||
" second: Second iteration [0..3]\n"
|
||||
" interval: Interval of second iterations [0..7]\n";
|
||||
if ((argc < 2) || (argc > 3)) {
|
||||
printf(usage);
|
||||
return;
|
||||
}
|
||||
|
||||
int ffi = extract_non_neg_int(argv[0], 0);
|
||||
int sfi = extract_non_neg_int(argv[1], 0);
|
||||
int intv = chu_cfg->sense.filter & 0x07;
|
||||
if (argc == 3) {
|
||||
intv = extract_non_neg_int(argv[2], 0);
|
||||
}
|
||||
|
||||
if ((ffi < 0) || (ffi > 3) || (sfi < 0) || (sfi > 3)) {
|
||||
if ((ffi < 0) || (ffi > 3) || (sfi < 0) || (sfi > 3) ||
|
||||
(intv < 0) || (intv > 7)) {
|
||||
printf(usage);
|
||||
return;
|
||||
}
|
||||
|
||||
chu_cfg->sense.filter = (ffi << 4) | sfi;
|
||||
chu_cfg->sense.filter = (ffi << 6) | (sfi << 4) | intv;
|
||||
|
||||
slider_update_config();
|
||||
config_changed();
|
||||
|
@ -174,7 +174,7 @@ static uint8_t mpr121_resume(uint8_t addr, uint8_t ecr)
|
||||
write_reg(addr, MPR121_ELECTRODE_CONFIG_REG, ecr);
|
||||
}
|
||||
|
||||
void mpr121_filter(uint8_t addr, uint8_t ffi, uint8_t sfi)
|
||||
void mpr121_filter(uint8_t addr, uint8_t ffi, uint8_t sfi, uint8_t esi)
|
||||
{
|
||||
uint8_t ecr = mpr121_stop(addr);
|
||||
|
||||
@ -183,7 +183,8 @@ void mpr121_filter(uint8_t addr, uint8_t ffi, uint8_t sfi)
|
||||
uint8_t acc = read_reg(addr, MPR121_AUTOCONFIG_CONTROL_0_REG);
|
||||
write_reg(addr, MPR121_AUTOCONFIG_CONTROL_0_REG, (acc & 0x3f) | ffi << 6);
|
||||
uint8_t fcr = read_reg(addr, MPR121_FILTER_CONFIG_REG);
|
||||
write_reg(addr, MPR121_FILTER_CONFIG_REG, (fcr & 0xe7) | (sfi & 3) << 3);
|
||||
write_reg(addr, MPR121_FILTER_CONFIG_REG,
|
||||
(fcr & 0xe0) | ((sfi & 3) << 3) | esi);
|
||||
|
||||
mpr121_resume(addr, ecr);
|
||||
}
|
||||
|
@ -11,8 +11,7 @@ void mpr121_init(uint8_t addr);
|
||||
|
||||
uint16_t mpr121_touched(uint8_t addr);
|
||||
void mpr121_raw(uint8_t addr, uint16_t *raw, int num);
|
||||
|
||||
void mpr121_filter(uint8_t addr, uint8_t ffi, uint8_t sfi);
|
||||
void mpr121_filter(uint8_t addr, uint8_t ffi, uint8_t sfi, uint8_t esi);
|
||||
void mpr121_sense(uint8_t addr, int8_t sense, int8_t *sense_keys);
|
||||
void mpr121_debounce(uint8_t addr, uint8_t touch, uint8_t release);
|
||||
|
||||
|
@ -93,8 +93,10 @@ void slider_update_config()
|
||||
for (int m = 0; m < 3; m++) {
|
||||
mpr121_debounce(MPR121_ADDR + m, chu_cfg->sense.debounce_touch,
|
||||
chu_cfg->sense.debounce_release);
|
||||
mpr121_sense(MPR121_ADDR + m, chu_cfg->sense.global, chu_cfg->sense.keys + m * 12);
|
||||
mpr121_filter(MPR121_ADDR + m, chu_cfg->sense.filter & 0x0f,
|
||||
(chu_cfg->sense.filter >> 4) & 0x0f);
|
||||
mpr121_sense(MPR121_ADDR + m, chu_cfg->sense.global,
|
||||
chu_cfg->sense.keys + m * 12);
|
||||
mpr121_filter(MPR121_ADDR + m, chu_cfg->sense.filter >> 6,
|
||||
(chu_cfg->sense.filter >> 4) & 0x03,
|
||||
chu_cfg->sense.filter & 0x07);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user