Add endurance power limit

This commit is contained in:
Jasper Blanckenburg 2023-08-01 19:43:09 +02:00
parent 2b54a8ffe8
commit 1eefffcbd6
3 changed files with 15 additions and 2 deletions

View File

@ -11,7 +11,7 @@ extern "C" {
#include "util.h"
CountedEnum(ParamType, size_t, PF_BBAL, PF_SLIPREF, PF_MUMAX, PF_ASRP, PF_ASRON,
PF_ASRI);
PF_ASRI, PF_PLIM);
typedef struct {
float bbal;
@ -20,6 +20,7 @@ typedef struct {
unsigned asrp;
unsigned asri;
unsigned asron;
unsigned plim;
} Params;
extern Params params;

View File

@ -4,7 +4,10 @@
Params params = {0};
void params_init() { params.bbal = 50; }
void params_init() {
params.bbal = 50;
params.plim = 20;
}
void params_inc(ParamType param) {
switch (param) {
@ -29,6 +32,9 @@ void params_inc(ParamType param) {
case PF_ASRON:
params.asron = 1;
break;
case PF_PLIM:
params.plim = (params.plim < 80) ? params.plim + 1 : 80;
break;
}
}
@ -63,6 +69,9 @@ void params_dec(ParamType param) {
case PF_ASRON:
params.asron = 0;
break;
case PF_PLIM:
params.plim = (params.plim > 2) ? params.plim - 1 : 2;
break;
}
}
@ -87,6 +96,8 @@ void params_broadcast(ParamType param) {
case PF_ASRON:
value = params.asron;
break;
case PF_PLIM:
value = params.plim;
default:
return;
}

View File

@ -316,6 +316,7 @@ NamedFieldDescription paramFieldDescs[] = {
[PF_ASRP] = {NamedFieldKind::Int, "ASR-P", 2, 0, PARAM_FIELD(asrp)},
[PF_ASRON] = {NamedFieldKind::Int, "ASR-ON", 2, 0, PARAM_FIELD(asron)},
[PF_ASRI] = {NamedFieldKind::Int, "ASR-I", 2, 0, PARAM_FIELD(asri)},
[PF_PLIM] = {NamedFieldKind::Int, "PLIM", 2, 0, PARAM_FIELD(plim)},
};
static_assert(sizeof(paramFieldDescs) / sizeof(paramFieldDescs[0]) ==