FORUM DE DISCUSSION SUR LE LANGAGE PANORAMIC
Vous souhaitez réagir à ce message ? Créez un compte en quelques clics ou connectez-vous pour continuer.
FORUM DE DISCUSSION SUR LE LANGAGE PANORAMIC

Développement d'applications avec le langage Panoramic
 
AccueilAccueil  RechercherRechercher  Dernières imagesDernières images  S'enregistrerS'enregistrer  MembresMembres  Connexion  
Derniers sujets
» Form(résolu)
SUB LED: permet d'afficher un voyant de type LED Emptypar leclode Aujourd'hui à 17:59

» trop de fichiers en cours
SUB LED: permet d'afficher un voyant de type LED Emptypar Marc Aujourd'hui à 11:42

» Bataille navale SM
SUB LED: permet d'afficher un voyant de type LED Emptypar jjn4 Hier à 17:39

» Une calculatrice en une ligne de programme
SUB LED: permet d'afficher un voyant de type LED Emptypar jean_debord Hier à 8:01

» Gestion d'un système client-serveur.
SUB LED: permet d'afficher un voyant de type LED Emptypar Pedro Jeu 25 Avr 2024 - 19:31

» Les maths du crocodile
SUB LED: permet d'afficher un voyant de type LED Emptypar jean_debord Jeu 25 Avr 2024 - 10:37

» Naissance de Crocodile Basic
SUB LED: permet d'afficher un voyant de type LED Emptypar jean_debord Jeu 25 Avr 2024 - 8:45

» Editeur EliP 6 : Le Tiny éditeur avec 25 onglets de travail
SUB LED: permet d'afficher un voyant de type LED Emptypar Froggy One Mer 24 Avr 2024 - 18:38

» Dessine-moi une galaxie
SUB LED: permet d'afficher un voyant de type LED Emptypar jjn4 Lun 22 Avr 2024 - 13:47

» Erreur END_SUB
SUB LED: permet d'afficher un voyant de type LED Emptypar jjn4 Lun 22 Avr 2024 - 13:43

» Bug sur DIM_LOCAL ?
SUB LED: permet d'afficher un voyant de type LED Emptypar papydall Dim 21 Avr 2024 - 23:30

» 2D_fill_color(résolu)
SUB LED: permet d'afficher un voyant de type LED Emptypar leclode Sam 20 Avr 2024 - 8:32

» Consommation gaz électricité
SUB LED: permet d'afficher un voyant de type LED Emptypar leclode Mer 17 Avr 2024 - 11:07

» on_key_down (résolu)
SUB LED: permet d'afficher un voyant de type LED Emptypar leclode Mar 16 Avr 2024 - 11:01

» Sous-programme(résolu)
SUB LED: permet d'afficher un voyant de type LED Emptypar jjn4 Jeu 4 Avr 2024 - 14:42

Navigation
 Portail
 Index
 Membres
 Profil
 FAQ
 Rechercher
Rechercher
 
 

Résultats par :
 
Rechercher Recherche avancée
Avril 2024
LunMarMerJeuVenSamDim
1234567
891011121314
15161718192021
22232425262728
2930     
CalendrierCalendrier
Le Deal du moment : -39%
Pack Home Cinéma Magnat Monitor : Ampli DENON ...
Voir le deal
1190 €

 

 SUB LED: permet d'afficher un voyant de type LED

Aller en bas 
+3
Minibug
Yannick
Jicehel
7 participants
Aller à la page : 1, 2  Suivant
AuteurMessage
Jicehel

Jicehel


Nombre de messages : 5947
Age : 51
Localisation : 77500
Date d'inscription : 18/04/2011

SUB LED: permet d'afficher un voyant de type LED Empty
MessageSujet: SUB LED: permet d'afficher un voyant de type LED   SUB LED: permet d'afficher un voyant de type LED EmptyLun 11 Mai 2015 - 13:51

