|
5 | 5 | from PIL import Image, ImageDraw, ImageFont
|
6 | 6 | import adafruit_rgb_display.ili9341 as ili9341
|
7 | 7 |
|
8 |
| -# Configuration for CS and DC pins (these are FeatherWing defaults on M0/M4): |
| 8 | +# Configuration for CS and DC pins (these are PiTFT defaults): |
9 | 9 | cs_pin = digitalio.DigitalInOut(board.CE0)
|
10 | 10 | dc_pin = digitalio.DigitalInOut(board.D25)
|
11 | 11 | reset_pin = digitalio.DigitalInOut(board.D24)
|
12 | 12 |
|
13 | 13 | # Config for display baudrate (default max is 24mhz):
|
14 |
| -BAUDRATE = 24000000 |
| 14 | +BAUDRATE = 64000000 |
15 | 15 |
|
16 | 16 | # Setup SPI bus using hardware SPI:
|
17 | 17 | spi = board.SPI()
|
|
33 | 33 | draw.rectangle((0, 0, width, height), outline=0, fill=(0, 0, 0))
|
34 | 34 | disp.image(image, rotation)
|
35 | 35 |
|
36 |
| -# Draw some shapes. |
37 |
| -# First define some constants to allow easy resizing of shapes. |
| 36 | +# First define some constants to allow easy positioning of text. |
38 | 37 | padding = -2
|
39 |
| -top = padding |
40 |
| -bottom = height-padding |
41 |
| - |
42 |
| -# Move left to right keeping track of the current x position for drawing shapes. |
43 | 38 | x = 0
|
44 | 39 |
|
45 |
| - |
46 |
| -# Alternatively load a TTF font. Make sure the .ttf font file is in the |
| 40 | +# Load a TTF font. Make sure the .ttf font file is in the |
47 | 41 | # same directory as the python script!
|
48 | 42 | # Some other nice fonts to try: http://www.dafont.com/bitmap.php
|
49 | 43 | font = ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf', 24)
|
|
66 | 60 | Temp = subprocess.check_output(cmd, shell=True).decode("utf-8")
|
67 | 61 |
|
68 | 62 | # Write four lines of text.
|
69 |
| - y = top |
| 63 | + y = padding |
70 | 64 | draw.text((x, y), IP, font=font, fill="#FFFFFF")
|
71 | 65 | y += font.getsize(IP)[1]
|
72 | 66 | draw.text((x, y), CPU, font=font, fill="#FFFF00")
|
|
0 commit comments