46 lines
1.1 KiB
Arduino
46 lines
1.1 KiB
Arduino
PAR_LONG aux = 0;
|
|
PAR_LONG auxScale = 0;
|
|
PAR_LONG auxDigits = 2;
|
|
PAR_TEXT auxLabel[16] = "aux";
|
|
|
|
void AuxPars() {
|
|
ParEnum("axa", auxAvailable, F("no|yes"));
|
|
ParFixed("ax", aux, auxDigits);
|
|
ParFixed("axs", auxScale, auxDigits);
|
|
ParFixed("axd", auxDigits, 0);
|
|
ParText("axt", auxLabel, false);
|
|
}
|
|
|
|
void AuxDisp() {
|
|
DispText(auxLabel);
|
|
DispBigValue(p_aux, 0);
|
|
DispButton(0, m_menu, m_menu, "menu");
|
|
DispButton(1, m_menu, m_home, "home");
|
|
}
|
|
|
|
|
|
void AuxHandler() {
|
|
long asum;
|
|
static long sum = 0;
|
|
static long cnt = 0;
|
|
byte i;
|
|
static ulong lastUpdate = 0;
|
|
const int nsum = 50;
|
|
|
|
if (auxScale == 0) return;
|
|
for (i = 0; i < nsum; i++) {
|
|
sum += aRead(a_levb_vminus);
|
|
}
|
|
cnt ++;
|
|
if (sum > 0x40000000 || expired(&lastUpdate, 500)) {
|
|
// auxScale must be < 200000 for no overflow
|
|
if (auxScale <= 200000) {
|
|
ParSet(aux, (sum * 10 / cnt / nsum) * auxScale / 10 / 876); // 876 = 5.62k / (5.62k + 47.5k) * 10V / 1.235V * 1023
|
|
} else {
|
|
ParSet(aux, (sum * 10 / cnt / nsum) * (auxScale / 10) / 876);
|
|
}
|
|
sum = 0;
|
|
cnt = 0;
|
|
}
|
|
}
|