Due to high demand expect some shipping delays at this time, orders may not ship for 1-2 business days.
0

displayio documentation and examples
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

displayio documentation and examples

by Kangus on Sun Mar 28, 2021 3:39 pm

I've been trying to get a simple loop to work using displayio documentation and examples but I seem to be missing something.

The documentation on Group https://adafru.it/EFx and the CircuitPython Display Support Using displayio http://bitly.ws/cogE do not show any examples of finding indexes, remove(), pop(), __getitem__(), __len__(), __setitem__(), __delitem__(), sort() do not have any examples, that I can find.

I found MagTag that uses the same display I'm working with, 296X128 Grayscale ePaper but it does not use displayio, MagTag uses an ESP32 for code and there are no 'Group' anywhere.

https://www.adafruit.com/product/4777 where are some examples of working with Group objects?

Kangus
 
Posts: 38
Joined: Sat May 19, 2018 10:01 pm

Re: displayio documentation and examples

by tannewt on Mon Mar 29, 2021 4:29 pm

All of those examples are pretty standard python functions on sequences. The `__` functions translate into different syntax though. Perhaps this would help: https://docs.python.org/3/library/stdty ... uple-range

tannewt
 
Posts: 2393
Joined: Thu Oct 06, 2016 8:48 pm

Re: displayio documentation and examples

by Kangus on Mon Mar 29, 2021 6:35 pm

So in:
t = displayio.TileGrid(pic, pixel_shader=displayio.ColorConverter())
g.append(t)
display.show(g)
display.refresh()
g = ""

Instead of g = ""
I use can use
g.clear()
to clear out the first bitmap image?

Thanks for the python link, combined with https://www.askpython.com/python/exampl ... -in-python this I have a better understanding since PLSQL, PHP, C, well about every language I've used use some sort of bracket/brace. (Forgot VB, Pascal, Lua)

Kangus
 
Posts: 38
Joined: Sat May 19, 2018 10:01 pm

Re: displayio documentation and examples

by tannewt on Mon Mar 29, 2021 8:05 pm

I'm not sure what you mean by clear. To remove the last element you appended to a sequence, you can either `g.pop()` (which returns the value) or `del g[-1]` which will delete the -1 entry. Negative indices are from the end of the sequence rather than the start.

tannewt
 
Posts: 2393
Joined: Thu Oct 06, 2016 8:48 pm

Re: displayio documentation and examples

by Kangus on Mon Mar 29, 2021 11:40 pm

From Python:
s.append(x)
appends x to the end of the sequence (same as s[len(s):len(s)] = [x])

s.clear()
removes all items from s (same as del s[:])

(Your POP)
s.pop([i])
retrieves the item at i and also removes it from s

s.remove(x)
remove the first item from s where s[i] is equal to x

At any rate my slide show loop will not work with your il0373.py driver since the driver does not pass the busy pin to EPaperDisplay and there isn't logic to wait busy. I checked the busy issue, the busy pin on the display was not hooked to any feather pin, I wired it to D4, the 180 second was to prevent 3 color displays from turning into junk but if I pass the grayscale flag I should by-pass that 3 minute wait.. nope. And last but not at all least, partial update, no support in displayio at all. But when I tried to add busy_pin I discovered that "Board specific pin names" yet there is noting in the board documentation about gpio handling just I2C, SPI and UART, how do you set direction and pull-ups? I know how that works with digitalio.

I have ePaper displays as clocks showing second updates, a partial refresh takes 0.3 seconds but I can't find any partial LUT defined.

Kangus
 
Posts: 38
Joined: Sat May 19, 2018 10:01 pm

Re: displayio documentation and examples

by tannewt on Tue Mar 30, 2021 1:10 pm

Kangus wrote:At any rate my slide show loop will not work with your il0373.py driver since the driver does not pass the busy pin to EPaperDisplay and there isn't logic to wait busy. I checked the busy issue, the busy pin on the display was not hooked to any feather pin, I wired it to D4, the 180 second was to prevent 3 color displays from turning into junk but if I pass the grayscale flag I should by-pass that 3 minute wait.. nope.


You change the 3 minute wait with the `seconds_per_frame` keyword arg. All keyword args are passed through to EPaperDisplay using `**kwargs`. This wait is separate from the busy wait. The busy wait is based on the busy pin state or `refresh_time` and is used to ensure we let the display finish before shutting down or refreshing a second time.

Kangus wrote:And last but not at all least, partial update, no support in displayio at all.

[...]

I have ePaper displays as clocks showing second updates, a partial refresh takes 0.3 seconds but I can't find any partial LUT defined.


Nope. You'd have to change the il0373 driver for it. displayio does track dirty rectangles but it's only used with TFT displays. Sounds like you are doing something more advanced than what we wanted to support with the work we did.


Kangus wrote:But when I tried to add busy_pin I discovered that "Board specific pin names" yet there is noting in the board documentation about gpio handling just I2C, SPI and UART, how do you set direction and pull-ups? I know how that works with digitalio.


