![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
First Draft, serial print change based on distance
main.h@10:be53044119d1, 2022-02-01 (annotated)
- Committer:
- liam94
- Date:
- Tue Feb 01 23:10:26 2022 +0000
- Revision:
- 10:be53044119d1
- Parent:
- 9:ada61082bbaa
- Child:
- 11:5a895d966a3e
sorted sensed object and array comparison for first object, added in text on display if object has been detected and what object it is.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
liam94 | 8:7e48229d678c | 1 | #ifndef main_H |
liam94 | 8:7e48229d678c | 2 | #define main_H |
liam94 | 5:98845ccaaacd | 3 | |
liam94 | 8:7e48229d678c | 4 | /***************************************************************************//** |
liam94 | 8:7e48229d678c | 5 | * |
liam94 | 8:7e48229d678c | 6 | * @author Liam Cox |
liam94 | 8:7e48229d678c | 7 | * @date January 2022 |
liam94 | 8:7e48229d678c | 8 | * |
liam94 | 8:7e48229d678c | 9 | * @brief This is the header section for my main code, it includes all the inputs, |
liam94 | 8:7e48229d678c | 10 | * outputs and member functions that will be used in the main source code |
liam94 | 8:7e48229d678c | 11 | * file |
liam94 | 8:7e48229d678c | 12 | * |
liam94 | 8:7e48229d678c | 13 | *******************************************************************************/ |
liam94 | 8:7e48229d678c | 14 | |
liam94 | 5:98845ccaaacd | 15 | #include "mbed.h" |
liam94 | 5:98845ccaaacd | 16 | #include "N5110.h" |
liam94 | 8:7e48229d678c | 17 | #include "Joystick.h" |
liam94 | 8:7e48229d678c | 18 | #include "ultrasonic.h" |
liam94 | 5:98845ccaaacd | 19 | |
liam94 | 8:7e48229d678c | 20 | /***************************************************************************//** |
liam94 | 8:7e48229d678c | 21 | * |
liam94 | 8:7e48229d678c | 22 | * below I have defined the inputs and outputs on the PCB, this includes all the |
liam94 | 8:7e48229d678c | 23 | * push buttons that have been defined as interrupts, the LEDs that have been |
liam94 | 8:7e48229d678c | 24 | * defined in a Bus output for ease of use, the LCD output pins VCC,SCE,RST,D/C, |
liam94 | 8:7e48229d678c | 25 | * MOSI,SCLK,LED and the joystick y-coordinate x-coordinate and button. |
liam94 | 8:7e48229d678c | 26 | * |
liam94 | 8:7e48229d678c | 27 | *******************************************************************************/ |
liam94 | 8:7e48229d678c | 28 | |
liam94 | 5:98845ccaaacd | 29 | InterruptIn L(PTB18); |
liam94 | 5:98845ccaaacd | 30 | InterruptIn R(PTB3); |
liam94 | 5:98845ccaaacd | 31 | InterruptIn Start(PTC5); |
liam94 | 5:98845ccaaacd | 32 | InterruptIn Back(PTB19); |
liam94 | 5:98845ccaaacd | 33 | |
liam94 | 5:98845ccaaacd | 34 | BusOut output(PTA1,PTA2,PTC2,PTC3,PTC4,PTD3); |
liam94 | 5:98845ccaaacd | 35 | |
liam94 | 8:7e48229d678c | 36 | N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); |
liam94 | 5:98845ccaaacd | 37 | |
liam94 | 5:98845ccaaacd | 38 | Joystick joystick(PTB10,PTB11,PTC16); |
liam94 | 5:98845ccaaacd | 39 | |
liam94 | 8:7e48229d678c | 40 | /***************************************************************************//** |
liam94 | 8:7e48229d678c | 41 | * |
liam94 | 8:7e48229d678c | 42 | * below is array of states for the LEDs in the FSM, states have been defined in |
liam94 | 8:7e48229d678c | 43 | * binary for ease of use, 0 is LED on, 1 is LED off so only one LED is on in any |
liam94 | 8:7e48229d678c | 44 | * state. the member functions that are to be used in the main source code file |
liam94 | 8:7e48229d678c | 45 | * have also been defined and the ultrasonice sensor trigger and echo pin have |
liam94 | 8:7e48229d678c | 46 | * been defined, it updates every .5 seconds and a timeout after 1 second and call |
liam94 | 8:7e48229d678c | 47 | * the function dist when the distance changes. |
liam94 | 8:7e48229d678c | 48 | * |
liam94 | 8:7e48229d678c | 49 | *******************************************************************************/ |
liam94 | 5:98845ccaaacd | 50 | |
liam94 | 10:be53044119d1 | 51 | int glass[] = {180,180,180,180,180,180}; //array for first object (pint glass) |
liam94 | 9:ada61082bbaa | 52 | |
liam94 | 6:18a4dd77057e | 53 | int fsm[6] = {0b111110, 0b111101, 0b111011, 0b110111, 0b101111, 0b011111}; |
liam94 | 5:98845ccaaacd | 54 | |
liam94 | 8:7e48229d678c | 55 | volatile int Start_flag, Back_flag; |
liam94 | 8:7e48229d678c | 56 | |
liam94 | 5:98845ccaaacd | 57 | void init_display(); |
liam94 | 5:98845ccaaacd | 58 | |
liam94 | 5:98845ccaaacd | 59 | void main_menu(); |
liam94 | 5:98845ccaaacd | 60 | |
liam94 | 5:98845ccaaacd | 61 | void sense_object(); |
liam94 | 5:98845ccaaacd | 62 | |
liam94 | 5:98845ccaaacd | 63 | void Start_isr(); |
liam94 | 5:98845ccaaacd | 64 | |
liam94 | 5:98845ccaaacd | 65 | void Back_isr(); |
liam94 | 5:98845ccaaacd | 66 | |
liam94 | 6:18a4dd77057e | 67 | void calibrate_object(); |
liam94 | 6:18a4dd77057e | 68 | |
liam94 | 7:7464fbb0f3e1 | 69 | void dist(int distance); |
liam94 | 7:7464fbb0f3e1 | 70 | |
liam94 | 9:ada61082bbaa | 71 | void object_sense1(); |
liam94 | 9:ada61082bbaa | 72 | |
liam94 | 9:ada61082bbaa | 73 | void object_sense2(); |
liam94 | 9:ada61082bbaa | 74 | |
liam94 | 9:ada61082bbaa | 75 | void object_sense3(); |
liam94 | 9:ada61082bbaa | 76 | |
liam94 | 9:ada61082bbaa | 77 | void object_sense4(); |
liam94 | 9:ada61082bbaa | 78 | |
liam94 | 9:ada61082bbaa | 79 | void object_sense5(); |
liam94 | 9:ada61082bbaa | 80 | |
liam94 | 9:ada61082bbaa | 81 | void object_sense6(); |
liam94 | 9:ada61082bbaa | 82 | |
liam94 | 10:be53044119d1 | 83 | void object_detection(); |
liam94 | 10:be53044119d1 | 84 | |
liam94 | 8:7e48229d678c | 85 | ultrasonic mu(PTD0, PTC12, .5, 1, &dist); |
liam94 | 8:7e48229d678c | 86 | |
liam94 | 9:ada61082bbaa | 87 | int sense; |
liam94 | 9:ada61082bbaa | 88 | |
liam94 | 10:be53044119d1 | 89 | int Distance1; |
liam94 | 9:ada61082bbaa | 90 | |
liam94 | 10:be53044119d1 | 91 | int Distance2; |
liam94 | 9:ada61082bbaa | 92 | |
liam94 | 10:be53044119d1 | 93 | int Distance3; |
liam94 | 9:ada61082bbaa | 94 | |
liam94 | 10:be53044119d1 | 95 | int Distance4; |
liam94 | 9:ada61082bbaa | 96 | |
liam94 | 10:be53044119d1 | 97 | int Distance5; |
liam94 | 9:ada61082bbaa | 98 | |
liam94 | 10:be53044119d1 | 99 | int Distance6; |
liam94 | 8:7e48229d678c | 100 | #endif |