kopia lustrzana https://github.com/pimoroni/pimoroni-pico
Porównaj commity
17 Commity
7a01a5a797
...
b9f984d573
Autor | SHA1 | Data |
---|---|---|
Ryan | b9f984d573 | |
Connor Linfoot | 32c10482d9 | |
Philip Howard | 4c44b77193 | |
Phil Howard | 5510c82564 | |
Philip Howard | 3a10b29f54 | |
Phil Howard | 8cf276b992 | |
thirdr | 3aa4f170a8 | |
thirdr | 8bca73df5d | |
thirdr | 06dba8c009 | |
thirdr | 951ee18c42 | |
thirdr | 7cdf939a4c | |
thirdr | 19141cf89a | |
thirdr | bd5624658e | |
thirdr | 03c2a68e3f | |
thirdr | 735cb1a058 | |
thirdr | 3c2d710e2e | |
thirdr | 4a65862858 |
|
@ -47,8 +47,9 @@ namespace pimoroni {
|
|||
return !(sr.read() & 128);
|
||||
}
|
||||
|
||||
void Inky73::busy_wait() {
|
||||
while(is_busy()) {
|
||||
void Inky73::busy_wait(uint timeout_ms) {
|
||||
absolute_time_t timeout = make_timeout_time_ms(timeout_ms);
|
||||
while(is_busy() && !time_reached(timeout)) {
|
||||
tight_loop_contents();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ namespace pimoroni {
|
|||
// Methods
|
||||
//--------------------------------------------------
|
||||
public:
|
||||
void busy_wait();
|
||||
void busy_wait(uint timeout_ms=45000);
|
||||
void reset();
|
||||
void power_off();
|
||||
|
||||
|
|
|
@ -133,8 +133,6 @@ namespace pimoroni {
|
|||
|
||||
void ST7789::configure_display(Rotation rotate) {
|
||||
|
||||
bool rotate180 = rotate == ROTATE_180 || rotate == ROTATE_90;
|
||||
|
||||
if(rotate == ROTATE_90 || rotate == ROTATE_270) {
|
||||
std::swap(width, height);
|
||||
}
|
||||
|
@ -185,20 +183,30 @@ namespace pimoroni {
|
|||
// Pico Display
|
||||
if(width == 240 && height == 135) {
|
||||
caset[0] = 40; // 240 cols
|
||||
caset[1] = 279;
|
||||
raset[0] = 53; // 135 rows
|
||||
raset[1] = 187;
|
||||
madctl = rotate180 ? MADCTL::ROW_ORDER : MADCTL::COL_ORDER;
|
||||
caset[1] = 40 + width - 1;
|
||||
raset[0] = 52; // 135 rows
|
||||
raset[1] = 52 + height - 1;
|
||||
if (rotate == ROTATE_0) {
|
||||
raset[0] += 1;
|
||||
raset[1] += 1;
|
||||
}
|
||||
madctl = rotate == ROTATE_180 ? MADCTL::ROW_ORDER : MADCTL::COL_ORDER;
|
||||
madctl |= MADCTL::SWAP_XY | MADCTL::SCAN_ORDER;
|
||||
}
|
||||
|
||||
// Pico Display at 90 degree rotation
|
||||
if(width == 135 && height == 240) {
|
||||
caset[0] = 52; // 135 cols
|
||||
caset[1] = 186;
|
||||
caset[1] = 52 + width - 1;
|
||||
raset[0] = 40; // 240 rows
|
||||
raset[1] = 279;
|
||||
madctl = rotate180 ? (MADCTL::COL_ORDER | MADCTL::ROW_ORDER) : 0;
|
||||
raset[1] = 40 + height - 1;
|
||||
madctl = 0;
|
||||
if (rotate == ROTATE_90) {
|
||||
caset[0] += 1;
|
||||
caset[1] += 1;
|
||||
madctl = MADCTL::COL_ORDER | MADCTL::ROW_ORDER;
|
||||
}
|
||||
madctl = rotate == ROTATE_90 ? (MADCTL::COL_ORDER | MADCTL::ROW_ORDER) : 0;
|
||||
}
|
||||
|
||||
// Pico Display 2.0
|
||||
|
@ -207,7 +215,7 @@ namespace pimoroni {
|
|||
caset[1] = 319;
|
||||
raset[0] = 0;
|
||||
raset[1] = 239;
|
||||
madctl = rotate180 ? MADCTL::ROW_ORDER : MADCTL::COL_ORDER;
|
||||
madctl = (rotate == ROTATE_180 || rotate == ROTATE_90) ? MADCTL::ROW_ORDER : MADCTL::COL_ORDER;
|
||||
madctl |= MADCTL::SWAP_XY | MADCTL::SCAN_ORDER;
|
||||
}
|
||||
|
||||
|
@ -217,7 +225,7 @@ namespace pimoroni {
|
|||
caset[1] = 239;
|
||||
raset[0] = 0;
|
||||
raset[1] = 319;
|
||||
madctl = rotate180 ? (MADCTL::COL_ORDER | MADCTL::ROW_ORDER) : 0;
|
||||
madctl = (rotate == ROTATE_180 || rotate == ROTATE_90) ? (MADCTL::COL_ORDER | MADCTL::ROW_ORDER) : 0;
|
||||
}
|
||||
|
||||
// Byte swap the 16bit rows/cols values
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
from picographics import PicoGraphics, DISPLAY_INKY_FRAME as DISPLAY # 5.7"
|
||||
# from picographics import PicoGraphics, DISPLAY_INKY_FRAME_4 as DISPLAY # 4.0"
|
||||
# from picographics import PicoGraphics, DISPLAY_INKY_FRAME_7 as DISPLAY # 7.3"
|
||||
import pngdec
|
||||
|
||||
# Create a PicoGraphics instance
|
||||
graphics = PicoGraphics(DISPLAY)
|
||||
WIDTH, HEIGHT = graphics.get_bounds()
|
||||
|
||||
# Set the font
|
||||
graphics.set_font("bitmap8")
|
||||
|
||||
# Create an instance of the PNG Decoder
|
||||
png = pngdec.PNG(graphics)
|
||||
|
||||
# Clear the screen
|
||||
graphics.set_pen(1)
|
||||
graphics.clear()
|
||||
graphics.set_pen(0)
|
||||
|
||||
# Few lines of text.
|
||||
graphics.text("PNG Pencil", 70, 100, WIDTH, 3)
|
||||
|
||||
# Open our PNG File from flash. In this example we're using a cartoon pencil.
|
||||
# You can use Thonny to transfer PNG Images to your Inky Frame.
|
||||
try:
|
||||
png.open_file("pencil_256x256.png")
|
||||
|
||||
# Decode our PNG file and set the X and Y
|
||||
png.decode(200, 100)
|
||||
|
||||
except OSError:
|
||||
graphics.text("Unable to find PNG file! Copy 'pencil_256x256.png' to your Inky Frame using Thonny :)", 10, 70, WIDTH, 3)
|
||||
|
||||
# Start the screen update
|
||||
graphics.update()
|
Plik binarny nie jest wyświetlany.
Po Szerokość: | Wysokość: | Rozmiar: 5.4 KiB |
|
@ -0,0 +1,40 @@
|
|||
from picographics import PicoGraphics, DISPLAY_PICO_DISPLAY, PEN_RGB332
|
||||
import pngdec
|
||||
|
||||
# Create a PicoGraphics instance
|
||||
display = PicoGraphics(display=DISPLAY_PICO_DISPLAY, pen_type=PEN_RGB332)
|
||||
|
||||
# Set the backlight so we can see it!
|
||||
display.set_backlight(1.0)
|
||||
|
||||
# Create an instance of the PNG Decoder
|
||||
png = pngdec.PNG(display)
|
||||
|
||||
# Create some pens for use later.
|
||||
BG = display.create_pen(200, 200, 200)
|
||||
TEXT = display.create_pen(0, 0, 0)
|
||||
|
||||
# Clear the screen
|
||||
display.set_pen(BG)
|
||||
display.clear()
|
||||
|
||||
display.set_pen(TEXT)
|
||||
display.text("PNG Pencil", 15, 80)
|
||||
|
||||
try:
|
||||
# Open our PNG File from flash. In this example we're using an image of a cartoon pencil.
|
||||
# You can use Thonny to transfer PNG Images to your Pico.
|
||||
png.open_file("pencil.png")
|
||||
|
||||
# Decode our PNG file and set the X and Y
|
||||
png.decode(20, 100, scale=3)
|
||||
|
||||
# Handle the error if the image doesn't exist on the flash.
|
||||
except OSError:
|
||||
print("Error: PNG File missing. Copy the PNG file from the example folder to your Pico using Thonny and run the example again.")
|
||||
|
||||
display.update()
|
||||
|
||||
# We're not doing anything else with the display now but we want to keep the program running!
|
||||
while True:
|
||||
pass
|
|
@ -0,0 +1,54 @@
|
|||
from picographics import PicoGraphics, DISPLAY_PICO_DISPLAY, PEN_P8
|
||||
import pngdec
|
||||
|
||||
# Create a PicoGraphics instance
|
||||
display = PicoGraphics(display=DISPLAY_PICO_DISPLAY, pen_type=PEN_P8, rotate=270)
|
||||
|
||||
# Set the backlight so we can see it!
|
||||
display.set_backlight(1.0)
|
||||
|
||||
# Create an instance of the PNG Decoder
|
||||
png = pngdec.PNG(display)
|
||||
|
||||
# Create some pens for use later.
|
||||
BG = display.create_pen(200, 200, 200)
|
||||
|
||||
# 16 Reds
|
||||
for i in range(16):
|
||||
display.create_pen(i * 16, 0, 0)
|
||||
|
||||
# 16 Greens
|
||||
for i in range(16):
|
||||
display.create_pen(0, i * 16, 0)
|
||||
|
||||
# 16 Blues
|
||||
for i in range(16):
|
||||
display.create_pen(0, 0, i * 16)
|
||||
|
||||
# Adding in an white background colour at the beginning of each offset.
|
||||
for i in range(3):
|
||||
display.update_pen(i * 16, 200, 200, 200)
|
||||
|
||||
# Clear the screen
|
||||
display.set_pen(BG)
|
||||
display.clear()
|
||||
|
||||
try:
|
||||
# Open our PNG File from flash. In this example we're using an image of a cartoon pencil.
|
||||
# You can use Thonny to transfer PNG Images to your Pico.
|
||||
png.open_file("pencil_gray.png")
|
||||
|
||||
# Decode our PNG file and set the X and Y
|
||||
png.decode(35, 10, scale=2, mode=pngdec.PNG_COPY, palette_offset=0)
|
||||
png.decode(35, 90, scale=2, mode=pngdec.PNG_COPY, palette_offset=16)
|
||||
png.decode(35, 170, scale=2, mode=pngdec.PNG_COPY, palette_offset=32)
|
||||
|
||||
# Handle the error if the image doesn't exist on the flash.
|
||||
except OSError:
|
||||
print("Error: PNG File missing. Copy the PNG file from the example folder to your Pico using Thonny and run the example again.")
|
||||
|
||||
display.update()
|
||||
|
||||
# We're not doing anything else with the display now but we want to keep the program running!
|
||||
while True:
|
||||
pass
|
Plik binarny nie jest wyświetlany.
Po Szerokość: | Wysokość: | Rozmiar: 1.1 KiB |
Plik binarny nie jest wyświetlany.
Po Szerokość: | Wysokość: | Rozmiar: 497 B |
|
@ -0,0 +1,36 @@
|
|||
from picographics import PicoGraphics, DISPLAY_TUFTY_2040
|
||||
import pngdec
|
||||
|
||||
display = PicoGraphics(display=DISPLAY_TUFTY_2040)
|
||||
|
||||
# Create an instance of the PNG Decoder
|
||||
png = pngdec.PNG(display)
|
||||
|
||||
# Create some pens for use later.
|
||||
BG = display.create_pen(200, 200, 200)
|
||||
TEXT = display.create_pen(0, 0, 0)
|
||||
|
||||
# Clear the screen
|
||||
display.set_pen(BG)
|
||||
display.clear()
|
||||
|
||||
display.set_pen(TEXT)
|
||||
display.text("PNG Pencil", 105, 80)
|
||||
|
||||
try:
|
||||
# Open our PNG File from flash. In this example we're using an image of a cartoon pencil.
|
||||
# You can use Thonny to transfer PNG Images to your Pico.
|
||||
png.open_file("pencil.png")
|
||||
|
||||
# Decode our PNG file and set the X and Y
|
||||
png.decode(140, 100)
|
||||
|
||||
# Handle the error if the image doesn't exist on the flash.
|
||||
except OSError:
|
||||
print("Error: PNG File missing. Copy the PNG file from the example folder to your Pico using Thonny and run the example again.")
|
||||
|
||||
display.update()
|
||||
|
||||
# We're not doing anything else with the display now but we want to keep the program running!
|
||||
while True:
|
||||
pass
|
|
@ -0,0 +1,54 @@
|
|||
from picographics import PicoGraphics, DISPLAY_TUFTY_2040, PEN_P8
|
||||
import pngdec
|
||||
|
||||
display = PicoGraphics(display=DISPLAY_TUFTY_2040, pen_type=PEN_P8)
|
||||
|
||||
# Create an instance of the PNG Decoder
|
||||
png = pngdec.PNG(display)
|
||||
|
||||
# Create some pens for use later.
|
||||
BG = display.create_pen(200, 200, 200)
|
||||
TEXT = display.create_pen(0, 0, 0)
|
||||
|
||||
# 16 Reds
|
||||
for i in range(15):
|
||||
display.create_pen(i * 16, 0, 0)
|
||||
|
||||
# 16 Greens
|
||||
for i in range(16):
|
||||
display.create_pen(0, i * 16, 0)
|
||||
|
||||
# 16 Blues
|
||||
for i in range(15):
|
||||
display.create_pen(0, 0, i * 16)
|
||||
|
||||
# Adding in an white background colour at the beginning of each offset.
|
||||
for i in range(3):
|
||||
display.update_pen(i * 16, 200, 200, 200)
|
||||
|
||||
# Clear the screen
|
||||
display.set_pen(BG)
|
||||
display.clear()
|
||||
|
||||
display.set_pen(TEXT)
|
||||
display.text("PNG Pencil \n& Offset Palette", 125, 115)
|
||||
|
||||
try:
|
||||
# Open our PNG File from flash. In this example we're using an image of a cartoon pencil.
|
||||
# You can use Thonny to transfer PNG Images to your Pico.
|
||||
png.open_file("pencil_gray.png")
|
||||
|
||||
# Decode our PNG file and set the X and Y
|
||||
png.decode(35, 10, scale=2, mode=pngdec.PNG_COPY, palette_offset=0)
|
||||
png.decode(35, 90, scale=2, mode=pngdec.PNG_COPY, palette_offset=16)
|
||||
png.decode(35, 170, scale=2, mode=pngdec.PNG_COPY, palette_offset=32)
|
||||
|
||||
# Handle the error if the image doesn't exist on the flash.
|
||||
except OSError:
|
||||
print("Error: PNG File missing. Copy the PNG file from the example folder to your Pico using Thonny and run the example again.")
|
||||
|
||||
display.update()
|
||||
|
||||
# We're not doing anything else with the display now but we want to keep the program running!
|
||||
while True:
|
||||
pass
|
Plik binarny nie jest wyświetlany.
Po Szerokość: | Wysokość: | Rozmiar: 1.1 KiB |
Plik binarny nie jest wyświetlany.
Po Szerokość: | Wysokość: | Rozmiar: 497 B |
|
@ -84,6 +84,7 @@ The available display settings are listed here:
|
|||
* 32 x 32 Matrix - `DISPLAY_INTERSTATE75_32X32`
|
||||
* 64 x 32 Matrix - `DISPLAY_INTERSTATE75_64X32`
|
||||
* 96 x 32 Matrix - `DISPLAY_INTERSTATE75_96X32`
|
||||
* 96 x 48 Matrix - `DISPLAY_INTERSTATE75_96X48`
|
||||
* 128 x 32 Matrix - `DISPLAY_INTERSTATE75_128X32`
|
||||
* 64 x 64 Matrix - `DISPLAY_INTERSTATE75_64X64`
|
||||
* 128 x 64 Matrix - `DISPLAY_INTERSTATE75_128X64`
|
||||
|
@ -583,3 +584,42 @@ The arguments for `decode` are as follows:
|
|||
2. Decode Y
|
||||
3. Flags - one of `JPEG_SCALE_FULL`, `JPEG_SCALE_HALF`, `JPEG_SCALE_QUARTER` or `JPEG_SCALE_EIGHTH`
|
||||
4. If you want to turn off dither altogether, try `dither=False`. This is useful if you want to [pre-dither your images](https://ditherit.com/) or for artsy posterization effects.
|
||||
|
||||
### PNG Files
|
||||
|
||||
We've included BitBank's PNGDEC - https://github.com/bitbank2/PNGDEC - so you can display PNG files on your LCDs.
|
||||
|
||||
Eg:
|
||||
|
||||
```python
|
||||
import picographics
|
||||
import pngdec
|
||||
|
||||
display = PicoGraphics(display=DISPLAY_PICO_DISPLAY, pen_type=PEN_RGB332)
|
||||
|
||||
# Create a new PNG decoder for our PicoGraphics
|
||||
png = pngdec.PNG(display)
|
||||
|
||||
# Open the PNG file
|
||||
png.open_file("filename.jpeg")
|
||||
|
||||
# Decode the PNG
|
||||
png.decode(0, 0)
|
||||
|
||||
# Display the result
|
||||
display.update()
|
||||
```
|
||||
|
||||
PNG files must be small enough to load into RAM for decoding.
|
||||
|
||||
PNGDEC Supports the following PNG types:
|
||||
|
||||
1. True Colour
|
||||
2. True Colour (with Alpha)
|
||||
3. Indexed
|
||||
4. Grayscale
|
||||
|
||||
The arguments for `decode` are as follows:
|
||||
|
||||
1. Decode X - where to place the decoded JPEG on screen
|
||||
2. Decode Y
|
|
@ -145,6 +145,7 @@ STATIC const mp_map_elem_t picographics_globals_table[] = {
|
|||
{ MP_ROM_QSTR(MP_QSTR_DISPLAY_INTERSTATE75_32X32), MP_ROM_INT(DISPLAY_INTERSTATE75_32X32) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_DISPLAY_INTERSTATE75_64X32), MP_ROM_INT(DISPLAY_INTERSTATE75_64X32) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_DISPLAY_INTERSTATE75_96X32), MP_ROM_INT(DISPLAY_INTERSTATE75_96X32) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_DISPLAY_INTERSTATE75_96X48), MP_ROM_INT(DISPLAY_INTERSTATE75_96X48) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_DISPLAY_INTERSTATE75_128X32), MP_ROM_INT(DISPLAY_INTERSTATE75_128X32) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_DISPLAY_INTERSTATE75_64X64), MP_ROM_INT(DISPLAY_INTERSTATE75_64X64) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_DISPLAY_INTERSTATE75_128X64), MP_ROM_INT(DISPLAY_INTERSTATE75_128X64) },
|
||||
|
|
|
@ -155,6 +155,14 @@ bool get_display_settings(PicoGraphicsDisplay display, int &width, int &height,
|
|||
if(rotate == -1) rotate = (int)Rotation::ROTATE_0;
|
||||
if(pen_type == -1) pen_type = PEN_RGB888;
|
||||
break;
|
||||
case DISPLAY_INTERSTATE75_96X48:
|
||||
width = 96;
|
||||
height = 48;
|
||||
bus_type = BUS_PIO;
|
||||
// Portrait to match labelling
|
||||
if(rotate == -1) rotate = (int)Rotation::ROTATE_0;
|
||||
if(pen_type == -1) pen_type = PEN_RGB888;
|
||||
break;
|
||||
case DISPLAY_INTERSTATE75_128X32:
|
||||
width = 128;
|
||||
height = 32;
|
||||
|
|
|
@ -19,6 +19,7 @@ enum PicoGraphicsDisplay {
|
|||
DISPLAY_INTERSTATE75_32X32,
|
||||
DISPLAY_INTERSTATE75_64X32,
|
||||
DISPLAY_INTERSTATE75_96X32,
|
||||
DISPLAY_INTERSTATE75_96X48,
|
||||
DISPLAY_INTERSTATE75_128X32,
|
||||
DISPLAY_INTERSTATE75_64X64,
|
||||
DISPLAY_INTERSTATE75_128X64,
|
||||
|
|
|
@ -32,6 +32,7 @@ You can choose the HUB75 matrix display size that you wish to use by defining `d
|
|||
DISPLAY_INTERSTATE75_32X32
|
||||
DISPLAY_INTERSTATE75_64X32
|
||||
DISPLAY_INTERSTATE75_96X32
|
||||
DISPLAY_INTERSTATE75_96X48
|
||||
DISPLAY_INTERSTATE75_128X32
|
||||
DISPLAY_INTERSTATE75_64X64
|
||||
DISPLAY_INTERSTATE75_128X64
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from pimoroni import RGBLED, Button
|
||||
from picographics import PicoGraphics, DISPLAY_INTERSTATE75_32X32, DISPLAY_INTERSTATE75_64X32, DISPLAY_INTERSTATE75_96X32, DISPLAY_INTERSTATE75_128X32, DISPLAY_INTERSTATE75_64X64, DISPLAY_INTERSTATE75_128X64, DISPLAY_INTERSTATE75_192X64, DISPLAY_INTERSTATE75_256X64
|
||||
from picographics import PicoGraphics, DISPLAY_INTERSTATE75_32X32, DISPLAY_INTERSTATE75_64X32, DISPLAY_INTERSTATE75_96X32, DISPLAY_INTERSTATE75_96X48, DISPLAY_INTERSTATE75_128X32, DISPLAY_INTERSTATE75_64X64, DISPLAY_INTERSTATE75_128X64, DISPLAY_INTERSTATE75_192X64, DISPLAY_INTERSTATE75_256X64
|
||||
from pimoroni_i2c import PimoroniI2C
|
||||
import hub75
|
||||
import sys
|
||||
|
@ -23,6 +23,7 @@ class Interstate75:
|
|||
DISPLAY_INTERSTATE75_32X32 = DISPLAY_INTERSTATE75_32X32
|
||||
DISPLAY_INTERSTATE75_64X32 = DISPLAY_INTERSTATE75_64X32
|
||||
DISPLAY_INTERSTATE75_96X32 = DISPLAY_INTERSTATE75_96X32
|
||||
DISPLAY_INTERSTATE75_96X48 = DISPLAY_INTERSTATE75_96X48
|
||||
DISPLAY_INTERSTATE75_128X32 = DISPLAY_INTERSTATE75_128X32
|
||||
DISPLAY_INTERSTATE75_64X64 = DISPLAY_INTERSTATE75_64X64
|
||||
DISPLAY_INTERSTATE75_128X64 = DISPLAY_INTERSTATE75_128X64
|
||||
|
|
Ładowanie…
Reference in New Issue