La SUB LED ci dessous vous permet d'afficher un voyant de type LED avec une couleur au choix.
On passe en argument la valeur x% et y% du coin supérieur gauche, le rayon de la led (10 minimum, 20 ou 30 s'est bien, vous pouvez mettre jusqu"à 300 mais honnètement, mettre un voyant sur tout l'écran, je ne vois pas l'intérêt Wink )
Après j'ai mis 5 couleurs possibles pour la led et la possibilité de l'afficher éteinte.
Vous pouvez facilement adapter si vous voulez une led d'une autre couleur. Les valeurs r, v,b doivent être comprises entre 30 et 225.

Code:
DIM i%
CAPTION 0,"Programme en cours - LED"
FOR i% = 1 TO 10
  Creer_LED(100,100,20,0)
  PAUSE 1000
  Creer_LED(100,100,20,ABS(5-i%))
  PAUSE 1000
NEXT i%
PAUSE 1000
CAPTION 0,"Programme terminé, la fenêtre va se fermer"
PAUSE 2000
TERMINATE

' Procédure Creer_LED : Créer une LED dans l'objet courant pour le dessin 2D
' x: position en x de la LED
' y: position en x de la LED
' r: rayon de la LED  (entre 10 et 300)
' couleur: couleur de la LED : 0 = éteinte ; 1 = rouge ; 2 = orange ; 3 = jaune
'                              4 = verte  ; 5 = bleue
SUB Creer_LED(x%,y%,r,couleur%)
DIM_LOCAL r%,v%,b%
  IF couleur% < 0 THEN couleur% = 0
  IF couleur% > 5 THEN couleur% = 5
  IF r < 10 THEN r = 10
  IF r > 300 THEN r = 300
  SELECT couleur%
    CASE 0: r%=128 : v%=128 : b%=128
    CASE 1: r%=220 : v%= 80 : b%= 80
    CASE 2: r%=220 : v%=120 : b%= 30
    CASE 3: r%=220 : v%=220 : b%= 30
    CASE 4: r%= 30 : v%=220 : b%= 30
    CASE 5: r%= 30 : v%= 30 : b%= 220
  END_SELECT
  2D_PEN_COLOR 0,0,0 : 2D_FILL_COLOR r%-30,v%-30,b%-30
  2D_CIRCLE x%+r,y%+r,r
  2D_PEN_COLOR r%,v%,b% : 2D_FILL_COLOR r%,v%,b%
  2D_CIRCLE x%+r,y%+r,(0.8 * r)
  2D_PEN_COLOR r%+30,v%+30,b%+30 : 2D_FILL_COLOR r%+30,v%+30,b%+30
  2D_CIRCLE x%+0.66*r,y%+0.66*r,r/3
  2D_PEN_COLOR 255,255,255 : 2D_FILL_COLOR 255,255,255
  2D_CIRCLE x%+0.66*r,y%+0.66*r,r/8
END_SUB
Revenir en haut Aller en bas
Yannick




Nombre de messages : 8610
Age : 52
Localisation : Bretagne
Date d'inscription : 15/02/2010

SUB LED: permet d'afficher un voyant de type LED Empty
MessageSujet: re   SUB LED: permet d'afficher un voyant de type LED EmptyLun 11 Mai 2015 - 14:11

C' est joli, joli...
Cela peut servir, je mets cela de coté.
Revenir en haut Aller en bas
Minibug

Minibug


Nombre de messages : 4566
Age : 57
Localisation : Vienne (86)
Date d'inscription : 09/02/2012

SUB LED: permet d'afficher un voyant de type LED Empty
MessageSujet: Re: SUB LED: permet d'afficher un voyant de type LED   SUB LED: permet d'afficher un voyant de type LED EmptyLun 11 Mai 2015 - 14:36

Oui j'aime bien l'idée aussi.
Je met de coté...
Revenir en haut Aller en bas
http://gpp.panoramic.free.fr
Jicehel

Jicehel


Nombre de messages : 5947
Age : 51
Localisation : 77500
Date d'inscription : 18/04/2011

SUB LED: permet d'afficher un voyant de type LED Empty
MessageSujet: Re: SUB LED: permet d'afficher un voyant de type LED   SUB LED: permet d'afficher un voyant de type LED EmptyLun 11 Mai 2015 - 15:48

Merci pour vos retours ça fait plaisir Wink
Revenir en haut Aller en bas
papydall

papydall


Nombre de messages : 6996
Age : 73
Localisation : Moknine (Tunisie) Entre la chaise et le clavier
Date d'inscription : 03/03/2012

SUB LED: permet d'afficher un voyant de type LED Empty
MessageSujet: Re: SUB LED: permet d'afficher un voyant de type LED   SUB LED: permet d'afficher un voyant de type LED EmptyLun 11 Mai 2015 - 17:34

Hmmm !
Une LED qui n’est pas LAIDE du tout !
Comme certains l’on mise de côté, j’en fais de même : je la mets de côté (tantôt à gauche, tantôt à droite, la plus part du temps en face) Idea

Code:
DIM i%
CAPTION 0,"Programme en cours - LED"
FOR i% = 1 TO 50
  Creer_LED(100,100,20,0) : Creer_LED(200,100,20,0)
  Creer_LED(300,100,20,0) : Creer_LED(300,100,20,0)
 ' PAUSE 100
  Creer_LED(100,100,20,ABS(5-i%))  : Creer_LED(200,100,20,ABS(15-i%))
  Creer_LED(300,100,20,ABS(25-i%)) : Creer_LED(300,100,20,mod(i%,5))
  PAUSE 500
NEXT i%
PAUSE 1000
CAPTION 0,"Programme terminé, la fenêtre va se fermer"
PAUSE 2000
TERMINATE

' Procédure Creer_LED : Créer une LED dans l'objet courant pour le dessin 2D
' x: position en x de la LED
' y: position en x de la LED
' r: rayon de la LED  (entre 10 et 300)
' couleur: couleur de la LED : 0 = éteinte ; 1 = rouge ; 2 = orange ; 3 = jaune
'                              4 = verte  ; 5 = bleue
SUB Creer_LED(x%,y%,r,couleur%)
DIM_LOCAL r%,v%,b%
  IF couleur% < 0 THEN couleur% = 0
  IF couleur% > 5 THEN couleur% = 5
  IF r < 10 THEN r = 10
  IF r > 300 THEN r = 300
  SELECT couleur%
    CASE 0: r%=128 : v%=128 : b%=128
    CASE 1: r%=220 : v%= 80 : b%= 80
    CASE 2: r%=220 : v%=120 : b%= 30
    CASE 3: r%=220 : v%=220 : b%= 30
    CASE 4: r%= 30 : v%=220 : b%= 30
    CASE 5: r%= 30 : v%= 30 : b%= 220
  END_SELECT
  2D_PEN_COLOR 0,0,0 : 2D_FILL_COLOR r%-30,v%-30,b%-30
  2D_CIRCLE x%+r,y%+r,r
  2D_PEN_COLOR r%,v%,b% : 2D_FILL_COLOR r%,v%,b%
  2D_CIRCLE x%+r,y%+r,(0.8 * r)
  2D_PEN_COLOR r%+30,v%+30,b%+30 : 2D_FILL_COLOR r%+30,v%+30,b%+30
  2D_CIRCLE x%+0.66*r,y%+0.66*r,r/3
  2D_PEN_COLOR 255,255,255 : 2D_FILL_COLOR 255,255,255
  2D_CIRCLE x%+0.66*r,y%+0.66*r,r/8
END_SUB

Revenir en haut Aller en bas
http://papydall-panoramic.forumarabia.com/
Jicehel

Jicehel


Nombre de messages : 5947
Age : 51
Localisation : 77500
Date d'inscription : 18/04/2011

SUB LED: permet d'afficher un voyant de type LED Empty
MessageSujet: Re: SUB LED: permet d'afficher un voyant de type LED   SUB LED: permet d'afficher un voyant de type LED EmptyLun 11 Mai 2015 - 17:57

et oui, il y a moyen de s'amuser avec ces LEDs Wink

Par contre, tu dessines plusieurs fois la même led avec des valeurs différentes alors j'ai légèrement modifié ton prog principal pour afficher les 4 dernières led de ton prog (comme les 4 premières permettent just de les afficher éteintes tellement peut de temps que l'on ne peut pas le voir.

Code:
DIM i%
CAPTION 0,"Programme en cours - LED"
FOR i% = 1 TO 40
  Creer_LED(100,100,20,ABS(5-i%)) :  Creer_LED(200,100,20,ABS(15-i%))
  Creer_LED(300,100,20,mod(i%,5)) :  Creer_LED(400,100,20,ABS(25-i%))
  PAUSE 500
NEXT i%
PAUSE 1000
CAPTION 0,"Programme terminé, la fenêtre va se fermer"
PAUSE 2000
TERMINATE
Revenir en haut Aller en bas
papydall

papydall


Nombre de messages : 6996
Age : 73
Localisation : Moknine (Tunisie) Entre la chaise et le clavier
Date d'inscription : 03/03/2012

SUB LED: permet d'afficher un voyant de type LED Empty
MessageSujet: Re: SUB LED: permet d'afficher un voyant de type LED   SUB LED: permet d'afficher un voyant de type LED EmptyLun 11 Mai 2015 - 18:18

Je t’avais dis que ce sont des LEDs pas LAIDES : c’est à toi de les enlaidir ou …. les enjoliver.
Revenir en haut Aller en bas
http://papydall-panoramic.forumarabia.com/
Minibug

Minibug


Nombre de messages : 4566
Age : 57
Localisation : Vienne (86)
Date d'inscription : 09/02/2012

SUB LED: permet d'afficher un voyant de type LED Empty
MessageSujet: Re: SUB LED: permet d'afficher un voyant de type LED   SUB LED: permet d'afficher un voyant de type LED EmptyLun 11 Mai 2015 - 20:27

Voila un mode chenillard :

Code:
DIM i% , n%(6)
n%(1)=50 : n%(2)=100 : n%(3)=150 : n%(4)=200 : n%(5)=250 : n%(6)=300

WIDTH 0,400 : HEIGHT 0,130 : CAPTION 0,"LED CHENILLARD" : BORDER_SMALL 0

REPEAT
  FOR i% = 1 TO 6
    n%(i%)=n%(i%)+50
    IF n%(i%)>300 THEN n%(i%)=50
  NEXT i%
  Creer_LED(n%(1),30,20,220,220,220)
  Creer_LED(n%(2),30,20,220,80,80)
  Creer_LED(n%(3),30,20,220,120,30)
  Creer_LED(n%(4),30,20,220,220,30)
  Creer_LED(n%(5),30,20,30,220,30)
  Creer_LED(n%(6),30,20,30,30,220)
  PAUSE 500

UNTIL INKEY$<>""

TERMINATE

SUB Creer_LED(x%,y%,r,r%,v%,b%)
  2D_PEN_COLOR 0,0,0 : 2D_FILL_COLOR r%-30,v%-30,b%-30 : 2D_CIRCLE x%+r,y%+r,r
  2D_PEN_COLOR r%,v%,b% : 2D_FILL_COLOR r%,v%,b% : 2D_CIRCLE x%+r,y%+r,(0.8 * r)
  2D_PEN_COLOR r%+30,v%+30,b%+30 : 2D_FILL_COLOR r%+30,v%+30,b%+30 : 2D_CIRCLE x%+0.66*r,y%+0.66*r,r/3
  2D_PEN_COLOR 255,255,255 : 2D_FILL_COLOR 255,255,255 : 2D_CIRCLE x%+0.66*r,y%+0.66*r,r/8
END_SUB
Revenir en haut Aller en bas
http://gpp.panoramic.free.fr
Jicehel

Jicehel


Nombre de messages : 5947
Age : 51
Localisation : 77500
Date d'inscription : 18/04/2011

SUB LED: permet d'afficher un voyant de type LED Empty
MessageSujet: Re: SUB LED: permet d'afficher un voyant de type LED   SUB LED: permet d'afficher un voyant de type LED EmptyLun 11 Mai 2015 - 22:02

Très réussi Minibug. Perso, j'ai mis la fenêtre 0 en noire mais c'est secondaire. Le chenillard multicolore est très réussi Wink
Revenir en haut Aller en bas
Minibug

Minibug


Nombre de messages : 4566
Age : 57
Localisation : Vienne (86)
Date d'inscription : 09/02/2012

SUB LED: permet d'afficher un voyant de type LED Empty
MessageSujet: Re: SUB LED: permet d'afficher un voyant de type LED   SUB LED: permet d'afficher un voyant de type LED EmptyLun 11 Mai 2015 - 22:59

Tout le mérite te reviens Jicehel, Ce sont tes LEDs !! Wink
Revenir en haut Aller en bas
http://gpp.panoramic.free.fr
Jicehel

Jicehel


Nombre de messages : 5947
Age : 51
Localisation : 77500
Date d'inscription : 18/04/2011

SUB LED: permet d'afficher un voyant de type LED Empty
MessageSujet: Re: SUB LED: permet d'afficher un voyant de type LED   SUB LED: permet d'afficher un voyant de type LED EmptyLun 11 Mai 2015 - 23:22

Pas grave, c'est la fusion des idées et leur application qui rendent les choses sympa.

Par contre j'ai besoind des matheux pour autre chose ...

Je voudrais dessiner un potentiomètre, mais j'ai du mal dans les formules de math.
Pouvez-vous corriger la formule pour qu'il y ait une graduation pour chcune des valeurs tout autour du cercle, par ce que moi, j'ai du mal avc ça ... ?
Code:
DIM i%
DIM Pi : Pi = 4*ATN(1)
CAPTION 0,"Programme en cours - Potentiometre"
Creer_Potentiometre(10,100,100,30,10)
PAUSE 1000
CAPTION 0,"Programme terminé, vous pouvez modifier la valeur du potentiomètre ou fermer"
END

' Procédure Creer_LED : Créer une LED dans l'objet courant pour le dessin 2D
' x: position en x de la LED
' y: position en x de la LED
' l: largeur du potentiomètre  (entre 10 et 300)
' nbmax : maximum du potentiomètre

SUB Creer_Potentiometre(obj%,x%,y%,l%,nbmax%)
DIM_LOCAL indice%, Angle, A, Xa, Ya, Xb, Yb
  Angle =  0.75 * PI / nbmax%
  IF l% < 100 THEN l% = 100
  PICTURE obj% : WIDTH obj%,l% : HEIGHT obj%, l% : LEFT obj%,x% : TOP obj%,y%
  COLOR obj%, 128,128,128
  2D_PEN_COLOR 0,0,0 : 2D_FILL_COLOR 128,128,128
  2D_CIRCLE x%+l%/2,y%+l%/2,l%/2 - 20
  2D_FILL_COLOR 200,120,20
  2D_CIRCLE x%+l%/2-15,y%+l%/2+15,2
  Xa = x%+l%/2 : Ya = y%+l%/2 + 3 : Xb = x%+l%/2 : Yb = y%+l%/2 + 8 : A = 1.25 * PI
  2D_PEN_COLOR 0,0,0
  FOR indice% = 0 TO nbmax%
    2D_LINE (l%/2)*cos(A)*Xa+x%+l%/2,(l%/2)*sin(A)*Ya+y%+l%/2,(l%/2)*cos(A)*Xb+x%+l%/2,(l%/2)*sin(A)*Yb+y%+l%/2
  NEXT indice%
  A = A+Angle
END_SUB
Revenir en haut Aller en bas
Jicehel

Jicehel


Nombre de messages : 5947
Age : 51
Localisation : 77500
Date d'inscription : 18/04/2011

SUB LED: permet d'afficher un voyant de type LED Empty
MessageSujet: Re: SUB LED: permet d'afficher un voyant de type LED   SUB LED: permet d'afficher un voyant de type LED EmptyMar 12 Mai 2015 - 8:07

Je fais un up sur ce sujet pour que les matheux voient bien que j'ai besoin d'eux pour corriger ma formule pour dessiner les ségments autour de mon cercle car je m'y prends mal (je croyais que j'avais compris le truc, mais non ...)
Revenir en haut Aller en bas
Jicehel

