Repo unification

This commit is contained in:
2024-03-12 21:22:26 +02:00
parent 7aa7edba33
commit 02cb3a9c70
152 changed files with 14575 additions and 2038 deletions

View File

@@ -0,0 +1,52 @@
/**** Includes ****/
#include "user_force.h"
/**** Private definitions ****/
/**** Private constants ****/
static const uint8_t MAX_PERCENT = USER_FORCE_MAX_PERCENT;
static const uint8_t MIN_PERCENT = USER_FORCE_MIN_PERCENT;
/**** Private variables ****/
/**** Private function declarations ****/
/**** Public function definitions ****/
#ifdef TESTING
#endif
uint8_t user_force_btn(uint8_t prev_force, uint8_t up_act, uint8_t down_act, uint8_t delta)
{
uint8_t new_froce = prev_force;
if(up_act)
{
new_froce = prev_force + delta;
// Limit overflow and top value
if(new_froce < prev_force) new_froce = 100;
else if(new_froce < MIN_PERCENT) new_froce = MIN_PERCENT;
};
if(down_act)
{
new_froce = prev_force - delta;
// Limit overflow and top value
if(new_froce > prev_force) new_froce = 0;
else if(new_froce > MAX_PERCENT) new_froce = MAX_PERCENT;
};
// Do deadband
if(new_froce < MIN_PERCENT) new_froce = 0;
else if(new_froce > MAX_PERCENT) new_froce = 100;
return new_froce;
}
uint8_t user_force_pot(uint8_t prev_force, uint8_t pot, uint8_t hyst)
{
uint8_t new_froce = pot;
if(new_froce < MIN_PERCENT) new_froce = 0;
else if(new_froce > MAX_PERCENT) new_froce = 100;
return new_froce;
}
/**** Private function definitions ****/