slight refactoring, also fuck that
This commit is contained in:
parent
94f28e0034
commit
2d8de20d57
1 changed files with 25 additions and 24 deletions
|
|
@ -12,18 +12,18 @@ use esp_hal::delay::Delay;
|
|||
use esp_hal::uart::{Config, Uart};
|
||||
use esp_hal::{gpio, main};
|
||||
|
||||
use core::fmt::Debug;
|
||||
use esp_hal::gpio::{Event, OutputConfig};
|
||||
use esp_hal::gpio::{Input, InputConfig};
|
||||
use esp_hal::handler;
|
||||
use esp_hal::rmt::{Rmt, TxChannelConfig, TxChannelCreator};
|
||||
use esp_hal::time::{Instant, Rate};
|
||||
use core::fmt::Debug;
|
||||
//pid-controller
|
||||
use core::time::Duration;
|
||||
use discrete_pid::pid::PidContext;
|
||||
use discrete_pid::time::InstantLike;
|
||||
use discrete_pid::time::Millis;
|
||||
use discrete_pid::{pid, time};
|
||||
use discrete_pid::time::InstantLike;
|
||||
|
||||
use core::cell::RefCell;
|
||||
use core::mem::forget;
|
||||
|
|
@ -44,9 +44,9 @@ use crate::peripherals::ErrCommand;
|
|||
use esp_hal::rmt::RxChannelConfig;
|
||||
use esp_hal::rmt::RxChannelCreator;
|
||||
|
||||
use esp_hal::timer::timg::TimerGroup;
|
||||
use esp_hal::timer::OneShotTimer;
|
||||
use esp_hal::timer::Timer;
|
||||
use esp_hal::timer::timg::TimerGroup;
|
||||
#[panic_handler]
|
||||
fn panic(panic: &core::panic::PanicInfo) -> ! {
|
||||
rprintln!("{}", panic.message());
|
||||
|
|
@ -82,8 +82,6 @@ impl InstantLike for Time {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#[main]
|
||||
fn main() -> ! {
|
||||
// generator version: 1.0.1
|
||||
|
|
@ -131,7 +129,8 @@ fn main() -> ! {
|
|||
let loop_time = Duration::from_micros(10);
|
||||
let cfg = pid::PidConfigBuilder::default()
|
||||
.kp(3.0)
|
||||
.ki(1.0).output_limits(100.00, 2040.00)
|
||||
.ki(1.0)
|
||||
.output_limits(100.00, 2040.00)
|
||||
.sample_time(loop_time)
|
||||
.filter_tc(0.1)
|
||||
.build()
|
||||
|
|
@ -143,12 +142,12 @@ fn main() -> ! {
|
|||
let mut rpm = 0;
|
||||
let mut control: f32 = 200.0;
|
||||
let mut timg0 = TimerGroup::new(peripherals.TIMG0);
|
||||
let timer0 = timg0.timer0;
|
||||
// let now =timer.now();
|
||||
//we need the explicit type here!
|
||||
timer0.load_value(esp_hal::time::Duration::from_secs(10));
|
||||
timer0.start();
|
||||
while !timer0.is_interrupt_set() {
|
||||
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 :)
|
||||
|
|
@ -166,7 +165,9 @@ fn main() -> ! {
|
|||
// rprintln!("RPM:{}",rpm);
|
||||
let last_time = esp_hal::time::Instant::now();
|
||||
|
||||
let timestamp = esp_hal::time::Instant::now().duration_since_epoch().as_millis();
|
||||
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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue