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.
Dependencies: mbed
Fork of el17ajf by
Graphics/Graphics.cpp@10:5762d7fae033, 2019-03-15 (annotated)
- Committer:
- el17ajf
- Date:
- Fri Mar 15 21:16:39 2019 +0000
- Revision:
- 10:5762d7fae033
- Parent:
- 9:3a7776a29a11
- Child:
- 11:fba7d54fd36b
declared static variables in class cpp files
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
el17ajf | 5:3efbdcb3efaf | 1 | #include "Graphics.h" |
el17ajf | 5:3efbdcb3efaf | 2 | |
el17ajf | 10:5762d7fae033 | 3 | N5110 * Graphics::lcd; |
el17ajf | 10:5762d7fae033 | 4 | |
el17ajf | 8:5066ce13a430 | 5 | void Graphics::init() { |
el17ajf | 8:5066ce13a430 | 6 | lcd = new N5110(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); |
el17ajf | 9:3a7776a29a11 | 7 | lcd->init(); |
el17ajf | 9:3a7776a29a11 | 8 | lcd->setContrast(0.4); |
el17ajf | 8:5066ce13a430 | 9 | } |
el17ajf | 8:5066ce13a430 | 10 | |
el17ajf | 8:5066ce13a430 | 11 | void Graphics::deinit() { |
el17ajf | 8:5066ce13a430 | 12 | delete lcd; |
el17ajf | 8:5066ce13a430 | 13 | } |
el17ajf | 8:5066ce13a430 | 14 | |
el17ajf | 5:3efbdcb3efaf | 15 | void Graphics::clear() { |
el17ajf | 9:3a7776a29a11 | 16 | lcd->clear(); |
el17ajf | 5:3efbdcb3efaf | 17 | } |
el17ajf | 5:3efbdcb3efaf | 18 | |
el17ajf | 5:3efbdcb3efaf | 19 | void Graphics::render() { |
el17ajf | 9:3a7776a29a11 | 20 | lcd->refresh(); |
el17ajf | 8:5066ce13a430 | 21 | } |
el17ajf | 8:5066ce13a430 | 22 | |
el17ajf | 8:5066ce13a430 | 23 | void Graphics::drawPoint(int x, int y) { |
el17ajf | 8:5066ce13a430 | 24 | lcd->setPixel(x, y, true); |
el17ajf | 8:5066ce13a430 | 25 | } |
el17ajf | 8:5066ce13a430 | 26 | |
el17ajf | 8:5066ce13a430 | 27 | void Graphics::drawLine(int x1, int y1, int x2, int y2) { |
el17ajf | 8:5066ce13a430 | 28 | lcd->drawLine(x1, y1, x2, y2, 1); |
el17ajf | 8:5066ce13a430 | 29 | } |
el17ajf | 8:5066ce13a430 | 30 | |
el17ajf | 8:5066ce13a430 | 31 | void Graphics::drawDottedLine(int x1, int y1, int x2, int y2) { |
el17ajf | 8:5066ce13a430 | 32 | lcd->drawLine(x1, y1, x2, y2, 2); |
el17ajf | 8:5066ce13a430 | 33 | } |
el17ajf | 8:5066ce13a430 | 34 | |
el17ajf | 8:5066ce13a430 | 35 | void Graphics::drawBox(int x1, int y1, int x2, int y2) { |
el17ajf | 8:5066ce13a430 | 36 | Graphics::drawLine(x1, y1, x2, y1); |
el17ajf | 8:5066ce13a430 | 37 | Graphics::drawLine(x2, y1, x2, y2); |
el17ajf | 8:5066ce13a430 | 38 | Graphics::drawLine(x2, y2, x1, y2); |
el17ajf | 8:5066ce13a430 | 39 | Graphics::drawLine(x1, y2, x1, y1); |
el17ajf | 8:5066ce13a430 | 40 | } |
el17ajf | 8:5066ce13a430 | 41 | |
el17ajf | 8:5066ce13a430 | 42 | void Graphics::drawBlock(int grid_x, int grid_y) { |
el17ajf | 8:5066ce13a430 | 43 | // TODO |
el17ajf | 8:5066ce13a430 | 44 | int x = grid_x; |
el17ajf | 9:3a7776a29a11 | 45 | int y = grid_y; |
el17ajf | 8:5066ce13a430 | 46 | Graphics::drawBox(x, y, x + 3, y + 3); |
el17ajf | 8:5066ce13a430 | 47 | Graphics::drawPoint(x + 2, y + 2); |
el17ajf | 8:5066ce13a430 | 48 | } |
el17ajf | 8:5066ce13a430 | 49 | |
el17ajf | 8:5066ce13a430 | 50 | void Graphics::drawBorder() { |
el17ajf | 10:5762d7fae033 | 51 | Graphics::drawDottedLine(0, 0, 0, SCREEN_HEIGHT - 1); |
el17ajf | 10:5762d7fae033 | 52 | Graphics::drawDottedLine(1, 1, 1, SCREEN_HEIGHT - 2); |
el17ajf | 5:3efbdcb3efaf | 53 | |
el17ajf | 10:5762d7fae033 | 54 | Graphics::drawDottedLine(0, SCREEN_HEIGHT - 1, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1); |
el17ajf | 10:5762d7fae033 | 55 | Graphics::drawDottedLine(1, SCREEN_HEIGHT - 2, SCREEN_WIDTH - 2, SCREEN_HEIGHT - 2); |
el17ajf | 8:5066ce13a430 | 56 | |
el17ajf | 10:5762d7fae033 | 57 | Graphics::drawDottedLine(SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1, SCREEN_WIDTH - 1, 0); |
el17ajf | 10:5762d7fae033 | 58 | Graphics::drawDottedLine(SCREEN_WIDTH - 2, SCREEN_HEIGHT - 2, SCREEN_WIDTH - 2, 1); |
el17ajf | 5:3efbdcb3efaf | 59 | } |