Adjustments for front porch calculation.
This commit is contained in:
parent
0cf72757e9
commit
9fcb7b3e99
32
src/main.c
32
src/main.c
@ -134,6 +134,17 @@ void set_pixel(uint16_t x, uint16_t y)
|
||||
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.
|
||||
*
|
||||
@ -157,17 +168,28 @@ int main()
|
||||
// horizontal lines
|
||||
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, 479);
|
||||
}
|
||||
// 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(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
|
||||
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_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
|
||||
pio_sm_put_blocking(vga_hsync.pio, vga_hsync.sm, (64 - 1));
|
||||
pio_sm_put_blocking(vga_hsync.pio, vga_hsync.sm, (640 - 1));
|
||||
pio_sm_put_blocking(vga_hsync.pio, vga_hsync.sm, (64 - 2));
|
||||
pio_sm_put_blocking(vga_hsync.pio, vga_hsync.sm, (640 + 16 - 1)); // 16 is front porch
|
||||
printf("OK\n");
|
||||
|
||||
// VGA VSYNC program
|
||||
|
@ -8,7 +8,7 @@ entrypoint_vga_free_run:
|
||||
mov x, y
|
||||
wait irq 7
|
||||
loop:
|
||||
out pins, 1 [3]
|
||||
out pins, 1 [2]
|
||||
jmp x-- loop
|
||||
.wrap
|
||||
|
||||
@ -27,10 +27,9 @@ hsync_pulse:
|
||||
jmp x-- hsync_pulse [3]
|
||||
|
||||
set pins, 1 [1]
|
||||
set y, 24
|
||||
set y, 27
|
||||
hsync_back_porch:
|
||||
jmp y-- hsync_back_porch [19]
|
||||
|
||||
jmp y-- hsync_back_porch [16]
|
||||
irq set 7
|
||||
|
||||
mov x, osr [3]
|
||||
|
Loading…
Reference in New Issue
Block a user