Kamil Ondrousek / Mbed 2 deprecated Sierpin-Tri

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "TFT_4DGL.h"
00002 
00003 TFT_4DGL lcd(p9,p10,p11);
00004 
00005 #define PI 3.14159265
00006 
00007 struct point
00008 {
00009     int x;
00010     int y;
00011 };
00012 
00013 point points[3];
00014 point current;
00015 
00016 int main() {
00017      
00018      int n = WHITE;
00019    
00020  for(int i=0; i<3; i++)
00021     {
00022         points[i].x = 150*sin(2*PI*i/3);
00023         points[i].y = 150*cos(2*PI*i/3);
00024     }
00025     
00026     current = points[rand()%3];
00027     
00028     while(1)
00029     {
00030     
00031         lcd.pixel(80+current.y,160+current.x,n);
00032         
00033         point nextpoint = points[rand()%3];
00034         
00035         current.x = (current.x + nextpoint.x)/2;
00036         current.y = (current.y + nextpoint.y)/2;
00037     }
00038 }