4 Commits

Author SHA1 Message Date
Oleg Kalachev
c3b818c2ae Try using installable Preferences library 2025-11-18 18:19:02 +03:00
Oleg Kalachev
531b3f4d04 Use analogWrite api instead of ledc 2025-11-18 16:54:51 +03:00
Oleg Kalachev
795b248b94 Adapt firmware for non-esp32 boards 2025-11-04 13:47:41 +03:00
Oleg Kalachev
77c4b5fc5b Test build for STM32 2025-11-04 13:42:05 +03:00
3 changed files with 20 additions and 7 deletions

View File

@@ -29,6 +29,13 @@ jobs:
run: sed -i 's/^#define WIFI_ENABLED 1$/#define WIFI_ENABLED 0/' flix/flix.ino && make
- name: Check c_cpp_properties.json
run: tools/check_c_cpp_properties.py
- name: Build for Black Pill F411CE (STM32)
run: |
arduino-cli config set board_manager.additional_urls https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json
arduino-cli core install STMicroelectronics:stm32
arduino-cli board listall STMicroelectronics:stm32
arduino-cli lib install "Preferences"
make BOARD=STMicroelectronics:stm32:GenF4:pnum=BLACKPILL_F411CE
build_macos:
runs-on: macos-latest

View File

@@ -25,13 +25,15 @@ const int MOTOR_FRONT_LEFT = 3;
void setupMotors() {
print("Setup Motors\n");
// configure pins
#ifdef ESP32
ledcAttach(MOTOR_0_PIN, PWM_FREQUENCY, PWM_RESOLUTION);
ledcAttach(MOTOR_1_PIN, PWM_FREQUENCY, PWM_RESOLUTION);
ledcAttach(MOTOR_2_PIN, PWM_FREQUENCY, PWM_RESOLUTION);
ledcAttach(MOTOR_3_PIN, PWM_FREQUENCY, PWM_RESOLUTION);
#else
analogWriteResolution(PWM_RESOLUTION);
analogWriteFrequency(PWM_FREQUENCY);
#endif
sendMotors();
print("Motors initialized\n");
}
@@ -45,10 +47,10 @@ int getDutyCycle(float value) {
}
void sendMotors() {
ledcWrite(MOTOR_0_PIN, getDutyCycle(motors[0]));
ledcWrite(MOTOR_1_PIN, getDutyCycle(motors[1]));
ledcWrite(MOTOR_2_PIN, getDutyCycle(motors[2]));
ledcWrite(MOTOR_3_PIN, getDutyCycle(motors[3]));
analogWrite(MOTOR_0_PIN, getDutyCycle(motors[0]));
analogWrite(MOTOR_1_PIN, getDutyCycle(motors[1]));
analogWrite(MOTOR_2_PIN, getDutyCycle(motors[2]));
analogWrite(MOTOR_3_PIN, getDutyCycle(motors[3]));
}
bool motorsActive() {

View File

@@ -6,8 +6,10 @@
#pragma once
#include <math.h>
#ifdef ESP32
#include <soc/soc.h>
#include <soc/rtc_cntl_reg.h>
#endif
const float ONE_G = 9.80665;
extern float t;
@@ -37,7 +39,9 @@ float wrapAngle(float angle) {
// Disable reset on low voltage
void disableBrownOut() {
#ifdef ESP32
REG_CLR_BIT(RTC_CNTL_BROWN_OUT_REG, RTC_CNTL_BROWN_OUT_ENA);
#endif
}
// Trim and split string by spaces