-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f6dc98e
commit f736b2a
Showing
10 changed files
with
143 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#include "controller.h" | ||
|
||
static controller_power_channels_t controller_power_channels; | ||
static uint8_t * active_power_channel; | ||
|
||
void controller_init(void) | ||
{ | ||
controller_power_channels.normal = 0; | ||
controller_power_channels.turbo = INITIAL_TURBO_VALUE; | ||
active_power_channel = &(controller_power_channels.normal); | ||
} | ||
|
||
void controller_power_channel_change(controller_power_channel_t *channel) | ||
{ | ||
if(channel == NULL){ | ||
if(active_power_channel == &(controller_power_channels.normal)){ | ||
active_power_channel = &(controller_power_channels.turbo); | ||
}else{ | ||
active_power_channel = &(controller_power_channels.normal); | ||
} | ||
}else{ | ||
active_power_channel = channel; | ||
} | ||
} | ||
|
||
void controller_power_channel_increase(controller_power_channel_t *channel) | ||
{ | ||
if(channel == NULL){ | ||
if((*active_power_channel) != 100) (*active_power_channel)++; | ||
}else{ | ||
if((*channel) != 100) (*channel)++; | ||
} | ||
} | ||
|
||
void controller_power_channel_decrease(controller_power_channel_t *channel) | ||
{ | ||
if(channel == NULL){ | ||
if((*active_power_channel) != 0) (*active_power_channel)--; | ||
}else{ | ||
if((*channel) != 0) (*channel)--; | ||
} | ||
} | ||
|
||
uint8_t controller_power_channel_active_value(void) | ||
{ | ||
return (*active_power_channel); | ||
} | ||
|
||
uint8_t controller_power_channel_normal_value(void) | ||
{ | ||
return controller_power_channels.normal; | ||
} | ||
|
||
uint8_t controller_power_channel_turbo_value(void) | ||
{ | ||
return controller_power_channels.turbo; | ||
} | ||
|
||
controller_power_channel_name_t controller_power_channel_active_channel_name(void) | ||
{ | ||
if(active_power_channel == &(controller_power_channels.normal)){ | ||
return controller_power_channel_normal_name; | ||
}else{ | ||
return controller_power_channel_turbo_name; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* @file controller.h | ||
* | ||
* @brief The boat controller module | ||
* | ||
*/ | ||
|
||
#ifndef CONTROLLER_H | ||
#define CONTROLLER_H | ||
|
||
#include <stddef.h> | ||
#include <inttypes.h> | ||
|
||
#define INITIAL_TURBO_VALUE 100 | ||
typedef uint8_t controller_power_channel_t; | ||
|
||
typedef struct{ | ||
controller_power_channel_t normal; | ||
controller_power_channel_t turbo; | ||
} controller_power_channels_t; | ||
|
||
typedef enum{ | ||
controller_power_channel_normal_name, | ||
controller_power_channel_turbo_name, | ||
} controller_power_channel_name_t; | ||
|
||
void controller_init(void); | ||
void controller_power_channel_change(controller_power_channel_t *channel); | ||
void controller_power_channel_increase(controller_power_channel_t *channel); | ||
void controller_power_channel_decrease(controller_power_channel_t *channel); | ||
|
||
uint8_t controller_power_channel_active_value(void); | ||
uint8_t controller_power_channel_normal_value(void); | ||
uint8_t controller_power_channel_turbo_value(void); | ||
controller_power_channel_name_t controller_power_channel_active_channel_name(void); | ||
|
||
#endif /* ifndef CONTROLLER_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters