Update Arduboy, Arduboy2 libraries

Remapped ABXY buttons for 8BitCADE XL Level UP
This commit is contained in:
Mr.Blinky 2022-03-14 21:24:51 +01:00
parent d168f3e8a4
commit dbe2df81da
3 changed files with 68 additions and 41 deletions

View File

@ -91,8 +91,13 @@
#define PIN_RIGHT_BUTTON A1 #define PIN_RIGHT_BUTTON A1
#define PIN_UP_BUTTON A0 #define PIN_UP_BUTTON A0
#define PIN_DOWN_BUTTON A3 #define PIN_DOWN_BUTTON A3
#ifndef SUPPORT_XY_BUTTONS
#define PIN_A_BUTTON 7 #define PIN_A_BUTTON 7
#define PIN_B_BUTTON 8 #define PIN_B_BUTTON 8
#else
#define PIN_A_BUTTON 8
#define PIN_B_BUTTON 7
#endif
// bit values for button states // bit values for button states
#define LEFT_BUTTON _BV(5) #define LEFT_BUTTON _BV(5)

View File

@ -194,30 +194,36 @@ void Arduboy2Core::bootPins()
#ifdef ARDUBOY_10 #ifdef ARDUBOY_10
// Port B INPUT_PULLUP or HIGH // Port B INPUT_PULLUP or HIGH
PORTB = (_BV(RED_LED_BIT) | _BV(BLUE_LED_BIT) | //RGB LED off PORTB = (_BV(RED_LED_BIT) | _BV(BLUE_LED_BIT) //RGB LED off
#ifndef AB_ALTERNATE_WIRING #ifndef AB_ALTERNATE_WIRING
_BV(GREEN_LED_BIT) | | _BV(GREEN_LED_BIT)
#endif #endif
#ifdef SUPPORT_XY_BUTTONS #ifdef SUPPORT_XY_BUTTONS
_BV(Y_BUTTON_BIT) | | _BV(X_BUTTON_BIT) | _BV(A_BUTTON_BIT)
#else
| _BV(B_BUTTON_BIT)
#endif #endif
#ifndef ARDUINO_AVR_MICRO #ifndef ARDUINO_AVR_MICRO
_BV(RX_LED_BIT) | //RX LED off for Arduboy and non Micro based Arduino | _BV(RX_LED_BIT) //RX LED off for Arduboy and non Micro based Arduino
#endif #endif
_BV(B_BUTTON_BIT)) &
// Port B INPUT or LOW // Port B INPUT or LOW
~(_BV(SPI_MISO_BIT) | _BV(SPI_MOSI_BIT) | _BV(SPI_SCK_BIT)); ) & ~(_BV(SPI_MISO_BIT) | _BV(SPI_MOSI_BIT) | _BV(SPI_SCK_BIT));
// Port B outputs // Port B outputs
DDRB = (_BV(RED_LED_BIT) | _BV(BLUE_LED_BIT) | DDRB = (_BV(RED_LED_BIT) | _BV(BLUE_LED_BIT)
#ifndef AB_ALTERNATE_WIRING #ifndef AB_ALTERNATE_WIRING
_BV(GREEN_LED_BIT) | | _BV(GREEN_LED_BIT)
#endif #endif
_BV(SPI_MOSI_BIT) | _BV(SPI_SCK_BIT) | _BV(RX_LED_BIT)) & | _BV(SPI_MOSI_BIT) | _BV(SPI_SCK_BIT) | _BV(RX_LED_BIT)) & ~(
// Port B inputs // Port B inputs
~(_BV(B_BUTTON_BIT) | _BV(SPI_MISO_BIT) #ifdef SUPPORT_XY_BUTTONS
_BV(A_BUTTON_BIT)
#else
_BV(B_BUTTON_BIT)
#endif
| _BV(SPI_MISO_BIT)
#ifdef SUPPORT_XY_BUTTONS #ifdef SUPPORT_XY_BUTTONS
| _BV(Y_BUTTON_BIT) | _BV(X_BUTTON_BIT)
#endif #endif
); );
@ -277,17 +283,22 @@ void Arduboy2Core::bootPins()
0); 0);
// Port E INPUT_PULLUP or HIGH // Port E INPUT_PULLUP or HIGH
#ifndef SUPPORT_XY_BUTTONS
PORTE |= _BV(A_BUTTON_BIT); PORTE |= _BV(A_BUTTON_BIT);
// Port E INPUT or LOW (none) // Port E INPUT or LOW (none)
// Port E inputs // Port E inputs
DDRE &= ~(_BV(A_BUTTON_BIT)); DDRE &= ~(_BV(A_BUTTON_BIT));
// Port E outputs (none) // Port E outputs (none)
#else
PORTE |= _BV(B_BUTTON_BIT);
DDRE &= ~(_BV(B_BUTTON_BIT));
#endif
// Port F INPUT_PULLUP or HIGH // Port F INPUT_PULLUP or HIGH
PORTF = (_BV(LEFT_BUTTON_BIT) | _BV(RIGHT_BUTTON_BIT) | PORTF = (_BV(LEFT_BUTTON_BIT) | _BV(RIGHT_BUTTON_BIT) |
_BV(UP_BUTTON_BIT) | _BV(DOWN_BUTTON_BIT) _BV(UP_BUTTON_BIT) | _BV(DOWN_BUTTON_BIT)
#ifdef SUPPORT_XY_BUTTONS #ifdef SUPPORT_XY_BUTTONS
| _BV(X_BUTTON_BIT) | _BV(Y_BUTTON_BIT)
#endif #endif
) & ) &
// Port F INPUT or LOW // Port F INPUT or LOW
@ -299,7 +310,7 @@ void Arduboy2Core::bootPins()
~(_BV(LEFT_BUTTON_BIT) | _BV(RIGHT_BUTTON_BIT) | ~(_BV(LEFT_BUTTON_BIT) | _BV(RIGHT_BUTTON_BIT) |
_BV(UP_BUTTON_BIT) | _BV(DOWN_BUTTON_BIT) | _BV(UP_BUTTON_BIT) | _BV(DOWN_BUTTON_BIT) |
#ifdef SUPPORT_XY_BUTTONS #ifdef SUPPORT_XY_BUTTONS
_BV(X_BUTTON_BIT) | _BV(Y_BUTTON_BIT) |
#endif #endif
_BV(RAND_SEED_IN_BIT)); _BV(RAND_SEED_IN_BIT));
@ -1383,7 +1394,7 @@ uint8_t Arduboy2Core::buttonsState()
(_BV(UP_BUTTON_BIT) | _BV(RIGHT_BUTTON_BIT) | (_BV(UP_BUTTON_BIT) | _BV(RIGHT_BUTTON_BIT) |
_BV(LEFT_BUTTON_BIT) | _BV(DOWN_BUTTON_BIT) | _BV(LEFT_BUTTON_BIT) | _BV(DOWN_BUTTON_BIT) |
#ifdef SUPPORT_XY_BUTTONS #ifdef SUPPORT_XY_BUTTONS
_BV(X_BUTTON_BIT) | _BV(Y_BUTTON_BIT) |
#endif #endif
0)); 0));
// A // A
@ -1392,7 +1403,7 @@ uint8_t Arduboy2Core::buttonsState()
if (bitRead(B_BUTTON_PORTIN, B_BUTTON_BIT) == 0) { buttons |= B_BUTTON; } if (bitRead(B_BUTTON_PORTIN, B_BUTTON_BIT) == 0) { buttons |= B_BUTTON; }
#ifdef SUPPORT_XY_BUTTONS #ifdef SUPPORT_XY_BUTTONS
// Y // Y
if (bitRead(Y_BUTTON_PORTIN, Y_BUTTON_BIT) == 0) { buttons |= Y_BUTTON; } if (bitRead(X_BUTTON_PORTIN, X_BUTTON_BIT) == 0) { buttons |= X_BUTTON; }
#endif #endif
#elif defined(AB_DEVKIT) #elif defined(AB_DEVKIT)
// down, left, up // down, left, up

