Skip to content

Commit

Permalink
Fix the ili9341 RGB mode
Browse files Browse the repository at this point in the history
Also fix some comments
  • Loading branch information
alloncm committed Sep 23, 2024
1 parent 2611e80 commit 401bb3b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions core/src/ppu/gfx_device.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use super::gb_ppu::{SCREEN_HEIGHT, SCREEN_WIDTH};

/// Pixel is in the format of RGB555 as in the gbdev docs which is low bits (Red) -> high bits (Blue)
pub type Pixel = u16;

pub trait GfxDevice{
Expand Down
4 changes: 2 additions & 2 deletions rpi/src/drivers/ili9341_gfx_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ impl Ili9341Contoller{
controller.spi.write(Ili9341Command::VcomControl2 as u8, &[0x86]);

// Configuring the screen
controller.spi.write(Ili9341Command::MemoryAccessControl as u8, &[0x28]); // This command tlit the screen 90 degree and set pixel to BGR order
controller.spi.write(Ili9341Command::PixelFormatSet as u8, &[0x55]); // set pixel format to 16 bit per pixel;
controller.spi.write(Ili9341Command::MemoryAccessControl as u8, &[0x20]); // This command tlit the screen 90 degree and set pixel to RGB order (low bits (Red) -> High bits (Blue))
controller.spi.write(Ili9341Command::PixelFormatSet as u8, &[0x55]); // set pixel format to 16 bit per pixel;
controller.spi.write(Ili9341Command::FrameRateControl as u8, &[0x0, 0x10 /*According to the docs this is 119 hrz, setting this option in order to avoid screen tearing on rpi zero2 */]);
controller.spi.write(Ili9341Command::DisplayFunctionControl as u8, &[0x8, 0x82, 0x27]);

Expand Down
2 changes: 1 addition & 1 deletion sdl/src/sdl_gfx_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use sdl2::sys::*;
use magenboy_core::{ppu::gb_ppu::{SCREEN_HEIGHT, SCREEN_WIDTH}, utils::vec2::Vec2, GfxDevice, Pixel};
use super::utils::get_sdl_error_message;

// The bit order is high -> low bit as opposed to RGB555 in the gbdev docs which is low -> high bit
// The bit order is high bits -> low bits as opposed to RGB555 in the gbdev docs which is low -> high
const SDL_PIXEL_FORMAT:u32 = SDL_PixelFormatEnum::SDL_PIXELFORMAT_BGR555 as u32;

struct SdlWindow{
Expand Down

0 comments on commit 401bb3b

Please sign in to comment.