Jicehel


Nombre de messages : 5947
Age : 51
Localisation : 77500
Date d'inscription : 18/04/2011

SUB LED: permet d'afficher un voyant de type LED Empty
MessageSujet: Re: SUB LED: permet d'afficher un voyant de type LED   SUB LED: permet d'afficher un voyant de type LED EmptyMar 12 Mai 2015 - 11:22

Mince alors, les matheux font la grace mat et enchaine directement sur l'apéro ... Sad
Bon, j'ai peut être une chance avant la sieste Very Happy
Revenir en haut Aller en bas
Yannick




Nombre de messages : 8610
Age : 52
Localisation : Bretagne
Date d'inscription : 15/02/2010

SUB LED: permet d'afficher un voyant de type LED Empty
MessageSujet: re   SUB LED: permet d'afficher un voyant de type LED EmptyMar 12 Mai 2015 - 13:10

@ Jicehel,

tu peux piocher là dedans :
Code:
dim sc%,Angl,pict$
pict$=dir_current$+"\pict.bmp"
label clic

height 0,600+38 : width 0,600+16
picture 1
full_space 1
color 1,255,255,255
Caption 0,"Visio Angles [ Degrés - Radians - Grades ]"
on_key_down 0,Clic

Cadran(1,150,200)

set_focus 0 : display

end

Clic:
  sc%=scancode
  if sc%=107 then Move(0) : Angl=Angl+0.5 : Move(1)
  if Angl > 360 then Angl = Angl - 360
  if sc%=109 then Move(0) : Angl=Angl-0.5 : Move(1)
  if Angl < 0-360 then Angl = Angl + 360
  if sc%=27  then terminate
return

SUB Cadran(Obj%,Ray%,Ray2%)
  dim_local i%,A,Ang
  dim_local Cx,Cy,Ax(360),Ay(360),Bx(360),By(360),nbs%
  nbs%=360
'  reperage du centre de l' objet 2D
  Cx=width(Obj%)/2 :  Cy=height(Obj%)/2  :  A=(2*acos(-1))/nbs%
'  marques interieures
  for i%=1 to nbs% : Ang=A*i% : Ax(i%)=Cx+(Ray%*cos(Ang))  : Ay(i%)=Cy+(Ray%*sin(Ang))  : next i%
'  marques exterieures
  for i%=1 to nbs% : Ang=A*i% : Bx(i%)=Cx+(Ray2%*cos(Ang)) : By(i%)=Cy+(Ray2%*sin(Ang)) :next i%
'  tracage du cadran
  2d_Target_is 1 :2d_pen_width 1
  for i%=1 to nbs%
     if i%=45 or i%=90 or i%=135 or i%=180 or i%=225 or  i%=270 or i%=315 or i%=360
        2d_pen_color 100,100,100
        2d_line Ax(i%),Ay(i%),Bx(i%),By(i%)
     else
        2d_pen_color 0,200,0
        2d_point Bx(i%),By(i%)
     end_if
  next i%
'  memorisation du cadran
  display
END_SUB

SUB Move(Type_trace%)
  off_key_down  0
  dim_local Cx,Cy,Mx,My,Nx,Ny,Ray,R,V,B,pi,rad$,grd$,deg$
  pi=acos(-1)
  Ray=150 : Cx=width(1)/2 : Cy=height(1)/2
  if Type_trace% = 1 then R=255: V=0 : B=0 : else : R=255: V=255 : B=255
  2d_pen_color R,V,B
  2d_pen_width 1 : 2d_Target_is 1
  Secteur_Circulaire(Cx,Cy,0,Angl,Ray)
  if Angl > 0 then 2d_flood Cx + Ray - 5, Cy - 1, R,V,B
  deg$ =str$(Angl)
  rad$ =str$((Angl*pi)/180) : rad$=left$(rad$,5)
  grd$ =str$((Angl/360)*400): grd$=left$(grd$,7)
  Caption 0,"Visio Angles [ Degrés : "+deg$+"   Radians : "+rad$+"   Grades : "+grd$+" ]"
  display :  set_focus 0 :  pause 10 :  on_key_down 0,Clic
END_SUB

SUB Secteur_Circulaire(xc,yc,deb,fin,rayon)
    dim_local x,y,a,pi,rad,p
    pi = acos(-1) : rad = pi/180 : deb = mod(deb,360) : fin = mod(fin,360)
    if deb < 0 then deb = deb + 360
    if fin < 0 then fin = fin + 360
    if deb > fin then  deb = deb - 360
    2d_poly_from xc,yc
      for a = deb to fin
          x = rayon*cos(a*rad) : y = rayon*sin(a*rad) : 2d_poly_to xc+x,yc-y
      next a
    2d_poly_to xc,yc
END_SUB
Revenir en haut Aller en bas
Jicehel

Jicehel


Nombre de messages : 5947
Age : 51
Localisation : 77500
Date d'inscription : 18/04/2011

SUB LED: permet d'afficher un voyant de type LED Empty
MessageSujet: Re: SUB LED: permet d'afficher un voyant de type LED   SUB LED: permet d'afficher un voyant de type LED EmptyMar 12 Mai 2015 - 15:30

Merci Ygeronimi. Je faisais une erreur et j'ai simplifié la lecture.
Bon, je dessine a peu près mon potentiomètre. Plus qu'à terminer ce soir en faisant une copie du potentiomètre dans une image et en libérant les objets utilisés pour la construction puis en la colant à la place puis à gérer les événements clics faisant vaier la variable globale contenant le résultat Smile
Code:
DIM i%
CAPTION 0,"Programme en cours - Potentiometre"
DIM Pi : Pi = 4*ATN(1)
Creer_Potentiometre(10,100,100,300,32)
PAUSE 1000
CAPTION 0,"Programme terminé, vous pouvez modifier la valeur du potentiomètre ou fermer"
END

' Procédure Creer_Potentiometre : Créer une LED dans l'objet courant pour le dessin 2D
' x%: position en x du potentiomètre
' y%: position en y du potentiomètre
' l: largeur du potentiomètre  (entre 100 et 300)
' nbmax : maximum du potentiomètre  (entre 1 et 50)

SUB Creer_Potentiometre(obj%,x%,y%,l%,nbmax%)
DIM_LOCAL indice, Angle, cx%, cy%, cr, deb, fin, compt%, posY%, posX%
  IF l% < 100 THEN l% = 100
  IF l% > 300 THEN l% = 300
  IF nbmax% <  1 THEN nbmax% = 1
  IF nbmax% > 50 THEN nbmax% = 50
  IF nbmax% < 30
    Angle=((29/20)*Pi)/(nbmax%)
  ELSE
    Angle=((3/2)*Pi)/(nbmax%+0.5)
  END_IF
  cx% = x%+l%/2 : cy% = y%+l%/2 : cr = l%/2 - 35
  PICTURE obj% : WIDTH obj%,l% : HEIGHT obj%, l% : LEFT obj%,x% : TOP obj%,y%
  COLOR obj%, 128,128,128
  2D_PEN_COLOR 0,0,0 : 2D_FILL_COLOR 128,128,128
  2D_CIRCLE cx%,cy%,cr
  2D_FILL_COLOR 200,120,20
  2D_CIRCLE cx%-0.55 * cr,cy%+0.55 * cr,cr/25 + 3
  2D_PEN_COLOR 0,0,0
  deb = (0-1.25) * PI : fin =  0.25*PI : compt% = 1
  FOR indice = deb TO fin STEP Angle
    IF indice > (0-PI) AND indice < 0
        posY% = -10
    ELSE
        posY% = 0
    END_IF
    IF indice > 0
      posX% = -8
    ELSE
        posX% = 0
    END_IF
    2D_LINE cx%+((cr+3)*cos(indice)),cy%+((cr+3)*sin(indice)),cx%+((cr+8)*cos(indice)),cy%+((cr+8)*sin(indice))
    ALPHA obj%+compt% : WIDTH obj%+compt%, 15 : HEIGHT obj%+compt%, 12
    TOP obj%+compt%,cy%+((cr+15)*sin(indice))+posY% : LEFT obj%+compt%, cx%+((cr+15)*cos(indice))+posX%
    COLOR obj%+compt%,128,128,128 : FONT_COLOR obj%+compt%,220,220,220 : FONT_BOLD obj%+compt%
    CAPTION obj%+compt%,STR$(compt% - 1 ) : compt% = compt% + 1
  NEXT indice
