コード例 #1
0
            oled.show()
            sleep(0.01)
            draw.rectangle(
                (BORDER, BORDER, oled.width - BORDER - 1,
                 oled.height - BORDER - 1),
                outline=0,
                fill=0,
            )


# GPIO pins on the raspberry for the LED&KEY display
STB = 14
CLK = 15
DIO = 18

TM = TMBoards(DIO, CLK, STB, 0)
TM.clearDisplay()

num_left = 1234
num_right = 5678

workout = -1
count = 0
key = " "
result = 0
score = 0
message = " "
player = "f20v/Player2"

# GPIO pins on the raspberry for the buttons on the breadboard
yes_button = Button(16)
コード例 #2
0
from time import sleep
from rpi_TM1638 import TMBoards
#pin en BCM
#IMPORTANTE YA QUE SE VA A RECIRBIR INFORMACION DEL MODULO ES NECESARIO CONECTAR A 3.3V
STB = 14
CLK = 15
DIO = 18

TM = TMBoards(DIO, CLK, STB, 0)
TM.clearDisplay()

#variable de despligue en 7 seg controlada por botones
num_left = 0

TM.segments[0] = '0'  #valor inicial

while True:  #ciclo infinito aguarda la pulsacion de un boton
    if TM.switches[0]:  #propiedad para acceder a los botones
        TM.leds[0] = True  #uso de led
        sleep(0.25)  #timepo para visualizar y operacion correcta
        TM.leds[0] = False
        if num_left > 0:  #resta de unidad y despligue en display, no tabaja para nuemeros negativos
            num_left -= 1
            TM.clearDisplay()
            TM.segments[0] = str(num_left)
    if TM.switches[1]:  #incremento de unidad y despligue en display
        TM.leds[1] = True
        sleep(0.25)
        TM.leds[1] = False
        num_left += 1
        TM.clearDisplay()
コード例 #3
0
ファイル: tmOff.py プロジェクト: JoshuaHernandezAl/PaginaRasp
#importacion de modulos
from time import sleep
from rpi_TM1638 import TMBoards  #imprtante cambio de biblioteca/modulo de TM1638 a rpi_TM1638
import random

#numeros de piens a usar en BCM para TMBoards
DIO = 19
CLK = 13
STB = 26
#intanciacion en TMBoards se incia los pin desabilitados con 0
TM = TMBoards(DIO, CLK, STB, 0)

#metodo limpieza de display similiar a clear.py
TM.clearDisplay()
TM.leds[1] = False
TM.leds[3] = False
TM.leds[5] = False
TM.leds[7] = False

TM.leds[0] = False
TM.leds[2] = False
TM.leds[4] = False
TM.leds[6] = False
TM.clearDisplay()
コード例 #4
0
from rpi_TM1638 import TMBoards
from time import sleep
import sys

DIO = 19
CLK = 13
STB = 26
TM = TMBoards(DIO, CLK, STB, 0)

TM.clearDisplay()
s=0
m=0
h=0 
try:
      while True:#ciclo infinito
            TM.segments[2]='.'#despligue en 7 segmentos
            TM.segments[5]='.'
            TM.segments[3]='{:02d}'.format(abs(m))#dar formato a dos decimales con .format de modo que se depligue 00.00.00
            TM.segments[6]='{:02d}'.format(abs(s))
            TM.segments[0]='{:02d}'.format(abs(h))
            s+=1
            if s ==60:#para proposito de prueba 5 seg hacen un minuto 2 min hacen una hora
                  s=0
                  m+=1
                  if m==60:
                        seg=0
                        m=0
                        h+=1
                        if h==24:
                              TM.clearDisplay()
                              TM.segments[0]='Adios'
コード例 #5
0
ファイル: test_TM.py プロジェクト: plop3/rpi-TM1638
# coding=utf-8
from time import sleep
from rpi_TM1638 import TMBoards

# my GPIO settings (two TM1638 boards connected on GPIO19 and GPIO13 for DataIO and Clock; and on GPIO06 and GPIO26 for the STB)
DIO = 19
CLK = 13
#STB = 06, 26
STB = 6

# instanciante my TMboards
TM = TMBoards(DIO, CLK, STB, 0)

TM.clearDisplay()

# some LEDs manipulation
TM.leds[0] = True  # turn on led 0 (1st led of the 1st board)
#TM.leds[12] = True      # turn on led 12 (5th led of the 2nd board, since there is 8 leds per board)

TM.segments[
    1] = '0'  # display '0' on the display 1 (2nd 7-segment display of the 1st board)
TM.segments[
    4] = '98.76'  # display '9876' on the 7-segment display number 4, 5, 6 and 7 (the point is on segment 5)
TM.segments[3, 1] = True  # turn on the segment #1 of the 7-segment number 3

#TM.segments[8] = '01234567'
#TM.leds = (True, False, True)   # set the three first leds

#
while True:
    a = TM.getData(0)
コード例 #6
0
from time import sleep
from rpi_TM1638 import TMBoards
import math
import sys

STB = 14
CLK = 15
DIO = 18

TM = TMBoards(DIO, CLK, STB, 0)
TM.clearDisplay()
''' 
s0->+
s1-> -
s2-> *
s3-> /
s4-> raiz
s5-> potencia
s6-> borrar display
s7-> salir
'''
#menu de opciones
print(
    "s0->+\ns1-> -\ns2-> *\ns3-> /\ns4-> raiz\ns5-> potencia\ns6-> borrar display\ns7-> salir"
)
num_left = 0
TM.segments[0] = '0'  #valor inicial
while True:
    a = int(input("Ingresa a: "))  #solicitud al usuario
    b = int(input("Ingresa b: "))
    while True:
コード例 #7
0
ファイル: clock.py プロジェクト: josedaidone/smart-clock
# queijo

from time import sleep
import sys, time
from rpi_TM1638 import TMBoards
from daemon import Daemon

DIO = 17
CLK = 27
STB = [22]

TM = TMBoards(DIO, CLK, STB, 5)


class MyDaemon(Daemon):
    def run(self, msg):
        if msg:
            setTxt(msg)
        horse(1, 20)
        antes = time.localtime()
        while (True):
            now = time.localtime()
            nowtxt = time.strftime("%H %M %S", now)
            if antes.tm_hour != now.tm_hour:
                antes = now
                if now.tm_hour == 19:
                    setTxt("sete horas - beijnho ba bunda")
                elif now.tm_hour == 20:
                    setTxt("ja sao oito - hora de comer biscoito")
            else:
                setMsg(nowtxt)
コード例 #8
0
from string import *
import random
import datetime
import time
import obd

try:
    import _rpi_ws281x as ws
    from rpi_TM1638 import TMBoards
    hasgpio = True

    DIO = 17
    CLK = 27
    STB = 22, 23

    TM = TMBoards(DIO, CLK, STB, 0)
    LED_CHANNEL = 0
    LED_COUNT = 24  # How many LEDs to light.
    LED_FREQ_HZ = 800000  # Frequency of the LED signal.  Should be 800khz or 400khz.
    LED_DMA_NUM = 5  # DMA channel to use, can be 0-14.
    LED_GPIO = 18  # GPIO connected to the LED signal line.  Must support PWM!
    LED_BRIGHTNESS = 255  # Set to 0 for darkest and 255 for brightest
    LED_INVERT = 0  # Set to 1 to invert the LED signal, good if using NPN
    # transistor as a 3.3V->5V level converter.  Keep at 0
    # for a normal/non-inverted signal.

    # Define colors which will be used by the example.  Each color is an unsigned
    # 32-bit value where the lower 24 bits define the red, green, blue data (each
    # being 8 bits long).
    DOT_COLORS = [
        0x200000,  # red
コード例 #9
0
from pymata_aio.constants import Constants
# TM1638
from rpi_TM1638 import TMBoards

board = PyMata3(com_port='/dev/Firmata')
SERIAL = "/dev/MySensors"

DEPLACEMENT = False
ARRETURG = False

# TM1638
DIO = 19
CLK = 13
STB = 6

TM = TMBoards(DIO, CLK, STB, 0)

#Adresses I2c
#26 	LCD
#27		Clavier matriciel 4x4

APA = 18  # LEDs néopixel
LCDBCK = 4  # Rétro-éclairage LCD
BUZZER = 22  # ou 23 /!\ Pas de Pwm (1 seul canal dispo pour le backlight LCD)

# Entrées/sorties
AO = 14  #A1 16
AF = 15  #A0 17
Po1 = 16  #A2 18
Po2 = 18  #A3 20
Pf1 = 17  #A4 19
コード例 #10
0
# my GPIO settings (two TM1638 boards connected on GPIO19 and GPIO13 for DataIO and Clock; and on GPIO06 and GPIO26 for the STB)
DIO = 19
CLK = 13
STB = 26, # S'il y a plusieurs TM1638 à la suite, vous pouvez les indiquer après la virgules 

### aptitude install python-yaml

## for debug :
import pprint

with open('/opt/PvMonit/config-default.yaml') as f1:
    config = yaml.load(f1, Loader=yaml.FullLoader)
with open('/opt/PvMonit/config.yaml') as f2:
    config_perso = yaml.load(f2, Loader=yaml.FullLoader)

TM = TMBoards(DIO, CLK, STB, 0)

TM.clearDisplay()

def configGet(key1, key2=None, key3=None, key4=None):
    if key4 != None:
        try:
            return config_perso[key1][key2][key3][key4]
        except:
            return config[key1][key2][key3][key4]
    elif key3 != None:
        try:
            return config_perso[key1][key2][key3]
        except:
            return config[key1][key2][key3]
    elif key2 != None:
コード例 #11
0
ファイル: test_TM.py プロジェクト: joxheaf21/rpi-TM1638
from time import sleep
from rpi_TM1638 import TMBoards

# my GPIO settings
# (one TM1638 board connected to GPIO19 for dataIO, GPIO13 for Clock, and GPIO26 for the STB)
STB = 22
CLK = 21
DIO = 17
# STB = 6, 26   # in case you have two TM1638 boards, connected to GPIO06 and GPIO26

myLeds = [False] * 8
myLeds[0] = True

# instanciante my TMboards
TM = TMBoards(DIO, CLK, STB, 0)
TM.brightness[0] = 5
#TM.clearDisplay()

# some LEDs manipulation
#TM.leds[12] = True      # turn on led 12 (5th led of the 2nd board, since there is 8 leds per board)

#TM.segments[1] = '0'        # display '0' on the display 1 (2nd 7-segment display of the 1st board)
#TM.segments[4] = '98.76'     # display '9876' on the 7-segment display number 4, 5, 6 and 7 (the point is on segment 5)
#TM.segments[3, 1] = True     # turn on the segment #1 of the 7-segment number 3

#TM.segments[0] = '01234567'
#TM.segments[0] = 'Niclas70'
count = 8597
o = 0
n = 1
コード例 #12
0
from time import sleep
from rpi_TM1638 import TMBoards
"""
Test case of LED, segments, and switches. 
Press S2/S1 to increase/decrease the number on the left; 
S6/S5 for the number on the right; 
S3/S7 resets the numbers; 
S4/S8 quits the cycle.
Whenever a switch is on, the corresponding LED is on as well.
"""

STB = 26
CLK = 13
DIO = 19

TM = TMBoards(DIO, CLK, STB, 0)
TM.clearDisplay()

num_left = 0
num_right = 9999


def num_update():
    TM.segments[0] = '{:04d}'.format(abs(num_left) % 10000)
    TM.segments[4] = '{:04d}'.format(abs(num_right) % 10000)
    return


while True:
    for i in range(8):
        TM.leds[i] = True if TM.switches[i] else False
コード例 #13
0
from rpi_TM1638 import TMBoards
from time import sleep

DIO = 19
CLK = 13
STB = 26
TM = TMBoards(DIO, CLK, STB, 0)

TM.clearDisplay()
s = int(input("Ingresa sengudos para el temporizador: "))
m = int(input("Ingresa minutos para el temporizador: "))
h = int(input("Ingresa horas para el temporizador: "))
while True:
    if h == 0 and m < 0 and s == 2:
        h = 0
        m = 0
        s = 0
        TM.segments[0] = '00'
        TM.segments[2] = '.'
        TM.segments[3] = '00'
        TM.segments[5] = '.'
        TM.segments[6] = '00'
        break
    TM.segments[0] = '{:2d}'.format(abs(h))
    TM.segments[2] = '.'
    TM.segments[3] = '{:2d}'.format(abs(m))
    TM.segments[5] = '.'
    TM.segments[6] = '{:2d}'.format(abs(s))
    s -= 1
    if h != 0:
        if s == 0:
コード例 #14
0
from rpi_TM1638 import TMBoards
import time

DIO = 19
CLK = 13
STB = 26
TM = TMBoards(DIO, CLK, STB, 0)

TM.clearDisplay()
try:
    while True:  #ciclo infinito
        TM.segments[0] = time.strftime(
            "%H")  #uso de time para obtener el reloj del sistema
        TM.segments[2] = '.'
        TM.segments[3] = time.strftime("%M")
        TM.segments[5] = '.'
        TM.segments[6] = time.strftime("%S")
        time.sleep(1)
except KeyboardInterrupt:
    pass
TM.clearDisplay()
コード例 #15
0
from rpi_TM1638 import TMBoards
from time import sleep

DIO = 19
CLK = 13
STB = 26
TM = TMBoards(DIO, CLK, STB, 0)

TM.clearDisplay()
s = int(
    input("Ingresa sengudos para el temporizador: ")
)  #solicitd al usuario por condiciones de prueba no se puede ingresar nuermos mayores a 2
m = int(input("Ingresa minutos para el temporizador: "))
h = int(input("Ingresa horas para el temporizador: "))
while True:
    if h == 0 and m < 0 and s == 2:  #condcion de salida
        h = 0
        m = 0
        s = 0
        TM.segments[0] = '00'  #despligue de termino
        TM.segments[2] = '.'
        TM.segments[3] = '00'
        TM.segments[5] = '.'
        TM.segments[6] = '00'
        break
    TM.segments[0] = '{:2d}'.format(abs(h))  #formato de despliegue
    TM.segments[2] = '.'
    TM.segments[3] = '{:2d}'.format(abs(m))
    TM.segments[5] = '.'
    TM.segments[6] = '{:2d}'.format(abs(s))
    s -= 1
コード例 #16
0
ファイル: test_TM.py プロジェクト: whwtf/rpi-TM1638
# coding=utf-8
"""This file shows some use of the rpi_TM1638 librairy"""

from time import sleep
from rpi_TM1638 import TMBoards

# my GPIO settings
# (one TM1638 board connected to GPIO19 for dataIO, GPIO13 for Clock, and GPIO26 for the STB)
DIO = 19
CLK = 13
STB = 26
# STB = 6, 26   # in case you have two TM1638 boards, connected to GPIO06 and GPIO26

# instanciante my TMboards
TM = TMBoards(DIO, CLK, STB, 0)

TM.clearDisplay()

# some LEDs manipulation
TM.leds[0] = True  # turn on led 0 (1st led of the 1st board)
TM.leds[
    5] = False  # turn off led 5 (5th led of the 2nd board, since there is 8 leds per board)
TM.leds[
    7] = True  # turn on led 12 (5th led of the 2nd board, since there is 8 leds per board)

TM.segments[
    1] = '0'  # display '0' on the display 1 (2nd 7-segment display of the 1st board)
TM.segments[
    4] = '98.76'  # display '9876' on the 7-segment display number 4, 5, 6 and 7 (the point is on segment 5)
TM.segments[3, 2] = True  # turn on the segment #1 of the 7-segment number 3
TM.segments[3, 3] = True
コード例 #17
0
# coding=utf-8
from time import sleep
from rpi_TM1638 import TMBoards

# my GPIO settings (two TM1638 boards connected on GPIO19 and GPIO13 for DataIO and Clock; and on GPIO06 and GPIO26 for the STB)
DIO = 19
CLK = 13
STB = 26
#STB = 6, 26

# instanciante my TMboards
TM = TMBoards(DIO, CLK, STB, 0)

TM.clearDisplay()

# some LEDs manipulation
TM.leds[0] = True  # turn on led 0 (1st led of the 1st board)
TM.leds[
    5] = False  # turn off led 5 (5th led of the 2nd board, since there is 8 leds per board)
TM.leds[
    12] = True  # turn on led 12 (5th led of the 2nd board, since there is 8 leds per board)

TM.segments[
    1] = '0'  # display '0' on the display 1 (2nd 7-segment display of the 1st board)
TM.segments[
    4] = '98.76'  # display '9876' on the 7-segment display number 4, 5, 6 and 7 (the point is on segment 5)
TM.segments[3, 1] = True  # turn on the segment #1 of the 7-segment number 3

TM.segments[8] = '01234567'
TM.leds = (True, False, True)  # set the three first leds
コード例 #18
0
#importacion de modulos
from time import sleep
from rpi_TM1638 import TMBoards  #imprtante cambio de biblioteca/modulo de TM1638 a rpi_TM1638
import random

#numeros de piens a usar en BCM para TMBoards
DIO = 19
CLK = 13
STB = 26
#intanciacion en TMBoards se incia los pin desabilitados con 0
TM = TMBoards(DIO, CLK, STB, 0)

#metodo limpieza de display similiar a clear.py
TM.clearDisplay()

print("Press Ctrl+C to finish")
#try except equivalente de try catch el C
try:
    while True:  #ciclo infinito
        TM.leds[0] = bool(
            random.getrandbits(1)
        )  #prpiedad para el uso de leds se necita especifcar poscion 0-7 y estado por en tipo bool
        TM.leds[1] = bool(random.getrandbits(1))
        TM.leds[2] = bool(random.getrandbits(1))
        TM.leds[3] = bool(random.getrandbits(1))
        TM.leds[4] = bool(random.getrandbits(1))
        TM.leds[5] = bool(random.getrandbits(1))
        TM.leds[6] = bool(random.getrandbits(1))
        TM.leds[7] = bool(random.getrandbits(1))
        TM.segments[0] = str(
            random.randint(0, 9)