main.c aktualisiert
This commit is contained in:
parent
6dbe624e41
commit
9ed1d398c7
110
main.c
110
main.c
@ -1,10 +1,15 @@
|
||||
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!!!!!!!!!! !!!!!!!!!!
|
||||
!!!!!!!!!! Hab ein bischen herumprobiert. Ich versteh nicht wie wir die Angabe umsetzen sollen !!!!!!!!!!
|
||||
!!!!!!!!!! !!!!!!!!!!
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
|
||||
|
||||
#include <stm32f10x.h>
|
||||
#include <armv30_std.h>
|
||||
#include <Nextion.h>
|
||||
#include "nex_ui.h"
|
||||
|
||||
//extern NexEventObj fuellstand;
|
||||
//NexEventObj *nextlisten_list[]= {NULL};
|
||||
//---------------------Nextion-Objekte------------------------
|
||||
|
||||
NexEventObj fuellstandInd;
|
||||
NexEventObj pumpeInd;
|
||||
@ -13,6 +18,10 @@ NexEventObj feinInd;
|
||||
NexEventObj grobInd;
|
||||
NexEventObj fehlerInd;
|
||||
|
||||
NexEventObj fuellstandText;
|
||||
|
||||
|
||||
|
||||
|
||||
//---------------------Alias-Defines------------------------
|
||||
|
||||
@ -33,7 +42,11 @@ NexEventObj fehlerInd;
|
||||
#define Switch2 *((volatile unsigned long *)(BITBAND_PERI(GPIOA_IDR,11))) // DIL2
|
||||
#define Switch3 *((volatile unsigned long *)(BITBAND_PERI(GPIOA_IDR,12))) // DIL3
|
||||
|
||||
//----------------------------------------------------------
|
||||
//---------------------Variables------------------------
|
||||
|
||||
#define SOLLWERT 0x7F
|
||||
|
||||
//------------------------------------------------------
|
||||
|
||||
char buffer[24];
|
||||
|
||||
@ -160,6 +173,16 @@ void configProgressBar(void)
|
||||
pumpeInd.pushhandler = NULL;
|
||||
}
|
||||
|
||||
|
||||
void configTextFields(void)
|
||||
{
|
||||
fuellstandText.pid = 0;
|
||||
fuellstandText.cid = 1; // Component ID aus Nextion Editor
|
||||
fuellstandText.name = "fuellstandn"; // Exakter Name!
|
||||
fuellstandText.pophandler = NULL;
|
||||
fuellstandText.pushhandler = NULL;
|
||||
}
|
||||
|
||||
void fehler(int8_t state)
|
||||
{
|
||||
if(state == 1)
|
||||
@ -265,6 +288,40 @@ void fuellstand(int8_t value)
|
||||
}
|
||||
}
|
||||
|
||||
static uint8_t scale_7bit_to_percent(uint8_t value)
|
||||
{
|
||||
if (value > 0x7F) value = 0x7F;
|
||||
return (uint8_t)((value * 100u + 63u) / 127u); // gerundet
|
||||
}
|
||||
|
||||
void fuellstand_ui(uint8_t percent)
|
||||
{
|
||||
if (percent <= 100)
|
||||
{
|
||||
NexProgressBar_setValue(&fuellstandInd, percent);
|
||||
}
|
||||
}
|
||||
|
||||
void set_fuellstand_process(uint8_t istwert_7bit)
|
||||
{
|
||||
uint8_t ui_value;
|
||||
|
||||
if (istwert_7bit > SOLLWERT)
|
||||
istwert_7bit = SOLLWERT;
|
||||
|
||||
ui_value = scale_7bit_to_percent(istwert_7bit);
|
||||
fuellstand_ui(ui_value);
|
||||
}
|
||||
|
||||
void fuellstandSetText(uint8_t value)
|
||||
{
|
||||
char buf[20];
|
||||
|
||||
sprintf(buf, "%u l", value);
|
||||
|
||||
NexText_setText(&fuellstandText, buf);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
PortConfig();
|
||||
@ -272,9 +329,12 @@ int main(void)
|
||||
|
||||
NexEventObj *nextlisten_list[] = {NULL};
|
||||
configProgressBar();
|
||||
configTextFields();
|
||||
Nex_Init(0);
|
||||
Init_Nex_UI();
|
||||
|
||||
uint8_t currentFuellstand = 0;
|
||||
|
||||
fuellstand(0);
|
||||
fehler(0);
|
||||
leerBlasen(0);
|
||||
@ -285,51 +345,15 @@ int main(void)
|
||||
|
||||
uart2_putString("Dosieranlage V01\r\n");
|
||||
|
||||
|
||||
while(1)
|
||||
{
|
||||
Nex_Event_Loop(nextlisten_list);
|
||||
wait_sys_ms(20);
|
||||
|
||||
if(Switch0 == 1)
|
||||
{
|
||||
uart2_putString("Switch0\r\n ");
|
||||
wait_sys_ms(20);
|
||||
}
|
||||
if(Switch1 == 1)
|
||||
{
|
||||
uart2_putString("Switch1\r\n ");
|
||||
wait_sys_ms(20);
|
||||
}
|
||||
if(Switch2 == 1)
|
||||
{
|
||||
uart2_putString("Switch2\r\n ");
|
||||
wait_sys_ms(20);
|
||||
}
|
||||
if(Switch3 == 1)
|
||||
{
|
||||
uart2_putString("Switch3\r\n ");
|
||||
wait_sys_ms(20);
|
||||
}
|
||||
if(Switch4 == 1)
|
||||
{
|
||||
uart2_putString("Switch4\r\n ");
|
||||
wait_sys_ms(20);
|
||||
}
|
||||
if(Switch5 == 1)
|
||||
{
|
||||
uart2_putString("Switch5\r\n ");
|
||||
wait_sys_ms(20);
|
||||
}
|
||||
if(Switch6 == 1)
|
||||
{
|
||||
uart2_putString("Switch6\r\n ");
|
||||
wait_sys_ms(20);
|
||||
}
|
||||
if(Switch7 == 1)
|
||||
{
|
||||
uart2_putString("Switch7\r\n ");
|
||||
wait_sys_ms(20);
|
||||
}
|
||||
set_fuellstand_process(100);
|
||||
fuellstandSetText(67);
|
||||
|
||||
wait_sys_ms(10);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user