remove led2 (tiny led)
This commit is contained in:
parent
b0b77a1538
commit
17d6f156db
2 changed files with 46 additions and 45 deletions
|
|
@ -193,7 +193,7 @@ pub struct TimerConfig {
|
||||||
pub usb_adc_timer_ms: usize,
|
pub usb_adc_timer_ms: usize,
|
||||||
pub led0_timer_ms: usize,
|
pub led0_timer_ms: usize,
|
||||||
pub led1_timer_ms: usize,
|
pub led1_timer_ms: usize,
|
||||||
pub led2_timer_ms: usize,
|
// pub led2_timer_ms: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Timers {
|
pub struct Timers {
|
||||||
|
|
@ -203,7 +203,7 @@ pub struct Timers {
|
||||||
usb_adc_timer: TickTimerService,
|
usb_adc_timer: TickTimerService,
|
||||||
led0_timer: TickTimerService,
|
led0_timer: TickTimerService,
|
||||||
led1_timer: TickTimerService,
|
led1_timer: TickTimerService,
|
||||||
led2_timer: TickTimerService,
|
// led2_timer: TickTimerService,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Timers {
|
impl Timers {
|
||||||
|
|
@ -233,10 +233,10 @@ impl Timers {
|
||||||
TickServiceData::new(config.led1_timer_ms * system_tick_rate_hz / 1000),
|
TickServiceData::new(config.led1_timer_ms * system_tick_rate_hz / 1000),
|
||||||
true,
|
true,
|
||||||
),
|
),
|
||||||
led2_timer: TickTimerService::new(
|
// led2_timer: TickTimerService::new(
|
||||||
TickServiceData::new(config.led2_timer_ms * system_tick_rate_hz / 1000),
|
// TickServiceData::new(config.led2_timer_ms * system_tick_rate_hz / 1000),
|
||||||
true,
|
// true,
|
||||||
),
|
// ),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn tick(&mut self) {
|
pub fn tick(&mut self) {
|
||||||
|
|
@ -246,7 +246,7 @@ impl Timers {
|
||||||
self.usb_adc_timer.tick();
|
self.usb_adc_timer.tick();
|
||||||
self.led0_timer.tick();
|
self.led0_timer.tick();
|
||||||
self.led1_timer.tick();
|
self.led1_timer.tick();
|
||||||
self.led2_timer.tick();
|
// self.led2_timer.tick();
|
||||||
}
|
}
|
||||||
pub fn need_service(&self) -> bool {
|
pub fn need_service(&self) -> bool {
|
||||||
self.sp_timer.need_service()
|
self.sp_timer.need_service()
|
||||||
|
|
@ -255,7 +255,7 @@ impl Timers {
|
||||||
| self.usb_adc_timer.need_service()
|
| self.usb_adc_timer.need_service()
|
||||||
| self.led0_timer.need_service()
|
| self.led0_timer.need_service()
|
||||||
| self.led1_timer.need_service()
|
| self.led1_timer.need_service()
|
||||||
| self.led2_timer.need_service()
|
// | self.led2_timer.need_service()
|
||||||
}
|
}
|
||||||
pub fn init(&mut self) {
|
pub fn init(&mut self) {
|
||||||
self.led0_timer.reset();
|
self.led0_timer.reset();
|
||||||
|
|
@ -272,7 +272,7 @@ impl Timers {
|
||||||
pub struct Services {
|
pub struct Services {
|
||||||
pub led0: LedService,
|
pub led0: LedService,
|
||||||
pub led1: LedService,
|
pub led1: LedService,
|
||||||
pub led2: LedService,
|
// pub led2: LedService,
|
||||||
pub synth0: SynthesizerService,
|
pub synth0: SynthesizerService,
|
||||||
pub sample_player: DacService<'static>,
|
pub sample_player: DacService<'static>,
|
||||||
pub sequencer: sequencer::DynamicSequence<'static>,
|
pub sequencer: sequencer::DynamicSequence<'static>,
|
||||||
|
|
@ -294,7 +294,7 @@ pub struct Config {
|
||||||
pub struct Sequences {
|
pub struct Sequences {
|
||||||
pub led0: sequencer::BasicSequence<'static>,
|
pub led0: sequencer::BasicSequence<'static>,
|
||||||
pub led1: sequencer::BasicSequence<'static>,
|
pub led1: sequencer::BasicSequence<'static>,
|
||||||
pub led2: sequencer::BasicSequence<'static>,
|
// pub led2: sequencer::BasicSequence<'static>,
|
||||||
pub audio: &'static [(&'static [sequencer::SequenceEntry], usize)],
|
pub audio: &'static [(&'static [sequencer::SequenceEntry], usize)],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -345,8 +345,8 @@ impl App {
|
||||||
self.timers.led1_timer.reset();
|
self.timers.led1_timer.reset();
|
||||||
self.timers.led1_timer.enable(true);
|
self.timers.led1_timer.enable(true);
|
||||||
|
|
||||||
self.timers.led2_timer.reset();
|
// self.timers.led2_timer.reset();
|
||||||
self.timers.led2_timer.enable(true);
|
// self.timers.led2_timer.enable(true);
|
||||||
|
|
||||||
self.services.synth0.set_freq(1);
|
self.services.synth0.set_freq(1);
|
||||||
self.services.synth0.disable();
|
self.services.synth0.disable();
|
||||||
|
|
@ -442,23 +442,23 @@ impl App {
|
||||||
// #[cfg(feature = "enable_print")]
|
// #[cfg(feature = "enable_print")]
|
||||||
// println!("led1 service");
|
// println!("led1 service");
|
||||||
}
|
}
|
||||||
if self.timers.led2_timer.need_service() {
|
// if self.timers.led2_timer.need_service() {
|
||||||
let out = match self.settings.brightness {
|
// let out = match self.settings.brightness {
|
||||||
Level::Off => 0,
|
// Level::Off => 0,
|
||||||
Level::Low => 5,
|
// Level::Low => 5,
|
||||||
Level::Medium => 25,
|
// Level::Medium => 25,
|
||||||
Level::High => 75,
|
// Level::High => 75,
|
||||||
Level::Maximum => {
|
// Level::Maximum => {
|
||||||
self.sequences.led2.next();
|
// self.sequences.led2.next();
|
||||||
self.sequences.led2.get_value() / 6
|
// self.sequences.led2.get_value() / 6
|
||||||
}
|
// }
|
||||||
};
|
// };
|
||||||
self.timers.led2_timer.service();
|
// self.timers.led2_timer.service();
|
||||||
self.services.led2.set_amplitude(out);
|
// self.services.led2.set_amplitude(out);
|
||||||
|
|
||||||
// #[cfg(feature = "enable_print")]
|
// // #[cfg(feature = "enable_print")]
|
||||||
// println!("led2 service");
|
// // println!("led2 service");
|
||||||
}
|
// }
|
||||||
|
|
||||||
// services
|
// services
|
||||||
if self.services.led0.need_service() {
|
if self.services.led0.need_service() {
|
||||||
|
|
@ -473,12 +473,12 @@ impl App {
|
||||||
.write_amplitude(self.services.led1.channel, self.services.led1.amplitude);
|
.write_amplitude(self.services.led1.channel, self.services.led1.amplitude);
|
||||||
self.services.led1.service();
|
self.services.led1.service();
|
||||||
}
|
}
|
||||||
if self.services.led2.need_service() {
|
// if self.services.led2.need_service() {
|
||||||
self.interfaces
|
// self.interfaces
|
||||||
.pwm_core
|
// .pwm_core
|
||||||
.write_amplitude(self.services.led2.channel, self.services.led2.amplitude);
|
// .write_amplitude(self.services.led2.channel, self.services.led2.amplitude);
|
||||||
self.services.led2.service();
|
// self.services.led2.service();
|
||||||
}
|
// }
|
||||||
|
|
||||||
// TODO: disable when you get to the end automatically
|
// TODO: disable when you get to the end automatically
|
||||||
// in the sequencer, not here
|
// in the sequencer, not here
|
||||||
|
|
@ -525,9 +525,9 @@ impl App {
|
||||||
self.interfaces
|
self.interfaces
|
||||||
.pwm_core
|
.pwm_core
|
||||||
.write_amplitude(self.services.led1.channel, 0);
|
.write_amplitude(self.services.led1.channel, 0);
|
||||||
self.interfaces
|
// self.interfaces
|
||||||
.pwm_core
|
// .pwm_core
|
||||||
.write_amplitude(self.services.led2.channel, 0);
|
// .write_amplitude(self.services.led2.channel, 0);
|
||||||
self.interfaces
|
self.interfaces
|
||||||
.pwm_core
|
.pwm_core
|
||||||
.disable(ch32_hal::timer::Channel::Ch4);
|
.disable(ch32_hal::timer::Channel::Ch4);
|
||||||
|
|
|
||||||
|
|
@ -215,9 +215,9 @@ fn app_main(mut p: hal::Peripherals) -> ! {
|
||||||
let led1_pin = PwmPin::new_ch1::<0>(p.PD2);
|
let led1_pin = PwmPin::new_ch1::<0>(p.PD2);
|
||||||
let led1_ch = hal::timer::Channel::Ch1;
|
let led1_ch = hal::timer::Channel::Ch1;
|
||||||
|
|
||||||
// LED2 output setup
|
// // LED2 output setup
|
||||||
let led2_pin = PwmPin::new_ch2::<0>(p.PA1);
|
// let led2_pin = PwmPin::new_ch2::<0>(p.PA1);
|
||||||
let led2_ch = hal::timer::Channel::Ch2;
|
// let led2_ch = hal::timer::Channel::Ch2;
|
||||||
|
|
||||||
// DAC output setup
|
// DAC output setup
|
||||||
let dac_pin = PwmPin::new_ch4::<0>(p.PC4);
|
let dac_pin = PwmPin::new_ch4::<0>(p.PC4);
|
||||||
|
|
@ -227,7 +227,8 @@ fn app_main(mut p: hal::Peripherals) -> ! {
|
||||||
let mut pwm = SimplePwm::new(
|
let mut pwm = SimplePwm::new(
|
||||||
p.TIM1,
|
p.TIM1,
|
||||||
Some(led1_pin),
|
Some(led1_pin),
|
||||||
Some(led2_pin),
|
// Some(led2_pin),
|
||||||
|
None,
|
||||||
Some(led0_pin),
|
Some(led0_pin),
|
||||||
Some(dac_pin),
|
Some(dac_pin),
|
||||||
Hertz::khz(200),
|
Hertz::khz(200),
|
||||||
|
|
@ -236,7 +237,7 @@ fn app_main(mut p: hal::Peripherals) -> ! {
|
||||||
|
|
||||||
pwm.set_polarity(led0_ch, OutputPolarity::ActiveHigh);
|
pwm.set_polarity(led0_ch, OutputPolarity::ActiveHigh);
|
||||||
pwm.set_polarity(led1_ch, OutputPolarity::ActiveLow);
|
pwm.set_polarity(led1_ch, OutputPolarity::ActiveLow);
|
||||||
pwm.set_polarity(led2_ch, OutputPolarity::ActiveLow);
|
// pwm.set_polarity(led2_ch, OutputPolarity::ActiveLow);
|
||||||
|
|
||||||
let tick_rate_hz = 50000;
|
let tick_rate_hz = 50000;
|
||||||
|
|
||||||
|
|
@ -296,7 +297,7 @@ fn app_main(mut p: hal::Peripherals) -> ! {
|
||||||
usb_adc_timer_ms: 10000,
|
usb_adc_timer_ms: 10000,
|
||||||
led0_timer_ms: 100,
|
led0_timer_ms: 100,
|
||||||
led1_timer_ms: 100,
|
led1_timer_ms: 100,
|
||||||
led2_timer_ms: 100,
|
// led2_timer_ms: 100,
|
||||||
};
|
};
|
||||||
|
|
||||||
let app_config = Config {
|
let app_config = Config {
|
||||||
|
|
@ -320,7 +321,7 @@ fn app_main(mut p: hal::Peripherals) -> ! {
|
||||||
let app_services = Services {
|
let app_services = Services {
|
||||||
led0: LedService::new(led0_ch),
|
led0: LedService::new(led0_ch),
|
||||||
led1: LedService::new(led1_ch),
|
led1: LedService::new(led1_ch),
|
||||||
led2: LedService::new(led2_ch),
|
// led2: LedService::new(led2_ch),
|
||||||
synth0: SynthesizerService::new(tick_rate_hz),
|
synth0: SynthesizerService::new(tick_rate_hz),
|
||||||
sample_player,
|
sample_player,
|
||||||
sequencer,
|
sequencer,
|
||||||
|
|
@ -329,7 +330,7 @@ fn app_main(mut p: hal::Peripherals) -> ! {
|
||||||
let app_sequences = Sequences {
|
let app_sequences = Sequences {
|
||||||
led0: BasicSequence::new(&LED0_SEQ),
|
led0: BasicSequence::new(&LED0_SEQ),
|
||||||
led1: BasicSequence::new(&LED0_SEQ),
|
led1: BasicSequence::new(&LED0_SEQ),
|
||||||
led2: BasicSequence::new(&LED0_SEQ),
|
// led2: BasicSequence::new(&LED0_SEQ),
|
||||||
audio: &SEQUENCE_LIST,
|
audio: &SEQUENCE_LIST,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue