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
» Une calculatrice en une ligne de programme
SUB LED: permet d'afficher un voyant de type LED - Page 2 Emptypar jean_debord Aujourd'hui à 8:47

» Form(résolu)
SUB LED: permet d'afficher un voyant de type LED - Page 2 Emptypar leclode Hier à 17:59

» trop de fichiers en cours
SUB LED: permet d'afficher un voyant de type LED - Page 2 Emptypar Marc Hier à 11:42

» Bataille navale SM
SUB LED: permet d'afficher un voyant de type LED - Page 2 Emptypar jjn4 Ven 26 Avr 2024 - 17:39

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

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

» Naissance de Crocodile Basic
SUB LED: permet d'afficher un voyant de type LED - Page 2 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 - Page 2 Emptypar Froggy One Mer 24 Avr 2024 - 18:38

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

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

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

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

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

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

» Sous-programme(résolu)
SUB LED: permet d'afficher un voyant de type LED - Page 2 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
-28%
Le deal à ne pas rater :
Brandt LVE127J – Lave-vaisselle encastrable 12 couverts – L60cm
279.99 € 390.99 €
Voir le deal

 

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

Aller en bas 
+3
Minibug
Yannick
Jicehel
7 participants
Aller à la page : Précédent  1, 2
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 - Page 2 Empty
MessageSujet: Re: SUB LED: permet d'afficher un voyant de type LED   SUB LED: permet d'afficher un voyant de type LED - Page 2 EmptyMer 13 Mai 2015 - 15:31

Coucou Papydall, merci de te pencher sur ce problème. Le problème ne vient pas de là, je travaillais avant avec une indentation par valeur entière (+1) ou (-1) selon le déplacement à droite ou à gauche. J'ai modifié ce matin pour passer en valeur décimale puisque l'on travaille sur des angles.
J'ai peut être oublié de retirer des %, mais tu peux tous les retirer (par contre, val_max_potentiometre% n'a rien à voir avec ). Pour t'éviter de perdre du temps avec ça, j'ai corrigé le code du dernier post (autant ne pas multiplier les sources d'erreur, tu as raison, ne confondons pas vitesse et précipitation)
Malheureusement, le problème n'est pas aussi simple, il est mathématique dans la formule pour retrouver la valeur sur laquelle se trouve la souris en fonction de l'angle formé entre la position de la souris et le centre de ce potentiomètre.
J'ai mis une formule mais elle est incomplète ou fausse dans la procédure la procédure événementielle: Potentiometre_maj et là, je compte sur toi par ce que je ne suis pas du tout à l'aise avec ces fonctions
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 - Page 2 Empty
MessageSujet: Re: SUB LED: permet d'afficher un voyant de type LED   SUB LED: permet d'afficher un voyant de type LED - Page 2 EmptyMer 13 Mai 2015 - 16:43

Je récapitule :
Tu as la position de la souris  : X_souris et Y_souris
La souris se trouve dans un cercle de centre Cx,Cy
Tu désires déterminer l’angle que fait la droite joignant la souris au centre du cercle avec l’axe horizontal ?
Si c’est ça, alors tu dois recourir  à la fonction ATN2(x,y) qui donne l’arc tangente de (Y/X) et  qui n’est pas disponible sous Panoramic.

Voici une SUB qui calcule ATN2(x,y).
Dans ton programme tu l’appelles en lui transmettant la position de la souris :
Comme ceci
Code:
ATN2(X_souris,Y_souris)
Le résultat sera retourné dans la variable globale result que tu déclareras dans ton programme

Code:
dim pi  : pi = acos(-1)
dim result

 ATN2(1,1)   : message result   : ' doit retourner PI/4  = 0.785398...
' ATN2(0,-1)  : message result   : ' doit retourner -PI/2  = -1.57079...
' ATN2(1,0)   : message result   : ' doit retourner 0
' ATN2(-1,-1) : message result   : ' doit retourner -3*PI/4 = -2.35619..

end
rem ============================================================================
' Atn2 - Arc tangente de Y/X
' arc tangente de Y/X -->  retourne les valeurs dans les 4 quadrants en radians
SUB ATN2(x,y)
    If x = 0
       result = Sgn(y) * pi/2
    Else
       If x > 0
          result = Atn(y / x)
       Else
          if x < 0 and y = 0
             result = atn(y / x) - sgn(x) * pi
          else
            result = Atn(y / x) + Sgn(y) * pi
          end_if
       End_if
   end_if
END_SUB
rem ============================================================================

EDIT

ATN2(x,y) peut retourner des valeurs négatives.

Si tu les veux toujours positives, tu fait
Code:
result = wrap_value(result/p)*p

avec p = pi/180  à déclarer au début du code
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 - Page 2 Empty
MessageSujet: Re: SUB LED: permet d'afficher un voyant de type LED   SUB LED: permet d'afficher un voyant de type LED - Page 2 EmptyMer 13 Mai 2015 - 17:21

Merci Papydall, ça avance
ATAN2 permet d'avoir une valeur cohérente, maintenant il faudrait que je sache faire en sort que le 0 retourné coincide avec le 0 de mon potentiomètre (qui est positioné à -5Pi/4) sinon j'ai une valeur qui progresse puis qui redescend et je ne peux donc pas appliquer une correction linéaire dessus pour récupérer mes valeurs.
Désolé, j'exploite le mathématicien de l'équipe ... Very Happy Mais bon tu maitrises vraiment mieux le sujet que moi ...

Je remet un version du code avec ATAN2 ci dessous

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, ATN_result

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
      ATN2(mouse_x_position(10),mouse_y_position(10))
      Potentiometre_value = ATN_result
      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


rem ============================================================================
' Atn2 - Arc tangente de Y/X
' arc tangente de Y/X -->  retourne les valeurs dans les 4 quadrants en radians
SUB ATN2(x,y)
    If x = 0
      ATN_result = Sgn(y) * pi/2
    Else
      If x > 0
          ATN_result = Atn(y / x)
      Else
          if x < 0 and y = 0
            ATN_result = atn(y / x) - sgn(x) * pi
          else
            ATN_result = Atn(y / x) + Sgn(y) * pi
          end_if
      End_if
  end_if
END_SUB
rem ============================================================================
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 - Page 2 Empty
MessageSujet: Re: SUB LED: permet d'afficher un voyant de type LED   SUB LED: permet d'afficher un voyant de type LED - Page 2 EmptyMer 13 Mai 2015 - 18:40

Difficile de se promener dans le labyrinthe d’un programme que l’on n’a pas fait soi-même.
Ajoutez à cela une demi-douzaine d’enfants chez soi qui appellent Papydall pour jouer avec eux et je vous laisse devinez la suite.
Une modification du code pour voir, mais … pas possible d’aller plus loin.
Peut-être tard dans la nuit.

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, ATN_result

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
   COLOR obj%,0,255,0  : ' Juste pour voir ============================ Papydall
  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
' ===================================================================== Papydall
  2d_circle cx%+(cr-20)*cos(ATN_result),cy%+ (cr-20)*sin(ATN_result),cr/25+3
' ========================================================================== FIN
'  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))
' ===================================================================== Papydall
     ATN2(delta1,delta2) : Potentiometre_value = ATN_result
      caption 0, Potentiometre_value
' ========================================================================== FIN
      
    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
   '   ATN2(mouse_x_position(10),mouse_y_position(10))
   '   Potentiometre_value = ATN_result
   '   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


rem ============================================================================
' Atn2 - Arc tangente de Y/X
' arc tangente de Y/X -->  retourne les valeurs dans les 4 quadrants en radians
SUB ATN2(x,y)
    If x = 0
      ATN_result = Sgn(y) * pi/2
    Else
      If x > 0
          ATN_result = Atn(y / x)
      Else
          if x < 0 and y = 0
            ATN_result = atn(y / x) - sgn(x) * pi
          else
            ATN_result = Atn(y / x) + Sgn(y) * pi
          end_if
      End_if
  end_if
END_SUB
rem ============================================================================
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 - Page 2 Empty
MessageSujet: Re: SUB LED: permet d'afficher un voyant de type LED   SUB LED: permet d'afficher un voyant de type LED - Page 2 EmptyMer 13 Mai 2015 - 19:00

Ok, je verrais bien si tu trouves, moi j'avoue que les résultats des arctangentes me laisse pantois ...
amuses toi bien, moi je retourne chez moi. Je suis en weekend !! Very Happy
Revenir en haut Aller en bas
Jean Claude

Jean Claude


Nombre de messages : 5948
Age : 69
Localisation : 83 Var
Date d'inscription : 07/05/2009

SUB LED: permet d'afficher un voyant de type LED - Page 2 Empty
MessageSujet: Re: SUB LED: permet d'afficher un voyant de type LED   SUB LED: permet d'afficher un voyant de type LED - Page 2 EmptyMer 13 Mai 2015 - 21:02

Jicehel a écrit:
moi je retourne chez moi. Je suis en weekend  !!  Very Happy  

Un plaisir réservé aux actifs. Ça me rappelle quelques années en arrière, où après deux semaines d’absence à la maison, j'allais retrouver ma tribu, distante de 1000Km, ... avec une pincée au cœur...    Sad   Very Happy  
-----------------------------------------------------------------------------------------------------------------
Question aide pour ton code: Je ne suis pas plus "matheu" que toi (voir, bien moins).... Embarassed

J'ai tenté d'utiliser ta SUB, pour en faire une OPTION colorée, mais c'est un demi-échec, car la 2D se mélange mal avec les objets Panoramic.
Pour illustrer: Essai de rapprocher la LED du BUTTON 1, dans le programme ci-dessous, en modifiant top et left (topled% et leftled%) de cet ALPHA 2. Les résultats d'affichage sont problématiques !.

Code:
DIM etat%,couleur%,topled%,leftled%
topled%=70 : leftled%=60 :' position de la LED et de son alpha
LABEL fin,clic
on_close 0,fin

button 1 : top 1,1 : left 1,1 : caption 1,"Start"
on_click 1,clic
alpha 2 : top 2,topled%-5 : left 2,leftled%+35
caption 2,"Etat de la LED: "+str$(etat%)+" = éteinte"
' 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

Creer_LED(topled%,leftled%,5,0)
END

clic:
  if etat%=0
     caption 2,"Etat de la LED: "+str$(etat%)+" = éteinte" : Creer_LED(topled%,leftled%,5,0)
     etat%=1 : caption 1,"Allume la LED"
  else
     caption 2,"Etat de la LED: "+str$(etat%)+" = allumée" : Creer_LED(topled%,leftled%,5,4)
     etat%=0 : caption 1,"Eteint la LED"
  end_if
return

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

fin:
  Terminate
return

A+
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 - Page 2 Empty
MessageSujet: Re: SUB LED: permet d'afficher un voyant de type LED   SUB LED: permet d'afficher un voyant de type LED - Page 2 EmptyMer 13 Mai 2015 - 21:19

Je pense que je vois ce que tu veux dire, mais pourrais tu dire le résultat que tu souhaitais ? Je pense savoir, mais pas exactement. Je pense par exemple que tu aurais pu vouloir avoir la led devant le texte du bouton, ce qui ne peut en effet pas être fait comme ça, mais par contre si c'est un objet qui t'interesse je peux le faire assez facilement en passant par un picture de travail.
Tracer un cercle et mettre un quart à chaque coin du picture, tracer 4 lignes pour faire les bords, laisser la place pour afficher une led, remplir l'interieur du bouton, ajouter un alpha avec la couleur de fond du bouton et le texte souhaité.
On peut gérer le clic sur le picture, on peut afficher la led dessus, on peut même faire 2 picture pour le bouton un relaché et un enfoncé avec des couleurs de leds différentes comme les boutons proposé par Jean dans son compilateur.
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 - Page 2 Empty
MessageSujet: Re: SUB LED: permet d'afficher un voyant de type LED   SUB LED: permet d'afficher un voyant de type LED - Page 2 EmptyMer 13 Mai 2015 - 22:11

Voila encore une possibilité de la LED sur un PANEL clickable...

Code:
DIM r%,v%,b%

LABEL fin , led
on_close 0,fin

PANEL 1 : top 1,1 : left 1,1 : HEIGHT 1, 50 : WIDTH 1,150 : COLOR 1,220,220,220
caption 1,"Allume la LED                  " : on_click 1,led
PICTURE 2 : PARENT 2,1 : LEFT 2,105 : TOP 2,5 : WIDTH 2,40 : HEIGHT 2,40 : COLOR 2,220,220,220
2D_TARGET_IS 2
END

led:
  IF caption$(1)="Eteint la LED                  "
    r%=150 : v%=150 : b%=150 : caption 1,"Allume la LED                  "
  ELSE
    r%= 30 : v%=220 : b%= 30 : caption 1,"Eteint la LED                  "
  END_IF
  2D_PEN_COLOR 0,0,0 : 2D_FILL_COLOR r%-30,v%-30,b%-30 : 2D_CIRCLE 20,20,20
  2D_PEN_COLOR r%,v%,b% : 2D_FILL_COLOR r%,v%,b% : 2D_CIRCLE 18,18,16
  2D_PEN_COLOR r%+30,v%+30,b%+30 : 2D_FILL_COLOR r%+30,v%+30,b%+30 : 2D_CIRCLE 12,12,6
  2D_PEN_COLOR 255,255,255 : 2D_FILL_COLOR 255,255,255 : 2D_CIRCLE 10,10,2
RETURN

fin:
  Terminate
Revenir en haut Aller en bas
http://gpp.panoramic.free.fr
silverman

silverman


Nombre de messages : 968
Age : 51
Localisation : Picardie
Date d'inscription : 18/03/2015

SUB LED: permet d'afficher un voyant de type LED - Page 2 Empty
MessageSujet: Re: SUB LED: permet d'afficher un voyant de type LED   SUB LED: permet d'afficher un voyant de type LED - Page 2 EmptyMer 13 Mai 2015 - 22:26

salut à tous,

@Jicehel
un petit code, qui t'aidera j'espère; modifis la variable "offset" à ta convenance, cela te permettra d'encadrer des angles selon tes besoins.
Code:

dim x,y
dim cx,cy

dim cosinus

dim pi
dim rtd

dim hypotenuse

dim offset
dim angle

label trace


pi=acos(-1) : rtd=180/pi   :' radians  to degrees

timer 100
timer_interval 100,20
on_timer 100,trace

END
trace:
   cls

   x=mouse_x_position(0)
   y=mouse_y_position(0)

   cx=320
   cy=200

   hypotenuse=sqr((x-cx)*(x-cx) + (cy-y)*(cy-y))
   if hypotenuse>0
      cosinus=(x-cx)/hypotenuse
      if y>cy
         angle=180+(acos(cosinus)*rtd)
      else
         angle=180-(acos(cosinus)*rtd)
      end_if
   end_if

   offset=0-45
   print wrap_value(angle-offset)

   2d_line cx,cy,x,y

return

EDIT: à l'origine, il fallait tourner dans le sens trigonométrique, j'ai modifié le code pour que ce soit dans le même sens que le potentiomètre.

EDIT2: code re-modifié Laughing


Dernière édition par silverman le Mer 13 Mai 2015 - 23:12, édité 2 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 - Page 2 Empty
MessageSujet: Re: SUB LED: permet d'afficher un voyant de type LED   SUB LED: permet d'afficher un voyant de type LED - Page 2 EmptyMer 13 Mai 2015 - 22:53

Minibug, pour le potentiometre, tu as une idee sur comment je pourrais récupérer l'angle ou la valeur sur laquelle se trouve la souris ?

Au fait j'aime beaucoup ton bouton à l'aide. Je mets une version qui facilite un peu les réglages de taille

Code:
DIM r%,v%,b%, r_led : r_led=15

LABEL fin , led
ON_CLOSE 0,fin

PANEL 1 : top 1,1 : left 1,1 : HEIGHT 1, r_led*2+10 : WIDTH 1,200 : COLOR 1,220,220,220
CAPTION 1,"Allume la LED                  " : on_click 1,led
PICTURE 2 : PARENT 2,1 : LEFT 2,WIDTH(1)-45 : TOP 2,(HEIGHT(1)-r_led*2)/2: WIDTH 2,r_led*2 : HEIGHT 2,r_led*2 : COLOR 2,220,220,220
2D_TARGET_IS 2
END

led:
  IF CAPTION$(1)="Eteint la LED                  "
    r%=150 : v%=150 : b%=150 : CAPTION 1,"Allume la LED                  "
  ELSE
    r%= 30 : v%=220 : b%= 30 : CAPTION 1,"Eteint la LED                  "
  END_IF
  2D_PEN_COLOR 0,0,0 : 2D_FILL_COLOR r%-30,v%-30,b%-30 : 2D_CIRCLE WIDTH(2) - r_led,HEIGHT(2) - r_led,r_led
  2D_PEN_COLOR r%,v%,b% : 2D_FILL_COLOR r%,v%,b%
  2D_CIRCLE WIDTH(2) - 1.1*r_led ,HEIGHT(2)- 1.1*r_led,0.8 * r_led
  2D_PEN_COLOR r%+30,v%+30,b%+30 : 2D_FILL_COLOR r%+30,v%+30,b%+30
  2D_CIRCLE WIDTH(2) - 1.3 * r_led,HEIGHT(2) - 1.3 * r_led, 0.4 * r_led
  2D_PEN_COLOR 255,255,255 : 2D_FILL_COLOR 255,255,255
  2D_CIRCLE WIDTH(2) - 1.5 * r_led,WIDTH(2) - 1.5 * r_led,0.1 * r_led
RETURN

fin:
  TERMINATE
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 - Page 2 Empty
MessageSujet: Re: SUB LED: permet d'afficher un voyant de type LED   SUB LED: permet d'afficher un voyant de type LED - Page 2 EmptyMer 13 Mai 2015 - 22:57

Super Silverman. Oui, je pense que je devrais pouvoir y arriver avec ton code Wink
Excuses moi de ne pas t'avoir présenti pour le code, mais c'est par ce que je ne connais pas encore toutes tes aptitudes Wink
Ca ne tardera pas et je suis bien content que tu m'ais répondu. Moi perso, j'ai du mal à m'y retrouver Wink

J'essaye d'adapter et je vous tiens au courant
Revenir en haut Aller en bas
silverman

silverman


Nombre de messages : 968
Age : 51
Localisation : Picardie
Date d'inscription : 18/03/2015

SUB LED: permet d'afficher un voyant de type LED - Page 2 Empty
MessageSujet: Re: SUB LED: permet d'afficher un voyant de type LED   SUB LED: permet d'afficher un voyant de type LED - Page 2 EmptyMer 13 Mai 2015 - 23:11

@Jicehel
pas de pb!Laughing

je viens de relire le post ou tu disait que ton 0 était à -45°(et pas 45° comme j'avais cru lire). Je viens de modifier mon code de tel sorte que si tu initialises "offset" à -45, ça donne le résultat que tu as demandé. Désolé pour l'étourderie Embarassed
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 - Page 2 Empty
MessageSujet: Re: SUB LED: permet d'afficher un voyant de type LED   SUB LED: permet d'afficher un voyant de type LED - Page 2 EmptyMer 13 Mai 2015 - 23:49

Merci Silverman, j'ai utilisé ton code tel qu'il était, j'ai vu la modif trop tard.
Je pense que je pourrais simplifier le code mais ça marche.
Pour utiliser le potentiomètre, on clique dessus.
Pour changer la valeur, on se balade sur les valeurs, pour fixer la valeur, on reclic sur le potentiomètre.
Je me doute que c'est une version opérationnel et optimisable, mais pour moi, elle fonctionne et fera l'affaire. Merci à tous pour vos aides respectives
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 , hypotenuse, cosinus

LABEL Select_potentiometre, Valide_valeur, Potentiometre_maj

CAPTION 0,"Programme en cours - Potentiometre"
DIM Pi : Pi = 4*ATN(1)
DIM rtd : : rtd=180/pi
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
      A=val_max_potentiometre% / 270
      hypotenuse=SQR((delta1)*(delta1) + (delta2)*(delta2))
      IF hypotenuse>0
        cosinus=(mouse_x_position(10)-Lp%/2)/hypotenuse
        IF mouse_y_position(10) > Lp%/2
          Potentiometre_value = 180+(acos(cosinus)*rtd)
        ELSE
          Potentiometre_value = 180-(acos(cosinus)*rtd)
        END_IF
      END_IF


      IF Potentiometre_value > 315
        Potentiometre_value = Potentiometre_value - 315
      ELSE
        IF Potentiometre_value > 270 THEN Potentiometre_value = 0
        IF Potentiometre_value > 215 THEN Potentiometre_value = 215
        IF Potentiometre_value > 0 AND Potentiometre_value < 216 THEN Potentiometre_value = Potentiometre_value + 55
      END_IF
      Potentiometre_value = Potentiometre_value * A
      MAJ_potentiometre(Np%,Xp%,Yp%,Lp%,val_max_potentiometre%)
    END_IF
    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
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 - Page 2 Empty
MessageSujet: Re: SUB LED: permet d'afficher un voyant de type LED   SUB LED: permet d'afficher un voyant de type LED - Page 2 EmptyJeu 14 Mai 2015 - 0:17

désolé les gars,

Mais les angles, sinus, cosinus et tout ca, je crois que c'était les jours ou j'étais malade que l'on a appris tous ca !!!!

Donc ne comptez donc pas sur moi pour ce coup de main. Wink 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 - Page 2 Empty
MessageSujet: Re: SUB LED: permet d'afficher un voyant de type LED   SUB LED: permet d'afficher un voyant de type LED - Page 2 EmptyJeu 14 Mai 2015 - 0:57

Pas de problème, maintenant, ça fonctionne Wink c'est le plus important.
Revenir en haut Aller en bas
Jean Claude

Jean Claude


Nombre de messages : 5948
Age : 69
Localisation : 83 Var
Date d'inscription : 07/05/2009

SUB LED: permet d'afficher un voyant de type LED - Page 2 Empty
MessageSujet: Re: SUB LED: permet d'afficher un voyant de type LED   SUB LED: permet d'afficher un voyant de type LED - Page 2 EmptyJeu 14 Mai 2015 - 8:47

Bravo pour le potentiomètre, ça peut être très utile.
Bravo à Minibug qui a fait ce que je cherchais à faire.

Mon intervention d'hier visait à montrer que l'on ne pouvait pas affiché la LED et son texte de manière facile (Tu l'as bien supposé Jicehel). Le panel est une bonne solution.

A+
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 - Page 2 Empty
MessageSujet: Re: SUB LED: permet d'afficher un voyant de type LED   SUB LED: permet d'afficher un voyant de type LED - Page 2 EmptyJeu 14 Mai 2015 - 10:35

Bonjour Jean Claude,

C'est bien ce que j'avais cru comprendre hier soir !

Je que je fais, le plus souvent, pour des boutons personnalisés, j'utilise des PICTURES au lien est place des BUTTON classiques et j'y insère des images que je crées de toutes pieces.

Seule contrainte, il faut charger les images dans le programme au début.
Alors que là, on a un bouton sans aucun fichier, c'est l'avantage.
Revenir en haut Aller en bas
http://gpp.panoramic.free.fr
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 - Page 2 Empty
MessageSujet: Re: SUB LED: permet d'afficher un voyant de type LED   SUB LED: permet d'afficher un voyant de type LED - Page 2 EmptyJeu 14 Mai 2015 - 10:51

Concernant les potentiomètres, voici encore un code repris de ceux ci_dessus.

ATTENTION, il faut utiliser l'image du bouton 1 de Bignono.

Pour monter ou descendre il faut laisser le bouton gauche appuyé.
La partie de gauche du potentiomètre : on monte
La partie droite : on baisse...

A vos tests !!! cheers

Code:
dim rep$ , j
j=-4.6

label turn1

rep$=DIR_CURRENT$+"\"

width 0,600:height 0,150:left 0,(screen_x-width(0))/2:top 0,(screen_y-40-height(0))/2
 
' Bouton 1
container 1:width 1,105:height 1,115:left 1,5:top 1,5
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

timer 101:timer_interval 101,1:on_timer 101,turn1

end

turn1:
  TIMER_OFF 101
  2d_target_is 2:2d_pen_width 5
  WHILE scancode<>0
      IF MOUSE_X_POSITION(2)<WIDTH(2)/2
        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)
      ELSE
        2d_pen_color 0,0,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<-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
      caption 1," VOLUME: "+str$(j+4.6)+chr$(32)
      wait 50
  END_WHILE
  TIMER_ON 101
return
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 - Page 2 Empty
MessageSujet: Re: SUB LED: permet d'afficher un voyant de type LED   SUB LED: permet d'afficher un voyant de type LED - Page 2 EmptyJeu 14 Mai 2015 - 11:41

Juste un conseil, ne mettais JAMAIS vos timer à 1. Bignono le fait souvent mais c'est très mauvais (désolé) C'est beaucoup trop court et si l'ordinateur est occupé, il n'y a rien de mieux pour remplir la pile et faire crasher un programme. Qui peut cliquer durant 1ms ? Quand on clique, on approche plutot de la demi - seconde, mais en effet si on mets un timer à 500, la détection marcherait mal, on peut tout à fait faire un programme qui fonctionne bien en mettant un timer à 200 ou si l'on veut vraiment de la réactivité, à 50. C'est tout bête mais ça laisse un peu de temsp au programme pour gérer l'évenement voir pour vider un peu la pile.

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 - Page 2 Empty
MessageSujet: Re: SUB LED: permet d'afficher un voyant de type LED   SUB LED: permet d'afficher un voyant de type LED - Page 2 EmptyJeu 14 Mai 2015 - 12:33

Bonjour Jicehel !

Je ne le fais jamais non plus.
mais là comme je l'ai dit j'ai repris les codes précédents et je n'ai pas modifier.

Pour le timer, je code la valeur minimum a 50 ou 100. parfois plus selon les besoins.
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 - Page 2 Empty
MessageSujet: Re: SUB LED: permet d'afficher un voyant de type LED   SUB LED: permet d'afficher un voyant de type LED - Page 2 EmptyJeu 14 Mai 2015 - 12:43

OK Minibug Wink Pas de problème, comme c'était dans le dernier code que tu as reprit, j'en profitais juste pour faire un rappel sur ces mauits timer s qui sont si pratiques mais qui nécessite beaucoup de vigileance dans leurs utilisation pour éviter les plantage ou les comportements bizzares.
Revenir en haut Aller en bas
Contenu sponsorisé





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

Revenir en haut Aller en bas
 
SUB LED: permet d'afficher un voyant de type LED
Revenir en haut 
Page 2 sur 2Aller à la page : Précédent  1, 2
 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: