summaryrefslogtreecommitdiff
path: root/tools/scilab/linux/macros/Arduino_GUI.sce
blob: 36a85768fecd0f69aa37842ebfbecf23d5093f04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
// This GUI file is generated by guibuilder version 3.0
//////////

function disable_all(handles)
    
    for cnt = 2:13
        cmd_str = "set(handles.d" + string(cnt) + ",''Enable'',''off'')";
        eval(cmd_str);
    end
    
    for cnt = 0:5
        cmd_str = "set(handles.a" + string(cnt) + ",''Enable'',''off'')";
        eval(cmd_str);
    end

endfunction

f=figure('figure_position',[128,41],'figure_size',[1024,645],'auto_resize','on','background',[33],'figure_name','Graphic window number %d',"visible", "off",...
"dockable", "off", ...
"infobar_visible", "off", ...
"toolbar_visible", "off", ...
"menubar_visible", "off", ...
"default_axes", "off");
//////////
//delmenu(f.figure_id,gettext('File'))
//delmenu(f.figure_id,gettext('?'))
//delmenu(f.figure_id,gettext('Tools'))
//toolbar(f.figure_id,'off')


//f = figure( ...
//"dockable", "off", ...
//"infobar_visible", "off", ...
//"toolbar_visible", "off", ...
//"menubar_visible", "off", ...
//"default_axes", "off",...
//"visible", "off");
//f.tag = "scilab550video";
//f.figure_size = [717,669];
//f.layout = "border";
//f.figure_name = "Scilab 5.5.0 new features";
//f.icon = "applications-system";
//f.background = -2;
//tab = uicontrol("parent", f, "style", "tab");

handles.dummy = 0;
handles.obj1=uicontrol(f,'unit','normalized','BackgroundColor',[-1,-1,-1],'Enable','on','FontAngle','normal','FontName','Tahoma','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[-1,-1,-1],'HorizontalAlignment','left','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.2571875,0.0233333,0.38625,0.9316667],'Relief','default','SliderStep',[0.01,0.1],'String','ArduinoUnoR3.png','Style','image','Value',[1,1,0,0,0],'VerticalAlignment','middle','Visible','on','Tag','obj1','Callback','obj1_callback(handles)')

//handles.fr_d2 = uicontrol(f,"style", "frame",'unit','normalized',"layout", "gridbag",'Position',[0.7742857,0.1214789,0.0642857,0.0352113], ...
//    "border", createBorder("titled", createBorder("etched", "lowered"), "Figure size"), ...
//    "constraints", createConstraints("gridbag", [1, 2, 1, 1], [1 1], "horizontal"));
//      
//    handles.rd_d2a=uicontrol(handles.fr_d2,'unit','normalized','BackgroundColor',[-1,-1,-1],'Enable','on','FontAngle','normal','FontName','Tahoma','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[-1,-1,-1],'HorizontalAlignment','left','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.7742857,0.1214789,0.0342857,0.0352113],'Relief','default','SliderStep',[0.01,0.1],'String','UnName2','Style','radiobutton','Value',[1],'VerticalAlignment','middle','Visible','on','Tag','rd_d2a','Callback','rd_d2a_callback(handles)')
//    handles.rd_d2b=uicontrol(handles.fr_d2,'unit','normalized','BackgroundColor',[-1,-1,-1],'Enable','on','FontAngle','normal','FontName','Tahoma','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[-1,-1,-1],'HorizontalAlignment','left','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.81,0.1197183,0.0328571,0.0352113],'Relief','default','SliderStep',[0.01,0.1],'String','UnName3','Style','radiobutton','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','rd_d2b','Callback','rd_d2b_callback(handles)')
//
//handles.rd_d3a=uicontrol(f,'unit','normalized','BackgroundColor',[-1,-1,-1],'Enable','on','FontAngle','normal','FontName','Tahoma','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[-1,-1,-1],'HorizontalAlignment','left','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.7757143,0.1619718,0.0257143,0.0264085],'Relief','default','SliderStep',[0.01,0.1],'String','UnName4','Style','radiobutton','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','rd_d3a','Callback','rd_d3a_callback(handles)')
//
x_pos = 0.65;
y_pos = 0.155;
width = 0.25;
height = 0.03;
y_offset = 0.029;
d2 = 2; 
d3 = 3; 
d4 = 4; 
d5 = 5; 
d6 = 6; 
d7 = 7;
d8 = 9;
d9 = 10;
d10 = 11;
d11 = 12;
d12 = 13;
d13 = 14;
dlabel = 15;

  handles.d2 = uicontrol("parent", f, 'unit','normalized',"style", "frame","layout", "gridbag","constraints", createConstraints("gridbag", [6, 1, 1, 1], [1 1], "horizontal"),...
    'Position',[x_pos,y_pos + y_offset*(d2-2),width,height],...
    "border", createBorder("line", 'blue'));
    handles.d2a = uicontrol("parent", handles.d2,'unit','normalized',"style", "radiobutton","horizontalalignment", "left","group", "d2", ...
    "constraints", createConstraints("gridbag", [1, 1, 1, 1], [0.1 1], "both"), ...
    "callback", "da_callback(handles,d2)");
    handles.d2b = uicontrol("parent", handles.d2,'unit','normalized',"style", "radiobutton","horizontalalignment", "left","group", "d2", ...
    "constraints", createConstraints("gridbag", [2, 1, 1, 1], [0.1 1], "both"), ...
    "callback", "db_callback(handles,d2)");
     handles.d2c = uicontrol("parent", handles.d2,'unit','normalized',"style", "radiobutton","horizontalalignment", "left","group", "d2",...
    "constraints", createConstraints("gridbag", [3, 1, 1, 1], [0.1 1], "both"), ...
    "callback", "dc_callback(handles,d2)");
     handles.d2d = uicontrol("parent", handles.d2,'unit','normalized',"style", "radiobutton","horizontalalignment", "left","group", "d2","enable","off",...
    "constraints", createConstraints("gridbag", [4, 1, 1, 1], [0.1 1], "both"), ...
    "callback", "dd_callback(handles,d2)");
    handles.d2a.value = 1;    
     handles.d2edit = uicontrol("parent", handles.d2,'unit','normalized',"style", "edit","horizontalalignment", "center","VerticalAlignment","top","group", "d2","Enable", "off",...
    'String','0',...
    "constraints", createConstraints("gridbag", [5, 1, 1, 1], [1.5 1], "both"), ...
    "callback", "");          
     handles.d2btn = uicontrol("parent", handles.d2,'unit','normalized',"style", "pushbutton","horizontalalignment", "center","group", "d2",...
    'String','Run',...
    "constraints", createConstraints("gridbag", [6, 1, 1, 1], [0.5 1], "both"), ...
    "callback", "dbtn_callback(handles,d2)");    
    
   handles.d4 = uicontrol("parent", f, 'unit','normalized',"style", "frame","layout", "gridbag","constraints", createConstraints("gridbag", [6, 1, 1, 1], [1 1], "horizontal"),...
    'Position',[x_pos,y_pos + y_offset*(d4-2),width,height],...
    "border", createBorder("line", 'blue'));
    handles.d4a = uicontrol("parent", handles.d4,'unit','normalized',"style", "radiobutton","horizontalalignment", "left","group", "d4", ...
    "constraints", createConstraints("gridbag", [1, 1, 1, 1], [0.1 1], "both"), ...
    "callback", "da_callback(handles,d4)");
    handles.d4b = uicontrol("parent", handles.d4,'unit','normalized',"style", "radiobutton","horizontalalignment", "left","group", "d4", ...
    "constraints", createConstraints("gridbag", [2, 1, 1, 1], [0.1 1], "both"), ...
    "callback", "db_callback(handles,d4)");
     handles.d4c = uicontrol("parent", handles.d4,'unit','normalized',"style", "radiobutton","horizontalalignment", "left","group", "d4",...
    "constraints", createConstraints("gridbag", [3, 1, 1, 1], [0.1 1], "both"), ...
    "callback", "dc_callback(handles,d4)");
     handles.d4d = uicontrol("parent", handles.d4,'unit','normalized',"style", "radiobutton","horizontalalignment", "left","group", "d4","enable","off",...
    "constraints", createConstraints("gridbag", [4, 1, 1, 1], [0.1 1], "both"), ...
    "callback", "dd_callback(handles,d4)");
    handles.d4a.value = 1;    
     handles.d4edit = uicontrol("parent", handles.d4,'unit','normalized',"style", "edit","horizontalalignment", "center","VerticalAlignment","top","group", "d4","Enable", "off",...
    'String','0',...
    "constraints", createConstraints("gridbag", [5, 1, 1, 1], [1.5 1], "both"), ...
    "callback", "");          
     handles.d4btn = uicontrol("parent", handles.d4,'unit','normalized',"style", "pushbutton","horizontalalignment", "center","group", "d4",...
    'String','Run',...
    "constraints", createConstraints("gridbag", [6, 1, 1, 1], [0.5 1], "both"), ...
    "callback", "dbtn_callback(handles,d4)");  
  handles.d7 = uicontrol("parent", f, 'unit','normalized',"style", "frame","layout", "gridbag","constraints", createConstraints("gridbag", [6, 1, 1, 1], [1 1], "horizontal"),...
    'Position',[x_pos,y_pos + y_offset*(d7-2),width,height],...
    "border", createBorder("line", 'blue'));
    handles.d7a = uicontrol("parent", handles.d7,'unit','normalized',"style", "radiobutton","horizontalalignment", "left","group", "d7", ...
    "constraints", createConstraints("gridbag", [1, 1, 1, 1], [0.1 1], "both"), ...
    "callback", "da_callback(handles,d7)");
    handles.d7b = uicontrol("parent", handles.d7,'unit','normalized',"style", "radiobutton","horizontalalignment", "left","group", "d7", ...
    "constraints", createConstraints("gridbag", [2, 1, 1, 1], [0.1 1], "both"), ...
    "callback", "db_callback(handles,d7)");
     handles.d7c = uicontrol("parent", handles.d7,'unit','normalized',"style", "radiobutton","horizontalalignment", "left","group", "d7",...
    "constraints", createConstraints("gridbag", [3, 1, 1, 1], [0.1 1], "both"), ...
    "callback", "dc_callback(handles,d7)");
     handles.d7d = uicontrol("parent", handles.d7,'unit','normalized',"style", "radiobutton","horizontalalignment", "left","group", "d7","enable","off",...
    "constraints", createConstraints("gridbag", [4, 1, 1, 1], [0.1 1], "both"), ...
    "callback", "dd_callback(handles,d7)");
    handles.d7a.value = 1;    
     handles.d7edit = uicontrol("parent", handles.d7,'unit','normalized',"style", "edit","horizontalalignment", "center","VerticalAlignment","top","group", "d7","Enable", "off",...
    'String','0',...
    "constraints", createConstraints("gridbag", [5, 1, 1, 1], [1.5 1], "both"), ...
    "callback", "");          
     handles.d7btn = uicontrol("parent", handles.d7,'unit','normalized',"style", "pushbutton","horizontalalignment", "center","group", "d7",...
    'String','Run',...
    "constraints", createConstraints("gridbag", [6, 1, 1, 1], [0.5 1], "both"), ...
    "callback", "dbtn_callback(handles,d7)");  
  handles.d8 = uicontrol("parent", f, 'unit','normalized',"style", "frame","layout", "gridbag","constraints", createConstraints("gridbag", [6, 1, 1, 1], [1 1], "horizontal"),...
    'Position',[x_pos,y_pos + y_offset*(d8-2),width,height],...
    "border", createBorder("line", 'blue'));
    handles.d8a = uicontrol("parent", handles.d8,'unit','normalized',"style", "radiobutton","horizontalalignment", "left","group", "d8", ...
    "constraints", createConstraints("gridbag", [1, 1, 1, 1], [0.1 1], "both"), ...
    "callback", "da_callback(handles,d8)");
    handles.d8b = uicontrol("parent", handles.d8,'unit','normalized',"style", "radiobutton","horizontalalignment", "left","group", "d8", ...
    "constraints", createConstraints("gridbag", [2, 1, 1, 1], [0.1 1], "both"), ...
    "callback", "db_callback(handles,d8)");
     handles.d8c = uicontrol("parent", handles.d8,'unit','normalized',"style", "radiobutton","horizontalalignment", "left","group", "d8",...
    "constraints", createConstraints("gridbag", [3, 1, 1, 1], [0.1 1], "both"), ...
    "callback", "dc_callback(handles,d8)");
     handles.d8d = uicontrol("parent", handles.d8,'unit','normalized',"style", "radiobutton","horizontalalignment", "left","group", "d8","enable","off",...
    "constraints", createConstraints("gridbag", [4, 1, 1, 1], [0.1 1], "both"), ...
    "callback", "dd_callback(handles,d8)");
    handles.d8a.value = 1;    
     handles.d8edit = uicontrol("parent", handles.d8,'unit','normalized',"style", "edit","horizontalalignment", "center","VerticalAlignment","top","group", "d8","Enable", "off",...
    'String','0',...
    "constraints", createConstraints("gridbag", [5, 1, 1, 1], [1.5 1], "both"), ...
    "callback", "");          
     handles.d8btn = uicontrol("parent", handles.d8,'unit','normalized',"style", "pushbutton","horizontalalignment", "center","group", "d8",...
    'String','Run',...
    "constraints", createConstraints("gridbag", [6, 1, 1, 1], [0.5 1], "both"), ...
    "callback", "dbtn_callback(handles,d8)");  
  handles.d12 = uicontrol("parent", f, 'unit','normalized',"style", "frame","layout", "gridbag","constraints", createConstraints("gridbag", [6, 1, 1, 1], [1 1], "horizontal"),...
    'Position',[x_pos,y_pos + y_offset*(d12-2),width,height],...
    "border", createBorder("line", 'blue'));
    handles.d12a = uicontrol("parent", handles.d12,'unit','normalized',"style", "radiobutton","horizontalalignment", "left","group", "d12", ...
    "constraints", createConstraints("gridbag", [1, 1, 1, 1], [0.1 1], "both"), ...
    "callback", "da_callback(handles,d12)");
    handles.d12b = uicontrol("parent", handles.d12,'unit','normalized',"style", "radiobutton","horizontalalignment", "left","group", "d12", ...
    "constraints", createConstraints("gridbag", [2, 1, 1, 1], [0.1 1], "both"), ...
    "callback", "db_callback(handles,d12)");
     handles.d12c = uicontrol("parent", handles.d12,'unit','normalized',"style", "radiobutton","horizontalalignment", "left","group", "d12",...
    "constraints", createConstraints("gridbag", [3, 1, 1, 1], [0.1 1], "both"), ...
    "callback", "dc_callback(handles,d12)");
     handles.d12d = uicontrol("parent", handles.d12,'unit','normalized',"style", "radiobutton","horizontalalignment", "left","group", "d12","enable","off",...
    "constraints", createConstraints("gridbag", [4, 1, 1, 1], [0.1 1], "both"), ...
    "callback", "dd_callback(handles,d12)");
    handles.d12a.value = 1;    
     handles.d12edit = uicontrol("parent", handles.d12,'unit','normalized',"style", "edit","horizontalalignment", "center","VerticalAlignment","top","group", "d12","Enable", "off",...
    'String','0',...
    "constraints", createConstraints("gridbag", [5, 1, 1, 1], [1.5 1], "both"), ...
    "callback", "");          
     handles.d12btn = uicontrol("parent", handles.d12,'unit','normalized',"style", "pushbutton","horizontalalignment", "center","group", "d12",...
    'String','Run',...
    "constraints", createConstraints("gridbag", [6, 1, 1, 1], [0.5 1], "both"), ...
    "callback", "dbtn_callback(handles,d12)");  
  handles.d13 = uicontrol("parent", f, 'unit','normalized',"style", "frame","layout", "gridbag","constraints", createConstraints("gridbag", [6, 1, 1, 1], [1 1], "horizontal"),...
    'Position',[x_pos,y_pos + y_offset*(d13-2),width,height],...
    "border", createBorder("line", 'blue'));
    handles.d13a = uicontrol("parent", handles.d13,'unit','normalized',"style", "radiobutton","horizontalalignment", "left","group", "d13", ...
    "constraints", createConstraints("gridbag", [1, 1, 1, 1], [0.1 1], "both"), ...
    "callback", "da_callback(handles,d13)");
    handles.d13b = uicontrol("parent", handles.d13,'unit','normalized',"style", "radiobutton","horizontalalignment", "left","group", "d13", ...
    "constraints", createConstraints("gridbag", [2, 1, 1, 1], [0.1 1], "both"), ...
    "callback", "db_callback(handles,d13)");
     handles.d13c = uicontrol("parent", handles.d13,'unit','normalized',"style", "radiobutton","horizontalalignment", "left","group", "d13",...
    "constraints", createConstraints("gridbag", [3, 1, 1, 1], [0.1 1], "both"), ...
    "callback", "dc_callback(handles,d13)");
     handles.d13d = uicontrol("parent", handles.d13,'unit','normalized',"style", "radiobutton","horizontalalignment", "left","group", "d13","enable","off",...
    "constraints", createConstraints("gridbag", [4, 1, 1, 1], [0.1 1], "both"), ...
    "callback", "dd_callback(handles,d13)");
    handles.d13a.value = 1;    
     handles.d13edit = uicontrol("parent", handles.d13,'unit','normalized',"style", "edit","horizontalalignment", "center","VerticalAlignment","top","group", "d13","Enable", "off",...
    'String','0',...
    "constraints", createConstraints("gridbag", [5, 1, 1, 1], [1.5 1], "both"), ...
    "callback", "");          
     handles.d13btn = uicontrol("parent", handles.d13,'unit','normalized',"style", "pushbutton","horizontalalignment", "center","group", "d13",...
    'String','Run',...
    "constraints", createConstraints("gridbag", [6, 1, 1, 1], [0.5 1], "both"), ...
    "callback", "dbtn_callback(handles,d13)");  
  handles.d3 = uicontrol("parent", f, 'unit','normalized',"style", "frame","layout", "gridbag","constraints", createConstraints("gridbag", [6, 1, 1, 1], [1 1], "horizontal"),...
    'Position',[x_pos,y_pos + y_offset*(d3-2),width,height],...
    "border", createBorder("line", 'blue'));
    handles.d3a = uicontrol("parent", handles.d3,'unit','normalized',"style", "radiobutton","horizontalalignment", "left","group", "d3", ...
    "constraints", createConstraints("gridbag", [1, 1, 1, 1], [0.1 1], "both"), ...
    "callback", "da_callback(handles,d3)");
    handles.d3b = uicontrol("parent", handles.d3,'unit','normalized',"style", "radiobutton","horizontalalignment", "left","group", "d3", ...
    "constraints", createConstraints("gridbag", [2, 1, 1, 1], [0.1 1], "both"), ...
    "callback", "db_callback(handles,d3)");
     handles.d3c = uicontrol("parent", handles.d3,'unit','normalized',"style", "radiobutton","horizontalalignment", "left","group", "d3",...
    "constraints", createConstraints("gridbag", [3, 1, 1, 1], [0.1 1], "both"), ...
    "callback", "dc_callback(handles,d3)");
     handles.d3d = uicontrol("parent", handles.d3,'unit','normalized',"style", "radiobutton","horizontalalignment", "left","group", "d3","enable","on",...
    "constraints", createConstraints("gridbag", [4, 1, 1, 1], [0.1 1], "both"), ...
    "callback", "dd_callback(handles,d3)");
    handles.d3a.value = 1;    
     handles.d3edit = uicontrol("parent", handles.d3,'unit','normalized',"style", "edit","horizontalalignment", "center","VerticalAlignment","top","group", "d3","Enable", "off",...
    'String','0',...
    "constraints", createConstraints("gridbag", [5, 1, 1, 1], [1.5 1], "both"), ...
    "callback", "");          
     handles.d3btn = uicontrol("parent", handles.d3,'unit','normalized',"style", "pushbutton","horizontalalignment", "center","group", "d3",...
    'String','Run',...
    "constraints", createConstraints("gridbag", [6, 1, 1, 1], [0.5 1], "both"), ...
    "callback", "dbtn_callback(handles,d3)");  
  handles.d5 = uicontrol("parent", f, 'unit','normalized',"style", "frame","layout", "gridbag","constraints", createConstraints("gridbag", [6, 1, 1, 1], [1 1], "horizontal"),...
    'Position',[x_pos,y_pos + y_offset*(d5-2),width,height],...
    "border", createBorder("line", 'blue'));
    handles.d5a = uicontrol("parent", handles.d5,'unit','normalized',"style", "radiobutton","horizontalalignment", "left","group", "d5", ...
    "constraints", createConstraints("gridbag", [1, 1, 1, 1], [0.1 1], "both"), ...
    "callback", "da_callback(handles,d5)");
    handles.d5b = uicontrol("parent", handles.d5,'unit','normalized',"style", "radiobutton","horizontalalignment", "left","group", "d5", ...
    "constraints", createConstraints("gridbag", [2, 1, 1, 1], [0.1 1], "both"), ...
    "callback", "db_callback(handles,d5)");
     handles.d5c = uicontrol("parent", handles.d5,'unit','normalized',"style", "radiobutton","horizontalalignment", "left","group", "d5",...
    "constraints", createConstraints("gridbag", [3, 1, 1, 1], [0.1 1], "both"), ...
    "callback", "dc_callback(handles,d5)");
     handles.d5d = uicontrol("parent", handles.d5,'unit','normalized',"style", "radiobutton","horizontalalignment", "left","group", "d5","enable","on",...
    "constraints", createConstraints("gridbag", [4, 1, 1, 1], [0.1 1], "both"), ...
    "callback", "dd_callback(handles,d5)");
    handles.d5a.value = 1;    
     handles.d5edit = uicontrol("parent", handles.d5,'unit','normalized',"style", "edit","horizontalalignment", "center","VerticalAlignment","top","group", "d5","Enable", "off",...
    'String','0',...
    "constraints", createConstraints("gridbag", [5, 1, 1, 1], [1.5 1], "both"), ...
    "callback", "");          
     handles.d5btn = uicontrol("parent", handles.d5,'unit','normalized',"style", "pushbutton","horizontalalignment", "center","group", "d5",...
    'String','Run',...
    "constraints", createConstraints("gridbag", [6, 1, 1, 1], [0.5 1], "both"), ...
    "callback", "dbtn_callback(handles,d5)");  
  handles.d6 = uicontrol("parent", f, 'unit','normalized',"style", "frame","layout", "gridbag","constraints", createConstraints("gridbag", [6, 1, 1, 1], [1 1], "horizontal"),...
    'Position',[x_pos,y_pos + y_offset*(d6-2),width,height],...
    "border", createBorder("line", 'blue'));
    handles.d6a = uicontrol("parent", handles.d6,'unit','normalized',"style", "radiobutton","horizontalalignment", "left","group", "d6", ...
    "constraints", createConstraints("gridbag", [1, 1, 1, 1], [0.1 1], "both"), ...
    "callback", "da_callback(handles,d6)");
    handles.d6b = uicontrol("parent", handles.d6,'unit','normalized',"style", "radiobutton","horizontalalignment", "left","group", "d6", ...
    "constraints", createConstraints("gridbag", [2, 1, 1, 1], [0.1 1], "both"), ...
    "callback", "db_callback(handles,d6)");
     handles.d6c = uicontrol("parent", handles.d6,'unit','normalized',"style", "radiobutton","horizontalalignment", "left","group", "d6",...
    "constraints", createConstraints("gridbag", [3, 1, 1, 1], [0.1 1], "both"), ...
    "callback", "dc_callback(handles,d6)");
     handles.d6d = uicontrol("parent", handles.d6,'unit','normalized',"style", "radiobutton","horizontalalignment", "left","group", "d6","enable","on",...
    "constraints", createConstraints("gridbag", [4, 1, 1, 1], [0.1 1], "both"), ...
    "callback", "dd_callback(handles,d6)");
    handles.d6a.value = 1;    
     handles.d6edit = uicontrol("parent", handles.d6,'unit','normalized',"style", "edit","horizontalalignment", "center","VerticalAlignment","top","group", "d6","Enable", "off",...
    'String','0',...
    "constraints", createConstraints("gridbag", [5, 1, 1, 1], [1.5 1], "both"), ...
    "callback", "");          
     handles.d6btn = uicontrol("parent", handles.d6,'unit','normalized',"style", "pushbutton","horizontalalignment", "center","group", "d6",...
    'String','Run',...
    "constraints", createConstraints("gridbag", [6, 1, 1, 1], [0.5 1], "both"), ...
    "callback", "dbtn_callback(handles,d6)");  
  handles.d9 = uicontrol("parent", f, 'unit','normalized',"style", "frame","layout", "gridbag","constraints", createConstraints("gridbag", [6, 1, 1, 1], [1 1], "horizontal"),...
    'Position',[x_pos,y_pos + y_offset*(d9-2),width,height],...
    "border", createBorder("line", 'blue'));
    handles.d9a = uicontrol("parent", handles.d9,'unit','normalized',"style", "radiobutton","horizontalalignment", "left","group", "d9", ...
    "constraints", createConstraints("gridbag", [1, 1, 1, 1], [0.1 1], "both"), ...
    "callback", "da_callback(handles,d9)");
    handles.d9b = uicontrol("parent", handles.d9,'unit','normalized',"style", "radiobutton","horizontalalignment", "left","group", "d9", ...
    "constraints", createConstraints("gridbag", [2, 1, 1, 1], [0.1 1], "both"), ...
    "callback", "db_callback(handles,d9)");
     handles.d9c = uicontrol("parent", handles.d9,'unit','normalized',"style", "radiobutton","horizontalalignment", "left","group", "d9",...
    "constraints", createConstraints("gridbag", [3, 1, 1, 1], [0.1 1], "both"), ...
    "callback", "dc_callback(handles,d9)");
     handles.d9d = uicontrol("parent", handles.d9,'unit','normalized',"style", "radiobutton","horizontalalignment", "left","group", "d9","enable","on",...
    "constraints", createConstraints("gridbag", [4, 1, 1, 1], [0.1 1], "both"), ...
    "callback", "dd_callback(handles,d9)");
    handles.d9a.value = 1;    
     handles.d9edit = uicontrol("parent", handles.d9,'unit','normalized',"style", "edit","horizontalalignment", "center","VerticalAlignment","top","group", "d9","Enable", "off",...
    'String','0',...
    "constraints", createConstraints("gridbag", [5, 1, 1, 1], [1.5 1], "both"), ...
    "callback", "");          
     handles.d9btn = uicontrol("parent", handles.d9,'unit','normalized',"style", "pushbutton","horizontalalignment", "center","group", "d9",...
    'String','Run',...
    "constraints", createConstraints("gridbag", [6, 1, 1, 1], [0.5 1], "both"), ...
    "callback", "dbtn_callback(handles,d9)");  
  handles.d10 = uicontrol("parent", f, 'unit','normalized',"style", "frame","layout", "gridbag","constraints", createConstraints("gridbag", [6, 1, 1, 1], [1 1], "horizontal"),...
    'Position',[x_pos,y_pos + y_offset*(d10-2),width,height],...
    "border", createBorder("line", 'blue'));
    handles.d10a = uicontrol("parent", handles.d10,'unit','normalized',"style", "radiobutton","horizontalalignment", "left","group", "d10", ...
    "constraints", createConstraints("gridbag", [1, 1, 1, 1], [0.1 1], "both"), ...
    "callback", "da_callback(handles,d10)");
    handles.d10b = uicontrol("parent", handles.d10,'unit','normalized',"style", "radiobutton","horizontalalignment", "left","group", "d10", ...
    "constraints", createConstraints("gridbag", [2, 1, 1, 1], [0.1 1], "both"), ...
    "callback", "db_callback(handles,d10)");
     handles.d10c = uicontrol("parent", handles.d10,'unit','normalized',"style", "radiobutton","horizontalalignment", "left","group", "d10",...
    "constraints", createConstraints("gridbag", [3, 1, 1, 1], [0.1 1], "both"), ...
    "callback", "dc_callback(handles,d10)");
     handles.d10d = uicontrol("parent", handles.d10,'unit','normalized',"style", "radiobutton","horizontalalignment", "left","group", "d10","enable","on",...
    "constraints", createConstraints("gridbag", [4, 1, 1, 1], [0.1 1], "both"), ...
    "callback", "dd_callback(handles,d10)");
    handles.d10a.value = 1;    
     handles.d10edit = uicontrol("parent", handles.d10,'unit','normalized',"style", "edit","horizontalalignment", "center","VerticalAlignment","top","group", "d10","Enable", "off",...
    'String','0',...
    "constraints", createConstraints("gridbag", [5, 1, 1, 1], [1.5 1], "both"), ...
    "callback", "");          
     handles.d10btn = uicontrol("parent", handles.d10,'unit','normalized',"style", "pushbutton","horizontalalignment", "center","group", "d10",...
    'String','Run',...
    "constraints", createConstraints("gridbag", [6, 1, 1, 1], [0.5 1], "both"), ...
    "callback", "dbtn_callback(handles,d10)");  
  handles.d11 = uicontrol("parent", f, 'unit','normalized',"style", "frame","layout", "gridbag","constraints", createConstraints("gridbag", [6, 1, 1, 1], [1 1], "horizontal"),...
    'Position',[x_pos,y_pos + y_offset*(d11-2),width,height],...
    "border", createBorder("line", 'blue'));
    handles.d11a = uicontrol("parent", handles.d11,'unit','normalized',"style", "radiobutton","horizontalalignment", "left","group", "d11", ...
    "constraints", createConstraints("gridbag", [1, 1, 1, 1], [0.1 1], "both"), ...
    "callback", "da_callback(handles,d11)");
    handles.d11b = uicontrol("parent", handles.d11,'unit','normalized',"style", "radiobutton","horizontalalignment", "left","group", "d11", ...
    "constraints", createConstraints("gridbag", [2, 1, 1, 1], [0.1 1], "both"), ...
    "callback", "db_callback(handles,d11)");
     handles.d11c = uicontrol("parent", handles.d11,'unit','normalized',"style", "radiobutton","horizontalalignment", "left","group", "d11",...
    "constraints", createConstraints("gridbag", [3, 1, 1, 1], [0.1 1], "both"), ...
    "callback", "dc_callback(handles,d11)");
     handles.d11d = uicontrol("parent", handles.d11,'unit','normalized',"style", "radiobutton","horizontalalignment", "left","group", "d11","enable","on",...
    "constraints", createConstraints("gridbag", [4, 1, 1, 1], [0.1 1], "both"), ...
    "callback", "dd_callback(handles,d11)");
    handles.d11a.value = 1;    
     handles.d11edit = uicontrol("parent", handles.d11,'unit','normalized',"style", "edit","horizontalalignment", "center","VerticalAlignment","top","group", "d11","Enable", "off",...
    'String','0',...
    "constraints", createConstraints("gridbag", [5, 1, 1, 1], [1.5 1], "both"), ...
    "callback", "");          
     handles.d11btn = uicontrol("parent", handles.d11,'unit','normalized',"style", "pushbutton","horizontalalignment", "center","group", "d11",...
    'String','Run',...
    "constraints", createConstraints("gridbag", [6, 1, 1, 1], [0.5 1], "both"), ...
    "callback", "dbtn_callback(handles,d11)");  


  handles.dlabel = uicontrol("parent", f, 'unit','normalized',"style", "frame","layout", "gridbag","constraints", createConstraints("gridbag", [4, 1, 1, 1], [1 1], "horizontal"),...
    'Position',[x_pos,y_pos + y_offset*(dlabel-2),width-0.147,height],...
    "border", createBorder("line", 'blue'));
    handles.dlabela = uicontrol("parent", handles.dlabel,'unit','normalized',"style", "text","horizontalalignment", "center","group", "dlabel", ...
    "constraints", createConstraints("gridbag", [1, 1, 1, 1], [0.1 1], "both"), ...
    "string","Off",...
    "callback", "da_callback(handles,dlabel)");
    handles.dlabelb = uicontrol("parent", handles.dlabel,'unit','normalized',"style", "text","horizontalalignment", "center","group", "dlabel", ...
    "constraints", createConstraints("gridbag", [2, 1, 1, 1], [0.1 1], "both"), ...
    "string","Din",...
    "callback", "db_callback(handles,dlabel)");
     handles.dlabelc = uicontrol("parent", handles.dlabel,'unit','normalized',"style", "text","horizontalalignment", "center","group", "dlabel",...
    "constraints", createConstraints("gridbag", [3, 1, 1, 1], [0.1 1], "both"), ...
    "string","Dout",...
    "callback", "dc_callback(handles,dlabel)");
     handles.dlabeld = uicontrol("parent", handles.dlabel,'unit','normalized',"style", "text","horizontalalignment", "center","group", "dlabel","enable","on",...
    "constraints", createConstraints("gridbag", [4, 1, 1, 1], [0.1 1], "both"), ...
    "string","Aout",...
    "callback", "dd_callback(handles,dlabel)");


