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
Diff: main.cpp
- Revision:
- 4:759a5c34e239
- Parent:
- 3:2e31dfcb712a
- Child:
- 5:54d3b36fec2c
--- a/main.cpp Fri Feb 22 14:01:20 2019 +0000
+++ b/main.cpp Fri Feb 22 19:05:28 2019 +0000
@@ -10,72 +10,27 @@
#include "mbed.h"
#include <vector>
+#ifndef FACE_H
+#define FACE_H
#include "Face.h"
+#endif
+#include "Rasturizer.h"
+#include "Cube.h"
-#include "N5110.h"
-N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
int main()
{
- float p[4][3] = {{1,0,0},{0,0,0},{0,0,0},{0,0,0}};
- char buffer[50];
- Face f(p);
- int n=sprintf (buffer, "%f", f.GetVertexValue(0,0));
-
-
- lcd.init();
-
+ Rasturizer renderer;
+ Cube cube(30,30, 1,10);
+ int i = 0;
while(1) {
- lcd.clear();
- for(int i = 0; i<5; i++){
- float points[4][2] = {{rand()%20,rand()%20},{20+rand()%20, rand()%20}, {20+rand()%20,20+rand()%20}, {rand()%20,20+rand()%20}};
-
- float length = sqrt(pow((double)(points[0][0]-points[1][0]),2.0) + pow((double)(points[0][1]-points[1][1]),2));
- float length1 = sqrt(pow((double)(points[2][0]-points[3][0]),2.0) + pow((double)(points[2][1]-points[3][1]),2));
-
- int diffX1 = points[0][0]-points[1][0];
- int diffY1 = points[0][1]-points[1][1];
- int diffX2 = points[2][0]-points[3][0];
- int diffY2 = points[2][1]-points[3][1];
-
- if (abs(diffX1) > abs(diffX2)){
-
- float step = (float)diffY1/(float)diffX1;
- float stepSmall1 = (float)diffX2/(float)diffX1;
- float stepSmall2 = (float)diffY2/(float)diffX1;
- lcd.printString(buffer,0,0);
- for(int s = 0; s<= abs(diffX1)-1; s++){
- lcd.drawLine(points[0][0]+s, rint(points[0][1]+step*s), rint(points[3][0]-stepSmall1*s), rint(points[3][1]-stepSmall2*s), 0);
- lcd.drawLine(points[0][0]+s+1, rint(points[0][1]+step*s), rint(points[3][0]-stepSmall1*s-1), rint(points[3][1]-stepSmall2*s), 0);
- }
- lcd.printString("a",10,0);
- }
- else{
- lcd.printString(buffer,0,0);
- float step = (float)diffY2/(float)diffX2;
- float stepSmall1 = (float)diffX1/(float)diffX2;
- float stepSmall2 = (float)diffY1/(float)diffX2;
-
- for(int s = 0; s<= abs(diffX2)-1; s++){
- lcd.drawLine(points[0][0]-stepSmall1*s, rint(points[0][1]-stepSmall2*s),rint(points[3][0]+s), rint(points[3][1]+step*s), 0);
- lcd.drawLine(points[0][0]-stepSmall1*s-1, rint(points[0][1]-stepSmall2*s),rint(points[3][0]+s+1), rint(points[3][1]+step*s), 0);
- }
- }
- for (int i = 0; i < 3; i++){
- lcd.drawLine(points[i][0],
- points[i][1],
- points[i+1][0],
- points[i+1][1],
- 1);
- }
- lcd.drawLine(points[0][0],
- points[0][1],
- points[3][0],
- points[3][1],
- 1);
- }
- lcd.refresh(); // refresh the LCD so the pixels appear
+ renderer.clear();
+ if (i == 6)
+ i = 0;
+ renderer.drawFace(cube.getFace(i));
+ renderer.refresh(); // refresh the LCD so the pixels appear
wait_ms(1000/1); // this gives a refresh rate of 10 frames per second
+ i++;
}
}
\ No newline at end of file