Vehicle Control Unit 0.01
This is the c library for controlling the car.
Loading...
Searching...
No Matches
Functions
App.c File Reference
#include "../../../Inc/Sensors/AnalogSensors/App.h"
#include <stdio.h>
Include dependency graph for App.c:

Go to the source code of this file.

Functions

void initApp (App *app, int hz, int channel)
 Initializes the APP with the given frequency and channel. More...
 
float getAppPosition (App *app)
 Gets the current position of the APP. More...
 
void updateApp (void *app)
 Updates the APP data. More...
 
float transferFunctionApp (float rawVal)
 Converts raw APP data to a meaningful position value. More...
 
void setAppPos (App *app, float pos)
 Sets pedal position in app sensor. More...
 

Function Documentation

◆ getAppPosition()

float getAppPosition ( App app)

Gets the current position of the APP.

Parameters
appPointer to the App structure to query.
Returns
The current position of the APP.

Definition at line 11 of file App.c.

11 {
12 return app->position;
13}
float position
Definition: App.h:8
Here is the caller graph for this function:

◆ initApp()

void initApp ( App app,
int  hz,
int  channel 
)

Initializes the APP with the given frequency and channel.

Parameters
appPointer to the App structure to initialize.
hzThe frequency in Hertz at which the APP operates.
channelThe analog channel the APP is connected to.

Definition at line 5 of file App.c.

5 {
6 initAnalogSensor(&app->base, "App", hz, channel);
7 app->position = 0;
9}
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 updateApp(void *app)
Updates the APP data.
Definition: App.c:15
Sensor sensor
Definition: AnalogSensor.h:28
AnalogSensor base
Definition: App.h:7
Updateable updateable
Definition: Sensor.h:15
void(* update)(void *self)
Definition: Updateable.h:26
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setAppPos()

void setAppPos ( App app,
float  pos 
)

Sets pedal position in app sensor.

Note
For testing only
Parameters
appPointer to app sensor.
posPosition to set on sensor.

Definition at line 35 of file App.c.

35 {
36 app->position = pos;
37}

◆ transferFunctionApp()

float transferFunctionApp ( float  rawVal)

Converts raw APP data to a meaningful position value.

Parameters
rawValThe raw data from the APP.
Returns
The converted APP position value.

Definition at line 22 of file App.c.

22 {
23 // This is a +-45 degree sensor
24 if (rawVal < 0.5) {
25 printf("App::transfer_function rawValue is too low\n");
26 return -1;
27 }
28 else if (rawVal > 4.5) {
29 printf("App::transfer_function rawValue is too high\n");
30 return -1;
31 }
32 return (22.5 * rawVal) - 56.25;
33}
Here is the caller graph for this function:

◆ updateApp()

void updateApp ( void *  app)

Updates the APP data.

Parameters
appPointer to the App structure to update.

Definition at line 15 of file App.c.

15 {
16 App *myApp = (App *)app;
17 // FIXME: Implement APP connection with stm
18 float rawData = 1.0f;
19 myApp->position = transferFunctionApp(rawData);
20}
float transferFunctionApp(float rawVal)
Converts raw APP data to a meaningful position value.
Definition: App.c:22
Definition: App.h:6
Here is the call graph for this function:
Here is the caller graph for this function: