计划弄个彩色屏幕,其实卓大好久前就弄好了,只是没有发帖子,也学着弄吧,其间出现各种错误,感谢卓大的指导
首先找到一块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);
}
}
}
我要赚赏金打赏帖 |
|
|---|---|
| 基于MCP23S17的输入输出功能模块控制被打赏¥20元 | |
| 【S32K3XX】SPD 软件包使用Link文件修改被打赏¥22元 | |
| Switch-Case局部变量定义问题被打赏¥23元 | |
| 基于米尔TIAM62L开发板的串口通信及应用被打赏¥20元 | |
| PCF8574功能模块及其使用被打赏¥20元 | |
| 传感器LSM6DSO及LIS3MDL的功能检测被打赏¥18元 | |
| LPS25HB气压传感器及其检测被打赏¥18元 | |
| HTS221温湿度传感器及其检测被打赏¥18元 | |
| 【S32K3XX】HSE FW 版本更新被打赏¥21元 | |
| 基于ArduinoUNO开发板的AT24C02读写测试被打赏¥16元 | |