USART2 Ausgabe gefixt 2.0
This commit is contained in:
parent
d3a9560d79
commit
6547cc23c5
62
main.c
62
main.c
@ -1,7 +1,7 @@
|
||||
#include <stm32f10x.h>
|
||||
#include <armv30_std.h>
|
||||
#include <Nextion.h>
|
||||
#include "nex_ui.h"
|
||||
//#include "nex_ui.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user