CoffeePi
Coffee machine control for Raspberry Pi
Functions | Variables
coffee.cpp File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <stdint.h>
#include <wiringPi.h>
#include <pthread.h>
#include <unistd.h>
#include <iostream>
#include <csignal>
#include <time.h>
#include <ctime>
#include "coffee.h"
#include "hal.h"
#include "logger.h"
#include "timer.h"
#include "database.h"
#include "display.h"

Functions

void * coffeeThread (void *threadid)
 Thread for the finite state machine It represents the current state of the machine and handles signals coming from the pressure control, buttons, the brew switch and the proximity sensor. More...
 
void coffeeHandler (int signum, siginfo_t *siginfo, void *context)
 Handler for the Signal send to this thread It saves the type of signal received and tracks the time between a push and release event of up to 4 signals The time is stored in the HalEvent variable when a release event is received. More...
 
int getSigValue (void)
 returns the Signal value from the last received Signal and clears the variable More...
 
bool SigValueEmpty (void)
 
void changeState (int newState)
 Changes the state of the machine to newState prints the change to the logger. More...
 
int getState (void)
 Returns the current state of the FSM. More...
 
void brewTimeHandler (void)
 Counter for the brew time refresh every 200ms. More...
 
void coffeeTerminate (void)
 handles program termination More...
 
void coffeeBrew (void)
 Brewing process. More...
 
void coffeeIncreaseBrewCounter (void)
 
void coffeeIncreaseHeatingTime (uint64_t heatingTime)
 

Variables

int state
 
int sigValue
 
int brewTime
 
timer brewTimer & brewTimeHandler
 
clock_t beginHeating
 
clock_t endHeating
 
double heatingTime
 

Function Documentation

void brewTimeHandler ( void  )

Counter for the brew time refresh every 200ms.

void changeState ( int  newState)

Changes the state of the machine to newState prints the change to the logger.

Parameters
newState
void coffeeBrew ( void  )

Brewing process.

void coffeeHandler ( int  signum,
siginfo_t *  siginfo,
void *  context 
)

Handler for the Signal send to this thread It saves the type of signal received and tracks the time between a push and release event of up to 4 signals The time is stored in the HalEvent variable when a release event is received.

Parameters
signum
siginfo
context
void coffeeIncreaseBrewCounter ( void  )
void coffeeIncreaseHeatingTime ( uint64_t  heatingTime)
void coffeeTerminate ( void  )

handles program termination

void* coffeeThread ( void *  threadid)

Thread for the finite state machine It represents the current state of the machine and handles signals coming from the pressure control, buttons, the brew switch and the proximity sensor.

Parameters
threadidthe ID of the thread
int getSigValue ( void  )

returns the Signal value from the last received Signal and clears the variable

Returns
value sent with the last signal
int getState ( void  )

Returns the current state of the FSM.

bool SigValueEmpty ( void  )

Variable Documentation

clock_t beginHeating
int brewTime
timer brewTimer& brewTimeHandler
clock_t endHeating
double heatingTime
int sigValue
int state