Exemple #1
0
def tidyup():
    global cyclts
    cyclts = False
    backlight.off()
    lcd.clear()
    lcd.set_contrast(0)
    backlight.set_graph(0)
Exemple #2
0
def main():

	lcd.clear()
	backlight.set_graph(0)
	backlight.rgb(255,255,255)
	lcd.set_cursor_position(1,0)
	lcd.write("MIFARE Cloner")
	lcd.set_cursor_position(3,2)
	lcd.write("by Cypaubr")
	
	time.sleep(3)
	
	lcd.clear()
	backlight.rgb(100,200,255)
	lcd.set_cursor_position(1,0)
	lcd.write("Place your tag")
	lcd.set_cursor_position(2,2)
	lcd.write("PRESS  START")
	
	while True:
		@touch.on(touch.BUTTON)
		def start_detection(ch, evt):
			lcd.clear()
			detect()
		
		@touch.on(touch.CANCEL)
		def cancel_detection(ch, evt):
			lcd.clear()
			lcd.write("Canceling...")
			backlight.rgb(255,0,0)
			time.sleep(1)
			exit(0)
Exemple #3
0
 def reset():
     lcd.clear()
     backlight.off()
     GVars.LED_RED = 0
     GVars.LED_GREEN = 0
     GVars.LED_BLUE = 0
     backlight.set_graph(0)
     lcd.set_display_mode(enable=True,cursor=False,blink=False)
     lcd.set_contrast(45)
Exemple #4
0
def tophat():
    #controls the raspberry pi HAT display
    lcd.clear(); lcd.set_contrast(50); backlight.set_graph(0)
    if (asoldiers > dsoldiers) and (atotallost != 1):
        backlight.rgb(0,255,0)
    elif (asoldiers <= dsoldiers):
        backlight.rgb(255,0,0)
    lcd.set_cursor_position(0,0); lcd.write("War is hell...")
    lcd.set_cursor_position(0,1); lcd.write("Offense Lost: " + str(atotallost))
    lcd.set_cursor_position(0,2); lcd.write("Defense Lost: " + str(dtotallost))
Exemple #5
0
 def visualisation(self):
     while True:
         got_data = False
         try:
             (indata, status) = self.queue.get_nowait()
             got_data = True
         except Empty:
             pass
         if got_data:
             mean = indata.mean()
             # print("Vis: %f (min %f, max %f, count %f)" % (mean, indata.min(), indata.max(), len(indata)))
             backlight.set_graph(mean * 3)
         time.sleep(self.updateTime)
Exemple #6
0
def graph():
    print 'Starting Graph'

    from dothat import backlight
    import time
    import math

    x = 0
    while True:

        x += 1
        backlight.set_graph(abs(math.sin(x / 100.0)))
        time.sleep(0.01)

    print 'graph: finishing'
def display_scoreboard():
    lcd.clear()
    backlight.set_graph(0.0)
    set_entire_backlight(0xff, 0xff, 0xff)

    str_score_1 = str(score_yellow).rjust(2)
    str_score_2 = str(score_black).ljust(2)
    lcd.set_cursor_position(0, 0)
    lcd.write('Yellow     Black')
    lcd.set_cursor_position(0, 1)
    lcd.write(' ')
    lcd.set_cursor_position(1, 1)
    lcd.write(str_score_1)
    lcd.set_cursor_position(13, 1)
    lcd.write(str_score_2)
Exemple #8
0
    def parse_packet(pkt):
        if ICMPv6EchoRequest in pkt:
            # Flash leds to indicate ICMPv6 Echo packet received
            backlight.set_graph(1.0)
            backlight.set_graph(0.0)

            address = pkt[IPv6].dst
            # Strip prefix and leading 0s and colons
            address = address[len(prefix):]
            address = address.lstrip(":0")
            address = address.replace(":","")
            try:
                text = bytearray.fromhex(address).decode()
                queue.put(text)
            except Exception as e:
                print (e)
def goooal(team):
    global score_yellow
    global score_black
    global button_pushed
    global goals_locked

    if (goals_locked):
        return
    button_pushed = False
    goals_locked = True

    # GOAL printed huge in block chars
    lcd.set_cursor_position(0, 0)
    lcd.write(
        chr(2) + chr(0) + chr(0) + ' ' + chr(2) + chr(0) + chr(0) + chr(4) +
        '  ' + chr(6) + '  ' + chr(0) + '  ')
    lcd.set_cursor_position(0, 1)
    lcd.write(
        chr(0) + ' ' + chr(1) + ' ' + chr(0) + '  ' + chr(0) + ' ' + chr(2) +
        chr(1) + chr(4) + ' ' + chr(0) + '  ')
    lcd.set_cursor_position(0, 2)
    lcd.write(
        chr(3) + chr(0) + chr(0) + ' ' + chr(3) + chr(0) + chr(0) + chr(5) +
        chr(2) + chr(5) + ' ' + chr(3) + chr(4) + chr(0) + chr(0) + chr(0))

    touch.high_sensitivity()
    touch.enable_repeat(False)
    lights = 1.0
    notify_replay_bot('goooooooooal!')
    while (lights > 0.0):
        if (button_pushed):
            display_scoreboard()
            goals_locked = False
            return
        backlight.set_graph(lights)
        set_backlight_rainbow(lights)

        lights = lights - 0.01
        sleep(0.0025)
    if (team == 0):
        score_yellow = score_yellow + 1
    else:
        score_black = score_black + 1
    check_if_someone_won()
def count_heat():
	global heat,heatc,dtemp,rtemp

	get_temp()
	if (dtemp-rtemp) > 0:
		if heatc < 1:
			heatc=heatc+0.01
			print time.strftime("%d-%m-%Y %H:%M:%S") + ": Counting heating, currently " + str(heatc) + "/1.0"
		else:
			heatc=1.0
			heat="ON"
			start_heating()
	else:
		if heatc > 0:
			heatc=heatc-0.01
			print time.strftime("%d-%m-%Y %H:%M:%S") + ": Counting heating, currently " + str(heatc) + "/0.0"
		else:
			heatc=0.0
			heat="OFF"
			stop_heating()
	if display_status == "ON":
		b.set_graph(heatc)
	else:
		b.set_graph(0)
 def update(self):
     x = (self.desk.height - MIN_HEIGHT) / (MAX_HEIGHT - MIN_HEIGHT)
     x = round(x, 1)
     if x < .1:
         x = .1
     backlight.set_graph(x)
            backlight.left_hue(parameters['hue'])
        elif command == 'setMiddleToHue':
            backlight.mid_hue(parameters['hue'])
        elif command == 'setRightToHue':
            backlight.right_hue(parameters['hue'])
        elif command == 'setToRGB':
            backlight.rgb(parameters['red'], parameters['green'], parameters['blue'])
        elif command == 'setZoneToRGB':
            backlight.single_rgb(parameters['zoneIndex'], parameters['red'], parameters['green'], parameters['blue'])
        elif command == 'setLeftToRGB':
            backlight.left_rgb(parameters['red'], parameters['green'], parameters['blue'])
        elif command == 'setMiddleToRGB':
            backlight.mid_rgb(parameters['red'], parameters['green'], parameters['blue'])
        elif command == 'setRightToRGB':
            backlight.right_rgb(parameters['red'], parameters['green'], parameters['blue'])
    elif component == 'BarGraph':
        if command == 'turnOff':
            backlight.graph_off()
        elif command == 'setByPercentage':
            backlight.set_graph(float(parameters['percentage']) / 100)
        elif command == 'setBrightness':
            backlight.graph_set_led_duty(parameters['minimumBrightness'], parameters['maximumBrightness'])
        elif command == 'setEnabledStateOfLed':
            backlight.graph_set_led_polarity(parameters['ledIndex'], 0b00000000)
            backlight.graph_set_led_state(parameters['ledIndex'], 1 if parameters['enabledState'] else 0)
    elif component == 'Touch':
        if command == 'enableHighSensitivityMode':
            touch.high_sensitivity()
        elif command == 'enableEventRepeating':
            touch.enable_repeat(True)
Exemple #13
0
did = DigitalInputDevice(5)
didv = did.value
print("Digital input is: " + str(didv))

lcd.clear()
lcd.set_contrast(50)

huestr = input("Enter Hue Value from 0.0 to 1.0: ")

backlight.hue(float(huestr))

lcd.set_cursor_position(0, 0)
lcd.write("Line 0")

lcd.set_cursor_position(0, 2)
lcd.write("Line 2")

for x in range(0, 101):
    foo = x / 10.0
    lcd.set_cursor_position(0, 1)
    string = "Line 1 {0}".format(foo)
    # print (string)
    lcd.write(string)
    backlight.set_graph(foo / 10.0)
    time.sleep(0.02)

endstr = input("Hit return to turn off backlight and bargraph ")

backlight.off()
backlight.set_graph(0.0)
Exemple #14
0
def lightsoff():
    global cyclts
    cyclts = False
    backlight.off()
    backlight.set_graph(0)
Exemple #15
0
#!/usr/bin/env python
print("""
This basic example display a simple text and terminates executaion immediately.
""")

import dothat.backlight as backlight
import dothat.lcd as lcd

# Turn off led bar
backlight.set_graph(0)

# Set backlight colour to cyan
backlight.rgb(0,255,255)

# Display text in FIRST line of the LCD
lcd.set_cursor_position(0, 0)
lcd.write("Hello world.")

# Display text in SECOND line of the LCD
lcd.set_cursor_position(0, 1)
lcd.write("This is fun!")

# Display text in THIRD line of the LCD
lcd.set_cursor_position(0, 2)
lcd.write(":)")


Exemple #16
0
class GracefulKiller:
    kill_now = False

    def __init__(self):
        signal.signal(signal.SIGINT, self.exit_gracefully)
        signal.signal(signal.SIGTERM, self.exit_gracefully)

    def exit_gracefully(self, signum, frame):
        self.kill_now = True


if __name__ == '__main__':
    killer = GracefulKiller()

    backlight.graph_off()

    backlight.graph_set_led_duty(0, 1)

    while True:
        cpu = psutil.cpu_percent()
        backlight.graph_off()

        backlight.set_graph(cpu / 100)

        if killer.kill_now:
            break
        sleep(0.3)

    print "End of the program. I was killed gracefully :)"
    backlight.graph_off()
print("lrm_cell:  ", lrm_cell)

did = DigitalInputDevice(5)

index = 0
jndex = 0
last_st = 0
excount = 0
st = 2
gen_start_time = 0.0
server_address = ('10.0.0.48', 10137)

nn = datetime.datetime.now()
lcd.set_contrast(50)
backlight.hue(0.5)
backlight.set_graph(0.0)
lcd.set_cursor_position(0, 0)
lcd.write("Monitor Starting")
#          1234567890123456
lcd.set_cursor_position(0, 1)
lcd.write(nn.strftime("%a %b %d %H:%M"))
lcd.set_cursor_position(0, 2)
lcd.write("                ")
#          1234567890123456

print("Startup: about to send text to DFM cell [" +
      str(datetime.datetime.now()) + "]")

body = "Generator monitor program launching"
###send_sms(dfm_cell, body, twilio_user, twilio_pass, twilio_num, twilio_acct)
Exemple #18
0
#!/usr/bin/env python
print("""
This example shows you a feature of the Dot HAT backlight.
You should see a rainbow sweep across the whole display!

Press CTRL+C to exit.
""")

import dothat.backlight as backlight
import dothat.lcd as lcd
import time
import math

lcd.set_cursor_position(0, 1)
lcd.write(" Such Rainbow! ")

x = 0

while True:
    x += 1

    backlight.sweep((x % 360) / 360.0)
    backlight.set_graph(abs(math.sin(x / 100.0)))
    time.sleep(0.01)
Exemple #19
0
def turn_off():
    backlight.off()
    backlight.set_graph(0)
    clear_text()
def write_status_line():
    lcd.set_cursor_position(0, 1)
    txt = 'Power {}%'.format(int(con.power * 100))
    lcd.write(pad_text(txt))
    backlight.set_graph(con.power)
Exemple #21
0
#!/usr/bin/python

"Import needed libraries"
from dothat import backlight, lcd
from dot3k.menu import MenuOption, Menu
import json, requests
from time import sleep
import threading

"Clear the HAT screen and set static content"
lcd.clear()
lcd.set_contrast(50)
backlight.set_graph(0)
backlight.graph_set_led_state(0, 0)
backlight.graph_set_led_state(5, 0)

lcd.set_cursor_position(0, 0)
lcd.write("Bittrex BTC-PAY:")
lcd.set_cursor_position(0, 0)
lcd.write("I'm rich biatch!")

"bitstamp API url for updated price information"
"added bittrex prices for pairs"
#URL = 'https://www.bitstamp.net/api/ticker/'
URL = "https://bittrex.com/api/v1.1/public/getmarketsummary?market=btc-pay"
string = ""
last = 0


class Ticker(MenuOption):
    def redraw(self, menu):
Exemple #22
0
import atexit
import time
from dothat import lcd, backlight


def tidyup():
    backlight.off()
    backlight.graph_off()
    lcd.clear()


atexit.register(tidyup)

backlight.rgb(0, 255, 0)
lcd.set_cursor_position(0, 0)
lcd.write('Hello LCD')

while(1):
    lcd.set_cursor_position(0,1)
    lcd.write(time.asctime()[:10])
    lcd.set_cursor_position(0,2)
    lcd.write(time.asctime()[11:])
    backlight.set_graph(time.time() % 1)
    time.sleep(1)




Exemple #23
0
    5]  # literally this is peak tuple. DONT ADD ANY EXTRA FIELDS TO THAT TABLE

# display price on LCD
# Clear the LCD and display Hello World
lcd.clear()
lcd.write("Now:")
lcd.write(str(current_price))

lcd.set_cursor_position(1, 0)

lcd.set_contrast(52)

# change colour to match the badness of the price.
backlight.off()
# doing nothing with the graph so far
backlight.set_graph(0)

if current_price < 9.8:  #greens
    g = 255
    if current_price < 6:
        r = 0
        b = 0
    elif current_price < 7:
        r = 30
        b = 30
    elif current_price < 8:
        r = 60
        b = 60
    else:
        r = 90
        b = 90
        elif command == 'setZoneToRGB':
            backlight.single_rgb(parameters['zoneIndex'], parameters['red'],
                                 parameters['green'], parameters['blue'])
        elif command == 'setLeftToRGB':
            backlight.left_rgb(parameters['red'], parameters['green'],
                               parameters['blue'])
        elif command == 'setMiddleToRGB':
            backlight.mid_rgb(parameters['red'], parameters['green'],
                              parameters['blue'])
        elif command == 'setRightToRGB':
            backlight.right_rgb(parameters['red'], parameters['green'],
                                parameters['blue'])
    elif component == 'BarGraph':
        if command == 'turnOff':
            backlight.graph_off()
        elif command == 'setByPercentage':
            backlight.set_graph(float(parameters['percentage']) / 100)
        elif command == 'setBrightness':
            backlight.graph_set_led_duty(parameters['minimumBrightness'],
                                         parameters['maximumBrightness'])
        elif command == 'setEnabledStateOfLed':
            backlight.graph_set_led_polarity(parameters['ledIndex'],
                                             0b00000000)
            backlight.graph_set_led_state(
                parameters['ledIndex'], 1 if parameters['enabledState'] else 0)
    elif component == 'Touch':
        if command == 'enableHighSensitivityMode':
            touch.high_sensitivity()
        elif command == 'enableEventRepeating':
            touch.enable_repeat(True)
Exemple #25
0

def get_anim_frame(char, fps):
    return char[int(round(time.time() * fps) % len(char))]


x = 0

text = "  pimoroni ftw  "

while True:
    x += 3
    x %= 360

    backlight.sweep((360.0 - x) / 360.0)
    backlight.set_graph(abs(math.sin(x / 100.0)))

    if x == 0:
        lcd.set_cursor_position(0, 1)
        lcd.write(" " * 16)

    pos = int(x / 20)
    lcd.set_cursor_position(0, 1)
    lcd.write(text[:pos] + "\x02")

    lcd.set_cursor_position(0, 2)
    lcd.write(colours[int(x / 52)])

    lcd.create_char(0, get_anim_frame(pirate, 2))
    lcd.create_char(1, get_anim_frame(heart, 2))
    lcd.create_char(2, get_anim_frame(pacman, 2))
    #print("power=",power)
    if (power > 500):
        power = 500
    maxim = 0.9 * maxim + 0.1 * np.max(np.abs(samples)) / 32767.0 * 500
    #print("samples=", samples[0:10])
    #print("maxim=",maxim)
    if (maxim > 500):
        maxim = 500
    #set green channel to power bar:
    #bar[0:50,0:power,1]=np.ones((50,power))
    #set red channel for maximum bar:
    #bar[50:100,0:maxim,2]=np.ones((50,maxim))

    #write bar every 4th block:
    if (np.mod(i, 1) == 0):
        backlight.set_graph(maxim / 500)
        """
       bartext=np.zeros((100,500,3))
       cv2.putText(bartext,"Compression on/off: key c, compr. strength: +/- keys", (20,20), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255,100,100))
       cv2.putText(bartext,"Quit: key q, Green: average power, Red: average peak", (20,40), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255,100,100))
       """
        """
       lcd.clear()
       if compression == False:
          #cv2.putText(bartext,"Compression off", (20,70), cv2.FONT_HERSHEY_SIMPLEX, 0.8, (255,100,100))
          lcd.write("Compression off!")
       else:
          #cv2.putText(bartext,"Compr. strength="+str(A), (20,70), cv2.FONT_HERSHEY_SIMPLEX, 0.8, (255,100,100))
          lcd.write("Compr. strength="+str(A))
       """
        #cv2.imshow('Aussteuerung',bar+bartext)