Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of blip_dado by
main.cpp@7:5b8708227c46, 2015-12-02 (annotated)
- Committer:
- pighixxx
- Date:
- Wed Dec 02 13:47:34 2015 +0000
- Revision:
- 7:5b8708227c46
- Parent:
- 6:cacc8514502c
- Child:
- 8:ab4a9bc09839
v0.2
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| pighixxx | 7:5b8708227c46 | 1 | // miniblip sketch demo |
| pighixxx | 3:2d84c8262139 | 2 | |
| JacobBramley | 0:60499ad28ea9 | 3 | #include "mbed.h" |
| JacobBramley | 1:ca76237d2965 | 4 | #include "neopixel.h" |
| JacobBramley | 0:60499ad28ea9 | 5 | |
| pighixxx | 3:2d84c8262139 | 6 | // Matrix led output pin |
| pighixxx | 3:2d84c8262139 | 7 | #define DATA_PIN P0_9 |
| pighixxx | 7:5b8708227c46 | 8 | #define TOUCH_N 2 |
| pighixxx | 4:55d1628dd2e5 | 9 | #define ANALOG_PHOTO P0_16 |
| pighixxx | 4:55d1628dd2e5 | 10 | #define ANALOG_POTENTIOMETER P0_22 |
| pighixxx | 4:55d1628dd2e5 | 11 | #define ANALOG_BUZZER P0_8 |
| pighixxx | 4:55d1628dd2e5 | 12 | #define DIGITAL_CIRCLE P0_12 |
| pighixxx | 7:5b8708227c46 | 13 | #define THRESHOLD 2 |
| pighixxx | 7:5b8708227c46 | 14 | |
| pighixxx | 7:5b8708227c46 | 15 | PinName touch_pin[] = {P0_14, P0_12}; |
| pighixxx | 7:5b8708227c46 | 16 | DigitalInOut *p_touch_io[TOUCH_N]; |
| pighixxx | 4:55d1628dd2e5 | 17 | |
| pighixxx | 4:55d1628dd2e5 | 18 | AnalogIn ain(ANALOG_POTENTIOMETER); |
| pighixxx | 7:5b8708227c46 | 19 | Ticker tick; |
| pighixxx | 4:55d1628dd2e5 | 20 | |
| pighixxx | 4:55d1628dd2e5 | 21 | void fill_pixel(neopixel::Pixel buffer[25], int x, int y, int red, int green, int blue){ |
| pighixxx | 4:55d1628dd2e5 | 22 | |
| pighixxx | 4:55d1628dd2e5 | 23 | if(x<0) x=0; |
| pighixxx | 4:55d1628dd2e5 | 24 | if(x>4) x=4; |
| pighixxx | 4:55d1628dd2e5 | 25 | if(y<0) y=0; |
| pighixxx | 4:55d1628dd2e5 | 26 | if(y>4) y=4; |
| pighixxx | 4:55d1628dd2e5 | 27 | |
| pighixxx | 4:55d1628dd2e5 | 28 | |
| pighixxx | 4:55d1628dd2e5 | 29 | int posicion=x+y*5; |
| pighixxx | 4:55d1628dd2e5 | 30 | buffer[posicion].red=red; |
| pighixxx | 4:55d1628dd2e5 | 31 | buffer[posicion].green=green; |
| pighixxx | 4:55d1628dd2e5 | 32 | buffer[posicion].blue=blue; |
| pighixxx | 4:55d1628dd2e5 | 33 | } |
| pighixxx | 4:55d1628dd2e5 | 34 | |
| pighixxx | 4:55d1628dd2e5 | 35 | void void_matrix(neopixel::Pixel aux[25], int tam=25){ |
| pighixxx | 4:55d1628dd2e5 | 36 | |
| pighixxx | 4:55d1628dd2e5 | 37 | for(int i=0;i<tam;i++){ |
| pighixxx | 4:55d1628dd2e5 | 38 | aux[i].red=0; |
| pighixxx | 4:55d1628dd2e5 | 39 | aux[i].green=0; |
| pighixxx | 4:55d1628dd2e5 | 40 | aux[i].blue=0; |
| pighixxx | 4:55d1628dd2e5 | 41 | } |
| JacobBramley | 0:60499ad28ea9 | 42 | } |
| JacobBramley | 0:60499ad28ea9 | 43 | |
| pighixxx | 5:03859160e3a9 | 44 | int pant[5][5] = { |
| pighixxx | 5:03859160e3a9 | 45 | {0,0,0,0,0}, |
| pighixxx | 5:03859160e3a9 | 46 | {0,0,0,0,0}, |
| pighixxx | 4:55d1628dd2e5 | 47 | {0,0,0,0,0}, |
| pighixxx | 4:55d1628dd2e5 | 48 | {0,0,0,0,0}, |
| pighixxx | 5:03859160e3a9 | 49 | {0,0,0,0,0} |
| pighixxx | 5:03859160e3a9 | 50 | }; |
| pighixxx | 5:03859160e3a9 | 51 | |
| pighixxx | 5:03859160e3a9 | 52 | int pantR[5][5] = { |
| pighixxx | 5:03859160e3a9 | 53 | {0,0,0,0,0}, |
| pighixxx | 6:cacc8514502c | 54 | {0,0,0,0,0}, |
| pighixxx | 5:03859160e3a9 | 55 | {0,0,0,0,0}, |
| pighixxx | 4:55d1628dd2e5 | 56 | {0,0,0,0,0}, |
| pighixxx | 4:55d1628dd2e5 | 57 | {0,0,0,0,0} |
| pighixxx | 4:55d1628dd2e5 | 58 | }; |
| pighixxx | 4:55d1628dd2e5 | 59 | |
| pighixxx | 5:03859160e3a9 | 60 | int pantG[5][5] = { |
| pighixxx | 5:03859160e3a9 | 61 | {0,0,0,0,0}, |
| pighixxx | 4:55d1628dd2e5 | 62 | {0,0,0,0,0}, |
| pighixxx | 4:55d1628dd2e5 | 63 | {0,0,0,0,0}, |
| pighixxx | 4:55d1628dd2e5 | 64 | {0,0,0,0,0}, |
| pighixxx | 5:03859160e3a9 | 65 | {0,0,0,0,0} |
| pighixxx | 4:55d1628dd2e5 | 66 | }; |
| pighixxx | 4:55d1628dd2e5 | 67 | |
| pighixxx | 5:03859160e3a9 | 68 | int pantB[5][5] = { |
| pighixxx | 4:55d1628dd2e5 | 69 | {0,0,0,0,0}, |
| pighixxx | 4:55d1628dd2e5 | 70 | {0,0,0,0,0}, |
| pighixxx | 4:55d1628dd2e5 | 71 | {0,0,0,0,0}, |
| pighixxx | 5:03859160e3a9 | 72 | {0,0,0,0,0}, |
| pighixxx | 5:03859160e3a9 | 73 | {0,0,0,0,0} |
| pighixxx | 4:55d1628dd2e5 | 74 | }; |
| pighixxx | 5:03859160e3a9 | 75 | |
| pighixxx | 7:5b8708227c46 | 76 | int palR[15] = { 5,10,15, 0,30,30, 0, 0, 0, 5,10,30,10,10,10}; |
| pighixxx | 7:5b8708227c46 | 77 | int palG[15] = { 0,10, 0,30,30, 5,10,15,20,20, 0,30, 0, 0, 0}; |
| pighixxx | 7:5b8708227c46 | 78 | int palB[15] = { 0, 0,10, 0, 0, 0, 0,15,20,10,10,30,20,10,30}; |
| pighixxx | 7:5b8708227c46 | 79 | int actualR=30; |
| pighixxx | 7:5b8708227c46 | 80 | int actualG=0; |
| pighixxx | 7:5b8708227c46 | 81 | int actualB=0; |
| pighixxx | 5:03859160e3a9 | 82 | |
| pighixxx | 7:5b8708227c46 | 83 | uint16_t touch_data[TOUCH_N] = {0, }; |
| pighixxx | 7:5b8708227c46 | 84 | int modo=10; |
| pighixxx | 7:5b8708227c46 | 85 | |
| pighixxx | 7:5b8708227c46 | 86 | // Pushbutton |
| pighixxx | 7:5b8708227c46 | 87 | DigitalIn pushbutton(P0_23); |
| pighixxx | 7:5b8708227c46 | 88 | |
| pighixxx | 7:5b8708227c46 | 89 | void detect(void) |
| pighixxx | 7:5b8708227c46 | 90 | { |
| pighixxx | 7:5b8708227c46 | 91 | for (int i = 0; i < TOUCH_N; i++) { |
| pighixxx | 7:5b8708227c46 | 92 | uint8_t count = 0; |
| pighixxx | 7:5b8708227c46 | 93 | DigitalInOut *touch_io = p_touch_io[i]; |
| pighixxx | 7:5b8708227c46 | 94 | |
| pighixxx | 7:5b8708227c46 | 95 | touch_io->input(); |
| pighixxx | 7:5b8708227c46 | 96 | touch_data[i] <<= 1; |
| pighixxx | 7:5b8708227c46 | 97 | while (touch_io->read()) { |
| pighixxx | 7:5b8708227c46 | 98 | count++; |
| pighixxx | 7:5b8708227c46 | 99 | if (count > THRESHOLD) { |
| pighixxx | 7:5b8708227c46 | 100 | touch_data[i] |= 0x01; |
| pighixxx | 7:5b8708227c46 | 101 | break; |
| pighixxx | 7:5b8708227c46 | 102 | } |
| pighixxx | 7:5b8708227c46 | 103 | } |
| pighixxx | 7:5b8708227c46 | 104 | touch_io->output(); |
| pighixxx | 7:5b8708227c46 | 105 | touch_io->write(1); |
| pighixxx | 7:5b8708227c46 | 106 | |
| pighixxx | 7:5b8708227c46 | 107 | if (0x01 == touch_data[i]) { // Threshold, get a touch |
| pighixxx | 7:5b8708227c46 | 108 | if(i==1){ |
| pighixxx | 7:5b8708227c46 | 109 | modo=0; |
| pighixxx | 7:5b8708227c46 | 110 | } |
| pighixxx | 7:5b8708227c46 | 111 | else if(i==0){ |
| pighixxx | 7:5b8708227c46 | 112 | modo=1; |
| pighixxx | 7:5b8708227c46 | 113 | } |
| pighixxx | 7:5b8708227c46 | 114 | } else if (0x80 == touch_data[i]) { // Last 7 measurement is under the threshold, touch is released |
| pighixxx | 7:5b8708227c46 | 115 | } |
| pighixxx | 7:5b8708227c46 | 116 | } |
| pighixxx | 7:5b8708227c46 | 117 | } |
| pighixxx | 4:55d1628dd2e5 | 118 | |
| pighixxx | 4:55d1628dd2e5 | 119 | void drawVector(int theArray[5][5], neopixel::Pixel * vectorPixel, int r, int g, int b){ |
| pighixxx | 4:55d1628dd2e5 | 120 | for(int i = 0;i<5;i++){ |
| pighixxx | 4:55d1628dd2e5 | 121 | for(int j = 0; j<5;j++){ |
| pighixxx | 4:55d1628dd2e5 | 122 | if(theArray[i][j] == 1) |
| pighixxx | 4:55d1628dd2e5 | 123 | fill_pixel(vectorPixel,i,j,r,g,b); |
| pighixxx | 4:55d1628dd2e5 | 124 | else |
| pighixxx | 4:55d1628dd2e5 | 125 | fill_pixel(vectorPixel,i,j,0,0,0); |
| pighixxx | 4:55d1628dd2e5 | 126 | } |
| pighixxx | 4:55d1628dd2e5 | 127 | } |
| pighixxx | 4:55d1628dd2e5 | 128 | } |
| pighixxx | 7:5b8708227c46 | 129 | |
| pighixxx | 7:5b8708227c46 | 130 | void drawColorPage(neopixel::Pixel buffer[25],int pag) { |
| pighixxx | 7:5b8708227c46 | 131 | // The pixel array control class. |
| pighixxx | 7:5b8708227c46 | 132 | neopixel::PixelArray array(DATA_PIN); |
| pighixxx | 7:5b8708227c46 | 133 | for (int i=0;i<5;i++) { |
| pighixxx | 7:5b8708227c46 | 134 | int pCol=(pag*5)+i; |
| pighixxx | 7:5b8708227c46 | 135 | for (int g=0; g<4; g++) { |
| pighixxx | 7:5b8708227c46 | 136 | fill_pixel(buffer,g,i,palR[pCol],palG[pCol],palB[pCol]); |
| pighixxx | 7:5b8708227c46 | 137 | } |
| pighixxx | 7:5b8708227c46 | 138 | array.update(buffer, 64); |
| pighixxx | 7:5b8708227c46 | 139 | } |
| pighixxx | 7:5b8708227c46 | 140 | } |
| pighixxx | 7:5b8708227c46 | 141 | |
| pighixxx | 7:5b8708227c46 | 142 | void refreshScreen(neopixel::Pixel buffer[25]) { |
| pighixxx | 7:5b8708227c46 | 143 | // The pixel array control class. |
| pighixxx | 7:5b8708227c46 | 144 | neopixel::PixelArray array(DATA_PIN); |
| pighixxx | 7:5b8708227c46 | 145 | for (int i=0;i<25;i++) { |
| pighixxx | 7:5b8708227c46 | 146 | int posx=i%5; |
| pighixxx | 7:5b8708227c46 | 147 | int posy=int(i/5); |
| pighixxx | 7:5b8708227c46 | 148 | fill_pixel(buffer,posx,posy,pantR[posx][posy],pantG[posx][posy],pantB[posx][posy]); |
| pighixxx | 7:5b8708227c46 | 149 | } |
| pighixxx | 7:5b8708227c46 | 150 | array.update(buffer, 64); |
| pighixxx | 7:5b8708227c46 | 151 | } |
| pighixxx | 7:5b8708227c46 | 152 | |
| pighixxx | 7:5b8708227c46 | 153 | |
| pighixxx | 7:5b8708227c46 | 154 | void selectColor(neopixel::Pixel buffer[25]) { |
| pighixxx | 7:5b8708227c46 | 155 | neopixel::PixelArray array(DATA_PIN); |
| pighixxx | 7:5b8708227c46 | 156 | int posLed = ain.read() * 15.0f; |
| pighixxx | 7:5b8708227c46 | 157 | if (posLed>15) posLed=15; |
| pighixxx | 7:5b8708227c46 | 158 | int page=int(posLed/3); |
| pighixxx | 7:5b8708227c46 | 159 | int oldpage=page; |
| pighixxx | 7:5b8708227c46 | 160 | drawColorPage(buffer,page); |
| pighixxx | 7:5b8708227c46 | 161 | int oldLed=posLed; |
| pighixxx | 7:5b8708227c46 | 162 | while (1) { |
| pighixxx | 7:5b8708227c46 | 163 | int posLed = ain.read() * 15.0f; |
| pighixxx | 7:5b8708227c46 | 164 | if (posLed>15) posLed=15; |
| pighixxx | 7:5b8708227c46 | 165 | page=int(posLed/5); |
| pighixxx | 7:5b8708227c46 | 166 | if (oldpage!=page) { |
| pighixxx | 7:5b8708227c46 | 167 | // Draw a new color page |
| pighixxx | 7:5b8708227c46 | 168 | drawColorPage(buffer,page); |
| pighixxx | 7:5b8708227c46 | 169 | oldpage=page; |
| pighixxx | 7:5b8708227c46 | 170 | } |
| pighixxx | 7:5b8708227c46 | 171 | if (oldLed!=posLed) |
| pighixxx | 7:5b8708227c46 | 172 | { |
| pighixxx | 7:5b8708227c46 | 173 | fill_pixel(buffer,5,oldLed%5,0,0,0); |
| pighixxx | 7:5b8708227c46 | 174 | oldLed=posLed; |
| pighixxx | 7:5b8708227c46 | 175 | fill_pixel(buffer,5,posLed%5,50,50,50); |
| pighixxx | 7:5b8708227c46 | 176 | array.update(buffer, 64); |
| pighixxx | 7:5b8708227c46 | 177 | } |
| pighixxx | 7:5b8708227c46 | 178 | if(pushbutton){ |
| pighixxx | 7:5b8708227c46 | 179 | // Select color |
| pighixxx | 7:5b8708227c46 | 180 | int elColor=(page*5)+posLed%5; |
| pighixxx | 7:5b8708227c46 | 181 | actualR=palR[elColor]; |
| pighixxx | 7:5b8708227c46 | 182 | actualG=palG[elColor]; |
| pighixxx | 7:5b8708227c46 | 183 | actualB=palB[elColor]; |
| pighixxx | 7:5b8708227c46 | 184 | wait_ms(50); |
| pighixxx | 7:5b8708227c46 | 185 | while (pushbutton) {wait_ms(10);} |
| pighixxx | 7:5b8708227c46 | 186 | // Repaint |
| pighixxx | 7:5b8708227c46 | 187 | refreshScreen(buffer); |
| pighixxx | 7:5b8708227c46 | 188 | break; |
| pighixxx | 7:5b8708227c46 | 189 | } |
| pighixxx | 7:5b8708227c46 | 190 | } |
| pighixxx | 7:5b8708227c46 | 191 | } |
| pighixxx | 7:5b8708227c46 | 192 | |
| pighixxx | 7:5b8708227c46 | 193 | void clearScreen(neopixel::Pixel buffer[25], bool newDraw) { |
| pighixxx | 7:5b8708227c46 | 194 | // The pixel array control class. |
| pighixxx | 7:5b8708227c46 | 195 | neopixel::PixelArray array(DATA_PIN); |
| pighixxx | 7:5b8708227c46 | 196 | for (int i=0;i<25;i++) { |
| pighixxx | 7:5b8708227c46 | 197 | int posx=i%5; |
| pighixxx | 7:5b8708227c46 | 198 | int posy=int(i/5); |
| pighixxx | 7:5b8708227c46 | 199 | fill_pixel(buffer,posx,posy,0,0,0); |
| pighixxx | 7:5b8708227c46 | 200 | if (newDraw) { |
| pighixxx | 7:5b8708227c46 | 201 | pantR[posx][posy]=0; |
| pighixxx | 7:5b8708227c46 | 202 | pantG[posx][posy]=0; |
| pighixxx | 7:5b8708227c46 | 203 | pantB[posx][posy]=0; |
| pighixxx | 7:5b8708227c46 | 204 | } |
| pighixxx | 7:5b8708227c46 | 205 | } |
| pighixxx | 7:5b8708227c46 | 206 | array.update(buffer, 64); |
| pighixxx | 7:5b8708227c46 | 207 | } |
| pighixxx | 7:5b8708227c46 | 208 | |
| pighixxx | 7:5b8708227c46 | 209 | |
| JacobBramley | 1:ca76237d2965 | 210 | int main() |
| JacobBramley | 1:ca76237d2965 | 211 | { |
| pighixxx | 3:2d84c8262139 | 212 | // Turn off miniblip buzzer |
| pighixxx | 3:2d84c8262139 | 213 | PwmOut speaker(P0_8); |
| pighixxx | 3:2d84c8262139 | 214 | speaker=0.0; |
| pighixxx | 7:5b8708227c46 | 215 | |
| pighixxx | 7:5b8708227c46 | 216 | for (int i = 0; i < TOUCH_N; i++) { |
| pighixxx | 7:5b8708227c46 | 217 | p_touch_io[i] = new DigitalInOut(touch_pin[i]); |
| pighixxx | 7:5b8708227c46 | 218 | p_touch_io[i]->mode(PullDown); |
| pighixxx | 7:5b8708227c46 | 219 | p_touch_io[i]->output(); |
| pighixxx | 7:5b8708227c46 | 220 | p_touch_io[i]->write(1); |
| pighixxx | 7:5b8708227c46 | 221 | } |
| pighixxx | 7:5b8708227c46 | 222 | |
| pighixxx | 7:5b8708227c46 | 223 | tick.attach(detect, 1.0 / 40.0); |
| pighixxx | 7:5b8708227c46 | 224 | |
| JacobBramley | 1:ca76237d2965 | 225 | // Create a temporary DigitalIn so we can configure the pull-down resistor. |
| JacobBramley | 1:ca76237d2965 | 226 | DigitalIn(DATA_PIN, PullDown); |
| pighixxx | 4:55d1628dd2e5 | 227 | |
| pighixxx | 7:5b8708227c46 | 228 | |
| pighixxx | 4:55d1628dd2e5 | 229 | |
| pighixxx | 4:55d1628dd2e5 | 230 | neopixel::Pixel vector[25]; |
| pighixxx | 4:55d1628dd2e5 | 231 | void_matrix(vector); |
| JacobBramley | 1:ca76237d2965 | 232 | |
| JacobBramley | 1:ca76237d2965 | 233 | // The pixel array control class. |
| JacobBramley | 1:ca76237d2965 | 234 | neopixel::PixelArray array(DATA_PIN); |
| pighixxx | 5:03859160e3a9 | 235 | |
| pighixxx | 5:03859160e3a9 | 236 | bool pixState=0; |
| pighixxx | 5:03859160e3a9 | 237 | int pixCount=0; |
| pighixxx | 5:03859160e3a9 | 238 | int OldPos = ain.read() * 26.0f; |
| pighixxx | 7:5b8708227c46 | 239 | |
| JacobBramley | 1:ca76237d2965 | 240 | while (1) { |
| pighixxx | 5:03859160e3a9 | 241 | // Read Pot |
| pighixxx | 5:03859160e3a9 | 242 | int posLed = ain.read() * 26.0f; |
| pighixxx | 7:5b8708227c46 | 243 | if (posLed>25) posLed=25; |
| pighixxx | 7:5b8708227c46 | 244 | if (posLed<0) posLed=0; |
| pighixxx | 4:55d1628dd2e5 | 245 | int posx=posLed%5; |
| pighixxx | 4:55d1628dd2e5 | 246 | int posy=int(posLed/5); |
| pighixxx | 7:5b8708227c46 | 247 | //fill_pixel(vector,posx,posy,actualR,actualG,actualB); |
| pighixxx | 7:5b8708227c46 | 248 | if (pixState) fill_pixel(vector,posx,posy,50,50,50); else { |
| pighixxx | 5:03859160e3a9 | 249 | int posx=posLed%5; |
| pighixxx | 5:03859160e3a9 | 250 | int posy=int(posLed/5); |
| pighixxx | 5:03859160e3a9 | 251 | int cred=pantR[posx][posy]; |
| pighixxx | 5:03859160e3a9 | 252 | int cblu=pantG[posx][posy]; |
| pighixxx | 5:03859160e3a9 | 253 | int cgreen=pantB[posx][posy]; |
| pighixxx | 5:03859160e3a9 | 254 | fill_pixel(vector,posx,posy,cred,cblu,cgreen); |
| pighixxx | 5:03859160e3a9 | 255 | } |
| pighixxx | 5:03859160e3a9 | 256 | if (posLed!=OldPos) { |
| pighixxx | 5:03859160e3a9 | 257 | // Delete old pos |
| pighixxx | 5:03859160e3a9 | 258 | int posx=OldPos%5; |
| pighixxx | 5:03859160e3a9 | 259 | int posy=int(OldPos/5); |
| pighixxx | 5:03859160e3a9 | 260 | int cred=pantR[posx][posy]; |
| pighixxx | 5:03859160e3a9 | 261 | int cblu=pantG[posx][posy]; |
| pighixxx | 5:03859160e3a9 | 262 | int cgreen=pantB[posx][posy]; |
| pighixxx | 5:03859160e3a9 | 263 | fill_pixel(vector,posx,posy,cred,cblu,cgreen); |
| pighixxx | 5:03859160e3a9 | 264 | OldPos=posLed; |
| pighixxx | 5:03859160e3a9 | 265 | } |
| pighixxx | 5:03859160e3a9 | 266 | |
| pighixxx | 5:03859160e3a9 | 267 | pixCount++; |
| pighixxx | 6:cacc8514502c | 268 | if (pixCount>8) { |
| pighixxx | 5:03859160e3a9 | 269 | pixCount=0; |
| pighixxx | 5:03859160e3a9 | 270 | pixState^= 1; |
| pighixxx | 5:03859160e3a9 | 271 | } |
| pighixxx | 4:55d1628dd2e5 | 272 | array.update(vector, 64); |
| pighixxx | 4:55d1628dd2e5 | 273 | wait_ms(30); |
| pighixxx | 5:03859160e3a9 | 274 | |
| pighixxx | 7:5b8708227c46 | 275 | // Color button |
| pighixxx | 7:5b8708227c46 | 276 | if (modo==1) { |
| pighixxx | 7:5b8708227c46 | 277 | clearScreen(vector,false); |
| pighixxx | 7:5b8708227c46 | 278 | selectColor(vector); |
| pighixxx | 7:5b8708227c46 | 279 | modo=10; |
| pighixxx | 7:5b8708227c46 | 280 | } |
| pighixxx | 7:5b8708227c46 | 281 | |
| pighixxx | 7:5b8708227c46 | 282 | // Change pixel |
| pighixxx | 4:55d1628dd2e5 | 283 | if(pushbutton){ |
| pighixxx | 5:03859160e3a9 | 284 | //Check |
| pighixxx | 5:03859160e3a9 | 285 | int posx=posLed%5; |
| pighixxx | 5:03859160e3a9 | 286 | int posy=int(posLed/5); |
| pighixxx | 5:03859160e3a9 | 287 | int cred=pantR[posx][posy]; |
| pighixxx | 5:03859160e3a9 | 288 | int cblu=pantG[posx][posy]; |
| pighixxx | 5:03859160e3a9 | 289 | int cgreen=pantB[posx][posy]; |
| pighixxx | 7:5b8708227c46 | 290 | if (cred==0&&cblu==0&cgreen==0) { |
| pighixxx | 7:5b8708227c46 | 291 | pantR[posx][posy]=actualR; |
| pighixxx | 7:5b8708227c46 | 292 | pantG[posx][posy]=actualG; |
| pighixxx | 7:5b8708227c46 | 293 | pantB[posx][posy]=actualB; |
| pighixxx | 7:5b8708227c46 | 294 | } |
| pighixxx | 7:5b8708227c46 | 295 | else { |
| pighixxx | 7:5b8708227c46 | 296 | pantR[posx][posy]=0; |
| pighixxx | 7:5b8708227c46 | 297 | pantG[posx][posy]=0; |
| pighixxx | 7:5b8708227c46 | 298 | pantB[posx][posy]=0; |
| pighixxx | 7:5b8708227c46 | 299 | } |
| pighixxx | 5:03859160e3a9 | 300 | //fill_pixel(vector,posx,posy,cred,cblu,cgreen); |
| pighixxx | 5:03859160e3a9 | 301 | wait_ms(50); |
| pighixxx | 6:cacc8514502c | 302 | while (pushbutton) {wait_ms(10);} |
| pighixxx | 4:55d1628dd2e5 | 303 | } |
| JacobBramley | 0:60499ad28ea9 | 304 | } |
| pighixxx | 4:55d1628dd2e5 | 305 | } |
