From 0749502d560adcd91014fbb58af054e0ea50fc2e Mon Sep 17 00:00:00 2001 From: Sebastian Holzapfel Date: Thu, 7 Dec 2023 16:19:09 +0100 Subject: [PATCH] rtl/hw: last 2 pmods and touch mappings --- example-colorlight-i5.py | 32 ++++++++++++++++++++++++++++---- firmware/polyvec/src/draw.rs | 8 ++++++-- firmware/polyvec/src/gw.rs | 2 ++ firmware/polyvec/src/main.rs | 28 +++++++++++++++++++++++++++- 4 files changed, 63 insertions(+), 7 deletions(-) diff --git a/example-colorlight-i5.py b/example-colorlight-i5.py index 3483d09..784aec7 100755 --- a/example-colorlight-i5.py +++ b/example-colorlight-i5.py @@ -34,8 +34,21 @@ Subsignal("pdn", Pins("R3")), IOStandard("LVCMOS33") ), + ("eurorack_pmod_aux0", 0, + Subsignal("i2c_sda", Pins("L4")), + Subsignal("i2c_scl", Pins("N4")), + Subsignal("sdin1", Pins("J18")), + Subsignal("sdout1", Pins("P16")), + IOStandard("LVCMOS33") + ), + ("eurorack_pmod_aux1", 0, + Subsignal("i2c_sda", Pins("K20")), + Subsignal("i2c_scl", Pins("G20")), + Subsignal("sdin1", Pins("N18")), + Subsignal("sdout1", Pins("L20")), + IOStandard("LVCMOS33") + ), ("eurorack_pmod_aux2", 0, - # Local signals AUX2 Subsignal("i2c_sda", Pins("L18")), Subsignal("i2c_scl", Pins("J20")), Subsignal("sdin1", Pins("N17")), @@ -43,7 +56,6 @@ IOStandard("LVCMOS33") ), ("eurorack_pmod_aux3", 0, - # Local signals AUX3 Subsignal("i2c_sda", Pins("D2")), Subsignal("i2c_scl", Pins("E2")), Subsignal("sdin1", Pins("A3")), @@ -258,18 +270,30 @@ def main(): shared_pads = soc.platform.request("eurorack_pmod_clk0") - pmod0_pads = soc.platform.request("eurorack_pmod_aux3") + pmod0_pads = soc.platform.request("eurorack_pmod_aux2") pmod0 = EurorackPmod(soc.platform, pmod0_pads, drive_shared_pads=shared_pads) soc.add_module("eurorack_pmod0", pmod0) into_shifter(soc, pmod0) - pmod1_pads = soc.platform.request("eurorack_pmod_aux2") + pmod1_pads = soc.platform.request("eurorack_pmod_aux0") pmod1 = EurorackPmod(soc.platform, pmod1_pads, drive_shared_pads=None, external_reset=pmod0.rst) soc.add_module("eurorack_pmod1", pmod1) into_mirror(soc, pmod1) + pmod2_pads = soc.platform.request("eurorack_pmod_aux1") + pmod2 = EurorackPmod(soc.platform, pmod2_pads, drive_shared_pads=None, external_reset=pmod0.rst) + soc.add_module("eurorack_pmod2", pmod2) + + into_mirror(soc, pmod2) + + pmod3_pads = soc.platform.request("eurorack_pmod_aux3") + pmod3 = EurorackPmod(soc.platform, pmod3_pads, drive_shared_pads=None, external_reset=pmod0.rst) + soc.add_module("eurorack_pmod3", pmod3) + + into_mirror(soc, pmod3) + add_oled(soc) add_uart_midi(soc) diff --git a/firmware/polyvec/src/draw.rs b/firmware/polyvec/src/draw.rs index fd68f81..55eaa10 100644 --- a/firmware/polyvec/src/draw.rs +++ b/firmware/polyvec/src/draw.rs @@ -275,17 +275,21 @@ where } if opts.screen.value == opt::Screen::Touch { + let n_width = 8; for (n_touch, touch) in touch.iter().enumerate() { let mut s: String<16> = String::new(); ufmt::uwrite!(&mut s, "{}", n_touch).ok(); - draw_title_box(d, &s, Point::new((16*n_touch) as i32, 0), Size::new(15, 16))?; let stroke_gain = PrimitiveStyleBuilder::new() .stroke_color(Gray4::new(((*touch as u32 * 15u32) / 256u32) as u8)) .stroke_width(1) .build(); - Rectangle::new(Point::new((16*n_touch) as i32+1, 10), Size::new(13, 5)) + let px = 16 * (n_touch % n_width); + let py = 16 * (n_touch / n_width); + + draw_title_box(d, &s, Point::new(px as i32, py as i32), Size::new(15, 16))?; + Rectangle::new(Point::new(px as i32+1, py as i32+10), Size::new(13, 5)) .into_styled(stroke_gain) .draw(d)?; } diff --git a/firmware/polyvec/src/gw.rs b/firmware/polyvec/src/gw.rs index 93f8664..a12c1a8 100644 --- a/firmware/polyvec/src/gw.rs +++ b/firmware/polyvec/src/gw.rs @@ -161,6 +161,8 @@ macro_rules! karlsen_lpf { eurorack_pmod!(pac::EURORACK_PMOD0); eurorack_pmod_reset!(pac::EURORACK_PMOD0); eurorack_pmod!(pac::EURORACK_PMOD1); +eurorack_pmod!(pac::EURORACK_PMOD2); +eurorack_pmod!(pac::EURORACK_PMOD3); pitch_shift!(pac::PITCH_SHIFT0); pitch_shift!(pac::PITCH_SHIFT1); pitch_shift!(pac::PITCH_SHIFT2); diff --git a/firmware/polyvec/src/main.rs b/firmware/polyvec/src/main.rs index 8bdfd62..516a68b 100644 --- a/firmware/polyvec/src/main.rs +++ b/firmware/polyvec/src/main.rs @@ -343,6 +343,8 @@ fn main() -> ! { pmod0.reset(&mut timer); let pmod1 = peripherals.EURORACK_PMOD1; + let pmod2 = peripherals.EURORACK_PMOD2; + let pmod3 = peripherals.EURORACK_PMOD3; let mut disp = oled_init(&mut timer, peripherals.OLED_SPI); let mut spi_dma = SpiDma::new(peripherals.SPI_DMA, pac::OLED_SPI::PTR); @@ -412,8 +414,16 @@ fn main() -> ! { let touch0 = pmod0.touch(); let touch1 = pmod1.touch(); + let touch2 = pmod2.touch(); + let touch3 = pmod3.touch(); - draw::draw_main(&mut disp, opts.clone(), voices, &scope_samples, &touch0, + let mut touch_concat: [u8; 8*4] = [0u8; 8*4]; + touch_concat[0..8].copy_from_slice(&touch0); + touch_concat[8..16].copy_from_slice(&touch1); + touch_concat[16..24].copy_from_slice(&touch2); + touch_concat[24..32].copy_from_slice(&touch3); + + draw::draw_main(&mut disp, opts.clone(), voices, &scope_samples, &touch_concat, irq0_len_us, trace_main.len_us()).ok(); for (n, v) in touch0.iter().enumerate() { @@ -432,6 +442,22 @@ fn main() -> ! { } } + for (n, v) in touch2.iter().enumerate() { + if opts.touch.led_mirror.value == opt::TouchLedMirror::MirrorOn { + pmod2.led_set(n, (v >> 1) as i8); + } else { + pmod2.led_auto(n); + } + } + + for (n, v) in touch3.iter().enumerate() { + if opts.touch.led_mirror.value == opt::TouchLedMirror::MirrorOn { + pmod3.led_set(n, (v >> 1) as i8); + } else { + pmod3.led_auto(n); + } + } + let fb = disp.swap_clear(); fence(); spi_dma.transfer(fb.as_ptr(), fb.len());