Amir Asemanpayeh / Mbed 2 deprecated WeatherStation

Dependencies:   BMP180 N5110 PowerControl mbed

Embed: (wiki syntax)

« Back to documentation index

Barometer.h File Reference

Barometer.h File Reference

Header file containing member functions and variables. More...

Go to the source code of this file.

Data Structures

struct  State
 A structure, contains the output, titles and nextstate data. More...

Namespaces

namespace  bmp180
 

A I2C instance to interact with the BMP sensor
SDA, SCL.


namespace  lcd
 

A serial data protocol to operate with a master/slave relationship to interact with the lcd
VCC,SCE,RST,D/C,MOSI,SCLK,LED.


namespace  leds
 

GPIO bus output for status LEDs.


namespace  serial
 

A USB Virtual Serial Port to print out messages to a host PC terminal.


namespace  local
 

A local file system declared to store data files.


namespace  button1
 

An Interrupt on digital pushbutton1 input p16.


namespace  button2
 

An Interrupt on digital pushbutton2 input p17.


namespace  button3
 

An Interrupt on digital pushbutton3 input p15.


namespace  button4
 

An Interrupt on digital pushbutton4 input p18.


namespace  redLED
 

A PwmOut interface is used to control the frequency and mark-space ratio of a led (The red LED)


namespace  yellowLED
 

A PwmOut interface is used to control the frequency and mark-space ratio of a led (The yellow LED)


namespace  greenLED
 

A PwmOut interface is used to control the frequency and mark-space ratio of a led (The green LED)


namespace  buzzer
 

A PwmOut interface is used to control the frequency and mark-space ratio of a buzzer pulse train.


namespace  timer
 

Create ticker object for temperature and pressure readings.


namespace  dataLoggerTimer
 

a ticker object for the data logger functions


namespace  powerSaverTimeout
 

create a timeout object for the poweerSaver function


namespace  debounce
 

create a debounce timer object to implement a debounce counter to avoid multiple interrupts.


Typedefs

typedef struct State STyp1
 Initialises a typedef struct, contains the output, titles and nextstate data for the start menu.
typedef struct State STyp2
 Initialises a typedef struct, contains the output, titles and nextstate data for the settings menu.
typedef struct State STyp3
 Initialises a typedef struct, contains the output, titles and nextstate data for the time/date settings also the alarmclock function.
typedef struct State STyp4
 Initialises a typedef struct, contains the output, titles and nextstate data for the unitsettings function.
typedef struct State STyp5
 Initialises a typedef struct, contains the output, titles and nextstate data for the powerSaverSetting.
typedef struct State Stype6
 Initialises a typedef struct, contains the output, titles and nextstate data for the alarms menu.
typedef struct State Stype7
 Initialises a typedef struct, contains the output, titles and nextstate data for the threshold and alarmclock functions.
typedef struct State Stype8
 Initialises a typedef struct, contains the output, titles and nextstate data for the threshold menu.

Functions

void button1Pressed ()
 ISR attached to the fisrt button interrupt.
void button2Pressed ()
 ISR attached to the second button interrupt.
void button3Pressed ()
 ISR attached to the third button interrupt.
void button4Pressed ()
 ISR attached to the fourth button interrupt.
void timerExpired ()
 ISR attached to the ticker timer.
void dataLoggerTimerExpired ()
 ISR attached to the ticker dataLoggerTimer.
void saveToFile (char *data, char *data1, char *data2, char *data3)
 Opens the local folder, creates a csv file and stores the arrays.
void updateTime ()
 Gets the local time from the RTC and stores them into two arrays.
void display ()
 Displays the char arrays on the LCD.
void readData ()
 Reads the data from the sensor and stores them into arrays.
void powerSaverExpired ()
 ISR attached to power saver timeout to set the flag to 1.
void powerSaverCheck ()
 Checks if the power saver option is set by the user, if yes puts the device in sleep mode and turns off the lcd.
void liveData ()
 Indicates the live data on the screen and updates the data once a second.
void loggerData ()
 Recieves the data, puts them in arrays and saves them to the file.
void dataLogger ()
 Uses the data from the loggerData function to indicate the calculated values and plot the graphs.
void thresholdCheck ()
 Checks the current values of temperature and pressure and compares to the threshold values, triggers the alarm if match.
void threshold ()
 Alloes the user to set the values for the thresholds and also turn the alarm on or off.
void alarmClockCheck ()
 Compares the set time in the alarm clock section with the current time, triggers the alarm when they match.
void alarmClock ()
 Allows the user to set the min , hour, day, month and year values to set the alarm clock.
void alarmsMenu ()
 Alarm menu, includes two submenus : alarmclock and thresholds.
void dataLoggerSetting ()
 Fourth option in the settings menu.
void powerSaverSetting ()
 Third option in the settings menu.
void calculateUNIXTime ()
 Calculates the UNIX time value.
void unitsSetting ()
 The second option in the settings menu.
void timeDateSetting ()
 The first option in the settings menu.
void settingsMenu ()
 The setting menu displayed when the fourth state of fsmA is picked from the main menu /n Depends on the state of the finite state machine used for this function, put the related title in the screen buffers /n Also copy the bufferTime (buffer used to store time) on the first screen buffer (at the top) /n Displays the screen buffers on the LCD/n switch statement checks the current state of the fsm (fsmB), The related function to each fsm state is executed as when a rising edge from the 4th button interrupts (button 4 is pressed)
void startMenu ()
 The main menu displayed at the start /n Depends on the state of the finite state machine (fsmA) used for this function, put the related title in the screen buffers /n Also copy the bufferTime (buffer used to store time) on the first screen buffer (at the top) /n Displays the screen buffers on the LCD/n switch statement checks the current state of the fsm (fsmA), The related function to each fsm state is executed as when a rising edge from the 4th button interrupts (button 4 is pressed)

Variables

int timerFlag = 1
int tickerFlag = 0
int button1Flag = 0
int button2Flag = 0
int button3Flag = 0
int button4Flag = 0
int unitFlag = 1
int powerSaverFlag = 0
int lcdPowerFlag = 1
int dataLoggerFlag = 0
int runLoggerFlag = 0
int alarmClockFlag = 0
int thresholdAlarmFlag = 0
int UNIXdate = 0
int currentTime
int powerSaverTime = 60
int dataLoggerTime = 60
float temperature
float pressure
float averageTemperature
float averagePressure
float minTemperature
float maxTemperature
float minPressure
float maxPressure
float arrayT [83]
float arrayP [83]
float arrayTG [83]
float arrayPG [83]
char bufferTime [14]
char bufferDate [14]
char bufferT [14]
char bufferP [14]
char buffer0 [14]
char buffer1 [14]
char buffer2 [14]
char buffer3 [14]
char buffer4 [14]
char buffer5 [14]
char timeSent [1000]
char dateSent [1000]
char temperatureSent [1000]
char pressureSent [1000]
char temperatureRecieved [1000]
char pressureRecieved [1000]
char timeRecieved [1000]
char dateRecieved [1000]
char * pch
char * pch1
char * pch2
char * pch3
int state = 0
float frequency [] = {659,554,659,554,659,554,659,554,659,554,659,554}

Detailed Description

Header file containing member functions and variables.

Author:
Amir M. Asemanpayeh
Date:
May 2015

Header file - Contains Global Variables, GPIO and Pins and Function prototypes

Definition in file Barometer.h.


Typedef Documentation

typedef struct State STyp1

Initialises a typedef struct, contains the output, titles and nextstate data for the start menu.

Definition at line 236 of file Barometer.h.

typedef struct State STyp2

Initialises a typedef struct, contains the output, titles and nextstate data for the settings menu.

Definition at line 248 of file Barometer.h.

typedef struct State STyp3

Initialises a typedef struct, contains the output, titles and nextstate data for the time/date settings also the alarmclock function.

Definition at line 259 of file Barometer.h.

typedef struct State STyp4

Initialises a typedef struct, contains the output, titles and nextstate data for the unitsettings function.

Definition at line 272 of file Barometer.h.

typedef struct State STyp5

Initialises a typedef struct, contains the output, titles and nextstate data for the powerSaverSetting.

Definition at line 283 of file Barometer.h.

typedef struct State Stype6

Initialises a typedef struct, contains the output, titles and nextstate data for the alarms menu.

Definition at line 292 of file Barometer.h.

typedef struct State Stype7

Initialises a typedef struct, contains the output, titles and nextstate data for the threshold and alarmclock functions.

Definition at line 301 of file Barometer.h.

typedef struct State Stype8

Initialises a typedef struct, contains the output, titles and nextstate data for the threshold menu.

Definition at line 310 of file Barometer.h.


Function Documentation

void alarmClock (  )

Allows the user to set the min , hour, day, month and year values to set the alarm clock.

Definition at line 711 of file Barometer.cpp.

void alarmClockCheck (  )

Compares the set time in the alarm clock section with the current time, triggers the alarm when they match.

Definition at line 671 of file Barometer.cpp.

void alarmsMenu (  )

Alarm menu, includes two submenus : alarmclock and thresholds.

Definition at line 817 of file Barometer.cpp.

void button1Pressed (  )

ISR attached to the fisrt button interrupt.

Parameters:
button1Flag- integer to indicate if the interrupt has occured

Definition at line 12 of file Barometer.cpp.

void button2Pressed (  )

ISR attached to the second button interrupt.

Parameters:
button2Flag- integer to indicate if the interrupt has occured

Definition at line 21 of file Barometer.cpp.

void button3Pressed (  )

ISR attached to the third button interrupt.

Parameters:
button3Flag- integer to indicate if the interrupt has occured

Definition at line 30 of file Barometer.cpp.

void button4Pressed (  )

ISR attached to the fourth button interrupt.

Parameters:
button4Flag- integer to indicate if the interrupt has occured

Definition at line 39 of file Barometer.cpp.

void calculateUNIXTime (  )

Calculates the UNIX time value.

/n Sets the integer values entered by user to the tm structure mebers /n Converts the tm structure to time_t /n

Parameters:
timeinfo- tm struct sent to mktime function
rawtime- fundamental arithmetic type to represent the current time informations

Definition at line 1025 of file Barometer.cpp.

void dataLogger (  )

Uses the data from the loggerData function to indicate the calculated values and plot the graphs.

Definition at line 382 of file Barometer.cpp.

void dataLoggerSetting (  )

Fourth option in the settings menu.

/n Allows the user to turn on the data logger and set the value of time out /n Attaches a timeout to set the dataloggerFlag /n

Parameters:
dataLoggerFlag- integer used as a flag to indicate if the datalogger option is switched on or off
state- integer used to navigate through fsm states

Definition at line 882 of file Barometer.cpp.

void dataLoggerTimerExpired (  )

ISR attached to the ticker dataLoggerTimer.

Parameters:
dataLoggerFlag- integer to indicate the data logger timer is expired

Definition at line 58 of file Barometer.cpp.

void display (  )

Displays the char arrays on the LCD.

Parameters:
buffer0 - char array printed on (0,0)
buffer1 - char array printed on (0,1)
buffer2 - char array printed on (0,2)
buffer3 - char array printed on (0,3)
buffer4 - char array printed on (0,4)
buffer5 - char array printed on (0,5)

Definition at line 89 of file Barometer.cpp.

void liveData (  )

Indicates the live data on the screen and updates the data once a second.

Parameters:
timerFlag- integer set when the timer ends

Definition at line 185 of file Barometer.cpp.

void loggerData (  )

Recieves the data, puts them in arrays and saves them to the file.

Saved arrays are restored and used to calculate the minimun maximum average values

Parameters:
sumTemperature- integer to store the total value of temperature values
sumPressure- integer to store the total value of pressure values
temperatureSent- char with the temperature values saved to the file
pressureSent-char with the pressure values saved to the file
timeSent-char with the time stamps saved to the file
dateSent-char with the data stamps saved to the file
temperatureRecieved- char with the temperature values restored from the file
pressureRecieved-char with the pressure values restored from the file
timeRecieved-char with the time stamps restored from the file
dateRecieved-char with the data stamps restored from the file
minTemperature- int to store the minimum value of temperature
minPressure- int to store the minimum value of pressure
maxTemperature- int to store the maximum value of temperature
maxPressure- int to store the maximum value of pressure
avgTemperature- int to store the average value of temperature
avgPressure- int to store the average value of pressure

Definition at line 222 of file Barometer.cpp.

void powerSaverCheck (  )

Checks if the power saver option is set by the user, if yes puts the device in sleep mode and turns off the lcd.

Also if the buttons are pressed it wakes up the device and attached the timeout

Definition at line 157 of file Barometer.cpp.

void powerSaverExpired (  )

ISR attached to power saver timeout to set the flag to 1.

Parameters:
powerSaverFlag- integer to indicate if the state of the power saver

Definition at line 146 of file Barometer.cpp.

void powerSaverSetting (  )

Third option in the settings menu.

/n Allows the user to turn on the power saving option and set the value of time out /n Attaches a timeout to set the powerSaverFlag /n

Parameters:
powerSaverFlag- integer used as a flag to indicate if the power saver option is switched on or off
state- integer used to navigate through fsm states

Definition at line 958 of file Barometer.cpp.

void readData (  )

Reads the data from the sensor and stores them into arrays.

Parameters:
bufferT- char array to store temperature
bufferP- char array to store pressure
temperature- float to store the value of the temperature
pressure- float to store the value of the pressure

Definition at line 105 of file Barometer.cpp.

