Copy_Assignment3

Dependencies:   mbed MCP23017 WattBob_TextLCD mbed-rtos

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers my_tools.h Source File

my_tools.h

00001 #include <vector>
00002 #include "mbed.h"
00003 #include "my_structures.h"
00004 #include "MCP23017.h"
00005 #include "WattBob_TextLCD.h"
00006 
00007 #pragma once
00008 #ifndef __MY_TOOLS_H__
00009 #define __MY_TOOLS_H__
00010 
00011 /*******************************************************************************
00012  *                           FUNCTION TOOLS DECLARATION
00013  *                     To Simplify the code of the task themselves
00014  ******************************************************************************/
00015 
00016 /** Read an analog input and return a float between 0 and 1
00017  *
00018  *  @param: pin [AnalogIn]
00019  *          Pin to read
00020  *
00021  *  @return: float between 0 and 1
00022  */
00023 float   readAnalogInput(AnalogIn pin);
00024 
00025 
00026 /** Delete the first value of the given vector
00027  *
00028  *  @param: &vec - Vector whose first value is deleted
00029  */
00030 void    deleteFirstValueVec(vector<float> &vec);
00031 
00032 
00033 /** Switch on a DigitalOut led if the given float value is above some threshold
00034  *
00035  *  @param: value [float]
00036  *          Checked Value
00037  *  @prama: led [DigitalOut]
00038  *          Output pin used to show if the value goes above the threshold
00039  *  @param: threshold [float]
00040  *          Threshold value use to switch on or or the DigitalOut pin
00041  *
00042  *  @return: int - 0 or 1, state of the DigitalOut pin
00043  */
00044 int monitorValue(float value, DigitalOut led, float thresholdValue);
00045 
00046 
00047 /** Write on the LCD the odometer and speed values
00048  *
00049  *  @param: &lcd [WattBob_TextLCD]
00050  *          Reference to the screen to use to display information
00051  *  @param: odometer [float]
00052  *          Travelled distance in m, displayed in km
00053  *  @param: avg [float]
00054  *          Last average speed computed in m/s. Displayed in km/h
00055  */
00056 void writeOnLCD(WattBob_TextLCD &lcd, float odometer, float avg);
00057 
00058 
00059 /** Update the PWM frequency of the right and left DigitalOut leds of the car
00060  *  based on the state of the given switch
00061  *
00062  *  @param: *myCar [carStructure]
00063  *          Main structure used in the program, used to access the right
00064  *          and left switch.
00065  *  @param: right [bool]
00066  *          State of the right switch
00067  *  @param: left [bool]
00068  *          State of the left switch.
00069  */
00070 void updateLEDs(carStructure *myCar, bool right, bool left);
00071 
00072 #endif /*! __MY__TOOLS_H__ */