test

Dependencies:   ad5422_arduino mbed LT1446 ADS1248-1 LM35-1 Flash FT813 PGA280_ADS1259

Revision:
5:21240fa1ee4c
Child:
6:cfe7cb0bdb1a
diff -r d53895f65eb7 -r 21240fa1ee4c TFT/display.PidScreen.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TFT/display.PidScreen.cpp	Thu Aug 13 14:37:39 2020 +0000
@@ -0,0 +1,151 @@
+#include "display.h"
+void Display::PidScreen(/*костыль костылей*/float (*btf)(unsigned char*),float temp, float ras,uint16_t power1,uint16_t power2,PID_t* PID1,PID_t* PID2)
+{
+    char key=pressedButton;
+    char str_v[48];
+    char sel=0;
+    
+    StartDL();
+    (*_TFT).DL(CLEAR_COLOR_RGB(31, 63, 127));
+    // clear buffers for preset values
+    (*_TFT).DL(CLEAR(1, 1, 1));
+    (*_TFT).DL(COLOR_RGB(255, 255, 255));    
+    (*_TFT).Text(300, 10 , 29, 0, "PID Controller Menu");
+    myWdget_NumPad(500,80);   
+    
+    //поля для отображения настроек
+    sprintf(str_v,"PID temp: %0.2f oC       | Power: %04d",temp,power1);    
+    myWdget_Edit(34,78,420,40,0,str_v);
+        
+    sprintf(str_v,"PID Rashod: %0.4f cm3/kg | Power: %04d",ras,power2);
+    myWdget_Edit(34,78+44,420,40,0,str_v);
+    
+    (*_TFT).DL(TAG_MASK(1));
+    
+    (*_TFT).DL(TAG(SEL_P1));
+    sprintf(str_v,"P1: %04.2f",PID1->kP);
+    if(selectedEditor==EDIT_P1)
+    {sel=1;
+        myWdget_Edit_change(str_v);        
+        sprintf(str_v,"%s",str_edit);
+    }    
+    myWdget_Edit(34,78+44+44,420/2-2,40,sel,str_v);    
+    sel=0;
+    
+    (*_TFT).DL(TAG(SEL_P2));
+    sprintf(str_v,"P2: %04.2f",PID2->kP);
+    if(selectedEditor==EDIT_P2)
+    {
+    sel=1;
+    myWdget_Edit_change(str_v);        
+        sprintf(str_v,"%s",str_edit);
+    }
+    myWdget_Edit(34+420/2+2,78+44+44,420/2-2,40,sel,str_v);
+    sel=0;
+    
+    (*_TFT).DL(TAG(SEL_I1));
+    sprintf(str_v,"I1: %06.1f",PID1->kI);
+    if(selectedEditor==EDIT_I1)
+    {
+    sel=1;
+    myWdget_Edit_change(str_v);        
+        sprintf(str_v,"%s",str_edit);
+    }
+    myWdget_Edit(34,78+44*3,420/2-2,40,sel,str_v);
+    sel=0;
+    
+    (*_TFT).DL(TAG(SEL_I2));
+    sprintf(str_v,"I2: %06.1f",PID2->kI);
+    if(selectedEditor==EDIT_I2)
+    {
+    sel=1;
+    myWdget_Edit_change(str_v);        
+        sprintf(str_v,"%s",str_edit);
+    }
+    myWdget_Edit(34+420/2+2,78+44*3,420/2-2,40,sel,str_v);
+    sel=0;
+    
+    (*_TFT).DL(TAG(SEL_D1));
+    sprintf(str_v,"D1: %05.2f",PID1->kD);
+    if(selectedEditor==EDIT_D1)
+    {
+    sel=1;
+    myWdget_Edit_change(str_v);        
+        sprintf(str_v,"%s",str_edit);
+    }
+    myWdget_Edit(34,78+44*4,420/2-2,40,sel,str_v);
+    sel=0;
+    
+    (*_TFT).DL(TAG(SEL_D2));
+    sprintf(str_v,"D2: %05.2f",PID2->kD);
+    if(selectedEditor==EDIT_D2)
+    {
+    sel=1;
+    
+    myWdget_Edit_change(str_v);        
+        sprintf(str_v,"%s",str_edit);
+    }
+    myWdget_Edit(34+420/2+2,78+44*4,420/2-2,40,sel,str_v);
+    sel=0;
+    
+    (*_TFT).DL(TAG(BACK_PRESS));
+    (*_TFT).DL(COLOR_RGB(255, 255, 255));
+    if(key==BACK_PRESS)        
+    (*_TFT).Button(34, 325, 120, 36, 27, OPT_FLAT, "Back");    
+    else
+    (*_TFT).Button(34, 325, 120, 36, 27, 0, "Back");
+    
+    
+    (*_TFT).DL(TAG(CANCEL_PRESS));
+    (*_TFT).DL(COLOR_RGB(255, 255, 255));
+    if(key==CANCEL_PRESS)
+    {
+    (*_TFT).Button(325, 325, 120, 36, 27, OPT_FLAT, "Cancel");
+    selectedEditor=EDIT_NONE;
+    for(int i=0;i<10;i++)
+    str_edit[i]=0;
+    cursor=0;
+    str_edit[0]='_';
+    }
+    else
+    (*_TFT).Button(325, 325, 120, 36, 27, 0, "Cancel");
+    
+    (*_TFT).DL(TAG(APPLY_PRESS));
+    (*_TFT).DL(COLOR_RGB(255, 255, 255));
+    if(key==APPLY_PRESS)
+    {
+    (*_TFT).Button(200, 325, 120, 36, 27, OPT_FLAT, "Apply");
+    //Применение значений
+    if(selectedEditor==EDIT_P1)
+    PID1->kP=btf(str_edit);
+    
+    if(selectedEditor==EDIT_P2)
+    PID2->kP=btf(str_edit);
+    
+    if(selectedEditor==EDIT_I1)
+    PID1->kI=btf(str_edit);
+    
+    if(selectedEditor==EDIT_I2)
+    PID2->kI=btf(str_edit);
+    
+    if(selectedEditor==EDIT_D1)
+    PID1->kD=btf(str_edit);
+    
+    if(selectedEditor==EDIT_D2)
+    PID2->kD=btf(str_edit);
+    
+    selectedEditor=EDIT_NONE;
+    for(int i=0;i<10;i++)
+    str_edit[i]=0;
+    cursor=0;
+    str_edit[0]='_';    
+    }
+    else
+    (*_TFT).Button(200, 325, 120, 36, 27, 0, "Apply");
+    
+    (*_TFT).DL(TAG_MASK(0));
+    
+    
+    
+    FinishDL();
+}
\ No newline at end of file