ELEC2645 (2018/19) / Mbed 2 deprecated el17ajf

Dependencies:   mbed

Fork of el17ajf by Angus Findlay

Revision:
8:5066ce13a430
Parent:
5:3efbdcb3efaf
Child:
9:3a7776a29a11
--- a/Graphics/Graphics.cpp	Fri Mar 15 07:55:23 2019 +0000
+++ b/Graphics/Graphics.cpp	Fri Mar 15 16:39:06 2019 +0000
@@ -1,13 +1,61 @@
 #include "Graphics.h"
 
+void Graphics::init() {
+    lcd = new N5110(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
+    lcd.init();
+    lcd.setContrast(0.4);
+}
+
+void Graphics::deinit() {
+    delete lcd;
+}
+
 void Graphics::update() {
-    
+    // TODO
 }
 
 void Graphics::clear() {
-    
+    // TODO
+    lcd.clear();
 }
 
 void Graphics::render() {
+    // TODO
+}
+
+void Graphics::drawPoint(int x, int y) {
+    lcd->setPixel(x, y, true);
+}
+
+void Graphics::drawLine(int x1, int y1, int x2, int y2) {
+    lcd->drawLine(x1, y1, x2, y2, 1);
+}
+
+void Graphics::drawDottedLine(int x1, int y1, int x2, int y2) {
+    lcd->drawLine(x1, y1, x2, y2, 2);
+}
+
+void Graphics::drawBox(int x1, int y1, int x2, int y2) {
+    Graphics::drawLine(x1, y1, x2, y1);
+    Graphics::drawLine(x2, y1, x2, y2);
+    Graphics::drawLine(x2, y2, x1, y2);
+    Graphics::drawLine(x1, y2, x1, y1);
+}
+
+void Graphics::drawBlock(int grid_x, int grid_y) {
+    // TODO
+    int x = grid_x;
+    Graphics::drawBox(x, y, x + 3, y + 3);
+    Graphics::drawPoint(x + 2, y + 2); 
+}
+
+void Graphics::drawBorder() {
+    Graphics::drawDottedLine(0, 0, 0, HEIGHT - 1);
+    Graphics::drawDottedLine(1, 1, 1, HEIGHT - 2);
     
+    Graphics::drawDottedLine(0, HEIGHT - 1, WIDTH - 1, HEIGHT - 1);
+    Graphics::drawDottedLine(1, HEIGHT - 2, WIDTH - 2, HEIGHT - 2);
+    
+    Graphics::drawDottedLine(WIDTH - 1, HEIGHT - 1, WIDTH - 1, 0);
+    Graphics::drawDottedLine(WIDTH - 2, HEIGHT - 2, WIDTH - 2, 1);
 }
\ No newline at end of file