void saveToFile ( char *  data,
char *  data1,
char *  data2,
char *  data3 
)

Opens the local folder, creates a csv file and stores the arrays.

Parameters:
data- char array inserted in the local file
data1- char array inserted in the local file
data2- char array inserted in the local file
data3- char array inserted in the local file

Definition at line 67 of file Barometer.cpp.

void settingsMenu (  )

The setting menu displayed when the fourth state of fsmA is picked from the main menu /n Depends on the state of the finite state machine used for this function, put the related title in the screen buffers /n Also copy the bufferTime (buffer used to store time) on the first screen buffer (at the top) /n Displays the screen buffers on the LCD/n switch statement checks the current state of the fsm (fsmB), The related function to each fsm state is executed as when a rising edge from the 4th button interrupts (button 4 is pressed)

Definition at line 1165 of file Barometer.cpp.

void startMenu (  )

The main menu displayed at the start /n Depends on the state of the finite state machine (fsmA) used for this function, put the related title in the screen buffers /n Also copy the bufferTime (buffer used to store time) on the first screen buffer (at the top) /n Displays the screen buffers on the LCD/n switch statement checks the current state of the fsm (fsmA), The related function to each fsm state is executed as when a rising edge from the 4th button interrupts (button 4 is pressed)

Definition at line 1235 of file Barometer.cpp.

void threshold (  )

Alloes the user to set the values for the thresholds and also turn the alarm on or off.

Definition at line 562 of file Barometer.cpp.

void thresholdCheck (  )

Checks the current values of temperature and pressure and compares to the threshold values, triggers the alarm if match.

Definition at line 458 of file Barometer.cpp.

void timeDateSetting (  )

The first option in the settings menu.

/n Allows the user to enter time and date /n Sends the recieved int arrays to the calculateUNIXtime function to calculate the unix time /n sets the current time to the calculated unix time.

Parameters:
state- integer used to navigate through fsm states

Definition at line 1097 of file Barometer.cpp.

void timerExpired (  )

ISR attached to the ticker timer.

Parameters:
timerFlag- integer to indicate the timer is expired

Definition at line 49 of file Barometer.cpp.

void unitsSetting (  )

The second option in the settings menu.

/n Allows the user to change the units /n

Parameters:
unitFlag- integer used as a flag to indicate the units set
state- integer used to navigate through fsm states

Definition at line 1052 of file Barometer.cpp.

void updateTime (  )

Gets the local time from the RTC and stores them into two arrays.

Parameters:
currentTime- integer to store the current data epoch unix time stamp
bufferTime- char array to store the time stamp
bufferTime- char array to store the date stamp

Definition at line 76 of file Barometer.cpp.


Variable Documentation

int alarmClockFlag = 0

Flag set in the AlarmClock function, indicates if the alarm clock has been turned on

Definition at line 151 of file Barometer.h.

float arrayP[83]

A A float array to store the values of pressure to calculate the average,minimum and maximum values

Definition at line 172 of file Barometer.h.

float arrayPG[83]

A A float array to store the values of pressure to plot the related graph

Definition at line 174 of file Barometer.h.

float arrayT[83]

A A float array to store the values of temperature to calculate the average,minimum and maximum values

Definition at line 171 of file Barometer.h.

float arrayTG[83]

A A float array to store the values of temperature to plot the related graph

Definition at line 173 of file Barometer.h.

A float value to store the average value of pressure readings over a period of time

Definition at line 162 of file Barometer.h.

A float value to store the average value of temperature readingsn taken over a period of time

Definition at line 161 of file Barometer.h.

char buffer0[14]

A A char array (buffer) used to display data on the LCD at (0,0)

Definition at line 187 of file Barometer.h.

char buffer1[14]

A A char array (buffer) used to display data on the LCD at (0,1)

Definition at line 188 of file Barometer.h.

char buffer2[14]

A A char array (buffer) used to display data on the LCD at (0,2)

Definition at line 189 of file Barometer.h.

char buffer3[14]

A A char array (buffer) used to display data on the LCD at (0,3)

Definition at line 190 of file Barometer.h.

char buffer4[14]

A A char array (buffer) used to display data on the LCD at (0,4)

Definition at line 191 of file Barometer.h.

char buffer5[14]

A A char array (buffer) used to display data on the LCD at (0,5)

Definition at line 192 of file Barometer.h.

char bufferDate[14]

A A char array (buffer) to store date

Definition at line 178 of file Barometer.h.

char bufferP[14]

A A char array (buffer) to store the value of pressure in char

Definition at line 180 of file Barometer.h.

char bufferT[14]

A A char array (buffer) to store the value of temperature in char

Definition at line 179 of file Barometer.h.

char bufferTime[14]

A A char array (buffer) to store time

Definition at line 177 of file Barometer.h.

int button1Flag = 0

Flag set in button1Pressed ISR

Definition at line 142 of file Barometer.h.

int button2Flag = 0

Flag set in button2Pressed ISR

Definition at line 143 of file Barometer.h.

int button3Flag = 0

Flag set in button3Pressed ISR

Definition at line 144 of file Barometer.h.

int button4Flag = 0

Flag set in button4Pressed ISR

Definition at line 145 of file Barometer.h.

An integer to store the UNIX value of the current time

Definition at line 155 of file Barometer.h.

int dataLoggerFlag = 0

Flag set by user in the dataLoggerSetting function to turn on the logger

Definition at line 149 of file Barometer.h.

int dataLoggerTime = 60

An integer used to set the initial value of the data logger ticker

Definition at line 157 of file Barometer.h.

char dateRecieved[1000]

A A char array used to retrive the saved date stamps from the local file

Definition at line 204 of file Barometer.h.

char dateSent[1000]

A A char array used to save date stamps the local file

Definition at line 198 of file Barometer.h.

float frequency[] = {659,554,659,554,659,554,659,554,659,554,659,554}

A An array of floats with different frequencies for the buzzer

Definition at line 216 of file Barometer.h.

int lcdPowerFlag = 1

Flag set in the savePower function to indicate the status of the LCD (ON or OFF)

Definition at line 148 of file Barometer.h.

float maxPressure

A float value to store the maximum value of pressure readings

Definition at line 166 of file Barometer.h.

A float value to store the maximum value of temperature readings

Definition at line 164 of file Barometer.h.

float minPressure

A float value to store the minimum value of pressure readings

Definition at line 165 of file Barometer.h.

A float value to save the minimum value of temperature readings

Definition at line 163 of file Barometer.h.

char* pch

A A char array used to split the char arrays of temperature values retrived from the local file to the individual temperature strings

Definition at line 208 of file Barometer.h.

char* pch1

A A char array used to split the char arrays of pressure values retrived from the local file to the individual pressure strings

Definition at line 209 of file Barometer.h.

char* pch2

A A char array used to split the char arrays of times retrived from the local file to the individual time strings

Definition at line 210 of file Barometer.h.

char* pch3

A A char array used to split the char arrays of dates retrived from the local file to the individual date strings

Definition at line 211 of file Barometer.h.

int powerSaverFlag = 0

Flag set in the powerSettings function when the powerSaver is switched on

Definition at line 147 of file Barometer.h.

int powerSaverTime = 60

An integer to set the initial value of the power saver ticker

Definition at line 156 of file Barometer.h.

float pressure

A float value to store the value of the pressure recieved from the sensor

Definition at line 160 of file Barometer.h.

char pressureRecieved[1000]

A A char array used to retrive the saved pressure readings from the local file

Definition at line 202 of file Barometer.h.

char pressureSent[1000]

A A char array used to save the pressure readings to the local file

Definition at line 200 of file Barometer.h.

int runLoggerFlag = 0

Fag set when the logger is switched on, allows user to navigate to this option in the main menu

Definition at line 150 of file Barometer.h.

int state = 0

A An integer used to navigate through the finite machines (indexes)

Definition at line 214 of file Barometer.h.

float temperature

A float value to store the value of the temperature recieved from the sensor

Definition at line 159 of file Barometer.h.

char temperatureRecieved[1000]

A A char array used to retrive the saved temperature readings from the local file

Definition at line 201 of file Barometer.h.

char temperatureSent[1000]

A A char array used to save the temperature readings to the local file

Definition at line 199 of file Barometer.h.

Flag set in the thresholdAlarmmenu function,indicates if the thresholds are set

Definition at line 152 of file Barometer.h.

int tickerFlag = 0

Flag to show the minutes passed

Definition at line 141 of file Barometer.h.

char timeRecieved[1000]

A A char array used to retrive the saved time stamps from the local file

Definition at line 203 of file Barometer.h.

int timerFlag = 1

Flag for tempesrature pressure reading ISR

Definition at line 140 of file Barometer.h.

char timeSent[1000]

A A char array used to save time staps to the local file

Definition at line 197 of file Barometer.h.

int unitFlag = 1

Flag set in the unitSettings function, indicates the units picked by user

Definition at line 146 of file Barometer.h.

int UNIXdate = 0

An integer to store the value of UNIX time calculated by mktime function

Definition at line 154 of file Barometer.h.