fix: address overflow and persistance bugs with filter config

This commit is contained in:
adelynflowers
2025-01-18 18:16:36 -05:00
parent 59d9efa781
commit 03d6a00643
4 changed files with 11 additions and 9 deletions
Binary file not shown.
+5 -6
View File
@@ -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();
+5 -2
View File
@@ -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();
}
+1 -1
View File
@@ -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;