// Analog In
a0 = 0;
a1 = 1;
a2 = 2;
a3 = 3;
a4 = 4;
a5 = 5;

  handles.a0 = uicontrol("parent", f, 'unit','normalized',"style", "frame","layout", "gridbag","constraints", createConstraints("gridbag", [2, 1, 1, 1], [1 1], "horizontal"),...
    'Position',[x_pos-0.53,y_pos - y_offset*(a0-3),width-0.12,height],...
    "border", createBorder("line", 'blue'));
     handles.a0btn = uicontrol("parent", handles.a0,'unit','normalized',"style", "pushbutton","horizontalalignment", "center","group", "a0",...
    'String','Run',...
    "constraints", createConstraints("gridbag", [1, 1, 1, 1], [0.5 1], "both"), ...
    "callback", "abtn_callback(handles,a0)");  
     handles.a0edit = uicontrol("parent", handles.a0,'unit','normalized',"style", "edit","horizontalalignment", "center","VerticalAlignment","top","group", "a0","Enable", "off",...
    'String','0',...
    "constraints", createConstraints("gridbag", [2, 1, 1, 1], [1.5 1], "both"), ...
    "callback", "");          

  handles.a1 = uicontrol("parent", f, 'unit','normalized',"style", "frame","layout", "gridbag","constraints", createConstraints("gridbag", [2, 1, 1, 1], [1 1], "horizontal"),...
    'Position',[x_pos-0.53,y_pos - y_offset*(a1-3),width-0.12,height],...
    "border", createBorder("line", 'blue'));
     handles.a1btn = uicontrol("parent", handles.a1,'unit','normalized',"style", "pushbutton","horizontalalignment", "center","group", "a1",...
    'String','Run',...
    "constraints", createConstraints("gridbag", [1, 1, 1, 1], [0.5 1], "both"), ...
    "callback", "abtn_callback(handles,a1)");  
     handles.a1edit = uicontrol("parent", handles.a1,'unit','normalized',"style", "edit","horizontalalignment", "center","VerticalAlignment","top","group", "a1","Enable", "off",...
    'String','0',...
    "constraints", createConstraints("gridbag", [2, 1, 1, 1], [1.5 1], "both"), ...
    "callback", "");          

  handles.a2 = uicontrol("parent", f, 'unit','normalized',"style", "frame","layout", "gridbag","constraints", createConstraints("gridbag", [2, 1, 1, 1], [1 1], "horizontal"),...
    'Position',[x_pos-0.53,y_pos - y_offset*(a2-3),width-0.12,height],...
    "border", createBorder("line", 'blue'));
     handles.a2btn = uicontrol("parent", handles.a2,'unit','normalized',"style", "pushbutton","horizontalalignment", "center","group", "a2",...
    'String','Run',...
    "constraints", createConstraints("gridbag", [1, 1, 1, 1], [0.5 1], "both"), ...
    "callback", "abtn_callback(handles,a2)");  
     handles.a2edit = uicontrol("parent", handles.a2,'unit','normalized',"style", "edit","horizontalalignment", "center","VerticalAlignment","top","group", "a2","Enable", "off",...
    'String','0',...
    "constraints", createConstraints("gridbag", [2, 1, 1, 1], [1.5 1], "both"), ...
    "callback", "");          

  handles.a3 = uicontrol("parent", f, 'unit','normalized',"style", "frame","layout", "gridbag","constraints", createConstraints("gridbag", [2, 1, 1, 1], [1 1], "horizontal"),...
    'Position',[x_pos-0.53,y_pos - y_offset*(a3-3),width-0.12,height],...
    "border", createBorder("line", 'blue'));
     handles.a3btn = uicontrol("parent", handles.a3,'unit','normalized',"style", "pushbutton","horizontalalignment", "center","group", "a3",...
    'String','Run',...
    "constraints", createConstraints("gridbag", [1, 1, 1, 1], [0.5 1], "both"), ...
    "callback", "abtn_callback(handles,a3)");  
     handles.a3edit = uicontrol("parent", handles.a3,'unit','normalized',"style", "edit","horizontalalignment", "center","VerticalAlignment","top","group", "a3","Enable", "off",...
    'String','0',...
    "constraints", createConstraints("gridbag", [2, 1, 1, 1], [1.5 1], "both"), ...
    "callback", "");   
          
  handles.a4 = uicontrol("parent", f, 'unit','normalized',"style", "frame","layout", "gridbag","constraints", createConstraints("gridbag", [2, 1, 1, 1], [1 1], "horizontal"),...
    'Position',[x_pos-0.53,y_pos - y_offset*(a4-3),width-0.12,height],...
    "border", createBorder("line", 'blue'));
     handles.a4btn = uicontrol("parent", handles.a4,'unit','normalized',"style", "pushbutton","horizontalalignment", "center","group", "a4",...
    'String','Run',...
    "constraints", createConstraints("gridbag", [1, 1, 1, 1], [0.5 1], "both"), ...
    "callback", "abtn_callback(handles,a4)");  
     handles.a4edit = uicontrol("parent", handles.a4,'unit','normalized',"style", "edit","horizontalalignment", "center","VerticalAlignment","top","group", "a4","Enable", "off",...
    'String','0',...
    "constraints", createConstraints("gridbag", [2, 1, 1, 1], [1.5 1], "both"), ...
    "callback", "");          

  handles.a5 = uicontrol("parent", f, 'unit','normalized',"style", "frame","layout", "gridbag","constraints", createConstraints("gridbag", [2, 1, 1, 1], [1 1], "horizontal"),...
    'Position',[x_pos-0.53,y_pos - y_offset*(a5-3),width-0.12,height],...
    "border", createBorder("line", 'blue'));
     handles.a5btn = uicontrol("parent", handles.a5,'unit','normalized',"style", "pushbutton","horizontalalignment", "center","group", "a5",...
    'String','Run',...
    "constraints", createConstraints("gridbag", [1, 1, 1, 1], [0.5 1], "both"), ...
    "callback", "abtn_callback(handles,a5)");  
     handles.a5edit = uicontrol("parent", handles.a5,'unit','normalized',"style", "edit","horizontalalignment", "center","VerticalAlignment","top","group", "a5","Enable", "off",...
    'String','0',...
    "constraints", createConstraints("gridbag", [2, 1, 1, 1], [1.5 1], "both"), ...
    "callback", "");          
     
                
            
// End of Analog In

// Control Panel
 handles.comport = uicontrol("parent", f,'unit','normalized',"style", "popupmenu","horizontalalignment", "center",...
    'Position',[x_pos+0.08,y_pos + y_offset*(d13-2+14),width/2,height*2],...
    'String',['com1','com2','com3','com4','com5','com6','com7','com8','com9'],...
    'value',1,...
    "callback", "");    
 handles.connect = uicontrol("parent", f,'unit','normalized',"style", "pushbutton","horizontalalignment", "center",...
    'Position',[x_pos+0.08,y_pos + y_offset*(d13-2+12),width/2,height*2],...
    'String','Connect',...
    "callback", "connect_callback(handles)");    

 handles.disconnect = uicontrol("parent", f,'unit','normalized',"style", "pushbutton","horizontalalignment", "center",...
    'Position',[x_pos+0.08,y_pos + y_offset*(d13-2+10),width/2,height*2],...
    'String','Disconnect','enable','off',...
    "callback", "disconnect_callback(handles)");   
// End of Control Panel
    
    
disable_all(handles)
//////////
// Callbacks are defined as below. Please do not delete the comments as it will be used in coming version
//////////

function da_callback(handles,val)
    
    if val>=2 & val <= 7 then
        cmd_str = "set(handles.d" + string(val) + "edit,''Enable'',''off'')";
        eval(cmd_str);
    else
        cmd_str = "set(handles.d" + string(val-1) + "edit,''Enable'',''off'')";
        eval(cmd_str);
    end
    
endfunction

function db_callback(handles,val)
    
    
    if val>=2 & val <= 7 then
        cmd_str = "set(handles.d" + string(val) + "edit,''Enable'',''off'')";
        eval(cmd_str);
    else
        cmd_str = "set(handles.d" + string(val-1) + "edit,''Enable'',''off'')";
        eval(cmd_str);
    end
    

endfunction

function dc_callback(handles,val)
    
    if val>=2 & val <= 7 then
        cmd_str = "set(handles.d" + string(val) + "edit,''Enable'',''on'')";
        eval(cmd_str);
    else
        cmd_str = "set(handles.d" + string(val-1) + "edit,''Enable'',''on'')";
        eval(cmd_str);
    end
    
endfunction

function dd_callback(handles,val)
    
    if val>=2 & val <= 7 then
        cmd_str = "set(handles.d" + string(val) + "edit,''Enable'',''on'')";
        eval(cmd_str);
    else
        cmd_str = "set(handles.d" + string(val-1) + "edit,''Enable'',''on'')";
        eval(cmd_str);
    end
    
endfunction




function enable_all(handles)
    
    for cnt = 2:13
        cmd_str = "set(handles.d" + string(cnt) + ",''Enable'',''on'')";
        eval(cmd_str);
    end
    
    for cnt = 0:5
        cmd_str = "set(handles.a" + string(cnt) + ",''Enable'',''on'')";
        eval(cmd_str);
    end
endfunction

function connect_callback(handles)
    
    ok = open_serial(1,handles.comport.value,115200);
    if ok == 0 then
        handles.connect.enable = 'off';
        handles.disconnect.enable = 'on';        
        enable_all(handles);
    else
        messagebox('aa','aa');
    end
    
endfunction

function disconnect_callback(handles)
    close_serial(1);
       handles.connect.enable = 'on';
        handles.disconnect.enable = 'off';           
    disable_all(handles);
endfunction

function dbtn_callback(handles,val)
//Write your callback for  rd_d2b  here
if val>=8 then
    val = val - 1;
end

cmd_str = "get(handles.d" + string(val) +".children,""value"");"
sel = find(evstr(cmd_str));

if sel == 1 then
    cmd_str = "get(handles.d" + string(val) +"edit,""string"");"
    out = strtod(evstr(cmd_str));
    cmd_analog_out(1,val,out);
elseif sel == 2
    cmd_str = "get(handles.d" + string(val) +"edit,""string"");"
    out = strtod(evstr(cmd_str));
    cmd_digital_out(1,val,out);
elseif sel == 3
    in = cmd_digital_in(1,val);
    cmd_str = "set(handles.d" + string(val) +"edit,""string"",""" + string(in) + """);"
    eval(cmd_str);
    
end

endfunction

function abtn_callback(handles,val)
    in = cmd_analog_in(1,val);
    cmd_str = "set(handles.a" + string(val) +"edit,""string"",""" + string(in) + """);"
    eval(cmd_str);

endfunction


f.visible = "on";