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.
Dependents: PIMS_VisionIndus_IHM
Vision_Indus_IHM.cpp
00001 /****************************************************************************/ 00002 /* Vision Industrielle IHM */ 00003 /****************************************************************************/ 00004 /* LEnsE / Julien VILLEMEJANE / Institut d'Optique Graduate School */ 00005 /****************************************************************************/ 00006 /* Library - Vision_Indus_IHM.cpp file */ 00007 /****************************************************************************/ 00008 /* Tested on DISCO-F746 / 14th nov 2021 */ 00009 /****************************************************************************/ 00010 00011 #include "Vision_Indus_IHM.h" 00012 00013 /* Inputs and Outputs */ 00014 // Flex 00015 DigitalOut flex1_out(D4); 00016 DigitalOut flex2_out(D5); 00017 // Dome 00018 DigitalOut dome_out(D11); 00019 // Rasant 00020 DigitalOut rasant_out(D12); 00021 // Effi-RGB 00022 DigitalOut ringRGB_R_out(D6); 00023 DigitalOut ringRGB_G_out(D7); 00024 DigitalOut ringRGB_B_out(D8); 00025 // Conveyor 00026 PwmOut conveyor_speed(D14); 00027 DigitalOut conveyor_dir(D15); 00028 DigitalOut conveyor_m0(D9); 00029 DigitalOut conveyor_m1(D10); 00030 DigitalOut conveyor_enable(D3); 00031 DigitalOut conveyor_reset(D13); 00032 DigitalIn conveyor_fault(D2); 00033 00034 00035 /* Graphical objects */ 00036 Label title(240, 2, "Vision Industrielle", Label::CENTER, Font24); 00037 Label subtitle(240, 25, "LEnsE / 2021", Label::CENTER, Font16); 00038 // All On-Off 00039 Button light_on(250, 65, 80, 40, "ALL ON"); 00040 Button light_off(340, 65, 80, 40, "ALL OFF"); 00041 uint8_t all_on_active; 00042 // EFFI-Ring 00043 Label ringRGB(10, 50, "EFFI-Ring RGB", Label::LEFT); 00044 Button ringRGB_R(10, 65, 50, 40, "RED"); 00045 Button ringRGB_G(70, 65, 50, 40, "GREEN"); 00046 Button ringRGB_B(130, 65, 50, 40, "BLUE"); 00047 uint8_t ringRGB_R_active; 00048 uint8_t ringRGB_G_active; 00049 uint8_t ringRGB_B_active; 00050 // EFFI-Dome 00051 Label dome(10, 115, "EFFI-Dome W", Label::LEFT); 00052 Button dome_W(10, 130, 80, 40, "Dome"); 00053 uint8_t dome_active; 00054 // EFFI-Dome 00055 Label rasant(100, 115, "EFFI-Rlla R", Label::LEFT); 00056 Button rasant_R(100, 130, 80, 40, "Rasant"); 00057 uint8_t rasant_active; 00058 // EFFI-Flex 00059 Label flex1(10, 180, "EFFI-Flex W", Label::LEFT); 00060 Button flex1_W(10, 195, 80, 40, "Flex1"); 00061 uint8_t flex1_active; 00062 Button flex2_W(100, 195, 80, 40, "Flex2"); 00063 uint8_t flex2_active; 00064 // Conveyor 00065 Label conveyor(250, 200, "Convoyeur / Vitesse", Label::LEFT); 00066 NumericLabel<int> conv_speed_lab(400, 200, "V = ", Label::LEFT); 00067 SeekBar conv_speed(250, 250, 150, 0, 100, 0, "0", "", "100%"); 00068 00069 00070 00071 00072 /* initIHM */ 00073 void initIHM(void){ 00074 all_on_active = 0; 00075 light_off.Draw(0xFFFFFFFF, 0xFF000000); 00076 light_on.Draw(COLOR_OFF, 0xFFFFFFFF); 00077 /* EFFI-Ring */ 00078 ringRGB_R_active = 0; 00079 ringRGB_R_out = 1; 00080 ringRGB_R.Draw(COLOR_OFF); 00081 ringRGB_G_active = 0; 00082 ringRGB_G_out = 1; 00083 ringRGB_G.Draw(COLOR_OFF); 00084 ringRGB_B_active = 0; 00085 ringRGB_B_out = 1; 00086 ringRGB_B.Draw(COLOR_OFF); 00087 /* EFFI-Dome */ 00088 dome_active = 0; 00089 dome_out = 1; 00090 dome_W.Draw(COLOR_OFF); 00091 /* EFFI-Rlla */ 00092 rasant_active = 0; 00093 rasant_out = 1; 00094 rasant_R.Draw(COLOR_OFF); 00095 /* EFFI-Flex */ 00096 flex1_active = 0; 00097 flex1_out = 1; 00098 flex1_W.Draw(COLOR_OFF); 00099 flex2_active = 0; 00100 flex2_out = 1; 00101 flex2_W.Draw(COLOR_OFF); 00102 /* Conveyor */ 00103 int8_t x = (int8_t)conv_speed.GetValue(); 00104 conv_speed_lab.Draw("%3d m/s", x); 00105 conveyor_enable = 1; 00106 conveyor_reset = 1; 00107 conveyor_m0 = 0; 00108 conveyor_m1 = 0; 00109 conveyor_speed.period_us(1000); 00110 conveyor_dir = CONV_DIR_FW; 00111 conveyor_speed.write(0); // STOP 00112 } 00113 00114 /* updateIHM */ 00115 void updateIHM(void){ 00116 if (light_on.Touched()){ 00117 all_on_active = 1; 00118 } 00119 if(all_on_active == 1){ 00120 light_off.Draw(COLOR_OFF, 0xFFFFFFFF); 00121 light_on.Draw(0xFFFFFFFF, 0xFF000000); 00122 00123 ringRGB_R_active = 1; 00124 ringRGB_R_out = 0; 00125 ringRGB_R.Draw(0xFFFF0000); 00126 ringRGB_G_active = 1; 00127 ringRGB_G_out = 0; 00128 ringRGB_G.Draw(0xFF33DD33, 0xFF000000); 00129 ringRGB_B_active = 1; 00130 ringRGB_B_out = 0; 00131 ringRGB_B.Draw(0xFF0000FF); 00132 00133 dome_active = 1; 00134 dome_out = 0; 00135 dome_W.Draw(0xFFFFFFFF, 0xFF000000); 00136 00137 rasant_active = 1; 00138 rasant_out = 0; 00139 rasant_R.Draw(0xFFFF0000); 00140 00141 flex1_active = 1; 00142 flex1_out = 0; 00143 flex1_W.Draw(0xFFEEEEEE, 0xFF000000); 00144 flex2_active = 1; 00145 flex2_out = 0; 00146 flex2_W.Draw(0xFFEEEEEE, 0xFF000000); 00147 00148 all_on_active = 0; 00149 } 00150 else{ 00151 light_off.Draw(0xFFFFFFFF, 0xFF000000); 00152 light_on.Draw(COLOR_OFF, 0xFFFFFFFF); 00153 if (light_off.Touched()){ 00154 all_on_active = 0; 00155 light_off.Draw(0xFFFFFFFF, 0xFF000000); 00156 light_on.Draw(COLOR_OFF, 0xFFFFFFFF); 00157 } 00158 if (ringRGB_R.Touched()){ 00159 if(ringRGB_R_active){ 00160 ringRGB_R_active = 0; 00161 ringRGB_R_out = 1; 00162 all_on_active = 0; 00163 ringRGB_R.Draw(COLOR_OFF); 00164 } 00165 else{ 00166 ringRGB_R_active = 1; 00167 ringRGB_R_out = 0; 00168 ringRGB_R.Draw(0xFFFF0000); 00169 } 00170 00171 } 00172 if (ringRGB_G.Touched()){ 00173 if(ringRGB_G_active){ 00174 ringRGB_G_active = 0; 00175 ringRGB_G_out = 1; 00176 all_on_active = 0; 00177 ringRGB_G.Draw(COLOR_OFF, 0xFFFFFFFF); 00178 } 00179 else{ 00180 ringRGB_G_active = 1; 00181 ringRGB_G_out = 0; 00182 ringRGB_G.Draw(0xFF33DD33, 0xFF000000); 00183 } 00184 00185 } 00186 if (ringRGB_B.Touched()){ 00187 if(ringRGB_B_active){ 00188 ringRGB_B_active = 0; 00189 ringRGB_B_out = 1; 00190 all_on_active = 0; 00191 ringRGB_B.Draw(COLOR_OFF); 00192 } 00193 else{ 00194 ringRGB_B_active = 1; 00195 ringRGB_B_out = 0; 00196 ringRGB_B.Draw(0xFF0000FF); 00197 } 00198 00199 } 00200 if (dome_W.Touched()){ 00201 if(dome_active){ 00202 dome_active = 0; 00203 dome_out = 1; 00204 all_on_active = 0; 00205 dome_W.Draw(COLOR_OFF, 0xFFFFFFFF); 00206 } 00207 else{ 00208 dome_active = 1; 00209 dome_out = 0; 00210 dome_W.Draw(0xFFFFFFFF, 0xFF000000); 00211 } 00212 } 00213 if (rasant_R.Touched()){ 00214 if(rasant_active){ 00215 rasant_active = 0; 00216 rasant_out = 1; 00217 all_on_active = 0; 00218 rasant_R.Draw(COLOR_OFF); 00219 } 00220 else{ 00221 rasant_active = 1; 00222 rasant_out = 0; 00223 rasant_R.Draw(0xFFFF0000); 00224 } 00225 } 00226 if (flex1_W.Touched()){ 00227 if(flex1_active){ 00228 flex1_active = 0; 00229 flex1_out = 1; 00230 all_on_active = 0; 00231 flex1_W.Draw(COLOR_OFF, 0xFFFFFFFF); 00232 } 00233 else{ 00234 flex1_active = 1; 00235 flex1_out = 0; 00236 flex1_W.Draw(0xFFEEEEEE, 0xFF000000); 00237 } 00238 } 00239 00240 if (flex2_W.Touched()){ 00241 if(flex2_active){ 00242 flex2_active = 0; 00243 flex2_out = 1; 00244 all_on_active = 0; 00245 flex2_W.Draw(COLOR_OFF, 0xFFFFFFFF); 00246 } 00247 else{ 00248 flex2_active = 1; 00249 flex2_out = 0; 00250 flex2_W.Draw(0xFFEEEEEE, 0xFF000000); 00251 } 00252 } 00253 } 00254 if (conv_speed.Slide()) 00255 { 00256 int8_t x = (int8_t)conv_speed.GetValue(); 00257 conv_speed_lab.Draw("%3d", x); 00258 } 00259 00260 } 00261 00262 /* updateIHM */ 00263 void moveConveyor(char dir, int speed_us){ 00264 conveyor_enable = 0; 00265 conveyor_speed.period_us(speed_us); 00266 conveyor_dir = dir; 00267 conveyor_speed.write(0.5); 00268 } 00269 /* updateIHM */ 00270 void stopConveyor(void){ 00271 conveyor_enable = 1; 00272 conveyor_speed.write(0); 00273 }
Generated on Wed Jul 27 2022 20:52:31 by
 1.7.2
 1.7.2