yibai 发表于 2024-4-20 09:57:59

firebeetle2 esp-c6试用报告2——小白又来了

经历环境配置之后,用arduino IDE点灯后,对于初学者小白来说是鼓舞,但是也是没有任何技术含量的项目,但是没关系,大佬们不都是从不会到会的过程么?
于是,我的第二篇试用报告来了,还是基础的入门,通过firebeetle2 esp-c6点亮led屏。
作为学渣文具多的典型,我有好几套的arduino的实验套餐,道具虽多,但是技术有限,勉强完成了点屏。
首先打开arduino IDE,选择板子类型跟端口,连接设备。一开始,想一口吃个胖子,使用温湿度传感器在屏幕上显示温湿度,结果失败了,粗浅的找下原因,一是温湿度的传感器不匹配库,二是板子的插针我没焊,解除不良。


后来,放弃了这艰巨的任务,留着后面慢慢再探索吧。于是我把温湿度传感器拆了,留下来屏幕,找到相关的点led程序。
#include "DFRobot_GDL.h"#define TFT_DC8#define TFT_CS1#define TFT_RST 14DFRobot_ST7735_128x160_HW_SPI screen(/*dc=*/TFT_DC,/*cs=*/TFT_CS,/*rst=*/TFT_RST);/* M0 mainboard DMA transfer *///DFRobot_ST7735_128x160_DMA_SPI screen(/*dc=*/TFT_DC,/*cs=*/TFT_CS,/*rst=*/TFT_RST);void setup() {Serial.begin(115200);screen.begin();}void loop(){    testLine();    testFastLines(COLOR_RGB565_PURPLE,COLOR_RGB565_YELLOW);         testRects(COLOR_RGB565_BLACK,COLOR_RGB565_WHITE);    testRoundRects();    testCircles(24,COLOR_RGB565_BLUE);    testTriangles(COLOR_RGB565_YELLOW);    testPrint();}void testLine(){uint16_t color = 0x00FF;screen.fillScreen(COLOR_RGB565_BLACK);for (int16_t x=0; x < screen.width(); x+=6) {    screen.drawLine(/*x0=*/screen.width()/*Screen width*//2, /*y0=*/screen.height()/*Screen height*//2, /*x1=*/x, /*y1=*/0, /*c=*/color+=0x0700);}for (int16_t y=0; y < screen.height(); y+=6) {    screen.drawLine(screen.width()/2, screen.height()/2, screen.width(), y, color+=0x0700);}for (int16_t x = screen.width(); x >= 0; x-=6) {    screen.drawLine(screen.width()/2, screen.height()/2, x,screen.height(), color+=0x0700);}for (int16_t y = screen.height(); y >= 0; y-=6) {    screen.drawLine(screen.width()/2, screen.height()/2, 0, y, color+=0x0700);}}void testFastLines(uint16_t color1, uint16_t color2) {for (int16_t y=0; y < screen.height(); y+=4) {    screen.drawFastHLine(/*x=*/0, /*y=*/y, /*w=*/screen.width(),/*c=*/color2);    delay(10);}for(int16_t x=0; x < screen.width(); x+=3) {    screen.drawFastVLine(/*x=*/x, /*y=*/0, /*h=*/screen.height(), /*c=*/color1);    delay(10);}}void testRects(uint16_t color1, uint16_t color2) {   screen.fillScreen(COLOR_RGB565_BLACK);    int16_t x=screen.width()-12;    for (; x > 100; x-=screen.width()/40) {      screen.drawRect(/*x=*/screen.width()/2 -x/2, /*y=*/screen.height()/2 -x/2 , /*w=*/x, /*h=*/x, /*color=*/color2+=0x0F00);      delay(100);    }    screen.fillRect(/*x=*/screen.width()/2 -x/2, /*y=*/screen.height()/2 -x/2 , /*w=*/x, /*h=*/x, /*color=*/color2);    delay(100);    for(; x > 6; x-=screen.width()/40){      screen.drawRect(screen.width()/2 -x/2, screen.height()/2 -x/2 , x, x, color1);      delay(100);    }}void testRoundRects() {screen.fillScreen(COLOR_RGB565_BLACK);int color = 0xF00F;int i;int x = 0;int y = 0;int w = screen.width()-3;int h = screen.height()-3;for(i = 0 ; i <= 10; i+=2) {    screen.drawRoundRect(/*x0=*/x, /*y0=*/y, /*w=*/w, /*h=*/h, /*radius=*/20, /*color=*/color);    x+=5;    y+=5;    w-=10;    h-=10;    color+=0x0100;    delay(50);}for(i = 0 ; i <= 10; i+=2) {    screen.fillRoundRect(/*x0=*/x, /*y0=*/y, /*w=*/w, /*h=*/h, /*radius=*/10, /*color=*/color);    x+=5;    y+=5;    w-=10;    h-=10;    color+=0x0500;    delay(50);}}void testCircles(uint8_t radius, uint16_t color) {screen.fillScreen(COLOR_RGB565_BLACK);for (int16_t x=radius; x <=screen.width()-radius; x+=radius*2) {    for (int16_t y=radius; y <=screen.height()-radius; y+=radius*2) {      screen.drawCircle(/*x0=*/x, /*y0=*/y, /*r=*/radius, /*color=*/color);      if(x == y ||x == -y ||x == y + 2*radius)          screen.fillCircle(/*x0=*/x, /*y0=*/y, /*r=*/radius, /*color=*/color);       color += 800;       delay(100);    }}}void testTriangles(uint16_t color){screen.fillScreen(COLOR_RGB565_BLACK);for (int16_t i=0; i <=screen.width(); i+=24)    screen.drawTriangle(/*x0=*/i,/*y0=*/0,/*x1=*/0,/*y1=*/screen.height()-i,/*x2=*/screen.width()-i,/*y2=*/screen.height(), /*color=*/color);for (int16_t i=0; i <screen.width(); i+=24)    screen.drawTriangle(screen.width(),i*4/3,0,screen.height()-i*4/3,i,0, color);for (int16_t i=0; i <screen.width(); i+=24)    screen.drawTriangle(screen.width(),i*4/3,i,0,screen.width()-i,screen.height(), color);color = COLOR_RGB565_RED;for (int16_t i=0; i <=screen.width(); i+=24)    screen.fillTriangle(/*x0=*/i,/*y0=*/0,/*x1=*/0,/*y1=*/screen.height()-i,/*x2=*/screen.width()-i,/*y2=*/screen.height(), /*color=*/color+=100);for (int16_t i=0; i <screen.width(); i+=24)    screen.fillTriangle(screen.width(),i*4/3,0,screen.height()-i*4/3,i,0, color+=100);for (int16_t i=0; i <screen.width(); i+=24)    screen.fillTriangle(screen.width(),i*4/3,i,0,screen.width()-i,screen.height(), color+=100);}void testPrint() {int16_t color = 0x00FF;screen.setTextWrap(false);screen.fillScreen(COLOR_RGB565_BLACK);screen.setCursor(0, 50);screen.setTextColor(color+=0x3000);screen.setTextSize(0);screen.println("Hello World!");screen.setTextColor(color+=0x3000);screen.setTextSize(1);screen.println("Hello World!");screen.setTextColor(color+=0x3000);screen.setTextSize(2);screen.println("Hello World!");screen.setTextColor(color+=0x3000);screen.setTextSize(3);screen.println("Hello World!");screen.setTextColor(color+=0x3000)screen.setTextSize(4);screen.println("Hello!");   screen.setTextSize(5);screen.print("Hello!");delay(2000);screen.setCursor(0, 0);screen.fillScreen(COLOR_RGB565_BLACK);screen.setTextSize(2);screen.setTextColor(color+=0x3000);screen.print("a = ");screen.setTextColor(color+=0x3000);int a = 1234;screen.println(a, 1);screen.setTextColor(color+=0x3000);screen.print(8675309, HEX);screen.println("this is HEX!");screen.println("");screen.setTextColor(color+=0x0F00);screen.println("running for: ");screen.setTextColor(color+=0x0F00);screen.print(millis());screen.setTextColor(color+=0x0F00);screen.println("/1000 seconds.");char text[ = "Hi DFRobot!";screen.setTextColor(color+=0x0F00);screen.setTextWrap(true);screen.setTextSize(3);screen.println(text);//screen.setFonts((const gdl_Font_t *)SIMKAIFont18ptBitmaps);screen.println(text);delay(2000);}

在整个过程中,遇到了几点问题:
一是插针接触不良,led没有亮,我以为是型号问题,换了一个led屏。
二是GDL库版本要安装。



三是整个程序跑完没问题,但是屏幕没反应,提示'hard resetting',手动按了板子上的reset键,再重新烧录程序就可以了


下一个适用目标,是实现用屏幕跟温湿度传感器显示温湿度,小白要努力。


页: [1]
查看完整版本: firebeetle2 esp-c6试用报告2——小白又来了