这个例子中,绘制首尾相接的直线。同时,可以按下反面的蓝色按钮清屏。
#include "mbed.h" #include "LCD_DISCO_F746NG.h" #define WIDTH 480 #define HEIGHT 272 DigitalOut led1(LED1); DigitalIn button(PI_11); LCD_DISCO_F746NG lcd; uint16_t x1, y1, x2, y2; int main() { led1 = 1; x1 = rand()%WIDTH; y1 = rand()%HEIGHT; x2 = rand()%WIDTH; y2 = rand()%HEIGHT; while(1) { lcd.SetTextColor(rand()); lcd.DrawLine(x1, y1, x2, y2); x1 = x2; y1 = y2; x2 = rand()%WIDTH; y2 = rand()%HEIGHT; if(button == 1) { lcd.Clear(0); } wait(0.1); led1 = !led1; } }