END_SUB
Revenir en haut Aller en bas
Yannick




Nombre de messages : 8610
Age : 52
Localisation : Bretagne
Date d'inscription : 15/02/2010

SUB LED: permet d'afficher un voyant de type LED Empty
MessageSujet: re   SUB LED: permet d'afficher un voyant de type LED EmptyMar 12 Mai 2015 - 16:10

Je le préfère comme ceci :
Code:
DIM i%
CAPTION 0,"Programme en cours - Potentiometre"
DIM Pi : Pi = 4*ATN(1)
Creer_Potentiometre(10,100,100,300,32)
PAUSE 1000
CAPTION 0,"Programme terminé, vous pouvez modifier la valeur du potentiomètre ou fermer"
END

' Procédure Creer_Potentiometre : Créer une LED dans l'objet courant pour le dessin 2D
' x%: position en x du potentiomètre
' y%: position en y du potentiomètre
' l: largeur du potentiomètre  (entre 100 et 300)
' nbmax : maximum du potentiomètre  (entre 1 et 50)

SUB Creer_Potentiometre(obj%,x%,y%,l%,nbmax%)
DIM_LOCAL indice, Angle, cx%, cy%, cr, deb, fin, compt%, posY%, posX%
  IF l% < 100 THEN l% = 100
  IF l% > 300 THEN l% = 300
  IF nbmax% <  1 THEN nbmax% = 1
  IF nbmax% > 50 THEN nbmax% = 50
  IF nbmax% < 30
    Angle=((29/20)*Pi)/(nbmax%)
  ELSE
    Angle=((3/2)*Pi)/(nbmax%+0.5)
  END_IF
  cx% = x%+l%/2 : cy% = y%+l%/2 : cr = l%/2 - 35
  PICTURE obj% : WIDTH obj%,l% : HEIGHT obj%, l% : LEFT obj%,x% : TOP obj%,y%
  COLOR obj%, 239,239,239
  2D_PEN_COLOR 0,0,0 : 2D_FILL_COLOR 128,128,128
  2D_CIRCLE cx%,cy%,cr
  2D_FILL_COLOR 200,120,20
  2D_CIRCLE cx%-0.55 * cr,cy%+0.55 * cr,cr/25 + 3
  2D_PEN_COLOR 0,0,0
  deb = (0-1.25) * PI : fin =  0.25*PI : compt% = 1
  FOR indice = deb TO fin STEP Angle
    IF indice > (0-PI) AND indice < 0
        posY% = -10
    ELSE
        posY% = 0
    END_IF
    IF indice > 0
      posX% = -8
    ELSE
        posX% = 0
    END_IF
    2D_LINE cx%+((cr+3)*cos(indice)),cy%+((cr+3)*sin(indice)),cx%+((cr+8)*cos(indice)),cy%+((cr+8)*sin(indice))
    ALPHA obj%+compt% : WIDTH obj%+compt%, 15 : HEIGHT obj%+compt%, 12
    TOP obj%+compt%,cy%+((cr+15)*sin(indice))+posY% : LEFT obj%+compt%, cx%+((cr+15)*cos(indice))+posX%
    COLOR obj%+compt%,239,239,239 : FONT_COLOR obj%+compt%,120,120,120 : FONT_BOLD obj%+compt%
    CAPTION obj%+compt%,STR$(compt% - 1 ) : compt% = compt% + 1
  NEXT indice
END_SUB

lol!
Revenir en haut Aller en bas
bignono

bignono


Nombre de messages : 1127
Age : 66
Localisation : Val de Marne
Date d'inscription : 13/11/2011

SUB LED: permet d'afficher un voyant de type LED Empty
MessageSujet: Re: SUB LED: permet d'afficher un voyant de type LED   SUB LED: permet d'afficher un voyant de type LED EmptyMar 12 Mai 2015 - 16:53

Bonjour à tous, Smile
@ Jicehel
j'avais déjà fait plusieurs type de bouton potentiomètre.
Voici plusieurs programmes qui j'espère t'inspirerons!
Il faut cliquer dans la figure et déplacer la souris vers la droite ou la gauche pour faire varier le potentiomètre sans relâcher le bouton de la souris. On relâche celui-ci quand on a le réglage voulu.
Code:
dim i,j,x1%,x2%
label turn

picture 1:width 1,150:height 1,150:left 1,25:top 1,25
j=3:2d_target_is 1

2d_rectangle 5,5,145,145
   for i=-4 to 1 step 0.5
      2d_line 70+40*cos(i),70+40*sin(i),70+50*cos(i),70+50*sin(i)
      alpha j:font_name j,"Terminal":font_bold j
      left j,90+58*cos(i):top j,90+58*sin(i):caption j,str$(j-2)
      j=j+1
   next i

j=-4
2d_pen_color 0,0,255:2d_pen_width 3:2d_fill_color 200,0,0
2d_circle 70,70,30:2d_line 70,70,70+27*cos(j),70+27*sin(j)

timer 99:timer_interval 99,1:on_timer 99,turn
end

turn:
   if scancode=0 then return
   timer_off 99
   x2%=mouse_x_position(1)
      if x2%>x1%
         2d_pen_color 200,0,0:2d_line 70,70,70+27*cos(j),70+27*sin(j)
         j=j+0.2:if j>1 then j=1
         2d_pen_color 0,0,255:2d_line 70,70,70+27*cos(j),70+27*sin(j)
      end_if
      if x2%<x1%
         2d_pen_color 200,0,0:2d_line 70,70,70+27*cos(j),70+27*sin(j)
         j=j-0.2:if j<-4 then j=-4
         2d_pen_color 0,0,255:2d_line 70,70,70+27*cos(j),70+27*sin(j)
      end_if
   x1%=mouse_x_position(1)
   pause 50
timer_on 99
return


SUB LED: permet d'afficher un voyant de type LED <a href=SUB LED: permet d'afficher un voyant de type LED Bouton11" />

SUB LED: permet d'afficher un voyant de type LED <a href=SUB LED: permet d'afficher un voyant de type LED Bouton12" />

Les 2 images pour les 2 programmes suivants:
Code:
dim rep$,j,x1,x2
label turn
rep$="c:\mesprog\"
j=-4.6
full_space 0
picture 1:width 1,92:height 1,92:file_load 1,rep$+"bouton.jpg"
left 1,750:top 1,300:2d_target_is 1:2d_pen_width 5
timer 99:timer_interval 99,1:on_timer 99,turn
end

turn:
   if scancode=0 then return
   timer_off 99
   x2=mouse_x_position(1)

   if x2>x1

      if j>0 then 2d_pen_color 90*(j+1),(90*(j+1))+39,255
      if j<=0 then 2d_pen_color 129+(j*16),45+(j*8),255

      2d_line 46+32*cos(j),46+32*sin(j),46+40*cos(j),46+40*sin(j)
      j=j+0.2:if j>1.4 then j=1.4
      2d_line 46+32*cos(j),46+32*sin(j),46+40*cos(j),46+40*sin(j)
   end_if
   if x2<x1
      2d_pen_color 0,0,0:2d_line 46+32*cos(j),46+32*sin(j),46+40*cos(j),46+40*sin(j)
      j=j-0.2:if j<-4.6 then j=-4.6
      2d_line 46+32*cos(j),46+32*sin(j),46+40*cos(j),46+40*sin(j)
   end_if

   x1=mouse_x_position(1)
   wait 50
   timer_on 99
return


Code:
variables()
labels()
gui()
init_gui_button1()
init_gui_button2()
init_gui_button3()
' init_gui_button4()

timer 101:timer_interval 101,1:on_timer 101,turn1
timer 102:timer_interval 102,1:on_timer 102,turn2
timer 103:timer_interval 103,1:on_timer 103,turn3
end

turn1:
   if scancode=0 then return
   timer_off 101:2d_target_is 2:2d_pen_width 5
   x2=mouse_x_position(2)
   if x2>x1
      if j>0 then 2d_pen_color 90*(j+1),0,0
      if j<=0 then 2d_pen_color 180-(j*16),90-(j*16),0
      2d_line 46+33*cos(j),46+33*sin(j),46+40*cos(j),46+40*sin(j)
      j=j+0.2:if j>1.4 then j=1.4
      2d_line 46+33*cos(j),46+33*sin(j),46+40*cos(j),46+40*sin(j)
   end_if
   if x2<x1
      2d_pen_color 192,192,192:2d_line 46+33*cos(j),46+33*sin(j),46+40*cos(j),46+40*sin(j)
      j=j-0.2:if j<-4.6 then j=-4.6
      2d_line 46+33*cos(j),46+33*sin(j),46+40*cos(j),46+40*sin(j)
   end_if
   x1=mouse_x_position(2)
   caption 1," VOLUME: "+str$(j+4.6)+chr$(32)
   wait 50
   timer_on 101
return

turn2:
   if scancode=0 then return
   timer_off 102:2d_target_is 4:2d_pen_width 5
   x4=mouse_x_position(4)
   if x4>x3
      if i>0 then 2d_pen_color 90*(i+1),(90*(i+1))+39,255
      if i<=0 then 2d_pen_color 129+(i*16),45+(i*8),255
      2d_line 46+33*cos(i),46+33*sin(i),46+40*cos(i),46+40*sin(i)
      i=i+0.2:if i>1.4 then i=1.4
      2d_line 46+33*cos(i),46+33*sin(i),46+40*cos(i),46+40*sin(i)
   end_if
   if x4<x3
      2d_pen_color 192,192,192:2d_line 46+33*cos(i),46+33*sin(i),46+40*cos(i),46+40*sin(i)
      i=i-0.2:if i<-4.6 then i=-4.6
      2d_line 46+33*cos(i),46+33*sin(i),46+40*cos(i),46+40*sin(i)
   end_if
   x3=mouse_x_position(4)
   caption 3," SPEED: "+str$(i+4.6)+chr$(32)
   wait 50
   timer_on 102
return

turn3:
   if scancode=0 then return
   timer_off 103:2d_target_is 6:2d_pen_width 2
   x6=mouse_x_position(6)
   if x6>x5
      2d_pen_color 0,0,0
      2d_line 46,53,46+20*cos(k),53+20*sin(k)
      k=k+0.1:if k>1 then k=1
      2d_pen_color 255,255,255
      2d_line 46,53,46+20*cos(k),53+20*sin(k)
   end_if
   if x6<x5
      2d_pen_color 0,0,0
      2d_line 46,53,46+20*cos(k),53+20*sin(k)
      k=k-0.1:if k<-4 then k=-4
      2d_pen_color 255,255,255
      2d_line 46,53,46+20*cos(k),53+20*sin(k)
   end_if
   x5=mouse_x_position(6)
   caption 5," SPEED: "+str$((k+4)*2)+chr$(32)
   wait 50
   timer_on 103
return

sub init_gui_button3()
   dim_local n
   container 5:width 5,105:height 5,115:left 5,310:top 5,100
   font_name 5,"Terminal":caption 5," SPEED: 0 "
   picture 6:parent 6,5:width 6,92:height 6,92:color 6,150,150,170
   left 6,(width(5)-width(6))/2:top 6,((height(5)-height(6))/2)+2
   for n=-4 to 1 step 0.5
      alpha number_objects+1:parent number_objects,5:color number_objects,150,150,170
      font_name number_objects,"Terminal":font_bold number_objects
      left number_objects,48+36*cos(n):top number_objects,60+36*sin(n):caption number_objects,str$(number_objects-7)
   next n
   2d_target_is 6
   for n=-4 to 1 step 0.5:2d_line 46+22*cos(n),52+22*sin(n),46+30*cos(n),52+30*sin(n):next n
   for n=-4 to 1 step 0.1:2d_point 46+23*cos(n),53+23*sin(n):next n
   2d_fill_color 0,0,0:2d_circle 46,53,20
   2d_pen_color 255,255,255:2d_pen_width 2:2d_line 46,53,46+20*cos(-4),53+20*sin(-4)
end_sub

sub init_gui_button2()
   container 3:width 3,105:height 3,115:left 3,205:top 3,100
   font_name 3,"Terminal":caption 3," SPEED: 0 "
   picture 4:parent 4,3:width 4,92:height 4,92:file_load 4,rep$+"bouton1.jpg"
   left 4,(width(3)-width(4))/2:top 4,((height(3)-height(4))/2)+2
end_sub

sub init_gui_button1()
   container 1:width 1,105:height 1,115:left 1,100:top 1,100
   font_name 1,"Terminal":caption 1," VOLUME: 0 "
   picture 2:parent 2,1:width 2,92:height 2,92:file_load 2,rep$+"bouton1.jpg"
   left 2,(width(1)-width(2))/2:top 2,((height(1)-height(2))/2)+2
end_sub

sub gui()
   width 0,1000:height 0,600:left 0,(screen_x-width(0))/2:top 0,(screen_y-40-height(0))/2
end_sub

sub labels()
   label turn1,turn2,turn3
end_sub

sub variables()
   dim rep$,i,j,k,x1,x2,x3,x4,x5,x6
   rep$="c:\mesprog\"
   i=-4.6:j=-4.6:k=-4
end_sub

et celui-ci, on change la position avec le scroll_bar:
Code:
dim i,j
label saut
j=1
' Création des numéros
 for i=-4 to 1 step 0.5
   alpha j:font_name j,"Terminal":font_bold j
   left j,70+60*cos(i)
   top j,70+60*sin(i)
   caption j,str$(j-1)
   j=j+1
 next i
' Création des graduations correspondantes aux numéros
 2d_pen_width 2
 2d_pen_color 0,0,255
 for i=-4 to 1 step 0.5:2d_line 70+40*cos(i),70+40*sin(i),70+50*cos(i),70+50*sin(i):next i
 for i=-4 to 1 step 0.1:2d_line 70+40*cos(i),70+40*sin(i),70+45*cos(i),70+45*sin(i):next i
' Création du bouton et de son marqueur
j=-4
 2d_pen_width 3:2d_fill_color 200,0,0:2d_circle 70,70,30
 2d_line 70,70,70+27*cos(j),70+27*sin(j)
 alpha number_objects+1:left number_objects,60:top number_objects,110
 font_name number_objects,"Arial":font_size number_objects,12
 font_color number_objects,200,0,200:font_bold number_objects
 caption number_objects,str$((j+4)*2)
 scroll_bar number_objects+1:left number_objects,10:top number_objects,140
 width number_objects,130:min number_objects,-40:max number_objects,10
 position number_objects,-40

on_change number_objects,saut
end

saut:
      2d_pen_color 200,0,0
      2d_line 70,70,70+27*cos(j),70+27*sin(j)
      j=position(number_objects)/10
      caption number_objects-1,str$((j+4)*2)
      2d_pen_color 0,0,255
      2d_line 70,70,70+27*cos(j),70+27*sin(j)
return

A+ Wink Wink Wink
Revenir en haut Aller en bas
Jicehel

Jicehel


Nombre de messages : 5947
Age : 51
Localisation : 77500
Date d'inscription : 18/04/2011

SUB LED: permet d'afficher un voyant de type LED Empty
MessageSujet: Re: SUB LED: permet d'afficher un voyant de type LED   SUB LED: permet d'afficher un voyant de type LED EmptyMar 12 Mai 2015 - 17:04

Merci Bignono, oui je m'en inspirerais ce soir pour gérer l'événement quand le potentiomètre est sélectionné.

Là au boulot, je ne peux pas trop Wink

J'ai quand même ajouté la sélection du potentiomètre à la modif d'Ygeronimi que j'adopte officiellement. Plus qu'à ajouter la variation de valeur en me basant sur ton exemple Bignono, mais je ferais ça cette nuit.

Code:
DIM i%,Potentiometre_value%

LABEL Select_potentiometre, Valide_valeur

CAPTION 0,"Programme en cours - Potentiometre"
DIM Pi : Pi = 4*ATN(1)
Potentiometre_value% = 0
Creer_Potentiometre(10,100,100,300,26)
ON_CLICK 10,Select_potentiometre
PAUSE 1000
CAPTION 0,"Programme terminé, vous pouvez modifier la valeur du potentiomètre ou fermer"
END

' Procédure Creer_Potentiometre : Créer une LED dans l'objet courant pour le dessin 2D
' x%: position en x du potentiomètre
' y%: position en y du potentiomètre
' l: largeur du potentiomètre  (entre 100 et 300)
' nbmax : maximum du potentiomètre  (entre 1 et 50)

