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