Skip to content

Commit

Permalink
lut values
Browse files Browse the repository at this point in the history
  • Loading branch information
CubicFX committed Aug 22, 2024
1 parent b7c1fa4 commit 57c97b1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion keyboards/cubicfx/keypad/keypad.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ bool debug_print(void) {
for (uint8_t col = 0; col < MATRIX_COLS; col++) {
analog_key_t *key = &keys[currentRow][col];
if (key->raw) {
bufferPtr += snprintf(bufferPtr, sizeof(rowBuffer) - (bufferPtr - rowBuffer), "%5u ", key->raw);
bufferPtr += snprintf(bufferPtr, sizeof(rowBuffer) - (bufferPtr - rowBuffer), "%5u ", key->value);
} else {
bufferPtr += snprintf(bufferPtr, sizeof(rowBuffer) - (bufferPtr - rowBuffer), " null ");
}
Expand Down
13 changes: 9 additions & 4 deletions keyboards/cubicfx/keypad/lut.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,22 @@ SPDX-License-Identifier: GPL-2.0-or-later */
#include "scanfunctions.h"
#include "util.h"

const double lut_a = 16654600.6755; // Lekker
const double lut_b = -0.00955994866577;
const double lut_c = -1278.75103145;
const double lut_d = 16652478.4163;
// const double lut_a = 16654600.6755; // Lekker
// const double lut_b = -0.00955994866577;
// const double lut_c = -1278.75103145;
// const double lut_d = 16652478.4163;

/* Equation parameters for the sensor-magnet linearity mapping */
// const double lut_a = 0.200347177016; // Latenpow
// const double lut_b = 0.00955994866154;
// const double lut_c = 6.01110636956;
// const double lut_d = 1966.74076381;

const double lut_a = 0.095; // Cubic
const double lut_b = 0.01;
const double lut_c = 0;
const double lut_d = 350;

uint16_t distance_to_adc(uint8_t distance) {
double intermediate = lut_a * exp(lut_b * distance + lut_c) + lut_d;
uint16_t adc = (uint16_t) MAX(0, MIN(intermediate, 4095));
Expand Down

0 comments on commit 57c97b1

Please sign in to comment.