test

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

Revision:
7:c364201bc3ed
Parent:
6:cfe7cb0bdb1a
diff -r cfe7cb0bdb1a -r c364201bc3ed TFT/display.PidScreen.cpp
--- a/TFT/display.PidScreen.cpp	Fri Aug 14 14:16:03 2020 +0000
+++ b/TFT/display.PidScreen.cpp	Tue Sep 01 10:52:34 2020 +0000
@@ -4,6 +4,7 @@
     char key=pressedButton;
     char str_v[48];
     char sel=0;
+    uint16_t tx,ty,tw,th;//временные параметры для обработки касаний;
     
     StartDL();
     (*_TFT).DL(CLEAR_COLOR_RGB(31, 63, 127));
@@ -20,19 +21,26 @@
     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_MASK(1));
     
-    (*_TFT).DL(TAG(SEL_P1));
+    //(*_TFT).DL(TAG(SEL_P1));
+    tx=34;    ty=78+44+44;    tw=420/2-2;    th=40;
+    if(TouchX>tx&&TouchY>ty&&TouchX<(tx+tw)&&TouchY<(ty+th))
+    
+    selectedEditor=EDIT_P1;//ниже пояснение
     sprintf(str_v,"P1: %04.2f",PID1->kP);
-    if(selectedEditor==EDIT_P1)
+    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);    
+    myWdget_Edit(tx,ty,tw,th,sel,str_v);    
     sel=0;
     
-    (*_TFT).DL(TAG(SEL_P2));
+    //(*_TFT).DL(TAG(SEL_P2));
+    tx=34+420/2+2;    ty=78+44+44;    tw=420/2-2;    th=40;
+    if(TouchX>tx&&TouchY>ty&&TouchX<(tx+tw)&&TouchY<(ty+th))
+    selectedEditor=EDIT_P2;
     sprintf(str_v,"P2: %04.2f",PID2->kP);
     if(selectedEditor==EDIT_P2)
     {
@@ -40,10 +48,13 @@
     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);
+    myWdget_Edit(tx,ty,tw,th,sel,str_v);
     sel=0;
     
-    (*_TFT).DL(TAG(SEL_I1));
+    //(*_TFT).DL(TAG(SEL_I1));
+    tx=34;    ty=78+44*3;    tw=420/2-2;    th=40;
+    if(TouchX>tx&&TouchY>ty&&TouchX<(tx+tw)&&TouchY<(ty+th))
+    selectedEditor=EDIT_I1;
     sprintf(str_v,"I1: %06.1f",PID1->kI);
     if(selectedEditor==EDIT_I1)
     {
@@ -51,10 +62,13 @@
     myWdget_Edit_change(str_v);        
         sprintf(str_v,"%s",str_edit);
     }
-    myWdget_Edit(34,78+44*3,420/2-2,40,sel,str_v);
+    myWdget_Edit(tx,ty,tw,th,sel,str_v);
     sel=0;
     
-    (*_TFT).DL(TAG(SEL_I2));
+    //(*_TFT).DL(TAG(SEL_I2));
+    tx=34+420/2+2;    ty=78+44*3;    tw=420/2-2;    th=40;
+    if(TouchX>tx&&TouchY>ty&&TouchX<(tx+tw)&&TouchY<(ty+th))
+    selectedEditor=EDIT_I2;
     sprintf(str_v,"I2: %06.1f",PID2->kI);
     if(selectedEditor==EDIT_I2)
     {
@@ -62,10 +76,13 @@
     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);
+    myWdget_Edit(tx,ty,tw,th,sel,str_v);
     sel=0;
     
-    (*_TFT).DL(TAG(SEL_D1));
+    //(*_TFT).DL(TAG(SEL_D1));
+    tx=34;    ty=78+44*4;    tw=420/2-2;    th=40;
+    if(TouchX>tx&&TouchY>ty&&TouchX<(tx+tw)&&TouchY<(ty+th))
+    selectedEditor=EDIT_D1;
     sprintf(str_v,"D1: %05.2f",PID1->kD);
     if(selectedEditor==EDIT_D1)
     {
@@ -73,10 +90,13 @@
     myWdget_Edit_change(str_v);        
         sprintf(str_v,"%s",str_edit);
     }
-    myWdget_Edit(34,78+44*4,420/2-2,40,sel,str_v);
+    myWdget_Edit(tx,ty,tw,th,sel,str_v);
     sel=0;
     
-    (*_TFT).DL(TAG(SEL_D2));
+    //(*_TFT).DL(TAG(SEL_D2));
+    tx=34+420/2+2;    ty=78+44*4;    tw=420/2-2;    th=40;
+    if(TouchX>tx&&TouchY>ty&&TouchX<(tx+tw)&&TouchY<(ty+th))
+    selectedEditor=EDIT_D2;
     sprintf(str_v,"D2: %05.2f",PID2->kD);
     if(selectedEditor==EDIT_D2)
     {
@@ -85,10 +105,12 @@
     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);
