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

Go to the source code of this file.

Classes

struct  Accelerometer
 

Functions

void initAccelerometer (Accelerometer *accel, int channel, int hz, int muxChannel)
 Initializes the accelerometer with the given channel, frequency, and multiplexer channel. More...
 
float getAccelerometerValue (Accelerometer *accel)
 Gets the current value of the accelerometer. More...
 
void updateAccelerometer (void *accel)
 Updates the accelerometer data. More...
 
float transferFunctionAccelerometer (float rawVal)
 Converts raw accelerometer data to a meaningful value. More...
 

Function Documentation

◆ getAccelerometerValue()

float getAccelerometerValue ( Accelerometer accel)

Gets the current value of the accelerometer.

Parameters
accelPointer to the Accelerometer structure to query.
Returns
The current accelerometer value.

Definition at line 14 of file Accelerometer.c.

14 {
15 return accel->value;
16}

◆ initAccelerometer()

void initAccelerometer ( Accelerometer accel,
int  channel,
int  hz,
int  muxChannel 
)

Initializes the accelerometer with the given channel, frequency, and multiplexer channel.

Parameters
accelPointer to the Accelerometer structure to initialize.
channelThe analog channel the accelerometer is connected to.
hzThe frequency in Hertz at which the accelerometer operates.
muxChannelThe multiplexer channel for the accelerometer.

Definition at line 8 of file Accelerometer.c.

8 {
9 initAnalogSensor(&accel->base, "Accelerometer", hz, channel);
10 accel->value = -1;
12}
void updateAccelerometer(void *accel)
Updates the accelerometer data.
Definition: Accelerometer.c:18
void initAnalogSensor(AnalogSensor *analogSensor, const char *name, int hz, int channel)
Initializes an analog sensor and configures the corresponding GPIO pin.
Definition: AnalogSensor.c:44
AnalogSensor base
Definition: Accelerometer.h:7
Sensor sensor
Definition: AnalogSensor.h:28
Updateable updateable
Definition: Sensor.h:15
void(* update)(void *self)
Definition: Updateable.h:26
Here is the call graph for this function:

◆ transferFunctionAccelerometer()

float transferFunctionAccelerometer ( float  rawVal)

Converts raw accelerometer data to a meaningful value.

Parameters
rawValThe raw data from the accelerometer.
Returns
The converted accelerometer value.

Definition at line 25 of file Accelerometer.c.

25 {
26 return (rawVal - kOffsetVolts) / kVoltsPerG;
27}
const float kOffsetVolts
Definition: Accelerometer.c:5
const float kVoltsPerG
Definition: Accelerometer.c:6
Here is the caller graph for this function:

◆ updateAccelerometer()

void updateAccelerometer ( void *  accel)

Updates the accelerometer data.

Parameters
accelPointer to the Accelerometer structure to update.

Definition at line 18 of file Accelerometer.c.

18 {
19 Accelerometer *myAccel = (Accelerometer *)accel;
20 float rawData = 0.0f; // Placeholder for sensor reading
21 printf("Updating Accelerometer\n");
22 myAccel->value = transferFunctionAccelerometer(rawData);
23}
float transferFunctionAccelerometer(float rawVal)
Converts raw accelerometer data to a meaningful value.
Definition: Accelerometer.c:25
Here is the call graph for this function:
Here is the caller graph for this function: