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.
main.cpp
00001 /* 00002 ELEC2645 Embedded Systems Project 00003 School of Electronic & Electrical Engineering 00004 University of Leeds 00005 2019/20 00006 00007 Name:Joe Body 00008 Username:el18jgb 00009 Student ID Number:201215898 00010 Date:11/03/2020 00011 */ 00012 00013 // includes 00014 #include "mbed.h" 00015 #include "Gamepad.h" 00016 #include "N5110.h" 00017 #include "Aim.h" 00018 #include "Heston.h" 00019 #include "Eng.h" 00020 00021 00022 // objects 00023 Gamepad pad; 00024 N5110 lcd; 00025 00026 Eng eng; 00027 00028 00029 // flag - must be volatile as changes within ISR 00030 // g_ prefix makes it easier to distinguish it as global 00031 volatile int g_timer_flag = 0; 00032 00033 // function prototypes 00034 void timer_isr(); 00035 00036 00037 void init(); 00038 void render(); 00039 //void draw(N5110 &lcd); 00040 //void read_input(Gamepad &pad); 00041 00042 int main() 00043 { 00044 int fps = 10; // frames per second 00045 int A_timer = 0; 00046 init(); // initialise and then display welcome screen... 00047 00048 render(); // first draw the initial frame 00049 wait(1.0f/fps); // and wait for one frame period 00050 while (1) { 00051 //read_input(pad); 00052 int fire = 0; 00053 if (A_timer <= 0){ 00054 fire = 0; 00055 if (pad.A_held()){ 00056 fire = 1; 00057 A_timer = 6; 00058 } 00059 } 00060 00061 00062 eng.update(pad, fire, lcd); 00063 render(); 00064 wait(1.0f/fps); 00065 00066 A_timer--; 00067 00068 eng.tik(); 00069 } 00070 00071 } 00072 00073 // initialies all classes and libraries 00074 void init() 00075 { 00076 // need to initialise LCD and Gamepad 00077 lcd.init(); 00078 pad.init(); 00079 00080 eng.init(); 00081 00082 } 00083 00084 // this function draws each frame on the LCD 00085 void render() 00086 { 00087 // clear screen, re-draw and refresh 00088 lcd.clear(); 00089 00090 eng.draw(lcd); 00091 lcd.refresh(); 00092 } 00093 00094 //void read_input(Gamepad &pad) 00095 //{ 00096 //int _d = pad.get_direction(); 00097 //float _mag = pad.get_mag(); 00098 //}
Generated on Wed Jul 13 2022 05:56:35 by
1.7.2