View File

@ -147,8 +147,8 @@
#define A_BUTTON _BV(3) /**< The A button value for functions requiring a bitmask */ #define A_BUTTON _BV(3) /**< The A button value for functions requiring a bitmask */
#define B_BUTTON _BV(2) /**< The B button value for functions requiring a bitmask */ #define B_BUTTON _BV(2) /**< The B button value for functions requiring a bitmask */
#ifdef SUPPORT_XY_BUTTONS #ifdef SUPPORT_XY_BUTTONS
#define X_BUTTON _BV(1) #define X_BUTTON _BV(0)
#define Y_BUTTON _BV(0) #define Y_BUTTON _BV(1)
#endif #endif
#define PIN_LEFT_BUTTON A2 #define PIN_LEFT_BUTTON A2
@ -175,30 +175,41 @@
#define DOWN_BUTTON_DDR DDRF #define DOWN_BUTTON_DDR DDRF
#define DOWN_BUTTON_BIT PORTF4 #define DOWN_BUTTON_BIT PORTF4
#define PIN_A_BUTTON 7 #ifndef SUPPORT_XY_BUTTONS
#define A_BUTTON_PORT PORTE #define PIN_A_BUTTON 7
#define A_BUTTON_PORTIN PINE #define A_BUTTON_PORT PORTE
#define A_BUTTON_DDR DDRE #define A_BUTTON_PORTIN PINE
#define A_BUTTON_BIT PORTE6 #define A_BUTTON_DDR DDRE
#define A_BUTTON_BIT PORTE6
#define PIN_B_BUTTON 8 #else
#define B_BUTTON_PORT PORTB #define PIN_A_BUTTON 8
#define B_BUTTON_PORTIN PINB #define A_BUTTON_PORT PORTB
#define B_BUTTON_DDR DDRB #define A_BUTTON_PORTIN PINB
#define B_BUTTON_BIT PORTB4 #define A_BUTTON_DDR DDRB
#define A_BUTTON_BIT PORTB4
#ifdef SUPPORT_XY_BUTTONS #endif
#define PIN_X_BUTTON A4 #ifndef SUPPORT_XY_BUTTONS
#define X_BUTTON_PORT PORTF #define PIN_B_BUTTON 8
#define X_BUTTON_PORTIN PINF #define B_BUTTON_PORT PORTB
#define X_BUTTON_DDR DDRF #define B_BUTTON_PORTIN PINB
#define X_BUTTON_BIT PORTF1 #define B_BUTTON_DDR DDRB
#define B_BUTTON_BIT PORTB4
#define PIN_Y_BUTTON 11 #else
#define Y_BUTTON_PORT PORTB #define PIN_B_BUTTON 7
#define Y_BUTTON_PORTIN PINB #define B_BUTTON_PORT PORTE
#define Y_BUTTON_DDR DDRB #define B_BUTTON_PORTIN PINE
#define Y_BUTTON_BIT PORTB7 #define B_BUTTON_DDR DDRE
#define B_BUTTON_BIT PORTE6
#define PIN_X_BUTTON 11
#define X_BUTTON_PORT PORTB
#define X_BUTTON_PORTIN PINB
#define X_BUTTON_DDR DDRB
#define X_BUTTON_BIT PORTB7
#define PIN_Y_BUTTON A4
#define Y_BUTTON_PORT PORTF
#define Y_BUTTON_PORTIN PINF
#define Y_BUTTON_DDR DDRF
#define Y_BUTTON_BIT PORTF1
#endif #endif
#define PIN_SPEAKER_1 5 /**< The pin number of the first lead of the speaker */ #define PIN_SPEAKER_1 5 /**< The pin number of the first lead of the speaker */