【得捷电子Follow me第4期】入门任务:开发环境搭建,BLINK,驱动液晶显示器进行显示
[复制链接]
本帖最后由 zygalaxy 于 2024-2-21 13:39 编辑
非常开心参加这次的Follow me第4期,本次使用的的核心板为 W5500-EVB-Pico,并且搭配一块 Pervasive Displays的EPD(墨水屏)来完成任务
入门任务:
一、开发环境搭建
本次使用的墨水屏幕在 arduino 有非常好的支持,所以使用 arduino 来完成以后的任务
1、下载安装 arduino
进入arduino官网下载 Software | Arduino
根据自己电脑,在红色框内选择要下载的安装包
2、安装 arduino完成以后打开 arduino,点击左侧第二个菜单添加 pico 开发板,直接搜索rp2040 即可
3、在选择开发板和接口处输入 pico 选择 Raspberry Pi Pico即可
到这里开发环境搭建基本完成
二、BLINK
按如下步骤选择点灯额示例代码
点击上传按钮,即可编译下载程序
点灯代码:
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
观察开发板即可看到,已经点灯成功
三、驱动液晶显示器
1、连接屏幕线
在屏幕连接器的官网EXT3-1 - PDI Public Wiki (pervasivedisplays.com)种可以找到PCB图以及接线的方式
连接的引脚图 Wiring to Raspberry Pico - PDI Public Wiki (pervasivedisplays.com)
连接好屏幕后的效果图
2、安装屏幕显示的驱动库
安装好驱动以后选择演示代码
测试代码:
/ Screen
#include "PDLS_EXT3_Basic_Global.h"
// SDK
// #include <Arduino.h>
#include "hV_HAL_Peripherals.h"
// Include application, user and local libraries
// #include <SPI.h>
// Configuration
#include "hV_Configuration.h"
// Set parameters
// Define structures and classes
// Define variables and constants
// Screen_EPD_EXT3 myScreen(eScreen_EPD_EXT3_154, boardRaspberryPiPico_RP2040);
// Screen_EPD_EXT3 myScreen(eScreen_EPD_EXT3_213, boardRaspberryPiPico_RP2040);
// Screen_EPD_EXT3 myScreen(eScreen_EPD_EXT3_266, boardRaspberryPiPico_RP2040);
// Screen_EPD_EXT3 myScreen(eScreen_EPD_EXT3_271, boardRaspberryPiPico_RP2040);
// Screen_EPD_EXT3 myScreen(eScreen_EPD_EXT3_287, boardRaspberryPiPico_RP2040);
Screen_EPD_EXT3 myScreen(eScreen_EPD_EXT3_370, boardRaspberryPiPico_RP2040);
// Screen_EPD_EXT3 myScreen(eScreen_EPD_EXT3_417, boardRaspberryPiPico_RP2040);
// Screen_EPD_EXT3 myScreen(eScreen_EPD_EXT3_437, boardRaspberryPiPico_RP2040);
// Screen_EPD_EXT3 myScreen(eScreen_EPD_EXT3_565, boardRaspberryPiPico_RP2040);
// Screen_EPD_EXT3 myScreen(eScreen_EPD_EXT3_581, boardRaspberryPiPico_RP2040);
// Screen_EPD_EXT3 myScreen(eScreen_EPD_EXT3_741, boardRaspberryPiPico_RP2040);
// Screen_EPD_EXT3 myScreen(eScreen_EPD_EXT3_969, boardRaspberryPiPico_RP2040);
// Screen_EPD_EXT3 myScreen(eScreen_EPD_EXT3_B98, boardRaspberryPiPico_RP2040);
// Prototypes
// Utilities
///
/// @brief Wait with countdown
/// @param second duration, s
///
void wait(uint8_t second)
{
for (uint8_t i = second; i > 0; i--)
{
Serial.print(formatString(" > %i \r", i));
delay(1000);
}
Serial.print(" \r");
}
// Functions
///
/// @brief Fonts test screen
/// @param flag true = default = perform flush, otherwise no
///
/// @image html T2_FONTS..jpg
/// @image latex T2_FONTS.PDF width=10cm
///
void displayFonts(bool flag = true)
{
uint16_t y = 10;
myScreen.setOrientation(7);
// #if (USE_FONT_MODE == USE_FONT_TERMINAL)
myScreen.selectFont(Font_Terminal12x16);
myScreen.gText(10, y, myScreen.WhoAmI(), myColours.red);
y += myScreen.characterSizeY();
myScreen.gText(10, y, formatString("%i x %i", myScreen.screenSizeX(), myScreen.screenSizeY()), myColours.red);
y += myScreen.characterSizeY();
y += myScreen.characterSizeY();
myScreen.selectFont(Font_Terminal6x8);
myScreen.gText(10, y, "Terminal6x8");
y += myScreen.characterSizeY();
myScreen.selectFont(Font_Terminal8x12);
myScreen.gText(10, y, "Terminal8x12");
y += myScreen.characterSizeY();
myScreen.selectFont(Font_Terminal12x16);
myScreen.gText(10, y, "Terminal12x16");
y += myScreen.characterSizeY();
myScreen.selectFont(Font_Terminal16x24);
myScreen.gText(10, y, "Terminal16x24");
y += myScreen.characterSizeY();
myScreen.flush();
}
// Add setup code
///
/// @brief Setup
///
void setup()
{
Serial.begin(115200);
delay(500);
Serial.println();
Serial.println("=== " __FILE__);
Serial.println("=== " __DATE__ " " __TIME__);
Serial.println();
Serial.println("begin... ");
myScreen.begin();
Serial.println(formatString("%s %ix%i", myScreen.WhoAmI().c_str(), myScreen.screenSizeX(), myScreen.screenSizeY()));
Serial.println("Fonts... ");
myScreen.clear();
displayFonts();
wait(8);
Serial.println("White... ");
myScreen.clear();
myScreen.flush();
Serial.println("=== ");
Serial.println();
}
// Add loop code
///
/// @brief Loop, empty
///
void loop()
{
delay(1000);
}
3、屏幕显示:
四、总结
通过入门任务将开发环境搭建好为后续更好的完成任务打下了基础,这是第一次使用墨水屏,让我对墨水屏幕有了初步的了解,希望以后能更好的利用这块屏幕。
|