First Draft, serial print change based on distance

main.h

Committer:
liam94
Date:
2022-01-26
Revision:
7:7464fbb0f3e1
Parent:
6:18a4dd77057e
Child:
8:7e48229d678c

File content as of revision 7:7464fbb0f3e1:


#include "mbed.h"
#include "N5110.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
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

//                     y     x   button
Joystick joystick(PTB10,PTB11,PTC16);

volatile int Start_flag, Back_flag; /*!< Button flags */

// 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};

void init_display();

void main_menu();

void sense_object();

void Start_isr();

void Back_isr();

void calibrate_object();

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