-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is what the rotation/8bit changes were for
- Loading branch information
1 parent
4b4b9d4
commit 8221dc2
Showing
3 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
set(BLIT_BOARD_NAME "Tufty 2040") | ||
|
||
set(BLIT_BOARD_DEFINITIONS | ||
PICO_FLASH_SIZE_BYTES=8388608 | ||
) | ||
|
||
blit_driver(display st7789) | ||
blit_driver(input tufty) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#pragma once | ||
|
||
#define DISPLAY_WIDTH 320 | ||
|
||
|
||
|
||
#define ST7789_8BIT | ||
#define ST7789_ROTATE_180 | ||
#define LCD_CS_PIN 10 | ||
#define LCD_DC_PIN 11 | ||
#define LCD_SCK_PIN 12 // WR | ||
#define LCD_RD_PIN 13 | ||
#define LCD_MOSI_PIN 14 // DB0 | ||
#define LCD_BACKLIGHT_PIN 2 | ||
// #define LCD_VSYNC_PIN 11 // shared | ||
|
||
// there is a white LED |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#include "input.hpp" | ||
|
||
#include "hardware/gpio.h" | ||
|
||
#include "pico/binary_info.h" | ||
|
||
#include "engine/api_private.hpp" | ||
#include "engine/input.hpp" | ||
|
||
enum class ButtonIO { | ||
UP = 22, | ||
DOWN = 6, | ||
|
||
A = 7, | ||
B = 8, | ||
C = 9, | ||
USER = 23, // USER_SW | ||
}; | ||
|
||
static void init_button(ButtonIO b) { | ||
int gpio = static_cast<int>(b); | ||
gpio_set_function(gpio, GPIO_FUNC_SIO); | ||
gpio_set_dir(gpio, GPIO_IN); | ||
gpio_pull_down(gpio); | ||
} | ||
|
||
inline bool get_button(ButtonIO b) { | ||
auto gpio = static_cast<int>(b); | ||
|
||
if(b == ButtonIO::USER) // USER_SW goes the other way | ||
return !gpio_get(gpio); | ||
|
||
return gpio_get(gpio); | ||
} | ||
|
||
void init_input() { | ||
init_button(ButtonIO::UP); | ||
init_button(ButtonIO::DOWN); | ||
init_button(ButtonIO::A); | ||
init_button(ButtonIO::B); | ||
init_button(ButtonIO::C); | ||
init_button(ButtonIO::USER); | ||
|
||
#define BUTTON_DECL(btn) bi_decl(bi_1pin_with_name(static_cast<int>(ButtonIO::btn), #btn" Button")); | ||
BUTTON_DECL(UP) | ||
BUTTON_DECL(DOWN) | ||
BUTTON_DECL(A) | ||
BUTTON_DECL(B) | ||
BUTTON_DECL(C) | ||
BUTTON_DECL(USER) | ||
#undef BUTTON_DECL | ||
} | ||
|
||
void update_input() { | ||
using namespace blit; | ||
|
||
api.buttons = (get_button(ButtonIO::UP) ? uint32_t(Button::DPAD_UP) : 0) | ||
| (get_button(ButtonIO::DOWN) ? uint32_t(Button::DPAD_DOWN) : 0) | ||
| (get_button(ButtonIO::A) ? uint32_t(Button::A) : 0) | ||
| (get_button(ButtonIO::B) ? uint32_t(Button::B) : 0) | ||
| (get_button(ButtonIO::C) ? uint32_t(Button::X) : 0) | ||
| (get_button(ButtonIO::USER) ? uint32_t(Button::Y) : 0); | ||
} |