Adjustments for front porch calculation.

This commit is contained in:
giomba 2022-11-27 22:07:01 +01:00
parent 0cf72757e9
commit 9fcb7b3e99
2 changed files with 30 additions and 9 deletions

View File

@ -134,6 +134,17 @@ void set_pixel(uint16_t x, uint16_t y)
frames[0].data[y * 80 + x / 8] |= (1 << x % 8); frames[0].data[y * 80 + x / 8] |= (1 << x % 8);
} }
void draw_simple_line(uint16_t x, uint16_t y, uint16_t len, bool horizontal)
{
for (uint16_t i = 0; i < len; ++i)
{
if (horizontal)
set_pixel(x + i, y);
else
set_pixel(x, y + i);
}
}
/** /**
* @brief Represents a program running on the SM of a PIO. * @brief Represents a program running on the SM of a PIO.
* *
@ -157,17 +168,28 @@ int main()
// horizontal lines // horizontal lines
for (uint16_t x = 0; x < 639; ++x) // last pixel high -> bad for (uint16_t x = 0; x < 639; ++x) // last pixel high -> bad
{ {
set_pixel(x, 0); if ((x / 32) % 2 == 0)
set_pixel(x, 21);
set_pixel(x, 239); set_pixel(x, 239);
set_pixel(x, 479); set_pixel(x, 479);
} }
// vertical lines // vertical lines
for (uint16_t y = 0; y < 480; ++y) for (uint16_t y = 21; y < 480; ++y)
{ {
set_pixel(0, y); set_pixel(0 + ((y - 20) / 10) * 4, y);
set_pixel(239, y); set_pixel(239, y);
set_pixel(638, y); set_pixel(638, y);
} }
// try to find strangeness using stairs
for (uint16_t x = 0; x < 639; ++x)
{
set_pixel(x, (x / 32) * 4 + 120);
}
// draw "E" - nice because it's not symmetrical along X
draw_simple_line(100, 100, 8, true);
draw_simple_line(100, 100, 8, false);
draw_simple_line(100, 104, 8, true);
draw_simple_line(100, 108, 8, true);
// Running programs on PIO // Running programs on PIO
PIORun vga_hsync, vga_vsync, vga_pixel; PIORun vga_hsync, vga_vsync, vga_pixel;
@ -188,8 +210,8 @@ int main()
vga_hsync.sm = pio_claim_unused_sm(vga_hsync.pio, true); vga_hsync.sm = pio_claim_unused_sm(vga_hsync.pio, true);
vga_hsync_program_init(vga_hsync.pio, vga_hsync.sm, vga_hsync.offset); vga_hsync_program_init(vga_hsync.pio, vga_hsync.sm, vga_hsync.offset);
// low pulse is X pixels long, and SM runs at 4x of pixel clock // low pulse is X pixels long, and SM runs at 4x of pixel clock
pio_sm_put_blocking(vga_hsync.pio, vga_hsync.sm, (64 - 1)); pio_sm_put_blocking(vga_hsync.pio, vga_hsync.sm, (64 - 2));
pio_sm_put_blocking(vga_hsync.pio, vga_hsync.sm, (640 - 1)); pio_sm_put_blocking(vga_hsync.pio, vga_hsync.sm, (640 + 16 - 1)); // 16 is front porch
printf("OK\n"); printf("OK\n");
// VGA VSYNC program // VGA VSYNC program

View File

@ -8,7 +8,7 @@ entrypoint_vga_free_run:
mov x, y mov x, y
wait irq 7 wait irq 7
loop: loop:
out pins, 1 [3] out pins, 1 [2]
jmp x-- loop jmp x-- loop
.wrap .wrap
@ -27,10 +27,9 @@ hsync_pulse:
jmp x-- hsync_pulse [3] jmp x-- hsync_pulse [3]
set pins, 1 [1] set pins, 1 [1]
set y, 24 set y, 27
hsync_back_porch: hsync_back_porch:
jmp y-- hsync_back_porch [19] jmp y-- hsync_back_porch [16]
irq set 7 irq set 7
mov x, osr [3] mov x, osr [3]