USART2 Ausgabe gefixt 2.0
This commit is contained in:
parent
d3a9560d79
commit
6547cc23c5
24
main.c
24
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;
|
||||
@ -228,7 +228,6 @@ void fein(bool state)
|
||||
}
|
||||
|
||||
lastStateFein = state;
|
||||
|
||||
if(state)
|
||||
{
|
||||
NexProgressBar_setValue(&feinInd, 100);
|
||||
@ -301,7 +300,7 @@ void pumpe(bool state)
|
||||
{
|
||||
NexProgressBar_setValue(&pumpeInd, 100);
|
||||
PUMPE = 1;
|
||||
uart2_putString("Pumpe eingeschaltet!\r\n");
|
||||
//uart2_putString("Pumpe eingeschaltet!\r\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -323,14 +322,12 @@ void fuellstand(int8_t value)
|
||||
NexProgressBar_setValue(&fuellstandInd, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (value == lastValue)
|
||||
else if (value == lastValue)
|
||||
{
|
||||
return; // nichts geändert ? nichts tun
|
||||
return;
|
||||
}
|
||||
|
||||
lastValue = value;
|
||||
|
||||
if(value >= 0 && value <= 100)
|
||||
{
|
||||
NexProgressBar_setValue(&fuellstandInd, value);
|
||||
@ -339,9 +336,10 @@ void fuellstand(int8_t value)
|
||||
else
|
||||
{
|
||||
NexProgressBar_setValue(&fuellstandInd, 0);
|
||||
uart2_putString("Ungueltiger Fuellstandswert!\r\n");
|
||||
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