+    myWdget_Edit(tx,ty,tw,th,sel,str_v);
     sel=0;
-    
-    (*_TFT).DL(TAG(BACK_PRESS));
+    //кнопка возврата в меню
+    //(*_TFT).DL(TAG(BACK_PRESS));
+    if(TouchX>34&&TouchY>325&&TouchX<(34+120)&&TouchY<(325+36))
+        pressedButton=BACK_PRESS;
     (*_TFT).DL(COLOR_RGB(255, 255, 255));
     if(key==BACK_PRESS)        
     (*_TFT).Button(34, 325, 120, 36, 27, OPT_FLAT, "Back");    
@@ -96,11 +118,14 @@
     (*_TFT).Button(34, 325, 120, 36, 27, 0, "Back");
     
     
-    (*_TFT).DL(TAG(CANCEL_PRESS));
+    //(*_TFT).DL(TAG(CANCEL_PRESS));
+    tx=325; ty=325; tw=120; th=36;
+    if(TouchX>tx&&TouchY>ty&&TouchX<(tx+tw)&&TouchY<(ty+th))
+    key=CANCEL_PRESS;
     (*_TFT).DL(COLOR_RGB(255, 255, 255));
     if(key==CANCEL_PRESS)
     {
-    (*_TFT).Button(325, 325, 120, 36, 27, OPT_FLAT, "Cancel");
+    (*_TFT).Button(tx, ty, tw, th, 27, OPT_FLAT, "Cancel");
     selectedEditor=EDIT_NONE;
     for(int i=0;i<10;i++)
     str_edit[i]=0;
@@ -108,9 +133,12 @@
     str_edit[0]='_';
     }
     else
-    (*_TFT).Button(325, 325, 120, 36, 27, 0, "Cancel");
+    (*_TFT).Button(tx, ty, tw, th, 27, 0, "Cancel");
     
-    (*_TFT).DL(TAG(APPLY_PRESS));
+    //(*_TFT).DL(TAG(APPLY_PRESS));
+    tx=200; ty=325; tw=120; th=36;
+    if(TouchX>tx&&TouchY>ty&&TouchX<(tx+tw)&&TouchY<(ty+th))
+    key=APPLY_PRESS;
     (*_TFT).DL(COLOR_RGB(255, 255, 255));
     if(key==APPLY_PRESS)
     {
@@ -143,7 +171,10 @@
     else
     (*_TFT).Button(200, 325, 120, 36, 27, 0, "Apply");
     
-    (*_TFT).DL(TAG(SAVE_PRESS));
+    //(*_TFT).DL(TAG(SAVE_PRESS));
+    tx=200; ty=365; tw=120; th=36;
+    if(TouchX>tx&&TouchY>ty&&TouchX<(tx+tw)&&TouchY<(ty+th))
+    pressedButton=key=SAVE_PRESS;
     (*_TFT).DL(COLOR_RGB(255, 255, 255));
     if(key==SAVE_PRESS)        
     (*_TFT).Button(200, 365, 120, 36, 27, OPT_FLAT, "Save");    
@@ -151,22 +182,25 @@
     (*_TFT).Button(200, 365, 120, 36, 27, 0, "Save");
     
     //переключатели ПИДов
-    (*_TFT).DL(TAG(PID1SW_PRESS));    
+    //(*_TFT).DL(TAG(PID1SW_PRESS));
+    tx=260; ty=420; tw=50; th=36;    
+    if(TouchX>tx&&TouchY>ty&&TouchX<(tx+tw)&&TouchY<(ty+th))
+    pressedButton=key=PID1SW_PRESS;    
     (*_TFT).Toggle(260, 420,50,27,0,0,"OFF""\xff""ON");
     if(key==PID1SW_PRESS)
     {PID1->enabled=~PID1->enabled;}
     if(PID1->enabled)
     (*_TFT).Toggle(260, 420,50,27,0,0xFFFF,"OFF""\xff""ON");//ПИД1 вкл
     
-    (*_TFT).DL(TAG(PID2SW_PRESS));    
+    //(*_TFT).DL(TAG(PID2SW_PRESS));
+    tx=385; ty=420; tw=50; th=36;    
+    if(TouchX>tx&&TouchY>ty&&TouchX<(tx+tw)&&TouchY<(ty+th))
+    pressedButton=key=PID2SW_PRESS;   
     (*_TFT).Toggle(385, 420,50,27,0,0,"OFF""\xff""ON");
-    if(key==PID2SW_PRESS)    
+    if(key==PID2SW_PRESS)
     {PID2->enabled=~PID2->enabled;}
     if(PID2->enabled)
-    (*_TFT).Toggle(385, 420,50,27,0,0xFFFF,"OFF""\xff""ON");//ПИД2 вкл
-    (*_TFT).DL(TAG_MASK(0));
-    
-    
+    (*_TFT).Toggle(385, 420,50,27,0,0xFFFF,"OFF""\xff""ON");//ПИД2 вкл    
     
     FinishDL();
 }
\ No newline at end of file