disable adc wip
This commit is contained in:
parent
5141bbda7b
commit
60fd0a02f8
@ -23,17 +23,13 @@ impl DisplayController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn display_led_state(bus: &mut Bus, led_state: &LedState, delay: &mut Delay) {
|
pub fn display_led_state(i: u8, bus: &mut Bus, led_state: &LedState, delay: &mut Delay) {
|
||||||
for i in 0_u8..6_u8 {
|
|
||||||
let ic_3_value = led_state.ic_3_value(i as _);
|
let ic_3_value = led_state.ic_3_value(i as _);
|
||||||
|
|
||||||
bus.output(10, 1_u8 << i);
|
bus.output(10, 1_u8 << i);
|
||||||
bus.output(3, ic_3_value);
|
bus.output(3, ic_3_value);
|
||||||
delay.delay_us(20u16);
|
delay.delay_us(20u16);
|
||||||
bus.output(3, 0xFF);
|
bus.output(3, 0xFF);
|
||||||
|
|
||||||
bus.output(11, 4_u8 << i);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -4,7 +4,6 @@ use hal::{delay::Delay, serial::Serial, stm32};
|
|||||||
use hal::gpio::{Input, Floating, gpiob};
|
use hal::gpio::{Input, Floating, gpiob};
|
||||||
use embedded_midi::{MidiOut, MidiIn};
|
use embedded_midi::{MidiOut, MidiIn};
|
||||||
use crate::bus::Bus;
|
use crate::bus::Bus;
|
||||||
use crate::adc::Tlc0832;
|
|
||||||
|
|
||||||
pub struct Hardware {
|
pub struct Hardware {
|
||||||
pub delay: Delay,
|
pub delay: Delay,
|
||||||
@ -13,7 +12,6 @@ pub struct Hardware {
|
|||||||
pub bus: Bus,
|
pub bus: Bus,
|
||||||
pub midi_tx: MidiOut<hal::serial::Tx<stm32::USART1>>,
|
pub midi_tx: MidiOut<hal::serial::Tx<stm32::USART1>>,
|
||||||
pub midi_rx: MidiIn<hal::serial::Rx<stm32::USART1>>,
|
pub midi_rx: MidiIn<hal::serial::Rx<stm32::USART1>>,
|
||||||
pub adc: Tlc0832,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Hardware {
|
impl Hardware {
|
||||||
@ -54,13 +52,6 @@ impl Hardware {
|
|||||||
let midi_tx = MidiOut::new(tx);
|
let midi_tx = MidiOut::new(tx);
|
||||||
let midi_rx = MidiIn::new(rx);
|
let midi_rx = MidiIn::new(rx);
|
||||||
|
|
||||||
let adc_sck = cortex_m::interrupt::free(|cs| gpiob.pb10.into_floating_input(cs));
|
|
||||||
let adc_miso = cortex_m::interrupt::free(|cs| gpiob.pb14.into_floating_input(cs));
|
|
||||||
let adc_mosi = cortex_m::interrupt::free(|cs| gpiob.pb15.into_floating_input(cs));
|
|
||||||
let adc_cs = cortex_m::interrupt::free(|cs| gpiob.pb12.into_floating_input(cs));
|
|
||||||
|
|
||||||
let adc = Tlc0832::new(dp.SPI2, adc_sck, adc_miso, adc_mosi, adc_cs, &mut rcc);
|
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
delay,
|
delay,
|
||||||
button_1_5,
|
button_1_5,
|
||||||
@ -68,7 +59,6 @@ impl Hardware {
|
|||||||
bus,
|
bus,
|
||||||
midi_tx,
|
midi_tx,
|
||||||
midi_rx,
|
midi_rx,
|
||||||
adc,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -7,7 +7,6 @@ mod button;
|
|||||||
mod midi;
|
mod midi;
|
||||||
mod hardware;
|
mod hardware;
|
||||||
mod display;
|
mod display;
|
||||||
mod adc;
|
|
||||||
|
|
||||||
use cortex_m_rt::entry;
|
use cortex_m_rt::entry;
|
||||||
use panic_halt as _;
|
use panic_halt as _;
|
||||||
@ -18,8 +17,6 @@ use button::ButtonHandler;
|
|||||||
use midi::MidiProcessor;
|
use midi::MidiProcessor;
|
||||||
use hardware::Hardware;
|
use hardware::Hardware;
|
||||||
use display::DisplayController;
|
use display::DisplayController;
|
||||||
use embedded_midi::MidiMessage;
|
|
||||||
use midi_types::{Control, Channel, Value7};
|
|
||||||
|
|
||||||
defmt::timestamp!("{=u32}", {
|
defmt::timestamp!("{=u32}", {
|
||||||
static mut COUNTER: u32 = 0;
|
static mut COUNTER: u32 = 0;
|
||||||
@ -41,9 +38,10 @@ fn main() -> ! {
|
|||||||
|
|
||||||
loop {
|
loop {
|
||||||
for _ in 0..20 {
|
for _ in 0..20 {
|
||||||
DisplayController::display_led_state(&mut hardware.bus, &led_state, &mut hardware.delay);
|
|
||||||
|
|
||||||
for i in 0_u8..6_u8 {
|
for i in 0_u8..6_u8 {
|
||||||
|
DisplayController::display_led_state(i, &mut hardware.bus, &led_state, &mut hardware.delay);
|
||||||
|
hardware.bus.output(11, 4_u8 << i);
|
||||||
|
|
||||||
button_handler.process_buttons(
|
button_handler.process_buttons(
|
||||||
&hardware.button_1_5,
|
&hardware.button_1_5,
|
||||||
&hardware.button_6_10,
|
&hardware.button_6_10,
|
||||||
@ -53,18 +51,6 @@ fn main() -> ! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
MidiProcessor::process_message(&mut hardware.midi_rx, &mut led_state);
|
MidiProcessor::process_message(&mut hardware.midi_rx, &mut led_state);
|
||||||
|
|
||||||
let (pedal_a_change, pedal_b_change) = hardware.adc.update_and_get_midi_changes();
|
|
||||||
|
|
||||||
if let Some(value) = pedal_a_change {
|
|
||||||
let msg = MidiMessage::ControlChange(Channel::C1, Control::from(1), Value7::new(value));
|
|
||||||
hardware.midi_tx.write(&msg).ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(value) = pedal_b_change {
|
|
||||||
let msg = MidiMessage::ControlChange(Channel::C1, Control::from(7), Value7::new(value));
|
|
||||||
hardware.midi_tx.write(&msg).ok();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user