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
Branches
Tags v1.4
No related merge requests found
...@@ -43,6 +43,9 @@ static esp_err_t _sequence_request(ad7147_chip_t *chip, bool reprogram) { ...@@ -43,6 +43,9 @@ static esp_err_t _sequence_request(ad7147_chip_t *chip, bool reprogram) {
int8_t offset = chip->channels[channel].afe_offset; int8_t offset = chip->channels[channel].afe_offset;
seq_out.channels[i] = channel; seq_out.channels[i] = channel;
seq_out.pos_afe_offsets[i] = offset; 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; esp_err_t ret;
......
...@@ -40,6 +40,8 @@ typedef struct { ...@@ -40,6 +40,8 @@ typedef struct {
typedef struct { typedef struct {
// Opaque name used to prefix log messages. // Opaque name used to prefix log messages.
const char *name; 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 // [0, n_channels) are the expected connected channels to the inputs of the
// chip. // chip.
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#define TIMEOUT_MS 1000 #define TIMEOUT_MS 1000
#define CIN CDC_NONE 0 #define CIN_CDC_NONE 0
#define CIN_CDC_NEG 1 #define CIN_CDC_NEG 1
#define CIN_CDC_POS 2 #define CIN_CDC_POS 2
#define CIN_BIAS 3 #define CIN_BIAS 3
...@@ -281,8 +281,9 @@ esp_err_t ad7147_hw_configure_stages(ad7147_hw_t *device, ...@@ -281,8 +281,9 @@ esp_err_t ad7147_hw_configure_stages(ad7147_hw_t *device,
bool reprogram) { bool reprogram) {
// Reset all stage/channel configuration. // Reset all stage/channel configuration.
for (size_t i = 0; i < 12; i++) { 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++) { 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; device->dev_config.stageX_complete_int_enable[i] = false;
} }
......
...@@ -100,6 +100,8 @@ typedef struct { ...@@ -100,6 +100,8 @@ typedef struct {
// For each sequencer stage, AFE offset that this stage should use when // For each sequencer stage, AFE offset that this stage should use when
// sampling the configured channel. // sampling the configured channel.
int8_t pos_afe_offsets[12]; 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; } ad7147_sequence_t;
// Configure sequencer stages. // Configure sequencer stages.
......
...@@ -106,6 +106,7 @@ static bool _interrupt_shared = false; ...@@ -106,6 +106,7 @@ static bool _interrupt_shared = false;
static ad7147_chip_t _top = { static ad7147_chip_t _top = {
.name = "top", .name = "top",
.is_bot = false,
.nchannels = 12, .nchannels = 12,
.sequences = { .sequences = {
{ {
...@@ -120,6 +121,7 @@ static ad7147_chip_t _top = { ...@@ -120,6 +121,7 @@ static ad7147_chip_t _top = {
static ad7147_chip_t _bot = { static ad7147_chip_t _bot = {
.name = "bot", .name = "bot",
.is_bot = true,
.nchannels = 13, .nchannels = 13,
.sequences = { .sequences = {
/// This is the ideal sequence we want. First, all the bottom sensors. /// This is the ideal sequence we want. First, all the bottom sensors.
......
...@@ -31,8 +31,7 @@ static bool _calibrating = false; ...@@ -31,8 +31,7 @@ static bool _calibrating = false;
static inline void _pad_feed(st3m_petal_pad_state_t *pad, uint16_t data, static inline void _pad_feed(st3m_petal_pad_state_t *pad, uint16_t data,
uint8_t index) { uint8_t index) {
bool top = (index % 2) == 0; bool top = (index % 2) == 0;
int32_t thres = int32_t thres = top ? (TOP_PETAL_THRESHOLD) : (BOTTOM_PETAL_THRESHOLD);
top ? (TOP_PETAL_THRESHOLD) : (BOTTOM_PETAL_THRESHOLD);
thres = pad->pressed_prev ? thres - (PETAL_HYSTERESIS) thres = pad->pressed_prev ? thres - (PETAL_HYSTERESIS)
: thres; // some hysteresis : thres; // some hysteresis
pad->raw = data; pad->raw = data;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment