def setup():
    GPIO.setmode(GPIO.BCM)
    GPIO.setup(5, GPIO.IN)
    GPIO.setup(6, GPIO.IN)

    lcd.set_contrast(53)

    # Custom font sprites for drawing huge "GOAL"
    # full block
    lcd.create_char(0, [0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff])

    # bottom half block
    lcd.create_char(1, [0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff])

    # bottom right corner
    lcd.create_char(2, [0x01, 0x03, 0x03, 0x07, 0x07, 0x0f, 0x0f, 0x1f])

    # top right corner
    lcd.create_char(3, [0x1f, 0x0f, 0x0f, 0x07, 0x07, 0x03, 0x03, 0x01])

    # bottom left corner
    lcd.create_char(4, [0x10, 0x18, 0x18, 0x1c, 0x1c, 0x1e, 0x1e, 0x1f])

    # top right corner
    lcd.create_char(5, [0x1f, 0x1e, 0x1e, 0x1c, 0x1c, 0x18, 0x18, 0x10])

    # Top pyramid corner of A
    lcd.create_char(6, [0, 0, 0x04, 0x04, 0x0e, 0x0e, 0x1f, 0x1f])

    global goals_locked
    goals_locked = True
    GPIO.add_event_detect(5, GPIO.RISING, callback=on_goal_1, bouncetime=3000)
    GPIO.add_event_detect(6, GPIO.RISING, callback=on_goal_2, bouncetime=3000)
Exemplo n.º 2
0
def tidyup():
    global cyclts
    cyclts = False
    backlight.off()
    lcd.clear()
    lcd.set_contrast(0)
    backlight.set_graph(0)
Exemplo n.º 3
0
def lcd(data):
    if data["command"] == "write":
        lcd.write(data["value"])
        return True
    if data["command"] == "clear":
        lcd.clear()
        return True
    if data["command"] == "set_contrast":
        lcd.set_contrast(data["contrast"])
        return True
    if data["command"] == "set_cursor_position":
        lcd.set_cursor_position(data["column"], data["row"])
        return True
    if data["command"] == "set_cursor_offset":
        lcd.set_cursor_offset(data["offset"])
        return True
    if data["command"] == "set_display_mode":
        lcd.set_display_mode(data["enable"], data["cursor"], data["blink"])
        return True
    if data["command"] == "create_char":
        lcd.create_char(data["char_pos"], data["char_map"])
        return True
    if data["command"] == "create_animation":
        lcd.create_animation(data["anim_pos"], data["anim_map"],
                             data["frame_rate"])
        return True
    if data["command"] == "update_animations":
        lcd.update_animations()
        return True
Exemplo n.º 4
0
def temp():
    print 'Starting Temp'
    from dothat import backlight
    from dothat import lcd
    import time

    lcd.set_contrast(50)

    while True:
        tempC = int(open('/sys/class/thermal/thermal_zone0/temp').read()) / 1e3

        # Change backlight if temp changes
        if tempC < 60:
            backlight.rgb(0, 255, 0)
        elif tempC > 70:
            backlight.rgb(255, 0, 0)
        else:
            backlight.rgb(0, 255, 255)

        # Convert Temp to String
        tempF = str(tempC)

        # Write Temp and wait 1 sec.
        lcd.set_cursor_position(0, 0)
        lcd.write("Temp: " + tempF + " C")
        time.sleep(1)
        lcd.clear()

    print 'backlight: finishing'
Exemplo n.º 5
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)
Exemplo n.º 6
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))
Exemplo n.º 7
0
def speakIPAddress():
    wlan = get_ip_address('wlan0')
    backlight.rgb(0, 255, 0)
    lcd.set_contrast(50)
    lcd.clear()
    lcd.set_cursor_position(2, 0)
    lcd.write("IP Address:")
    lcd.set_cursor_position(1, 1)
    lcd.write(wlan)
    command = "flite -voice rms -t 'My I P address is " + wlan + "' "
    print command
    os.system(command)
