From 2f4b1423e640dfda7dc05f895d1d982f2d69f19d Mon Sep 17 00:00:00 2001 From: Oleg Kalachev Date: Thu, 28 May 2026 18:39:44 +0300 Subject: [PATCH] Typo and minor code style changes --- flix/imu.ino | 8 ++++++-- flix/motors.ino | 3 ++- flix/rc.ino | 1 + flix/wifi.ino | 1 + tools/pyflix/README.md | 2 +- 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/flix/imu.ino b/flix/imu.ino index 136412e..0b0e97f 100644 --- a/flix/imu.ino +++ b/flix/imu.ino @@ -40,10 +40,12 @@ void readIMU() { imu.getGyro(gyro.x, gyro.y, gyro.z); imu.getAccel(acc.x, acc.y, acc.z); calibrateGyroOnce(); - // apply scale and bias + + // Apply scale and bias acc = (acc - accBias) / accScale; gyro = gyro - gyroBias; - // rotate to body frame + + // Rotate to body frame Quaternion rotation = Quaternion::fromEuler(imuRotation); acc = Quaternion::rotateVector(acc, rotation.inversed()); gyro = Quaternion::rotateVector(gyro, rotation.inversed()); @@ -52,6 +54,7 @@ void readIMU() { void calibrateGyroOnce() { static Delay landedDelay(2); if (!landedDelay.update(landed)) return; // calibrate only if definitely stationary + gyroBias = gyroBiasFilter.update(gyro); } @@ -105,6 +108,7 @@ void calibrateAccelOnce() { if (acc.x < accMin.x) accMin.x = acc.x; if (acc.y < accMin.y) accMin.y = acc.y; if (acc.z < accMin.z) accMin.z = acc.z; + // Compute scale and bias accScale = (accMax - accMin) / 2 / ONE_G; accBias = (accMax + accMin) / 2; diff --git a/flix/motors.ino b/flix/motors.ino index b25e61a..b1a1206 100644 --- a/flix/motors.ino +++ b/flix/motors.ino @@ -18,7 +18,7 @@ const int MOTOR_REAR_LEFT = 0, MOTOR_REAR_RIGHT = 1, MOTOR_FRONT_RIGHT = 2, MOTO void setupMotors() { print("Setup Motors\n"); - // configure pins + // Configure pins for (int i = 0; i < 4; i++) { ledcAttach(motorPins[i], pwmFrequency, pwmResolution); pwmFrequency = ledcChangeFrequency(motorPins[i], pwmFrequency, pwmResolution); // when reconfiguring @@ -35,6 +35,7 @@ void sendMotors() { int getDutyCycle(float value) { value = constrain(value, 0, 1); + if (pwmMax >= 0) { // pwm mode float pwm = mapf(value, 0, 1, pwmMin, pwmMax); if (value == 0) pwm = pwmStop; diff --git a/flix/rc.ino b/flix/rc.ino index 7433c72..8332e2d 100644 --- a/flix/rc.ino +++ b/flix/rc.ino @@ -55,6 +55,7 @@ void calibrateRC() { print("RC_RX_PIN = %d, set the RC pin!\n", rcRxPin); return; } + uint16_t zero[16]; // for zero positions uint16_t center[16]; // for center positions uint16_t _[16]; // for unused data diff --git a/flix/wifi.ino b/flix/wifi.ino index bfd5061..ccdf0fa 100644 --- a/flix/wifi.ino +++ b/flix/wifi.ino @@ -56,6 +56,7 @@ void setupWiFi() { void sendWiFi(const uint8_t *buf, int len) { if (espnow) { espnow.write(buf, len); + static Rate discovery(2); if (discovery) espnowBroadcast.write((const uint8_t *)"flix", 4); // broadcast message to help finding this device return; diff --git a/tools/pyflix/README.md b/tools/pyflix/README.md index ea79714..138878f 100644 --- a/tools/pyflix/README.md +++ b/tools/pyflix/README.md @@ -28,7 +28,7 @@ from pyflix import Flix flix = Flix() # create a Flix object and wait for connection ``` -If using ESP-NOW connection, specify the proxy's device name in `FLIX_DEVICE` environment variable or pass it to the constructor: `Flix(device='/dev/cu.usbserial-0001')`. +If using ESP-NOW connection, specify the proxy device name in `FLIX_DEVICE` environment variable or pass it to the constructor: `Flix(device='/dev/cu.usbserial-0001')`. ### Telemetry