Fix orientation and offset

Signed-off-by: Mahyar Koshkouei <mk@deltabeard.com>
This commit is contained in:
Mahyar Koshkouei
2022-03-27 22:45:47 +01:00
parent 02c6fedeee
commit 4379ef9f47
3 changed files with 33 additions and 7 deletions
+2
View File
@@ -129,6 +129,8 @@ void mk_ili9225_power_control(uint8_t drive_power, bool sleep);
void mk_ili9225_set_drive_freq(uint16_t f); void mk_ili9225_set_drive_freq(uint16_t f);
void mk_ili9225_set_x(uint8_t x);
/** /**
* Exit and stop using LCD. Currently does nothing. * Exit and stop using LCD. Currently does nothing.
*/ */
+24 -4
View File
@@ -148,7 +148,8 @@ void core1_lcd_draw_line(const uint_fast8_t line)
[pixels_buffer[x] & 3]; [pixels_buffer[x] & 3];
} }
mk_ili9225_set_address(0, 15 + line); mk_ili9225_set_address(line + 15, 0xDB - 30);
//mk_ili9225_set_x(line + 15);
#if USE_DMA #if USE_DMA
mk_ili9225_write_pixels_start(); mk_ili9225_write_pixels_start();
dma_channel_transfer_from_buffer_now(dma_lcd, &fb[0], LCD_WIDTH); dma_channel_transfer_from_buffer_now(dma_lcd, &fb[0], LCD_WIDTH);
@@ -193,7 +194,7 @@ void main_core1(void)
#endif #endif
/* Set LCD window to DMG size. */ /* Set LCD window to DMG size. */
mk_ili9225_set_window(15, LCD_HEIGHT+15, 29, LCD_WIDTH+29); //mk_ili9225_set_window(15, LCD_HEIGHT+15, 29, LCD_WIDTH+29);
while(1) while(1)
{ {
@@ -205,7 +206,7 @@ void main_core1(void)
break; break;
case CORE_CMD_IDLE_SET: case CORE_CMD_IDLE_SET:
mk_ili9225_display_control(false, cmd.data); mk_ili9225_display_control(true, cmd.data);
break; break;
case CORE_CMD_NOP: case CORE_CMD_NOP:
@@ -256,7 +257,7 @@ int main(void)
/* Initialise USB serial connection for debugging. */ /* Initialise USB serial connection for debugging. */
stdio_init_all(); stdio_init_all();
(void) getchar(); //(void) getchar();
puts_raw("Starting"); puts_raw("Starting");
/* Initialise GPIO pins. */ /* Initialise GPIO pins. */
@@ -313,6 +314,7 @@ int main(void)
} while(HEDLEY_LIKELY(gb.gb_frame == 0)); } while(HEDLEY_LIKELY(gb.gb_frame == 0));
frames++; frames++;
gb.direct.joypad = 0xFF;
input = getchar_timeout_us(0); input = getchar_timeout_us(0);
if(input == PICO_ERROR_TIMEOUT) if(input == PICO_ERROR_TIMEOUT)
continue; continue;
@@ -368,6 +370,24 @@ int main(void)
break; break;
} }
case '\n':
{
gb.direct.joypad_bits.start = 0;
break;
}
case 'z':
{
gb.direct.joypad_bits.a = 0;
break;
}
case 'x':
{
gb.direct.joypad_bits.b = 0;
break;
}
case 'q': case 'q':
goto out; goto out;
+7 -3
View File
@@ -68,7 +68,7 @@
* decrement (0). * decrement (0).
* W (0xXX1X): ID0: Control vertical address counter increment (1) or * W (0xXX1X): ID0: Control vertical address counter increment (1) or
* decrement (0). * decrement (0).
* W (0xXXX8): AM: GRAM update direction. "0" is horizontal. * W (0xXXX8): AM: GRAM update direction. "1" is horizontal.
*/ */
#define MK_ILI9225_REG_ENTRY_MODE 0x03 #define MK_ILI9225_REG_ENTRY_MODE 0x03
/** /**
@@ -391,8 +391,7 @@ unsigned mk_ili9225_init(void)
* Increment vertical and horizontal address. * Increment vertical and horizontal address.
* Use vertical image. * Use vertical image.
* FIXME: Why is BGR enabled? */ * FIXME: Why is BGR enabled? */
/* TODO: Change to horizontal mode. */ { MK_ILI9225_REG_ENTRY_MODE, 0x0008 },
{ MK_ILI9225_REG_ENTRY_MODE, 0x1000 },
/* Turn off all display outputs. */ /* Turn off all display outputs. */
{ MK_ILI9225_REG_DISPLAY_CTRL, 0x0000 }, { MK_ILI9225_REG_DISPLAY_CTRL, 0x0000 },
/* Set porches to 8 lines. */ /* Set porches to 8 lines. */
@@ -493,6 +492,11 @@ void mk_ili9225_set_window(uint16_t hor_start, uint16_t hor_end,
set_register(MK_ILI9225_REG_VERT_WIN_ADDR2, vert_start); set_register(MK_ILI9225_REG_VERT_WIN_ADDR2, vert_start);
} }
void mk_ili9225_set_x(uint8_t x)
{
set_register(MK_ILI9225_REG_RAM_ADDR_SET1, x);
}
void mk_ili9225_set_address(uint8_t x, uint8_t y) void mk_ili9225_set_address(uint8_t x, uint8_t y)
{ {
set_register(MK_ILI9225_REG_RAM_ADDR_SET1, x); set_register(MK_ILI9225_REG_RAM_ADDR_SET1, x);