|
15 | 15 | # create the spi device and pins we will need
|
16 | 16 | spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
|
17 | 17 |
|
18 |
| -ecs = digitalio.DigitalInOut(board.D22) |
19 |
| -dc = digitalio.DigitalInOut(board.D13) |
20 |
| -srcs = digitalio.DigitalInOut(board.D6) |
21 |
| -rst = digitalio.DigitalInOut(board.D19) |
22 |
| -busy = digitalio.DigitalInOut(board.D26) |
| 18 | +# create the spi device and pins we will need |
| 19 | +spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO) |
| 20 | +ecs = digitalio.DigitalInOut(board.D4) |
| 21 | +dc = digitalio.DigitalInOut(board.D5) |
| 22 | +srcs = None |
| 23 | +rst = digitalio.DigitalInOut(board.D6) # can be None to not use this pin |
| 24 | +busy = digitalio.DigitalInOut(board.D7) # can be None to not use this pin |
| 25 | + |
23 | 26 |
|
24 | 27 |
|
25 | 28 | # give them all to our driver
|
|
34 | 37 | cs_pin=ecs, dc_pin=dc, sramcs_pin=srcs,
|
35 | 38 | rst_pin=rst, busy_pin=busy)
|
36 | 39 |
|
37 |
| - |
| 40 | +display.rotation = 3 |
38 | 41 | # Create blank image for drawing.
|
39 | 42 | # Make sure to create image with mode '1' for 1-bit color.
|
40 | 43 | width = display.width
|
|
50 | 53 |
|
51 | 54 | # Get drawing object to draw on image.
|
52 | 55 | draw = ImageDraw.Draw(image)
|
| 56 | +# empty it |
| 57 | +draw.rectangle((0, 0, width, height), fill=WHITE) |
53 | 58 |
|
54 |
| -# Draw a white filled box to clear the image. |
55 |
| -draw.rectangle((0,0,width,height), outline=BLACK, fill=WHITE) |
| 59 | +# Draw an outline box |
| 60 | +draw.rectangle((1, 1, width-2, height-2), outline=BLACK, fill=WHITE) |
56 | 61 |
|
57 | 62 | # Draw some shapes.
|
58 | 63 | # First define some constants to allow easy resizing of shapes.
|
59 |
| -padding = 2 |
| 64 | +padding = 5 |
60 | 65 | shape_width = 30
|
61 | 66 | top = padding
|
62 | 67 | bottom = height-padding
|
|
78 | 83 | x += shape_width+padding
|
79 | 84 |
|
80 | 85 | # Load default font.
|
81 |
| -font = ImageFont.load_default() |
| 86 | +font = ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf', 20) |
82 | 87 |
|
83 | 88 | # Alternatively load a TTF font. Make sure the .ttf font
|
84 | 89 | # file is in the same directory as the python script!
|
|
0 commit comments