main.c aktualisiert
This commit is contained in:
parent
89625f8966
commit
bd178f6632
119
main.c
119
main.c
@ -37,6 +37,9 @@ NexEventObj fuellstandText;
|
||||
|
||||
//---------------------Variablen------------------------
|
||||
|
||||
#define NEX_PID_MAIN 0
|
||||
#define NEX_CID_PROG 1
|
||||
|
||||
#define SOLLWERT 0x7F // 127d
|
||||
#define GAP 0x5F // 95d
|
||||
#define NACHLAUF 0x5
|
||||
@ -120,75 +123,48 @@ char uart2_getChar(void)
|
||||
return ((char) (USART2->DR & 0xFF));
|
||||
}
|
||||
|
||||
void configProgressBar(void)
|
||||
static void NexEventObj_Init(NexEventObj *obj, uint8_t pid, uint8_t cid, const char *name)
|
||||
{
|
||||
fuellstandInd.pid = 0;
|
||||
fuellstandInd.cid = 1;
|
||||
fuellstandInd.name = "fuellstand";
|
||||
fuellstandInd.pophandler = NULL;
|
||||
fuellstandInd.pushhandler = NULL;
|
||||
|
||||
fehlerInd.pid = 0;
|
||||
fehlerInd.cid = 1;
|
||||
fehlerInd.name = "fehlerInd";
|
||||
fehlerInd.pophandler = NULL;
|
||||
fehlerInd.pushhandler = NULL;
|
||||
|
||||
leerInd.pid = 0;
|
||||
leerInd.cid = 1;
|
||||
leerInd.name = "leerInd";
|
||||
leerInd.pophandler = NULL;
|
||||
leerInd.pushhandler = NULL;
|
||||
|
||||
feinInd.pid = 0;
|
||||
feinInd.cid = 1;
|
||||
feinInd.name = "feinInd";
|
||||
feinInd.pophandler = NULL;
|
||||
feinInd.pushhandler = NULL;
|
||||
|
||||
grobInd.pid = 0;
|
||||
grobInd.cid = 1;
|
||||
grobInd.name = "grobInd";
|
||||
grobInd.pophandler = NULL;
|
||||
grobInd.pushhandler = NULL;
|
||||
|
||||
pumpeInd.pid = 0;
|
||||
pumpeInd.cid = 1;
|
||||
pumpeInd.name = "pumpeInd";
|
||||
pumpeInd.pophandler = NULL;
|
||||
pumpeInd.pushhandler = NULL;
|
||||
obj->pid = pid;
|
||||
obj->cid = cid;
|
||||
obj->name = name;
|
||||
obj->pophandler = NULL;
|
||||
obj->pushhandler = NULL;
|
||||
}
|
||||
|
||||
void configTextFields(void)
|
||||
void configNexObjects(void)
|
||||
{
|
||||
fuellstandText.pid = 0;
|
||||
fuellstandText.cid = 1; // Component ID aus Nextion Editor
|
||||
fuellstandText.name = "fuellstandn"; // Exakter Name!
|
||||
fuellstandText.pophandler = NULL;
|
||||
fuellstandText.pushhandler = NULL;
|
||||
NexEventObj_Init(&fuellstandInd, NEX_PID_MAIN, NEX_CID_PROG, "fuellstand");
|
||||
NexEventObj_Init(&fehlerInd, NEX_PID_MAIN, NEX_CID_PROG, "fehlerInd");
|
||||
NexEventObj_Init(&leerInd, NEX_PID_MAIN, NEX_CID_PROG, "leerInd");
|
||||
NexEventObj_Init(&feinInd, NEX_PID_MAIN, NEX_CID_PROG, "feinInd");
|
||||
NexEventObj_Init(&grobInd, NEX_PID_MAIN, NEX_CID_PROG, "grobInd");
|
||||
NexEventObj_Init(&pumpeInd, NEX_PID_MAIN, NEX_CID_PROG, "pumpeInd");
|
||||
|
||||
NexEventObj_Init(&fuellstandText, NEX_PID_MAIN, NEX_CID_PROG, "fuellstandn");
|
||||
}
|
||||
|
||||
void fehler(int8_t state)
|
||||
void fehler(bool state)
|
||||
{
|
||||
if(state == 1)
|
||||
if(state)
|
||||
{
|
||||
NexProgressBar_setValue(&fehlerInd, 100);
|
||||
FEHLER = 1;
|
||||
uart2_putString("Fehler aufgetreten!\r\n");
|
||||
//uart2_putString("Fehler aufgetreten!\r\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
NexProgressBar_setValue(&fehlerInd, 0);
|
||||
FEHLER = 0;
|
||||
uart2_putString("Fehler behoben!\r\n");
|
||||
//uart2_putString("Fehler behoben!\r\n");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void leerBlasen(int8_t state)
|
||||
void leerBlasen(bool state)
|
||||
{
|
||||
if(state == 1)
|
||||
if(state)
|
||||
{
|
||||
NexProgressBar_setValue(&leerInd, 100);
|
||||
LEERBLASEN = 1;
|
||||
@ -204,9 +180,9 @@ void leerBlasen(int8_t state)
|
||||
return;
|
||||
}
|
||||
|
||||
void fein(int8_t state)
|
||||
void fein(bool state)
|
||||
{
|
||||
if(state == 1)
|
||||
if(state)
|
||||
{
|
||||
NexProgressBar_setValue(&feinInd, 100);
|
||||
FEIN = 1;
|
||||
@ -222,9 +198,9 @@ void fein(int8_t state)
|
||||
return;
|
||||
}
|
||||
|
||||
void grob(int8_t state)
|
||||
void grob(bool state)
|
||||
{
|
||||
if(state == 1)
|
||||
if(state)
|
||||
{
|
||||
NexProgressBar_setValue(&grobInd, 100);
|
||||
GROB = 1;
|
||||
@ -240,9 +216,9 @@ void grob(int8_t state)
|
||||
return;
|
||||
}
|
||||
|
||||
void pumpe(int8_t state)
|
||||
void pumpe(bool state)
|
||||
{
|
||||
if(state == 1)
|
||||
if(state)
|
||||
{
|
||||
NexProgressBar_setValue(&pumpeInd, 100);
|
||||
PUMPE = 1;
|
||||
@ -309,17 +285,16 @@ int main(void)
|
||||
uart2_init();
|
||||
|
||||
NexEventObj *nextlisten_list[] = {NULL};
|
||||
configProgressBar();
|
||||
configTextFields();
|
||||
configNexObjects();
|
||||
Nex_Init(0);
|
||||
Init_Nex_UI();
|
||||
|
||||
fuellstand(0);
|
||||
fehler(0);
|
||||
leerBlasen(0);
|
||||
fein(0);
|
||||
grob(0);
|
||||
pumpe(0);
|
||||
fehler(false);
|
||||
leerBlasen(false);
|
||||
fein(false);
|
||||
grob(false);
|
||||
pumpe(false);
|
||||
wait_sys_ms(20);
|
||||
|
||||
bool leerGeblasen = false;
|
||||
@ -339,30 +314,30 @@ int main(void)
|
||||
leerGeblasen = true;
|
||||
leitungBenutzt = false;
|
||||
|
||||
pumpe(1);
|
||||
pumpe(true);
|
||||
|
||||
if(effektiverWert < SOLLWERT - NACHLAUF)
|
||||
{
|
||||
fein(1);
|
||||
fein(true);
|
||||
leitungBenutzt = true;
|
||||
}
|
||||
else if(effektiverWert >= SOLLWERT - NACHLAUF)
|
||||
{
|
||||
fein(0);
|
||||
fein(false);
|
||||
}
|
||||
|
||||
if(effektiverWert < GAP)
|
||||
{
|
||||
grob(1);
|
||||
grob(true);
|
||||
leitungBenutzt = true;
|
||||
}
|
||||
else if(effektiverWert < SOLLWERT)
|
||||
{
|
||||
grob(0);
|
||||
grob(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
grob(0);
|
||||
grob(false);
|
||||
}
|
||||
|
||||
setFuellstand(effektiverWert);
|
||||
@ -372,10 +347,10 @@ int main(void)
|
||||
{
|
||||
if(leerGeblasen)
|
||||
{
|
||||
pumpe(0);
|
||||
grob(0);
|
||||
fein(0);
|
||||
leerBlasen(1);
|
||||
pumpe(false);
|
||||
grob(false);
|
||||
fein(false);
|
||||
leerBlasen(true);
|
||||
|
||||
if(leitungBenutzt)
|
||||
{
|
||||
@ -394,7 +369,7 @@ int main(void)
|
||||
wait_sys_ms(3000);
|
||||
}
|
||||
|
||||
leerBlasen(0);
|
||||
leerBlasen(false);
|
||||
leerGeblasen = false;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user