dynamic sequencer support
This commit is contained in:
parent
7d93cd8977
commit
9e67026345
3 changed files with 144 additions and 22 deletions
|
|
@ -36,7 +36,19 @@ use hal::println;
|
|||
|
||||
use qingke::riscv;
|
||||
|
||||
use crate::app::sequencer::{DynamicSequence, SequenceEntry};
|
||||
|
||||
static LED0_SEQ: [u8; 8] = [0u8, 25u8, 50u8, 75u8, 100u8, 75u8, 50u8, 25u8];
|
||||
static TEST_SEQ: [app::sequencer::SequenceEntry; 2] = [
|
||||
SequenceEntry {
|
||||
frequency_hz: 440,
|
||||
duration_ms: 1000,
|
||||
},
|
||||
SequenceEntry {
|
||||
frequency_hz: 220,
|
||||
duration_ms: 1000,
|
||||
},
|
||||
];
|
||||
|
||||
#[derive(Debug)]
|
||||
struct Flag {
|
||||
|
|
@ -86,8 +98,8 @@ static mut INPUT_FLAGS: InputFlags = InputFlags {
|
|||
struct Test {}
|
||||
impl Handler<hal::interrupt::typelevel::EXTI7_0> for Test {
|
||||
unsafe fn on_interrupt() {
|
||||
#[cfg(feature = "enable_print")]
|
||||
println!("on_interrupt()");
|
||||
// #[cfg(feature = "enable_print")]
|
||||
// println!("on_interrupt()");
|
||||
critical_section::with(|_| unsafe {
|
||||
let flags = system::clear_interrupt(2, 6);
|
||||
if flags[0] {
|
||||
|
|
@ -206,8 +218,8 @@ fn app_main(mut p: hal::Peripherals) -> ! {
|
|||
// println!("ADC_PIN CHANNEL: {}", adc_pin.channel().channel());
|
||||
let adc_cal = adc.calibrate();
|
||||
|
||||
#[cfg(feature = "enable_print")]
|
||||
println!("ADC calibration value: {}", adc_cal);
|
||||
// #[cfg(feature = "enable_print")]
|
||||
// println!("ADC calibration value: {}", adc_cal);
|
||||
|
||||
// definitions
|
||||
let sense_coin_pin = p.PC2;
|
||||
|
|
@ -260,12 +272,15 @@ fn app_main(mut p: hal::Peripherals) -> ! {
|
|||
let sample_player = DacService::new(ch32_hal::timer::Channel::Ch4, dac_service_data);
|
||||
sample_player.load_data(coin_sound);
|
||||
|
||||
let sequencer = app::sequencer::DynamicSequence::new(&TEST_SEQ, tick_rate_hz);
|
||||
|
||||
let app_services = Services {
|
||||
led0: LedService::new(led0_ch),
|
||||
led1: LedService::new(led1_ch),
|
||||
led2: LedService::new(led2_ch),
|
||||
synth0: SynthesizerService::new(tick_rate_hz),
|
||||
sample_player,
|
||||
sequencer,
|
||||
};
|
||||
|
||||
let app_sequences = Sequences {
|
||||
|
|
@ -303,9 +318,8 @@ fn app_main(mut p: hal::Peripherals) -> ! {
|
|||
// -depress the big button for approx 2s and it puts the led into low light mode. Just making it dimmer than usual.
|
||||
// -depress the big button for 5s and it goes into deep sleep, everything off with the low sleep current draw
|
||||
|
||||
#[cfg(feature = "enable_print")]
|
||||
println!("begin");
|
||||
|
||||
// #[cfg(feature = "enable_print")]
|
||||
// println!("begin");
|
||||
let mut volume_btn_prev = volume_btn_input.is_high_immediate();
|
||||
let mut light_ctrl_btn_prev = light_ctrl_btn_input.is_high_immediate();
|
||||
|
||||
|
|
@ -324,8 +338,8 @@ fn app_main(mut p: hal::Peripherals) -> ! {
|
|||
|
||||
volume_btn_input.service();
|
||||
if volume_btn_input.ready() {
|
||||
#[cfg(feature = "enable_print")]
|
||||
println!("volume btn value: {}", volume_btn_input.value());
|
||||
// #[cfg(feature = "enable_print")]
|
||||
// println!("volume btn value: {}", volume_btn_input.value());
|
||||
if !volume_btn_input.value() {
|
||||
app.volume_button();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue