This class encapsulates all the algorithms required for the displaying strings and time dependent patterns on the lcd.
Dependents: 200943412_QuickClick
Diff: Display.cpp
- Revision:
- 10:6f5a88c24a07
- Parent:
- 9:1e25dcab4927
- Child:
- 11:7ad2ea427784
--- a/Display.cpp Sat Apr 15 15:38:51 2017 +0000 +++ b/Display.cpp Sun Apr 16 13:44:55 2017 +0000 @@ -5,15 +5,7 @@ Display::Display() { - _h = 0; - _w = 0.3; - _a = 0; - _A = 0; - _v = 0; - x = 0; - y = 0; - x0 = 0; - y0 = 0; + } Display::~Display() @@ -23,137 +15,175 @@ void Display::init() { - _h = 0; - _w = 0.3; - _a = 0; - _A = 0; - _v = 0; - x = 0; - y = 0; - x0 = 0; - y0 = 0; + _h = 0; + _w = 0.3; + _a = 0; + _v = 0; + x = 0; + y = 0; + x0 = 0; + y0 = 0; } void Display::drawCircle(Controller &pad, N5110 &lcd) -{ - Circle(pad, lcd); - calculateWait(); +{ + Circle(pad, lcd); + calculateWait(); + printf("%d\n",_h); _h++; - lcd.clear(); + lcd.clear(); lcd.refresh(); - } +} -void Display::calculateWait() -{ - _w = 0.3*exp(-0.03465*_h); - -} - -void Display::display_instruction(N5110 &lcd, int ran) { +void Display::calculateWait() +{ + printf("Arc Number :- %d\n",_h); + _w = 0.3*exp(-0.03465*_h); + printf("Wait 1 :- %f7.6/n",_w); +} + +void Display::display_instruction(N5110 &lcd, int ran) +{ lcd.clear(); - if (ran == 1){ + printf("Random number :- %d\n",ran); + if (ran == 1) { lcd.printString("PRESS",28,2); - lcd.printChar('A',40,3); } - else if (ran == 2){ + lcd.printChar('A',40,3); + } else if (ran == 2) { lcd.printString("PRESS",28,2); - lcd.printChar('B',40,3); } - else if (ran == 3){ + lcd.printChar('B',40,3); + } else if (ran == 3) { lcd.printString("PRESS",28,2); - lcd.printChar('X',40,3); } - else if (ran == 4){ + lcd.printChar('X',40,3); + } else if (ran == 4) { lcd.printString("PRESS",28,2); - lcd.printChar('Y',40,3); } - else if (ran == 5){ + lcd.printChar('Y',40,3); + } else if (ran == 5) { lcd.printString("FLICK",28,2); - lcd.printChar('L',40,3); } - else if (ran == 6){ + lcd.printChar('L',40,3); + } else if (ran == 6) { lcd.printString("FLICK",28,2); - lcd.printChar('R',40,3); } - else { + lcd.printChar('R',40,3); + } else { lcd.printString("PRESS",28,2); - lcd.printString("STICK",28,3); } - lcd.refresh(); - } - + lcd.printString("STICK",28,3); + } + lcd.refresh(); +} + // function to draw circle void Display::Circle(Controller &pad ,N5110 &lcd) { - for (int a = 0; a < 8; ++a) - { - Drawarc(lcd, a); - lcd.refresh(); - float Brightness = pad.read_pot(); - lcd.setBrightness(Brightness); - wait(_w); - lcd.setBrightness(0.0); - wait(_w); - } - - } - -void Display::Drawarc(N5110 &lcd, int a) { + for (int a = 0; a < 8; ++a) { + printf("forloop (a) :- %d\n",a); + Drawarc(lcd, a); + lcd.refresh(); + float Brightness = pad.pot_value(); + lcd.setBrightness(Brightness); + printf("potentiometer value :- %f7.6/n",Brightness); + printf("%f7.6/n",_w); + wait(_w); + lcd.setBrightness(0.0); + wait(_w); + } + +} + +void Display::Drawarc(N5110 &lcd, int a) +{ x = 20; y = 0; - + int a1; int b1; - radiusMod = 1-x; - x0 = 42; + radiusMod = 1-x; + printf("RadiusMod :- %d\n",radiusMod); + x0 = 42; y0 = 24; while(x >= y) { - - switch(a) { - case 0 : {a1 = y; - b1 = x * -1; - break; - } - case 1 : {a1 = x; - b1 = y * -1; - break; - } - case 2 : {a1 = x; - b1 = y; - break; - } - case 3 : {a1 = y; - b1 = x; - break; - } - case 4 : {a1 = y * -1; - b1 = x; - break; - } - case 5 : {a1 = x * -1; - b1 = y; - break; - } - case 6 : {a1 = x * -1; - b1 = y * -1; - break; - } - case 7 : {a1 = y * -1; - b1 = x * -1; - break; - } - default : { a1 = x; + + printf("x = %d\n", x); + printf("y = %d\n", y); + + switch(a) { + case 0 : { + a1 = y; + b1 = x * -1; + printf("a1 = %d\n", a1); + printf("b1 = %d\n", b1); + break; + } + case 1 : { + a1 = x; + b1 = y * -1; + printf("a1 = %d\n", a1); + printf("b1 = %d\n", b1); + break; + } + case 2 : { + a1 = x; + b1 = y; + printf("a1 = %d\n", a1); + printf("b1 = %d\n", b1); + break; + } + case 3 : { + a1 = y; + b1 = x; + printf("a1 = %d\n", a1); + printf("b1 = %d\n", b1); + break; + } + case 4 : { + a1 = y * -1; + b1 = x; + printf("a1 = %d\n", a1); + printf("b1 = %d\n", b1); + break; + } + case 5 : { + a1 = x * -1; + b1 = y; + printf("a1 = %d\n", a1); + printf("b1 = %d\n", b1); + break; + } + case 6 : { + a1 = x * -1; b1 = y * -1; + printf("a1 = %d\n", a1); + printf("b1 = %d\n", b1); break; - } + } + case 7 : { + a1 = y * -1; + b1 = x * -1; + printf("a1 = %d\n", a1); + printf("b1 = %d\n", b1); + break; + } + default : { + a1 = x; + b1 = y * -1; + printf("a1 = %d\n", a1); + printf("b1 = %d\n", b1); + break; + } } - - - lcd.setPixel( a1 + x0, b1 + y0); - - y++; - - + + + lcd.setPixel( a1 + x0, b1 + y0); + + y++; + + if (radiusMod<0) { radiusMod += 2*y+1; } else { x--; radiusMod += 2*(y-x)+1; } - + printf("radiusMod 1 = %d\n", radiusMod); } } \ No newline at end of file