
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
SDFileSystem/SDFileSystem.h
- Committer:
- el18gs
- Date:
- 2020-05-26
- Revision:
- 17:3ebcf7bba112
- Parent:
- 2:eaf245af2aae
File content as of revision 17:3ebcf7bba112:
/* SD/MMC File System Library * Copyright (c) 2016 Neil Thiessen * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef SD_FILE_SYSTEM_H #define SD_FILE_SYSTEM_H #include "mbed.h" #include "FATFileSystem.h" /** SDFileSystem class. * Used for creating a virtual file system for accessing SD/MMC cards via SPI. * * Example: * @code * #include "mbed.h" * #include "SDFileSystem.h" * * //Create an SDFileSystem object * SDFileSystem sd(p5, p6, p7, p20, "sd"); * * int main() * { * //Mount the filesystem * sd.mount(); * * //Perform a write test * printf("\nWriting to SD card..."); * FILE *fp = fopen("/sd/sdtest.txt", "w"); * if (fp != NULL) { * fprintf(fp, "We're writing to an SD card!"); * fclose(fp); * printf("success!\n"); * } else { * printf("failed!\n"); * } * * //Perform a read test * printf("Reading from SD card..."); * fp = fopen("/sd/sdtest.txt", "r"); * if (fp != NULL) { * char c = fgetc(fp); * if (c == 'W') * printf("success!\n"); * else * printf("incorrect char (%c)!\n", c); * fclose(fp); * } else { * printf("failed!\n"); * } * * //Unmount the filesystem * sd.unmount(); * } * @endcode */ class SDFileSystem : public FATFileSystem { public: /** Represents the different card detect switch types */ enum SwitchType { SWITCH_NONE, /**< No card detect switch (assumes socket is always occupied) */ SWITCH_POS_NO, /**< Switch shorts to VDD when the socket is occupied (positive logic, normally open) */ SWITCH_POS_NC, /**< Switch shorts to VDD when the socket is empty (positive logic, normally closed) */ SWITCH_NEG_NO, /**< Switch shorts to GND when the socket is occupied (negative logic, normally open) */ SWITCH_NEG_NC /**< Switch shorts to GND when the socket is empty (negative logic, normally closed) */ }; /** Represents the different SD/MMC card types */ enum CardType { CARD_NONE, /**< No card is present */ CARD_MMC, /**< MMC card */ CARD_SD, /**< Standard capacity SD card */ CARD_SDHC, /**< High capacity SD card */ CARD_UNKNOWN /**< Unknown or unsupported card */ }; /** Create a virtual file system for accessing SD/MMC cards via SPI * * @param mosi The SPI data out pin. * @param miso The SPI data in pin. * @param sclk The SPI clock pin. * @param cs The SPI chip select pin. * @param name The name used to access the virtual filesystem. * @param cd The card detect pin. * @param cdtype The type of card detect switch. * @param hz The SPI bus frequency (defaults to 1MHz). */ SDFileSystem(PinName mosi, PinName miso, PinName sclk, PinName cs, const char* name, PinName cd = NC, SwitchType cdtype = SWITCH_NONE, int hz = 1000000); /** Determine whether or not a card is present * * @returns * 'true' if a card is present, * 'false' if no card is present. */ bool card_present(); /** Get the detected SD/MMC card type * * @returns The detected card type as a CardType enum. * * @note Valid after the filesystem has been mounted. */ SDFileSystem::CardType card_type(); /** Get whether or not CRC is enabled for commands and data * * @returns * 'true' if CRC is enabled for commands and data, * 'false' if CRC is disabled for commands and data. */ bool crc(); /** Set whether or not CRC is enabled for commands and data * * @param enabled Whether or not to enable CRC for commands and data. */ void crc(bool enabled); /** Get whether or not 16-bit frames are enabled for data read/write operations * * @returns * 'true' if 16-bit frames will be used during data read/write operations, * 'false' if 8-bit frames will be used during data read/write operations. */ bool large_frames(); /** Set whether or not 16-bit frames are enabled for data read/write operations * * @param enabled Whether or not 16-bit frames are enabled for data read/write operations. */ void large_frames(bool enabled); /** Get whether or not write validation is enabled for data write operations * * @returns * 'true' if data writes will be verified using CMD13, * 'false' if data writes will not be verified. */ bool write_validation(); /** Set whether or not write validation is enabled for data write operations * * @param enabled Whether or not write validation is enabled for data write operations. */ void write_validation(bool enabled); virtual int unmount(); virtual int disk_initialize(); virtual int disk_status(); virtual int disk_read(uint8_t* buffer, uint32_t sector, uint32_t count); virtual int disk_write(const uint8_t* buffer, uint32_t sector, uint32_t count); virtual int disk_sync(); virtual uint32_t disk_sectors(); private: //Commands enum Command { CMD0 = (0x40 | 0), /**< GO_IDLE_STATE */ CMD1 = (0x40 | 1), /**< SEND_OP_COND */ CMD6 = (0x40 | 6), /**< SWITCH_FUNC */ CMD8 = (0x40 | 8), /**< SEND_IF_COND */ CMD9 = (0x40 | 9), /**< SEND_CSD */ CMD12 = (0x40 | 12), /**< STOP_TRANSMISSION */ CMD13 = (0x40 | 13), /**< SEND_STATUS */ CMD16 = (0x40 | 16), /**< SET_BLOCKLEN */ CMD17 = (0x40 | 17), /**< READ_SINGLE_BLOCK */ CMD18 = (0x40 | 18), /**< READ_MULTIPLE_BLOCK */ ACMD22 = (0x40 | 22), /**< SEND_NUM_WR_BLOCKS */ ACMD23 = (0x40 | 23), /**< SET_WR_BLK_ERASE_COUNT */ CMD24 = (0x40 | 24), /**< WRITE_BLOCK */ CMD25 = (0x40 | 25), /**< WRITE_MULTIPLE_BLOCK */ ACMD41 = (0x40 | 41), /**< SD_SEND_OP_COND */ ACMD42 = (0x40 | 42), /**< SET_CLR_CARD_DETECT */ CMD55 = (0x40 | 55), /**< APP_CMD */ CMD58 = (0x40 | 58), /**< READ_OCR */ CMD59 = (0x40 | 59) /**< CRC_ON_OFF */ }; //Member variables Timer m_Timer; SPI m_Spi; DigitalOut m_Cs; InterruptIn m_Cd; int m_CdAssert; const int m_FREQ; SDFileSystem::CardType m_CardType; bool m_Crc; bool m_LargeFrames; bool m_WriteValidation; int m_Status; //Internal methods void onCardRemoval(); void checkSocket(); bool waitReady(int timeout); bool select(); void deselect(); char commandTransaction(char cmd, unsigned int arg, unsigned int* resp = NULL); char writeCommand(char cmd, unsigned int arg, unsigned int* resp = NULL); bool readData(char* buffer, int length); char writeData(const char* buffer, char token); bool readBlock(char* buffer, unsigned int lba); bool readBlocks(char* buffer, unsigned int lba, unsigned int count); bool writeBlock(const char* buffer, unsigned int lba); bool writeBlocks(const char* buffer, unsigned int lba, unsigned int count); bool enableHighSpeedMode(); }; #endif