USART2 Ausgabe gefixt 2.0

This commit is contained in:
Dorian Karl Strohmayr 2026-02-10 22:20:36 +00:00
parent d3a9560d79
commit 6547cc23c5

26
main.c
View File

@ -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,15 +322,13 @@ 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)
if(value >= 0 && value <= 100)
{
NexProgressBar_setValue(&fuellstandInd, value);
uart2_putString("Fuellstand geaendert!\r\n");
@ -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);
}