计划弄个彩色屏幕,其实卓大好久前就弄好了,只是没有发帖子,也学着弄吧,其间出现各种错误,感谢卓大的指导
首先找到一块SPI_TFT_ILI9341屏幕,这个是香蕉派上的,怎么接线呢,一头雾水
写了一段小程序,其实是假的小游戏,有机会实现吧
// example to test the TFT Display
// Thanks to the GraphicsDisplay and TextDisplay classes
// test2.bmp has to be on the mbed file system
#include "stdio.h"
#include "mbed.h"
#include "SPI_TFT_ILI9341.h"
#include "string"
#include "Arial12x12.h"
#include "Arial24x23.h"
#include "Arial28x28.h"
#include "font_big.h"
#include <time.h>
#include <stdlib.h>
SPI_TFT_ILI9341 TFT(D11, D12, D13, D10, D9, D8, "TFT"); // mosi, miso, sclk, cs, reset, dc
int x=20;
int y=60;
int dx=10;
int dy=10;
int l=20;
int x1=0;
int x2=0;
int x3=0;
int main()
{
TFT.claim(stdout); // send stdout to the TFT display
TFT.foreground(White);
TFT.background(Blue);
TFT.set_orientation(1);
TFT.cls();
TFT.set_font((unsigned char*) Neu42x35);
TFT.locate(40,5);
TFT.printf("Hello Mbed");
TFT.rect(10,50,310,230,Red);
TFT.set_font((unsigned char*) Arial24x23);
srand(time(0));
while(1) {
x3=x;
x1=x-l;
x2=x+l;
if (x1<12) x1=12;
if (x2>307) x2=307;
TFT.foreground(White);
TFT.locate(x,y);
TFT.printf("o");
TFT.fillrect(x1,225,x2,228,Yellow);
wait(0.1);
TFT.foreground(Blue);
TFT.locate(x,y);
TFT.printf("o");
TFT.fillrect(x1,225,x2,228,Blue);
x+=dx;
y+=dy;
if (x>280) {
x=280;
dx=-(rand()%30+20);
}
if (x<30) {
x=30;
dx=(rand()%30+20);
}
if (y>200) {
y=200;
dy=-(rand()%30+20);
}
if (y<70) {
y=70;
dy=(rand()%30+20);
}
}
}
| 有奖活动 | |
|---|---|
| 2026年“我要开发板活动”第三季,开始了! | |
| 硬核工程师专属补给计划——填盲盒 | |
| “我踩过的那些坑”主题活动——第002期 | |
| 【EEPW电子工程师创研计划】技术变现通道已开启~ | |
| 发原创文章 【每月瓜分千元赏金 凭实力攒钱买好礼~】 | |
| 【EEPW在线】E起听工程师的声音! | |
| 高校联络员开始招募啦!有惊喜!! | |
| 【工程师专属福利】每天30秒,积分轻松拿!EEPW宠粉打卡计划启动! | |
我要赚赏金打赏帖 |
|
|---|---|
| RTOS怎么选?让我来给你答案!被打赏¥15元 | |
| 【S32K3XX】Flash驱动使用被打赏¥26元 | |
| 【FreeRtos】第一个任务的启动过程被打赏¥21元 | |
| 【分享开发笔记,赚取电动螺丝刀】FPB-RA6E2开发板的WDT功能测试被打赏¥22元 | |
| 关于cmakelist特性presets的使用被打赏¥20元 | |
| 【分享开发笔记,赚取电动螺丝刀】M5STACK系列屏幕质量测试程序,竟然有块亮斑?被打赏¥20元 | |
| 【分享开发笔记,赚取电动螺丝刀】快速搭建瑞萨FPB-RA6E2开发板开发环境被打赏¥14元 | |
| 【分享开发笔记,赚取电动螺丝刀】在音频测试中顺序的调整可改变功效被打赏¥18元 | |
| 【分享开发笔记,赚取电动螺丝刀】点阵显示模块及其应用-----献给新年的小礼物被打赏¥22元 | |
| 基于地奇星开发板的数码管模块显示技术被打赏¥23元 | |