SUB Creer_Potentiometre(obj%,x%,y%,l%,nbmax%)
DIM_LOCAL indice, Angle, cx%, cy%, cr, deb, fin, compt%, posY%, posX%
  IF l% < 100 THEN l% = 100
  IF l% > 300 THEN l% = 300
  IF nbmax% <  1 THEN nbmax% = 1
  IF nbmax% > 50 THEN nbmax% = 50
  IF nbmax% < 30
    Angle=((29/20)*Pi)/(nbmax%)
  ELSE
    Angle=((3/2)*Pi)/(nbmax%+0.5)
  END_IF
  cx% = x%+l%/2 : cy% = y%+l%/2 : cr = l%/2 - 35
  PICTURE obj% : WIDTH obj%,l% : HEIGHT obj%, l% : LEFT obj%,x% : TOP obj%,y%
  COLOR obj%, 239,239,239
  2D_PEN_COLOR 0,0,0 : 2D_FILL_COLOR 128,128,128
  2D_CIRCLE cx%,cy%,cr
  2D_FILL_COLOR 200,120,20
  2D_CIRCLE cx%+((2/3) * cr) * cos(0 - 1.25*Pi),cy%+((2/3) * cr) * sin(0- 1.25*Pi), cr/25 + 3
  2D_PEN_COLOR 0,0,0
  deb = (0-1.25) * PI : fin =  0.25*PI : compt% = 1
  FOR indice = deb TO fin STEP Angle
    posY% = -8
    IF indice > 0
      posX% = -3
    ELSE
      IF indice < (0-Pi/2) : posX% = -8 : ELSE: posX% = 0 : END_IF
    END_IF
    2D_LINE cx%+((cr+3)*cos(indice)),cy%+((cr+3)*sin(indice)),cx%+((cr+8)*cos(indice)),cy%+((cr+8)*sin(indice))
    ALPHA obj%+compt% : WIDTH obj%+compt%, 15 : HEIGHT obj%+compt%, 12
    TOP obj%+compt%,cy%+((cr+15)*sin(indice))+posY% : LEFT obj%+compt%, cx%+((cr+15)*cos(indice))+posX%
    COLOR obj%+compt%,239,239,239 : FONT_COLOR obj%+compt%,120,120,120 : FONT_BOLD obj%+compt%
    CAPTION obj%+compt%,STR$(compt% - 1 ) : compt% = compt% + 1
  NEXT indice
END_SUB


SUB Selectionner_Potentiometre(obj%,x%,y%,l%,nbmax%)
DIM_LOCAL indice, Angle, cx%, cy%, cr, deb, fin, compt%, posY%, posX%
  IF l% < 100 THEN l% = 100
  IF l% > 300 THEN l% = 300
  IF nbmax% <  1 THEN nbmax% = 1
  IF nbmax% > 50 THEN nbmax% = 50
  IF nbmax% < 30
    Angle=((29/20)*Pi)/(nbmax%)
  ELSE
    Angle=((3/2)*Pi)/(nbmax%+0.5)
  END_IF
  cx% = x%+l%/2 : cy% = y%+l%/2 : cr = l%/2 - 35
  2D_PEN_COLOR 255,0,0 : 2D_FILL_COLOR 128,128,128: 2D_PEN_WIDTH 3
  2D_CIRCLE cx%,cy%,cr - 2
  2D_FILL_COLOR 200,120,20
  2D_CIRCLE cx%+((2/3) * cr) * cos((Potentiometre_value% * Angle) - (1.25*Pi)),cy%+((2/3) * cr) * sin((Potentiometre_value% * Angle) - (1.25*Pi)), cr/25 + 3
END_SUB

SUB Valider_Potentiometre(obj%,x%,y%,l%,nbmax%)
DIM_LOCAL indice, Angle, cx%, cy%, cr, deb, fin, compt%, posY%, posX%
  IF l% < 100 THEN l% = 100
  IF l% > 300 THEN l% = 300
  IF nbmax% <  1 THEN nbmax% = 1
  IF nbmax% > 50 THEN nbmax% = 50
  IF nbmax% < 30
    Angle=((29/20)*Pi)/(nbmax%)
  ELSE
    Angle=((3/2)*Pi)/(nbmax%+0.5)
  END_IF
  cx% = x%+l%/2 : cy% = y%+l%/2 : cr = l%/2 - 35
  2D_PEN_COLOR 0,0,0 : 2D_FILL_COLOR 128,128,128: 2D_PEN_WIDTH 1
  2D_CIRCLE cx%,cy%,cr
  2D_FILL_COLOR 200,120,20
  2D_CIRCLE cx%+((2/3) * cr) * cos((Potentiometre_value% * Angle) - (1.25*Pi)),cy%+((2/3) * cr) * sin((Potentiometre_value% * Angle) - (1.25*Pi)), cr/25 + 3
END_SUB



Select_potentiometre:
  ON_CLICK 10, Valide_valeur
  Selectionner_Potentiometre(10,100,100,300,26)
RETURN

Valide_valeur:
  ON_CLICK 10, Select_potentiometre
  Valider_Potentiometre(10,100,100,300,26)
RETURN
Revenir en haut Aller en bas
Jicehel

Jicehel


Nombre de messages : 5947
Age : 51
Localisation : 77500
Date d'inscription : 18/04/2011

SUB LED: permet d'afficher un voyant de type LED Empty
MessageSujet: Re: SUB LED: permet d'afficher un voyant de type LED   SUB LED: permet d'afficher un voyant de type LED EmptyMar 12 Mai 2015 - 18:20

Oui, j'adore la presentation de ton dernier potentiomètre.
J'essayerais d'améliorer le mien avec ce style si je peux.
Sinon, j'ai rajouté le sytème d'augmentation tel que tu l'as implémenté par déplacement à gauche sur le bouton qui baisse la valeur et à droite qui la monte avant de partir du boluot, mais ça ne me satisfait que moyennement.
Si je peux, ce soir, je voudrais modifier la formule pour que la valeur ne change que si l'on se déplace dans la zone où sont affichées les valeurs et que le bouton se place sur la valeur la plus proche (en se basant sur l'angle entre la position de la souris et le centre du potentiomètre)
En attendant, le programme donne:
Code:
DIM i%,Potentiometre_value%, Pos_souris%, val_max_potentiometre%

LABEL Select_potentiometre, Valide_valeur, Potentiometre_maj

CAPTION 0,"Programme en cours - Potentiometre"
DIM Pi : Pi = 4*ATN(1)
Potentiometre_value% = 0
val_max_potentiometre% = 26
Creer_Potentiometre(10,100,100,300,val_max_potentiometre%)
TIMER 5:TIMER_INTERVAL 5,50: ON_TIMER 5,Potentiometre_maj : TIMER_OFF 5
ON_CLICK 10,Select_potentiometre
PAUSE 1000
CAPTION 0,"Programme terminé, vous pouvez modifier la valeur du potentiomètre ou fermer"
END

' Procédure Creer_Potentiometre : Créer une LED dans l'objet courant pour le dessin 2D
' x%: position en x du potentiomètre
' y%: position en y du potentiomètre
' l: largeur du potentiomètre  (entre 100 et 300)
' nbmax : maximum du potentiomètre  (entre 1 et 50)

SUB Creer_Potentiometre(obj%,x%,y%,l%,nbmax%)
DIM_LOCAL indice, Angle, cx%, cy%, cr, deb, fin, compt%, posY%, posX%
  IF l% < 100 THEN l% = 100
  IF l% > 300 THEN l% = 300
  IF nbmax% <  1 THEN nbmax% = 1
  IF nbmax% > 50 THEN nbmax% = 50
  IF nbmax% < 30
    Angle=((29/20)*Pi)/(nbmax%)
  ELSE
    Angle=((3/2)*Pi)/(nbmax%+0.5)
  END_IF
  cx% = x%+l%/2 : cy% = y%+l%/2 : cr = l%/2 - 35
  PICTURE obj% : WIDTH obj%,l% : HEIGHT obj%, l% : LEFT obj%,x% : TOP obj%,y%
  COLOR obj%, 239,239,239
  2D_PEN_COLOR 0,0,0 : 2D_FILL_COLOR 128,128,128
  2D_CIRCLE cx%,cy%,cr
  2D_FILL_COLOR 200,120,20
  2D_CIRCLE cx%+((2/3) * cr) * cos(0 - 1.25*Pi),cy%+((2/3) * cr) * sin(0- 1.25*Pi), cr/25 + 3
  2D_PEN_COLOR 0,0,0
  deb = (0-1.25) * PI : fin =  0.25*PI : compt% = 1
  FOR indice = deb TO fin STEP Angle
    posY% = -8
    IF indice > 0
      posX% = -3
    ELSE
      IF indice < (0-Pi/2) : posX% = -8 : ELSE: posX% = 0 : END_IF
    END_IF
    2D_LINE cx%+((cr+3)*cos(indice)),cy%+((cr+3)*sin(indice)),cx%+((cr+8)*cos(indice)),cy%+((cr+8)*sin(indice))
    ALPHA obj%+compt% : WIDTH obj%+compt%, 15 : HEIGHT obj%+compt%, 12
    TOP obj%+compt%,cy%+((cr+15)*sin(indice))+posY% : LEFT obj%+compt%, cx%+((cr+15)*cos(indice))+posX%
    COLOR obj%+compt%,239,239,239 : FONT_COLOR obj%+compt%,120,120,120 : FONT_BOLD obj%+compt%
    CAPTION obj%+compt%,STR$(compt% - 1 ) : compt% = compt% + 1
  NEXT indice
END_SUB


