test
Dependencies: ad5422_arduino mbed LT1446 ADS1248-1 LM35-1 Flash FT813 PGA280_ADS1259
TFT/display.PidScreen.cpp@6:cfe7cb0bdb1a, 2020-08-14 (annotated)
- Committer:
- nikmaos
- Date:
- Fri Aug 14 14:16:03 2020 +0000
- Revision:
- 6:cfe7cb0bdb1a
- Parent:
- 5:21240fa1ee4c
- Child:
- 7:c364201bc3ed
1408
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 | 5:21240fa1ee4c | 7 | |
nikmaos | 5:21240fa1ee4c | 8 | StartDL(); |
nikmaos | 5:21240fa1ee4c | 9 | (*_TFT).DL(CLEAR_COLOR_RGB(31, 63, 127)); |
nikmaos | 5:21240fa1ee4c | 10 | // clear buffers for preset values |
nikmaos | 5:21240fa1ee4c | 11 | (*_TFT).DL(CLEAR(1, 1, 1)); |
nikmaos | 5:21240fa1ee4c | 12 | (*_TFT).DL(COLOR_RGB(255, 255, 255)); |
nikmaos | 5:21240fa1ee4c | 13 | (*_TFT).Text(300, 10 , 29, 0, "PID Controller Menu"); |
nikmaos | 5:21240fa1ee4c | 14 | myWdget_NumPad(500,80); |
nikmaos | 5:21240fa1ee4c | 15 | |
nikmaos | 5:21240fa1ee4c | 16 | //поля для отображения настроек |
nikmaos | 5:21240fa1ee4c | 17 | sprintf(str_v,"PID temp: %0.2f oC | Power: %04d",temp,power1); |
nikmaos | 5:21240fa1ee4c | 18 | myWdget_Edit(34,78,420,40,0,str_v); |
nikmaos | 5:21240fa1ee4c | 19 | |
nikmaos | 5:21240fa1ee4c | 20 | sprintf(str_v,"PID Rashod: %0.4f cm3/kg | Power: %04d",ras,power2); |
nikmaos | 5:21240fa1ee4c | 21 | myWdget_Edit(34,78+44,420,40,0,str_v); |
nikmaos | 5:21240fa1ee4c | 22 | |
nikmaos | 5:21240fa1ee4c | 23 | (*_TFT).DL(TAG_MASK(1)); |
nikmaos | 5:21240fa1ee4c | 24 | |
nikmaos | 5:21240fa1ee4c | 25 | (*_TFT).DL(TAG(SEL_P1)); |
nikmaos | 5:21240fa1ee4c | 26 | sprintf(str_v,"P1: %04.2f",PID1->kP); |
nikmaos | 5:21240fa1ee4c | 27 | if(selectedEditor==EDIT_P1) |
nikmaos | 5:21240fa1ee4c | 28 | {sel=1; |
nikmaos | 5:21240fa1ee4c | 29 | myWdget_Edit_change(str_v); |
nikmaos | 5:21240fa1ee4c | 30 | sprintf(str_v,"%s",str_edit); |
nikmaos | 5:21240fa1ee4c | 31 | } |
nikmaos | 5:21240fa1ee4c | 32 | myWdget_Edit(34,78+44+44,420/2-2,40,sel,str_v); |
nikmaos | 5:21240fa1ee4c | 33 | sel=0; |
nikmaos | 5:21240fa1ee4c | 34 | |
nikmaos | 5:21240fa1ee4c | 35 | (*_TFT).DL(TAG(SEL_P2)); |
nikmaos | 5:21240fa1ee4c | 36 | sprintf(str_v,"P2: %04.2f",PID2->kP); |
nikmaos | 5:21240fa1ee4c | 37 | if(selectedEditor==EDIT_P2) |
nikmaos | 5:21240fa1ee4c | 38 | { |
nikmaos | 5:21240fa1ee4c | 39 | sel=1; |
nikmaos | 5:21240fa1ee4c | 40 | myWdget_Edit_change(str_v); |
nikmaos | 5:21240fa1ee4c | 41 | sprintf(str_v,"%s",str_edit); |
nikmaos | 5:21240fa1ee4c | 42 | } |
nikmaos | 5:21240fa1ee4c | 43 | myWdget_Edit(34+420/2+2,78+44+44,420/2-2,40,sel,str_v); |
nikmaos | 5:21240fa1ee4c | 44 | sel=0; |
nikmaos | 5:21240fa1ee4c | 45 | |
nikmaos | 5:21240fa1ee4c | 46 | (*_TFT).DL(TAG(SEL_I1)); |
nikmaos | 5:21240fa1ee4c | 47 | sprintf(str_v,"I1: %06.1f",PID1->kI); |
nikmaos | 5:21240fa1ee4c | 48 | if(selectedEditor==EDIT_I1) |
nikmaos | 5:21240fa1ee4c | 49 | { |
nikmaos | 5:21240fa1ee4c | 50 | sel=1; |
nikmaos | 5:21240fa1ee4c | 51 | myWdget_Edit_change(str_v); |
nikmaos | 5:21240fa1ee4c | 52 | sprintf(str_v,"%s",str_edit); |
nikmaos | 5:21240fa1ee4c | 53 | } |
nikmaos | 5:21240fa1ee4c | 54 | myWdget_Edit(34,78+44*3,420/2-2,40,sel,str_v); |
nikmaos | 5:21240fa1ee4c | 55 | sel=0; |
nikmaos | 5:21240fa1ee4c | 56 | |
nikmaos | 5:21240fa1ee4c | 57 | (*_TFT).DL(TAG(SEL_I2)); |
nikmaos | 5:21240fa1ee4c | 58 | sprintf(str_v,"I2: %06.1f",PID2->kI); |
nikmaos | 5:21240fa1ee4c | 59 | if(selectedEditor==EDIT_I2) |
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 | 5:21240fa1ee4c | 65 | myWdget_Edit(34+420/2+2,78+44*3,420/2-2,40,sel,str_v); |
nikmaos | 5:21240fa1ee4c | 66 | sel=0; |
nikmaos | 5:21240fa1ee4c | 67 | |
nikmaos | 5:21240fa1ee4c | 68 | (*_TFT).DL(TAG(SEL_D1)); |
nikmaos | 5:21240fa1ee4c | 69 | sprintf(str_v,"D1: %05.2f",PID1->kD); |
nikmaos | 5:21240fa1ee4c | 70 | if(selectedEditor==EDIT_D1) |
nikmaos | 5:21240fa1ee4c | 71 | { |
nikmaos | 5:21240fa1ee4c | 72 | sel=1; |
nikmaos | 5:21240fa1ee4c | 73 | myWdget_Edit_change(str_v); |
nikmaos | 5:21240fa1ee4c | 74 | sprintf(str_v,"%s",str_edit); |
nikmaos | 5:21240fa1ee4c | 75 | } |
nikmaos | 5:21240fa1ee4c | 76 | myWdget_Edit(34,78+44*4,420/2-2,40,sel,str_v); |
nikmaos | 5:21240fa1ee4c | 77 | sel=0; |
nikmaos | 5:21240fa1ee4c | 78 | |
nikmaos | 5:21240fa1ee4c | 79 | (*_TFT).DL(TAG(SEL_D2)); |
nikmaos | 5:21240fa1ee4c | 80 | sprintf(str_v,"D2: %05.2f",PID2->kD); |
nikmaos | 5:21240fa1ee4c | 81 | if(selectedEditor==EDIT_D2) |
nikmaos | 5:21240fa1ee4c | 82 | { |
nikmaos | 5:21240fa1ee4c | 83 | sel=1; |
nikmaos | 5:21240fa1ee4c | 84 | |
nikmaos | 5:21240fa1ee4c | 85 | myWdget_Edit_change(str_v); |
nikmaos | 5:21240fa1ee4c | 86 | sprintf(str_v,"%s",str_edit); |
nikmaos | 5:21240fa1ee4c | 87 | } |
nikmaos | 5:21240fa1ee4c | 88 | myWdget_Edit(34+420/2+2,78+44*4,420/2-2,40,sel,str_v); |
nikmaos | 5:21240fa1ee4c | 89 | sel=0; |
nikmaos | 5:21240fa1ee4c | 90 | |
nikmaos | 5:21240fa1ee4c | 91 | (*_TFT).DL(TAG(BACK_PRESS)); |
nikmaos | 5:21240fa1ee4c | 92 | (*_TFT).DL(COLOR_RGB(255, 255, 255)); |
nikmaos | 5:21240fa1ee4c | 93 | if(key==BACK_PRESS) |
nikmaos | 5:21240fa1ee4c | 94 | (*_TFT).Button(34, 325, 120, 36, 27, OPT_FLAT, "Back"); |
nikmaos | 5:21240fa1ee4c | 95 | else |
nikmaos | 5:21240fa1ee4c | 96 | (*_TFT).Button(34, 325, 120, 36, 27, 0, "Back"); |
nikmaos | 5:21240fa1ee4c | 97 | |
nikmaos | 5:21240fa1ee4c | 98 | |
nikmaos | 5:21240fa1ee4c | 99 | (*_TFT).DL(TAG(CANCEL_PRESS)); |
nikmaos | 5:21240fa1ee4c | 100 | (*_TFT).DL(COLOR_RGB(255, 255, 255)); |
nikmaos | 5:21240fa1ee4c | 101 | if(key==CANCEL_PRESS) |
nikmaos | 5:21240fa1ee4c | 102 | { |
nikmaos | 5:21240fa1ee4c | 103 | (*_TFT).Button(325, 325, 120, 36, 27, OPT_FLAT, "Cancel"); |
nikmaos | 5:21240fa1ee4c | 104 | selectedEditor=EDIT_NONE; |
nikmaos | 5:21240fa1ee4c | 105 | for(int i=0;i<10;i++) |
nikmaos | 5:21240fa1ee4c | 106 | str_edit[i]=0; |
nikmaos | 5:21240fa1ee4c | 107 | cursor=0; |
nikmaos | 5:21240fa1ee4c | 108 | str_edit[0]='_'; |
nikmaos | 5:21240fa1ee4c | 109 | } |
nikmaos | 5:21240fa1ee4c | 110 | else |
nikmaos | 5:21240fa1ee4c | 111 | (*_TFT).Button(325, 325, 120, 36, 27, 0, "Cancel"); |
nikmaos | 5:21240fa1ee4c | 112 | |
nikmaos | 5:21240fa1ee4c | 113 | (*_TFT).DL(TAG(APPLY_PRESS)); |
nikmaos | 5:21240fa1ee4c | 114 | (*_TFT).DL(COLOR_RGB(255, 255, 255)); |
nikmaos | 5:21240fa1ee4c | 115 | if(key==APPLY_PRESS) |
nikmaos | 5:21240fa1ee4c | 116 | { |
nikmaos | 5:21240fa1ee4c | 117 | (*_TFT).Button(200, 325, 120, 36, 27, OPT_FLAT, "Apply"); |
nikmaos | 5:21240fa1ee4c | 118 | //Применение значений |
nikmaos | 5:21240fa1ee4c | 119 | if(selectedEditor==EDIT_P1) |
nikmaos | 5:21240fa1ee4c | 120 | PID1->kP=btf(str_edit); |
nikmaos | 5:21240fa1ee4c | 121 | |
nikmaos | 5:21240fa1ee4c | 122 | if(selectedEditor==EDIT_P2) |
nikmaos | 5:21240fa1ee4c | 123 | PID2->kP=btf(str_edit); |
nikmaos | 5:21240fa1ee4c | 124 | |
nikmaos | 5:21240fa1ee4c | 125 | if(selectedEditor==EDIT_I1) |
nikmaos | 5:21240fa1ee4c | 126 | PID1->kI=btf(str_edit); |
nikmaos | 5:21240fa1ee4c | 127 | |
nikmaos | 5:21240fa1ee4c | 128 | if(selectedEditor==EDIT_I2) |
nikmaos | 5:21240fa1ee4c | 129 | PID2->kI=btf(str_edit); |
nikmaos | 5:21240fa1ee4c | 130 | |
nikmaos | 5:21240fa1ee4c | 131 | if(selectedEditor==EDIT_D1) |
nikmaos | 5:21240fa1ee4c | 132 | PID1->kD=btf(str_edit); |
nikmaos | 5:21240fa1ee4c | 133 | |
nikmaos | 5:21240fa1ee4c | 134 | if(selectedEditor==EDIT_D2) |
nikmaos | 5:21240fa1ee4c | 135 | PID2->kD=btf(str_edit); |
nikmaos | 5:21240fa1ee4c | 136 | |
nikmaos | 5:21240fa1ee4c | 137 | selectedEditor=EDIT_NONE; |
nikmaos | 5:21240fa1ee4c | 138 | for(int i=0;i<10;i++) |
nikmaos | 5:21240fa1ee4c | 139 | str_edit[i]=0; |
nikmaos | 5:21240fa1ee4c | 140 | cursor=0; |
nikmaos | 5:21240fa1ee4c | 141 | str_edit[0]='_'; |
nikmaos | 5:21240fa1ee4c | 142 | } |
nikmaos | 5:21240fa1ee4c | 143 | else |
nikmaos | 5:21240fa1ee4c | 144 | (*_TFT).Button(200, 325, 120, 36, 27, 0, "Apply"); |
nikmaos | 5:21240fa1ee4c | 145 | |
nikmaos | 6:cfe7cb0bdb1a | 146 | (*_TFT).DL(TAG(SAVE_PRESS)); |
nikmaos | 6:cfe7cb0bdb1a | 147 | (*_TFT).DL(COLOR_RGB(255, 255, 255)); |
nikmaos | 6:cfe7cb0bdb1a | 148 | if(key==SAVE_PRESS) |
nikmaos | 6:cfe7cb0bdb1a | 149 | (*_TFT).Button(200, 365, 120, 36, 27, OPT_FLAT, "Save"); |
nikmaos | 6:cfe7cb0bdb1a | 150 | else |
nikmaos | 6:cfe7cb0bdb1a | 151 | (*_TFT).Button(200, 365, 120, 36, 27, 0, "Save"); |
nikmaos | 6:cfe7cb0bdb1a | 152 | |
nikmaos | 6:cfe7cb0bdb1a | 153 | //переключатели ПИДов |
nikmaos | 6:cfe7cb0bdb1a | 154 | (*_TFT).DL(TAG(PID1SW_PRESS)); |
nikmaos | 6:cfe7cb0bdb1a | 155 | (*_TFT).Toggle(260, 420,50,27,0,0,"OFF""\xff""ON"); |
nikmaos | 6:cfe7cb0bdb1a | 156 | if(key==PID1SW_PRESS) |
nikmaos | 6:cfe7cb0bdb1a | 157 | {PID1->enabled=~PID1->enabled;} |
nikmaos | 6:cfe7cb0bdb1a | 158 | if(PID1->enabled) |
nikmaos | 6:cfe7cb0bdb1a | 159 | (*_TFT).Toggle(260, 420,50,27,0,0xFFFF,"OFF""\xff""ON");//ПИД1 вкл |
nikmaos | 6:cfe7cb0bdb1a | 160 | |
nikmaos | 6:cfe7cb0bdb1a | 161 | (*_TFT).DL(TAG(PID2SW_PRESS)); |
nikmaos | 6:cfe7cb0bdb1a | 162 | (*_TFT).Toggle(385, 420,50,27,0,0,"OFF""\xff""ON"); |
nikmaos | 6:cfe7cb0bdb1a | 163 | if(key==PID2SW_PRESS) |
nikmaos | 6:cfe7cb0bdb1a | 164 | {PID2->enabled=~PID2->enabled;} |
nikmaos | 6:cfe7cb0bdb1a | 165 | if(PID2->enabled) |
nikmaos | 6:cfe7cb0bdb1a | 166 | (*_TFT).Toggle(385, 420,50,27,0,0xFFFF,"OFF""\xff""ON");//ПИД2 вкл |
nikmaos | 5:21240fa1ee4c | 167 | (*_TFT).DL(TAG_MASK(0)); |
nikmaos | 5:21240fa1ee4c | 168 | |
nikmaos | 5:21240fa1ee4c | 169 | |
nikmaos | 5:21240fa1ee4c | 170 | |
nikmaos | 5:21240fa1ee4c | 171 | FinishDL(); |
nikmaos | 5:21240fa1ee4c | 172 | } |