![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
First Draft, serial print change based on distance
Diff: main.h
- Revision:
- 8:7e48229d678c
- Parent:
- 7:7464fbb0f3e1
- Child:
- 9:ada61082bbaa
diff -r 7464fbb0f3e1 -r 7e48229d678c main.h --- a/main.h Wed Jan 26 23:08:24 2022 +0000 +++ b/main.h Fri Jan 28 13:01:19 2022 +0000 @@ -1,28 +1,57 @@ +#ifndef main_H +#define main_H +/***************************************************************************//** +* +* @author Liam Cox +* @date January 2022 +* +* @brief This is the header section for my main code, it includes all the inputs, +* outputs and member functions that will be used in the main source code +* file +* +*******************************************************************************/ + #include "mbed.h" #include "N5110.h" +#include "Joystick.h" +#include "ultrasonic.h" -// added R and L buttons presses in so that the user has to press when they are ready to rotate object and in which direction +/***************************************************************************//** +* +* below I have defined the inputs and outputs on the PCB, this includes all the +* push buttons that have been defined as interrupts, the LEDs that have been +* defined in a Bus output for ease of use, the LCD output pins VCC,SCE,RST,D/C, +* MOSI,SCLK,LED and the joystick y-coordinate x-coordinate and button. +* +*******************************************************************************/ + InterruptIn L(PTB18); InterruptIn R(PTB3); InterruptIn Start(PTC5); InterruptIn Back(PTB19); -// LEDs on PCB to be connected (1 to 6) - active-low 0 = on and 1 = off BusOut output(PTA1,PTA2,PTC2,PTC3,PTC4,PTD3); -// VCC,SCE,RST,D/C,MOSI,SCLK,LED -N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); // K64F - pwr from 3V3 +N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); -// y x button Joystick joystick(PTB10,PTB11,PTC16); -volatile int Start_flag, Back_flag; /*!< Button flags */ +/***************************************************************************//** +* +* below is array of states for the LEDs in the FSM, states have been defined in +* binary for ease of use, 0 is LED on, 1 is LED off so only one LED is on in any +* state. the member functions that are to be used in the main source code file +* have also been defined and the ultrasonice sensor trigger and echo pin have +* been defined, it updates every .5 seconds and a timeout after 1 second and call +* the function dist when the distance changes. +* +*******************************************************************************/ -// array of states in the FSM, each element is the output of the counter -// set the output in binary to make it easier, 0 is LED on, 1 is LED off int fsm[6] = {0b111110, 0b111101, 0b111011, 0b110111, 0b101111, 0b011111}; +volatile int Start_flag, Back_flag; + void init_display(); void main_menu(); @@ -37,6 +66,6 @@ void dist(int distance); -ultrasonic mu(PTD0, PTC12, .5, 1, &dist); //Set the trigger pin to PTD0 and the echo pin to PTC12 - //have updates every .5 seconds and a timeout after 1 - //second, and call dist when the distance changes +ultrasonic mu(PTD0, PTC12, .5, 1, &dist); + +#endif