SUB Selectionner_Potentiometre(obj%,x%,y%,l%,nbmax%)
DIM_LOCAL indice, Angle, cx%, cy%, cr, deb, fin, compt%, posY%, posX%
  IF l% < 100 THEN l% = 100
  IF l% > 300 THEN l% = 300
  IF nbmax% <  1 THEN nbmax% = 1
  IF nbmax% > 50 THEN nbmax% = 50
  IF nbmax% < 30
    Angle=((29/20)*Pi)/(nbmax%)
  ELSE
    Angle=((3/2)*Pi)/(nbmax%+0.5)
  END_IF
  cx% = x%+l%/2 : cy% = y%+l%/2 : cr = l%/2 - 35
  2D_PEN_COLOR 255,0,0 : 2D_FILL_COLOR 128,128,128: 2D_PEN_WIDTH 3
  2D_CIRCLE cx%,cy%,cr - 2
  2D_FILL_COLOR 200,120,20
  2D_CIRCLE cx%+((2/3) * cr) * cos((Potentiometre_value% * Angle) - (1.25*Pi)),cy%+((2/3) * cr) * sin((Potentiometre_value% * Angle) - (1.25*Pi)), cr/25 + 3
END_SUB

SUB Valider_Potentiometre(obj%,x%,y%,l%,nbmax%)
DIM_LOCAL Angle, cx%, cy%, cr
  IF nbmax% < 30
    Angle=((29/20)*Pi)/(nbmax%)
  ELSE
    Angle=((3/2)*Pi)/(nbmax%+0.5)
  END_IF
  cx% = x%+l%/2 : cy% = y%+l%/2 : cr = l%/2 - 35
  2D_PEN_COLOR 0,0,0 : 2D_FILL_COLOR 128,128,128: 2D_PEN_WIDTH 1
  2D_CIRCLE cx%,cy%,cr
  2D_FILL_COLOR 200,120,20
  2D_CIRCLE cx%+((2/3) * cr) * cos((Potentiometre_value% * Angle) - (1.25*Pi)),cy%+((2/3) * cr) * sin((Potentiometre_value% * Angle) - (1.25*Pi)), cr/25 + 3
END_SUB

SUB MAJ_Potentiometre(obj%,x%,y%,l%,nbmax%)
DIM_LOCAL Angle, cx%, cy%, cr
  IF nbmax% < 30
    Angle=((29/20)*Pi)/(nbmax%)
  ELSE
    Angle=((3/2)*Pi)/(nbmax%+0.5)
  END_IF
  cx% = x%+l%/2 : cy% = y%+l%/2 : cr = l%/2 - 35
  2D_PEN_COLOR 255,0,0 : 2D_FILL_COLOR 128,128,128: 2D_PEN_WIDTH 3
  2D_CIRCLE cx%,cy%,cr - 2
  2D_FILL_COLOR 200,120,20
  2D_CIRCLE cx%+((2/3) * cr) * cos((Potentiometre_value% * Angle) - (1.25*Pi)),cy%+((2/3) * cr) * sin((Potentiometre_value% * Angle) - (1.25*Pi)), cr/25 + 3
END_SUB


Potentiometre_maj:
  TIMER_OFF 5
  IF mouse_x_position(10) > Pos_souris% THEN Potentiometre_value% = Potentiometre_value% + 1
  IF mouse_x_position(10) < Pos_souris% THEN Potentiometre_value% = Potentiometre_value% - 1
  IF mouse_x_position(10) <> Pos_souris%
    IF Potentiometre_value% < 1  THEN Potentiometre_value% = 0
    IF Potentiometre_value% > val_max_potentiometre% THEN Potentiometre_value% = val_max_potentiometre%
    MAJ_potentiometre(10,100,100,300,val_max_potentiometre%)
    Pos_Souris% = mouse_x_position(10)
  END_IF
  TIMER_ON 5
RETURN

Select_potentiometre:
  ON_CLICK 10, Valide_valeur
  Selectionner_Potentiometre(10,100,100,300,val_max_potentiometre%)
  Pos_Souris% = mouse_x_position(10)
  TIMER_ON 5
RETURN

Valide_valeur:
  TIMER_OFF 5
  ON_CLICK 10, Select_potentiometre
  Valider_Potentiometre(10,100,100,300,val_max_potentiometre%)
  CAPTION 0, Potentiometre_value%
RETURN

PS: On a des amis ce soir chez nous, ce sera donc peut être pour demain. On verra bien Wink
Revenir en haut Aller en bas
Jicehel

Jicehel


Nombre de messages : 5947
Age : 51
Localisation : 77500
Date d'inscription : 18/04/2011

SUB LED: permet d'afficher un voyant de type LED Empty
MessageSujet: Re: SUB LED: permet d'afficher un voyant de type LED   SUB LED: permet d'afficher un voyant de type LED EmptyMer 13 Mai 2015 - 10:50

J'ai besoin des matheux pour la procédure événementielle: Potentiometre_maj
Je voudrais retrouver la valeur sur laquelle se trouve ma souris en passant par l'arccosinus de l'angle formé entre mon centre et la position de la souris... mais moi la trigo c'est trop loin alors que je sais que certains d'entre vous maîtrisent le sujet ...
Ma formule est fausse, j'ai essayé de bidouiller pour trouver mais je dois encore faire une erreur quelque part... Plutôt que de faire n'importe quoi, je m'adresse directement aux spécialistes: svp, pouvez vous me donner la bonne formule a mettre ?
Merci par avance

Code:
DIM d%,Potentiometre_value, Pos_souris%, val_max_potentiometre%
DIM Np%,Xp%,Yp%,Lp% : Np% = 10 : Xp% = 50 : Yp% = 50 : Lp% = 300
DIM Delta1, Delta2, A

LABEL Select_potentiometre, Valide_valeur, Potentiometre_maj

CAPTION 0,"Programme en cours - Potentiometre"
DIM Pi : Pi = 4*ATN(1)
Potentiometre_value = 0
val_max_potentiometre% = 26
Creer_Potentiometre(Np%,Xp%,Yp%,Lp%,val_max_potentiometre%)
TIMER 5:TIMER_INTERVAL 5,50: ON_TIMER 5,Potentiometre_maj : TIMER_OFF 5
ON_CLICK 10,Select_potentiometre
PAUSE 1000
CAPTION 0,"Programme terminé, vous pouvez modifier la valeur du potentiomètre ou fermer"
END

' Procédure Creer_Potentiometre : Créer une LED dans l'objet courant pour le dessin 2D
' x%: position en x du potentiomètre
' y%: position en y du potentiomètre
' l: largeur du potentiomètre  (entre 100 et 300)
' nbmax : maximum du potentiomètre  (entre 1 et 50)

SUB Creer_Potentiometre(obj%,x%,y%,l%,nbmax%)
DIM_LOCAL indice, Angle, cx%, cy%, cr, deb, fin, compt%, posY%, posX%
  IF l% < 100 THEN l% = 100
  IF l% > 300 THEN l% = 300
  IF nbmax% <  1 THEN nbmax% = 1
  IF nbmax% > 50 THEN nbmax% = 50
  IF nbmax% < 30
    Angle=((29/20)*Pi)/(nbmax%)
  ELSE
    Angle=((3/2)*Pi)/(nbmax%+0.5)
  END_IF
  cx% = x%+l%/2 : cy% = y%+l%/2 : cr = l%/2 - 35
  PICTURE obj% : WIDTH obj%,l% : HEIGHT obj%, l% : LEFT obj%,x% : TOP obj%,y%
  COLOR obj%, 239,239,239
  2D_PEN_COLOR 0,0,0 : 2D_FILL_COLOR 128,128,128
  2D_CIRCLE cx%,cy%,cr
  2D_FILL_COLOR 200,120,20
  2D_CIRCLE cx%+((2/3) * cr) * cos(0 - 1.25*Pi),cy%+((2/3) * cr) * sin(0- 1.25*Pi), cr/25 + 3
  2D_PEN_COLOR 0,0,0
  deb = (0-1.25) * PI : fin =  0.25*PI : compt% = 1
  FOR indice = deb TO fin STEP Angle
    posY% = -8
    IF indice > 0
      posX% = -3
    ELSE
      IF indice < (0-Pi/2) : posX% = -8 : ELSE: posX% = 0 : END_IF
    END_IF
    2D_LINE cx%+((cr+3)*cos(indice)),cy%+((cr+3)*sin(indice)),cx%+((cr+8)*cos(indice)),cy%+((cr+8)*sin(indice))
    ALPHA obj%+compt% : WIDTH obj%+compt%, 15 : HEIGHT obj%+compt%, 12
    TOP obj%+compt%,cy%+((cr+15)*sin(indice))+posY% : LEFT obj%+compt%, cx%+((cr+15)*cos(indice))+posX%
    COLOR obj%+compt%,239,239,239 : FONT_COLOR obj%+compt%,120,120,120 : FONT_BOLD obj%+compt%
    CAPTION obj%+compt%,STR$(compt% - 1 ) : compt% = compt% + 1
  NEXT indice
END_SUB


