Vehicle Control Unit 0.01
This is the c library for controlling the car.
Loading...
Searching...
No Matches
Classes | Functions
Temperature.h File Reference
#include "../AnalogSensor.h"
Include dependency graph for Temperature.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  Temperature
 

Functions

void initTemperature (Temperature *temp, int hz, int channel)
 Initializes the Temperature sensor with the given frequency and channel. More...
 
void updateTemperature (void *temp)
 Updates the Temperature data. More...
 
double getTemperatureCelsius (Temperature *temp)
 Gets the current temperature in Celsius. More...
 
double getTemperatureFahrenheit (Temperature *temp)
 Gets the current temperature in Fahrenheit. More...
 
double transferFunction (Temperature *temp, float rawValue)
 Converts raw temperature data to a meaningful temperature value. More...
 

Function Documentation

◆ getTemperatureCelsius()

double getTemperatureCelsius ( Temperature temp)

Gets the current temperature in Celsius.

Parameters
tempPointer to the Temperature structure to query.
Returns
The current temperature in Celsius.

Definition at line 15 of file Temperature.c.

15 {
16 return temperature->degrees;
17}

◆ getTemperatureFahrenheit()

double getTemperatureFahrenheit ( Temperature temp)

Gets the current temperature in Fahrenheit.

Parameters
tempPointer to the Temperature structure to query.
Returns
The current temperature in Fahrenheit.

Definition at line 19 of file Temperature.c.

19 {
20 return temperature->degrees * 9.0 / 5.0 + 32;
21}
Here is the caller graph for this function:

◆ initTemperature()

void initTemperature ( Temperature temp,
int  hz,
int  channel 
)

Initializes the Temperature sensor with the given frequency and channel.

Parameters
tempPointer to the Temperature structure to initialize.
hzThe frequency in Hertz at which the sensor operates.
channelThe analog channel the sensor is connected to.

Definition at line 3 of file Temperature.c.

3 {
4 initAnalogSensor(&temperature->base, "Temperature", hz, channel, temperature);
5 temperature->degrees = 0;
6 temperature->base.sensor.updateable.update = updateTemperature;
7}
void initAnalogSensor(AnalogSensor *analogSensor, const char *name, int hz, int channel, void *child)
Initializes an analog sensor and configures the corresponding GPIO pin.
Definition: AnalogSensor.c:42
void updateTemperature(void *temperature)
Updates the Temperature data.
Definition: Temperature.c:9
Here is the call graph for this function:
Here is the caller graph for this function:

◆ transferFunction()

double transferFunction ( Temperature temp,
float  rawValue 
)

Converts raw temperature data to a meaningful temperature value.

Parameters
tempPointer to the Temperature structure.
rawValThe raw data from the temperature sensor.
Returns
The converted temperature value.

Definition at line 23 of file Temperature.c.

23 {
24
25 #ifdef DEBUGn
26 printf("Implement Temperature::TF\r\n");
27 #endif
28
29 return 0.0;
30}
Here is the caller graph for this function:

◆ updateTemperature()

void updateTemperature ( void *  temp)

Updates the Temperature data.

Parameters
tempPointer to the Temperature structure to update.

Definition at line 9 of file Temperature.c.

9 {
10 Temperature *myTemp = (Temperature *)temperature;
11 float rawData = getAnalogSensorData(&myTemp->base);
12 myTemp->degrees = transferFunction(temperature, rawData);
13}
float getAnalogSensorData(AnalogSensor *sensor)
Retrieves analog sensor data for a specific channel.
Definition: AnalogSensor.c:89
double transferFunction(Temperature *temperature, float rawVal)
Converts raw temperature data to a meaningful temperature value.
Definition: Temperature.c:23
double degrees
Definition: Temperature.h:8
AnalogSensor base
Definition: Temperature.h:7
Here is the call graph for this function:
Here is the caller graph for this function: