计划弄个彩色屏幕,其实卓大好久前就弄好了,只是没有发帖子,也学着弄吧,其间出现各种错误,感谢卓大的指导
首先找到一块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);
}
}
}
我要赚赏金打赏帖 |
|
|---|---|
| 【FreeRtos】FreeRtos + MPU模块的配置使用被打赏¥32元 | |
| 【分享开发笔记,赚取电动螺丝刀】墨水屏文本显示器被打赏¥25元 | |
| 【STEVAL-STWINKT1B】:结合STMcubeMX读取磁力计iis2mdc被打赏¥19元 | |
| 【STEVAL-STWINKT1B】:结合STMcubeMX读取LPS22HH气压、温度被打赏¥19元 | |
| 【STEVAL-STWINKT1B】:结合STMcubeMX读取STTS751温度被打赏¥17元 | |
| 【STEVAL-STWINKT1B】:结合STMcubeMX软件读取HTS221温湿度被打赏¥22元 | |
| M5PAPERESP32EINKDEVKIT评测|使用MicroPython开发M5Paper被打赏¥15元 | |
| OK1126B-S开发板下以导航按键控制云台/机械臂姿态调整被打赏¥29元 | |
| 【树莓派5】便携热成像仪被打赏¥36元 | |
| 【树莓派5】环境监测仪被打赏¥35元 | |