test

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

Committer:
nikmaos
Date:
Thu Aug 13 14:37:39 2020 +0000
Revision:
5:21240fa1ee4c
Child:
6:cfe7cb0bdb1a
13.08

Who changed what in which revision?

UserRevisionLine numberNew 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 5:21240fa1ee4c 146 (*_TFT).DL(TAG_MASK(0));
nikmaos 5:21240fa1ee4c 147
nikmaos 5:21240fa1ee4c 148
nikmaos 5:21240fa1ee4c 149
nikmaos 5:21240fa1ee4c 150 FinishDL();
nikmaos 5:21240fa1ee4c 151 }