diff --git a/main.c b/main.c index a48da56..37f17e6 100644 --- a/main.c +++ b/main.c @@ -1,7 +1,7 @@ #include #include #include -#include "nex_ui.h" +//#include "nex_ui.h" #include @@ -86,7 +86,7 @@ void PortConfig(void) void uart2_init(void) { - RCC->APB2ENR |= RCC_APB2ENR_AFIOEN | RCC_APB2ENR_IOPAEN; + RCC->APB2ENR |= RCC_APB2ENR_AFIOEN | RCC_APB2ENR_IOPAEN; // 0x4 RCC->APB1ENR |= 0x20000; // UART2 Taktversorgung GPIOA->CRL &= 0xFFFFF0FF; @@ -146,7 +146,7 @@ void configNexObjects(void) void fehler(bool state) { - static bool lastStateF = true; + static bool lastStateF = true; static bool firstCallF = true; if (firstCallF) @@ -179,7 +179,7 @@ void fehler(bool state) void leerBlasen(bool state) { - static bool lastStateB; + static bool lastStateB; static bool firstCallB = true; if (firstCallB) @@ -194,7 +194,7 @@ void leerBlasen(bool state) } lastStateB = state; - + if(state) { NexProgressBar_setValue(&leerInd, 100); @@ -213,7 +213,7 @@ void leerBlasen(bool state) void fein(bool state) { - static bool lastStateFein; + static bool lastStateFein; static bool firstCallFein = true; if (firstCallFein) @@ -228,7 +228,6 @@ void fein(bool state) } lastStateFein = state; - if(state) { NexProgressBar_setValue(&feinInd, 100); @@ -247,7 +246,7 @@ void fein(bool state) void grob(bool state) { - static bool lastStateGrob; + static bool lastStateGrob; static bool firstCallGrob = true; if (firstCallGrob) @@ -262,7 +261,7 @@ void grob(bool state) } lastStateGrob = state; - + if(state) { NexProgressBar_setValue(&grobInd, 100); @@ -281,7 +280,7 @@ void grob(bool state) void pumpe(bool state) { - static bool lastState; + static bool lastState; static bool firstCall = true; if (firstCall) @@ -296,12 +295,12 @@ void pumpe(bool state) } lastState = state; - + if(state) { NexProgressBar_setValue(&pumpeInd, 100); PUMPE = 1; - uart2_putString("Pumpe eingeschaltet!\r\n"); + //uart2_putString("Pumpe eingeschaltet!\r\n"); } else { @@ -323,25 +322,24 @@ void fuellstand(int8_t value) NexProgressBar_setValue(&fuellstandInd, 0); return; } - - if (value == lastValue) + else if (value == lastValue) { - return; // nichts geƤndert ? nichts tun - } - - lastValue = value; - - if (value >= 0 && value <= 100) - { - NexProgressBar_setValue(&fuellstandInd, value); - uart2_putString("Fuellstand geaendert!\r\n"); - } - else - { - NexProgressBar_setValue(&fuellstandInd, 0); - uart2_putString("Ungueltiger Fuellstandswert!\r\n"); + return; } + + lastValue = value; + if(value >= 0 && value <= 100) + { + NexProgressBar_setValue(&fuellstandInd, value); + uart2_putString("Fuellstand geaendert!\r\n"); + } + else + { + NexProgressBar_setValue(&fuellstandInd, 0); + uart2_putString("Uengueltiger Fuellstandswert!\r\n"); + } } + uint8_t toPercent(uint8_t value, uint8_t max) { if (value > max) value = max; @@ -449,11 +447,19 @@ int main(void) if(leitungBenutzt) { int time = 3000 / NACHLAUF; + int rest = 3000 % NACHLAUF; uint8_t i = 0; for(i = 0; i < NACHLAUF; i++) { wait_sys_ms(time); + + if(rest > 0) + { + wait_sys_ms(1); + rest -= 1; + } + nachlaufOffset += 1; setFuellstand(istWert + nachlaufOffset); }