-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #821 from Daft-Freak/pico-st7789-config-parallel
st7789 config and parallel support
- Loading branch information
Showing
8 changed files
with
191 additions
and
5 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
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 |
---|---|---|
@@ -1,6 +1,8 @@ | ||
#pragma once | ||
|
||
#ifdef BLIT_BOARD_CONFIG | ||
#include BLIT_BOARD_CONFIG | ||
#endif | ||
|
||
// these are the defaults | ||
|
||
|
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); | ||
} |
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,52 @@ | ||
.program st7789_raw | ||
.side_set 1 opt | ||
|
||
; raw serial, nothing special | ||
.wrap_target | ||
out x, 8 side 1 | ||
mov pins, x side 0 | ||
.wrap | ||
|
||
; pixel doubling, "borrowed" from PicoSystem | ||
.program st7789_pixel_double | ||
.side_set 1 opt | ||
|
||
.wrap_target | ||
|
||
pull side 1 ; fetch two pixels | ||
mov x, osr ; both pixels in x register | ||
out y, 16 ; second pixel in y register | ||
|
||
; write first pixel (still in osr) | ||
out pins, 8 side 0 | ||
nop side 1 | ||
out pins, 8 side 0 | ||
|
||
; duplicate first pixel | ||
|
||
mov osr, x side 1 ; move pixel data back into osr from register x | ||
out null, 16 ; discard second pixel | ||
|
||
out pins, 8 side 0 | ||
nop side 1 | ||
out pins, 8 side 0 | ||
|
||
; write second pixel | ||
|
||
mov osr, y side 1 ; move pixel data back into osr from register y | ||
out null, 16 ; discard the 16-bits of dummy data from the mov | ||
|
||
out pins, 8 side 0 | ||
nop side 1 | ||
out pins, 8 side 0 | ||
|
||
; duplicate second pixel | ||
|
||
mov osr, y side 1 ; move pixel data back into osr from register y | ||
out null, 16 ; discard as above.. | ||
|
||
out pins, 8 side 0 | ||
nop side 1 | ||
out pins, 8 side 0 | ||
|
||
.wrap |
File renamed without changes.
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