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
Diff: Graphics/Graphics.cpp
- Revision:
- 11:fba7d54fd36b
- Parent:
- 10:5762d7fae033
- Child:
- 12:beb0d7632531
--- a/Graphics/Graphics.cpp Fri Mar 15 21:16:39 2019 +0000 +++ b/Graphics/Graphics.cpp Sun Mar 17 10:55:11 2019 +0000 @@ -5,7 +5,7 @@ void Graphics::init() { lcd = new N5110(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); lcd->init(); - lcd->setContrast(0.4); + lcd->setContrast(0.5); } void Graphics::deinit() { @@ -29,7 +29,13 @@ } void Graphics::drawDottedLine(int x1, int y1, int x2, int y2) { - lcd->drawLine(x1, y1, x2, y2, 2); + lcd->drawLine( + y1, + x1, + y2, + x2, + 2 // dotted + ); } void Graphics::drawBox(int x1, int y1, int x2, int y2) { @@ -40,11 +46,11 @@ } void Graphics::drawBlock(int grid_x, int grid_y) { - // TODO - int x = grid_x; - int y = grid_y; - Graphics::drawBox(x, y, x + 3, y + 3); - Graphics::drawPoint(x + 2, y + 2); + // screen coords + int x = gridYToScreenX(grid_y); + int y = gridXToScreenY(grid_x); + Graphics::drawBox(x, y, x + 3, y - 3); + Graphics::drawPoint(x + 2, y - 2); } void Graphics::drawBorder() { @@ -56,4 +62,12 @@ Graphics::drawDottedLine(SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1, SCREEN_WIDTH - 1, 0); Graphics::drawDottedLine(SCREEN_WIDTH - 2, SCREEN_HEIGHT - 2, SCREEN_WIDTH - 2, 1); -} \ No newline at end of file +} + +int Graphics::gridYToScreenX(int grid_y) { + return grid_y * BLOCK_SIZE + BORDER_SIZE; +} + +int Graphics::gridXToScreenY(int grid_x) { + return SCREEN_WIDTH - (grid_x * BLOCK_SIZE) - BORDER_SIZE; +}