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.
draw.cpp@0:06f3e47afa60, 2012-10-11 (annotated)
- Committer:
- lucoby
- Date:
- Thu Oct 11 18:54:40 2012 +0000
- Revision:
- 0:06f3e47afa60
- Child:
- 1:2e528b145987
initial
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| lucoby | 0:06f3e47afa60 | 1 | #include "mbed.h" |
| lucoby | 0:06f3e47afa60 | 2 | #include "TFT_4DGL.h" |
| lucoby | 0:06f3e47afa60 | 3 | #include "draw.h" |
| lucoby | 0:06f3e47afa60 | 4 | |
| lucoby | 0:06f3e47afa60 | 5 | |
| lucoby | 0:06f3e47afa60 | 6 | TFT_4DGL ecran(p28,p27,p23); // serial tx, serial rx, reset pin; |
| lucoby | 0:06f3e47afa60 | 7 | |
| lucoby | 0:06f3e47afa60 | 8 | void drawSetup() { |
| lucoby | 0:06f3e47afa60 | 9 | ecran.baudrate(115200); |
| lucoby | 0:06f3e47afa60 | 10 | ecran.cls(); |
| lucoby | 0:06f3e47afa60 | 11 | // added - Set Display to 640 by 480 mode |
| lucoby | 0:06f3e47afa60 | 12 | ecran.display_control(0x0c, 0x01); |
| lucoby | 0:06f3e47afa60 | 13 | // |
| lucoby | 0:06f3e47afa60 | 14 | ecran.background_color(DGREY); |
| lucoby | 0:06f3e47afa60 | 15 | } |
| lucoby | 0:06f3e47afa60 | 16 | |
| lucoby | 0:06f3e47afa60 | 17 | void clearscr() { |
| lucoby | 0:06f3e47afa60 | 18 | ecran.cls(); |
| lucoby | 0:06f3e47afa60 | 19 | } |
| lucoby | 0:06f3e47afa60 | 20 | |
| lucoby | 0:06f3e47afa60 | 21 | void drawPixel(int row, int col, int color) { |
| lucoby | 0:06f3e47afa60 | 22 | ecran.rectangle(col*15+135, row*15+80, col*15+149, row*15+94, color); |
| lucoby | 0:06f3e47afa60 | 23 | } |
| lucoby | 0:06f3e47afa60 | 24 | |
| lucoby | 0:06f3e47afa60 | 25 | void drawSnake(int row, int col) { |
| lucoby | 0:06f3e47afa60 | 26 | drawPixel(row, col, 0x00FF00); |
| lucoby | 0:06f3e47afa60 | 27 | } |
| lucoby | 0:06f3e47afa60 | 28 | |
| lucoby | 0:06f3e47afa60 | 29 | void drawApple(int row, int col) { |
| lucoby | 0:06f3e47afa60 | 30 | drawPixel(row, col, 0xFF0000); |
| lucoby | 0:06f3e47afa60 | 31 | } |
| lucoby | 0:06f3e47afa60 | 32 | |
| lucoby | 0:06f3e47afa60 | 33 | void drawBlank(int row, int col) { |
| lucoby | 0:06f3e47afa60 | 34 | drawPixel(row, col, DGREY); |
| lucoby | 0:06f3e47afa60 | 35 | } |
| lucoby | 0:06f3e47afa60 | 36 | |
| lucoby | 0:06f3e47afa60 | 37 | void drawScore(int score) { |
| lucoby | 0:06f3e47afa60 | 38 | char scr[8]; |
| lucoby | 0:06f3e47afa60 | 39 | ecran.rectangle(375,300,420,320,DGREY); |
| lucoby | 0:06f3e47afa60 | 40 | scr = sprintf("%d", score); |
| lucoby | 0:06f3e47afa60 | 41 | ecran.text_string("Score: ", 320, 315, FONT_8X8, WHITE); |
| lucoby | 0:06f3e47afa60 | 42 | ecran.text_string(scr, 376, 315, FONT_8X8, WHITE); |
| lucoby | 0:06f3e47afa60 | 43 | } |