[Digi-Key Follow Me Issue 4] Getting Started Tasks
[Copy link]
[Digi-Key Follow Me Issue 4 ] Getting Started Tasks: Development Environment Setup, BLINK , and LCD Display Driver
Hardware Environment
According to the requirements of the 4th phase of Digi-Key's Follow me program, we purchased two boards: W5500-EVB-PICO (hereinafter referred to as the main control module) and AdafruitSharp Memory Display (hereinafter referred to as the display module).
Figure 1 Activity requirements for purchasing boards
Figure 2 W5500-EVB-PICO board
Figure 3 AdafruitSharp Memory Display module
The display module is operated through the SPI interface, so the main control module needs to select a suitable pin to complete the drive.
Figure 4: Pin connection relationship between display module and main control module
Figure 5 Module
Currently used IO pin assignment relationship table:
I/O |
Pin Name |
describe |
I |
GP16 |
Connect to MISO of W5500 |
O |
GP17 |
CSn connected to W5500 |
O |
GP18 |
Connect to SCLK of W5500 |
O |
GP19 |
MOSI connected to W5500 |
O |
GP20 |
Connect to RSTn of W5500 |
I |
GP21 |
Connect to INTn of W5500 |
I |
GP24 |
VBUS sense - high if VBUS is present, else low |
O |
GP25 |
User LEDs |
I |
GP29 |
Used in ADC mode (ADC3) to measure VSYS/3 |
O |
GP15 |
Connect to display module DI |
O |
GP14 |
Connect to display module CLK |
O |
GP13 |
Connect to display module CS |
Software Environment
After multiple comparisons, CircuitPython was chosen as the basic software platform for this test.
Figure 6 CircuitPython firmware download
Firmware installation:
There are many online tutorials on the firmware installation process, so I won’t go into details here.
Download the Adafruit library:
It should be noted that we should choose the library that corresponds to the CircuitPython version. For example, if we chose version 8.2.9, we should choose the library circled in red. The library is on GitHub and is difficult to download. You can still succeed after trying a few times.
Figure 7 Library download
Installation of the library:
After we successfully burn CircuitPython to the main control module, reconnect the USB cable or reset the module, you can see that there will be an additional drive letter named CIRCUITPY in the system. The drive letter contains a folder named "lib". If it does not exist, we need to create it ourselves.
Unzip the compressed library file downloaded earlier. The extension of the library file may be mpy. It doesn't matter. The system can recognize it correctly. We select the library files we need in the library and copy them to the lib folder for future use. After installing the library files, it will be as shown in the figure below.
Figure 8 Directory after library file installation
Test code
The test program is edited, uploaded, and run debugged using Tonny software. The code is as follows:
# 测试任务1 入门任务
import time
import board
import busio
import digitalio
import adafruit_sharpmemorydisplay
def led_flush():
led.value = not led.value
time.sleep(0.5)
def clear_disp():
# Clear the display. Always call show after changing pixels to make the display
# update visible!
display.fill(1)
display.show()
def disp_helloworld():
print("hello world")
display.fill(1)
display.text(" hello world!", 30, 50, 0)
display.show()
if __name__ == '__main__':
led = digitalio.DigitalInOut(board.GP25)
led.direction = digitalio.Direction.OUTPUT
# Initialize SPI bus and control pins
spi = busio.SPI(board.GP14, MOSI=board.GP15)
scs = digitalio.DigitalInOut(board.GP13) # inverted chip select
# pass in the display size, width and height, as well
# display = adafruit_sharpmemorydisplay.SharpMemoryDisplay(spi, scs, 96, 96)
display = adafruit_sharpmemorydisplay.SharpMemoryDisplay(spi, scs, 144, 168)
clear_disp()
disp_helloworld()
while True:
led_flush()
Run Output
After the program runs, a line of text "hello world" is displayed in the middle of the display module, and the small light flashes, indicating that the requirements of the entry-level task have been met.
|