main.c aktualisiert
This commit is contained in:
parent
00dc991ce3
commit
c5aa70028e
192
main.c
192
main.c
@ -3,11 +3,16 @@
|
|||||||
#include <Nextion.h>
|
#include <Nextion.h>
|
||||||
#include "nex_ui.h"
|
#include "nex_ui.h"
|
||||||
|
|
||||||
extern NexEventObj fuellstand;
|
//extern NexEventObj fuellstand;
|
||||||
NexEventObj *nextlisten_list[]= {NULL};
|
//NexEventObj *nextlisten_list[]= {NULL};
|
||||||
|
|
||||||
|
NexEventObj fuellstandInd;
|
||||||
|
NexEventObj pumpeInd;
|
||||||
|
NexEventObj leerInd;
|
||||||
|
NexEventObj feinInd;
|
||||||
|
NexEventObj grobInd;
|
||||||
|
NexEventObj fehlerInd;
|
||||||
|
|
||||||
NexEventObj fuellstand_j0;
|
|
||||||
NexEventObj fuellstand_n0;
|
|
||||||
|
|
||||||
//---------------------Alias-Defines------------------------
|
//---------------------Alias-Defines------------------------
|
||||||
|
|
||||||
@ -30,9 +35,9 @@ void SysTick_Handler()
|
|||||||
|
|
||||||
void PortConfig(void)
|
void PortConfig(void)
|
||||||
{
|
{
|
||||||
RCC -> APB2ENR |= RCC_APB2ENR_IOPCEN; //Takt für Port C aktivieren
|
RCC -> APB2ENR |= RCC_APB2ENR_IOPCEN; //Takt für Port C aktivieren
|
||||||
RCC -> APB2ENR |= RCC_APB2ENR_IOPBEN; //Takt für Port B aktivieren
|
RCC -> APB2ENR |= RCC_APB2ENR_IOPBEN; //Takt für Port B aktivieren
|
||||||
RCC -> APB2ENR |= RCC_APB2ENR_IOPAEN; //Takt für Port A aktivieren
|
RCC -> APB2ENR |= RCC_APB2ENR_IOPAEN; //Takt für Port A aktivieren
|
||||||
|
|
||||||
GPIOC -> CRL &= 0x00000000;
|
GPIOC -> CRL &= 0x00000000;
|
||||||
GPIOC -> CRL = 0x22222222;
|
GPIOC -> CRL = 0x22222222;
|
||||||
@ -85,28 +90,183 @@ char uart2_getChar(void)
|
|||||||
return ((char) (USART2->DR & 0xFF));
|
return ((char) (USART2->DR & 0xFF));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void configProgressBar(void)
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
void fehler(int8_t state)
|
||||||
|
{
|
||||||
|
if(state == 1)
|
||||||
|
{
|
||||||
|
NexProgressBar_setValue(&fehlerInd, 100);
|
||||||
|
FEHLER = 1;
|
||||||
|
uart2_putString("Fehler aufgetreten!\r\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NexProgressBar_setValue(&fehlerInd, 0);
|
||||||
|
FEHLER = 0;
|
||||||
|
uart2_putString("Fehler behoben!\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void leerBlasen(int8_t state)
|
||||||
|
{
|
||||||
|
if(state == 1)
|
||||||
|
{
|
||||||
|
NexProgressBar_setValue(&leerInd, 100);
|
||||||
|
LEERBLASEN = 1;
|
||||||
|
uart2_putString("Leerblasventil geoeffnet!\r\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NexProgressBar_setValue(&leerInd, 0);
|
||||||
|
LEERBLASEN = 0;
|
||||||
|
uart2_putString("Leerblasventil geschlossen!\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void fein(int8_t state)
|
||||||
|
{
|
||||||
|
if(state == 1)
|
||||||
|
{
|
||||||
|
NexProgressBar_setValue(&feinInd, 100);
|
||||||
|
FEIN = 1;
|
||||||
|
uart2_putString("Feinventil geoeffnet!\r\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NexProgressBar_setValue(&feinInd, 0);
|
||||||
|
FEIN = 0;
|
||||||
|
uart2_putString("Feinventil geschlossen!\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void grob(int8_t state)
|
||||||
|
{
|
||||||
|
if(state == 1)
|
||||||
|
{
|
||||||
|
NexProgressBar_setValue(&grobInd, 100);
|
||||||
|
GROB = 1;
|
||||||
|
uart2_putString("Grobventil geoeffnet!\r\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NexProgressBar_setValue(&grobInd, 0);
|
||||||
|
GROB = 0;
|
||||||
|
uart2_putString("Grobventil geoeffnet!\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void pumpe(int8_t state)
|
||||||
|
{
|
||||||
|
if(state == 1)
|
||||||
|
{
|
||||||
|
NexProgressBar_setValue(&pumpeInd, 100);
|
||||||
|
PUMPE = 1;
|
||||||
|
uart2_putString("Pumpe eingeschaltet!\r\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NexProgressBar_setValue(&pumpeInd, 0);
|
||||||
|
PUMPE = 0;
|
||||||
|
uart2_putString("Pumpe ausgeschaltet!\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void fuellstand(int8_t 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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
PortConfig();
|
PortConfig();
|
||||||
uart2_init();
|
uart2_init();
|
||||||
|
|
||||||
|
NexEventObj *nextlisten_list[] = {NULL};
|
||||||
|
configProgressBar();
|
||||||
Nex_Init(0);
|
Nex_Init(0);
|
||||||
Init_Nex_UI();
|
Init_Nex_UI();
|
||||||
|
|
||||||
uart2_putString("Dosieranlage V01 ");
|
uart2_putString("Dosieranlage V01\r\n");
|
||||||
|
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
// Nex_Event_Loop(nextlisten_list); // Touch Event ?
|
Nex_Event_Loop(nextlisten_list);
|
||||||
|
wait_sys_ms(20);
|
||||||
|
|
||||||
NexProgressBar_setValue(&fuellstand, 100);
|
fuellstand(67);
|
||||||
|
fehler(1);
|
||||||
|
leerBlasen(1);
|
||||||
|
fein(1);
|
||||||
|
grob(1);
|
||||||
|
pumpe(1);
|
||||||
|
|
||||||
wait_sys_ms(1);
|
wait_sys_ms(3000);
|
||||||
|
|
||||||
FEHLER = 1;
|
fuellstand(10);
|
||||||
LEERBLASEN = 1;
|
fehler(0);
|
||||||
FEIN = 1;
|
leerBlasen(0);
|
||||||
GROB = 1;
|
fein(0);
|
||||||
PUMPE = 1;
|
grob(0);
|
||||||
|
pumpe(0);
|
||||||
|
|
||||||
|
wait_sys_ms(3000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user