This class encapsulates all the algorithms required for the displaying strings and time dependent patterns on the lcd.
Dependents: 200943412_QuickClick
Display.cpp@0:dd78eca4b004, 2017-04-08 (annotated)
- Committer:
- domkay97
- Date:
- Sat Apr 08 15:01:45 2017 +0000
- Revision:
- 0:dd78eca4b004
- Child:
- 1:41a1c20a2056
Basic Class setup for gamecontroller
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
domkay97 | 0:dd78eca4b004 | 1 | #include "Display.h" |
domkay97 | 0:dd78eca4b004 | 2 | #include "N5110.h" |
domkay97 | 0:dd78eca4b004 | 3 | |
domkay97 | 0:dd78eca4b004 | 4 | Display::Display() |
domkay97 | 0:dd78eca4b004 | 5 | { |
domkay97 | 0:dd78eca4b004 | 6 | _h = 0; |
domkay97 | 0:dd78eca4b004 | 7 | _w = 0.1; |
domkay97 | 0:dd78eca4b004 | 8 | _a = 0; |
domkay97 | 0:dd78eca4b004 | 9 | _A = 0; |
domkay97 | 0:dd78eca4b004 | 10 | } |
domkay97 | 0:dd78eca4b004 | 11 | |
domkay97 | 0:dd78eca4b004 | 12 | Display::~Display() |
domkay97 | 0:dd78eca4b004 | 13 | { |
domkay97 | 0:dd78eca4b004 | 14 | |
domkay97 | 0:dd78eca4b004 | 15 | } |
domkay97 | 0:dd78eca4b004 | 16 | void Display::init() |
domkay97 | 0:dd78eca4b004 | 17 | { |
domkay97 | 0:dd78eca4b004 | 18 | |
domkay97 | 0:dd78eca4b004 | 19 | //InterruptIn button_X(SW3); |
domkay97 | 0:dd78eca4b004 | 20 | //olatile int g_timer_flag = 0; |
domkay97 | 0:dd78eca4b004 | 21 | // volatile int X_flag = 0; |
domkay97 | 0:dd78eca4b004 | 22 | // button_X.fall(&X_isr); |
domkay97 | 0:dd78eca4b004 | 23 | // button_X.mode(PullNone); |
domkay97 | 0:dd78eca4b004 | 24 | _h = 0; |
domkay97 | 0:dd78eca4b004 | 25 | _w = 0.1; |
domkay97 | 0:dd78eca4b004 | 26 | _a = 0; |
domkay97 | 0:dd78eca4b004 | 27 | _A = 0; |
domkay97 | 0:dd78eca4b004 | 28 | } |
domkay97 | 0:dd78eca4b004 | 29 | |
domkay97 | 0:dd78eca4b004 | 30 | void Display::drawCircle(N5110 &lcd) |
domkay97 | 0:dd78eca4b004 | 31 | { |
domkay97 | 0:dd78eca4b004 | 32 | while(1) { |
domkay97 | 0:dd78eca4b004 | 33 | for( int _A = 0; _A < 84; _A++ ) { |
domkay97 | 0:dd78eca4b004 | 34 | _a = _A; |
domkay97 | 0:dd78eca4b004 | 35 | |
domkay97 | 0:dd78eca4b004 | 36 | wait(_w); |
domkay97 | 0:dd78eca4b004 | 37 | lcd.refresh(); |
domkay97 | 0:dd78eca4b004 | 38 | lcd.setPixel(_a,22); |
domkay97 | 0:dd78eca4b004 | 39 | lcd.setPixel(_a,23); |
domkay97 | 0:dd78eca4b004 | 40 | lcd.setPixel(_a,24); |
domkay97 | 0:dd78eca4b004 | 41 | lcd.setPixel(_a,25); |
domkay97 | 0:dd78eca4b004 | 42 | lcd.setPixel(_a,26); |
domkay97 | 0:dd78eca4b004 | 43 | } |
domkay97 | 0:dd78eca4b004 | 44 | calculateWait(); |
domkay97 | 0:dd78eca4b004 | 45 | _h++; |
domkay97 | 0:dd78eca4b004 | 46 | lcd.clear(); |
domkay97 | 0:dd78eca4b004 | 47 | } |
domkay97 | 0:dd78eca4b004 | 48 | } |
domkay97 | 0:dd78eca4b004 | 49 | |
domkay97 | 0:dd78eca4b004 | 50 | void Display::calculateWait() |
domkay97 | 0:dd78eca4b004 | 51 | { |
domkay97 | 0:dd78eca4b004 | 52 | if (_h < 10) { |
domkay97 | 0:dd78eca4b004 | 53 | _w = _w - _w/10; } |
domkay97 | 0:dd78eca4b004 | 54 | else if (_h < 20) { |
domkay97 | 0:dd78eca4b004 | 55 | _w = _w - _w/20; } |
domkay97 | 0:dd78eca4b004 | 56 | else if (_h < 30) { |
domkay97 | 0:dd78eca4b004 | 57 | _w = _w - _w/30; } |
domkay97 | 0:dd78eca4b004 | 58 | else |
domkay97 | 0:dd78eca4b004 | 59 | { _w = _w - _w/40; } |
domkay97 | 0:dd78eca4b004 | 60 | } |
domkay97 | 0:dd78eca4b004 | 61 | |
domkay97 | 0:dd78eca4b004 | 62 |