put coating logic into the main loop of the display
This commit is contained in:
parent
2d8de20d57
commit
db90f6dc0c
1 changed files with 46 additions and 33 deletions
|
|
@ -143,38 +143,7 @@ fn main() -> ! {
|
|||
let mut control: f32 = 200.0;
|
||||
let mut timg0 = TimerGroup::new(peripherals.TIMG0);
|
||||
let coat_timer = timg0.timer0;
|
||||
let _ = coat_timer
|
||||
.load_value(esp_hal::time::Duration::from_secs(10))
|
||||
.expect("TODO: Could not set timer for coating! ");
|
||||
coat_timer.start();
|
||||
while !coat_timer.is_interrupt_set() {
|
||||
dshot_esc.process();
|
||||
//let control_val = dc_driver::
|
||||
//this bad boy needs floats, this will be fun :)
|
||||
dshot_esc.set_throttle(control as _);
|
||||
rpm = match dshot_esc.get_rpm() {
|
||||
Some(x) => {
|
||||
// rprintln!("GOT RPM {}", x);
|
||||
x
|
||||
}
|
||||
None => {
|
||||
// rprintln!("NO RPM!");
|
||||
rpm
|
||||
}
|
||||
};
|
||||
// rprintln!("RPM:{}",rpm);
|
||||
let last_time = esp_hal::time::Instant::now();
|
||||
|
||||
let timestamp = esp_hal::time::Instant::now()
|
||||
.duration_since_epoch()
|
||||
.as_millis();
|
||||
(control, ctx) = controller.compute(ctx, rpm as _, set_point as _, Millis(timestamp), None);
|
||||
let dumped_context = ctx.last_time().expect("LAST TIME!");
|
||||
// rprintln!("control:{},rpm:{}", control,rpm);
|
||||
}
|
||||
rprintln!("Coating done!");
|
||||
dshot_esc.set_throttle(0);
|
||||
// rprintln!("RMT SENT!");
|
||||
// let mut esc = AfroEsc::new(&mut pwm_pin);;
|
||||
// esc.set_timestamp(1000);
|
||||
// delay.delay_millis(3000);
|
||||
|
|
@ -207,7 +176,7 @@ fn main() -> ! {
|
|||
.with_rx(peripherals.GPIO5)
|
||||
.with_tx(peripherals.GPIO7);
|
||||
let mut display = Nextion::new(&mut uart0);
|
||||
|
||||
//we just set it to page0 to be sure
|
||||
display.send_command(b"page page0");
|
||||
let mut _rpm = DEFAULT_TARGET_RPM;
|
||||
let mut _timer = DEFAULT_SPIN_TIME;
|
||||
|
|
@ -220,6 +189,7 @@ fn main() -> ! {
|
|||
}
|
||||
Ok(Command::Start) => {
|
||||
rprintln!("START");
|
||||
display.send_command(b"page page2");
|
||||
started = true;
|
||||
}
|
||||
Ok(Command::Stop) => {
|
||||
|
|
@ -246,12 +216,55 @@ fn main() -> ! {
|
|||
Err(ErrCommand::ReadError) => {
|
||||
rprintln!("READ FAILED!");
|
||||
}
|
||||
_ => {
|
||||
rprintln!("This should never happen!")
|
||||
}
|
||||
}
|
||||
// display.send_command(b"page page0");
|
||||
}
|
||||
if started {
|
||||
rprintln!("STARTING!");
|
||||
// spincoater.armed();
|
||||
rprintln!("STARTING!")
|
||||
let _ = coat_timer
|
||||
.load_value(esp_hal::time::Duration::from_secs(10))
|
||||
.expect("TODO: Could not set timer for coating! ");
|
||||
coat_timer.start();
|
||||
while !coat_timer.is_interrupt_set() {
|
||||
dshot_esc.process();
|
||||
//let control_val = dc_driver::
|
||||
//this bad boy needs floats, this will be fun :)
|
||||
dshot_esc.set_throttle(control as _);
|
||||
rpm = match dshot_esc.get_rpm() {
|
||||
Some(x) => {
|
||||
// rprintln!("GOT RPM {}", x);
|
||||
x
|
||||
}
|
||||
None => {
|
||||
// rprintln!("NO RPM!");
|
||||
rpm
|
||||
}
|
||||
};
|
||||
// rprintln!("RPM:{}",rpm);
|
||||
let last_time = esp_hal::time::Instant::now();
|
||||
|
||||
let timestamp = esp_hal::time::Instant::now()
|
||||
.duration_since_epoch()
|
||||
.as_millis();
|
||||
(control, ctx) =
|
||||
controller.compute(ctx, rpm as _, set_point as _, Millis(timestamp), None);
|
||||
let dumped_context = ctx.last_time().expect("LAST TIME!");
|
||||
// rprintln!("control:{},rpm:{}", control,rpm);
|
||||
//first we send the RPM!
|
||||
let running_rpm = format!("running_rpm.val={}", rpm);
|
||||
display.send_command(running_rpm.to_string().as_bytes());
|
||||
|
||||
let counter = format!("counter.val={}", 1234);
|
||||
display.send_command(counter.to_string().as_bytes());
|
||||
}
|
||||
|
||||
rprintln!("COATING done!");
|
||||
started = false;
|
||||
display.send_command(b"page page0");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue