Skip to content

Commit

Permalink
Move the rpi config one section
Browse files Browse the repository at this point in the history
  • Loading branch information
alloncm committed Sep 26, 2022
1 parent 5656676 commit 6ddbbcd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions gb/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,15 @@ cfg_if::cfg_if! {if #[cfg(feature = "apu")]{
#[cfg(feature = "sdl")]
use sdl2::sys::*;

const SCREEN_SCALE:usize = 4;
const TURBO_MUL:u8 = 1;

cfg_if::cfg_if!{
if #[cfg(feature = "rpi")]{
const RESET_PIN_BCM:u8 = 14;
const DC_PIN_BCM:u8 = 15;
const LED_PIN_BCM:u8 = 25;
use crate::rpi_gpio::gpio_joypad_provider::*;
fn buttons_mapper(button:&Button)->GpioPin{
fn buttons_mapper(button:&Button)->GpioBcmPin{
match button{
Button::A => 18,
Button::B => 17,
Expand All @@ -75,6 +77,7 @@ cfg_if::cfg_if!{
}
}
else{
const SCREEN_SCALE:usize = 4;
use sdl2::sys::SDL_Scancode;
fn buttons_mapper(button:Button)->SDL_Scancode{
match button{
Expand Down Expand Up @@ -179,10 +182,7 @@ fn main() {
}

cfg_if::cfg_if!{ if #[cfg(feature = "rpi")]{
let reset_pin = 14;
let dc_pin = 15;
let led_pin = 25;
let mut gfx_device:rpi_gpio::ili9341_controller::Ili9341GfxDevice<rpi_gpio::SpiType> = rpi_gpio::ili9341_controller::Ili9341GfxDevice::new(reset_pin, dc_pin, led_pin, TURBO_MUL, 0);
let mut gfx_device:rpi_gpio::ili9341_controller::Ili9341GfxDevice<rpi_gpio::SpiType> = rpi_gpio::ili9341_controller::Ili9341GfxDevice::new(RESET_PIN_BCM, DC_PIN_BCM, LED_PIN_BCM, TURBO_MUL, 0);
}else{
let mut gfx_device = sdl::sdl_gfx_device::SdlGfxDevice::new("MagenBoy", SCREEN_SCALE, TURBO_MUL,
check_for_terminal_feature_flag(&args, "--no-vsync"), check_for_terminal_feature_flag(&args, "--full-screen"));
Expand Down
4 changes: 2 additions & 2 deletions gb/src/rpi_gpio/gpio_joypad_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ use lib_gb::keypad::{joypad::{Joypad, NUM_OF_KEYS},joypad_provider::JoypadProvid
use lib_gb::utils::create_array;
use rppal::gpio::{Gpio, InputPin};

pub type GpioPin = u8;
pub type GpioBcmPin = u8;

pub struct GpioJoypadProvider{
input_pins:[InputPin;NUM_OF_KEYS]
}

impl GpioJoypadProvider{
pub fn new<F:Fn(&Button)->GpioPin>(mapper:F)->Self{
pub fn new<F:Fn(&Button)->GpioBcmPin>(mapper:F)->Self{
let gpio = Gpio::new().unwrap();
let buttons = [Button::A,Button::B,Button::Start,Button::Select,Button::Up,Button::Down,Button::Right,Button::Left];
let mut counter = 0;
Expand Down

0 comments on commit 6ddbbcd

Please sign in to comment.