mirror of
https://github.com/whowechina/chu_pico.git
synced 2026-10-12 09:08:25 +03:00
fix: address overflow and persistance bugs with filter config
This commit is contained in:
Binary file not shown.
@@ -328,9 +328,10 @@ static void handle_ir(int argc, char *argv[])
|
||||
static void handle_filter(int argc, char *argv[])
|
||||
{
|
||||
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";
|
||||
"Adjusts MPR121 noise filtering parameters. See datasheets for more details.\n"
|
||||
" first: First Filter Iterations (FFI) [0..3]\n"
|
||||
" second: Second Filter Iterations (SFI) [0..3]\n"
|
||||
" interval: Electode Sample Interval (ESI) [0..7]\n";
|
||||
if ((argc < 2) || (argc > 3)) {
|
||||
printf(usage);
|
||||
return;
|
||||
@@ -348,9 +349,7 @@ static void handle_filter(int argc, char *argv[])
|
||||
printf(usage);
|
||||
return;
|
||||
}
|
||||
|
||||
chu_cfg->sense.filter = (ffi << 6) | (sfi << 4) | intv;
|
||||
|
||||
chu_cfg->sense.filter = (uint8_t)((ffi << 6) | (sfi << 4) | intv );
|
||||
slider_update_config();
|
||||
config_changed();
|
||||
disp_sense();
|
||||
|
||||
@@ -61,8 +61,11 @@ static void config_loaded()
|
||||
chu_cfg->tof = default_cfg.tof;
|
||||
config_changed();
|
||||
}
|
||||
if ((chu_cfg->sense.filter & 0x0f) > 3 ||
|
||||
((chu_cfg->sense.filter >> 4) & 0x0f) > 3) {
|
||||
if (
|
||||
((chu_cfg->sense.filter & 0x07) > 7) ||
|
||||
((chu_cfg->sense.filter >> 6) > 3) ||
|
||||
(((chu_cfg->sense.filter >> 4) & 0x03) > 3)
|
||||
) {
|
||||
chu_cfg->sense.filter = default_cfg.sense.filter;
|
||||
config_changed();
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ typedef struct __attribute__((packed)) {
|
||||
uint8_t pitch;
|
||||
} tof;
|
||||
struct {
|
||||
int8_t filter;
|
||||
uint8_t filter;
|
||||
int8_t global;
|
||||
uint8_t debounce_touch;
|
||||
uint8_t debounce_release;
|
||||
|
||||
Reference in New Issue
Block a user