![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
f
Dependencies: mbed 4DGL-uLCD-SE MMA8452
main.cpp@2:ca5910acbade, 2022-03-10 (annotated)
- Committer:
- lballard9
- Date:
- Thu Mar 10 05:32:49 2022 +0000
- Revision:
- 2:ca5910acbade
- Parent:
- 1:d57364f0349f
- Child:
- 3:ebf55ea6f18b
removed extraneous comments;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
lballard9 | 0:8e3b9bb1084a | 1 | //================================================================= |
lballard9 | 0:8e3b9bb1084a | 2 | // The main program file. |
lballard9 | 0:8e3b9bb1084a | 3 | // |
lballard9 | 0:8e3b9bb1084a | 4 | // Copyright 2022 Georgia Tech. All rights reserved. |
lballard9 | 0:8e3b9bb1084a | 5 | // The materials provided by the instructor in this course are for |
lballard9 | 0:8e3b9bb1084a | 6 | // the use of the students currently enrolled in the course. |
lballard9 | 0:8e3b9bb1084a | 7 | // Copyrighted course materials may not be further disseminated. |
lballard9 | 0:8e3b9bb1084a | 8 | // This file must not be made publicly available anywhere. |
lballard9 | 0:8e3b9bb1084a | 9 | //================================================================== |
lballard9 | 0:8e3b9bb1084a | 10 | |
lballard9 | 0:8e3b9bb1084a | 11 | // External libs |
lballard9 | 0:8e3b9bb1084a | 12 | #include <stdlib.h> |
lballard9 | 0:8e3b9bb1084a | 13 | |
lballard9 | 0:8e3b9bb1084a | 14 | // Project includes |
lballard9 | 0:8e3b9bb1084a | 15 | #include "globals.h" |
lballard9 | 0:8e3b9bb1084a | 16 | #include "hardware.h" |
lballard9 | 0:8e3b9bb1084a | 17 | #include "graphics.h" |
lballard9 | 0:8e3b9bb1084a | 18 | #include "keyboard.h" |
lballard9 | 1:d57364f0349f | 19 | |
lballard9 | 1:d57364f0349f | 20 | |
lballard9 | 2:ca5910acbade | 21 | //some LED's to use for debugging. |
lballard9 | 1:d57364f0349f | 22 | DigitalOut myled1(LED1); |
lballard9 | 1:d57364f0349f | 23 | DigitalOut myled2(LED2); |
lballard9 | 1:d57364f0349f | 24 | DigitalOut myled3(LED3); |
lballard9 | 1:d57364f0349f | 25 | DigitalOut myled4(LED4); |
lballard9 | 0:8e3b9bb1084a | 26 | |
lballard9 | 0:8e3b9bb1084a | 27 | void set_random_seed(Timer); |
lballard9 | 0:8e3b9bb1084a | 28 | |
lballard9 | 0:8e3b9bb1084a | 29 | /* |
lballard9 | 0:8e3b9bb1084a | 30 | * This function handles the main logic of the game. You should |
lballard9 | 0:8e3b9bb1084a | 31 | * initialize the hardware in this function, make calls to |
lballard9 | 0:8e3b9bb1084a | 32 | * functions that update the keyboard and your guess of |
lballard9 | 0:8e3b9bb1084a | 33 | * the word. |
lballard9 | 0:8e3b9bb1084a | 34 | */ |
lballard9 | 0:8e3b9bb1084a | 35 | int main() |
lballard9 | 0:8e3b9bb1084a | 36 | { |
lballard9 | 1:d57364f0349f | 37 | |
lballard9 | 1:d57364f0349f | 38 | GameInputs inputs; |
lballard9 | 1:d57364f0349f | 39 | // First things first: initialize hardware |
lballard9 | 1:d57364f0349f | 40 | ASSERT_P(hardware_init() == ERROR_NONE, "Hardware init failed!"); |
lballard9 | 1:d57364f0349f | 41 | pc.printf("Program Starting\n"); |
lballard9 | 1:d57364f0349f | 42 | //led1 hardware initialization |
lballard9 | 1:d57364f0349f | 43 | |
lballard9 | 1:d57364f0349f | 44 | myled1=1; |
lballard9 | 1:d57364f0349f | 45 | Timer t; |
lballard9 | 1:d57364f0349f | 46 | int dt; // delta time |
lballard9 | 1:d57364f0349f | 47 | |
lballard9 | 1:d57364f0349f | 48 | /* |
lballard9 | 1:d57364f0349f | 49 | Put your code for main menu here, seed random function here as well |
lballard9 | 1:d57364f0349f | 50 | */ |
lballard9 | 1:d57364f0349f | 51 | |
lballard9 | 1:d57364f0349f | 52 | // initialize the game state, print something to the screen and wait for an input. |
lballard9 | 1:d57364f0349f | 53 | // do that before entering this game loop |
lballard9 | 1:d57364f0349f | 54 | |
lballard9 | 1:d57364f0349f | 55 | while(1){ |
lballard9 | 1:d57364f0349f | 56 | t.start(); //start a timer |
lballard9 | 1:d57364f0349f | 57 | draw_lower_status(); //draw the lower status bar |
lballard9 | 1:d57364f0349f | 58 | inputs = read_inputs(); //read the inputs of the game |
lballard9 | 1:d57364f0349f | 59 | |
lballard9 | 1:d57364f0349f | 60 | |
lballard9 | 1:d57364f0349f | 61 | /* |
lballard9 | 1:d57364f0349f | 62 | your code here, make decisions based on those inputs, update the keyboard |
lballard9 | 1:d57364f0349f | 63 | make selections, update words etc. |
lballard9 | 1:d57364f0349f | 64 | */ |
lballard9 | 1:d57364f0349f | 65 | |
lballard9 | 1:d57364f0349f | 66 | t.stop(); |
lballard9 | 1:d57364f0349f | 67 | dt = t.read_ms(); |
lballard9 | 1:d57364f0349f | 68 | |
lballard9 | 1:d57364f0349f | 69 | } |
lballard9 | 0:8e3b9bb1084a | 70 | } |
lballard9 | 0:8e3b9bb1084a | 71 | |
lballard9 | 1:d57364f0349f | 72 | |
lballard9 | 0:8e3b9bb1084a | 73 | |
lballard9 | 0:8e3b9bb1084a | 74 | /* |
lballard9 | 0:8e3b9bb1084a | 75 | * This function sets the random seed for the game. |
lballard9 | 0:8e3b9bb1084a | 76 | * It also initializes the keyboard. You may choose to |
lballard9 | 0:8e3b9bb1084a | 77 | * put the start screen in here as well. This should be |
lballard9 | 0:8e3b9bb1084a | 78 | * called in the main function above. |
lballard9 | 0:8e3b9bb1084a | 79 | */ |
lballard9 | 0:8e3b9bb1084a | 80 | void set_random_seed(Timer t) { |
lballard9 | 0:8e3b9bb1084a | 81 | |
lballard9 | 0:8e3b9bb1084a | 82 | } |
lballard9 | 0:8e3b9bb1084a | 83 | // ===User implementations end=== |