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: N5110 SDFileSystem mbed
main.h
00001 /** 00002 @file main.h 00003 @brief Header file containing functions prototypes, defines and global variables. 00004 @author John A. C. Richards 00005 @date April 20156 00006 */ 00007 00008 #ifndef MAIN_H 00009 #define MAIN_H 00010 00011 #include "mbed.h" 00012 #include "N5110.h" 00013 #include "string" 00014 #include "SDFileSystem.h" 00015 00016 #define DIRECTION_TOLERANCE 0.05f 00017 #define maxPlayerSize 1000 00018 00019 /** 00020 @namespace red_led 00021 @brief GPIO output for game-over LED 00022 */ 00023 DigitalOut red_led(LED_RED); 00024 00025 /** 00026 @namespace green_led 00027 @brief GPIO output for game-playing LED 00028 */ 00029 DigitalOut green_led(LED_GREEN); 00030 00031 /** 00032 @namespace N5110_lcd 00033 @brief GPIO output for Nokia screen 00034 */ 00035 N5110 lcd (PTE26 , PTA0 , PTC4 , PTD0 , PTD2 , PTD1 , PTC3); 00036 00037 /** 00038 @namespace yellowLED 00039 @brief GPIO output for collision warning 00040 */ 00041 DigitalOut yellowLED(PTA2); 00042 00043 /** 00044 @namespace greenLED 00045 @brief GPIO output for eating food 00046 */ 00047 DigitalOut greenLED(PTC2); 00048 00049 /** 00050 @namespace xPot 00051 @brief GPIO output for joystick in x plane 00052 */ 00053 AnalogIn xPot(PTB2); 00054 00055 /** 00056 @namespace yPot 00057 @brief GPIO output for joystick in y plane 00058 */ 00059 AnalogIn yPot(PTB3); 00060 00061 /** 00062 @namespace buzzer 00063 @brief GPIO output for buzzer 00064 */ 00065 PwmOut buzzer(PTA1); 00066 00067 /** 00068 @namespace volume 00069 @brief GPIO output for potentiometer 00070 */ 00071 AnalogIn volume(PTB10); 00072 00073 00074 /** 00075 @namespace sd 00076 @brief GPIO output for SDcard 00077 */ 00078 SDFileSystem sd(PTE3, PTE1, PTE2, PTE4, "sd"); // MOSI, MISO, SCK, CS 00079 00080 00081 00082 volatile int playerLength ; /*!<length of player*/ 00083 00084 volatile int playerPositionsX [maxPlayerSize]; /*!<max player size x*/ 00085 volatile int playerPositionsY [maxPlayerSize]; /*!<max player size y*/ 00086 00087 volatile int areaWidth = 41; /*!<width of game map*/ 00088 volatile int areaHeight = 19; /*!<height of game map*/ 00089 00090 /** 00091 @brief Sets flag for bringing the next frame 00092 */ 00093 void nextFrame(); //go to next frame function 00094 00095 /** 00096 @brief Sets the bool timerDone as true 00097 */ 00098 void timerTrigger(); //function to set bool as true to be used again 00099 00100 00101 /** 00102 @brief Timeout which keeps the program at one point for a while 00103 @param seconds Time delayed, in seconds 00104 */ 00105 void screenDelay(float seconds); // timeout function 00106 00107 /** 00108 @brief Turns off external green LED 00109 */ 00110 void greenOff (); 00111 00112 00113 /** 00114 @brief Checks is snake has hit wall or self 00115 @param x - set x plane 00116 @param y - set y plane 00117 @returns true or false 00118 */ 00119 bool checkCollision(int x,int y); 00120 00121 /** 00122 @brief read default positions of the joystick to calibrate later readings 00123 */ 00124 void calibrateJoystick(); 00125 00126 /** 00127 @brief read current joystick values relative to calibrated values and calculate direction depending on x,y values 00128 */ 00129 void updateJoystick(); 00130 00131 /** 00132 @brief Contains all of the snake code 00133 */ 00134 void snake(); 00135 00136 00137 00138 00139 00140 00141 00142 00143 00144 00145 00146 00147 00148 00149 00150 00151 00152 00153 00154 00155 00156 00157 00158 00159 #endif
Generated on Thu Jul 14 2022 13:33:05 by
1.7.2