*: cargo fmt

This commit is contained in:
Serge Bazanski 2026-01-23 21:28:46 +01:00
parent 9948a76602
commit fe8942575a
7 changed files with 156 additions and 151 deletions

View file

@ -6,18 +6,18 @@
holding buffers for the duration of a data transfer."
)]
use alloc::string::ToString;
use esp_hal::uart::{Config, Uart};
use esp_hal::clock::CpuClock;
use esp_hal::delay::Delay;
use esp_hal::main;
use esp_hal::uart::{Config, Uart};
use esp_hal::gpio::Event;
use esp_hal::gpio::{Input, InputConfig};
use esp_hal::handler;
use esp_hal::mcpwm::operator::PwmPinConfig;
use esp_hal::mcpwm::timer::PwmWorkingMode;
use esp_hal::time::Rate;
use esp_hal::rmt::{Rmt, TxChannelConfig, TxChannelCreator};
use esp_hal::handler;
use esp_hal::time::Rate;
use core::cell::RefCell;
use critical_section::Mutex;
@ -36,10 +36,10 @@ use peripherals::nextion::Nextion;
use dc_driver::dshot::DShot;
use dc_driver::dshot::DShotSpeed;
use esp_hal::rmt::RxChannelCreator;
use esp_hal::rmt::RxChannelConfig;
use crate::dc_driver::dshot;
use crate::peripherals::ErrCommand;
use esp_hal::rmt::RxChannelConfig;
use esp_hal::rmt::RxChannelCreator;
#[panic_handler]
fn panic(_: &core::panic::PanicInfo) -> ! {
rprintln!("PANIC!");
@ -57,8 +57,8 @@ const DEFAULT_SPIN_TIME: u32 = 10;
// For more information see: <https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/system/app_image_format.html#application-description>
esp_bootloader_esp_idf::esp_app_desc!();
use crate::peripherals::Command;
use esp_hal::gpio::Output;
use esp_hal::gpio::Level;
use esp_hal::gpio::Output;
use esp_hal::gpio::OutputConfig;
#[main]
@ -85,23 +85,34 @@ fn main() -> ! {
.timer_clock_with_frequency(19_999, PwmWorkingMode::Increase, Rate::from_hz(50))
.unwrap();
mcpwm.timer0.start(timer_clock_cfg);
//setup RMT
let freq = Rate::from_mhz(80);
let rmt = Rmt::new(peripherals.RMT, freq).expect("CAN NOT SET FREQUENCY");
let rx_config = RxChannelConfig::default().with_clk_divider(1);
let tx_config = TxChannelConfig::default().with_clk_divider(1);
let mut toggle_pin = Output::new(peripherals.GPIO2, Level::Low, OutputConfig::default());
let mut tx_channel = rmt.channel0.configure_tx(peripherals.GPIO23,tx_config ).expect("creation of TX_CHANNEL FAILED!");
let mut rx_channel = rmt.channel3.configure_rx(peripherals.GPIO14,rx_config).unwrap();
let mut dshot_esc = dshot::DShot::new(&mut rx_channel, &mut tx_channel, DShotSpeed::DShot600, Some(80_000_000), Some(1));
let mut toggle_pin = Output::new(peripherals.GPIO2, Level::Low, OutputConfig::default());
let mut tx_channel = rmt
.channel0
.configure_tx(peripherals.GPIO23, tx_config)
.expect("creation of TX_CHANNEL FAILED!");
let mut rx_channel = rmt
.channel3
.configure_rx(peripherals.GPIO14, rx_config)
.unwrap();
let mut dshot_esc = dshot::DShot::new(
&mut rx_channel,
&mut tx_channel,
DShotSpeed::DShot600,
Some(80_000_000),
Some(1),
);
rprintln!("SENDING RMT");
loop{
delay.delay_millis(1000);
toggle_pin.set_high();
dshot_esc.write_throttle(2047,true);
toggle_pin.set_low();
loop {
delay.delay_millis(1000);
toggle_pin.set_high();
dshot_esc.write_throttle(2047, true);
toggle_pin.set_low();
}
// rprintln!("RMT SENT!");
// let mut esc = AfroEsc::new(&mut pwm_pin);;
@ -144,35 +155,35 @@ fn main() -> ! {
loop {
if display.read_ready() {
match display.read_command() {
Ok(Command::CommandSuccess) => {
rprintln!("COMMAND SUCCESSFULLY executed");
}
Ok(Command::Start) => {
rprintln!("START");
started = true;
},
Ok(Command::Stop) => {
rprintln!("STOP");
started = false;
// spincoater.stop();
},
Ok(Command::SetRpm(x)) => {
rprintln!("SET_RPM with {}", x);
rpm = x;
},
Ok(Command::SetTimer(x)) => {
rprintln!("SETTING TIMER {}", x);
timer = x;
},
Ok(Command::SendConfig) => {
rprintln!("SEND CONFIG");
let command = format!("rpm.val={}",DEFAULT_TARGET_RPM);
display.send_command(command.to_string().as_bytes());
},
Ok(Command::CommandSuccess) => {
rprintln!("COMMAND SUCCESSFULLY executed");
}
Ok(Command::Start) => {
rprintln!("START");
started = true;
}
Ok(Command::Stop) => {
rprintln!("STOP");
started = false;
// spincoater.stop();
}
Ok(Command::SetRpm(x)) => {
rprintln!("SET_RPM with {}", x);
rpm = x;
}
Ok(Command::SetTimer(x)) => {
rprintln!("SETTING TIMER {}", x);
timer = x;
}
Ok(Command::SendConfig) => {
rprintln!("SEND CONFIG");
let command = format!("rpm.val={}", DEFAULT_TARGET_RPM);
display.send_command(command.to_string().as_bytes());
}
Err(ErrCommand::NoValidCmd) => {
rprintln!(" NOT A VALID CMD!");
},
Err(ErrCommand::ReadError) =>{
}
Err(ErrCommand::ReadError) => {
rprintln!("READ FAILED!");
}
}