A retro gaming programme, designed for use on a portable embedded system. Incorporates power saving techniques.
Dependencies: ConfigFile N5110 PowerControl beep mbed
main.cpp@3:57bab3b1c974, 2015-04-13 (annotated)
- Committer:
- el13drt
- Date:
- Mon Apr 13 20:59:14 2015 +0000
- Revision:
- 3:57bab3b1c974
- Parent:
- 2:8fac5562ed1e
- Child:
- 4:c6305031f80d
pre EXIT MENU
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
el13drt | 0:a8bc3aac5f69 | 1 | /** |
el13drt | 0:a8bc3aac5f69 | 2 | @file main.cpp |
el13drt | 0:a8bc3aac5f69 | 3 | @brief Program implementation |
el13drt | 0:a8bc3aac5f69 | 4 | */ |
el13drt | 0:a8bc3aac5f69 | 5 | |
el13drt | 0:a8bc3aac5f69 | 6 | #include "mbed.h" |
el13drt | 0:a8bc3aac5f69 | 7 | #include "N5110.h" |
el13drt | 0:a8bc3aac5f69 | 8 | |
el13drt | 0:a8bc3aac5f69 | 9 | #include <ctime> |
el13drt | 0:a8bc3aac5f69 | 10 | #include <cstdlib> |
el13drt | 0:a8bc3aac5f69 | 11 | |
el13drt | 0:a8bc3aac5f69 | 12 | // change this to alter tolerance of joystick direction |
el13drt | 0:a8bc3aac5f69 | 13 | #define DIRECTION_TOLERANCE 0.05 |
el13drt | 0:a8bc3aac5f69 | 14 | |
el13drt | 0:a8bc3aac5f69 | 15 | // VCC,SCE,RST,D/C,MOSI,SCLK,LED - set pins for LCD |
el13drt | 0:a8bc3aac5f69 | 16 | N5110 lcd(p7,p8,p9,p10,p11,p13,p22); |
el13drt | 0:a8bc3aac5f69 | 17 | |
el13drt | 0:a8bc3aac5f69 | 18 | // navigation/action buttons |
el13drt | 0:a8bc3aac5f69 | 19 | DigitalIn buttonA(p19); |
el13drt | 0:a8bc3aac5f69 | 20 | DigitalIn buttonB(p20); |
el13drt | 0:a8bc3aac5f69 | 21 | |
el13drt | 3:57bab3b1c974 | 22 | // LED indicators |
el13drt | 3:57bab3b1c974 | 23 | AnalogOut ledR(p18);// RED LED |
el13drt | 3:57bab3b1c974 | 24 | DigitalOut ledY(p24);// YELLOW LED |
el13drt | 3:57bab3b1c974 | 25 | |
el13drt | 0:a8bc3aac5f69 | 26 | // connections for joystick |
el13drt | 3:57bab3b1c974 | 27 | DigitalIn button(p17); |
el13drt | 0:a8bc3aac5f69 | 28 | AnalogIn xPot(p15); |
el13drt | 0:a8bc3aac5f69 | 29 | AnalogIn yPot(p16); |
el13drt | 0:a8bc3aac5f69 | 30 | |
el13drt | 0:a8bc3aac5f69 | 31 | // boundary conditions |
el13drt | 0:a8bc3aac5f69 | 32 | int cells [84][48]; |
el13drt | 0:a8bc3aac5f69 | 33 | |
el13drt | 0:a8bc3aac5f69 | 34 | // Globabl Variables ///////////////////////// |
el13drt | 0:a8bc3aac5f69 | 35 | |
el13drt | 0:a8bc3aac5f69 | 36 | // global variables for movement |
el13drt | 0:a8bc3aac5f69 | 37 | int a1 = 22; |
el13drt | 0:a8bc3aac5f69 | 38 | int a2 = 24; |
el13drt | 0:a8bc3aac5f69 | 39 | int a3 = 23; |
el13drt | 0:a8bc3aac5f69 | 40 | int a4 = 25; |
el13drt | 0:a8bc3aac5f69 | 41 | int a5 = 20; |
el13drt | 0:a8bc3aac5f69 | 42 | int a6 = 26; |
el13drt | 0:a8bc3aac5f69 | 43 | int a7 = 19; |
el13drt | 0:a8bc3aac5f69 | 44 | int a8 = 21; |
el13drt | 0:a8bc3aac5f69 | 45 | |
el13drt | 0:a8bc3aac5f69 | 46 | //global variable for random X co-ordinates |
el13drt | 0:a8bc3aac5f69 | 47 | int randX1; |
el13drt | 0:a8bc3aac5f69 | 48 | int randX2; |
el13drt | 0:a8bc3aac5f69 | 49 | int randX3; |
el13drt | 0:a8bc3aac5f69 | 50 | int randX4; |
el13drt | 0:a8bc3aac5f69 | 51 | int randX5; |
el13drt | 0:a8bc3aac5f69 | 52 | int randX6; |
el13drt | 0:a8bc3aac5f69 | 53 | |
el13drt | 0:a8bc3aac5f69 | 54 | // global variable for random Y co-ordinates |
el13drt | 0:a8bc3aac5f69 | 55 | int randY1 = 0; |
el13drt | 0:a8bc3aac5f69 | 56 | int randY2 = 0; |
el13drt | 0:a8bc3aac5f69 | 57 | int randY3 = 0; |
el13drt | 0:a8bc3aac5f69 | 58 | int randY4 = 0; |
el13drt | 0:a8bc3aac5f69 | 59 | int randY5 = 0; |
el13drt | 0:a8bc3aac5f69 | 60 | int randY6 = 0; |
el13drt | 0:a8bc3aac5f69 | 61 | |
el13drt | 0:a8bc3aac5f69 | 62 | // timer to regularly read the joystick |
el13drt | 0:a8bc3aac5f69 | 63 | Ticker pollJoystick; |
el13drt | 1:352c50e88ffa | 64 | |
el13drt | 3:57bab3b1c974 | 65 | // serial for debug |
el13drt | 0:a8bc3aac5f69 | 66 | Serial serial(USBTX,USBRX); |
el13drt | 0:a8bc3aac5f69 | 67 | |
el13drt | 0:a8bc3aac5f69 | 68 | // create enumerated type (0,1,2,3 etc. for direction) |
el13drt | 0:a8bc3aac5f69 | 69 | // could be extended for diagonals etc. |
el13drt | 0:a8bc3aac5f69 | 70 | enum DirectionName { |
el13drt | 0:a8bc3aac5f69 | 71 | UP, |
el13drt | 0:a8bc3aac5f69 | 72 | DOWN, |
el13drt | 0:a8bc3aac5f69 | 73 | LEFT, |
el13drt | 0:a8bc3aac5f69 | 74 | RIGHT, |
el13drt | 0:a8bc3aac5f69 | 75 | CENTRE, |
el13drt | 0:a8bc3aac5f69 | 76 | UNKNOWN |
el13drt | 0:a8bc3aac5f69 | 77 | }; |
el13drt | 0:a8bc3aac5f69 | 78 | |
el13drt | 0:a8bc3aac5f69 | 79 | // struct for Joystick |
el13drt | 0:a8bc3aac5f69 | 80 | typedef struct JoyStick Joystick; |
el13drt | 0:a8bc3aac5f69 | 81 | struct JoyStick { |
el13drt | 0:a8bc3aac5f69 | 82 | float x; // current x value |
el13drt | 0:a8bc3aac5f69 | 83 | float x0; // 'centred' x value |
el13drt | 0:a8bc3aac5f69 | 84 | float y; // current y value |
el13drt | 0:a8bc3aac5f69 | 85 | float y0; // 'centred' y value |
el13drt | 0:a8bc3aac5f69 | 86 | int button; // button state (assume pull-down used, so 1 = pressed, 0 = unpressed) |
el13drt | 0:a8bc3aac5f69 | 87 | DirectionName direction; // current direction |
el13drt | 0:a8bc3aac5f69 | 88 | }; |
el13drt | 0:a8bc3aac5f69 | 89 | |
el13drt | 0:a8bc3aac5f69 | 90 | // create struct variable |
el13drt | 0:a8bc3aac5f69 | 91 | Joystick joystick; |
el13drt | 0:a8bc3aac5f69 | 92 | |
el13drt | 0:a8bc3aac5f69 | 93 | int printFlag = 0; |
el13drt | 0:a8bc3aac5f69 | 94 | |
el13drt | 0:a8bc3aac5f69 | 95 | // function prototypes |
el13drt | 0:a8bc3aac5f69 | 96 | void calibrateJoystick(); |
el13drt | 0:a8bc3aac5f69 | 97 | void updateJoystick(); |
el13drt | 0:a8bc3aac5f69 | 98 | |
el13drt | 0:a8bc3aac5f69 | 99 | //intro screen |
el13drt | 0:a8bc3aac5f69 | 100 | void welcome() |
el13drt | 0:a8bc3aac5f69 | 101 | { |
el13drt | 0:a8bc3aac5f69 | 102 | //bottom border |
el13drt | 0:a8bc3aac5f69 | 103 | lcd.drawRect(0,44,84,2,1); |
el13drt | 0:a8bc3aac5f69 | 104 | |
el13drt | 0:a8bc3aac5f69 | 105 | //top border |
el13drt | 0:a8bc3aac5f69 | 106 | lcd.drawRect(0,1,84,2,1); |
el13drt | 0:a8bc3aac5f69 | 107 | |
el13drt | 0:a8bc3aac5f69 | 108 | //print initials 'DRT' |
el13drt | 0:a8bc3aac5f69 | 109 | lcd.printChar('D',30,14); |
el13drt | 0:a8bc3aac5f69 | 110 | wait(0.6); |
el13drt | 0:a8bc3aac5f69 | 111 | lcd.printChar('R',37,14); |
el13drt | 0:a8bc3aac5f69 | 112 | wait(0.6); |
el13drt | 0:a8bc3aac5f69 | 113 | lcd.printChar('T',44,14); |
el13drt | 0:a8bc3aac5f69 | 114 | wait(0.6); |
el13drt | 0:a8bc3aac5f69 | 115 | |
el13drt | 0:a8bc3aac5f69 | 116 | //print 'presents...' |
el13drt | 0:a8bc3aac5f69 | 117 | lcd.printString("presents...",8,21); |
el13drt | 0:a8bc3aac5f69 | 118 | wait(1.0); |
el13drt | 0:a8bc3aac5f69 | 119 | |
el13drt | 0:a8bc3aac5f69 | 120 | //dramatic flashing |
el13drt | 0:a8bc3aac5f69 | 121 | lcd.inverseMode(); |
el13drt | 0:a8bc3aac5f69 | 122 | wait(0.2); |
el13drt | 0:a8bc3aac5f69 | 123 | lcd.normalMode(); |
el13drt | 0:a8bc3aac5f69 | 124 | wait(0.2); |
el13drt | 0:a8bc3aac5f69 | 125 | lcd.inverseMode(); |
el13drt | 0:a8bc3aac5f69 | 126 | wait(0.2); |
el13drt | 0:a8bc3aac5f69 | 127 | lcd.normalMode(); |
el13drt | 0:a8bc3aac5f69 | 128 | wait(1.0); |
el13drt | 0:a8bc3aac5f69 | 129 | |
el13drt | 0:a8bc3aac5f69 | 130 | //more dramatic flashing |
el13drt | 0:a8bc3aac5f69 | 131 | lcd.inverseMode(); |
el13drt | 0:a8bc3aac5f69 | 132 | wait(0.2); |
el13drt | 0:a8bc3aac5f69 | 133 | lcd.normalMode(); |
el13drt | 0:a8bc3aac5f69 | 134 | wait(0.2); |
el13drt | 0:a8bc3aac5f69 | 135 | lcd.inverseMode(); |
el13drt | 0:a8bc3aac5f69 | 136 | wait(0.2); |
el13drt | 0:a8bc3aac5f69 | 137 | lcd.normalMode(); |
el13drt | 0:a8bc3aac5f69 | 138 | wait(0.6); |
el13drt | 0:a8bc3aac5f69 | 139 | } |
el13drt | 0:a8bc3aac5f69 | 140 | |
el13drt | 0:a8bc3aac5f69 | 141 | //selection menu/////////////////////////////////////////// |
el13drt | 0:a8bc3aac5f69 | 142 | void mainMenu() |
el13drt | 0:a8bc3aac5f69 | 143 | { |
el13drt | 0:a8bc3aac5f69 | 144 | //bottom border |
el13drt | 0:a8bc3aac5f69 | 145 | lcd.drawRect(0,47,84,0,1); |
el13drt | 0:a8bc3aac5f69 | 146 | //top border |
el13drt | 0:a8bc3aac5f69 | 147 | lcd.drawRect(0,0,84,2,1); |
el13drt | 0:a8bc3aac5f69 | 148 | |
el13drt | 0:a8bc3aac5f69 | 149 | //print 'Xtreme Tower' |
el13drt | 0:a8bc3aac5f69 | 150 | lcd.printString("Xtreme",4,25); |
el13drt | 0:a8bc3aac5f69 | 151 | lcd.printString("Tower",44,25); |
el13drt | 0:a8bc3aac5f69 | 152 | |
el13drt | 0:a8bc3aac5f69 | 153 | //title outline |
el13drt | 0:a8bc3aac5f69 | 154 | lcd.drawRect(3,6,77,10,0); |
el13drt | 0:a8bc3aac5f69 | 155 | |
el13drt | 0:a8bc3aac5f69 | 156 | ////castle //x, y, w, h, fill////////////////////// |
el13drt | 0:a8bc3aac5f69 | 157 | |
el13drt | 0:a8bc3aac5f69 | 158 | //castle main bulk |
el13drt | 0:a8bc3aac5f69 | 159 | lcd.drawRect(59,32,21,8,1); |
el13drt | 0:a8bc3aac5f69 | 160 | |
el13drt | 0:a8bc3aac5f69 | 161 | //left window bulk |
el13drt | 0:a8bc3aac5f69 | 162 | lcd.drawRect(59,22,2,10,1); |
el13drt | 0:a8bc3aac5f69 | 163 | //centre left window bulk |
el13drt | 0:a8bc3aac5f69 | 164 | lcd.drawRect(65,22,2,10,1); |
el13drt | 0:a8bc3aac5f69 | 165 | //centre right window bulk |
el13drt | 0:a8bc3aac5f69 | 166 | lcd.drawRect(72,22,2,10,1); |
el13drt | 0:a8bc3aac5f69 | 167 | //right window bulk |
el13drt | 0:a8bc3aac5f69 | 168 | lcd.drawRect(78,22,2,10,1); |
el13drt | 0:a8bc3aac5f69 | 169 | //central window bulk |
el13drt | 0:a8bc3aac5f69 | 170 | lcd.drawRect(68,25,3,7,1); |
el13drt | 0:a8bc3aac5f69 | 171 | |
el13drt | 0:a8bc3aac5f69 | 172 | //central window bulk |
el13drt | 0:a8bc3aac5f69 | 173 | lcd.drawRect(75,28,0,0,1); |
el13drt | 0:a8bc3aac5f69 | 174 | lcd.drawRect(77,28,0,0,1); |
el13drt | 0:a8bc3aac5f69 | 175 | lcd.drawRect(64,28,0,0,1); |
el13drt | 0:a8bc3aac5f69 | 176 | lcd.drawRect(62,28,0,0,1); |
el13drt | 0:a8bc3aac5f69 | 177 | |
el13drt | 0:a8bc3aac5f69 | 178 | //above left window bulk |
el13drt | 0:a8bc3aac5f69 | 179 | lcd.drawRect(62,25,3,2,1); |
el13drt | 0:a8bc3aac5f69 | 180 | //above right window bulk |
el13drt | 0:a8bc3aac5f69 | 181 | lcd.drawRect(75,25,2,2,1); |
el13drt | 0:a8bc3aac5f69 | 182 | |
el13drt | 0:a8bc3aac5f69 | 183 | //lower right line |
el13drt | 0:a8bc3aac5f69 | 184 | lcd.drawRect(71,42,9,0,1); |
el13drt | 0:a8bc3aac5f69 | 185 | //upper right line |
el13drt | 0:a8bc3aac5f69 | 186 | lcd.drawRect(70,41,10,0,1); |
el13drt | 0:a8bc3aac5f69 | 187 | |
el13drt | 0:a8bc3aac5f69 | 188 | //upper left line |
el13drt | 0:a8bc3aac5f69 | 189 | lcd.drawRect(59,41,10,0,1); |
el13drt | 0:a8bc3aac5f69 | 190 | //lower left line |
el13drt | 0:a8bc3aac5f69 | 191 | lcd.drawRect(59,42,9,0,1); |
el13drt | 0:a8bc3aac5f69 | 192 | |
el13drt | 0:a8bc3aac5f69 | 193 | //bottom left bulk |
el13drt | 0:a8bc3aac5f69 | 194 | lcd.drawRect(59,43,8,3,1); |
el13drt | 0:a8bc3aac5f69 | 195 | //bottom right bulk |
el13drt | 0:a8bc3aac5f69 | 196 | lcd.drawRect(72,43,8,3,1); |
el13drt | 0:a8bc3aac5f69 | 197 | |
el13drt | 0:a8bc3aac5f69 | 198 | //option arrows - lower |
el13drt | 0:a8bc3aac5f69 | 199 | lcd.drawRect(27,42,4,0,1); |
el13drt | 0:a8bc3aac5f69 | 200 | lcd.drawRect(28,43,2,0,1); |
el13drt | 0:a8bc3aac5f69 | 201 | lcd.drawRect(29,44,0,0,1); |
el13drt | 0:a8bc3aac5f69 | 202 | |
el13drt | 0:a8bc3aac5f69 | 203 | //option arrows - higher |
el13drt | 0:a8bc3aac5f69 | 204 | lcd.drawRect(27,29,4,0,1); |
el13drt | 0:a8bc3aac5f69 | 205 | lcd.drawRect(28,28,2,0,1); |
el13drt | 0:a8bc3aac5f69 | 206 | lcd.drawRect(29,27,0,0,1); |
el13drt | 0:a8bc3aac5f69 | 207 | |
el13drt | 0:a8bc3aac5f69 | 208 | //present options |
el13drt | 0:a8bc3aac5f69 | 209 | lcd.printString("Play Game",3,4); |
el13drt | 0:a8bc3aac5f69 | 210 | |
el13drt | 0:a8bc3aac5f69 | 211 | } |
el13drt | 0:a8bc3aac5f69 | 212 | |
el13drt | 0:a8bc3aac5f69 | 213 | // static background |
el13drt | 0:a8bc3aac5f69 | 214 | void backGround() |
el13drt | 0:a8bc3aac5f69 | 215 | { |
el13drt | 0:a8bc3aac5f69 | 216 | // x, y, w, h, fill - draw ground |
el13drt | 0:a8bc3aac5f69 | 217 | lcd.drawRect(0,47,84,0,1); |
el13drt | 0:a8bc3aac5f69 | 218 | |
el13drt | 0:a8bc3aac5f69 | 219 | // x, y, w, h, fill - draw left wall |
el13drt | 0:a8bc3aac5f69 | 220 | lcd.drawRect(2,0,0,47,1); |
el13drt | 0:a8bc3aac5f69 | 221 | // left wall - brick line 1 |
el13drt | 0:a8bc3aac5f69 | 222 | for(int x=0; x<47; x+=4) |
el13drt | 0:a8bc3aac5f69 | 223 | lcd.drawLine(1,1,1,48,2); |
el13drt | 0:a8bc3aac5f69 | 224 | // left wall - brick line 2 |
el13drt | 0:a8bc3aac5f69 | 225 | for(int x=0; x<47; x+=4) |
el13drt | 0:a8bc3aac5f69 | 226 | lcd.drawLine(0,0,0,48,2); |
el13drt | 0:a8bc3aac5f69 | 227 | |
el13drt | 0:a8bc3aac5f69 | 228 | // x, y, w, h, fill - draw right wall |
el13drt | 0:a8bc3aac5f69 | 229 | lcd.drawRect(81,0,0,47,1); |
el13drt | 0:a8bc3aac5f69 | 230 | // right wall - brick line 1 |
el13drt | 0:a8bc3aac5f69 | 231 | for(int x=0; x<WIDTH; x+=4) |
el13drt | 0:a8bc3aac5f69 | 232 | lcd.drawLine(82,0,82,48,2); |
el13drt | 0:a8bc3aac5f69 | 233 | // right wall - brick line 2 |
el13drt | 0:a8bc3aac5f69 | 234 | for(int x=0; x<WIDTH; x+=4) |
el13drt | 0:a8bc3aac5f69 | 235 | lcd.drawLine(83,1,83,48,2); |
el13drt | 0:a8bc3aac5f69 | 236 | |
el13drt | 0:a8bc3aac5f69 | 237 | lcd.refresh(); |
el13drt | 0:a8bc3aac5f69 | 238 | } |
el13drt | 0:a8bc3aac5f69 | 239 | |
el13drt | 0:a8bc3aac5f69 | 240 | //pixel ninja character |
el13drt | 0:a8bc3aac5f69 | 241 | void pixelNinja() |
el13drt | 0:a8bc3aac5f69 | 242 | { |
el13drt | 0:a8bc3aac5f69 | 243 | //x, y, w, h, fill - left leg |
el13drt | 0:a8bc3aac5f69 | 244 | lcd.drawRect(a1,39,0,7,1); |
el13drt | 0:a8bc3aac5f69 | 245 | //right leg |
el13drt | 0:a8bc3aac5f69 | 246 | lcd.drawRect(a2,39,0,7,1); |
el13drt | 0:a8bc3aac5f69 | 247 | //centre stick |
el13drt | 0:a8bc3aac5f69 | 248 | lcd.drawRect(a3,37,0,7,1); |
el13drt | 0:a8bc3aac5f69 | 249 | //back of the head |
el13drt | 0:a8bc3aac5f69 | 250 | lcd.drawRect(a1,33,0,4,1); |
el13drt | 0:a8bc3aac5f69 | 251 | //top of the head |
el13drt | 0:a8bc3aac5f69 | 252 | lcd.drawRect(a1,33,4,0,1); |
el13drt | 0:a8bc3aac5f69 | 253 | //jaw |
el13drt | 0:a8bc3aac5f69 | 254 | lcd.drawRect(a2,38,2,0,1); |
el13drt | 0:a8bc3aac5f69 | 255 | //right shoulder |
el13drt | 0:a8bc3aac5f69 | 256 | lcd.drawRect(a4,40,1,0,1); |
el13drt | 0:a8bc3aac5f69 | 257 | //left shoulder |
el13drt | 0:a8bc3aac5f69 | 258 | lcd.drawRect(a5,40,1,0,1); |
el13drt | 0:a8bc3aac5f69 | 259 | //left arm |
el13drt | 0:a8bc3aac5f69 | 260 | lcd.drawRect(a5,41,0,1,1); |
el13drt | 0:a8bc3aac5f69 | 261 | //right arm |
el13drt | 0:a8bc3aac5f69 | 262 | lcd.drawRect(a6,41,0,1,1); |
el13drt | 0:a8bc3aac5f69 | 263 | //right eye |
el13drt | 0:a8bc3aac5f69 | 264 | lcd.drawRect(a6,35,0,0,1); |
el13drt | 0:a8bc3aac5f69 | 265 | //mouth piece |
el13drt | 0:a8bc3aac5f69 | 266 | lcd.drawRect(a6,37,0,0,1); |
el13drt | 0:a8bc3aac5f69 | 267 | //left eye |
el13drt | 0:a8bc3aac5f69 | 268 | lcd.drawRect(a2,35,0,0,1); |
el13drt | 0:a8bc3aac5f69 | 269 | //sword handle |
el13drt | 0:a8bc3aac5f69 | 270 | lcd.drawRect(a7,36,0,0,1); |
el13drt | 0:a8bc3aac5f69 | 271 | lcd.drawRect(a5,37,0,0,1); |
el13drt | 0:a8bc3aac5f69 | 272 | lcd.drawRect(a8,38,0,0,1); |
el13drt | 0:a8bc3aac5f69 | 273 | |
el13drt | 0:a8bc3aac5f69 | 274 | } |
el13drt | 0:a8bc3aac5f69 | 275 | |
el13drt | 3:57bab3b1c974 | 276 | // when player gets struck, game ends |
el13drt | 0:a8bc3aac5f69 | 277 | void endGame() |
el13drt | 0:a8bc3aac5f69 | 278 | { |
el13drt | 0:a8bc3aac5f69 | 279 | int n = 0; |
el13drt | 0:a8bc3aac5f69 | 280 | |
el13drt | 3:57bab3b1c974 | 281 | // contact points |
el13drt | 3:57bab3b1c974 | 282 | if(lcd.getPixel((a1+4),32)) |
el13drt | 3:57bab3b1c974 | 283 | n++; |
el13drt | 3:57bab3b1c974 | 284 | if(lcd.getPixel((a1),32)) |
el13drt | 3:57bab3b1c974 | 285 | n++; |
el13drt | 3:57bab3b1c974 | 286 | if(lcd.getPixel((a7),32)) |
el13drt | 0:a8bc3aac5f69 | 287 | n++; |
el13drt | 0:a8bc3aac5f69 | 288 | |
el13drt | 3:57bab3b1c974 | 289 | // play again option |
el13drt | 0:a8bc3aac5f69 | 290 | if ( n !=0) { |
el13drt | 3:57bab3b1c974 | 291 | lcd.printString("Game Over!!",8,25); |
el13drt | 3:57bab3b1c974 | 292 | wait(0.5); |
el13drt | 3:57bab3b1c974 | 293 | lcd.inverseMode(); |
el13drt | 3:57bab3b1c974 | 294 | wait(0.5); |
el13drt | 3:57bab3b1c974 | 295 | lcd.normalMode(); |
el13drt | 3:57bab3b1c974 | 296 | wait(0.5); |
el13drt | 3:57bab3b1c974 | 297 | lcd.inverseMode(); |
el13drt | 3:57bab3b1c974 | 298 | wait(0.5); |
el13drt | 3:57bab3b1c974 | 299 | lcd.normalMode(); |
el13drt | 3:57bab3b1c974 | 300 | wait(0.5); |
el13drt | 3:57bab3b1c974 | 301 | lcd.printString("Play Again?",8,25); |
el13drt | 3:57bab3b1c974 | 302 | lcd.printString("YES",20,2); |
el13drt | 3:57bab3b1c974 | 303 | lcd.printString("NO",51,2); |
el13drt | 3:57bab3b1c974 | 304 | wait(3.0); |
el13drt | 3:57bab3b1c974 | 305 | |
el13drt | 3:57bab3b1c974 | 306 | if(buttonA == 1) { |
el13drt | 3:57bab3b1c974 | 307 | } |
el13drt | 0:a8bc3aac5f69 | 308 | } |
el13drt | 0:a8bc3aac5f69 | 309 | } |
el13drt | 0:a8bc3aac5f69 | 310 | |
el13drt | 0:a8bc3aac5f69 | 311 | // draws falling hazards |
el13drt | 0:a8bc3aac5f69 | 312 | void hazards() |
el13drt | 0:a8bc3aac5f69 | 313 | { |
el13drt | 0:a8bc3aac5f69 | 314 | // X, Y, radius, fill |
el13drt | 0:a8bc3aac5f69 | 315 | lcd.drawCircle(randX1,randY1,2,1); |
el13drt | 0:a8bc3aac5f69 | 316 | lcd.drawCircle(randX2,randY2,2,1); |
el13drt | 0:a8bc3aac5f69 | 317 | lcd.drawCircle(randX3,randY3,2,1); |
el13drt | 0:a8bc3aac5f69 | 318 | lcd.drawCircle(randX4,randY4,2,1); |
el13drt | 0:a8bc3aac5f69 | 319 | lcd.drawCircle(randX5,randY5,2,1); |
el13drt | 0:a8bc3aac5f69 | 320 | lcd.drawCircle(randX6,randY6,2,1); |
el13drt | 0:a8bc3aac5f69 | 321 | |
el13drt | 0:a8bc3aac5f69 | 322 | lcd.refresh(); |
el13drt | 0:a8bc3aac5f69 | 323 | } |
el13drt | 0:a8bc3aac5f69 | 324 | |
el13drt | 0:a8bc3aac5f69 | 325 | // makes hazards fall - randomises X axis co-ordinates |
el13drt | 0:a8bc3aac5f69 | 326 | void hazardFall() |
el13drt | 0:a8bc3aac5f69 | 327 | { |
el13drt | 0:a8bc3aac5f69 | 328 | // increments randY1 variables |
el13drt | 0:a8bc3aac5f69 | 329 | // appearing to make them fall |
el13drt | 0:a8bc3aac5f69 | 330 | randY1 = randY1+=2; |
el13drt | 0:a8bc3aac5f69 | 331 | randY2 = randY2+=2; |
el13drt | 0:a8bc3aac5f69 | 332 | randY3 = randY3+=2; |
el13drt | 0:a8bc3aac5f69 | 333 | randY4 = randY4+=2; |
el13drt | 0:a8bc3aac5f69 | 334 | randY5 = randY5+=2; |
el13drt | 0:a8bc3aac5f69 | 335 | randY6 = randY6+=2; |
el13drt | 0:a8bc3aac5f69 | 336 | |
el13drt | 0:a8bc3aac5f69 | 337 | // loops the objects once they 'hit the floor' |
el13drt | 0:a8bc3aac5f69 | 338 | // this imitates a new set of objects falling |
el13drt | 0:a8bc3aac5f69 | 339 | |
el13drt | 0:a8bc3aac5f69 | 340 | if (randY1>=48) |
el13drt | 0:a8bc3aac5f69 | 341 | randY1=0; |
el13drt | 0:a8bc3aac5f69 | 342 | |
el13drt | 0:a8bc3aac5f69 | 343 | if (randY2>=48) |
el13drt | 0:a8bc3aac5f69 | 344 | randY2=0; |
el13drt | 0:a8bc3aac5f69 | 345 | |
el13drt | 0:a8bc3aac5f69 | 346 | if (randY3>=48) |
el13drt | 0:a8bc3aac5f69 | 347 | randY3=0; |
el13drt | 0:a8bc3aac5f69 | 348 | |
el13drt | 0:a8bc3aac5f69 | 349 | if (randY4>=48) |
el13drt | 0:a8bc3aac5f69 | 350 | randY4=0; |
el13drt | 0:a8bc3aac5f69 | 351 | |
el13drt | 0:a8bc3aac5f69 | 352 | if (randY5>=48) |
el13drt | 0:a8bc3aac5f69 | 353 | randY5=0; |
el13drt | 0:a8bc3aac5f69 | 354 | |
el13drt | 0:a8bc3aac5f69 | 355 | // each time the objects loop, a new pseudo random value |
el13drt | 0:a8bc3aac5f69 | 356 | // is assigned to the global variables (randX) to |
el13drt | 0:a8bc3aac5f69 | 357 | // randomise their positions |
el13drt | 0:a8bc3aac5f69 | 358 | |
el13drt | 0:a8bc3aac5f69 | 359 | if (randY6>=48) { |
el13drt | 0:a8bc3aac5f69 | 360 | randY6=0; |
el13drt | 0:a8bc3aac5f69 | 361 | |
el13drt | 0:a8bc3aac5f69 | 362 | randX1 = rand() % 74 + 5;// psuedo random number |
el13drt | 0:a8bc3aac5f69 | 363 | randX2 = rand() % 74 + 5;// between 5 and 74 |
el13drt | 0:a8bc3aac5f69 | 364 | randX3 = rand() % 74 + 5; |
el13drt | 0:a8bc3aac5f69 | 365 | randX4 = rand() % 74 + 5; |
el13drt | 0:a8bc3aac5f69 | 366 | randX5 = rand() % 74 + 5; |
el13drt | 0:a8bc3aac5f69 | 367 | randX6 = rand() % 74 + 5; |
el13drt | 0:a8bc3aac5f69 | 368 | } |
el13drt | 0:a8bc3aac5f69 | 369 | } |
el13drt | 0:a8bc3aac5f69 | 370 | |
el13drt | 0:a8bc3aac5f69 | 371 | // clears old pixels and keeps set pixels |
el13drt | 0:a8bc3aac5f69 | 372 | void startrek() |
el13drt | 0:a8bc3aac5f69 | 373 | { |
el13drt | 0:a8bc3aac5f69 | 374 | for (int i=3; i<81; i++)// loops through rows |
el13drt | 0:a8bc3aac5f69 | 375 | for (int j=0; j<47; j++) |
el13drt | 0:a8bc3aac5f69 | 376 | if (cells[i][j]) {// if there's a pixel then keep it |
el13drt | 0:a8bc3aac5f69 | 377 | lcd.setPixel(i,j); |
el13drt | 0:a8bc3aac5f69 | 378 | } else { |
el13drt | 0:a8bc3aac5f69 | 379 | lcd.clearPixel(i,j);// else remove the old ones |
el13drt | 0:a8bc3aac5f69 | 380 | } |
el13drt | 0:a8bc3aac5f69 | 381 | lcd.refresh(); |
el13drt | 0:a8bc3aac5f69 | 382 | } |
el13drt | 0:a8bc3aac5f69 | 383 | |
el13drt | 3:57bab3b1c974 | 384 | // sound / light when buttonA is closed |
el13drt | 3:57bab3b1c974 | 385 | void actionButton() |
el13drt | 3:57bab3b1c974 | 386 | { |
el13drt | 3:57bab3b1c974 | 387 | buttonA.mode(PullDown); |
el13drt | 3:57bab3b1c974 | 388 | if (buttonA == 1) { |
el13drt | 3:57bab3b1c974 | 389 | ledY = 1; |
el13drt | 3:57bab3b1c974 | 390 | } else { |
el13drt | 3:57bab3b1c974 | 391 | ledY = 0; |
el13drt | 3:57bab3b1c974 | 392 | } |
el13drt | 3:57bab3b1c974 | 393 | } |
el13drt | 3:57bab3b1c974 | 394 | |
el13drt | 3:57bab3b1c974 | 395 | // sound / light when buttonB is closed |
el13drt | 3:57bab3b1c974 | 396 | void backButton() |
el13drt | 3:57bab3b1c974 | 397 | { |
el13drt | 3:57bab3b1c974 | 398 | buttonB.mode(PullDown); |
el13drt | 3:57bab3b1c974 | 399 | if (buttonA == 1) { |
el13drt | 3:57bab3b1c974 | 400 | ledY = 1; |
el13drt | 3:57bab3b1c974 | 401 | } else { |
el13drt | 3:57bab3b1c974 | 402 | ledY = 0; |
el13drt | 3:57bab3b1c974 | 403 | } |
el13drt | 3:57bab3b1c974 | 404 | } |
el13drt | 3:57bab3b1c974 | 405 | |
el13drt | 3:57bab3b1c974 | 406 | // MAIN ///////////////////////////////////////////////// |
el13drt | 3:57bab3b1c974 | 407 | |
el13drt | 0:a8bc3aac5f69 | 408 | int main() |
el13drt | 0:a8bc3aac5f69 | 409 | { |
el13drt | 0:a8bc3aac5f69 | 410 | //////// set initial values - configurate joystick ///////////////////////////////// |
el13drt | 1:352c50e88ffa | 411 | |
el13drt | 3:57bab3b1c974 | 412 | // Power indicator - RED LED |
el13drt | 3:57bab3b1c974 | 413 | ledR = 1; |
el13drt | 3:57bab3b1c974 | 414 | |
el13drt | 3:57bab3b1c974 | 415 | // initialize time seed for psuedo randomaisation |
el13drt | 0:a8bc3aac5f69 | 416 | srand (time(NULL)); |
el13drt | 0:a8bc3aac5f69 | 417 | |
el13drt | 0:a8bc3aac5f69 | 418 | // generate random x co-ordinates for falling hazards |
el13drt | 0:a8bc3aac5f69 | 419 | // (initial values only) |
el13drt | 0:a8bc3aac5f69 | 420 | // value between 3 and 76 |
el13drt | 0:a8bc3aac5f69 | 421 | randX1 = rand() % 74 + 5; |
el13drt | 0:a8bc3aac5f69 | 422 | randX2 = rand() % 74 + 5; |
el13drt | 0:a8bc3aac5f69 | 423 | randX3 = rand() % 74 + 5; |
el13drt | 0:a8bc3aac5f69 | 424 | randX4 = rand() % 74 + 5; |
el13drt | 0:a8bc3aac5f69 | 425 | randX5 = rand() % 74 + 5; |
el13drt | 0:a8bc3aac5f69 | 426 | randX6 = rand() % 74 + 5; |
el13drt | 0:a8bc3aac5f69 | 427 | |
el13drt | 0:a8bc3aac5f69 | 428 | calibrateJoystick(); // get centred values of joystick |
el13drt | 0:a8bc3aac5f69 | 429 | pollJoystick.attach(&updateJoystick,1.0/10.0); // read joystick 10 times per second |
el13drt | 0:a8bc3aac5f69 | 430 | |
el13drt | 1:352c50e88ffa | 431 | /////// initiate main menu ////////////////////////////////////////////////////////////// |
el13drt | 1:352c50e88ffa | 432 | |
el13drt | 0:a8bc3aac5f69 | 433 | lcd.init();//initialise screen |
el13drt | 0:a8bc3aac5f69 | 434 | welcome();//welcome screen |
el13drt | 0:a8bc3aac5f69 | 435 | lcd.clear();//clear pixels |
el13drt | 0:a8bc3aac5f69 | 436 | mainMenu();//menu screen |
el13drt | 0:a8bc3aac5f69 | 437 | |
el13drt | 1:352c50e88ffa | 438 | /////// Menu Selection Loop //////////////////////////////////////////////////////////// |
el13drt | 1:352c50e88ffa | 439 | |
el13drt | 3:57bab3b1c974 | 440 | // options counter |
el13drt | 1:352c50e88ffa | 441 | int option = 0; |
el13drt | 3:57bab3b1c974 | 442 | |
el13drt | 3:57bab3b1c974 | 443 | // loop 1 - menu |
el13drt | 1:352c50e88ffa | 444 | while(1) { |
el13drt | 1:352c50e88ffa | 445 | |
el13drt | 3:57bab3b1c974 | 446 | // joystick selection |
el13drt | 3:57bab3b1c974 | 447 | if (printFlag) { //if flag set, clear flag and print joystick values to serial port |
el13drt | 1:352c50e88ffa | 448 | printFlag = 0; |
el13drt | 1:352c50e88ffa | 449 | serial.printf("x = %f y = %f button = %d ",joystick.x,joystick.y,joystick.button); |
el13drt | 0:a8bc3aac5f69 | 450 | |
el13drt | 3:57bab3b1c974 | 451 | // option up |
el13drt | 2:8fac5562ed1e | 452 | if (joystick.direction == UP) { |
el13drt | 1:352c50e88ffa | 453 | serial.printf(" UP\n"); |
el13drt | 2:8fac5562ed1e | 454 | option = option--; |
el13drt | 3:57bab3b1c974 | 455 | if (option < 0)option = 0; |
el13drt | 2:8fac5562ed1e | 456 | } |
el13drt | 3:57bab3b1c974 | 457 | // option down |
el13drt | 2:8fac5562ed1e | 458 | if (joystick.direction == DOWN) { |
el13drt | 2:8fac5562ed1e | 459 | serial.printf(" DOWN\n"); |
el13drt | 1:352c50e88ffa | 460 | option = option++; |
el13drt | 3:57bab3b1c974 | 461 | if (option > 1)option = 1; |
el13drt | 1:352c50e88ffa | 462 | } |
el13drt | 2:8fac5562ed1e | 463 | // Centre / Unknown orientation |
el13drt | 2:8fac5562ed1e | 464 | if (joystick.direction == CENTRE) |
el13drt | 2:8fac5562ed1e | 465 | serial.printf(" CENTRE\n"); |
el13drt | 2:8fac5562ed1e | 466 | if (joystick.direction == UNKNOWN) |
el13drt | 2:8fac5562ed1e | 467 | serial.printf(" Unsupported direction\n"); |
el13drt | 3:57bab3b1c974 | 468 | |
el13drt | 3:57bab3b1c974 | 469 | // 'Play Game' option 1 |
el13drt | 1:352c50e88ffa | 470 | if (option == 0) { |
el13drt | 1:352c50e88ffa | 471 | lcd.printString("Play Game",3,4); |
el13drt | 1:352c50e88ffa | 472 | } |
el13drt | 3:57bab3b1c974 | 473 | // 'Options' option 2 |
el13drt | 1:352c50e88ffa | 474 | if (option == 1) { |
el13drt | 1:352c50e88ffa | 475 | lcd.printString(" Options ",3,4); |
el13drt | 1:352c50e88ffa | 476 | } |
el13drt | 3:57bab3b1c974 | 477 | } |
el13drt | 3:57bab3b1c974 | 478 | //////////// Game Loop ///////////////////////////////////////////////////////////// |
el13drt | 3:57bab3b1c974 | 479 | |
el13drt | 3:57bab3b1c974 | 480 | // 'Play Game' selected |
el13drt | 3:57bab3b1c974 | 481 | if ((option == 0)&&(buttonA == 1)) { |
el13drt | 3:57bab3b1c974 | 482 | |
el13drt | 3:57bab3b1c974 | 483 | backGround(); |
el13drt | 3:57bab3b1c974 | 484 | |
el13drt | 3:57bab3b1c974 | 485 | // loop 2 - Exit menu |
el13drt | 3:57bab3b1c974 | 486 | while(1) { |
el13drt | 3:57bab3b1c974 | 487 | |
el13drt | 3:57bab3b1c974 | 488 | // loop 3 - Game loop |
el13drt | 3:57bab3b1c974 | 489 | while(buttonB != 1) { |
el13drt | 3:57bab3b1c974 | 490 | |
el13drt | 3:57bab3b1c974 | 491 | pixelNinja();//set character |
el13drt | 3:57bab3b1c974 | 492 | hazards();//initiates hazards |
el13drt | 3:57bab3b1c974 | 493 | hazardFall();//increments hazards towards floor |
el13drt | 3:57bab3b1c974 | 494 | |
el13drt | 3:57bab3b1c974 | 495 | if (printFlag) { //if flag set, clear flag and print joystick values to serial port |
el13drt | 3:57bab3b1c974 | 496 | printFlag = 0; |
el13drt | 3:57bab3b1c974 | 497 | serial.printf("x = %f y = %f button = %d ",joystick.x,joystick.y,joystick.button); |
el13drt | 3:57bab3b1c974 | 498 | |
el13drt | 3:57bab3b1c974 | 499 | // check joystick direction |
el13drt | 3:57bab3b1c974 | 500 | if (joystick.direction == LEFT) { |
el13drt | 3:57bab3b1c974 | 501 | serial.printf(" LEFT\n"); |
el13drt | 3:57bab3b1c974 | 502 | a1 = a1-=2; |
el13drt | 3:57bab3b1c974 | 503 | a2 = a2-=2; |
el13drt | 3:57bab3b1c974 | 504 | a3 = a3-=2; |
el13drt | 3:57bab3b1c974 | 505 | a4 = a4-=2; |
el13drt | 3:57bab3b1c974 | 506 | a5 = a5-=2; |
el13drt | 3:57bab3b1c974 | 507 | a6 = a6-=2; |
el13drt | 3:57bab3b1c974 | 508 | a7 = a7-=2; |
el13drt | 3:57bab3b1c974 | 509 | a8 = a8-=2; |
el13drt | 3:57bab3b1c974 | 510 | } |
el13drt | 3:57bab3b1c974 | 511 | if (joystick.direction == RIGHT) { |
el13drt | 3:57bab3b1c974 | 512 | serial.printf(" RIGHT\n"); |
el13drt | 3:57bab3b1c974 | 513 | a1 = a1+=2; |
el13drt | 3:57bab3b1c974 | 514 | a2 = a2+=2; |
el13drt | 3:57bab3b1c974 | 515 | a3 = a3+=2; |
el13drt | 3:57bab3b1c974 | 516 | a4 = a4+=2; |
el13drt | 3:57bab3b1c974 | 517 | a5 = a5+=2; |
el13drt | 3:57bab3b1c974 | 518 | a6 = a6+=2; |
el13drt | 3:57bab3b1c974 | 519 | a7 = a7+=2; |
el13drt | 3:57bab3b1c974 | 520 | a8 = a8+=2; |
el13drt | 3:57bab3b1c974 | 521 | } |
el13drt | 3:57bab3b1c974 | 522 | if (joystick.direction == CENTRE) |
el13drt | 3:57bab3b1c974 | 523 | serial.printf(" CENTRE\n"); |
el13drt | 3:57bab3b1c974 | 524 | if (joystick.direction == UNKNOWN) |
el13drt | 3:57bab3b1c974 | 525 | serial.printf(" Unsupported direction\n"); |
el13drt | 3:57bab3b1c974 | 526 | |
el13drt | 3:57bab3b1c974 | 527 | //endGame(); |
el13drt | 3:57bab3b1c974 | 528 | startrek();//clears unset pixels, keeps set pixels |
el13drt | 3:57bab3b1c974 | 529 | |
el13drt | 3:57bab3b1c974 | 530 | } |
el13drt | 2:8fac5562ed1e | 531 | |
el13drt | 3:57bab3b1c974 | 532 | |
el13drt | 3:57bab3b1c974 | 533 | // break code e.g. person dies / exits game |
el13drt | 3:57bab3b1c974 | 534 | if (buttonB == 1) { |
el13drt | 3:57bab3b1c974 | 535 | |
el13drt | 3:57bab3b1c974 | 536 | lcd.printString("Exit Game?",9,25); |
el13drt | 3:57bab3b1c974 | 537 | if(buttonA == 1) |
el13drt | 3:57bab3b1c974 | 538 | break; |
el13drt | 3:57bab3b1c974 | 539 | } |
el13drt | 3:57bab3b1c974 | 540 | } |
el13drt | 3:57bab3b1c974 | 541 | } |
el13drt | 1:352c50e88ffa | 542 | } |
el13drt | 0:a8bc3aac5f69 | 543 | } |
el13drt | 3:57bab3b1c974 | 544 | } |
el13drt | 1:352c50e88ffa | 545 | |
el13drt | 0:a8bc3aac5f69 | 546 | |
el13drt | 0:a8bc3aac5f69 | 547 | // read default positions of the joystick to calibrate later readings |
el13drt | 0:a8bc3aac5f69 | 548 | void calibrateJoystick() |
el13drt | 0:a8bc3aac5f69 | 549 | { |
el13drt | 0:a8bc3aac5f69 | 550 | button.mode(PullDown); |
el13drt | 0:a8bc3aac5f69 | 551 | // must not move during calibration |
el13drt | 3:57bab3b1c974 | 552 | joystick.x0 = xPot; //initial positions in the range 0.0 to 1.0 (0.5 if centred exactly) |
el13drt | 0:a8bc3aac5f69 | 553 | joystick.y0 = yPot; |
el13drt | 0:a8bc3aac5f69 | 554 | } |
el13drt | 0:a8bc3aac5f69 | 555 | |
el13drt | 0:a8bc3aac5f69 | 556 | void updateJoystick() |
el13drt | 0:a8bc3aac5f69 | 557 | { |
el13drt | 0:a8bc3aac5f69 | 558 | // read current joystick values relative to calibrated values (in range -0.5 to 0.5, 0.0 is centred) |
el13drt | 0:a8bc3aac5f69 | 559 | joystick.x = xPot - joystick.x0; |
el13drt | 0:a8bc3aac5f69 | 560 | joystick.y = yPot - joystick.y0; |
el13drt | 0:a8bc3aac5f69 | 561 | // read button state |
el13drt | 0:a8bc3aac5f69 | 562 | joystick.button = button; |
el13drt | 0:a8bc3aac5f69 | 563 | |
el13drt | 0:a8bc3aac5f69 | 564 | // calculate direction depending on x,y values |
el13drt | 0:a8bc3aac5f69 | 565 | // tolerance allows a little lee-way in case joystick not exactly in the stated direction |
el13drt | 0:a8bc3aac5f69 | 566 | if ( fabs(joystick.y) < DIRECTION_TOLERANCE && fabs(joystick.x) < DIRECTION_TOLERANCE) { |
el13drt | 0:a8bc3aac5f69 | 567 | joystick.direction = CENTRE; |
el13drt | 0:a8bc3aac5f69 | 568 | } else if ( joystick.y > DIRECTION_TOLERANCE && fabs(joystick.x) < DIRECTION_TOLERANCE) { |
el13drt | 0:a8bc3aac5f69 | 569 | joystick.direction = UP; |
el13drt | 0:a8bc3aac5f69 | 570 | } else if ( joystick.y < DIRECTION_TOLERANCE && fabs(joystick.x) < DIRECTION_TOLERANCE) { |
el13drt | 0:a8bc3aac5f69 | 571 | joystick.direction = DOWN; |
el13drt | 0:a8bc3aac5f69 | 572 | } else if ( joystick.x > DIRECTION_TOLERANCE && fabs(joystick.y) < DIRECTION_TOLERANCE) { |
el13drt | 0:a8bc3aac5f69 | 573 | joystick.direction = RIGHT; |
el13drt | 0:a8bc3aac5f69 | 574 | } else if ( joystick.x < DIRECTION_TOLERANCE && fabs(joystick.y) < DIRECTION_TOLERANCE) { |
el13drt | 0:a8bc3aac5f69 | 575 | joystick.direction = LEFT; |
el13drt | 0:a8bc3aac5f69 | 576 | } else { |
el13drt | 0:a8bc3aac5f69 | 577 | joystick.direction = UNKNOWN; |
el13drt | 0:a8bc3aac5f69 | 578 | } |
el13drt | 0:a8bc3aac5f69 | 579 | |
el13drt | 0:a8bc3aac5f69 | 580 | // set flag for printing |
el13drt | 0:a8bc3aac5f69 | 581 | printFlag = 1; |
el13drt | 0:a8bc3aac5f69 | 582 | } |
el13drt | 0:a8bc3aac5f69 | 583 | |
el13drt | 0:a8bc3aac5f69 | 584 |