Commit 4c26a381 authored by russhughes's avatar russhughes

fix for #57

parent eaee507b
......@@ -66,17 +66,19 @@ The firmware directory contains pre-compiled firmware for various devices with
the st7789 C driver and frozen python font files. See the README.md file in the
fonts folder for more information on the font files.
MicroPython MicroPython v1.18-5-g037b2c72a compiled with ESP IDF v4.2 using CMake
MicroPython MicroPython v1.18-56-g517e82eb6 compiled with ESP IDF v4.2 using CMake
Directory | File | Device
--------------------- | ------------ | ----------------------------------
GENERIC-7789 | firmware.bin | Generic ESP32 devices
GENERIC_SPIRAM-7789 | firmware.bin | Generic ESP32 devices with SPI Ram
GENERIC_C3 | firmware.bin | Generic ESP32-C3 devices (JPG support not working)
PYBV11 | firmware.dfu | Pyboard v1.1
RP2 | firmware.uf2 | Raspberry Pi Pico RP2040
T-DISPLAY | firmware.bin | LILYGO® TTGO T-Display
T-Watch-2020 | firmware.bin | LILYGO® T-Watch 2020
## Additional Modules
Module | Source
......@@ -286,18 +288,23 @@ I was not able to run the display with a baud rate over 40MHZ.
- `backlight` sets the pin connected to the displays backlight enable input. The displays backlight input can often be left floating or disconnected as the backlight on some displays are always powered on and cannot be turned off.
- `rotations` sets the orientation table for each of the rotations. The orientation table is a list of tuples for each rotation that define the MADCTL register, width, height, start_x, and start_y values.
- `rotations` sets the orientation table. The orientation table is a list of tuples for each `rotation` that defines the MADCTL register, width, height, start_x, and start_y values.
Default `rotations` are included for the following st7789 and st7735 display sizes:
Display | Default Orientation Tables
------- | --------------------------
240x320 | [(0x00, 240, 320, 0, 0), (0x60, 320, 240, 0, 0), (0xc0, 240, 320, 0, 0), (0xa0, 320, 240, 0, 0)]
240x240 | [(0x00, 240, 240, 0, 0), (0x60, 240, 240, 0, 0), (0xc0, 240, 240, 0, 80), (0xa0, 240, 240, 80, 0)]
135x240 | [(0x00, 135, 240, 52, 40), (0x60, 240, 135, 40, 53), (0xc0, 135, 240, 53, 40), (0xa0, 240, 135, 40, 52)]
128x160 | [(0x00, 128, 160, 0, 0), (0x60, 160, 128, 0, 0), (0xc0, 128, 160, 0, 0), (0xa0, 160, 128, 0, 0)]
128x128 | [(0x00, 128, 128, 2, 1), (0x60, 128, 128, 1, 2), (0xc0, 128, 128, 2, 3), (0xa0, 128, 128, 3, 2)]
other | [(0x00, width, height, 0, 0)]
You may define as many rotations in the list as you wish.
- `rotation` sets the display rotation according to the orientation table. The default orientation table defines four counter-clockwise rotations as 0-Portrait (0 degrees), 1- Landscape (90 degrees), 2- Reverse Portrait (180 degrees), and 3- Reverse Landscape (270 degrees) for 240x320, 240x240 and 123x240 displays with the LCD's ribbon cable at the bottom of the display. The default rotation being Portrait (0 degrees).
- `rotation` sets the display rotation according to the orientation table. The default orientation table defines four counter-clockwise rotations as 0-Portrait (0 degrees), 1- Landscape (90 degrees), 2- Reverse Portrait (180 degrees), and 3- Reverse Landscape (270 degrees) for 240x320, 240x240, 134x240, 128x160 and 128x128 displays with the LCD's ribbon cable at
the bottom of the display. The default rotation being Portrait (0 degrees).
- `color_order` set the color order used by the driver st7789.RGB and st7789.BGR are supported.
......@@ -328,6 +335,10 @@ I was not able to run the display with a baud rate over 40MHZ.
st7789_RGB | 0x00 | RGB color order
st7789_BGR | 0x08 | BGR color order
- `init()`
Must be called to initalize the display.
- `on()`
Turn on the backlight pin if one was defined during init.
......@@ -336,6 +347,10 @@ I was not able to run the display with a baud rate over 40MHZ.
Turn off the backlight pin if one was defined during init.
- `fill(color)`
Fill the display with the specified color.
- `pixel(x, y, color)`
Set the specified pixel to the given `color`.
......
......@@ -3,18 +3,6 @@
from machine import Pin, SPI
import st7789
# Orientation Overrides for each rotation of the display counter-clockwise, with the ribbon cable at
# the top of the display. 0-Portrait (0 degrees), 1-Landscape (90 degrees), 2-Inverse Portrait
# (180 degrees), 3-Inverse Landscape (270 degrees)Portrait.
# (MADCTL Register Value, width, height, start_x, start_y)x
ORIENTATIONS = [
(0, 128, 128, 2, 1),
(st7789.MADCTL_MX | st7789.MADCTL_MV, 128, 128, 1, 2),
(st7789.MADCTL_MY | st7789.MADCTL_MX, 128, 128, 2, 3),
(st7789.MADCTL_MY | st7789.MADCTL_MV, 128, 128, 3, 2),
]
TFA = 1
BFA = 3
......@@ -29,7 +17,6 @@ def config(rotation=0, buffer_size=0, options=0):
backlight=Pin(15, Pin.OUT),
color_order=st7789.BGR,
inversion=False,
rotations=ORIENTATIONS,
rotation=rotation,
options=options,
buffer_size=buffer_size)
......@@ -3,18 +3,6 @@
from machine import Pin, SPI
import st7789
# Orientation Overrides for each rotation of the display counter-clockwise, with the ribbon
# cable at the top of the display. 0-Portrait (0 degrees), 1-Landscape (90 degrees), 2-Inverse
# Portrait (180 degrees), 3-Inverse Landscape (270 degrees)Portrait.
# (MADCTL Register Value, width, height, start_x, start_y)x
ORIENTATIONS = [
(st7789.RGB, 128, 160, 0, 0),
(st7789.MADCTL_MX | st7789.MADCTL_MV, 160, 128, 0, 0),
(st7789.MADCTL_MY | st7789.MADCTL_MX, 128, 160, 0, 0),
(st7789.MADCTL_MY | st7789.MADCTL_MV, 160, 128, 0, 0),
]
TFA = 0
BFA = 0
......@@ -29,7 +17,6 @@ def config(rotation=0, buffer_size=0, options=0):
backlight=Pin(15, Pin.OUT),
color_order=st7789.RGB,
inversion=False,
rotations=ORIENTATIONS,
rotation=rotation,
options=options,
buffer_size=buffer_size)
......@@ -75,7 +75,8 @@
mp_hal_pin_write(self->reset, 1); \
}
// Default st7789 display orientation tables
//
// Default st7789 and st7735 display orientation tables
// can be overridden during init(), madctl values
// will be combined with color_mode
//
......@@ -103,6 +104,21 @@ st7789_rotation_t ORIENTATIONS_135x240[4] = {
{0xa0, 240, 135, 40, 52}
};
st7789_rotation_t ORIENTATIONS_128x160[4] = {
{0x00, 128, 160, 0, 0},
{0x60, 160, 128, 0, 0},
{0xc0, 128, 160, 0, 0},
{0xa0, 160, 128, 0, 0}
};
st7789_rotation_t ORIENTATIONS_128x128[4] = {
{0x00, 128, 128, 2, 1},
{0x60, 128, 128, 1, 2},
{0xc0, 128, 128, 2, 3},
{0xa0, 128, 128, 3, 2}
};
STATIC void write_spi(mp_obj_base_t *spi_obj, const uint8_t *buf, int len)
{
mp_machine_spi_p_t *spi_p = (mp_machine_spi_p_t *) spi_obj->type->protocol;
......@@ -1036,12 +1052,16 @@ STATIC void set_rotation(st7789_ST7789_obj_t *self)
st7789_rotation_t *rotations = self->rotations;
if (rotations == NULL) {
if (self->display_width == 135 && self->display_height == 240) {
rotations = ORIENTATIONS_135x240;
if (self->display_width == 240 && self->display_height == 320) {
rotations = ORIENTATIONS_240x320;
} else if (self->display_width == 240 && self->display_height == 240) {
rotations = ORIENTATIONS_240x240;
} else if (self->display_width == 240 && self->display_height == 320) {
rotations = ORIENTATIONS_240x320;
} else if (self->display_width == 135 && self->display_height == 240) {
rotations = ORIENTATIONS_135x240;
} else if (self->display_width == 128 && self->display_height == 160) {
rotations = ORIENTATIONS_128x160;
} else if (self->display_width == 128 && self->display_height == 128) {
rotations = ORIENTATIONS_128x128;
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment