test
Dependencies: ad5422_arduino mbed LT1446 ADS1248-1 LM35-1 Flash FT813 PGA280_ADS1259
TFT/display.PidScreen.cpp@7:c364201bc3ed, 2020-09-01 (annotated)
- Committer:
- nikmaos
- Date:
- Tue Sep 01 10:52:34 2020 +0000
- Revision:
- 7:c364201bc3ed
- Parent:
- 6:cfe7cb0bdb1a
1.09.2020;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nikmaos | 5:21240fa1ee4c | 1 | #include "display.h" |
nikmaos | 5:21240fa1ee4c | 2 | void Display::PidScreen(/*костыль костылей*/float (*btf)(unsigned char*),float temp, float ras,uint16_t power1,uint16_t power2,PID_t* PID1,PID_t* PID2) |
nikmaos | 5:21240fa1ee4c | 3 | { |
nikmaos | 5:21240fa1ee4c | 4 | char key=pressedButton; |
nikmaos | 5:21240fa1ee4c | 5 | char str_v[48]; |
nikmaos | 5:21240fa1ee4c | 6 | char sel=0; |
nikmaos | 7:c364201bc3ed | 7 | uint16_t tx,ty,tw,th;//временные параметры для обработки касаний; |
nikmaos | 5:21240fa1ee4c | 8 | |
nikmaos | 5:21240fa1ee4c | 9 | StartDL(); |
nikmaos | 5:21240fa1ee4c | 10 | (*_TFT).DL(CLEAR_COLOR_RGB(31, 63, 127)); |
nikmaos | 5:21240fa1ee4c | 11 | // clear buffers for preset values |
nikmaos | 5:21240fa1ee4c | 12 | (*_TFT).DL(CLEAR(1, 1, 1)); |
nikmaos | 5:21240fa1ee4c | 13 | (*_TFT).DL(COLOR_RGB(255, 255, 255)); |
nikmaos | 5:21240fa1ee4c | 14 | (*_TFT).Text(300, 10 , 29, 0, "PID Controller Menu"); |
nikmaos | 5:21240fa1ee4c | 15 | myWdget_NumPad(500,80); |
nikmaos | 5:21240fa1ee4c | 16 | |
nikmaos | 5:21240fa1ee4c | 17 | //поля для отображения настроек |
nikmaos | 5:21240fa1ee4c | 18 | sprintf(str_v,"PID temp: %0.2f oC | Power: %04d",temp,power1); |
nikmaos | 5:21240fa1ee4c | 19 | myWdget_Edit(34,78,420,40,0,str_v); |
nikmaos | 5:21240fa1ee4c | 20 | |
nikmaos | 5:21240fa1ee4c | 21 | sprintf(str_v,"PID Rashod: %0.4f cm3/kg | Power: %04d",ras,power2); |
nikmaos | 5:21240fa1ee4c | 22 | myWdget_Edit(34,78+44,420,40,0,str_v); |
nikmaos | 5:21240fa1ee4c | 23 | |
nikmaos | 7:c364201bc3ed | 24 | //(*_TFT).DL(TAG_MASK(1)); |
nikmaos | 5:21240fa1ee4c | 25 | |
nikmaos | 7:c364201bc3ed | 26 | //(*_TFT).DL(TAG(SEL_P1)); |
nikmaos | 7:c364201bc3ed | 27 | tx=34; ty=78+44+44; tw=420/2-2; th=40; |
nikmaos | 7:c364201bc3ed | 28 | if(TouchX>tx&&TouchY>ty&&TouchX<(tx+tw)&&TouchY<(ty+th)) |
nikmaos | 7:c364201bc3ed | 29 | |
nikmaos | 7:c364201bc3ed | 30 | selectedEditor=EDIT_P1;//ниже пояснение |
nikmaos | 5:21240fa1ee4c | 31 | sprintf(str_v,"P1: %04.2f",PID1->kP); |
nikmaos | 7:c364201bc3ed | 32 | if(selectedEditor==EDIT_P1)//повторение из-за того что исправлял старую разработку |
nikmaos | 5:21240fa1ee4c | 33 | {sel=1; |
nikmaos | 5:21240fa1ee4c | 34 | myWdget_Edit_change(str_v); |
nikmaos | 5:21240fa1ee4c | 35 | sprintf(str_v,"%s",str_edit); |
nikmaos | 5:21240fa1ee4c | 36 | } |
nikmaos | 7:c364201bc3ed | 37 | myWdget_Edit(tx,ty,tw,th,sel,str_v); |
nikmaos | 5:21240fa1ee4c | 38 | sel=0; |
nikmaos | 5:21240fa1ee4c | 39 | |
nikmaos | 7:c364201bc3ed | 40 | //(*_TFT).DL(TAG(SEL_P2)); |
nikmaos | 7:c364201bc3ed | 41 | tx=34+420/2+2; ty=78+44+44; tw=420/2-2; th=40; |
nikmaos | 7:c364201bc3ed | 42 | if(TouchX>tx&&TouchY>ty&&TouchX<(tx+tw)&&TouchY<(ty+th)) |
nikmaos | 7:c364201bc3ed | 43 | selectedEditor=EDIT_P2; |
nikmaos | 5:21240fa1ee4c | 44 | sprintf(str_v,"P2: %04.2f",PID2->kP); |
nikmaos | 5:21240fa1ee4c | 45 | if(selectedEditor==EDIT_P2) |
nikmaos | 5:21240fa1ee4c | 46 | { |
nikmaos | 5:21240fa1ee4c | 47 | sel=1; |
nikmaos | 5:21240fa1ee4c | 48 | myWdget_Edit_change(str_v); |
nikmaos | 5:21240fa1ee4c | 49 | sprintf(str_v,"%s",str_edit); |
nikmaos | 5:21240fa1ee4c | 50 | } |
nikmaos | 7:c364201bc3ed | 51 | myWdget_Edit(tx,ty,tw,th,sel,str_v); |
nikmaos | 5:21240fa1ee4c | 52 | sel=0; |
nikmaos | 5:21240fa1ee4c | 53 | |
nikmaos | 7:c364201bc3ed | 54 | //(*_TFT).DL(TAG(SEL_I1)); |
nikmaos | 7:c364201bc3ed | 55 | tx=34; ty=78+44*3; tw=420/2-2; th=40; |
nikmaos | 7:c364201bc3ed | 56 | if(TouchX>tx&&TouchY>ty&&TouchX<(tx+tw)&&TouchY<(ty+th)) |
nikmaos | 7:c364201bc3ed | 57 | selectedEditor=EDIT_I1; |
nikmaos | 5:21240fa1ee4c | 58 | sprintf(str_v,"I1: %06.1f",PID1->kI); |
nikmaos | 5:21240fa1ee4c | 59 | if(selectedEditor==EDIT_I1) |
nikmaos | 5:21240fa1ee4c | 60 | { |
nikmaos | 5:21240fa1ee4c | 61 | sel=1; |
nikmaos | 5:21240fa1ee4c | 62 | myWdget_Edit_change(str_v); |
nikmaos | 5:21240fa1ee4c | 63 | sprintf(str_v,"%s",str_edit); |
nikmaos | 5:21240fa1ee4c | 64 | } |
nikmaos | 7:c364201bc3ed | 65 | myWdget_Edit(tx,ty,tw,th,sel,str_v); |
nikmaos | 5:21240fa1ee4c | 66 | sel=0; |
nikmaos | 5:21240fa1ee4c | 67 | |
nikmaos | 7:c364201bc3ed | 68 | //(*_TFT).DL(TAG(SEL_I2)); |
nikmaos | 7:c364201bc3ed | 69 | tx=34+420/2+2; ty=78+44*3; tw=420/2-2; th=40; |
nikmaos | 7:c364201bc3ed | 70 | if(TouchX>tx&&TouchY>ty&&TouchX<(tx+tw)&&TouchY<(ty+th)) |
nikmaos | 7:c364201bc3ed | 71 | selectedEditor=EDIT_I2; |
nikmaos | 5:21240fa1ee4c | 72 | sprintf(str_v,"I2: %06.1f",PID2->kI); |
nikmaos | 5:21240fa1ee4c | 73 | if(selectedEditor==EDIT_I2) |
nikmaos | 5:21240fa1ee4c | 74 | { |
nikmaos | 5:21240fa1ee4c | 75 | sel=1; |
nikmaos | 5:21240fa1ee4c | 76 | myWdget_Edit_change(str_v); |
nikmaos | 5:21240fa1ee4c | 77 | sprintf(str_v,"%s",str_edit); |
nikmaos | 5:21240fa1ee4c | 78 | } |
nikmaos | 7:c364201bc3ed | 79 | myWdget_Edit(tx,ty,tw,th,sel,str_v); |
nikmaos | 5:21240fa1ee4c | 80 | sel=0; |
nikmaos | 5:21240fa1ee4c | 81 | |
nikmaos | 7:c364201bc3ed | 82 | //(*_TFT).DL(TAG(SEL_D1)); |
nikmaos | 7:c364201bc3ed | 83 | tx=34; ty=78+44*4; tw=420/2-2; th=40; |
nikmaos | 7:c364201bc3ed | 84 | if(TouchX>tx&&TouchY>ty&&TouchX<(tx+tw)&&TouchY<(ty+th)) |
nikmaos | 7:c364201bc3ed | 85 | selectedEditor=EDIT_D1; |
nikmaos | 5:21240fa1ee4c | 86 | sprintf(str_v,"D1: %05.2f",PID1->kD); |
nikmaos | 5:21240fa1ee4c | 87 | if(selectedEditor==EDIT_D1) |
nikmaos | 5:21240fa1ee4c | 88 | { |
nikmaos | 5:21240fa1ee4c | 89 | sel=1; |
nikmaos | 5:21240fa1ee4c | 90 | myWdget_Edit_change(str_v); |
nikmaos | 5:21240fa1ee4c | 91 | sprintf(str_v,"%s",str_edit); |
nikmaos | 5:21240fa1ee4c | 92 | } |
nikmaos | 7:c364201bc3ed | 93 | myWdget_Edit(tx,ty,tw,th,sel,str_v); |
nikmaos | 5:21240fa1ee4c | 94 | sel=0; |
nikmaos | 5:21240fa1ee4c | 95 | |
nikmaos | 7:c364201bc3ed | 96 | //(*_TFT).DL(TAG(SEL_D2)); |
nikmaos | 7:c364201bc3ed | 97 | tx=34+420/2+2; ty=78+44*4; tw=420/2-2; th=40; |
nikmaos | 7:c364201bc3ed | 98 | if(TouchX>tx&&TouchY>ty&&TouchX<(tx+tw)&&TouchY<(ty+th)) |
nikmaos | 7:c364201bc3ed | 99 | selectedEditor=EDIT_D2; |
nikmaos | 5:21240fa1ee4c | 100 | sprintf(str_v,"D2: %05.2f",PID2->kD); |
nikmaos | 5:21240fa1ee4c | 101 | if(selectedEditor==EDIT_D2) |
nikmaos | 5:21240fa1ee4c | 102 | { |
nikmaos | 5:21240fa1ee4c | 103 | sel=1; |
nikmaos | 5:21240fa1ee4c | 104 | |
nikmaos | 5:21240fa1ee4c | 105 | myWdget_Edit_change(str_v); |
nikmaos | 5:21240fa1ee4c | 106 | sprintf(str_v,"%s",str_edit); |
nikmaos | 5:21240fa1ee4c | 107 | } |
nikmaos | 7:c364201bc3ed | 108 | myWdget_Edit(tx,ty,tw,th,sel,str_v); |
nikmaos | 5:21240fa1ee4c | 109 | sel=0; |
nikmaos | 7:c364201bc3ed | 110 | //кнопка возврата в меню |
nikmaos | 7:c364201bc3ed | 111 | //(*_TFT).DL(TAG(BACK_PRESS)); |
nikmaos | 7:c364201bc3ed | 112 | if(TouchX>34&&TouchY>325&&TouchX<(34+120)&&TouchY<(325+36)) |
nikmaos | 7:c364201bc3ed | 113 | pressedButton=BACK_PRESS; |
nikmaos | 5:21240fa1ee4c | 114 | (*_TFT).DL(COLOR_RGB(255, 255, 255)); |
nikmaos | 5:21240fa1ee4c | 115 | if(key==BACK_PRESS) |
nikmaos | 5:21240fa1ee4c | 116 | (*_TFT).Button(34, 325, 120, 36, 27, OPT_FLAT, "Back"); |
nikmaos | 5:21240fa1ee4c | 117 | else |
nikmaos | 5:21240fa1ee4c | 118 | (*_TFT).Button(34, 325, 120, 36, 27, 0, "Back"); |
nikmaos | 5:21240fa1ee4c | 119 | |
nikmaos | 5:21240fa1ee4c | 120 | |
nikmaos | 7:c364201bc3ed | 121 | //(*_TFT).DL(TAG(CANCEL_PRESS)); |
nikmaos | 7:c364201bc3ed | 122 | tx=325; ty=325; tw=120; th=36; |
nikmaos | 7:c364201bc3ed | 123 | if(TouchX>tx&&TouchY>ty&&TouchX<(tx+tw)&&TouchY<(ty+th)) |
nikmaos | 7:c364201bc3ed | 124 | key=CANCEL_PRESS; |
nikmaos | 5:21240fa1ee4c | 125 | (*_TFT).DL(COLOR_RGB(255, 255, 255)); |
nikmaos | 5:21240fa1ee4c | 126 | if(key==CANCEL_PRESS) |
nikmaos | 5:21240fa1ee4c | 127 | { |
nikmaos | 7:c364201bc3ed | 128 | (*_TFT).Button(tx, ty, tw, th, 27, OPT_FLAT, "Cancel"); |
nikmaos | 5:21240fa1ee4c | 129 | selectedEditor=EDIT_NONE; |
nikmaos | 5:21240fa1ee4c | 130 | for(int i=0;i<10;i++) |
nikmaos | 5:21240fa1ee4c | 131 | str_edit[i]=0; |
nikmaos | 5:21240fa1ee4c | 132 | cursor=0; |
nikmaos | 5:21240fa1ee4c | 133 | str_edit[0]='_'; |
nikmaos | 5:21240fa1ee4c | 134 | } |
nikmaos | 5:21240fa1ee4c | 135 | else |
nikmaos | 7:c364201bc3ed | 136 | (*_TFT).Button(tx, ty, tw, th, 27, 0, "Cancel"); |
nikmaos | 5:21240fa1ee4c | 137 | |
nikmaos | 7:c364201bc3ed | 138 | //(*_TFT).DL(TAG(APPLY_PRESS)); |
nikmaos | 7:c364201bc3ed | 139 | tx=200; ty=325; tw=120; th=36; |
nikmaos | 7:c364201bc3ed | 140 | if(TouchX>tx&&TouchY>ty&&TouchX<(tx+tw)&&TouchY<(ty+th)) |
nikmaos | 7:c364201bc3ed | 141 | key=APPLY_PRESS; |
nikmaos | 5:21240fa1ee4c | 142 | (*_TFT).DL(COLOR_RGB(255, 255, 255)); |
nikmaos | 5:21240fa1ee4c | 143 | if(key==APPLY_PRESS) |
nikmaos | 5:21240fa1ee4c | 144 | { |
nikmaos | 5:21240fa1ee4c | 145 | (*_TFT).Button(200, 325, 120, 36, 27, OPT_FLAT, "Apply"); |
nikmaos | 5:21240fa1ee4c | 146 | //Применение значений |
nikmaos | 5:21240fa1ee4c | 147 | if(selectedEditor==EDIT_P1) |
nikmaos | 5:21240fa1ee4c | 148 | PID1->kP=btf(str_edit); |
nikmaos | 5:21240fa1ee4c | 149 | |
nikmaos | 5:21240fa1ee4c | 150 | if(selectedEditor==EDIT_P2) |
nikmaos | 5:21240fa1ee4c | 151 | PID2->kP=btf(str_edit); |
nikmaos | 5:21240fa1ee4c | 152 | |
nikmaos | 5:21240fa1ee4c | 153 | if(selectedEditor==EDIT_I1) |
nikmaos | 5:21240fa1ee4c | 154 | PID1->kI=btf(str_edit); |
nikmaos | 5:21240fa1ee4c | 155 | |
nikmaos | 5:21240fa1ee4c | 156 | if(selectedEditor==EDIT_I2) |
nikmaos | 5:21240fa1ee4c | 157 | PID2->kI=btf(str_edit); |
nikmaos | 5:21240fa1ee4c | 158 | |
nikmaos | 5:21240fa1ee4c | 159 | if(selectedEditor==EDIT_D1) |
nikmaos | 5:21240fa1ee4c | 160 | PID1->kD=btf(str_edit); |
nikmaos | 5:21240fa1ee4c | 161 | |
nikmaos | 5:21240fa1ee4c | 162 | if(selectedEditor==EDIT_D2) |
nikmaos | 5:21240fa1ee4c | 163 | PID2->kD=btf(str_edit); |
nikmaos | 5:21240fa1ee4c | 164 | |
nikmaos | 5:21240fa1ee4c | 165 | selectedEditor=EDIT_NONE; |
nikmaos | 5:21240fa1ee4c | 166 | for(int i=0;i<10;i++) |
nikmaos | 5:21240fa1ee4c | 167 | str_edit[i]=0; |
nikmaos | 5:21240fa1ee4c | 168 | cursor=0; |
nikmaos | 5:21240fa1ee4c | 169 | str_edit[0]='_'; |
nikmaos | 5:21240fa1ee4c | 170 | } |
nikmaos | 5:21240fa1ee4c | 171 | else |
nikmaos | 5:21240fa1ee4c | 172 | (*_TFT).Button(200, 325, 120, 36, 27, 0, "Apply"); |
nikmaos | 5:21240fa1ee4c | 173 | |
nikmaos | 7:c364201bc3ed | 174 | //(*_TFT).DL(TAG(SAVE_PRESS)); |
nikmaos | 7:c364201bc3ed | 175 | tx=200; ty=365; tw=120; th=36; |
nikmaos | 7:c364201bc3ed | 176 | if(TouchX>tx&&TouchY>ty&&TouchX<(tx+tw)&&TouchY<(ty+th)) |
nikmaos | 7:c364201bc3ed | 177 | pressedButton=key=SAVE_PRESS; |
nikmaos | 6:cfe7cb0bdb1a | 178 | (*_TFT).DL(COLOR_RGB(255, 255, 255)); |
nikmaos | 6:cfe7cb0bdb1a | 179 | if(key==SAVE_PRESS) |
nikmaos | 6:cfe7cb0bdb1a | 180 | (*_TFT).Button(200, 365, 120, 36, 27, OPT_FLAT, "Save"); |
nikmaos | 6:cfe7cb0bdb1a | 181 | else |
nikmaos | 6:cfe7cb0bdb1a | 182 | (*_TFT).Button(200, 365, 120, 36, 27, 0, "Save"); |
nikmaos | 6:cfe7cb0bdb1a | 183 | |
nikmaos | 6:cfe7cb0bdb1a | 184 | //переключатели ПИДов |
nikmaos | 7:c364201bc3ed | 185 | //(*_TFT).DL(TAG(PID1SW_PRESS)); |
nikmaos | 7:c364201bc3ed | 186 | tx=260; ty=420; tw=50; th=36; |
nikmaos | 7:c364201bc3ed | 187 | if(TouchX>tx&&TouchY>ty&&TouchX<(tx+tw)&&TouchY<(ty+th)) |
nikmaos | 7:c364201bc3ed | 188 | pressedButton=key=PID1SW_PRESS; |
nikmaos | 6:cfe7cb0bdb1a | 189 | (*_TFT).Toggle(260, 420,50,27,0,0,"OFF""\xff""ON"); |
nikmaos | 6:cfe7cb0bdb1a | 190 | if(key==PID1SW_PRESS) |
nikmaos | 6:cfe7cb0bdb1a | 191 | {PID1->enabled=~PID1->enabled;} |
nikmaos | 6:cfe7cb0bdb1a | 192 | if(PID1->enabled) |
nikmaos | 6:cfe7cb0bdb1a | 193 | (*_TFT).Toggle(260, 420,50,27,0,0xFFFF,"OFF""\xff""ON");//ПИД1 вкл |
nikmaos | 6:cfe7cb0bdb1a | 194 | |
nikmaos | 7:c364201bc3ed | 195 | //(*_TFT).DL(TAG(PID2SW_PRESS)); |
nikmaos | 7:c364201bc3ed | 196 | tx=385; ty=420; tw=50; th=36; |
nikmaos | 7:c364201bc3ed | 197 | if(TouchX>tx&&TouchY>ty&&TouchX<(tx+tw)&&TouchY<(ty+th)) |
nikmaos | 7:c364201bc3ed | 198 | pressedButton=key=PID2SW_PRESS; |
nikmaos | 6:cfe7cb0bdb1a | 199 | (*_TFT).Toggle(385, 420,50,27,0,0,"OFF""\xff""ON"); |
nikmaos | 7:c364201bc3ed | 200 | if(key==PID2SW_PRESS) |
nikmaos | 6:cfe7cb0bdb1a | 201 | {PID2->enabled=~PID2->enabled;} |
nikmaos | 6:cfe7cb0bdb1a | 202 | if(PID2->enabled) |
nikmaos | 7:c364201bc3ed | 203 | (*_TFT).Toggle(385, 420,50,27,0,0xFFFF,"OFF""\xff""ON");//ПИД2 вкл |
nikmaos | 5:21240fa1ee4c | 204 | |
nikmaos | 5:21240fa1ee4c | 205 | FinishDL(); |
nikmaos | 5:21240fa1ee4c | 206 | } |