Exemplo n.º 8
0
def LCD_update(first = "", second = "Coretec Robotics", third = "", r = 0, g = 225, b = 0):
    print first
    print second
    print third
    backlight.rgb(r, g, b)
    lcd.clear()
    lcd.set_contrast(50)
    lcd.set_cursor_position(0, 0)
    lcd.write(first)
    lcd.set_cursor_position(0, 1)
    lcd.write(second)
    lcd.set_cursor_position(0,2)
    lcd.write(third)
Exemplo n.º 9
0
def main():
    ip = urlopen('http://ip.42.pl/raw').read()
    lcd.clear()
    lcd.set_contrast(50)
    if ip == '#IPADDRESS':
        backlight.rgb(0, 255, 0)
        lcd.set_cursor_position(0, 0)
        lcd.write("  LINK SECURED")
        lcd.set_cursor_position(0, 1)
        lcd.write(" " + ip)
    else:
        backlight.rgb(255, 0, 0)
        lcd.set_cursor_position(0, 0)
        lcd.write(" LINK UNSECURED")
        lcd.set_cursor_position(0, 1)
        lcd.write(" " + ip)
Exemplo n.º 10
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):
Exemplo n.º 11
0
    'combo': (0, 0, 255)
}, {
    'name': 'Magenta',
    'combo': (255, 0, 255)
}, {
    'name': 'Aqua',
    'combo': (0, 255, 255)
}, {
    'name': 'Purple',
    'combo': (131, 66, 244)
}, {
    'name': 'Indiglo',
    'combo': (0, 66, 33)
}]

lcd.set_contrast(51)

lcd.create_char(0, [0, 14, 10, 10, 10, 10, 14, 0])
lcd.create_char(1, [0, 14, 14, 14, 14, 14, 14, 0])

months_abbr = [
    None, 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct',
    'Nov', 'Dec'
]
trailing_zeros = [
    '00',
    '01',
    '02',
    '03',
    '04',
    '05',
Exemplo n.º 12
0
import time
import wiringpi
from threading import Thread, Event, Lock
from gpiozero import RGBLED, Buzzer

from dothat import lcd
from interface_strings import *

lcd.set_display_mode()
lcd.set_contrast(20)

import locale
locale.setlocale(locale.LC_ALL, display_locale)

backlight = RGBLED(5, 6, 13)

buzzer = Buzzer(22)

message_lock = Lock()

terminal_enabled = 0
terminal_message = ""
terminal_amount = 0

lcd.create_animation(
    7,
    [[0b00000, 0b10001, 0b01010, 0b00100, 0b10001, 0b01010, 0b00100, 0b00000],
     [0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000]],
    1)

Exemplo n.º 13
0
        if command == 'kill':
            if parameters['performReset']:
                lcd.clear()
                backlight.off()
                backlight.graph_off()

            sys.exit()
        elif command == 'reset':
            lcd.clear()
            backlight.off()
            backlight.graph_off()
    elif component == 'LCD':
        if command == 'clear':
            lcd.clear()
        elif command == 'setContrast':
            lcd.set_contrast(parameters['contrast'])
        elif command == 'setCursorPosition':
            lcd.set_cursor_position(parameters['column'], parameters['row'])
        elif command == 'write':
            lcd.write(parameters['value'])
        elif command == 'createCharacter':
            lcd.create_char(parameters['memoryPosition'], parameters['map'])
        elif command == 'writeCharacter':
            lcd.write(chr(parameters['memoryPosition']))
    elif component == 'Backlight':
        if command == 'turnOff':
            backlight.off()
        elif command == 'setBrightnessOfLed':
            backlight.set(parameters['ledIndex'], parameters['brightness'])
        elif command == 'setToHue':
            backlight.hue(parameters['hue'])
pygame.mixer.pre_init(44100, -16, 1, 512)
pygame.mixer.init()
pygame.mixer.set_num_channels(256)

patches = glob.glob(os.path.join(BANK, '*'))
print(patches)
patch_index = 0

if len(patches) == 0:
    exit("Couldn't find any .wav files in {}".format(BANK))

# Display-o-Tron setup
lcd.clear()
backlight.sweep(5)  # Set a rainbow background
lcd.set_contrast(50)  # Readable contrast, for our Displayotron HAT
lcd.write("SYSTEM START")
backlight.graph_off()  # Make sure the hellish-bright sidebar LEDs are off


def natural_sort_key(s, _nsre=re.compile('([0-9]+)')):
    return [
        int(text) if text.isdigit() else text.lower()
        for text in re.split(_nsre, s)
    ]


def load_samples(patch):
    """Load audio samples into buffers for playback."""
    global samples, files, octave, octaves
    files = []
Exemplo n.º 15
0
for row in rows:
    print(row[5])

# get price
current_price = row[
    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:
Exemplo n.º 16
0
import fcntl
import socket
import struct
import time
import os
import sys
import psutil

from dothat import lcd
from dothat import backlight
import dothat.touch as nav

#Clears the LCD and sets contrast on Start
lcd.clear()
lcd.set_contrast(47)
backlight.graph_off()

#Global Variables
ButtonStatus = 'Off'
loopcount = 0


#Function to get CPU Temp
def getCPUtemperature():
    res = os.popen('vcgencmd measure_temp').readline()
    return (res.replace("temp=", "").replace("'C\n", ""))


#Function to get CPU Usage
def getCPUuse():
Exemplo n.º 17
0
import struct
#import threading
#import wifi
#import math

import dothat.backlight as backlight
import dothat.lcd as lcd
import dothat.touch as nav
from dot3k.menu import Menu, MenuOption, MenuIcon
from sys import exit

print "Displayotron system monitor - should be started as a service: sudo systemctl start dispotron.service"

#Variable for backlight RGB cycling - set from menu option 'CYCLE RGB'
cyclts = False
lcd.set_contrast(0)


def run_cmd(cmd):
    p = subprocess.Popen(cmd,
                         shell=True,
                         stdout=subprocess.PIPE,
                         stderr=subprocess.STDOUT)
    output = p.communicate()[0].rstrip()
    return output


def bytes2human(n):
    # http://code.activestate.com/recipes/578019
    symbols = ('K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y')
    prefix = {}
Exemplo n.º 18
0
item_dict = {}
for i in items:
    item_dict[i.topic] = i

item_deque = deque()
for i in item_dict.keys():
    item_deque.append(item_dict[i])

# default sensor
selected_sensor = item_deque[0]

# lcd initialization
lcd.clear()
backlight.rgb(255, 255, 255)
lcd.set_contrast(45)
lcd.clear()


def on_connect(mqtt_client, userdata, flags, rc):
    logger.info("Connected with result code: %s", rc)

    item_dict = userdata[ITEM_DICT]
    for key in item_dict.keys():
        mqtt_client.subscribe(item_dict[key].topic)


def on_message(mqtt_client, userdata, msg):
    item_dict = userdata[ITEM_DICT]

    # Payload is a string byte array
     if command == 'kill':
         if parameters['performReset']:
             lcd.clear()
             backlight.off()
             backlight.graph_off()
         
         sys.exit()
     elif command == 'reset':
         lcd.clear()
         backlight.off()
         backlight.graph_off()
 elif component == 'LCD':
     if command == 'clear':
         lcd.clear()
     elif command == 'setContrast':
         lcd.set_contrast(parameters['contrast'])
     elif command == 'setCursorPosition':
         lcd.set_cursor_position(parameters['column'], parameters['row'])
     elif command == 'write':
         lcd.write(parameters['value'])
     elif command == 'createCharacter':
         lcd.create_char(parameters['memoryPosition'], parameters['map'])
     elif command == 'writeCharacter':
         lcd.write(chr(parameters['memoryPosition']))
 elif component == 'Backlight':
     if command == 'turnOff':
         backlight.off()
     elif command == 'setBrightnessOfLed':
         backlight.set(parameters['ledIndex'], parameters['brightness'])
     elif command == 'setToHue':
         backlight.hue(parameters['hue'])