EA OLED Hello World (Runs through the different possibilities with the OLED software

Dependencies:   mbed

Committer:
Lerche
Date:
Sun Oct 03 08:40:47 2010 +0000
Revision:
0:ff072ee9597c

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Lerche 0:ff072ee9597c 1 // test library for Embedded Artists OLED used on Xpresso Baseboard
Lerche 0:ff072ee9597c 2
Lerche 0:ff072ee9597c 3 #include "EAOLED.h"
Lerche 0:ff072ee9597c 4 #include "mbed.h"
Lerche 0:ff072ee9597c 5
Lerche 0:ff072ee9597c 6 EAOLED::EAOLED(PinName mosi, PinName dnc, PinName sclk, PinName cs, PinName power)
Lerche 0:ff072ee9597c 7 : _spi(mosi, NC, sclk), _data(dnc), _cs(cs), _power(power) {
Lerche 0:ff072ee9597c 8 reset();
Lerche 0:ff072ee9597c 9 }
Lerche 0:ff072ee9597c 10
Lerche 0:ff072ee9597c 11 void EAOLED::command(int value) {
Lerche 0:ff072ee9597c 12 _data = 0;
Lerche 0:ff072ee9597c 13 _cs = 0;
Lerche 0:ff072ee9597c 14 _spi.write(value);
Lerche 0:ff072ee9597c 15 _cs = 1;
Lerche 0:ff072ee9597c 16 }
Lerche 0:ff072ee9597c 17
Lerche 0:ff072ee9597c 18 void EAOLED::data(int value) {
Lerche 0:ff072ee9597c 19 _data = 1;
Lerche 0:ff072ee9597c 20 _cs = 0;
Lerche 0:ff072ee9597c 21 _spi.write(value);
Lerche 0:ff072ee9597c 22 _cs = 1;
Lerche 0:ff072ee9597c 23 }
Lerche 0:ff072ee9597c 24
Lerche 0:ff072ee9597c 25 void EAOLED::reset() {
Lerche 0:ff072ee9597c 26 _power = 0;
Lerche 0:ff072ee9597c 27 _cs = 1;
Lerche 0:ff072ee9597c 28
Lerche 0:ff072ee9597c 29 // Startup sequence recommended by embedded artists baseboard reference code
Lerche 0:ff072ee9597c 30 command(0x02); // set low column address
Lerche 0:ff072ee9597c 31 command(0x12); // set high column address
Lerche 0:ff072ee9597c 32 command(0x40); // display start set
Lerche 0:ff072ee9597c 33 command(0x2e); // stop horzontal scroll
Lerche 0:ff072ee9597c 34 command(0x81); // set contrast control register
Lerche 0:ff072ee9597c 35 command(0x32); //
Lerche 0:ff072ee9597c 36 command(0x82); // brightness for color banks
Lerche 0:ff072ee9597c 37 command(0x80); // display on
Lerche 0:ff072ee9597c 38 command(0xa1); // set segment re-map
Lerche 0:ff072ee9597c 39 command(0xa6); // set normal/inverse display
Lerche 0:ff072ee9597c 40 command(0xa8); // set multiplex ratio
Lerche 0:ff072ee9597c 41 command(0x3F); //
Lerche 0:ff072ee9597c 42 command(0xd3); // set display offset
Lerche 0:ff072ee9597c 43 command(0x40); //
Lerche 0:ff072ee9597c 44 command(0xad); // set dc-dc on/off
Lerche 0:ff072ee9597c 45 command(0x8E); //
Lerche 0:ff072ee9597c 46 command(0xc8); // set com output scan direction
Lerche 0:ff072ee9597c 47 command(0xd5); // set display clock divide ratio/oscillator/frequency
Lerche 0:ff072ee9597c 48 command(0xf0); //
Lerche 0:ff072ee9597c 49 command(0xd8); // set area color mode on/off & low power display mode
Lerche 0:ff072ee9597c 50 command(0x05); //
Lerche 0:ff072ee9597c 51 command(0xd9); // set pre-charge period
Lerche 0:ff072ee9597c 52 command(0xF1); //
Lerche 0:ff072ee9597c 53 command(0xda); // set com pins hardware configuration
Lerche 0:ff072ee9597c 54 command(0x12); //
Lerche 0:ff072ee9597c 55 command(0xdb); // set vcom deselect level
Lerche 0:ff072ee9597c 56 command(0x34); //
Lerche 0:ff072ee9597c 57 command(0x91); // set look up table for area color
Lerche 0:ff072ee9597c 58 command(0x3f); //
Lerche 0:ff072ee9597c 59 command(0x3f); //
Lerche 0:ff072ee9597c 60 command(0x3f); //
Lerche 0:ff072ee9597c 61 command(0x3f); //
Lerche 0:ff072ee9597c 62 command(0xaf); // display on
Lerche 0:ff072ee9597c 63 command(0xa4); // display on
Lerche 0:ff072ee9597c 64
Lerche 0:ff072ee9597c 65 wait_us(10);
Lerche 0:ff072ee9597c 66
Lerche 0:ff072ee9597c 67 _power = 1;
Lerche 0:ff072ee9597c 68 }
Lerche 0:ff072ee9597c 69
Lerche 0:ff072ee9597c 70 #define OLED_DISPLAY_WIDTH 96
Lerche 0:ff072ee9597c 71 #define OLED_DISPLAY_HEIGHT 64
Lerche 0:ff072ee9597c 72
Lerche 0:ff072ee9597c 73 void EAOLED::pixel(int x, int y, int colour) {
Lerche 0:ff072ee9597c 74 int page = y >> 3;
Lerche 0:ff072ee9597c 75 int address = 18 + x;
Lerche 0:ff072ee9597c 76
Lerche 0:ff072ee9597c 77 int lo = (address >> 0) & 0x0F;
Lerche 0:ff072ee9597c 78 int hi = (address >> 4) | 0x10;
Lerche 0:ff072ee9597c 79 int mask = 1 << (y & 0x7);
Lerche 0:ff072ee9597c 80 int byte = page * OLED_DISPLAY_WIDTH + x;
Lerche 0:ff072ee9597c 81
Lerche 0:ff072ee9597c 82 if(colour) {
Lerche 0:ff072ee9597c 83 framebuffer[byte] |= mask;
Lerche 0:ff072ee9597c 84 } else {
Lerche 0:ff072ee9597c 85 framebuffer[byte] &= ~mask;
Lerche 0:ff072ee9597c 86 }
Lerche 0:ff072ee9597c 87
Lerche 0:ff072ee9597c 88 command(0xB0 + page);
Lerche 0:ff072ee9597c 89 command(lo);
Lerche 0:ff072ee9597c 90 command(hi);
Lerche 0:ff072ee9597c 91 data(framebuffer[byte]);
Lerche 0:ff072ee9597c 92 }
Lerche 0:ff072ee9597c 93
Lerche 0:ff072ee9597c 94 void EAOLED::circle(int x0, int y0, int r, int colour) {
Lerche 0:ff072ee9597c 95
Lerche 0:ff072ee9597c 96 #define OLED_DISPLAY_WIDTH 96
Lerche 0:ff072ee9597c 97 #define OLED_DISPLAY_HEIGHT 64
Lerche 0:ff072ee9597c 98
Lerche 0:ff072ee9597c 99 int draw_x0, draw_y0;
Lerche 0:ff072ee9597c 100 int draw_x1, draw_y1;
Lerche 0:ff072ee9597c 101 int draw_x2, draw_y2;
Lerche 0:ff072ee9597c 102 int draw_x3, draw_y3;
Lerche 0:ff072ee9597c 103 int draw_x4, draw_y4;
Lerche 0:ff072ee9597c 104 int draw_x5, draw_y5;
Lerche 0:ff072ee9597c 105 int draw_x6, draw_y6;
Lerche 0:ff072ee9597c 106 int draw_x7, draw_y7;
Lerche 0:ff072ee9597c 107 int xx, yy;
Lerche 0:ff072ee9597c 108 int di;
Lerche 0:ff072ee9597c 109
Lerche 0:ff072ee9597c 110 if(r == 0) /* no radius */
Lerche 0:ff072ee9597c 111 {
Lerche 0:ff072ee9597c 112 return;
Lerche 0:ff072ee9597c 113 }
Lerche 0:ff072ee9597c 114
Lerche 0:ff072ee9597c 115 draw_x0 = draw_x1 = x0;
Lerche 0:ff072ee9597c 116 draw_y0 = draw_y1 = y0 + r;
Lerche 0:ff072ee9597c 117 if(draw_y0 < OLED_DISPLAY_HEIGHT)
Lerche 0:ff072ee9597c 118 {
Lerche 0:ff072ee9597c 119 pixel(draw_x0, draw_y0, colour); /* 90 degree */
Lerche 0:ff072ee9597c 120 }
Lerche 0:ff072ee9597c 121
Lerche 0:ff072ee9597c 122 draw_x2 = draw_x3 = x0;
Lerche 0:ff072ee9597c 123 draw_y2 = draw_y3 = y0 - r;
Lerche 0:ff072ee9597c 124 if(draw_y2 >= 0)
Lerche 0:ff072ee9597c 125 {
Lerche 0:ff072ee9597c 126 pixel(draw_x2, draw_y2, colour); /* 270 degree */
Lerche 0:ff072ee9597c 127 }
Lerche 0:ff072ee9597c 128
Lerche 0:ff072ee9597c 129 draw_x4 = draw_x6 = x0 + r;
Lerche 0:ff072ee9597c 130 draw_y4 = draw_y6 = y0;
Lerche 0:ff072ee9597c 131 if(draw_x4 < OLED_DISPLAY_WIDTH)
Lerche 0:ff072ee9597c 132 {
Lerche 0:ff072ee9597c 133 pixel(draw_x4, draw_y4, colour); /* 0 degree */
Lerche 0:ff072ee9597c 134 }
Lerche 0:ff072ee9597c 135
Lerche 0:ff072ee9597c 136 draw_x5 = draw_x7 = x0 - r;
Lerche 0:ff072ee9597c 137 draw_y5 = draw_y7 = y0;
Lerche 0:ff072ee9597c 138 if(draw_x5>=0)
Lerche 0:ff072ee9597c 139 {
Lerche 0:ff072ee9597c 140 pixel(draw_x5, draw_y5, colour); /* 180 degree */
Lerche 0:ff072ee9597c 141 }
Lerche 0:ff072ee9597c 142
Lerche 0:ff072ee9597c 143 if(r == 1)
Lerche 0:ff072ee9597c 144 {
Lerche 0:ff072ee9597c 145 return;
Lerche 0:ff072ee9597c 146 }
Lerche 0:ff072ee9597c 147
Lerche 0:ff072ee9597c 148 di = 3 - 2*r;
Lerche 0:ff072ee9597c 149 xx = 0;
Lerche 0:ff072ee9597c 150 yy = r;
Lerche 0:ff072ee9597c 151 while(xx < yy)
Lerche 0:ff072ee9597c 152 {
Lerche 0:ff072ee9597c 153
Lerche 0:ff072ee9597c 154 if(di < 0)
Lerche 0:ff072ee9597c 155 {
Lerche 0:ff072ee9597c 156 di += 4*xx + 6;
Lerche 0:ff072ee9597c 157 }
Lerche 0:ff072ee9597c 158 else
Lerche 0:ff072ee9597c 159 {
Lerche 0:ff072ee9597c 160 di += 4*(xx - yy) + 10;
Lerche 0:ff072ee9597c 161 yy--;
Lerche 0:ff072ee9597c 162 draw_y0--;
Lerche 0:ff072ee9597c 163 draw_y1--;
Lerche 0:ff072ee9597c 164 draw_y2++;
Lerche 0:ff072ee9597c 165 draw_y3++;
Lerche 0:ff072ee9597c 166 draw_x4--;
Lerche 0:ff072ee9597c 167 draw_x5++;
Lerche 0:ff072ee9597c 168 draw_x6--;
Lerche 0:ff072ee9597c 169 draw_x7++;
Lerche 0:ff072ee9597c 170 }
Lerche 0:ff072ee9597c 171 xx++;
Lerche 0:ff072ee9597c 172 draw_x0++;
Lerche 0:ff072ee9597c 173 draw_x1--;
Lerche 0:ff072ee9597c 174 draw_x2++;
Lerche 0:ff072ee9597c 175 draw_x3--;
Lerche 0:ff072ee9597c 176 draw_y4++;
Lerche 0:ff072ee9597c 177 draw_y5++;
Lerche 0:ff072ee9597c 178 draw_y6--;
Lerche 0:ff072ee9597c 179 draw_y7--;
Lerche 0:ff072ee9597c 180
Lerche 0:ff072ee9597c 181 if( (draw_x0 <= OLED_DISPLAY_WIDTH) && (draw_y0>=0) )
Lerche 0:ff072ee9597c 182 {
Lerche 0:ff072ee9597c 183 pixel(draw_x0, draw_y0, colour);
Lerche 0:ff072ee9597c 184 }
Lerche 0:ff072ee9597c 185
Lerche 0:ff072ee9597c 186 if( (draw_x1 >= 0) && (draw_y1 >= 0) )
Lerche 0:ff072ee9597c 187 {
Lerche 0:ff072ee9597c 188 pixel(draw_x1, draw_y1, colour);
Lerche 0:ff072ee9597c 189 }
Lerche 0:ff072ee9597c 190
Lerche 0:ff072ee9597c 191 if( (draw_x2 <= OLED_DISPLAY_WIDTH) && (draw_y2 <= OLED_DISPLAY_HEIGHT) )
Lerche 0:ff072ee9597c 192 {
Lerche 0:ff072ee9597c 193 pixel(draw_x2, draw_y2, colour);
Lerche 0:ff072ee9597c 194 }
Lerche 0:ff072ee9597c 195
Lerche 0:ff072ee9597c 196 if( (draw_x3 >=0 ) && (draw_y3 <= OLED_DISPLAY_HEIGHT) )
Lerche 0:ff072ee9597c 197 {
Lerche 0:ff072ee9597c 198 pixel(draw_x3, draw_y3, colour);
Lerche 0:ff072ee9597c 199 }
Lerche 0:ff072ee9597c 200
Lerche 0:ff072ee9597c 201 if( (draw_x4 <= /*OLED_DISPLAY_HEIGHT*/OLED_DISPLAY_WIDTH) && (draw_y4 >= 0) )
Lerche 0:ff072ee9597c 202 {
Lerche 0:ff072ee9597c 203 pixel(draw_x4, draw_y4, colour);
Lerche 0:ff072ee9597c 204 }
Lerche 0:ff072ee9597c 205
Lerche 0:ff072ee9597c 206 if( (draw_x5 >= 0) && (draw_y5 >= 0) )
Lerche 0:ff072ee9597c 207 {
Lerche 0:ff072ee9597c 208 pixel(draw_x5, draw_y5, colour);
Lerche 0:ff072ee9597c 209 }
Lerche 0:ff072ee9597c 210 if( (draw_x6 <= OLED_DISPLAY_WIDTH) && (draw_y6 <= OLED_DISPLAY_HEIGHT) )
Lerche 0:ff072ee9597c 211 {
Lerche 0:ff072ee9597c 212 pixel(draw_x6, draw_y6, colour);
Lerche 0:ff072ee9597c 213 }
Lerche 0:ff072ee9597c 214 if( (draw_x7 >= 0) && (draw_y7 <= OLED_DISPLAY_HEIGHT) )
Lerche 0:ff072ee9597c 215 {
Lerche 0:ff072ee9597c 216 pixel(draw_x7, draw_y7, colour);
Lerche 0:ff072ee9597c 217 }
Lerche 0:ff072ee9597c 218 }
Lerche 0:ff072ee9597c 219 return;
Lerche 0:ff072ee9597c 220 }
Lerche 0:ff072ee9597c 221
Lerche 0:ff072ee9597c 222 void EAOLED::hline(int x0, int x1, int y, int colour) {
Lerche 0:ff072ee9597c 223 for(int x=x0; x<x1; x++){
Lerche 0:ff072ee9597c 224 pixel(x, y, colour);
Lerche 0:ff072ee9597c 225 }
Lerche 0:ff072ee9597c 226 return;
Lerche 0:ff072ee9597c 227 }
Lerche 0:ff072ee9597c 228
Lerche 0:ff072ee9597c 229 void EAOLED::vline(int y0, int y1, int x, int colour) {
Lerche 0:ff072ee9597c 230 for(int y=y0; y<y1; y++){
Lerche 0:ff072ee9597c 231 pixel(x, y, colour);
Lerche 0:ff072ee9597c 232 }
Lerche 0:ff072ee9597c 233 return;
Lerche 0:ff072ee9597c 234 }
Lerche 0:ff072ee9597c 235
Lerche 0:ff072ee9597c 236 void EAOLED::line(int x0, int y0, int x1, int y1, int colour) {
Lerche 0:ff072ee9597c 237 int dx = 0, dy = 0;
Lerche 0:ff072ee9597c 238 int dx_sym = 0, dy_sym = 0;
Lerche 0:ff072ee9597c 239 int dx_x2 = 0, dy_x2 = 0;
Lerche 0:ff072ee9597c 240 int di = 0;
Lerche 0:ff072ee9597c 241
Lerche 0:ff072ee9597c 242 dx = x1-x0;
Lerche 0:ff072ee9597c 243 dy = y1-y0;
Lerche 0:ff072ee9597c 244
Lerche 0:ff072ee9597c 245
Lerche 0:ff072ee9597c 246 if(dx == 0) /* vertical line */
Lerche 0:ff072ee9597c 247 {
Lerche 0:ff072ee9597c 248 for(int y=y0; y<y1; y++){
Lerche 0:ff072ee9597c 249 pixel(x0, y, colour);
Lerche 0:ff072ee9597c 250 }
Lerche 0:ff072ee9597c 251 return;
Lerche 0:ff072ee9597c 252 }
Lerche 0:ff072ee9597c 253
Lerche 0:ff072ee9597c 254 if(dx > 0)
Lerche 0:ff072ee9597c 255 {
Lerche 0:ff072ee9597c 256 dx_sym = 1;
Lerche 0:ff072ee9597c 257 }
Lerche 0:ff072ee9597c 258 else
Lerche 0:ff072ee9597c 259 {
Lerche 0:ff072ee9597c 260 dx_sym = -1;
Lerche 0:ff072ee9597c 261 }
Lerche 0:ff072ee9597c 262
Lerche 0:ff072ee9597c 263
Lerche 0:ff072ee9597c 264 if(dy == 0) /* horizontal line */
Lerche 0:ff072ee9597c 265 {
Lerche 0:ff072ee9597c 266 for(int x=x0; x<x1; x++){
Lerche 0:ff072ee9597c 267 pixel(x, y0, colour);
Lerche 0:ff072ee9597c 268 }
Lerche 0:ff072ee9597c 269 return;
Lerche 0:ff072ee9597c 270 }
Lerche 0:ff072ee9597c 271
Lerche 0:ff072ee9597c 272
Lerche 0:ff072ee9597c 273 if(dy > 0)
Lerche 0:ff072ee9597c 274 {
Lerche 0:ff072ee9597c 275 dy_sym = 1;
Lerche 0:ff072ee9597c 276 }
Lerche 0:ff072ee9597c 277 else
Lerche 0:ff072ee9597c 278 {
Lerche 0:ff072ee9597c 279 dy_sym = -1;
Lerche 0:ff072ee9597c 280 }
Lerche 0:ff072ee9597c 281
Lerche 0:ff072ee9597c 282 dx = dx_sym*dx;
Lerche 0:ff072ee9597c 283 dy = dy_sym*dy;
Lerche 0:ff072ee9597c 284
Lerche 0:ff072ee9597c 285 dx_x2 = dx*2;
Lerche 0:ff072ee9597c 286 dy_x2 = dy*2;
Lerche 0:ff072ee9597c 287
Lerche 0:ff072ee9597c 288 if(dx >= dy)
Lerche 0:ff072ee9597c 289 {
Lerche 0:ff072ee9597c 290 di = dy_x2 - dx;
Lerche 0:ff072ee9597c 291 while(x0 != x1)
Lerche 0:ff072ee9597c 292 {
Lerche 0:ff072ee9597c 293
Lerche 0:ff072ee9597c 294 pixel(x0, y0, colour);
Lerche 0:ff072ee9597c 295 x0 += dx_sym;
Lerche 0:ff072ee9597c 296 if(di<0)
Lerche 0:ff072ee9597c 297 {
Lerche 0:ff072ee9597c 298 di += dy_x2;
Lerche 0:ff072ee9597c 299 }
Lerche 0:ff072ee9597c 300 else
Lerche 0:ff072ee9597c 301 {
Lerche 0:ff072ee9597c 302 di += dy_x2 - dx_x2;
Lerche 0:ff072ee9597c 303 y0 += dy_sym;
Lerche 0:ff072ee9597c 304 }
Lerche 0:ff072ee9597c 305 }
Lerche 0:ff072ee9597c 306 pixel(x0, y0, colour);
Lerche 0:ff072ee9597c 307 }
Lerche 0:ff072ee9597c 308 else
Lerche 0:ff072ee9597c 309 {
Lerche 0:ff072ee9597c 310 di = dx_x2 - dy;
Lerche 0:ff072ee9597c 311 while(y0 != y1)
Lerche 0:ff072ee9597c 312 {
Lerche 0:ff072ee9597c 313 pixel(x0, y0, colour);
Lerche 0:ff072ee9597c 314 y0 += dy_sym;
Lerche 0:ff072ee9597c 315 if(di < 0)
Lerche 0:ff072ee9597c 316 {
Lerche 0:ff072ee9597c 317 di += dx_x2;
Lerche 0:ff072ee9597c 318 }
Lerche 0:ff072ee9597c 319 else
Lerche 0:ff072ee9597c 320 {
Lerche 0:ff072ee9597c 321 di += dx_x2 - dy_x2;
Lerche 0:ff072ee9597c 322 x0 += dx_sym;
Lerche 0:ff072ee9597c 323 }
Lerche 0:ff072ee9597c 324 }
Lerche 0:ff072ee9597c 325 pixel(x0, y0, colour);
Lerche 0:ff072ee9597c 326 }
Lerche 0:ff072ee9597c 327 return;
Lerche 0:ff072ee9597c 328 }
Lerche 0:ff072ee9597c 329
Lerche 0:ff072ee9597c 330 void EAOLED::rect(int x0, int y0, int x1, int y1, int colour) {
Lerche 0:ff072ee9597c 331
Lerche 0:ff072ee9597c 332 for(int x=x0; x<x1; x++){
Lerche 0:ff072ee9597c 333 pixel(x, y0, colour);
Lerche 0:ff072ee9597c 334 }
Lerche 0:ff072ee9597c 335 for(int x=x0; x<x1; x++){
Lerche 0:ff072ee9597c 336 pixel(x, y1, colour);
Lerche 0:ff072ee9597c 337 }
Lerche 0:ff072ee9597c 338 for(int y=y0; y<y1; y++){
Lerche 0:ff072ee9597c 339 pixel(x0, y, colour);
Lerche 0:ff072ee9597c 340 }
Lerche 0:ff072ee9597c 341 for(int y=y0; y<y1; y++){
Lerche 0:ff072ee9597c 342 pixel(x1, y, colour);
Lerche 0:ff072ee9597c 343 }
Lerche 0:ff072ee9597c 344 return;
Lerche 0:ff072ee9597c 345 }
Lerche 0:ff072ee9597c 346
Lerche 0:ff072ee9597c 347 void EAOLED::fillrect(int x0, int y0, int x1, int y1, int colour) {
Lerche 0:ff072ee9597c 348
Lerche 0:ff072ee9597c 349 int i = 0;
Lerche 0:ff072ee9597c 350
Lerche 0:ff072ee9597c 351 if(x0 > x1)
Lerche 0:ff072ee9597c 352 {
Lerche 0:ff072ee9597c 353 i = x0;
Lerche 0:ff072ee9597c 354 x0 = x1;
Lerche 0:ff072ee9597c 355 x1 = i;
Lerche 0:ff072ee9597c 356 }
Lerche 0:ff072ee9597c 357
Lerche 0:ff072ee9597c 358 if(y0 > y1)
Lerche 0:ff072ee9597c 359 {
Lerche 0:ff072ee9597c 360 i = y0;
Lerche 0:ff072ee9597c 361 y0 = y1;
Lerche 0:ff072ee9597c 362 y1 = i;
Lerche 0:ff072ee9597c 363 }
Lerche 0:ff072ee9597c 364
Lerche 0:ff072ee9597c 365 if(y0 == y1)
Lerche 0:ff072ee9597c 366 {
Lerche 0:ff072ee9597c 367 for(int x=x0; x<x1; x++){
Lerche 0:ff072ee9597c 368 pixel(x, y0, colour);
Lerche 0:ff072ee9597c 369 }
Lerche 0:ff072ee9597c 370 return;
Lerche 0:ff072ee9597c 371 }
Lerche 0:ff072ee9597c 372
Lerche 0:ff072ee9597c 373 if(x0 == x1)
Lerche 0:ff072ee9597c 374 {
Lerche 0:ff072ee9597c 375 for(int y=y0; y<y1; y++){
Lerche 0:ff072ee9597c 376 pixel(x0, y, colour);
Lerche 0:ff072ee9597c 377 }
Lerche 0:ff072ee9597c 378 return;
Lerche 0:ff072ee9597c 379 }
Lerche 0:ff072ee9597c 380
Lerche 0:ff072ee9597c 381 while(y0 <= y1)
Lerche 0:ff072ee9597c 382 {
Lerche 0:ff072ee9597c 383 for(int x=x0; x<x1; x++){
Lerche 0:ff072ee9597c 384 pixel(x, y0, colour);
Lerche 0:ff072ee9597c 385 }
Lerche 0:ff072ee9597c 386 y0++;
Lerche 0:ff072ee9597c 387 }
Lerche 0:ff072ee9597c 388 return;
Lerche 0:ff072ee9597c 389
Lerche 0:ff072ee9597c 390 }