IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Déploiement/Installation Python Discussion :

wordclock diy en python et Raspberry


Sujet :

Déploiement/Installation Python

  1. #41
    Futur Membre du Club
    Homme Profil pro
    diy
    Inscrit en
    Septembre 2020
    Messages
    61
    Points
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : diy
    Secteur : Arts - Culture

    Informations forums :
    Inscription : Septembre 2020
    Messages : 61
    Points : 7
    Par défaut
    Citation Envoyé par josmiley Voir le message
    arf, oui ...
    remplace get_color comme suit:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    def get_color():
        R,G,B = list_color[index_color]
        return (int(R*current_bright),int(G*current_bright),int(B*current_bright))
    un code de retour plus long
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    pi@raspberrypi:~/piLedClock/rpi_ws281x/python $ sudo python wordclock.py
    Press Ctrl-C to quit.
    Use "-c" argument to clear LEDs on exit
    IL EST TROIS HEURES DIX . . .
    Traceback (most recent call last):
      File "wordclock.py", line 132, in <module>
        showArray(strip, get_color(), convert(*getHour()))
      File "wordclock.py", line 102, in showArray
        strip.setPixelColor(i, color if (i+1) in array else Color(0,0,0))
      File "/home/pi/piLedClock/rpi_ws281x/python/neopixel.py", line 118, in setPixelColor
        self._led_data[n] = color
      File "/home/pi/piLedClock/rpi_ws281x/python/neopixel.py", line 49, in __setitem__
        return ws.ws2811_led_set(self.channel, pos, value)
    TypeError: in method 'ws2811_led_set', argument 3 of type 'uint32_t'

  2. #42
    Membre expérimenté
    Homme Profil pro
    Inscrit en
    Avril 2004
    Messages
    1 065
    Points
    1 403
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 1 065
    Points : 1 403
    Par défaut
    ok ça doit accepter que des strip.Color

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    def get_color():
        R,G,B = list_color[index_color]
        return Color(int(R*current_bright),int(G*current_bright),int(B*current_bright))

  3. #43
    Futur Membre du Club
    Homme Profil pro
    diy
    Inscrit en
    Septembre 2020
    Messages
    61
    Points
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : diy
    Secteur : Arts - Culture

    Informations forums :
    Inscription : Septembre 2020
    Messages : 61
    Points : 7
    Par défaut
    ça marche!!!
    trop fort

  4. #44
    Membre expérimenté
    Homme Profil pro
    Inscrit en
    Avril 2004
    Messages
    1 065
    Points
    1 403
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 1 065
    Points : 1 403
    Par défaut
    faudrait savoir si on peut détecter les fronts montants sur les pins.
    Si oui, alors on change la luminosité sur les fronts montants et on mesure le temps d'état bas pour éteindre les LEDs.

  5. #45
    Futur Membre du Club
    Homme Profil pro
    diy
    Inscrit en
    Septembre 2020
    Messages
    61
    Points
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : diy
    Secteur : Arts - Culture

    Informations forums :
    Inscription : Septembre 2020
    Messages : 61
    Points : 7
    Par défaut
    Citation Envoyé par josmiley Voir le message
    faudrait savoir si on peut détecter les fronts montants sur les pins.
    Si oui, alors on change la luminosité sur les fronts montants et on mesure le temps d'état bas pour éteindre les LEDs.
    c'est quoi les fronts montants?
    sinon... j'ai l'impression que le truc meteo ça va etre vraiment casse tête... je me trompe? le 3eme bouton pourrais dès lors servir à éteindre les led.... (ou à lancer une anim strandtest trop cool )

  6. #46
    Membre expérimenté
    Homme Profil pro
    Inscrit en
    Avril 2004
    Messages
    1 065
    Points
    1 403
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 1 065
    Points : 1 403
    Par défaut
    Détecter quand tu relâches le bouton, pas quand appuies.

  7. #47
    Futur Membre du Club
    Homme Profil pro
    diy
    Inscrit en
    Septembre 2020
    Messages
    61
    Points
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : diy
    Secteur : Arts - Culture

    Informations forums :
    Inscription : Septembre 2020
    Messages : 61
    Points : 7
    Par défaut
    si j'essaye ça c'est correct?
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
        try:
            while True:
     
                if datetime.now().second == 0:
     
                    output = convert(*getHour())
                    print(output)
                    showArray(strip, get_color(), convert(*getHour()))
     
                entreepin24 = GPIO.input(24)
                if (entreepin24 == False):
                    print ('PIN24')
                    current_bright = round((current_bright+.1)%1.1,1) or .1
                    # met à jour au cas de dépassement de minute
                    showArray(strip, get_color(), convert(*getHour()))
     
                entreepin22 = GPIO.input(22)
                if (entreepin22 == False):
                    print ('PIN22')
                    index_color = (index_color+1)%len(list_color)
                    # met à jour au cas de dépassement de minute
                    showArray(strip, get_color(), convert(*getHour()))
     
                entreepin17 = GPIO.input(17)
                if (entreepin17 == False):
                    print ('PIN17') 
                     current_bright = 0
                    showArray(strip, get_color(), convert(*getHour()))
                time.sleep(temps / 1000)

  8. #48
    Membre expérimenté
    Homme Profil pro
    Inscrit en
    Avril 2004
    Messages
    1 065
    Points
    1 403
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 1 065
    Points : 1 403
    Par défaut
    coder un peu à l'arrache ...
    appui long(ou presque) pour éteindre

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
     
    delay_low       = 0
     
    pin17state      = True
     
    if __name__ == '__main__':
        # Process arguments
        parser = argparse.ArgumentParser()
        parser.add_argument('-c', '--clear', action='store_true', help='clear the display on exit')
        args = parser.parse_args()
     
        # Create NeoPixel object with appropriate configuration.
        strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS, LED_CHANNEL)
        # Intialize the library (must be called once before other functions).
        strip.begin()
     
        print ('Press Ctrl-C to quit.')
        if not args.clear:
            print('Use "-c" argument to clear LEDs on exit')
     
        # attendre si on est moins d'une seconde de la minute suivante
        while datetime.now().second == 59: continue
        showArray(strip, get_color(), convert(*getHour()))
     
        try:
            while True:
     
     
                if datetime.now().second == 0:
     
                    output = convert(*getHour())
                    print(output)
                    showArray(strip, get_color(), convert(*getHour()))
     
                entreepin17 = GPIO.input(17)
                if (entreepin17 == True) and not pin17state:
                    pin17state = True
                    delay_low = 0
                    current_bright = round((current_bright+.1)%1.1,1) or .1
                    # met à jour au cas de dépassement de minute
                    showArray(strip, get_color(), convert(*getHour()))
                if (entreepin17 == False):
                    pin17state = False
                    print ('PIN17')
                    delay_low += 1
                if delay_low == 20: # valeur à ajuster
                    colorWipe(strip, Color(0,0,0), 10)
                    current_bright = round((current_bright-.1),1)
                    pin17state = True
                    while not GPIO.input(17): pass
     
                entreepin22 = GPIO.input(22)
                if (entreepin22 == False):
                    print ('PIN22')
                    index_color = (index_color+1)%len(list_color)
                    # met à jour au cas de dépassement de minute
                    showArray(strip, get_color(), convert(*getHour()))
     
                entreepin24 = GPIO.input(24)
                if (entreepin24 == False):
                    print ('PIN24') 
                    # met à jour au cas de dépassement de minute
                    showArray(strip, Color(50,50,50), convert(*getHour()))
                time.sleep(temps / 1000)
     
        except KeyboardInterrupt:
                if args.clear:
                     colorWipe(strip, Color(0,0,0), 10)

  9. #49
    Futur Membre du Club
    Homme Profil pro
    diy
    Inscrit en
    Septembre 2020
    Messages
    61
    Points
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : diy
    Secteur : Arts - Culture

    Informations forums :
    Inscription : Septembre 2020
    Messages : 61
    Points : 7
    Par défaut
    ben codé à l'arrache mais ça marche! ça s'eteind bien.... par contre ce serait bien de pouvoir la rallumer de la meme manière ;-)
    sinon... comment je fait pour lancer ça au démarage du pi? j'ai testé ça https://raspberry-pi.fr/executer-programme-demarrage/ sans succès...

    edit : du coup il termine comme ceci aussi :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    IL EST CINQ HEURES .
    [100, 101, 103, 104, 105, 70, 69, 68, 67, 50, 49, 48, 47, 46, 45, 111]
    IL EST CINQ HEURES .
    Traceback (most recent call last):
      File "wordclock.py", line 146, in <module>
        showArray(strip, get_color(), convert(*getHour()))
      File "wordclock.py", line 102, in showArray
        strip.setPixelColor(i, color if (i+1) in array else Color(0,0,0))
      File "/home/pi/piLedClock/rpi_ws281x/python/neopixel.py", line 118, in setPixelColor
        self._led_data[n] = color
      File "/home/pi/piLedClock/rpi_ws281x/python/neopixel.py", line 49, in __setitem__
        return ws.ws2811_led_set(self.channel, pos, value)
    OverflowError: in method 'ws2811_led_set', argument 3 of type 'uint32_t'

  10. #50
    Membre expérimenté
    Homme Profil pro
    Inscrit en
    Avril 2004
    Messages
    1 065
    Points
    1 403
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 1 065
    Points : 1 403
    Par défaut
    ça devrait rallumer maintenant avec un appui bref:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
                entreepin17 = GPIO.input(17)
                if (entreepin17 == True) and not pin17state:
                    pin17state = True
                    delay_low = 0
                    current_bright = round((current_bright+.1)%1.1,1) or .1
                    # met à jour au cas de dépassement de minute
                    showArray(strip, get_color(), convert(*getHour()))
                if (entreepin17 == False):
                    pin17state = False
                    print ('PIN17')
                    delay_low += 1
                if delay_low == 20: # valeur à ajuster
                    colorWipe(strip, Color(0,0,0), 10)
                    current_bright = round((current_bright-.1),1)
                    while not GPIO.input(17): pass

  11. #51
    Futur Membre du Club
    Homme Profil pro
    diy
    Inscrit en
    Septembre 2020
    Messages
    61
    Points
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : diy
    Secteur : Arts - Culture

    Informations forums :
    Inscription : Septembre 2020
    Messages : 61
    Points : 7
    Par défaut
    sans succès.... pas certain de l'avoir bien intégré...
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
     
    #a lancer avec cd piLedClock/rpi_ws281x/python
    #et sudo python3 wordclock.py
    from datetime import datetime
    from time import sleep
    from neopixel import *
    import argparse
    import RPi.GPIO as GPIO                 #bibliothèque RPi.GPIO
    import time                             #bibliothèque time
     
    # LED strip configuration:
    LED_COUNT      = 114      # Number of LED pixels.
    LED_PIN        = 18      # GPIO pin connected to the pixels (18 uses PWM!).
    #LED_PIN        = 10      # GPIO pin connected to the pixels (10 uses SPI /dev/spidev0.0).
    LED_FREQ_HZ    = 800000  # LED signal frequency in hertz (usually 800khz)
    LED_DMA        = 10      # DMA channel to use for generating signal (try 10)
    LED_BRIGHTNESS = 255     # Set to 0 for darkest and 255 for brightest
    LED_INVERT     = False   # True to invert the signal (when using NPN transistor level shift)
    LED_CHANNEL    = 0       # set to '1' for GPIOs 13, 19, 41, 45 or 53
    #-------------------------------------------------------------------------------
    pin = 17, 22, 24                                        #broche utilisé en entrée
    #temps = 1                                              #valeur attente en msec
    #temps = 10
    temps = 100
    #temps = 100
    #temps = 1000
    GPIO.setwarnings(False)                                 #désactive le mode warning
    GPIO.setmode(GPIO.BCM)                                  #utilisation des numéros de ports du
                                                            #processeur
    GPIO.setup(pin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
                                                            #mise en entrée du port GPIO 22
                                                            #et activation résistance soutirage
                                                            #au ground
     
     
    panel    = \
    "\
    ILNESTODEUX\
    QUATRETROIS\
    NEUFUNESEPT\
    HUITSIXCINQ\
    MIDIXMINUIT\
    ONZERHEURES\
    MOINSOLEDIX\
    ETRQUARTPMD\
    TRENTEOURXT\
    VINGT-CINQU\
    ....\
    "
     
     
    # stripLettre est la liste des LEDs en fonction de l'ordre des lettres dans panel
    # tient compte du tortillement du ruban
    stripLettre = list(range(110,0,-1))
    for i in range(0,110,22): stripLettre[i:i+11] = stripLettre[i:i+11][::-1]
    stripDot    = [111, 114, 113, 112]
    stripLettre += stripDot
     
     
    def convert(heure,minute):
        """convertit l'heure en texte, recherche chaque terme dans le panel,
        et utilise l'index des mots pour extraire dans stripLettre les numéros des leds à allumer"""
     
        heure   = (heure+(minute>=35))%24
        liaison = heure%12>1 and'HEURES'or heure%12 and'HEURE'or''
        heure   = (heure//12 and'MIDI'or'MINUIT','UNE','DEUX','TROIS','QUATRE','CINQ','SIX','SEPT','HUIT','NEUF','DIX','ONZE')[heure%12]
        dot     = ' . . . .'[:minute%5*2]
        minute  = ('','CINQ','DIX','ET QUART','VINGT','VINGT-CINQ','TRENTE','TRENTE CINQ','MOINS VINGT','MOINS LE QUART','MOINS DIX','MOINS CINQ')[minute//5]
        litt    = f'IL EST {heure}'
        if liaison: litt = litt + ' ' + liaison
        if minute : litt = litt + ' ' + minute
        litt += dot
        print(litt)
        output  = []
        index   = 0
        for mot in litt.split():
            i = panel.find(mot,index)
            output.extend(stripLettre[i:i+len(mot)])
            index = i + len(mot)
        return output
     
     
    def getHour():
     
        maintenant = datetime.now()
        heure      = maintenant.hour
        minute     = maintenant.minute
        return heure,minute
     
     
    # Define functions which animate LEDs in various ways.
    def colorWipe(strip, color, wait_ms=50):
        """Wipe color across display a pixel at a time."""
        for i in range(strip.numPixels()):
            strip.setPixelColor(i, color)
            strip.show()
            sleep(wait_ms/1000.0)
     
    #Show array
    def showArray(strip, color, array):
        array = set(array)
        for i in range(strip.numPixels()):
            strip.setPixelColor(i, color if (i+1) in array else Color(0,0,0))
        strip.show() 
     
     
    def get_color():
        R,G,B = list_color[index_color]
        return Color(int(R*current_bright),int(G*current_bright),int(B*current_bright))
     
    list_color      = [(253, 51, 100), (138, 36, 177), (240, 120, 228), (129, 77, 86), (111, 147, 168), (221, 254, 42), (152, 216, 39), (166, 165, 158), (144, 44, 102), (236, 25, 252)]
    index_color     = 0
    current_bright  = 1
     
     
    delay_low       = 0
     
    pin17state      = True
     
    if __name__ == '__main__':
        # Process arguments
        parser = argparse.ArgumentParser()
        parser.add_argument('-c', '--clear', action='store_true', help='clear the display on exit')
        args = parser.parse_args()
     
        # Create NeoPixel object with appropriate configuration.
        strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS, LED_CHANNEL)
        # Intialize the library (must be called once before other functions).
        strip.begin()
     
        print ('Press Ctrl-C to quit.')
        if not args.clear:
            print('Use "-c" argument to clear LEDs on exit')
     
        # attendre si on est moins d'une seconde de la minute suivante
        while datetime.now().second == 59: continue
        showArray(strip, get_color(), convert(*getHour()))
     
        try:
            while True:
     
     
                if datetime.now().second == 0:
     
                    output = convert(*getHour())
                    print(output)
                    showArray(strip, get_color(), convert(*getHour()))
     
                entreepin17 = GPIO.input(17)
                if (entreepin17 == True) and not pin17state:
                    pin17state = True
                    delay_low = 0
                    current_bright = round((current_bright+.1)%1.1,1) or .1
                    # met à jour au cas de dépassement de minute
                    showArray(strip, get_color(), convert(*getHour()))
                if (entreepin17 == False):
                    pin17state = False
                    print ('PIN17')
                    delay_low += 1
                if delay_low == 20: # valeur à ajuster
                    colorWipe(strip, Color(0,0,0), 10)
                    current_bright = round((current_bright-.1),1)
                    while not GPIO.input(17): pass
                if (entreepin17 == False):
                    pin17state = False
                    print ('PIN17')
                    delay_low += 1
                if delay_low == 20: # valeur à ajuster
                    colorWipe(strip, Color(0,0,0), 10)
                    current_bright = round((current_bright-.1),1)
                    pin17state = True
                    while not GPIO.input(17): pass
     
                entreepin22 = GPIO.input(22)
                if (entreepin22 == False):
                    print ('PIN22')
                    index_color = (index_color+1)%len(list_color)
                    # met à jour au cas de dépassement de minute
                    showArray(strip, get_color(), convert(*getHour()))
     
                entreepin24 = GPIO.input(24)
                if (entreepin24 == False):
                    print ('PIN24') 
                    # met à jour au cas de dépassement de minute
                    showArray(strip, Color(50,50,50), convert(*getHour()))
                time.sleep(temps / 1000)
     
        except KeyboardInterrupt:
                if args.clear:
                     colorWipe(strip, Color(0,0,0), 10)

  12. #52
    Membre expérimenté
    Homme Profil pro
    Inscrit en
    Avril 2004
    Messages
    1 065
    Points
    1 403
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 1 065
    Points : 1 403
    Par défaut
    faut retirer les lignes 164 à 172, elles sont en double

  13. #53
    Futur Membre du Club
    Homme Profil pro
    diy
    Inscrit en
    Septembre 2020
    Messages
    61
    Points
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : diy
    Secteur : Arts - Culture

    Informations forums :
    Inscription : Septembre 2020
    Messages : 61
    Points : 7
    Par défaut
    alors ça s'éteind effectivement mais ça se rallume directement dans la foulée

  14. #54
    Membre expérimenté
    Homme Profil pro
    Inscrit en
    Avril 2004
    Messages
    1 065
    Points
    1 403
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 1 065
    Points : 1 403
    Par défaut
    normalement ça devrait fonctionner, possible qu'il y ait un rebond ...

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    if __name__ == '__main__':
        # Process arguments
        parser = argparse.ArgumentParser()
        parser.add_argument('-c', '--clear', action='store_true', help='clear the display on exit')
        args = parser.parse_args()
     
        # Create NeoPixel object with appropriate configuration.
        strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS, LED_CHANNEL)
        # Intialize the library (must be called once before other functions).
        strip.begin()
     
        print ('Press Ctrl-C to quit.')
        if not args.clear:
            print('Use "-c" argument to clear LEDs on exit')
     
        # attendre si on est moins d'une seconde de la minute suivante
        while datetime.now().second == 59: continue
        showArray(strip, get_color(), convert(*getHour()))
     
        try:
            while True:
     
     
                if datetime.now().second == 0:
     
                    output = convert(*getHour())
                    print(output)
                    showArray(strip, get_color(), convert(*getHour()))
     
                entreepin17 = GPIO.input(17)
                if (entreepin17 == True) and not pin17state:
                    pin17state = True
                    delay_low = 0
                    current_bright = round((current_bright+.1)%1.1,1) or .1
                    # met à jour au cas de dépassement de minute
                    showArray(strip, get_color(), convert(*getHour()))
                if (entreepin17 == False):
                    pin17state = False
                    print ('PIN17')
                    delay_low += 1
                if delay_low == 20: # valeur à ajuster
                    colorWipe(strip, Color(0,0,0), 10)
                    current_bright = round((current_bright-.1),1)
                    while not GPIO.input(17): pass
                    pin17state = True
     
                entreepin22 = GPIO.input(22)
                if (entreepin22 == False):
                    print ('PIN22')
                    index_color = (index_color+1)%len(list_color)
                    # met à jour au cas de dépassement de minute
                    showArray(strip, get_color(), convert(*getHour()))
     
                entreepin24 = GPIO.input(24)
                if (entreepin24 == False):
                    print ('PIN24') 
                    # met à jour au cas de dépassement de minute
                    showArray(strip, Color(50,50,50), convert(*getHour()))
                time.sleep(temps / 1000)
     
        except KeyboardInterrupt:
                if args.clear:
                     colorWipe(strip, Color(0,0,0), 10)

  15. #55
    Futur Membre du Club
    Homme Profil pro
    diy
    Inscrit en
    Septembre 2020
    Messages
    61
    Points
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : diy
    Secteur : Arts - Culture

    Informations forums :
    Inscription : Septembre 2020
    Messages : 61
    Points : 7
    Par défaut
    ok..... en fait ça fonctionne.... faut juste que j'appuie super super vite sur le boutton...

  16. #56
    Membre expérimenté
    Homme Profil pro
    Inscrit en
    Avril 2004
    Messages
    1 065
    Points
    1 403
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 1 065
    Points : 1 403
    Par défaut
    au bout de combien de temps ça s'éteint ?

    Citation Envoyé par 7ced7 Voir le message
    ok..... en fait ça fonctionne.... faut juste que j'appuie super super vite sur le boutton...
    modifie la ligne suivante, essaye d'autres valeurs genre 50, 100 ou 200, etc ...
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
                if delay_low == 20: # valeur à ajuster

  17. #57
    Futur Membre du Club
    Homme Profil pro
    diy
    Inscrit en
    Septembre 2020
    Messages
    61
    Points
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : diy
    Secteur : Arts - Culture

    Informations forums :
    Inscription : Septembre 2020
    Messages : 61
    Points : 7
    Par défaut
    Citation Envoyé par josmiley Voir le message
    au bout de combien de temps ça s'éteint ?



    modifie la ligne suivante, essaye d'autres valeurs genre 50, 100 ou 200, etc ...
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
                if delay_low == 20: # valeur à ajuster
    en fait on doit du coup pousser super longtemps pour eteindre..... je dois trouver le juste milieu....
    pour le lancer au demarage?

  18. #58
    Membre expérimenté
    Homme Profil pro
    Inscrit en
    Avril 2004
    Messages
    1 065
    Points
    1 403
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 1 065
    Points : 1 403
    Par défaut
    Citation Envoyé par 7ced7 Voir le message
    en fait on doit du coup pousser super longtemps pour eteindre..... je dois trouver le juste milieu....
    pour le lancer au demarage?
    est-ce que ça modifie aussi le temps pour le rallumer ? théoriquement avec temps = 100 et une valeur de 20, faut appuyer 2 secondes pour éteindre, et un appui de moins de 2 secondes suffit à le rallumer. Je ne comprends pas pourquoi tu dois appuyer super super vite


    https://raspberry-pi.fr/executer-pro...20votre%20PC).

  19. #59
    Futur Membre du Club
    Homme Profil pro
    diy
    Inscrit en
    Septembre 2020
    Messages
    61
    Points
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : diy
    Secteur : Arts - Culture

    Informations forums :
    Inscription : Septembre 2020
    Messages : 61
    Points : 7
    Par défaut
    [QUOTE=josmiley;11615992]est-ce que ça modifie aussi le temps pour le rallumer ? théoriquement avec temps = 100 et une valeur de 20, faut appuyer 2 secondes pour éteindre, et un appui de moins de 2 secondes suffit à le rallumer. Je ne comprends pas pourquoi tu dois appuyer super super vite


    bon.... j'ai mis 100 et 15... je crois que c'est le meilleur compromis.... je dois chipoter à chaque fois mais ça marche...

  20. #60
    Membre expérimenté
    Homme Profil pro
    Inscrit en
    Avril 2004
    Messages
    1 065
    Points
    1 403
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 1 065
    Points : 1 403
    Par défaut
    je viens de me rendre compte que ça doit se rallumer à la minute suivante ...

    ça devrait aller mieux ...

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    if __name__ == '__main__':
        # Process arguments
        parser = argparse.ArgumentParser()
        parser.add_argument('-c', '--clear', action='store_true', help='clear the display on exit')
        args = parser.parse_args()
     
        # Create NeoPixel object with appropriate configuration.
        strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS, LED_CHANNEL)
        # Intialize the library (must be called once before other functions).
        strip.begin()
     
        print ('Press Ctrl-C to quit.')
        if not args.clear:
            print('Use "-c" argument to clear LEDs on exit')
     
        # attendre si on est moins d'une seconde de la minute suivante
        while datetime.now().second == 59: continue
        showArray(strip, get_color(), convert(*getHour()))
     
        try:
            while True:
     
     
                if datetime.now().second == 0:
     
                    output = convert(*getHour())
                    print(output)
                    showArray(strip, get_color(), convert(*getHour()))
     
                entreepin17 = GPIO.input(17)
                if (entreepin17 == True) and not pin17state:
                    pin17state = True
                    delay_low = 0
                    current_bright = round((current_bright+.1)%1.1,1) or .1
                    # met à jour au cas de dépassement de minute
                    showArray(strip, get_color(), convert(*getHour()))
                if (entreepin17 == False):
                    pin17state = False
                    print ('PIN17')
                    delay_low += 1
                if delay_low == 20: # valeur à ajuster
                    colorWipe(strip, Color(0,0,0), 10)
                    current_bright = round((current_bright-.1),1)
                    while not GPIO.input(17): pass
                    time.sleep(temps / 1000) # anti rebond
                    while GPIO.input(17): pass
     
                entreepin22 = GPIO.input(22)
                if (entreepin22 == False):
                    print ('PIN22')
                    index_color = (index_color+1)%len(list_color)
                    # met à jour au cas de dépassement de minute
                    showArray(strip, get_color(), convert(*getHour()))
     
                entreepin24 = GPIO.input(24)
                if (entreepin24 == False):
                    print ('PIN24') 
                    # met à jour au cas de dépassement de minute
                    showArray(strip, Color(50,50,50), convert(*getHour()))
                time.sleep(temps / 1000)
     
        except KeyboardInterrupt:
                if args.clear:
                     colorWipe(strip, Color(0,0,0), 10)

Discussions similaires

  1. Python sur raspberry et POST
    Par joseph20480 dans le forum Général Python
    Réponses: 0
    Dernier message: 04/02/2018, 01h34
  2. Python Tweepy Raspberry
    Par pi3dany dans le forum Raspberry Pi
    Réponses: 4
    Dernier message: 14/03/2017, 19h54
  3. conseils pour serveur python sur raspberry
    Par nma dans le forum Raspberry Pi
    Réponses: 1
    Dernier message: 12/11/2016, 14h34
  4. Conenxion SSH python et raspberry
    Par Stoufiler dans le forum Réseau/Web
    Réponses: 4
    Dernier message: 14/06/2015, 18h24
  5. Python et Raspberry
    Par Horizon1956 dans le forum Raspberry Pi
    Réponses: 1
    Dernier message: 14/12/2014, 14h09

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo