def display_time(time_element): time_to_display = time_element.strftime('%H%M') #Display time display = TM1637(CLK=21, DIO=20, brightness=1.0) display.Clear() display.ShowDoublepoint(True) display.Show([int(d) for d in str(time_to_display)])
def __init__(self): self.buzzer = BuzzerWrapper(Pin(15, Pin.OUT)) # D8 self.rgb_led = RGBLedWrapper(red_pin=Pin(16, Pin.OUT), # D0 green_pin=Pin(2, Pin.OUT), # D4 blue_pin=Pin(12, Pin.OUT)) # D6 self.seven_segment = TM1637(clk=Pin(5, Pin.OUT), # D1 dio=Pin(4, Pin.OUT)) # D2 self.led = Pin(14, Pin.OUT) # D5
def display(): from tm1637 import TM1637 display = TM1637(CLK=21, DIO=20, brightness=1.0) display.Clear() digits = [1, 3, 3, 7] display.Show(digits) return render_template('home.html')
def Init(): UI.SubLevel = 0 UI.RoLevel = 0 UI.Temperature = 0 # Power controller UI.Sea_pump = False UI.Ro_ext_pump = False UI.Ro_pump = False UI.Rever_dc = False UI.Main_pump = False UI.Skim_pump = False UI.Main_wave = False UI.Main_wave_bak = False # Switch type sensors UI.Ro_emergen_sensor = False UI.Sub_emergen_sensor = False UI.Ro_ext_have_water = False # Power UI.bat24v = False UI.dc24_bat24 = False UI.dc_v = 0 UI.battery_v = 0 UI.dc_c = 0 UI.main_pump_c = 0 UI.Skim_pump_c = 0 UI.WorkMode = 0 UI.id = 0 UI.last_handshake_tick = 0 UI.uart_connection = False # Init UI.tm = TM1637(Pin('X18'), Pin('X17')) UI.tm.brightness(0) # darkest UI.tm.write([0, 0, 0, 0]) UI.pi_uart = UART(1, 115200) UI.pi_uart.init(115200, timeout = 100, read_buf_len = 512) # Buffer UI.uart_buf = memoryview(bytearray(UI_UART_BUF_LEN)) UI.uart_buf_len = 0 UI.cmds = deque((), 5)
def main(): p = argparse.ArgumentParser() p.add_argument('-i', '--iface', metavar='str', required=True, help='wireless interface name') p.add_argument('-s', '--ssid', metavar='str', required=True, help='ssid of camera wifi network') p.add_argument('-p', '--password', metavar='str', required=True, help='wifi password') p.add_argument('-e', '--newer', metavar='str', default=(None, None), help=argparse.SUPPRESS) p.add_argument('--tm1637-clk-dio', metavar='int', type=int, nargs=2, default=(23, 24), help=argparse.SUPPRESS) p.add_argument('destdir', type=pathlib.Path, help='destination directory') args = p.parse_args() # Create a wpa_supplicant config file. wpa_conf_fh = NamedTemporaryFile() subprocess.run(['wpa_passphrase', args.ssid], input=args.password.encode('utf8'), stdout=wpa_conf_fh, check=True) global tm1637 try: if TM1637 and args.tm1637_clk_dio: tm1637 = TM1637(*args.tm1637_clk_dio) tm1637.clear() except: pass if tm1637: download_func = functools.partial(download_reporter_tm1637, tm1637=tm1637) else: download_func = download_reporter_basic # Sync only files newer than the specified filename (e.g. PA290946.JPG) if isinstance(args.newer, str): args.newer = (utils.parse_filename(args.newer), 'name') try: loop = asyncio.get_event_loop() main_task = asyncio.ensure_future(main_coro(args, wpa_conf_fh, download_func)) loop.run_until_complete(main_task) except KeyboardInterrupt: main_task.cancel() finally: del wpa_conf_fh tm1637.clear()
def initializeBoard(): lcddisplay = TM1637(4, 21) lcddisplay.show_clock() display1 = displayScore() display2 = displayScore() display1.createDevice(portNo='0', bgcolor="red", reset_pin='25', rotate_screen=180) display1.display_graphic("misc_images", "color_bars2") display2.createDevice(portNo='1', bgcolor="green", reset_pin='22', rotate_screen=180) display2.display_graphic("misc_images", "color_bars2") time.sleep(2) display1.clearscreen("Black") display2.clearscreen("Black") return display1, display2, lcddisplay
def __init__(self): # # connect to the WiFi network and setup the time # connect() # # setup the initial time # currentTime = cetTime() # cetTime returns (year,month,day,hours,minute,sec...) self.hours = currentTime[3] self.minutes = currentTime[4] time = self.hours = currentTime[3] * 100 + self.minutes # switch display on self.tm1637 = TM1637() self.tm1637.display_on() self.tm1637.write_dec(time, self.colon) # start a timer to interrupt every second timer = Timer(1) timer.init(period=1000, mode=Timer.PERIODIC, callback=self.set_clock)
#!/usr/bin/env python3 # Importation des librairies TM1637 et time from tm1637 import TM1637 from time import sleep # Stockage de la duree dans des variables print("- Duree du minuteur -") minutes = int(input("Minutes : ")) secondes = int(input("Secondes : ")) print("- Demarage du minuteur : " + str(minutes) + ":" + str(secondes) + " -") # Initialisation de l'afficheur afficheur = TM1637(clk=23, dio=24) # Definition de la luminosite (0-7) afficheur.brightness(2) # Affichage du temps du minuteur sur le module avant demarage # .numbers(x, y) : Affiche x sur les deux premiers 7 segments et y sur les deux suivants # -10 < x(resp. y) < 100 afficheur.numbers(minutes, secondes) # Boucle du minuteur i = minutes j = secondes while i >= 0: while j >= 0: afficheur.numbers(i, j) sleep(1) j -= 1
def __init__(self, clk_pin, dio_pin, brightness): self.display = TM1637(clk=Pin(clk_pin), dio=Pin(dio_pin)) self.display.brightness(brightness) self.display.show('----') sleep_ms(100)
# -*- coding: utf-8 -* from tm1637 import TM1637 from gpiozero import CPUTemperature from time import sleep CLK = 23 DIO = 24 cpuTemp = CPUTemperature() tm = TM1637(clk=CLK, dio=DIO) # 0 ... off # 7 ... max tm.brightness(5) while True: tm.temperature(round(cpuTemp.temperature)) sleep(1)
#!/usr/bin/env python3 from tm1637 import TM1637 import includes_display # Setup Display DIO = 2 CLK = 3 tm = TM1637(CLK, DIO) tm.brightness(5) import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM) import time #mysql database import MySQLdb try: db = MySQLdb.connect(host="localhost", user="******", passwd="pi_root1", db="hackathon_kicker_db") cursor = db.cursor() except: print "Cannot connect to database" #Variable definitions score_home = 0 score_guest = 0 #lights = 0 -> button; lights = 1 -> light sensor lights = 0 max_score = 6
#encoding:utf8 from tm1637 import TM1637 import time board = TM1637() board.show("L###") time.sleep(0.3) board.show("#O##") time.sleep(0.3) board.show("##V#") time.sleep(0.3) board.show("###E") time.sleep(0.3) board.show("LOVE") raw_input("Press Enter to continue...") board.clear()
def initDisplay(): global display display = TM1637(PIN_CLK, PIN_DIO, 2) display.Clear()
from tm1637 import TM1637 from time import sleep_ms tm1637 = TM1637() tm1637.debug = True tm1637.start_transfer() tm1637.write_byte(0x55) tm1637.stop_transfer() if tm1637.debug: f = open("/data/dio.txt", "w+b") f.write(tm1637.dio_data) f.close() f = open("/data/clk.txt", "w+b") f.write(tm1637.clk_data) f.close()
from microbit import * from tm1637 import TM1637, _SEG tm = TM1637(clk=pin1, dio=pin2) while True: tm.scroll('Hello World', 500) sleep(2000) tm.scroll('The quick brown fox jumps over the lazy dog') sleep(2000) tm.scroll('123456789') sleep(2000) tm.scroll(list(_SEG)) sleep(2000)
ARGS = parser.parse_args() try: # Load the labels file labels = [ line.rstrip('\n').split(':')[1] for line in open(ARGS.labels) if line != 'classes\n' ] # load codes codes = [ line.rstrip('\n').split(':')[2] for line in open(ARGS.labels) if line != 'classes\n' ] display = TM1637(CLK=21, DIO=20, brightness=1.0) display.SetBrightness(1) display.Clear() M, Minv = get_perspective_matrixes(1640, 1232) device = open_ncs_device() graph = load_graph(device) cam = PiCamera() cam.resolution = (1640, 1232) cam.framerate = 5 rawCapture = PiRGBArray(cam, size=(1640, 1232)) # init HTTP server server = HTTPServer(("", PORT), SimpleHTTPRequestHandler)
# -*- coding: utf-8 -* from time import sleep from gpiozero import DistanceSensor # Be aware not to use a GPIO with a physical pull-up resistor # like GPIO3, otherwise gpiozero will raise an exception because # it can't deactivate the pull-up ds = DistanceSensor(echo=27, trigger=17) # Measure and print distance periodically while True: print(str(round(ds.distance * 100)) + ' cm') sleep(1) # ... Or print distance on 7-segment display from tm1637 import TM1637 tm = TM1637(clk=23, dio=24) tm.brightness(5) while True: dist = str(round(ds.distance * 100)) print(str(round(ds.distance * 100)) + ' cm') tm.write(tm.encode_string(' ' * (4 - len(dist)) + dist)) sleep(1)
#!/usr/bin/env python # -*- coding: utf-8 -*- from tm1637 import TM1637 import time import datetime import RPi.GPIO as IO BRIGHT_TYPICAL = 2 Display = TM1637(23, 24, BRIGHT_TYPICAL) Display.Clear() count = 0 while (count < 5): now = datetime.datetime.now() hour = now.hour minute = now.minute second = now.second currenttime = [int(hour / 10), hour % 10, int(minute / 10), minute % 10] Display.Show(currenttime) Display.ShowDoublepoint(second % 2) time.sleep(1) count += 1 print count time.sleep(1) Display.Clear()
import csv # GPIO口使用BCM编码 GPIO.setmode(GPIO.BCM) # 定义按键引脚(可修改) pin_btn = 21 # 初始化按键的状态,内部上拉 GPIO.setup(pin_btn, GPIO.IN, pull_up_down=GPIO.PUD_UP) # 初始化按键的次数 press_times = 1 # 定义数码管引脚亮度(数码管引脚和亮度请修改此处,亮度最大7.0) Display = TM1637(CLK=23, DIO=24, brightness=1.0) Display.Clear() #请在此处修改城市,讲beijing改为你所在城市的全拼 weather = heweather('beijing') # 定义温湿度传感器引脚(可修改) pin_dht11 = 4 # 读取城市代码csv文件 def getcitycode(csvfile, city): csvcontent = csv.reader(file(csvfile, 'rb')) res = [] for line in csvcontent: if line[0].find(city) <> -1: