Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: ad5422_arduino mbed LT1446 ADS1248-1 LM35-1 Flash FT813 PGA280_ADS1259
display.PidScreen.cpp
00001 #include "display.h" 00002 void Display::PidScreen(/*костыль костылей*/float (*btf)(unsigned char*),float temp, float ras,uint16_t power1,uint16_t power2,PID_t* PID1,PID_t* PID2) 00003 { 00004 char key=pressedButton; 00005 char str_v[48]; 00006 char sel=0; 00007 uint16_t tx,ty,tw,th;//временные параметры для обработки касаний; 00008 00009 StartDL(); 00010 (*_TFT).DL(CLEAR_COLOR_RGB(31, 63, 127)); 00011 // clear buffers for preset values 00012 (*_TFT).DL(CLEAR(1, 1, 1)); 00013 (*_TFT).DL(COLOR_RGB(255, 255, 255)); 00014 (*_TFT).Text(300, 10 , 29, 0, "PID Controller Menu"); 00015 myWdget_NumPad(500,80); 00016 00017 //поля для отображения настроек 00018 sprintf(str_v,"PID temp: %0.2f oC | Power: %04d",temp,power1); 00019 myWdget_Edit(34,78,420,40,0,str_v); 00020 00021 sprintf(str_v,"PID Rashod: %0.4f cm3/kg | Power: %04d",ras,power2); 00022 myWdget_Edit(34,78+44,420,40,0,str_v); 00023 00024 //(*_TFT).DL(TAG_MASK(1)); 00025 00026 //(*_TFT).DL(TAG(SEL_P1)); 00027 tx=34; ty=78+44+44; tw=420/2-2; th=40; 00028 if(TouchX>tx&&TouchY>ty&&TouchX<(tx+tw)&&TouchY<(ty+th)) 00029 00030 selectedEditor=EDIT_P1;//ниже пояснение 00031 sprintf(str_v,"P1: %04.2f",PID1->kP); 00032 if(selectedEditor==EDIT_P1)//повторение из-за того что исправлял старую разработку 00033 {sel=1; 00034 myWdget_Edit_change(str_v); 00035 sprintf(str_v,"%s",str_edit); 00036 } 00037 myWdget_Edit(tx,ty,tw,th,sel,str_v); 00038 sel=0; 00039 00040 //(*_TFT).DL(TAG(SEL_P2)); 00041 tx=34+420/2+2; ty=78+44+44; tw=420/2-2; th=40; 00042 if(TouchX>tx&&TouchY>ty&&TouchX<(tx+tw)&&TouchY<(ty+th)) 00043 selectedEditor=EDIT_P2; 00044 sprintf(str_v,"P2: %04.2f",PID2->kP); 00045 if(selectedEditor==EDIT_P2) 00046 { 00047 sel=1; 00048 myWdget_Edit_change(str_v); 00049 sprintf(str_v,"%s",str_edit); 00050 } 00051 myWdget_Edit(tx,ty,tw,th,sel,str_v); 00052 sel=0; 00053 00054 //(*_TFT).DL(TAG(SEL_I1)); 00055 tx=34; ty=78+44*3; tw=420/2-2; th=40; 00056 if(TouchX>tx&&TouchY>ty&&TouchX<(tx+tw)&&TouchY<(ty+th)) 00057 selectedEditor=EDIT_I1; 00058 sprintf(str_v,"I1: %06.1f",PID1->kI); 00059 if(selectedEditor==EDIT_I1) 00060 { 00061 sel=1; 00062 myWdget_Edit_change(str_v); 00063 sprintf(str_v,"%s",str_edit); 00064 } 00065 myWdget_Edit(tx,ty,tw,th,sel,str_v); 00066 sel=0; 00067 00068 //(*_TFT).DL(TAG(SEL_I2)); 00069 tx=34+420/2+2; ty=78+44*3; tw=420/2-2; th=40; 00070 if(TouchX>tx&&TouchY>ty&&TouchX<(tx+tw)&&TouchY<(ty+th)) 00071 selectedEditor=EDIT_I2; 00072 sprintf(str_v,"I2: %06.1f",PID2->kI); 00073 if(selectedEditor==EDIT_I2) 00074 { 00075 sel=1; 00076 myWdget_Edit_change(str_v); 00077 sprintf(str_v,"%s",str_edit); 00078 } 00079 myWdget_Edit(tx,ty,tw,th,sel,str_v); 00080 sel=0; 00081 00082 //(*_TFT).DL(TAG(SEL_D1)); 00083 tx=34; ty=78+44*4; tw=420/2-2; th=40; 00084 if(TouchX>tx&&TouchY>ty&&TouchX<(tx+tw)&&TouchY<(ty+th)) 00085 selectedEditor=EDIT_D1; 00086 sprintf(str_v,"D1: %05.2f",PID1->kD); 00087 if(selectedEditor==EDIT_D1) 00088 { 00089 sel=1; 00090 myWdget_Edit_change(str_v); 00091 sprintf(str_v,"%s",str_edit); 00092 } 00093 myWdget_Edit(tx,ty,tw,th,sel,str_v); 00094 sel=0; 00095 00096 //(*_TFT).DL(TAG(SEL_D2)); 00097 tx=34+420/2+2; ty=78+44*4; tw=420/2-2; th=40; 00098 if(TouchX>tx&&TouchY>ty&&TouchX<(tx+tw)&&TouchY<(ty+th)) 00099 selectedEditor=EDIT_D2; 00100 sprintf(str_v,"D2: %05.2f",PID2->kD); 00101 if(selectedEditor==EDIT_D2) 00102 { 00103 sel=1; 00104 00105 myWdget_Edit_change(str_v); 00106 sprintf(str_v,"%s",str_edit); 00107 } 00108 myWdget_Edit(tx,ty,tw,th,sel,str_v); 00109 sel=0; 00110 //кнопка возврата в меню 00111 //(*_TFT).DL(TAG(BACK_PRESS)); 00112 if(TouchX>34&&TouchY>325&&TouchX<(34+120)&&TouchY<(325+36)) 00113 pressedButton=BACK_PRESS; 00114 (*_TFT).DL(COLOR_RGB(255, 255, 255)); 00115 if(key==BACK_PRESS) 00116 (*_TFT).Button(34, 325, 120, 36, 27, OPT_FLAT, "Back"); 00117 else 00118 (*_TFT).Button(34, 325, 120, 36, 27, 0, "Back"); 00119 00120 00121 //(*_TFT).DL(TAG(CANCEL_PRESS)); 00122 tx=325; ty=325; tw=120; th=36; 00123 if(TouchX>tx&&TouchY>ty&&TouchX<(tx+tw)&&TouchY<(ty+th)) 00124 key=CANCEL_PRESS; 00125 (*_TFT).DL(COLOR_RGB(255, 255, 255)); 00126 if(key==CANCEL_PRESS) 00127 { 00128 (*_TFT).Button(tx, ty, tw, th, 27, OPT_FLAT, "Cancel"); 00129 selectedEditor=EDIT_NONE; 00130 for(int i=0;i<10;i++) 00131 str_edit[i]=0; 00132 cursor=0; 00133 str_edit[0]='_'; 00134 } 00135 else 00136 (*_TFT).Button(tx, ty, tw, th, 27, 0, "Cancel"); 00137 00138 //(*_TFT).DL(TAG(APPLY_PRESS)); 00139 tx=200; ty=325; tw=120; th=36; 00140 if(TouchX>tx&&TouchY>ty&&TouchX<(tx+tw)&&TouchY<(ty+th)) 00141 key=APPLY_PRESS; 00142 (*_TFT).DL(COLOR_RGB(255, 255, 255)); 00143 if(key==APPLY_PRESS) 00144 { 00145 (*_TFT).Button(200, 325, 120, 36, 27, OPT_FLAT, "Apply"); 00146 //Применение значений 00147 if(selectedEditor==EDIT_P1) 00148 PID1->kP=btf(str_edit); 00149 00150 if(selectedEditor==EDIT_P2) 00151 PID2->kP=btf(str_edit); 00152 00153 if(selectedEditor==EDIT_I1) 00154 PID1->kI=btf(str_edit); 00155 00156 if(selectedEditor==EDIT_I2) 00157 PID2->kI=btf(str_edit); 00158 00159 if(selectedEditor==EDIT_D1) 00160 PID1->kD=btf(str_edit); 00161 00162 if(selectedEditor==EDIT_D2) 00163 PID2->kD=btf(str_edit); 00164 00165 selectedEditor=EDIT_NONE; 00166 for(int i=0;i<10;i++) 00167 str_edit[i]=0; 00168 cursor=0; 00169 str_edit[0]='_'; 00170 } 00171 else 00172 (*_TFT).Button(200, 325, 120, 36, 27, 0, "Apply"); 00173 00174 //(*_TFT).DL(TAG(SAVE_PRESS)); 00175 tx=200; ty=365; tw=120; th=36; 00176 if(TouchX>tx&&TouchY>ty&&TouchX<(tx+tw)&&TouchY<(ty+th)) 00177 pressedButton=key=SAVE_PRESS; 00178 (*_TFT).DL(COLOR_RGB(255, 255, 255)); 00179 if(key==SAVE_PRESS) 00180 (*_TFT).Button(200, 365, 120, 36, 27, OPT_FLAT, "Save"); 00181 else 00182 (*_TFT).Button(200, 365, 120, 36, 27, 0, "Save"); 00183 00184 //переключатели ПИДов 00185 //(*_TFT).DL(TAG(PID1SW_PRESS)); 00186 tx=260; ty=420; tw=50; th=36; 00187 if(TouchX>tx&&TouchY>ty&&TouchX<(tx+tw)&&TouchY<(ty+th)) 00188 pressedButton=key=PID1SW_PRESS; 00189 (*_TFT).Toggle(260, 420,50,27,0,0,"OFF""\xff""ON"); 00190 if(key==PID1SW_PRESS) 00191 {PID1->enabled=~PID1->enabled;} 00192 if(PID1->enabled) 00193 (*_TFT).Toggle(260, 420,50,27,0,0xFFFF,"OFF""\xff""ON");//ПИД1 вкл 00194 00195 //(*_TFT).DL(TAG(PID2SW_PRESS)); 00196 tx=385; ty=420; tw=50; th=36; 00197 if(TouchX>tx&&TouchY>ty&&TouchX<(tx+tw)&&TouchY<(ty+th)) 00198 pressedButton=key=PID2SW_PRESS; 00199 (*_TFT).Toggle(385, 420,50,27,0,0,"OFF""\xff""ON"); 00200 if(key==PID2SW_PRESS) 00201 {PID2->enabled=~PID2->enabled;} 00202 if(PID2->enabled) 00203 (*_TFT).Toggle(385, 420,50,27,0,0xFFFF,"OFF""\xff""ON");//ПИД2 вкл 00204 00205 FinishDL(); 00206 }
Generated on Thu Jul 14 2022 17:32:52 by
1.7.2