SUB Selectionner_Potentiometre(obj%,x%,y%,l%,nbmax%)
DIM_LOCAL indice, Angle, cx%, cy%, cr, deb, fin, compt%, posY%, posX%
  IF l% < 100 THEN l% = 100
  IF l% > 300 THEN l% = 300
  IF nbmax% <  1 THEN nbmax% = 1
  IF nbmax% > 50 THEN nbmax% = 50
  IF nbmax% < 30
    Angle=((29/20)*Pi)/(nbmax%)
  ELSE
    Angle=((3/2)*Pi)/(nbmax%+0.5)
  END_IF
  cx% = x%+l%/2 : cy% = y%+l%/2 : cr = l%/2 - 35
  2D_PEN_COLOR 255,0,0 : 2D_FILL_COLOR 128,128,128: 2D_PEN_WIDTH 3
  2D_CIRCLE cx%,cy%,cr - 2
  2D_FILL_COLOR 200,120,20
  2D_CIRCLE cx%+((2/3) * cr) * cos((Potentiometre_value * Angle) - (1.25*Pi)),cy%+((2/3) * cr) * sin((Potentiometre_value * Angle) - (1.25*Pi)), cr/25 + 3
END_SUB

SUB Valider_Potentiometre(obj%,x%,y%,l%,nbmax%)
DIM_LOCAL Angle, cx%, cy%, cr
  IF nbmax% < 30
    Angle=((29/20)*Pi)/(nbmax%)
  ELSE
    Angle=((3/2)*Pi)/(nbmax%+0.5)
  END_IF
  cx% = x%+l%/2 : cy% = y%+l%/2 : cr = l%/2 - 35
  2D_PEN_COLOR 0,0,0 : 2D_FILL_COLOR 128,128,128: 2D_PEN_WIDTH 1
  2D_CIRCLE cx%,cy%,cr
  2D_FILL_COLOR 200,120,20
  2D_CIRCLE cx%+((2/3) * cr) * cos((Potentiometre_value * Angle) - (1.25*Pi)),cy%+((2/3) * cr) * sin((Potentiometre_value * Angle) - (1.25*Pi)), cr/25 + 3
END_SUB

SUB MAJ_Potentiometre(obj%,x%,y%,l%,nbmax%)
DIM_LOCAL Angle, cx%, cy%, cr
  IF nbmax% < 30
    Angle=((29/20)*Pi)/(nbmax%)
  ELSE
    Angle=((3/2)*Pi)/(nbmax%+0.5)
  END_IF
  cx% = x%+l%/2 : cy% = y%+l%/2 : cr = l%/2 - 35
  2D_PEN_COLOR 255,0,0 : 2D_FILL_COLOR 128,128,128: 2D_PEN_WIDTH 3
  2D_CIRCLE cx%,cy%,cr - 2
  2D_FILL_COLOR 200,120,20
  2D_CIRCLE cx%+((2/3) * cr) * cos((Potentiometre_value * Angle) - (1.25*Pi)),cy%+((2/3) * cr) * sin((Potentiometre_value * Angle) - (1.25*Pi)), cr/25 + 3
END_SUB


Potentiometre_maj:
  TIMER_OFF 5

  IF mouse_x_position(10) <> Pos_souris%
    delta1 = (mouse_x_position(10) - (Lp%/2))
    delta2 = (mouse_y_position(10) - (Lp%/2))
    d% = delta1 * delta1 + delta2 * delta2 -  (Lp%/2 - 35) * (Lp%/2 - 35)
    IF d% > 700 AND d% < 8000
      IF val_max_potentiometre% < 30
        A=((29/20)*Pi)/(val_max_potentiometre%)
      ELSE
        A=((3/2)*Pi)/(val_max_potentiometre%+0.5)
      END_IF
      Potentiometre_value = (0  - acos ( delta1 /(delta1*delta1 + delta2*delta2) ) + 1.25*Pi)
      caption 0, Potentiometre_value
'      IF Potentiometre_value < 1  THEN Potentiometre_value = 0
'      IF Potentiometre_value > val_max_potentiometre THEN Potentiometre_value = val_max_potentiometre%
    END_IF
'    MAJ_potentiometre(Np%,Xp%,Yp%,Lp%,val_max_potentiometre%)
    Pos_Souris% = mouse_x_position(10)
  END_IF
  TIMER_ON 5
RETURN

Select_potentiometre:
  ON_CLICK 10, Valide_valeur
  Selectionner_Potentiometre(Np%,Xp%,Yp%,Lp%,val_max_potentiometre%)
  Pos_Souris% = mouse_x_position(10)
  TIMER_ON 5
RETURN

Valide_valeur:
  TIMER_OFF 5
  ON_CLICK 10, Select_potentiometre
  Valider_Potentiometre(Np%,Xp%,Yp%,Lp%,val_max_potentiometre%)
  CAPTION 0, Potentiometre_value
RETURN


Dernière édition par Jicehel le Mer 13 Mai 2015 - 15:26, édité 1 fois
Revenir en haut Aller en bas
Jicehel

Jicehel


Nombre de messages : 5947
Age : 51
Localisation : 77500
Date d'inscription : 18/04/2011

SUB LED: permet d'afficher un voyant de type LED Empty
MessageSujet: Re: SUB LED: permet d'afficher un voyant de type LED   SUB LED: permet d'afficher un voyant de type LED EmptyMer 13 Mai 2015 - 12:14

Ben alors, les matheux n'ont pas la forme en ce moment ... C'est encore Ygeronimi qui va me sortir de l'impasse ? Wait and see ...
Revenir en haut Aller en bas
Yannick




Nombre de messages : 8610
Age : 52
Localisation : Bretagne
Date d'inscription : 15/02/2010

SUB LED: permet d'afficher un voyant de type LED Empty
MessageSujet: re   SUB LED: permet d'afficher un voyant de type LED EmptyMer 13 Mai 2015 - 13:03

Heu... YGeronimi peut t' aider sur une déduction logique mais
compte pas sur lui pour des sinus, coussinus and Co.

Il était pas là le jour des cours... Laughing
Revenir en haut Aller en bas
Jicehel

Jicehel


Nombre de messages : 5947
Age : 51
Localisation : 77500
Date d'inscription : 18/04/2011

SUB LED: permet d'afficher un voyant de type LED Empty
MessageSujet: Re: SUB LED: permet d'afficher un voyant de type LED   SUB LED: permet d'afficher un voyant de type LED EmptyMer 13 Mai 2015 - 14:10

Bon, ben il n'y a plus qu'à attendre que Jean debord ou Papydall lisent ces lignes (Jean-Claude peut être, je ne sais plus s'il maitrise ça... )
Revenir en haut Aller en bas
papydall

papydall


Nombre de messages : 6996
Age : 73
Localisation : Moknine (Tunisie) Entre la chaise et le clavier
Date d'inscription : 03/03/2012

SUB LED: permet d'afficher un voyant de type LED Empty
MessageSujet: Re: SUB LED: permet d'afficher un voyant de type LED   SUB LED: permet d'afficher un voyant de type LED EmptyMer 13 Mai 2015 - 14:51

Je n’ai pas compris exactement ce que tu demandes, peut-être à cause de ce maudit Chrome qui ne se  satisfait plus de ramer : il stagne une éternité avant de me rendre la main !

Bon, je vois un potentiomètre.
Je clique dans le cercle, le pourtour  se colorise en rouge ainsi que le petit bouton.
Puis quoi faire ensuite ?
Un second clic et hop un message d’erreur :  not correct arithmetic expression : Line 89
Revenir en haut Aller en bas
http://papydall-panoramic.forumarabia.com/
papydall

papydall


Nombre de messages : 6996
Age : 73
Localisation : Moknine (Tunisie) Entre la chaise et le clavier
Date d'inscription : 03/03/2012

SUB LED: permet d'afficher un voyant de type LED Empty
MessageSujet: Re: SUB LED: permet d'afficher un voyant de type LED   SUB LED: permet d'afficher un voyant de type LED EmptyMer 13 Mai 2015 - 15:12

Je vois dans le code tantôt Potentiometre_value%, tantôt Potentiometre_value, tantôt val_max_potentiometre%% avec zéro, un ou deux %
Est-ce que le Forum m’a joué l’un de ses mauvais tours ?
En tous cas, le code est presque inexploitable chez moi  Sad
Et la variable  Potentiometre_value% ne reçoit jamais aucune valeur
Revenir en haut Aller en bas
http://papydall-panoramic.forumarabia.com/
Contenu sponsorisé





SUB LED: permet d'afficher un voyant de type LED Empty
MessageSujet: Re: SUB LED: permet d'afficher un voyant de type LED   SUB LED: permet d'afficher un voyant de type LED Empty

Revenir en haut Aller en bas
 
SUB LED: permet d'afficher un voyant de type LED
Revenir en haut 
Page 1 sur 2Aller à la page : 1, 2  Suivant
 Sujets similaires
-
» sub bouton voyant et voyant 3d
»  Détecter le type du PC Portable ou Fixe
» Déterminer le type de clavier
» Créer un objet selon son type
» Un menu déroulant type "Side Bar"

Permission de ce forum:Vous ne pouvez pas répondre aux sujets dans ce forum
FORUM DE DISCUSSION SUR LE LANGAGE PANORAMIC :: PANORAMIC :: Les inutilitaires-
Sauter vers: