Eric Wieser / Mbed 2 deprecated Mystic_rose

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "MobileLCD.h"
00003 
00004 #define PI 3.1415926535897
00005 MobileLCD lcd(5, 6, 7, 8, 9);
00006 DigitalIn Plus(20);
00007 DigitalIn Minus(19);
00008 AnalogIn Potent(18);
00009 struct point
00010 {
00011     int x;
00012     int y;
00013 };
00014 
00015 int numpoints = 10;
00016 point points[256];
00017 
00018 int main()
00019 {
00020     while(1)
00021     {
00022         for(int i=0; i<numpoints; i++)
00023         {
00024             points[i].x = 65+60*sin(2*PI*i/numpoints);
00025             points[i].y = 65+60*cos(2*PI*i/numpoints);
00026         }
00027         lcd.background(0x0);
00028         lcd.cls();
00029         for(int i=0; i<numpoints; i++)
00030         {
00031             for(int j=i+1; j<numpoints; j++)
00032             {
00033                 lcd.line(points[i].x,points[i].y,points[j].x,points[j].y,0xFFFFFF);
00034             }
00035         }
00036         /*
00037         while(1)
00038         {
00039             if(Plus && numpoints<256-1)
00040             {
00041                 numpoints++;
00042                 while(Plus);
00043                 break;
00044             }
00045             else if(Minus && numpoints>3+1)
00046             {
00047                 numpoints--;
00048                 while(Minus);
00049                 break;
00050             }
00051         }*/
00052         while(1)
00053         {
00054             float theta = Potent;
00055             if(abs(numpoints - theta*20)>1)
00056             {
00057                 numpoints = ceil(theta*20);
00058                 break;
00059             }
00060         }
00061     }
00062 }