additional bugfixing
This commit is contained in:
parent
46ff7c865e
commit
36ab15255f
3 changed files with 64 additions and 16 deletions
|
|
@ -6,6 +6,7 @@
|
|||
holding buffers for the duration of a data transfer."
|
||||
)]
|
||||
use core::fmt::Write;
|
||||
use alloc::string::ToString;
|
||||
use esp_hal::uart::{self, Config, Uart};
|
||||
|
||||
use esp_hal::clock::CpuClock;
|
||||
|
|
@ -21,27 +22,30 @@ use esp_hal::time::Rate;
|
|||
use esp_hal::handler;
|
||||
|
||||
use core::cell::RefCell;
|
||||
use critical_section::Mutex;
|
||||
use esp_backtrace as _;
|
||||
use esp_hal::time::{Duration, Instant};
|
||||
use esp_hal::timer::timg::TimerGroup;
|
||||
use esp_backtrace as _;
|
||||
use critical_section::Mutex;
|
||||
use rtt_target::rprintln;
|
||||
mod dc_driver;
|
||||
mod peripherals;
|
||||
use dc_driver::afroesc::AfroEsc;
|
||||
use peripherals::nextion::Nextion;
|
||||
|
||||
use crate::peripherals::ErrCommand;
|
||||
#[panic_handler]
|
||||
fn panic(_: &core::panic::PanicInfo) -> ! {
|
||||
rprintln!("PANIC!");
|
||||
loop {}
|
||||
}
|
||||
use alloc::format;
|
||||
//
|
||||
static EMERGENCY_BUTTON: Mutex<RefCell<Option<Input>>> = Mutex::new(RefCell::new(None));
|
||||
extern crate alloc;
|
||||
//target RPM
|
||||
const DEFAULT_TARGET_RPM: u32 = 1000;
|
||||
const DEFAULT_TARGET_RPM: u32 = 2000;
|
||||
//in seconds
|
||||
const DEFAULT_SPIN_TIME:u32 = 10;
|
||||
const DEFAULT_SPIN_TIME: u32 = 10;
|
||||
// This creates a default app-descriptor required by the esp-idf bootloader.
|
||||
// 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!();
|
||||
|
|
@ -80,6 +84,7 @@ fn main() -> ! {
|
|||
// delay.delay_millis(3000);
|
||||
//gpio 9 is the button
|
||||
let input_config = InputConfig::default().with_pull(esp_hal::gpio::Pull::Up);
|
||||
use crate::peripherals::Command;
|
||||
//let emergency_button = peripherals.GPIO9;
|
||||
let mut emergency_button = Input::new(peripherals.GPIO9, input_config);
|
||||
critical_section::with(|cs| {
|
||||
|
|
@ -102,15 +107,44 @@ fn main() -> ! {
|
|||
.with_rx(peripherals.GPIO5)
|
||||
.with_tx(peripherals.GPIO7);
|
||||
let mut display = Nextion::new(&mut uart0);
|
||||
|
||||
display.send_command(b"page page0");
|
||||
let mut rpm = DEFAULT_TARGET_RPM;
|
||||
let mut timer = DEFAULT_SPIN_TIME;
|
||||
loop {
|
||||
let mut buf:[u8;20] = [0;20];
|
||||
if display.read_ready(){
|
||||
display.read_command(&mut buf);
|
||||
display.send_command(b"page page0");
|
||||
rprintln!("RECV BUF:{:?}",buf);
|
||||
rprintln!("WTF");
|
||||
}
|
||||
if display.read_ready() {
|
||||
match display.read_command() {
|
||||
Ok(Command::CommandSuccess) => {
|
||||
rprintln!("COMMAND SUCCESSFULLY executed");
|
||||
}
|
||||
Ok(Command::Start) => {
|
||||
rprintln!("START")
|
||||
},
|
||||
Ok(Command::Stop) => {
|
||||
rprintln!("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) =>{
|
||||
rprintln!("READ FAILED!");
|
||||
}
|
||||
}
|
||||
// display.send_command(b"page page0");
|
||||
}
|
||||
//display.send_command(b"page page0");
|
||||
//uart0.write(b"page page0\xff\xff\xff");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue