STM32F746-Disco试用7-画图2

  • shaoziyang
  • LV5工程师
  • |      2015-11-30 22:44:34
  • 浏览量 624
  • 回复:0

这个例子中,绘制首尾相接的直线。同时,可以按下反面的蓝色按钮清屏。


#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;

    }

}

  • 0
  • 收藏
  • 举报
  • 分享
我来回复

登录后可评论,请 登录注册

所有回答 数量:0
x
收藏成功!点击 我的收藏 查看收藏的全部帖子