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

Go to the source code of this file.

Classes

struct  ShockPot
 

Functions

void initShockPot (ShockPot *shockPot, int hz, int channel, WHEEL_LOCATION location)
 Initializes the ShockPot sensor with the given frequency, channel, and wheel location. More...
 
float getShockPotDistance (ShockPot *shockPot)
 Gets the current distance measured by the ShockPot. More...
 
void updateShockPot (void *shockPot)
 Updates the ShockPot data. More...
 
float transferFunctionShockPot (float rawVal)
 Converts raw ShockPot data to a meaningful distance value. More...
 

Function Documentation

◆ getShockPotDistance()

float getShockPotDistance ( ShockPot shockPot)

Gets the current distance measured by the ShockPot.

Parameters
shockPotPointer to the ShockPot structure to query.
Returns
The current distance measured by the ShockPot.

Definition at line 13 of file ShockPot.c.

13 {
14 return shockPot->distance;
15}
float distance
Definition: ShockPot.h:9

◆ initShockPot()

void initShockPot ( ShockPot shockPot,
int  hz,
int  channel,
WHEEL_LOCATION  location 
)

Initializes the ShockPot sensor with the given frequency, channel, and wheel location.

Parameters
shockPotPointer to the ShockPot structure to initialize.
hzThe frequency in Hertz at which the sensor operates.
channelThe analog channel the sensor is connected to.
locationThe wheel location as defined by the WHEEL_LOCATION enum.

Definition at line 6 of file ShockPot.c.

6 {
7 initAnalogSensor(&shockPot->base, "ShockPot", hz, channel);
8 shockPot->distance = -1;
9 shockPot->wheel_location = location;
11}
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
void updateShockPot(void *shockPot)
Updates the ShockPot data.
Definition: ShockPot.c:17
Sensor sensor
Definition: AnalogSensor.h:28
Updateable updateable
Definition: Sensor.h:15
AnalogSensor base
Definition: ShockPot.h:8
WHEEL_LOCATION wheel_location
Definition: ShockPot.h:10
void(* update)(void *self)
Definition: Updateable.h:26
Here is the call graph for this function:

◆ transferFunctionShockPot()

float transferFunctionShockPot ( float  rawVal)

Converts raw ShockPot data to a meaningful distance value.

Parameters
rawValThe raw data from the ShockPot sensor.
Returns
The converted distance value.

Definition at line 24 of file ShockPot.c.

24 {
25 if (rawVal < 15) {
26 printf("ShockPot::transfer_function rawValue is too low\n");
27 return -1;
28 }
29 else if (rawVal > 135) {
30 printf("ShockPot::transfer_function rawValue is too high\n");
31 return -1;
32 }
33 return 2.71965 * pow(rawVal, 0.837683) - 16.2622;
34}
Here is the caller graph for this function:

◆ updateShockPot()

void updateShockPot ( void *  shockPot)

Updates the ShockPot data.

Parameters
shockPotPointer to the ShockPot structure to update.

Definition at line 17 of file ShockPot.c.

17 {
18 ShockPot *myShockPot = (ShockPot *)shockPot;
19 printf("Implement ShockPot::update\n");
20 float rawData = 50.0;
21 myShockPot->distance = transferFunctionShockPot(rawData);
22}
float transferFunctionShockPot(float rawVal)
Converts raw ShockPot data to a meaningful distance value.
Definition: ShockPot.c:24
Here is the call graph for this function:
Here is the caller graph for this function: