Esempio n. 1
0
def setup(pins=display_pins, val=8888):
	displays = []
	for clk, dio in pins:
		print(clk, dio)
		tm = tm1637.TM1637(clk=Pin(clk), dio=Pin(dio))
		tm.number(val)
		displays.append(tm)
	return displays
Esempio n. 2
0
 def init(self):
     display = tm1637.TM1637(int(self.params.clk),
             int(self.params.dio), tm1637.BRIGHT_TYPICAL)
     display.Clear()
     display.SetBrightnes(1)
     display.ShowDoublepoint(True)
     self._device = display
     return self._device
Esempio n. 3
0
 def __init__(self, config):
     """Define all objects and variables."""
     self.tm = tm1637.TM1637(clk=machine.Pin(config['display_clock']),
                             dio=machine.Pin(config['display_dio']))
     self.config = config
     self.wlan = network.WLAN(network.STA_IF)
     self.wlan_ap = network.WLAN(network.AP_IF)
     self.rtc = machine.RTC()
 def __init__(self):
     self.lastRead = {
         "intern": {"humidity": 0, "temperature": 0},
         "extern": {"humidity": 0, "temperature": 0}
     }
     self.timer = None
     # Initialize the clock (GND, VCC=3.3V, Example Pins are DIO-20 and CLK21)
     self.display = tm1637.TM1637(CLK=23, DIO=18, brightness=0.1)
     # read data using pin 17
     self.sensor = dht11.DHT11(pin=17)
def output():
    # /// Uncomment the following line out for terminal testing without 7-segment display
    time_file = open(time_file_path, "w")
    new_time_str = str(digits[3]) + str(digits[2]) + ':' + str(
        digits[1]) + str(digits[0])
    time_file.write(new_time_str)
    time_file.close()
    print(new_time_str)
    display = tm1637.TM1637(CLK=5, DIO=6, brightness=1.0)
    display.ShowDoublepoint(True)
    display.Show([digits[3], digits[2], digits[1], digits[0]])
Esempio n. 6
0
    def __init__(self):
        self.display = tm1637.TM1637(clk=Pin(5), dio=Pin(4))
        self.light = Pin(12, Pin.OUT)
        self.button = Pin(15, Pin.IN)
        self.speaker = PWM(Pin(0), 50)
        self.speaker.duty(0)
        self.remaining = 0
        self.start = None
        self.last_update = None
        self.last_press = None
        self.running = False

        self.display.write([0, 0, 0, 0])
Esempio n. 7
0
def main(args):  # 초기화
    FND = tm1637.TM1637(3, 2, tm1637.BRIGHT_TYPICAL)
    FND.Clear()
    FND.SetBrightnes(1)
    # 기능구현
    try:
        while True:  #현재 시간 정보
            now = datetime.datetime.now()
            hour = now.hour
            minute = now.minute
            second = now.second
            currenttime = [
                int(hour / 10), hour % 10,
                int(minute / 10), minute % 10
            ]
            FND.Show(currenttime)
            FND.ShowDoublepoint(second % 2)
            time.sleep(1)
    except KeyboardInterrupt:
        print("END FND")
    return 0
Esempio n. 8
0
def init():
    print("unix init")

    if not cfg.testmode:
        subprocess.call(['modprobe', 'w1-gpio', 'gpiopin=10'])
        if subprocess.call(['modprobe', 'w1_therm']):
            w1dev.sw_ds18b20 = True
            print('using sw ds18b20')
        if subprocess.call(['modprobe', 'w1_ds2413']):
            w1dev.sw_ds2413 = True
            print('using sw ds2413')
        os.chdir('/opt/brewarm')
    else:
        w1dev.w1path = '.' + w1dev.w1path

    if 0:  # rpi lcd
        import tm1637
        lcd = tm1637.TM1637(16, 15, tm1637.BRIGHT_HIGHEST)
        lcd.ShowDoublepoint(True)
        lcd.Clear()

    if 0:  # hw clock
        open(
            '/sys/class/i2c-adapter/i2c-' + str(cfg.config['i2c_bus']) +
            '/new_device', 'w').write("ds1307 0x68")
        subprocess.call(['hwclock', '-s'])  # load clock from rtc

    #if shutdown_pin != None: Timer(0, thread_shutdown, ()).start()
    #Timer(5, thread_discovery, ()).start()
    if shutdown_pin != None:
        threading.Thread(daemon=True, target=thread_shutdown).start()
    threading.Thread(daemon=True, target=thread_discovery).start()
    threading.Thread(daemon=True, target=thread_temp).start()

    def signal_term_handler(signal, frame):
        print('got SIGTERM')
        sync()
        sys.exit(0)

    signal.signal(signal.SIGTERM, signal_term_handler)
Esempio n. 9
0
 def plugin_init(self, enableplugin=None):
     plugin.PluginProto.plugin_init(self, enableplugin)
     self.hide = False
     if self.enabled == False or enableplugin == False:
         self.clrscr()
         return False
     if self.enabled:
         if int(self.taskdevicepin[0]) >= 0:
             self.initialized = False
             self.device = None
             try:
                 if self.taskdevicepluginconfig[
                         0] == self.P073_TM1637_4DGTDOTS:
                     self.device = tm1637.TM1637Decimal(
                         clk=int(self.taskdevicepin[0]),
                         dio=int(self.taskdevicepin[1]))
                 else:
                     self.device = tm1637.TM1637(
                         clk=int(self.taskdevicepin[0]),
                         dio=int(self.taskdevicepin[1]))
                 self.initialized = True
             except Exception as e:
                 misc.addLog(rpieGlobals.LOG_LEVEL_ERROR,
                             "7DGT can not be initialized! " + str(e))
                 self.device = None
                 return False
             if self.device is None:
                 self.initialized = False
     if self.enabled and self.initialized:
         self.uservar[0] = ""
         self.blink = -1
         self.p073_brightness(self.taskdevicepluginconfig[2])
         if int(self.taskdevicepluginconfig[1]) > int(
                 self.P073_DISP_MANUAL):
             self.timer1s = True
     else:
         self.timer1s = False
Esempio n. 10
0
GPIO.output(17,GPIO.LOW)
GPIO.output(27,GPIO.LOW)
GPIO.output(22,GPIO.LOW)

    #                     BCM
    #leds(7,0); //p       4
    #leds(0,0); //c       17
    #leds(2,0); //d       27
    #leds(3,0); //e       22


if __name__ == '__main__':
    # test1.py executed as script
    # do something
    # tm1637.got_here()
    tm = tm1637.TM1637(21, 20)
    start_time = time.time()
    print ("start time = ")
    #show_ip_address(tm)
    clear_display() 
 
    start_switch = 1
    while start_switch == 1:
       start_switch = GPIO.input(26)
       time.sleep(0.5)
       #print ("start = " + str(start_switch))

    light_loop()


Esempio n. 11
0
import time
#import utime
import random
import atexit
import RPi.GPIO as GPIO
from luma.core.interface.serial import spi, noop
from luma.core.render import canvas
from luma.core.legacy import show_message, text
from luma.core.legacy.font import proportional, CP437_FONT, TINY_FONT, SINCLAIR_FONT, LCD_FONT
from luma.led_matrix.device import max7219
from multiprocessing import Process, Array, Value
import threading
import os, signal, sys
import tm1637

tm = tm1637.TM1637(clk=3, dio=2)

serial = spi(port=0, device=0, gpio=noop())
device = max7219(serial, width=160, hight=8, block_orientation=-90)

device.clear()

BEAM_PINS = [24, 23, 22, 27, 17]

timeupp = Value('i', 0)
hitcountp = Value('i', 0)
hitp = Value('i', 0)

target = None
p = None
targetlist = [1, 2, 3, 4, 5]
Esempio n. 12
0
import spidev

import tm1637

pd = 2  #Analog in (on linker-base ADC)

spi = spidev.SpiDev()
spi.open(0, 0)


def readadc(adcnum):
    # read SPI data from MCP3004 chip, 4 possible adc’s (0 thru 3)
    if ((adcnum > 3) or (adcnum < 0)):
        return -1
    r = spi.xfer2([1, 8 + adcnum << 4, 0])
    #print(r)
    adcout = ((r[1] & 3) << 8) + r[2]
    return adcout


Display = tm1637.TM1637(23, 24, tm1637.BRIGHT_TYPICAL)

while True:
    value = readadc(pd)
    volts = (value * 3.3) / 1024
    #print("%4d/1023 => %5.3f V" % (value, volts))
    Display.ShowInt(value)
    time.sleep(0.1)

print('done.')
Esempio n. 13
0
import RPi.GPIO as GPIO
import dht11
import time
import datetime
import tm1637

# initialize GPIO
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
GPIO.cleanup()

# read data using pin 12
instance = dht11.DHT11(pin=12)

# initialize the display
display = tm1637.TM1637(clock_pin=5, data_pin=3)

while True:
    result = instance.read()
    if result.is_valid():
        print("Last valid input: " + str(datetime.datetime.now()))
        print("Temperature: %d C" % result.temperature)
        print("Humidity: %d %%" % result.humidity)

        display_map = map(int, str(result.temperature)) + map(
            int, str(result.humidity))
        display.set_values(display_map)

    time.sleep(1)
Esempio n. 14
0
#!/usr/bin/env python
# tm1637 test

import tm1637
import RPi.GPIO as GPIO
import time

CLK = 21
DATA = 20
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)

d = tm1637.TM1637(CLK, DATA)
d.showDoublePoint(1)  # 显示中间两个点
d.showData([5, 6, 7, 9])  # 显示内容

GPIO.cleanup()
Esempio n. 15
0
start = gpiozero.Button(26) # gumb za začetek igre
gumb = [
    gpiozero.Button(13), # modra
    gpiozero.Button(16), # rdeča
    gpiozero.Button(19), # oranžna
    gpiozero.Button(20)  # zelena
]

zvok = [
    pygame.mixer.Sound('blue.ogg'),   # modra
    pygame.mixer.Sound('red.ogg'),    # rdeča
    pygame.mixer.Sound('orange.ogg'), # oranžna
    pygame.mixer.Sound('green.ogg')   # zelena
]

prikaz = tm1637.TM1637(3, 2)


zaporedje = []
nivo = 0


def predvajaj(i):
    led[i].on()
    zvok[i].play()
    time.sleep(1)
    led[i].off()

def konec_igre():
    prikaz.set_values(['b', 'u', 'u', 'u'])
    prikaz.set_doublepoint(False)
Esempio n. 16
0
import board
import busio
import Adafruit_DHT
import time
import datetime
import RPi.GPIO as GPIO
import tm1637

DHT_SENSOR = Adafruit_DHT.DHT22
DHT_PIN = 4

Display = tm1637.TM1637(20, 21, tm1637.BRIGHT_TYPICAL)

Display.Clear()
Display.SetBrightnes(3)

while True:
    try:
        humidity, temp = Adafruit_DHT.read_retry(DHT_SENSOR, DHT_PIN)
        if humidity is not None and temp is not None:
            Display.Clear()
            Display.Show([int(temp / 10), int(temp % 10), 38, 36])
            time.sleep(5)
            Display.Show([int(humidity / 10), int(humidity % 10), 25, 36])
            time.sleep(5)
    except:
        pass
    for i in range(0, 11):
        now = datetime.datetime.now()
        hour = now.hour
        minute = now.minute
Esempio n. 17
0
# Updates TM1637 with each db update.

import RPi.GPIO as GPIO
import tm1637
import Adafruit_DHT

# PI 1
#DHT11
# tm = tm1637.TM1637(clk=23, dio=24)
# PI 4
#DHT22
tm = tm1637.TM1637(clk=24, dio=23)

# v1.0.00a
import time
from py4j.java_gateway import JavaGateway, GatewayParameters

PI = 4
# DHT Pin
DHT_PIN = 4
# Print each reading
DEBUG = 0
# Send every reading to application
DEBUG_SOCKET = 0


def one():
    return JavaGateway()


def two():
#-*- coding: utf-8 -*- 
import tm1637 #led
import time 

if __name__ == "__main__":
	display = tm1637.TM1637(CLK=21, DIO=20, brightness=1.0)
	display.Clear()
	display.ShowDoublepoint(False)
	try:
			while True:
				display.showtmp(8)
				time.sleep(3)
	except KeyboardInterrupt:
		print("stop")
	finally:
		display.cleanup()
Esempio n. 19
0
import tm1637
from time import sleep
from multiprocessing import Process
import json



tm = tm1637.TM1637(clk=21,dio=20) #brana
tm2 = tm1637.TM1637(clk=6,dio=5)  #garáž

tm.brightness(val=2)
tm2.brightness(val=2)


sleepTime = 0.2
hodnota = 0

horniPul  = 0b00000110
spodniPul = 0b00110000
sCel      = 0b00110110

def write(obj,a,b,c,d):
    if(obj == "gate"):
        tm.write([a,b,c,d])
    if(obj == "garage"):
        tm2.write([a,b,c,d])
    sleep(sleepTime)


def reset(obj):
    if(obj == "gate"):
Esempio n. 20
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from time import sleep
import tm1637
import signal

# Initialize the display (GND, VCC=3.3V, Example Pins are DIO-21 and CLK20)
# Do not use GPIO5 and GPIO6 for a display.
Display1 = tm1637.TM1637(CLK=13, DIO=12, brightness=1.0)
Display2 = tm1637.TM1637(CLK=19, DIO=16, brightness=1.0)
Display3 = tm1637.TM1637(CLK=26, DIO=20, brightness=1.0)
Display4 = tm1637.TM1637(CLK=21, DIO=22, brightness=1.0)

# Display.ShowDoublepoint(True)
Display1.SetBrightness(0.1)
Display2.SetBrightness(0.1)
Display3.SetBrightness(0.1)
Display4.SetBrightness(0.1)

def sigint_handler(signum, frame):
	Display1.Clear()
	Display2.Clear()
	Display3.Clear()
	Display4.cleanup()
	print("Exit Signal Recieved!")
	exit()

signal.signal(signal.SIGINT, sigint_handler)

def main():
Esempio n. 21
0
#code developed by apurva singh[Embedded Engineer]
# rev 10.2.2020

from gpiozero import CPUTemperature  #pull temperature from board of raspberry pi
import time  #importing time makes no sense.
import datetime  #importing this also makes no sense.
import sys  #this is required to pull temperature from the system
import RPi.GPIO as GPIO  #this is required inorder for the tm1637 to run
import tm1637  #this pulls the main library so we can use prebui3lt functions.
#CLK -> GPIO23 (Pin 16)
#Di0 -> GPIO24 (Pin 18)
##GUI DEFINITIONS ##
Display = tm1637.TM1637(23, 24, tm1637.BRIGHT_TYPICAL)  #inititating display
Display.Clear()  #clear display
Display.SetBrightnes(7)  #setting the brightness of the display
while (True):
    b = CPUTemperature()
    cpu = CPUTemperature()
    a = int(cpu.temperature
            )  #converting temperature in integers as it can be in decimal
    c = [0, 0, int(a / 10),
         a % 10]  #logic to print temperature on 7segment 4 digit
    print(c)  #print temperature on display
    Display.Show(c)  #display temperature on display using function
    time.sleep(
        2)  #delay of 2 sec. You can increase this as per your requirement.
Esempio n. 22
0
#!/usr/bin/env python3

# Raspberry Pi Python 3 TM1637 quad 7-segment LED display driver examples
from time import sleep

import tm1637

CLK = 1
DIO = 0
DELAY = 0.5

tm = tm1637.TM1637(clk=CLK, dio=DIO)

# all segments on "88:88"
tm.write([127, 255, 127, 127])
tm.write(bytearray([127, 255, 127, 127]))
tm.write(b'\x7F\xFF\x7F\x7F')
tm.show('8888', True)
tm.numbers(88, 88, True)
sleep(DELAY)

# all segments off
tm.write([0, 0, 0, 0])
tm.show('    ')
sleep(DELAY)

# write to the 2nd and 3rd segments only
tm.write([119, 124], 1)  # _Ab_
sleep(DELAY)
tm.write([0, 0, 0, 0])
tm.write([124], 2)  # __b_
Esempio n. 23
0
pi = pigpio.pi()

PWM_RANGE = 2000
PWM_FREQUENCY = 100
pi.set_PWM_frequency(RED_LED_PIN, PWM_FREQUENCY)
pi.set_PWM_frequency(GREEN_LED_PIN, PWM_FREQUENCY)
pi.set_PWM_frequency(BLUE_LED_PIN, PWM_FREQUENCY)

MAX_GREEN = 120
MAX_BLUE = MAX_GREEN * 0.8

pi.set_PWM_range(RED_LED_PIN, PWM_RANGE)
pi.set_PWM_range(GREEN_LED_PIN, PWM_RANGE)
pi.set_PWM_range(BLUE_LED_PIN, PWM_RANGE)

clockDisplay = tm1637.TM1637(CLK_PIN, DIO_PIN, tm1637.BRIGHT_TYPICAL)
clockDisplay.Clear()
clockDisplay.SetBrightness(c.CLOCK_BRIGHTNESS)

shouldDisplayBeClear = True
isDisplayActuallyClear = True
currentlySetFourNumbers = [0, 0, 0, 0]
currentlyDisplayedLight = (0, 0, 0, 0)

doublePoint = False


def get_currently_displayed_light():
    return currentlyDisplayedLight

Esempio n. 24
0
import tm1637,math
from machine import Pin,delay
from machine import USonic
sonic=USonic(0)
tm = tm1637.TM1637(clk=Pin.board.P0, dio=Pin.board.P1)
while True:
  dis = math.floor(sonic.distance()) #取整數
  tm.number(dis)
delay(200)
Esempio n. 25
0
selatan.setGreenTime(selatan.countGreenTime(kendaraan_selatan_pertama))
barat.setGreenTime(selatan.countGreenTime(kendaraan_barat_pertama))
utara.setGreenTime(utara.countGreenTime(kendaraan_utara_pertama))

timur.setRedTime(0)
selatan.setRedTime(selatan.countRedTime(timur))
barat.setRedTime(barat.countRedTime(selatan))
utara.setRedTime(utara.countRedTime(barat))
# selatan.setRedTime(10)
# barat.setRedTime(10)
# utara.setRedTime(10)

GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)

tm_timur = tm1637.TM1637(clk=timur.getPinTraffic()[0], dio=timur.getDio())
tm_selatan = tm1637.TM1637(clk=selatan.getPinTraffic()[0],
                           dio=selatan.getDio())
tm_barat = tm1637.TM1637(clk=barat.getPinTraffic()[0], dio=barat.getDio())
tm_utara = tm1637.TM1637(clk=utara.getPinTraffic()[0], dio=utara.getDio())

ruas = [timur, selatan, barat, utara]


def decrement_number():
    for i in range(len(ruas)):
        if ruas[i][2] >= 0 and ruas[i][3] is True:
            if i is 3:
                ruas[i][2] -= 1
                ruas[0][0] -= 1
            else:
Esempio n. 26
0
# CLK == Shared P9_12
# DIO == GPIO PIN P9_23
# GND == External Power
# 5v  == External Power

# Setup the pins for two LED's (AM/PM)
GPIO.setup("P8_8", GPIO.OUT)
GPIO.output("P8_8", GPIO.LOW)
GPIO.setup("P8_10", GPIO.OUT)
GPIO.output("P8_10", GPIO.LOW)
GPIO.setup("P8_12", GPIO.OUT)
GPIO.output("P8_12", GPIO.LOW)
GPIO.setup("P8_14", GPIO.OUT)
GPIO.output("P8_14", GPIO.LOW)
# Display 1 (Time)
ShowTime=tm1637.TM1637("P9_12", "P9_23")
# Display 2 (Date)
ShowDate=tm1637.TM1637("P9_12", "P9_25")
# Display 3 (Year)
ShowYear=tm1637.TM1637("P9_12", "P9_27")
# Clear all Displays
ShowTime.clear()
ShowDate.clear()
ShowYear.clear()
# Set Brightness of all Displays
ShowTime.set_brightness(2)
ShowDate.set_brightness(2)
ShowYear.set_brightness(2)
# Declare Variables
x=True
LastTime1='0'
Esempio n. 27
0
import tm1637
from machine import Pin, RTC
import network, usocket, utime, ntptime
from time import sleep
print("Connecting to WiFi...")
wifi = network.WLAN(network.STA_IF)
wifi.active(True)
wifi.connect('wifi', 'passwd')
while not wifi.isconnected():
    pass
print("Connected")

tm = tm1637.TM1637(clk=Pin(2), dio=Pin(0))
tm.brightness(1)
ntptime.settime()

while (True):
    sleep(60)
    local_time_sec = utime.time() + 8 * 3600
    local_time = utime.localtime(local_time_sec)
    h = local_time[3]
    m = local_time[4]
    print(local_time)
    tm.numbers(h, m)
Esempio n. 28
0
#!/usr/bin/env python2.7
import os
import sys
import requests
from requests.exceptions import ConnectionError, HTTPError
from time import sleep

import tm1637

# Rpi: GPIO3, GPIO2
disp = tm1637.TM1637(3, 2)

URL = 'http://panel.home.lan/get_metar'


def display(string):
    """ Returns a four element list to be displayed. """

    char_list = list(str(string))

    new_list = []

    # Check if the value is int or not
    for x in char_list:
        try:
            y = int(x)
        except ValueError:
            new_list.append(x)
        else:
            new_list.append(int(y))
Esempio n. 29
0
 def __init__(self):
     self.display = tm1637.TM1637(23, 24, brightness=1.0)
     self.display.Clear()
import urtc
from machine import Pin, I2C
from utime import sleep
import tm1637
from ssd1306 import SSD1306_I2C

sdapin = Pin(14)
sclpin = Pin(15)
i2c = I2C(1, sda=sdapin, scl=sclpin, freq=400000)
rtc = urtc.DS3231(i2c)
WIDTH = 128  # oled display width
HEIGHT = 32

oled = SSD1306_I2C(WIDTH, HEIGHT, i2c)

clock = tm1637.TM1637(clk=Pin(16), dio=Pin(17))

DAYS = 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'


def oled_blank():
    'blank the oled screen'
    oled.fill(0)
    oled.show()


def oled_fill():
    'fill the oled screen'
    oled.fill(1)
    oled.show()