I'm not sure what you mean by this. Please give more context. digitalio is the way to set direction and pull and EPaperDisplay uses it internally to read the busy pin state.

tannewt
 
Posts: 2393
Joined: Thu Oct 06, 2016 8:48 pm

Re: displayio documentation and examples

by Kangus on Wed Mar 31, 2021 12:51 pm

A long one:

From displayio.EPaperDisplay busy_pin (microcontroller.Pin) – Pin used to signify the display is busy
From adafruit_il0373.py

class IL0373(displayio.EPaperDisplay)

From il0373_2.9_grayscale.py
"""Simple test script for 2.9" 296x128 grayscale display.
spi = busio.SPI(board.SCK, board.MOSI) # Uses SCK and MOSI
epd_cs = board.D9
epd_dc = board.D10

display_bus = displayio.FourWire(
spi, command=epd_dc, chip_select=epd_cs, baudrate=1000000
)
time.sleep(1)

display = adafruit_il0373.IL0373(
display_bus,
width=296,
height=128,
rotation=270,
black_bits_inverted=False,
color_bits_inverted=False,
grayscale=True,
refresh_time=1,
)
Since the epd_busy pin was not wired on the 2.9 grayscale Feather display it is not defined, I guess

From il0373_2.13_color.py

NOTE: the same Driver adafruit_il0373

import adafruit_il0373

pi = board.SPI() # Uses SCK and MOSI
epd_cs = board.D9
epd_dc = board.D10
epd_reset = board.D5
epd_busy = board.D6

# Create the displayio connection to the display pins
display_bus = displayio.FourWire(
spi, command=epd_dc, chip_select=epd_cs, reset=epd_reset, baudrate=1000000
)
# NOTE: All SPI pins are passed to displayio.FourWire where they are setup for direction ? I looked at FourWire.c and didn't see anything

Here they pass busy_pin as epd_busy to adafruit_il0373.IL0373
# Create the display object - the third color is red (0xff0000)
display = adafruit_il0373.IL0373(
display_bus,
width=212,
height=104,
rotation=90,
busy_pin=epd_busy,
highlight_color=0xFF0000,
)

and in the driver:
:Keyword Arguments:
* *width* (``int``) --
Display width
* *height* (``int``) --
Display height
* *rotation* (``int``) --
Display rotation
* *color_bits_inverted* (``bool``) --
Invert color bit values
* *black_bits_inverted* (``bool``) --
Invert black bit values
"""

there is no busy_pin

Last, the link to the data sheet of the Display controller from the 2.9 Grayscale Feather: https://learn.adafruit.com/adafruit-ein ... ownloads-2

IL0376F E-Ink interface chip datasheet https://cdn-learn.adafruit.com/assets/a ... L0376F.pdf

That is not a il0373 controller, all the LUT structures are different.

The other device that adafriut uses the 2.9 Grayscale display is the MagTag:

displayio_epaperdisplay_obj_t* display = &displays[0].epaper_display;
display->base.type = &displayio_epaperdisplay_type;
common_hal_displayio_epaperdisplay_construct(
display,
bus,
display_start_sequence, sizeof(display_start_sequence),
display_stop_sequence, sizeof(display_stop_sequence),
296, // width
128, // height
160, // ram_width
296, // ram_height
0, // colstart
0, // rowstart
270, // rotation
NO_COMMAND, // set_column_window_command
NO_COMMAND, // set_row_window_command
NO_COMMAND, // set_current_column_command
NO_COMMAND, // set_current_row_command
0x10, // write_black_ram_command
false, // black_bits_inverted
0x13, // write_color_ram_command
false, // color_bits_inverted
0x000000, // highlight_color
0x12, // refresh_display_command
1.0, // refresh_time
&pin_GPIO5, // busy_pin
false, // busy_state
5.0, // seconds_per_frame
false, // always_toggle_chip_select
true); // grayscale
}
It maps the busy_pin to a gpio and uses it:

while (common_hal_displayio_epaperdisplay_get_busy(display)) {
RUN_BACKGROUND_TASKS;
i++;

Kangus
 
Posts: 38
Joined: Sat May 19, 2018 10:01 pm

Re: displayio documentation and examples

by brianw8 on Sun May 02, 2021 4:22 pm

02 May 2021

Is anyone using these epaper modules? I have activated the SPI function on a raspberry pi3, and by some freak of nature, was actually able to get the ribbon cable from the 2.9 inch module to hook to the 4224 breakout friend. If one uses the Thony IDE for python, can one program a simple image to the 2.9 inch module? I haven't used SPI very much. I don't know which pins from the 40 pin header (on the Raspberry Pi 3) to use to hook to the breakout friend. I have yet to download circuit python onto the Pi3. Is there a simple code snippet which will program the 2.9 inch module? Does circuit python work from within the Thony IDE?? Any pointers would be helpful. There seems to be many many snippets available. I just need a simple one. Thank you.

brianw8
 
Posts: 3
Joined: Sat Feb 22, 2014 5:09 pm

Please be positive and constructive with your questions and comments.