This class encapsulates all the algorithms required for the displaying strings and time dependent patterns on the lcd.
Dependents: 200943412_QuickClick
Revision 2:f0ecd70c9ea2, committed 2017-04-11
- Comitter:
- domkay97
- Date:
- Tue Apr 11 22:42:33 2017 +0000
- Parent:
- 1:41a1c20a2056
- Child:
- 3:c61282372cf9
- Commit message:
- Working Circle
Changed in this revision
Display.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 41a1c20a2056 -r f0ecd70c9ea2 Display.cpp --- a/Display.cpp Mon Apr 10 20:10:26 2017 +0000 +++ b/Display.cpp Tue Apr 11 22:42:33 2017 +0000 @@ -6,7 +6,7 @@ Display::Display() { _h = 0; - _w = 0.1; + _w = 0.4; _a = 0; _A = 0; _v = 0; @@ -23,13 +23,8 @@ void Display::init() { - //InterruptIn button_X(SW3); - //olatile int g_timer_flag = 0; - // volatile int X_flag = 0; - // button_X.fall(&X_isr); - // button_X.mode(PullNone); _h = 0; - _w = 0.1; + _w = 0.4; _a = 0; _A = 0; _v = 0; @@ -41,47 +36,30 @@ void Display::drawCircle(N5110 &lcd) { - Circle(lcd); + lcd.clear(); random_instruction(lcd); - for( int _A = 0; _A < 84; _A++ ) { - _a = _A; - - wait(_w); - lcd.refresh(); - lcd.setPixel(_a,22); - lcd.setPixel(_a,23); - lcd.setPixel(_a,24); - lcd.setPixel(_a,25); - lcd.setPixel(_a,26); - } - calculateWait(); - _h++; - lcd.clear(); + Circle(lcd); + calculateWait(); + _h++; + lcd.clear(); + lcd.refresh(); } void Display::calculateWait() { - _w = 0.05*exp(-0.03465*_h); + _w = 0.4*exp(-0.03465*_h); } - // if (_h < 10) { - // _w = _w - _w/10; } - //else if (_h < 20) { - // _w = _w - _w/20; } - //else if (_h < 30) { - // _w = _w - _w/30; } - //else - // { _w = _w - _w/40; } -//} + void Display::random_instruction(N5110 &lcd) { _v = rand() % 4 + 1; if (_v == 1){ - lcd.printChar('A',45,2); } + lcd.printChar('A',42,3); } else if (_v == 2){ - lcd.printChar('X',45,2); } + lcd.printChar('X',42,3); } else if (_v == 3){ - lcd.printChar('Y',45,2); } + lcd.printChar('Y',42,3); } else { - lcd.printChar('B',45,2); } + lcd.printChar('B',42,3); } lcd.refresh(); } @@ -95,11 +73,12 @@ for (int a = 0; a < 8; ++a) { Drawarc(lcd, a); - lcd.refresh(); - - - wait(1); } + lcd.setBrightness(1.0); + wait(_w); + lcd.setBrightness(0.0); + wait(_w); + } }