Skip to content

Commit

Permalink
rtl/hw: last 2 pmods and touch mappings
Browse files Browse the repository at this point in the history
  • Loading branch information
vk2seb committed Dec 7, 2023
1 parent aa24ba1 commit 0749502
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 7 deletions.
32 changes: 28 additions & 4 deletions example-colorlight-i5.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,28 @@
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")),
Subsignal("sdout1", Pins("M18")),
IOStandard("LVCMOS33")
),
("eurorack_pmod_aux3", 0,
# Local signals AUX3
Subsignal("i2c_sda", Pins("D2")),
Subsignal("i2c_scl", Pins("E2")),
Subsignal("sdin1", Pins("A3")),
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 6 additions & 2 deletions firmware/polyvec/src/draw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
}
Expand Down
2 changes: 2 additions & 0 deletions firmware/polyvec/src/gw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
28 changes: 27 additions & 1 deletion firmware/polyvec/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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() {
Expand All @@ -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());
Expand Down

0 comments on commit 0749502

Please sign in to comment.