|
27 | 27 |
|
28 | 28 | # *** Choose your color display driver here *** |
29 | 29 | # ili9341 specific driver |
30 | | -from drivers.ili93xx.ili9341 import ILI9341 as SSD |
| 30 | +#from drivers.ili93xx.ili9341 import ILI9341 as SSD # 4-bit buffer, also supports grayscale/greyscale |
| 31 | +from drivers.ili93xx.ili9341_8bit import ILI9341 as SSD # 8-bit buffer (needs more 2x memory of 4-bit driver) - does not support grayscale/greyscale, for non-color use matching r, g, b values. |
31 | 32 |
|
32 | 33 | PIN_sck = 14 |
33 | 34 | PIN_mosi = 13 |
|
47 | 48 | spi = SPI(1, 10_000_000, sck=Pin(PIN_sck), mosi=Pin(PIN_mosi)) # default miso |
48 | 49 |
|
49 | 50 |
|
50 | | -# NOTE on CYD1 clock is upside down. |
| 51 | +number_of_usb_ports = 1 |
| 52 | +number_of_usb_ports = 2 |
| 53 | +if number_of_usb_ports == 1: |
| 54 | + # CYD / CYD1 |
| 55 | + # landscape - (0, 0) is top left hand corner |
| 56 | + #ssd = SSD(spi, dc=pdc, cs=pcs, rst=prst, usd=True) # CYD1 working landscape mode |
| 57 | + default_mod = None |
| 58 | + default_bgr = False |
| 59 | + default_usd = True |
| 60 | +else: # if number_of_usb_ports == 2: |
| 61 | + # CYD2 |
| 62 | + # landscape |
| 63 | + # NOTE on (first) init, CYD2 screen will contain static (unlike CYD1) |
| 64 | + #default_mod = 1 # 1, 3, 5, and 7 is GARBAGE |
| 65 | + #default_mod = 0 # 0 appears to be landscape mirror flipped vertically - (0, 0) is top right hand corner |
| 66 | + #default_mod = 2 # 2 is landscape, flipped/mirrored somehow (TBD) - (0, 0) is bottom right hand corner |
| 67 | + #default_mod = 4 # 4 is landscape, correct! - (0, 0) is top left hand corner |
| 68 | + #default_mod = 6 # 4 is landscape, flipped/mirrored somehow (TBD) - (0, 0) is bottom left hand corner |
| 69 | + default_mod = 4 # 4 is landscape, correct! - (0, 0) is top left hand corner |
| 70 | + default_bgr = True |
| 71 | + default_usd = False |
| 72 | +height, width = 240, 320 |
| 73 | + |
| 74 | + |
| 75 | +# If below fails with memory errors, check main.py/boot.py (are empty) and re-run |
| 76 | +ssd = SSD(spi, dc=pdc, cs=pcs, rst=prst, height=height, width=width, usd=default_usd, mod=default_mod, bgr=default_bgr) |
| 77 | + |
| 78 | +############ |
| 79 | + |
| 80 | +# NOTE on CYD1 clock is upside down, with default parameters into ILI9341 display driver |
51 | 81 | # With power usb bottom right from front, clock is bottom right hand and upside down |
52 | | -# setting usd to True will correct this |
53 | | -# For more information see https://github.com/peterhinch/micropython-nano-gui/blob/master/DRIVERS.md#32-drivers-for-ili9341 |
54 | | -# TODO for CYD2 probably need to pass in height=320, width=240 (i.e. transposed compared with default and CYD1) |
55 | | -usd = False # Default |
56 | | -usd = True |
| 82 | +# setting usd to True will correct this - https://github.com/peterhinch/micropython-nano-gui/blob/master/DRIVERS.md#32-drivers-for-ili9341 |
| 83 | + |
| 84 | +# landscape - CYD1 |
| 85 | +#ssd = SSD(spi, dc=pdc, cs=pcs, rst=prst, usd=True) # CYD - with single USB port, height=240, width=320 - works in landscape mode |
| 86 | +#ssd = SSD(spi, dc=pdc, cs=pcs, rst=prst, usd=True, rotated=True) # CYD - with single USB port, height=240, width=320 - works in landscape mode |
| 87 | +##ssd = SSD(spi, dc=pdc, cs=pcs, rst=prst, usd=True, rotated=False) # CYD - with single USB port, height=240, width=320 - GARBAGE displayed |
| 88 | + |
| 89 | +# portrait - CYD1 |
| 90 | +#ssd = SSD(spi, dc=pdc, cs=pcs, rst=prst, height=320, width=240, usd=False, rotated=False) # CYD - with single USB port - works in portrait mode, with USB at top of screen |
| 91 | +#ssd = SSD(spi, dc=pdc, cs=pcs, rst=prst, height=320, width=240, usd=True, rotated=False) # CYD - with single USB port - works in portrait mode, with USB at bottom of screen |
| 92 | +##ssd = SSD(spi, dc=pdc, cs=pcs, rst=prst, height=320, width=240, usd=False, rotated=True) # CYD - with single USB port - GARBAGE displayed |
| 93 | + |
| 94 | +################################## |
| 95 | + |
| 96 | +# NOTE on CYD2 display is rotated, in comparison to CYD1 |
| 97 | + |
| 98 | +# landscape - CYD2 |
| 99 | +#ssd = SSD(spi, dc=pdc, cs=pcs, rst=prst, height=240, width=320, usd=False, rotated=False) # CYD2 with 2x USB ports |
| 100 | +#ssd = SSD(spi, dc=pdc, cs=pcs, rst=prst, height=240, width=320, usd=True, rotated=False) # CYD2 with 2x USB ports, upside down |
| 101 | +####this does not work. Still figuring out nano landscape options for CYD2 |
| 102 | + |
| 103 | +# portrait - CYD2 |
| 104 | +# CYD2 - with 2 USB ports - NOTE when screen inits get static |
| 105 | +#ssd = SSD(spi, dc=pdc, cs=pcs, rst=prst, height=320, width=240, usd=False, rotated=True) # CYD2 with 2x USB ports, this works for portrait viewing, with USB at bottom of screen |
| 106 | +#ssd = SSD(spi, dc=pdc, cs=pcs, rst=prst, height=320, width=240, usd=True, rotated=True) # CYD2 with 2x USB ports, this works for portrait viewing, with USB at top of screen |
57 | 107 |
|
58 | | -ssd = SSD(spi, dc=pdc, cs=pcs, rst=prst, usd=usd) |
59 | 108 |
|
60 | 109 | # on CYD need to turn on backlight to see anything |
61 | 110 | backlight_percentage = 50 |
|
0 commit comments