diff --git a/DualYokeControl (Previous Version).ino b/DualYokeControl (Previous Version).ino index 2807030..cb97e69 100644 --- a/DualYokeControl (Previous Version).ino +++ b/DualYokeControl (Previous Version).ino @@ -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(", "); diff --git a/IndSensorMap.cpp b/IndSensorMap.cpp index 2f492a1..d77439b 100644 --- a/IndSensorMap.cpp +++ b/IndSensorMap.cpp @@ -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); } diff --git a/IndSensorMap.hpp b/IndSensorMap.hpp index f38fc9b..ff70533 100644 --- a/IndSensorMap.hpp +++ b/IndSensorMap.hpp @@ -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 diff --git a/IndivCoilControl (AI Slop Version).ino b/IndivCoilControl (AI Slop Version).ino index f0f66ac..6977159 100755 --- a/IndivCoilControl (AI Slop Version).ino +++ b/IndivCoilControl (AI Slop Version).ino @@ -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); }