diff --git a/lambda-test/adc-test.c b/lambda-test/adc-test.c index d045816..1ba9d38 100644 --- a/lambda-test/adc-test.c +++ b/lambda-test/adc-test.c @@ -15,7 +15,7 @@ /* Module adc */ -bool testSetupADC(void) { +static bool testSetupADC(void) { setupADC(); // AVCC is set as AREF @@ -31,7 +31,7 @@ return true; } -bool testGetVoltage(void) { +static bool testGetVoltage(void) { initInterrupts(); setupADC(); setupSleepMode(); diff --git a/lambda-test/alert-test.c b/lambda-test/alert-test.c index 015b950..e6a621e 100644 --- a/lambda-test/alert-test.c +++ b/lambda-test/alert-test.c @@ -14,7 +14,7 @@ /* Module alert */ -bool testOscillateBeep(void) { +static bool testOscillateBeep(void) { extern uint8_t beepCount; extern uint8_t oscCount; @@ -63,7 +63,7 @@ return true; } -bool testBeep(void) { +static bool testBeep(void) { extern uint8_t beepCount; extern uint16_t beepLength; extern uint8_t oscCount; @@ -82,7 +82,7 @@ return true; } -bool testAlert(void) { +static bool testAlert(void) { extern uint8_t beepCount; extern uint16_t beepLength; extern uint8_t oscCount; @@ -102,7 +102,7 @@ return true; } -bool testCancelAlert(void) { +static bool testCancelAlert(void) { extern uint8_t beepCount; extern uint16_t beepLength; extern uint8_t oscCount; diff --git a/lambda-test/command-test.c b/lambda-test/command-test.c index 145bf32..afa4b7a 100644 --- a/lambda-test/command-test.c +++ b/lambda-test/command-test.c @@ -17,7 +17,7 @@ /* Module command */ -bool testIsSimulation(void) { +static bool testIsSimulation(void) { setupPorts(); setHeatingOn(false); @@ -34,7 +34,7 @@ return true; } -bool testIsLogging(void) { +static bool testIsLogging(void) { assertFalse(isLogging()); runCommand("le"); assertTrue(isLogging()); @@ -44,7 +44,7 @@ return true; } -bool testHeating(void) { +static bool testHeating(void) { setupPorts(); setHeatingOn(false); @@ -57,7 +57,7 @@ return true; } -bool testCycleDisplay(void) { +static bool testCycleDisplay(void) { extern uint8_t position; cancelAlert(true); diff --git a/lambda-test/display-test.c b/lambda-test/display-test.c index ce6be96..3535d74 100644 --- a/lambda-test/display-test.c +++ b/lambda-test/display-test.c @@ -16,7 +16,7 @@ /* Module display */ -bool testCycle(void) { +static bool testCycle(void) { extern uint8_t position; extern bool updatePending; @@ -48,7 +48,7 @@ return true; } -bool testCycleCancelAlert(void) { +static bool testCycleCancelAlert(void) { extern uint8_t position; extern bool updatePending; @@ -66,7 +66,7 @@ return true; } -bool testUpdateMeas(void) { +static bool testUpdateMeas(void) { extern bool updatePending; extern Measurement measLatest; extern Measurement measMax; // = {0, 0, 2000}; @@ -106,7 +106,7 @@ return true; } -bool testResetMeas(void) { +static bool testResetMeas(void) { extern bool updatePending; extern Measurement measLatest; extern Measurement measMax; @@ -123,7 +123,7 @@ return true; } -bool testUpdateDisplayIfPending(void) { +static bool testUpdateDisplayIfPending(void) { extern bool updatePending; updatePending = true; @@ -134,7 +134,7 @@ return true; } -bool testUpdateDisplayIfPendingAlertActive(void) { +static bool testUpdateDisplayIfPendingAlertActive(void) { extern bool updatePending; updatePending = true; @@ -148,7 +148,7 @@ return true; } -bool testDisplayText(void) { +static bool testDisplayText(void) { displayText("testDisplayText", "testDisplayTextLineTooLong"); return true; diff --git a/lambda-test/integers-test.c b/lambda-test/integers-test.c index 6d52ebc..41223ad 100644 --- a/lambda-test/integers-test.c +++ b/lambda-test/integers-test.c @@ -13,7 +13,7 @@ /* Module integers */ -bool testDivRoundNearest(void) { +static bool testDivRoundNearest(void) { assertTrue(divRoundNearest(4, 2) == 2); assertTrue(divRoundNearest(5, 2) == 3); assertTrue(divRoundNearest(10, 3) == 3); @@ -21,7 +21,7 @@ return true; } -bool testDivRoundNearestNumNeg(void) { +static bool testDivRoundNearestNumNeg(void) { assertTrue(divRoundNearest(-4, 2) == -2); assertTrue(divRoundNearest(-5, 2) == -3); assertTrue(divRoundNearest(-10, 3) == -3); @@ -29,7 +29,7 @@ return true; } -bool testDivRoundNearestDenNeg(void) { +static bool testDivRoundNearestDenNeg(void) { assertTrue(divRoundNearest(4, -2) == -2); assertTrue(divRoundNearest(5, -2) == -3); assertTrue(divRoundNearest(10, -3) == -3); @@ -37,7 +37,7 @@ return true; } -bool testDivRoundNearestBothNeg(void) { +static bool testDivRoundNearestBothNeg(void) { assertTrue(divRoundNearest(-4, -2) == 2); assertTrue(divRoundNearest(-5, -2) == 3); assertTrue(divRoundNearest(-10, -3) == 3); @@ -45,7 +45,7 @@ return true; } -bool testDivRoundUp(void) { +static bool testDivRoundUp(void) { assertTrue(divRoundUp(4, 2) == 2); assertTrue(divRoundUp(5, 2) == 3); assertTrue(divRoundUp(10, 3) == 4); @@ -53,7 +53,7 @@ return true; } -bool testDivRoundUpNumNeg(void) { +static bool testDivRoundUpNumNeg(void) { assertTrue(divRoundUp(-4, 2) == -2); assertTrue(divRoundUp(-5, 2) == -3); assertTrue(divRoundUp(-10, 3) == -4); @@ -61,7 +61,7 @@ return true; } -bool testDivRoundUpDenNeg(void) { +static bool testDivRoundUpDenNeg(void) { assertTrue(divRoundUp(4, -2) == -2); assertTrue(divRoundUp(5, -2) == -3); assertTrue(divRoundUp(10, -3) == -4); @@ -69,7 +69,7 @@ return true; } -bool testDivRoundUpBothNeg(void) { +static bool testDivRoundUpBothNeg(void) { assertTrue(divRoundUp(-4, -2) == 2); assertTrue(divRoundUp(-5, -2) == 3); assertTrue(divRoundUp(-10, -3) == 4); diff --git a/lambda-test/interrupts-test.c b/lambda-test/interrupts-test.c index 45fe032..8e7902e 100644 --- a/lambda-test/interrupts-test.c +++ b/lambda-test/interrupts-test.c @@ -15,7 +15,7 @@ /* Module interrupts */ -bool testSetupPorts(void) { +static bool testSetupPorts(void) { setupPorts(); // test that the pull-up resistor for the mouton is enabled @@ -30,7 +30,7 @@ return true; } -bool testSetupSleepMode(void) { +static bool testSetupSleepMode(void) { setupSleepMode(); // set_sleep_mode(SLEEP_MODE_IDLE); @@ -41,7 +41,7 @@ return true; } -bool testInitInterrupts(void) { +static bool testInitInterrupts(void) { initInterrupts(); // ADC interrupt enabled @@ -60,7 +60,7 @@ return true; } -bool testInitTimers(void) { +static bool testInitTimers(void) { initTimers(); // timer0 clock prescaler /64 = 15.625 kHz overflowing every 16.2 ms @@ -79,7 +79,7 @@ return true; } -bool testTime(void) { +static bool testTime(void) { resetTime(); assertTrue(getInts() == 0); assertTrue(getTime() == 0); diff --git a/lambda-test/rules-test.c b/lambda-test/rules-test.c index c40f504..4205398 100644 --- a/lambda-test/rules-test.c +++ b/lambda-test/rules-test.c @@ -11,6 +11,7 @@ #include "avrjunit.h" #include "rules.h" #include "alert.h" +#include "interrupts.h" extern uint16_t age; extern int8_t dir; @@ -18,7 +19,7 @@ /* Module rules */ -bool testAirgate50(void) { +static bool testAirgate50(void) { Measurement meas = {0, 0, 0}; @@ -59,7 +60,7 @@ return true; } -bool testAirgate25(void) { +static bool testAirgate25(void) { Measurement meas = {999, 0, 0}; @@ -100,7 +101,7 @@ return true; } -bool testAirgateClose(void) { +static bool testAirgateClose(void) { Measurement meas = {999, 0, 0}; @@ -141,7 +142,7 @@ return true; } -bool testTooRich(void) { +static bool testTooRich(void) { Measurement meas = {0, 0, 0}; dir = 0; @@ -183,7 +184,7 @@ return true; } -bool testFireOut(void) { +static bool testFireOut(void) { resetRules(); Measurement meas = {0, 0, 0}; @@ -219,46 +220,111 @@ return true; } -bool testHeatingReady(void) { +static bool testHeatingReady(void) { resetRules(); + resetTime(); Measurement meas = {0, 0, 0}; dir = 1; + setHeatingOn(false); + meas.current = 1300; + reason(meas); + assertTrue(HEATING_OFF == getHeatingState()); + setHeatingOn(true); + meas.current = 5000; + reason(meas); + assertTrue(HEATING_UP == getHeatingState()); + + setHeatingOn(true); + meas.current = 1300; + reason(meas); + assertTrue(HEATING_READY == getHeatingState()); cancelAlert(false); return true; } -bool testHeatingFault(void) { +static bool testHeatingFaultNoconn(void) { resetRules(); + resetTime(); Measurement meas = {0, 0, 0}; dir = 1; - + setHeatingOn(true); + meas.current = 0; + reason(meas); + assertTrue(HEATING_FAULT == getHeatingState()); cancelAlert(false); return true; } -bool testHeatingTimeout(void) { +static bool testHeatingFaultShort(void) { resetRules(); + resetTime(); Measurement meas = {0, 0, 0}; dir = 1; - + setHeatingOn(true); + meas.current = 8000; + reason(meas); + assertTrue(HEATING_FAULT == getHeatingState()); cancelAlert(false); return true; } -bool testReasonDirBurnUp(void) { +static bool testHeatingFaultNoheat(void) { + + resetRules(); + resetTime(); + Measurement meas = {0, 0, 0}; + dir = 1; + + setHeatingOn(true); + + // more than 3 mins + addInts(INTS_PER_SEC * 181); + + meas.current = 5000; + reason(meas); + assertTrue(HEATING_FAULT == getHeatingState()); + + cancelAlert(false); + + return true; +} + +static bool testHeatingTimeout(void) { + + resetRules(); + resetTime(); + Measurement meas = {0, 0, 0}; + dir = 1; + + setHeatingOn(true); + + // more than 3 hours below 400°C + addInts(INTS_PER_SEC * 10800UL); + + meas.tempI = 300; + meas.current = 1300; + reason(meas); + assertTrue(HEATING_OFF == getHeatingState()); + + cancelAlert(false); + + return true; +} + +static bool testReasonDirBurnUp(void) { resetRules(); Measurement meas = {0, 0, 2000}; @@ -314,7 +380,7 @@ return true; } -bool testReasonDirBurnDown(void) { +static bool testReasonDirBurnDown(void) { resetRules(); Measurement meas = {999, 0, 1999}; @@ -374,7 +440,9 @@ static const char testTooRich_P[] PROGMEM = "testTooRich"; static const char testFireOut_P[] PROGMEM = "testFireOut"; static const char testHeatingReady_P[] PROGMEM = "testHeatingReady"; -static const char testHeatingFault_P[] PROGMEM = "testHeatingFault"; +static const char testHeatingFaultNoconn_P[] PROGMEM = "testHeatingFaultNoconn"; +static const char testHeatingFaultShort_P[] PROGMEM = "testHeatingFaultShort"; +static const char testHeatingFaultNoheat_P[] PROGMEM = "testHeatingFaultNoheat"; static const char testHeatingTimeout_P[] PROGMEM = "testHeatingTimeout"; static const char testReasonDirBurnUp_P[] PROGMEM = "testReasonDirBurnUp"; static const char testReasonDirBurnDown_P[] PROGMEM = "testReasonDirBurnDown"; @@ -387,7 +455,9 @@ {class, testTooRich_P, testTooRich}, {class, testFireOut_P, testFireOut}, {class, testHeatingReady_P, testHeatingReady}, - {class, testHeatingFault_P, testHeatingFault}, + {class, testHeatingFaultNoconn_P, testHeatingFaultNoconn}, + {class, testHeatingFaultShort_P, testHeatingFaultShort}, + {class, testHeatingFaultNoheat_P, testHeatingFaultNoheat}, {class, testHeatingTimeout_P, testHeatingTimeout}, {class, testReasonDirBurnUp_P, testReasonDirBurnUp}, {class, testReasonDirBurnDown_P, testReasonDirBurnDown} diff --git a/lambda-test/sensors-test.c b/lambda-test/sensors-test.c index eb57a3e..95679e1 100644 --- a/lambda-test/sensors-test.c +++ b/lambda-test/sensors-test.c @@ -26,7 +26,7 @@ /* Module sensors */ -bool testMeasure(void) { +static bool testMeasure(void) { setupADC(); setupSleepMode(); initInterrupts(); @@ -55,7 +55,7 @@ return true; } -bool testReadMeas(void) { +static bool testReadMeas(void) { char* fields[] = {"1", "2", "3", "4"}; Measurement meas = readMeas(fields, 4); @@ -67,7 +67,7 @@ return true; } -bool testReadMeasTooFewFields(void) { +static bool testReadMeasTooFewFields(void) { char* fields[] = {"1"}; Measurement meas = readMeas(fields, 1); @@ -79,91 +79,91 @@ return true; } -bool testToLambdaValue(void) { +static bool testToLambdaValue(void) { uint16_t lambda = toLambda(132); return lambda == 1500; } -bool testToLambdaInter(void) { +static bool testToLambdaInter(void) { uint16_t lambda = toLambda(550); return lambda == 1073; } -bool testToTempI(void) { +static bool testToTempI(void) { int16_t temp = toTempI(100); return temp == 20; } -bool testToTempOValue(void) { +static bool testToTempOValue(void) { int16_t temp = toTempO(454); return temp == 0; } -bool testToTempOInter(void) { +static bool testToTempOInter(void) { int16_t temp = toTempO(929); return temp == 50; } -bool testToCurrent(void) { +static bool testToCurrent(void) { uint16_t current = toCurrent(150); return current == 1500 / SHUNT_MILLIOHMS * 100; } -bool testLookupLinInterBelow(void) { +static bool testLookupLinInterBelow(void) { int16_t value = lookupLinInter(0, testTable, 2); return value == 10; } -bool testLookupLinInterAbove(void) { +static bool testLookupLinInterAbove(void) { int16_t value = lookupLinInter(30, testTable, 2); return value == 20; } -bool testLookupLinInterValue(void) { +static bool testLookupLinInterValue(void) { int16_t value = lookupLinInter(10, testTable, 2); return value == 10; } -bool testLookupLinInterInter(void) { +static bool testLookupLinInterInter(void) { int16_t value = lookupLinInter(15, testTable, 2); return value == 15; } -bool testLinADCLow(void) { +static bool testLinADCLow(void) { int32_t lin = linADC(1000); return lin == 1004; } -bool testLinADCMid(void) { +static bool testLinADCMid(void) { int32_t lin = linADC(2000); return lin == 2000; } -bool testLinADCHigh(void) { +static bool testLinADCHigh(void) { int32_t lin = linADC(4000); return lin == 3992; } -bool testToInfoLean(void) { +static bool testToInfoLean(void) { char* info = toInfo(191); return ! strcmp(info, MSG_LEAN); } -bool testToInfoOkay(void) { +static bool testToInfoOkay(void) { assertTrue(0 == strcmp(toInfo(190), MSG_OKAY)); assertTrue(0 == strcmp(toInfo(170), MSG_OKAY)); assertTrue(0 == strcmp(toInfo(151), MSG_OKAY)); @@ -171,7 +171,7 @@ return true; } -bool testToInfoIdeal(void) { +static bool testToInfoIdeal(void) { assertTrue(0 == strcmp(toInfo(150), MSG_IDEAL)); assertTrue(0 == strcmp(toInfo(140), MSG_IDEAL)); assertTrue(0 == strcmp(toInfo(130), MSG_IDEAL)); @@ -179,13 +179,13 @@ return true; } -bool testToInfoRich(void) { +static bool testToInfoRich(void) { char* info = toInfo(129); return ! strcmp(info, MSG_RICH); } -bool testSetHeatingOn(void) { +static bool testSetHeatingOn(void) { setHeatingOn(true); assertTrue(isHeatingOn()); assertTrue(HEATING_UP == getHeatingState()); @@ -197,7 +197,7 @@ return true; } -bool testSetHeatingState(void) { +static bool testSetHeatingState(void) { setHeatingOn(false); assertFalse(isHeatingOn()); assertTrue(HEATING_OFF == getHeatingState()); diff --git a/lambda-test/strings-test.c b/lambda-test/strings-test.c index 1d44f51..4ae4297 100644 --- a/lambda-test/strings-test.c +++ b/lambda-test/strings-test.c @@ -14,7 +14,7 @@ /* Module strings */ -bool testSplit(void) { +static bool testSplit(void) { char string[] = "f1 f2 f3 "; char* fields[4]; split(string, " ", fields, 4); @@ -27,7 +27,7 @@ return true; } -bool testSplitSizeTooSmall(void) { +static bool testSplitSizeTooSmall(void) { char string[] = "f1 f2"; char* fields[1]; split(string, " ", fields, 1); diff --git a/lambda-test/usart-test.c b/lambda-test/usart-test.c index 4e1324e..d1a0619 100644 --- a/lambda-test/usart-test.c +++ b/lambda-test/usart-test.c @@ -14,7 +14,7 @@ /* Module usart */ -bool testInitUSART(void) { +static bool testInitUSART(void) { assertTrue(BAUD); initUSART();