diff --git a/aux.ino b/aux.ino index cb0103d..f758cf6 100644 --- a/aux.ino +++ b/aux.ino @@ -1,5 +1,5 @@ PAR_LONG aux = 0; -PAR_LONG auxScale = 100000; +PAR_LONG auxScale = 0; PAR_LONG auxDigits = 2; PAR_TEXT auxLabel[16] = "aux"; diff --git a/ccu4_78.ino b/ccu4_80.ino similarity index 98% rename from ccu4_78.ino rename to ccu4_80.ino index 530b7a9..8fddad0 100644 --- a/ccu4_78.ino +++ b/ccu4_80.ino @@ -11,7 +11,7 @@ // define SERIALCOMMON 1 for testing the serial connection over usb #define SERIALCOMMON 0 -PAR_TEXT configSoft[16] = "7.8"; +PAR_TEXT configSoft[16] = "8.0"; long now; // global variable, updated by FastHandler byte inside; @@ -48,7 +48,7 @@ enum {p_vu = p_nBase - 1, p_vuCmd = p_vu + 12}; // valve unit base (+ 24 paramet enum {p_nPar = p_nBase + 24}; // max. parameter of all extensions enum {no_extension, valve_extension, he_extension}; -byte extension = valve_extension; +byte extension; /* char *menu_text = "menu|home|configuration"; @@ -78,7 +78,7 @@ PAR_LONG timF = 0; PAR_LONG timM = 0; PAR_LONG timV = 0; PAR_LONG timQ = 0; - +byte motorEndSwitch = 0; // parameters for Summary command: int sumidx = 0; // actual position in parameter list @@ -272,7 +272,11 @@ void WriteDisplay() { N2Disp(); break; case m_nv: - ConfigDispShort("n.v."); + if (flowAvailable) { + ConfigDispShort("n.v."); + } else { + ConfigDispShort("m.v."); + } FlowDisp(); break; case m_ext: @@ -350,7 +354,7 @@ boolean spc; name_t name; void OutResult(boolean ok) { - char *value; + const char *value; boolean containsBlanks; //long s; diff --git a/config.ino b/config.ino index 2de4f69..770bd75 100644 --- a/config.ino +++ b/config.ino @@ -2,8 +2,8 @@ //#include "utils.h" #include "EEPROM.h" -enum {standard_cfg, argon_cfg, multihe_cfg}; -#define config_cfg_text "std|argon|multiHe" +enum {standard_cfg, argon_cfg, multihe_cfg, jtext_cfg}; +#define config_cfg_text "std|argon|multiHe|jtext" PAR_LONG codeA = 0; PAR_LONG codeB = 0; @@ -786,12 +786,15 @@ void ConfigDeviceCmd(byte cmd) { void ConfigSpecial(EeMode mode) { switch (configSpecial) { case argon_cfg: - Serial.println("save argon"); if (mode == ee_read) { extension = valve_extension; ParSet(auxAvailable, 1); ParSetText(configDevice, "argon"); + Serial.print("load"); + } else { + Serial.print("save"); } + Serial.println(" argon"); EESTORE(auxDigits, mode); EESTORE(auxScale, mode); EESTORE(auxLabel, mode); @@ -806,6 +809,21 @@ void ConfigSpecial(EeMode mode) { ParSetText(configDevice, "LHe vess"); } HeStore(mode); + break; + case jtext_cfg: + if (mode == ee_read) { + extension = valve_extension; + ParSetText(configDevice, "jtext"); + Serial.print("load"); + ParSet(n2Available, 1); + ParSet(motorAvailable, 1); + motorEndSwitch = 1; + } else { + Serial.print("save"); + } + Serial.println(" jtext"); + break; + } } diff --git a/dipdisplay.ino b/dipdisplay.ino index 58040aa..13f980d 100644 --- a/dipdisplay.ino +++ b/dipdisplay.ino @@ -77,7 +77,7 @@ void DispClrAll() { disp.clrall = true; } -void DispButton(int8_t nr, byte menu, byte cmd, char *text) { +void DispButton(int8_t nr, byte menu, byte cmd, const char *text) { struct Disp_Button *button = &ARRAY(disp.buttons, nr); char old[18]; @@ -172,11 +172,11 @@ void DispText2(const char *head, const char *text) { DispTextRow(fmt_rsmall, head, text); } -void DispState(char *head, byte nr) { +void DispState(const char *head, byte nr) { DispTextRow(fmt_lsmall, head, ParFmt(nr)); } -void DispValueArg(byte fmt, char *head, byte nr, byte stateNr) { +void DispValueArg(byte fmt, const char *head, byte nr, byte stateNr) { byte state, maxlen; //if (!disp.freeze) { @@ -204,15 +204,15 @@ void DispBigValue(byte nr, byte stateNr) { DispValueArg(fmt_big, 0, nr, stateNr); } -void DispMediumValue(char *head, byte nr, byte stateNr) { +void DispMediumValue(const char *head, byte nr, byte stateNr) { DispValueArg(fmt_medium, head, nr, stateNr); } -void DispLargeValue(char *head, byte nr, byte stateNr) { +void DispLargeValue(const char *head, byte nr, byte stateNr) { DispValueArg(fmt_large, head, nr, stateNr); } -void DispValue(char *head, byte nr, byte stateNr) { +void DispValue(const char *head, byte nr, byte stateNr) { DispValueArg(fmt_rsmall, head, nr, stateNr); } @@ -315,7 +315,7 @@ void DispDrawRow(struct Disp_Row *row, boolean doclear) { boolean skip = false; int len, maxlen; byte ytop, ybot; - char *afterHead = 0; + const char *afterHead = 0; disp.handler(); ytop = disp.textPos; @@ -325,7 +325,7 @@ void DispDrawRow(struct Disp_Row *row, boolean doclear) { Serial.print(F("D ybot overlap ")); Serial.println(ybot - disp.butLim); } if (ytop > disp.butLim) { - Serial.println(F("skip")); + if (DISPDEBUG) Serial.println(F("skip")); skip = true; ytop = disp.butLim; } @@ -852,7 +852,7 @@ int DispActMenu() { } */ -void DispError(char *head, char *text) { +void DispError(const char *head, const char *text) { Serial.print("\nERROR: "); Serial.print(head); Serial.print(' '); diff --git a/he.ino b/he.ino index 2a1f9f3..e9d0fc6 100644 --- a/he.ino +++ b/he.ino @@ -87,7 +87,15 @@ void HePars() { if (changed) { heLastIncrease = now; } - ParEnum("hav", heAvailable, F("no|yes|ext")); + if (ParEnum("hav", heAvailable, F("no|yes|ext")) == par_command) { + if (heAvailable == 1) { + if (heSensState == he_disabled) { + ParSet(heSensState, he_not_yet); + } else { + ParSet(heSensState, he_disabled); + } + } + } //ParEnum("hbe", heBooster, F("disable|enable")); if (ParEnum("hcd", heCommand, he_cmd_text) == par_command) { HeRemoteCmd(heCommand); @@ -488,7 +496,7 @@ void HeHandler() { const float sum_to_current = 1235. / 1024 / 100 / 5 / 0.1; // 1235 mV / 1024 adcsteps / 100 sum_counts / 5 Ohm / 0.1 mA const float sum_to_volt = 1235. / 1024 / 200 * 105.62 / 5.62 / 10; // 1235 mV / 1024 adcsteps / 200 sum_counts * (105.62 kOhm / 5.62 kOhm) / 10 mV; - if (heAvailable != 1) { + if (heAvailable != 1 && heExtAvailable == 0) { return; } if (heMeas == 0) { // not measuring/checking @@ -856,8 +864,8 @@ void HeValveState(boolean ok) { } } -boolean HeStateDisp(char *title) { - char *text; +boolean HeStateDisp(const char *title) { + const char *text; static char old[32]; if (heValve == valve_on) { if (heMeas && heChannel == 6) { diff --git a/motor.ino b/motor.ino index fcd61c5..ab905f3 100644 --- a/motor.ino +++ b/motor.ino @@ -77,22 +77,34 @@ void FlowPars() { } boolean FlowDispShort(boolean big) { - if (big) { - DispText("flow/mbar"); - DispBigValue(p_flow, p_flowSensState); // flow value + if (flowAvailable) { + if (big) { + DispText("flow/mbar"); + DispBigValue(p_flow, p_flowSensState); // flow value + } else { + DispMediumValue("flow", p_flow, p_flowSensState); // flow value + //DispValue("flow", p_flow, p_flowSensState); + } + FlowStateDisp(); } else { - DispMediumValue("flow", p_flow, p_flowSensState); // flow value - //DispValue("flow", p_flow, p_flowSensState); + DispState("m.v. ", p_motorState); } - FlowStateDisp(); return motorState == motor_opening || motorState == motor_closing; } +boolean MotorDispShort() { + DispTextRow(fmt_lsmall, "m.v. ", ParFmt(p_motorState)); +} + void MotorButtons(byte top) { byte codebase = m_nv * 16; if (!flowAvailable && !motorAvailable) return; - DispButton(top, m_menu, m_nv, "*n.v."); + if (flowAvailable) { + DispButton(top, m_menu, m_nv, "*n.v."); + } else { + DispButton(top, m_menu, m_nv, "*m.v."); + } if (motorState != motor_unplugged) { if (motorAutoState == motor_ctrl) { DispButton(top - 2, m_nv, motor_setfixed, "-fixed"); @@ -114,11 +126,14 @@ void MotorButtons(byte top) { void FlowDisp() { byte codebase = m_nv * 16; - DispText("flow/mbar"); - DispBigValue(p_flow, p_flowSensState); // flow value - DispState("n.v. ", p_motorState); - DispState("mode: ", p_motorAutoState); - + if (flowAvailable) { + DispText("flow/mbar"); + DispBigValue(p_flow, p_flowSensState); // flow value + DispState("n.v. ", p_motorState); + DispState("mode: ", p_motorAutoState); + } else { + DispState("m.v. ", p_motorState); + } if (motorState != motor_unplugged) { DispButton(2, m_nv, motor_open, "open"); DispButton(3, m_nv, motor_close, "close"); @@ -416,6 +431,11 @@ void MotorHandler() { Serial.print(motorTorque); Serial.println("tq"); } + if (motorEndSwitch && motorState != motor_closing) { + if (aRead(a_aux_current) > 10) { + ParSet(motorState, motor_opened); + } + } if (motorTorque > motorTorqueLimit) { if (motorDir > 0) { if (MOTDEBUG) { @@ -568,7 +588,7 @@ void MotorCmd(byte cmd) { } void FlowStateDisp() { - char *text; + const char *text; if (motorState == motor_idle && motorAutoState != motor_offline) { text = ParFmt(p_motorAutoState); diff --git a/n2.ino b/n2.ino index d1fc598..6010708 100644 --- a/n2.ino +++ b/n2.ino @@ -254,8 +254,8 @@ void N2ValveState(boolean ok) { } } -void N2StateDisp(char *title) { - char *text; +void N2StateDisp(const char *title) { + const char *text; if (n2valve == valve_on) { if (n2fault == n2_no_sensor) { diff --git a/par.ino b/par.ino index 3b13496..9754624 100644 --- a/par.ino +++ b/par.ino @@ -77,7 +77,7 @@ void ParSet_(byte nr, void *ptr, byte siz, long value) { bitClear(ARRAY(flags,nr), par_display_unchanged); } -void ParSetText_(byte nr, char *ptr, byte siz, char *value) { +void ParSetText_(byte nr, char *ptr, byte siz, const char *value) { textcopy(ptr, siz, value); bitClear(ARRAY(flags,nr), par_serial_unchanged); bitClear(ARRAY(flags,nr), par_display_unchanged); @@ -127,7 +127,7 @@ void ParHide(name_t name) { action = oldact; } -char *ParFmtByName(name_t name) { +const char *ParFmtByName(name_t name) { ParAction *oldact = action; ParAction act; action = &act; @@ -142,7 +142,7 @@ char *ParFmtByName(name_t name) { } // format for display -char *ParFmt(byte nr, byte maxlen) { +const char *ParFmt(byte nr, byte maxlen) { ParAction *oldact = action; ParAction act; action = &act; @@ -161,7 +161,7 @@ char *ParFmt(byte nr, byte maxlen) { return ctx.text; } -char *ParFmt(byte nr) { +const char *ParFmt(byte nr) { return ParFmt(nr, 0); } diff --git a/parser.ino b/parser.ino index dfd6f32..a5b1e83 100644 --- a/parser.ino +++ b/parser.ino @@ -65,7 +65,7 @@ ParserType Parser() { */ ch = ParserRd(); } else { - if (parser.ident >= 64000*64000) { + if (parser.ident >= 64000UL*64000UL) { result = parser_error; } else { // Serial.print("parsed "); Serial.print(parser.ident); Serial.println(c40(parser.ident)); diff --git a/ramtest.ino b/ramtest.ino index 9b7ce9f..8e6890c 100644 --- a/ramtest.ino +++ b/ramtest.ino @@ -1,7 +1,7 @@ extern byte __bss_end; #define RAMBEG 0x0200 -#define RAMEND 0x2200 +#define RAMENDE 0x2200 static byte *ramPtr; diff --git a/utils.ino b/utils.ino index 9de7f7e..1f88733 100644 --- a/utils.ino +++ b/utils.ino @@ -31,7 +31,7 @@ char *c40(ulong c40) { ulong addCharToC40(ulong in, char chr) { ulong pos = 1; - if (in >= 40*40*40*40*40) return in; // throw away superflous chars + if (in >= 40UL*40UL*40UL*40UL*40UL) return in; // throw away superflous chars while (pos < in) { pos *= 40; } @@ -196,7 +196,7 @@ char *fix2str(long num, char dig, char *buffer, char maxlen) { } char *enum2str(byte value, flash_str flashList, char *buffer, byte maxlen) { - const char PROGMEM *list = (const char PROGMEM *)flashList; + const char *list PROGMEM = (const char PROGMEM *)flashList; byte len; byte val = value; char ch; diff --git a/valveUnit.ino b/valveUnit.ino index a154fbc..2525e80 100644 --- a/valveUnit.ino +++ b/valveUnit.ino @@ -138,7 +138,7 @@ void VuHandler() { byte v; byte state; static byte cnt[13]={0}; - + for (v = 1; v <= 12; v++) { if (ARRAY(vu,v) == valve_boost) { if (time_ge(now, ARRAY(booststart,v) + boostdelay)) {