Skip to content
Snippets Groups Projects
Commit 334d9ce8 authored by moon2's avatar moon2 :speech_balloon:
Browse files

captouch: disconnect idle bottom petals from bias.

mitigates floating flow3r captouch threshold issues.
side effects unknown but there probably are some.
it's nice not having to care about EMI n'est-ce pas?
parent d837cf76
No related branches found
No related tags found
1 merge request!599captouch: improved signal processing
Pipeline #12546 passed
......@@ -43,6 +43,9 @@ static esp_err_t _sequence_request(ad7147_chip_t *chip, bool reprogram) {
int8_t offset = chip->channels[channel].afe_offset;
seq_out.channels[i] = channel;
seq_out.pos_afe_offsets[i] = offset;
// seq_out.idle_to_bias[i] = !(chip->is_bot && (channel < 10)); // jumpy
// petal 2
seq_out.idle_to_bias[i] = !chip->is_bot;
}
esp_err_t ret;
......
......@@ -40,6 +40,8 @@ typedef struct {
typedef struct {
// Opaque name used to prefix log messages.
const char *name;
// True for bottom chip, false for top
bool is_bot;
// [0, n_channels) are the expected connected channels to the inputs of the
// chip.
......
......@@ -7,7 +7,7 @@
#define TIMEOUT_MS 1000
#define CIN CDC_NONE 0
#define CIN_CDC_NONE 0
#define CIN_CDC_NEG 1
#define CIN_CDC_POS 2
#define CIN_BIAS 3
......@@ -281,8 +281,9 @@ esp_err_t ad7147_hw_configure_stages(ad7147_hw_t *device,
bool reprogram) {
// Reset all stage/channel configuration.
for (size_t i = 0; i < 12; i++) {
uint8_t idle_con = seq->idle_to_bias[i] ? CIN_BIAS : CIN_CDC_NONE;
for (int8_t j = 0; j < 13; j++) {
device->stage_config[i].cinX_connection_setup[j] = CIN_BIAS;
device->stage_config[i].cinX_connection_setup[j] = idle_con;
}
device->dev_config.stageX_complete_int_enable[i] = false;
}
......
......@@ -100,6 +100,8 @@ typedef struct {
// For each sequencer stage, AFE offset that this stage should use when
// sampling the configured channel.
int8_t pos_afe_offsets[12];
// Whether idle pads are supposed to be connected to bias. Awful hack.
bool idle_to_bias[12];
} ad7147_sequence_t;
// Configure sequencer stages.
......@@ -112,4 +114,4 @@ esp_err_t ad7147_hw_configure_stages(ad7147_hw_t *device,
// Polls sequencer status from the chip and calls the user callback if new data
// is available / the sequence finished.
esp_err_t ad7147_hw_process(ad7147_hw_t *device);
\ No newline at end of file
esp_err_t ad7147_hw_process(ad7147_hw_t *device);
......@@ -106,6 +106,7 @@ static bool _interrupt_shared = false;
static ad7147_chip_t _top = {
.name = "top",
.is_bot = false,
.nchannels = 12,
.sequences = {
{
......@@ -120,6 +121,7 @@ static ad7147_chip_t _top = {
static ad7147_chip_t _bot = {
.name = "bot",
.is_bot = true,
.nchannels = 13,
.sequences = {
/// This is the ideal sequence we want. First, all the bottom sensors.
......
......@@ -31,8 +31,7 @@ static bool _calibrating = false;
static inline void _pad_feed(st3m_petal_pad_state_t *pad, uint16_t data,
uint8_t index) {
bool top = (index % 2) == 0;
int32_t thres =
top ? (TOP_PETAL_THRESHOLD) : (BOTTOM_PETAL_THRESHOLD);
int32_t thres = top ? (TOP_PETAL_THRESHOLD) : (BOTTOM_PETAL_THRESHOLD);
thres = pad->pressed_prev ? thres - (PETAL_HYSTERESIS)
: thres; // some hysteresis
pad->raw = data;
......@@ -85,7 +84,7 @@ static inline void _petal_process(st3m_petal_state_t *petal, uint8_t index) {
} else {
petal->pressure = (petal->base.pressure + petal->tip.pressure) / 2;
int32_t raw = petal->base.raw + petal->tip.raw;
if(index == 5) raw *= 2;
if (index == 5) raw *= 2;
petal->pressed = raw > thres;
int32_t base = petal->base.raw;
int32_t tip = petal->tip.raw;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment