rename indToMM

This commit is contained in:
kellharpole
2025-11-16 12:26:02 -06:00
parent 7e9a437797
commit b9c9845790
4 changed files with 7 additions and 7 deletions

View File

@@ -115,13 +115,13 @@ void loop() {
// put your main code here, to run repeatedly:
dist_raw = analogRead(indL);
if (dist_raw > 870) oor = true;
dist = ind2mm(ind0Map, dist_raw); // 189->950, 16->26
dist = indToMM(ind0Map, dist_raw); // 189->950, 16->26
Serial.print(dist);
Serial.print(", ");
dist2_raw = analogRead(indR);
if (dist2_raw > 870) oor2 = true;
dist2 = ind2mm(ind1Map, dist2_raw);
dist2 = indToMM(ind1Map, dist2_raw);
Serial.print(dist2);
Serial.print(", ");

View File

@@ -8,6 +8,6 @@ IndSensorMap ind2Map = {-9.824360913609562, 871.4744633266955, 0.290936623509330
IndSensorMap ind3Map = {-13.891292062248292, 990.6819962477331, 0.16376045588859353, -0.074904004740735, 0.17727132893449118};
// Convert raw analog reading to millimeters using sensor calibration
float ind2mm(IndSensorMap ind, unsigned int raw) {
float indToMM(IndSensorMap ind, unsigned int raw) {
return ind.C - (1.0 / ind.B) * log(pow((ind.K - ind.A) / ((float)raw - ind.A), ind.v) - 1.0);
}

View File

@@ -17,6 +17,6 @@ extern IndSensorMap ind2Map;
extern IndSensorMap ind3Map;
// Convert raw analog reading to millimeters using sensor calibration
float ind2mm(IndSensorMap ind, unsigned int raw);
float indToMM(IndSensorMap ind, unsigned int raw);
#endif // IND_SENSOR_MAP_HPP

View File

@@ -123,7 +123,7 @@ static inline float clamp90(float x) { return clampf(x, -90.0f, 90.0f); }
// prototypes (so we can keep your function layout)
void send_pwm1(int val);
void send_pwm2(int val);
float ind2mm(IndSensorMap ind, unsigned int raw);
float indToMM(IndSensorMap ind, unsigned int raw);
int levitate(float e, float de, float ecum_local, int oor);
int levitate2(float e, float de, float ecum_local, int oor);
@@ -189,7 +189,7 @@ void loop() {
// Read height sensors (yours)
// ----------------------------
dist_raw = analogRead(ind0Pin);
dist = ind2mm(ind0Map, dist_raw);
dist = indToMM(ind0Map, dist_raw);
Serial.print(dist);
Serial.print(", ");
@@ -376,6 +376,6 @@ void send_pwm2(int val) {
// float_map() — ADC→distance mapping (yours)
// ----------------------------
// Uses John and Adi's sensor calibration to return the millimeter reading from an analog sensor value.
float ind2mm(IndSensorMap ind, unsigned int raw) {
float indToMM(IndSensorMap ind, unsigned int raw) {
return ind.C - (1.0 / ind.B) * log(pow((ind.K - ind.A) / ((float)raw - ind.A), ind.v) - 1.0);
}