
George Sykes ELEC2645 project
Dependencies: mbed
GHOST HUNTER
In a world of ghostly horrors there is much money to be made in underground ghost fighting rings. You've managed to get hold of a Ghostbuster, a special piece of equipment that allows you to catch, train and fight ghosts.
Instructions
Below you will find the instructions for the game. Please note that due to COVID-19 a large part of the game (fighting ghosts) could not be added as it would have required access to a second gamepad which i could not acquire.
Welcome screen
When first started you will be presented with a welcome screen
- Pot 1 to adjust the contrast on the screen
- Press A to continue.
Main menu
You have three options, catch ghosts (add ghosts to your inventory), inventory (sell ghosts) or settings(adjust the games settings).
- Press X and B to move the selection up and down respectively
- Press A to enter the selected submenu
Catch Ghost
Will now be presented with two challenges. In the first you need to find a ghost, in the second you catch it. Theses stages will start automatically.
Find ghost
Rotate the gamepad on its roll and pitch axis until all the LED's turn on. The ones on the left indicate roll and the right pitch.
- Rotate the gamepad on it roll and pitch to light up the LED's
Catch ghost
Return the gamepad to a comfortable position and use the joystick to move the crosshairs onto the ghost sprite. When ready press the A button to catch the ghost. You will be told what kind of ghost you have captured and it will be added to your inventory.
- Press A to catch the ghost
- Move the joystick to move the crosshairs
Inventory
The inventory allows you to view your ghosts and sell them.
- Use Pot 1 to scroll through the ghosts
- Pot 2 to scroll up and down the details of the individual ghosts
- Press X to prepare to sell a ghost and press again to confirm, if you don't press again the sale screen will disappear after 5 seconds
- Press Start to return to the main menu
Settings
This menu allows you to adjust some of the settings of the game.
- Press X to go up one option
- Press B to go down one option
- Press A to enter the selected submenu
- Press Start to return to the main menu
Contrast
Set the contrast of the LCD screen, the contrast will adjust on this screen so you can see the effect (contrast is bounded between 0.4 and 0.6).
- Pot 1 to increase or decrease the contrast
- Press A to set the contrast
Button Delay
Set the minimum time between button presses; if this is too low the game will detect two button presses when there was only one, too high and the buttons will seem unresponsive. So as to ensure these issues do not occur while changing the setting button X temporarily operates on the new delay but none of the others will until A is pressed.
- Pot 1 to increase or decrease the delay
- Press X to test the new delay, this will toggle the small circle to be filled in or unfilled
- Press A to save the setting
FX0S8700CQ/FX0S8700CQ.h@17:3ebcf7bba112, 2020-05-26 (annotated)
- Committer:
- el18gs
- Date:
- Tue May 26 13:37:32 2020 +0000
- Revision:
- 17:3ebcf7bba112
- Parent:
- 13:3b2a4e14937b
Final Submission. I have read and agreed with Statement of Academic Integrity.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
el18gs | 12:8666cd2c6201 | 1 | /** @file FX0S8700CQ.h |
el18gs | 12:8666cd2c6201 | 2 | * @brief Library to interface with the FX0S8700CQ magnetometer |
el18gs | 12:8666cd2c6201 | 3 | */ |
el18gs | 12:8666cd2c6201 | 4 | |
el18gs | 2:eaf245af2aae | 5 | // Protect library from being imported twice |
el18gs | 2:eaf245af2aae | 6 | #ifndef FX0S8700CQ_H |
el18gs | 2:eaf245af2aae | 7 | #define FX0S8700CQ_H |
el18gs | 2:eaf245af2aae | 8 | |
el18gs | 2:eaf245af2aae | 9 | #include "mbed.h" |
el18gs | 2:eaf245af2aae | 10 | #include <math.h> |
el18gs | 2:eaf245af2aae | 11 | |
el18gs | 2:eaf245af2aae | 12 | // Define symbols used throughout class |
el18gs | 2:eaf245af2aae | 13 | #define FAST 1 |
el18gs | 2:eaf245af2aae | 14 | #define NORMAL 0 |
el18gs | 2:eaf245af2aae | 15 | #define WRITE 0 |
el18gs | 2:eaf245af2aae | 16 | |
el18gs | 12:8666cd2c6201 | 17 | /** Struct to handle data */ |
el18gs | 2:eaf245af2aae | 18 | struct Data |
el18gs | 2:eaf245af2aae | 19 | { |
el18gs | 12:8666cd2c6201 | 20 | float ax; /**< Acceleration in the X axis */ |
el18gs | 12:8666cd2c6201 | 21 | float ay; /**< Acceleration in the Y axis */ |
el18gs | 12:8666cd2c6201 | 22 | float az; /**< Acceleration in the Z axis */ |
el18gs | 2:eaf245af2aae | 23 | |
el18gs | 12:8666cd2c6201 | 24 | float mx; /**< Magnetisim in the X axis */ |
el18gs | 12:8666cd2c6201 | 25 | float my; /**< Magnetisim in the X axis */ |
el18gs | 12:8666cd2c6201 | 26 | float mz; /**< Magnetisim in the X axis */ |
el18gs | 2:eaf245af2aae | 27 | |
el18gs | 12:8666cd2c6201 | 28 | float roll; /**< Roll in radians*/ |
el18gs | 12:8666cd2c6201 | 29 | float pitch; /**< Pitch in radians */ |
el18gs | 12:8666cd2c6201 | 30 | float yaw; /**< Yaw in radians */ |
el18gs | 2:eaf245af2aae | 31 | }; |
el18gs | 2:eaf245af2aae | 32 | |
el18gs | 12:8666cd2c6201 | 33 | |
el18gs | 12:8666cd2c6201 | 34 | /** FX0S8700CQ Class |
el18gs | 12:8666cd2c6201 | 35 | * @brief Class used to represent the interface |
el18gs | 12:8666cd2c6201 | 36 | * @author George Sykes [el18gs] |
el18gs | 12:8666cd2c6201 | 37 | * @date 12 May 2020 |
el18gs | 12:8666cd2c6201 | 38 | * @version 1.1 |
el18gs | 12:8666cd2c6201 | 39 | */ |
el18gs | 2:eaf245af2aae | 40 | class FX0S8700CQ |
el18gs | 2:eaf245af2aae | 41 | { |
el18gs | 12:8666cd2c6201 | 42 | /** This class manages one FX08700CQ sensor |
el18gs | 12:8666cd2c6201 | 43 | * @TODO Calibration sequences |
el18gs | 12:8666cd2c6201 | 44 | * @TODO Temperature sensor |
el18gs | 12:8666cd2c6201 | 45 | * @TODO Drop detection |
el18gs | 12:8666cd2c6201 | 46 | * @TODO Pulse detection |
el18gs | 12:8666cd2c6201 | 47 | * @TODO Sleep mode |
el18gs | 12:8666cd2c6201 | 48 | * @TODO Wake on pickup |
el18gs | 12:8666cd2c6201 | 49 | */ |
el18gs | 2:eaf245af2aae | 50 | public: |
el18gs | 12:8666cd2c6201 | 51 | /** This is the default constructor and sets up the I2C interface |
el18gs | 12:8666cd2c6201 | 52 | * @param address this defines what adress the sensor should has, default value 0x1D |
el18gs | 12:8666cd2c6201 | 53 | * @param speed The I2C standard speed to use, options are FAST or NORMAL default is FAST |
el18gs | 12:8666cd2c6201 | 54 | * @param auto_update whether the gather data program should be automatically run at intervals default is false |
el18gs | 12:8666cd2c6201 | 55 | * @param period how frequently should the data be automatically updated in ms, default 10 ms |
el18gs | 12:8666cd2c6201 | 56 | * @param magn_info whether to collect magnitude info, defualt true |
el18gs | 12:8666cd2c6201 | 57 | * @param SDA_pin what pin will is the Serial Data pin, defualts to I2C_SDA |
el18gs | 12:8666cd2c6201 | 58 | * @param SCL_pin what pin will is the clock pin, defualts to I2C_SCL |
el18gs | 12:8666cd2c6201 | 59 | */ |
el18gs | 2:eaf245af2aae | 60 | FX0S8700CQ(char address = 0x1D, |
el18gs | 2:eaf245af2aae | 61 | int speed = FAST, |
el18gs | 2:eaf245af2aae | 62 | bool auto_update = false, |
el18gs | 2:eaf245af2aae | 63 | int period = 10, |
el18gs | 2:eaf245af2aae | 64 | bool mag_info = true, |
el18gs | 2:eaf245af2aae | 65 | PinName sda = I2C_SDA, |
el18gs | 2:eaf245af2aae | 66 | PinName scl = I2C_SCL); |
el18gs | 2:eaf245af2aae | 67 | |
el18gs | 12:8666cd2c6201 | 68 | /** Destructor function to call once the object falls out of scope */ |
el18gs | 2:eaf245af2aae | 69 | ~FX0S8700CQ(); |
el18gs | 12:8666cd2c6201 | 70 | |
el18gs | 2:eaf245af2aae | 71 | // This function is used to write values to the sensors register |
el18gs | 12:8666cd2c6201 | 72 | /** Write a value to an adress in the chips register |
el18gs | 12:8666cd2c6201 | 73 | * @param address what register to write too |
el18gs | 12:8666cd2c6201 | 74 | * @param value what value to write into the register |
el18gs | 12:8666cd2c6201 | 75 | * @return a bool, true if successful else false |
el18gs | 12:8666cd2c6201 | 76 | */ |
el18gs | 2:eaf245af2aae | 77 | bool write_register(char address, char value); |
el18gs | 2:eaf245af2aae | 78 | |
el18gs | 2:eaf245af2aae | 79 | // This function is used to read values from the sensors register |
el18gs | 12:8666cd2c6201 | 80 | /** Read from an address in chips registers for an number of bytes |
el18gs | 12:8666cd2c6201 | 81 | * @param reg the address of the register to read from |
el18gs | 12:8666cd2c6201 | 82 | * @param num_bytes how many bytes to read out of memory |
el18gs | 12:8666cd2c6201 | 83 | * @param bytes where to store the data after its been recieved |
el18gs | 12:8666cd2c6201 | 84 | */ |
el18gs | 2:eaf245af2aae | 85 | void read_register(char reg, int num_bytes, char bytes[]); |
el18gs | 2:eaf245af2aae | 86 | |
el18gs | 12:8666cd2c6201 | 87 | /** This function reads Data from the sensor and stores it */ |
el18gs | 2:eaf245af2aae | 88 | void read_data(); |
el18gs | 2:eaf245af2aae | 89 | |
el18gs | 12:8666cd2c6201 | 90 | /** @var Data sensor |
el18gs | 12:8666cd2c6201 | 91 | * Stores the sensor data in a struct |
el18gs | 12:8666cd2c6201 | 92 | */ |
el18gs | 2:eaf245af2aae | 93 | Data sensor; |
el18gs | 2:eaf245af2aae | 94 | |
el18gs | 2:eaf245af2aae | 95 | private: |
el18gs | 2:eaf245af2aae | 96 | char _address; |
el18gs | 2:eaf245af2aae | 97 | |
el18gs | 2:eaf245af2aae | 98 | // Ticker interupt object to retrieve new sensor Data |
el18gs | 2:eaf245af2aae | 99 | Ticker _tick_read; |
el18gs | 2:eaf245af2aae | 100 | void _tick_service(); |
el18gs | 2:eaf245af2aae | 101 | |
el18gs | 2:eaf245af2aae | 102 | // I2C interface object |
el18gs | 2:eaf245af2aae | 103 | I2C* _i2c; |
el18gs | 2:eaf245af2aae | 104 | |
el18gs | 2:eaf245af2aae | 105 | void accel_calibration(); |
el18gs | 2:eaf245af2aae | 106 | |
el18gs | 2:eaf245af2aae | 107 | }; |
el18gs | 2:eaf245af2aae | 108 | |
el18gs | 2:eaf245af2aae | 109 | #endif |