mercredi 6 novembre 2013

' Simulation _ Recherche _ de _ personnes _Panoramic.bas
' 20131101

error_french
label clavier
label sp_rouge,sp_vert,sp_jaune,sp_bleu,envoyer,sp_fin
dim i,nobj,r%,v%,j%,b%,dat$,com_ok,data$,res
dim num,aff$,tch%,lt_cav ,c21%
com_ok=0
nobj=10:giro(nobj,0,80,300,"colonne")
num =100 :lt_cav=80
clavier_hexa(num,120,lt_cav)
affichtxt(200,0,10,50,14,"Simulation Recherche de personnes en Panoramic")
affichtxt(220,0,220,410,14,date$)
nobj=550:voyant(nobj,0,100,440,"Com.Série",0)

nobj=750:button_con(nobj,0,350,460,"F I N")
com_serie()
on_click 751,sp_fin
on_close 0,sp_fin
' ======================
end
' ======================
sp_rouge:
select r%
case 1 :color 12,255,0,0
case 0 :color 12,200,125,125
end_select
return
' =======
sp_vert:
select v%
case 1 :color 14,0,255,0
case 0 :color 14,125,200,125
end_select
return
' =======
sp_jaune:
select j%
case 1 :color 16,255,255,0
case 0 :color 16,200,200,125
end_select
return
' =======
sp_bleu:
select b%
case 1 :color 18,0,255,255
case 0 :color 18,125,200,200
end_select
return
' =======
envoyer:
if com_ok =0 then return
if tch% >=0 and tch% <16
data$=str$(tch%)
if data$="" then return
for i= 1 to len(data$)
c21%=asc(mid$(data$,i,1))
res=dll_call1("ComSetDataOut",c21%)
next i
pause 2
end_if

return
' =====FIN========
sp_fin:
dll_off:pause 4
terminate
return
' =================
clavier:
tch%=0
for i=1 to 16
if clicked(i+num)=1 then tch%=i-1:gosub envoyer
next i
if tch% >7
r%=1 :tch%=tch%-8
else
r%=0
end_if
gosub sp_rouge
if tch% >3
v%=1 :tch%=tch%-4
else
v%=0
end_if
gosub sp_vert
if tch% >1
j%=1 :tch%=tch%-2
else
j%=0
end_if
gosub sp_jaune
if tch% =1
b%=1
else
b%=0
end_if
gosub sp_bleu

return
' ======================
rem =========sub===================
sub clavier_hexa(num,tp,lt)
dim_local i,j,ii
container num+20:top num+20,tp:left num+20,lt
caption num+20,"clavier_numérique"
height num+20,200: color num+20,200,200,50
for i=1 to 16
ii=ii+1:if ii=5 then j=j+1:ii=1
button i+num:width i+num,21:parent i+num,num+20
top i+num,(j*30)+30: left i+num,(ii*30)+5
caption i+num,hex$(i-1)
on_click i+num,clavier
next i
end_sub
rem =================================
sub giro(nos,par,t_c,l_c,txt$)
container nos:parent nos,par:top nos,t_c:left nos,l_c
width nos,80: height nos,250
if len(txt$) > 9 then txt$=left$(txt$,9)
caption nos,txt$
dim_local top_loc,left_loc: top_loc=28: left_loc =30
alpha nos+1:parent nos+1,nos:top nos+1,top_loc:left nos+1,left_loc
width nos+1,24: height nos+1,12:color nos+1,0,0,0 :top_loc=top_loc+12
alpha nos+2:parent nos+2,nos:top nos+2,top_loc:left nos+2,left_loc
width nos+2,24: height nos+2,24:color nos+2,200,125,125:top_loc=top_loc+24
alpha nos+3:parent nos+3,nos:top nos+3,top_loc:left nos+3,left_loc
width nos+3,24: height nos+3,5:color nos+3,0,0,0:top_loc=top_loc+5
alpha nos+4:parent nos+4,nos:top nos+4,top_loc:left nos+4,left_loc
width nos+4,24: height nos+4,24:color nos+4,125,200,125:top_loc=top_loc+24
alpha nos+5:parent nos+5,nos:top nos+5,top_loc:left nos+5,left_loc
width nos+5,24: height nos+5,5:color nos+5,0,0,0:top_loc=top_loc+5
alpha nos+6:parent nos+6,nos:top nos+6,top_loc:left nos+6,left_loc
width nos+6,24: height nos+6,24:color nos+6,200,200,125:top_loc=top_loc+24
alpha nos+7:parent nos+7,nos:top nos+7,top_loc:left nos+7,left_loc
width nos+7,24: height nos+7,5:color nos+7,0,0,0:top_loc=top_loc+5
alpha nos+8:parent nos+8,nos:top nos+8,top_loc:left nos+8,left_loc
width nos+8,24: height nos+8,24:color nos+8,125,200,200:top_loc=top_loc+24
alpha nos+9:parent nos+9,nos:top nos+9,top_loc:left nos+9,left_loc
width nos+9,24: height nos+9,30:color nos+9,0,0,0:top_loc=top_loc+30
alpha nos+10:parent nos+10,nos:top nos+10,top_loc:left nos+10,left_loc+6
width nos+10,12: height nos+10,50:color nos+10,0,0,0:top_loc=top_loc+50
alpha nos+11:parent nos+11,nos:top nos+11,top_loc:left nos+11,left_loc
width nos+11,24: height nos+11,12:color nos+11,0,0,0 :top_loc=top_loc+12
end_sub
rem ===================================
sub button_container(nos,par,t_c,l_c,txtt$)
container nos:parent nos,par:top nos,t_c:left nos, l_c
caption nos ,txtt$
button nos+1:parent nos+1,nos:top nos+1,30:left nos+1,10
width nos+1,30
width nos,width(nos+1)+20
height nos,height(nos+1)+40
end_sub

rem =================================
sub com_serie()
dim_local rc,rrc
rem DLL chargée en mémoire
' suivant configuration
dll_on "F:\Mes_Document_F\Basic_panoramic\Arduino_Panoramic\IO_Acces_COM.dll"
rc= dll_call1("ComUsePort",8)
rrc= dll_call4("ComConfig",115200,8,1,0)
if rc=1 and rrc=1
com_ok =1:position 552,1
else
message "Defaut_com_Serie"
end_if
end_sub
rem =================================
sub affichtxt(nxt,par,tpt,ltt,fsize,txt$)
container nxt:parent nxt,par :top nxt,tpt:left nxt,ltt
Alpha nxt+1:parent nxt+1,nxt:top nxt+1,20:left nxt+1,10
font_bold nxt+1:font_size nxt+1,fsize:caption nxt+1,txt$
width nxt,width(nxt+1)+40
height nxt,height(nxt+1)+40
end_sub
rem =========================
sub voyant(ntp,par,ttp,ltp,txt$,etat)
dim_local top_loc,left_loc: top_loc=28: left_loc =7
container ntp:parent ntp,par:top ntp,ttp:left ntp,ltp
width ntp,80: height ntp,85
if len(txt$) > 9 then txt$=left$(txt$,9)
caption ntp,txt$
alpha ntp+1:parent ntp+1,ntp:top ntp+1,top_loc:left ntp+1,left_loc
width ntp+1,64: height ntp+1,44:color ntp+1,0,0,0
progress_bar ntp+2:parent ntp+2,ntp:top ntp+2,top_loc+4:left ntp+2,left_loc+4
width ntp+2,56: height ntp+2,36:min ntp+2,0:max ntp+2,1
if etat=0
position ntp+2,0
else
position ntp+2,1
end_if
end_sub
rem =========================
sub button_con(nbc,parc,tpc,ltc,txt$)
container nbc:parent nbc,parc:top nbc,tpc:left nbc,ltc
caption nbc ,txt$
button nbc+1:parent nbc+1,nbc:top nbc+1,30:left nbc+1,10
width nbc+1,30
width nbc,width(nbc+1)+20
height nbc,height(nbc+1)+40
end_sub
rem =========================




Code Arduino uno:


int tch = 0;
int buf;
int ascii;
int valeur;
int valeurm;
String chiffre;
// =================
void setup() {
 //code
pinMode(2,OUTPUT);
pinMode(3,OUTPUT);
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
Serial.begin(115200);
}
// ================
void loop() {
buf = Serial.available();
delay(10);
if (buf>0){
  module_reception();
  delay(10);
  tch=valeur;
 if ( valeur|= valeurm){
    valeurm=valeur;
   sp_led();
 } //fin if valeur
 }// fin if buf
}// fin loop
// ================
void sp_led(){
if (tch >7){digitalWrite(5, HIGH);
 tch=tch-8;}
 else {digitalWrite(5, LOW);}

 if (tch >3){digitalWrite(4, HIGH);
 tch=tch-4;}
 else {digitalWrite(4, LOW);}

 if (tch >1){digitalWrite(3, HIGH);
 tch=tch-2;}
 else {digitalWrite(3, LOW);}

 if (tch==1){digitalWrite(2, HIGH);}
 else{digitalWrite(2, LOW);}
 }//fin sp_led
// ===========================
void module_reception(){
while(Serial.available()){
ascii=Serial.read();
if (ascii != -1 ){
if (ascii >47 && ascii< 58){ 
chiffre =chiffre+char(ascii);}
} //fin if -1
} //fin while
valeur=chiffre.toInt();
chiffre="";
buf=0;
}//fin module_reception












Aucun commentaire:

Enregistrer un commentaire