some display plumbing
This commit is contained in:
parent
db90f6dc0c
commit
9e842a2a30
2 changed files with 17 additions and 10 deletions
|
|
@ -128,8 +128,8 @@ fn main() -> ! {
|
|||
//PID-Controller
|
||||
let loop_time = Duration::from_micros(10);
|
||||
let cfg = pid::PidConfigBuilder::default()
|
||||
.kp(3.0)
|
||||
.ki(1.0)
|
||||
.kp(0.4)
|
||||
.ki(0.0)
|
||||
.output_limits(100.00, 2040.00)
|
||||
.sample_time(loop_time)
|
||||
.filter_tc(0.1)
|
||||
|
|
@ -138,12 +138,11 @@ fn main() -> ! {
|
|||
let controller = pid::FuncPidController::new(cfg);
|
||||
let mut ctx = PidContext::new(Millis(0), 0.0, 0.0);
|
||||
let set_point = DEFAULT_TARGET_RPM;
|
||||
dshot_esc.arm();
|
||||
let mut rpm = 0;
|
||||
let mut control: f32 = 200.0;
|
||||
let mut timg0 = TimerGroup::new(peripherals.TIMG0);
|
||||
let coat_timer = timg0.timer0;
|
||||
dshot_esc.set_throttle(0);
|
||||
// shot_esc.set_throttle(0);
|
||||
// let mut esc = AfroEsc::new(&mut pwm_pin);;
|
||||
// esc.set_timestamp(1000);
|
||||
// delay.delay_millis(3000);
|
||||
|
|
@ -224,15 +223,16 @@ fn main() -> ! {
|
|||
}
|
||||
if started {
|
||||
rprintln!("STARTING!");
|
||||
// spincoater.armed();
|
||||
let _ = coat_timer
|
||||
.load_value(esp_hal::time::Duration::from_secs(10))
|
||||
.expect("TODO: Could not set timer for coating! ");
|
||||
dshot_esc.arm();
|
||||
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 :)
|
||||
control = 200.00;
|
||||
dshot_esc.set_throttle(control as _);
|
||||
rpm = match dshot_esc.get_rpm() {
|
||||
Some(x) => {
|
||||
|
|
@ -253,13 +253,17 @@ fn main() -> ! {
|
|||
(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!("control:{},rpm:{}", control,rpm);
|
||||
//first we send the RPM!
|
||||
if display.write_ready(){
|
||||
let running_rpm = format!("running_rpm.val={}", rpm);
|
||||
display.send_command(running_rpm.to_string().as_bytes());
|
||||
|
||||
}
|
||||
if display.write_ready(){
|
||||
let counter = format!("counter.val={}", 1234);
|
||||
display.send_command(counter.to_string().as_bytes());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
rprintln!("COATING done!");
|
||||
|
|
|
|||
|
|
@ -123,6 +123,9 @@ impl<'a> Nextion<'a> {
|
|||
pub fn read_ready(&mut self) -> bool {
|
||||
self.interface.read_ready()
|
||||
}
|
||||
pub fn write_ready(&mut self) -> bool {
|
||||
self.interface.write_ready()
|
||||
}
|
||||
fn reset(&mut self) {
|
||||
self.state = UartStatemachine::WaitingP;
|
||||
self.idx = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue