testing documentation
Dependencies: mbed ll16j23s_test_docs
main.cpp
- Committer:
- JoeShotton
- Date:
- 2020-05-23
- Revision:
- 4:ea3fa51c4386
- Parent:
- 3:fcd6d70e9694
- Child:
- 5:06fa7674622a
File content as of revision 4:ea3fa51c4386:
/* ELEC2645 Embedded Systems Project School of Electronic & Electrical Engineering University of Leeds 2019/20 Name: Joe Shotton Username: ll16j23s Student ID Number: 201127267 Date: 4/4/20 */ // includes #include "mbed.h" #include "Gamepad.h" #include "N5110.h" #include "FXOS8700CQ.h" #include "SnakeEngine.h" #include <vector> #include <cstdlib> #define X_MAX 84 #define Y_MAX 48 // objects Gamepad pad; N5110 lcd; SnakeEngine snake; FXOS8700CQ device(I2C_SDA,I2C_SCL); int main() { lcd.init(); pad.init(); float speed = 0.5; int fps = 25; int frame_t = 1000/fps; bool death = false; //int length = 10; //intial snake size //int size_inc = 5; //how much longer the snake gets due to food //int d = 0; //direction starts in centre //int state = 0; //first state is centre of joystick /* Dir fsm[5] = { {0, 0, 0, {0,1,2,3,4}}, // Centred {1, 0, -1, {1,1,2,1,4}}, // North, will not go to centre or south {2, 1, 0, {2,1,2,3,2}}, // East, will not go to centre or west {3, 0, 1, {3,3,2,3,4}}, // South, will not go to centre or north {4, -1, 0, {4,1,4,3,4}} // West, will not go to centre or east }; */ while(death == false){ //printf("Running!"); speed = pad.read_pot2(); lcd.clear(); snake.move_body(pad, lcd, death); lcd.setContrast(0.4); lcd.refresh(); wait_ms(500/(5+snake.score)); } } /* if ((lcd.getPixel(x, y) == 1 && ((state == 1) || (state == 4))) || (lcd.getPixel(x+1, y+1) == 1 && ((state == 2) || (state == 3)))) { // checks infront of head to see if pixel is set // due to the size of the head, there is an offset for the check for North and Eastward directions death = true; pad.led(1,0.9); } else { death = false; pad.led(1,0.0); } */ /* if(pad.B_pressed() == true && length > size_inc) { length -= size_inc; printf("Lenght: %d\n", length); } */ /* body_x.insert(body_x.begin(), x_head); //sets first array element to head coordinates body_y.insert(body_y.begin(), y_head); body_x.erase(body_x.begin()+length); body_y.erase(body_y.begin()+length); */ /* if(pad.A_pressed() == true) { length += size_inc; //printf("Length: %d\n", length); body = new int*[length]; for(int i = length + 1; i < length + size_inc + 1; i++) { body[i] = new int[2]; body[i][0] = X_MAX + 1; //snake body starts outside the screen body[i][1] = 0; } */