Esempio n. 1
0
def custom_bitmaps():
    speaker = pifacecad.LCDBitmap([1, 3, 15, 15, 15, 3, 1, 0])
    play = pifacecad.LCDBitmap([0, 8, 12, 14, 12, 8, 0, 0])
    stop = pifacecad.LCDBitmap([0, 31, 31, 31, 31, 31, 0, 0])
    playlist = pifacecad.LCDBitmap([2, 3, 2, 2, 14, 30, 12, 0])

    cad.lcd.store_custom_bitmap(0, speaker)
    cad.lcd.store_custom_bitmap(1, play)
    cad.lcd.store_custom_bitmap(2, stop)
    cad.lcd.store_custom_bitmap(3, playlist)
Esempio n. 2
0
    def __init__(self):
        # First define some pretty cutstom bitmaps!
        self.__temp_symbol_index = 7
        self.__temperature_symbol = pifacecad.LCDBitmap(
            [0x18, 0x18, 0x3, 0x4, 0x4, 0x4, 0x3, 0x0])

        # Screen data
        self.__name = ''
        self.__state = ''
        self.__temp = ''
        self.__volts = ''
        self.__amps = ''
Esempio n. 3
0
# gen bitmaps with: http://www.quinapalus.com/hd44780udg.html
# import sys
# import os
# sys.path.insert(0, os.path.abspath('..'))
import time

import os
import sys
parentdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, parentdir)
import pifacecad


batt_char = pifacecad.LCDBitmap(
    [0x0E, 0x1B, 0x11, 0x11, 0x11, 0x11, 0x11, 0x1F]
)
checkerboard = pifacecad.LCDBitmap(
    [0x15, 0xa, 0x15, 0xa, 0x15, 0xa, 0x15, 0xa]
)

left_holder = pifacecad.LCDBitmap(
    [0x3, 0xc, 0x8, 0x10, 0x10, 0x8, 0xc, 0x3]
)
right_holder = pifacecad.LCDBitmap(
    [0x18, 0x6, 0x2, 0x1, 0x1, 0x2, 0x6, 0x18]
)
middle_holder = pifacecad.LCDBitmap(
    [0x1f, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1f]
)
left_heart = pifacecad.LCDBitmap(
    [0x6, 0xf, 0x1f, 0xf, 0xf, 0x7, 0x3, 0x1]
Esempio n. 4
0
#!/usr/bin/env python3
import sys
import math
import subprocess
from time import sleep
import psutil
import pifacecad

UPDATE_INTERVAL = 1  # 1 seconds
GET_IP_CMD = "hostname --all-ip-addresses"
GET_TEMP_CMD = "/opt/vc/bin/vcgencmd measure_temp"
GET_CORES_CMD = "mpstat -P ALL 1 1"
one_bar = pifacecad.LCDBitmap([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f])
two_bar = pifacecad.LCDBitmap([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x1f])
three_bar = pifacecad.LCDBitmap(
    [0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x1f, 0x1f])
four_bar = pifacecad.LCDBitmap(
    [0x00, 0x00, 0x00, 0x00, 0x1f, 0x1f, 0x1f, 0x1f])
five_bar = pifacecad.LCDBitmap(
    [0x00, 0x00, 0x00, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f])
six_bar = pifacecad.LCDBitmap([0x00, 0x00, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f])
seven_bar = pifacecad.LCDBitmap(
    [0x00, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f])
eight_bar = pifacecad.LCDBitmap(
    [0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f])


def run_cmd(cmd):
    return subprocess.check_output(cmd, shell=True).decode('utf-8')

Esempio n. 5
0
import pifacecad
import pifacecad.tools
from pifacecad.lcd import LCD_WIDTH

WORDS = ["piface", "raspberrypi", "horses", "eggs", "bacon"]

TOP_LEFT_INDEX, TOP_MIDDLE_INDEX, TOP_RIGHT_INDEX = range(3)
BOTTOM_LEFT_INDEX, BOTTOM_MIDDLE_INDEX, BOTTOM_RIGHT_INDEX = range(3, 6)

# hangman is in six squares
HANGMAN_WIDTH = 3
stages = [
    # stage 0
    {
        'top-left':
        pifacecad.LCDBitmap([0x0, 0x0, 0xf, 0x8, 0x8, 0x8, 0x8, 0x8]),
        'top-middle':
        pifacecad.LCDBitmap([0x0, 0x0, 0x1c, 0x4, 0x0, 0x0, 0x0, 0x0]),
        'top-right':
        pifacecad.LCDBitmap([0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0]),
        'bottom-left':
        pifacecad.LCDBitmap([0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x1f]),
        'bottom-middle':
        pifacecad.LCDBitmap([0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1f]),
        'bottom-right':
        pifacecad.LCDBitmap([0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x18]),
    },
    # stage 1
    {
        'top-left':
        pifacecad.LCDBitmap([0x0, 0x0, 0xf, 0x8, 0x8, 0x8, 0x8, 0x8]),
Esempio n. 6
0
#PiFaceCAD Setup
cad = pifacecad.PiFaceCAD()
cad.lcd.clear()
cad.lcd.backlight_on()
cad.lcd.blink_off()

#Global Variables
count = 1
backlight = 1
time_wake = str("06:30")
time_sleep = str("22:00")
#current_date = str("2019/02/18")

# the bit map for the number 1 in binary
LT = pifacecad.LCDBitmap(
    [0B00111, 0B01111, 0B11111, 0B11111, 0B11111, 0B11111, 0B11111, 0B11111])
UB = pifacecad.LCDBitmap(
    [0B11111, 0B11111, 0B11111, 0B00000, 0B00000, 0B00000, 0B00000, 0B00000])
RT = pifacecad.LCDBitmap(
    [0B11100, 0B11110, 0B11111, 0B11111, 0B11111, 0B11111, 0B11111, 0B11111])
LL = pifacecad.LCDBitmap(
    [0B11111, 0B11111, 0B11111, 0B11111, 0B11111, 0B11111, 0B01111, 0B00111])
LB = pifacecad.LCDBitmap(
    [0B00000, 0B00000, 0B00000, 0B00000, 0B00000, 0B11111, 0B11111, 0B11111])
LR = pifacecad.LCDBitmap(
    [0B11111, 0B11111, 0B11111, 0B11111, 0B11111, 0B11111, 0B11110, 0B11100])
MB = pifacecad.LCDBitmap(
    [0B11111, 0B11111, 0B11111, 0B00000, 0B00000, 0B00000, 0B11111, 0B11111])
block = pifacecad.LCDBitmap(
    [0B11111, 0B11111, 0B11111, 0B11111, 0B11111, 0B11111, 0B11111, 0B11111])
Esempio n. 7
0
#!/usr/bin/env python3
import sys
import subprocess
from time import sleep
import pifacecad

UPDATE_INTERVAL = 10  # 10 sec
GET_IP_CMD = "hostname --all-ip-addresses | awk '{print $1}'"
GET_TEMP_CMD = "/opt/vc/bin/vcgencmd measure_temp"
TOTAL_MEM_CMD = "free | grep 'Mem' | awk '{print $2}'"
USED_MEM_CMD = "free | grep '\-\/+' | awk '{print $3}'"
CPU_LOAD_CMD = "uptime | awk '{print $9}' | sed s/,/" "/g"
HOSTNAME_CMD = "hostname"
FREE_DISK_CMD = "df -h | grep rootfs | awk '{print $5}'"

cpu_symbol = pifacecad.LCDBitmap([0x0, 0x1f, 0x11, 0x15, 0x11, 0x1f, 0x0, 0x0])
disk_symbol = pifacecad.LCDBitmap(
    [0x0, 0x1c, 0x1e, 0x1e, 0x1e, 0x1e, 0x0, 0x0])
temperature_symbol = pifacecad.LCDBitmap(
    [0x4, 0x4, 0x4, 0x4, 0xe, 0xe, 0xe, 0x0])
memory_symbol = pifacecad.LCDBitmap(
    [0xe, 0x1f, 0xe, 0x1f, 0xe, 0x1f, 0xe, 0x0])

temp_symbol_index, memory_symbol_index, cpu_symbol_index, disk_symbol_index = 0, 1, 2, 3


def run_cmd(cmd):
    return subprocess.check_output(cmd, shell=True).decode('utf-8')


def get_cpu_load():
Esempio n. 8
0
#!/usr/bin/env python3
import sys
import subprocess
from time import sleep
import pifacecad

UPDATE_INTERVAL = 5
GET_IP_CMD = "hostname --all-ip-addresses"
GET_LOADAVG_CMD = "cat /proc/loadavg"
GET_TEMP_CMD = "/opt/vc/bin/vcgencmd measure_temp"
TOTAL_MEM_CMD = "free | grep 'Mem' | awk '{print $2}'"
USED_MEM_CMD = "free | grep '\-\/+' | awk '{print $3}'"

network_symbol = pifacecad.LCDBitmap([14, 14, 14, 4, 4, 4, 31, 0])
load_symbol = pifacecad.LCDBitmap([0, 2, 7, 15, 31, 31, 31, 0])
temperature_symbol = pifacecad.LCDBitmap([4, 4, 4, 4, 14, 14, 14, 0])
degree_symbol = pifacecad.LCDBitmap([6, 9, 9, 6, 0, 0, 0, 0])
memory_symbol = pifacecad.LCDBitmap([14, 31, 14, 31, 14, 31, 14, 0])

allow_write = True
display_on = True


def run_cmd(cmd):
    return subprocess.check_output(cmd, shell=True).decode('utf-8')


def get_my_ip():
    val = run_cmd(GET_IP_CMD)[:-1]
    if val == "":
        val = "No Connection!"
Esempio n. 9
0
# sudo update-rc.d pifacecadshutdown stop 99 0 .

import pifacecad as p

cad = p.PiFaceCAD()
cad.lcd.backlight_on()
cad.lcd.cursor_off()
cad.lcd.blink_off()

cad.lcd.set_cursor(6, 0)
cad.lcd.write("Shutdown")
cad.lcd.set_cursor(6, 1)
cad.lcd.write("Complete")

# K over 4 chars (down, left)
cg = p.LCDBitmap([24, 24, 24, 25, 27, 31, 30, 28])
cad.lcd.store_custom_bitmap(0, cg)
cg = p.LCDBitmap([28, 30, 31, 27, 25, 24, 24, 24])
cad.lcd.store_custom_bitmap(1, cg)
cg = p.LCDBitmap([6, 14, 28, 24, 16, 0, 0, 0])
cad.lcd.store_custom_bitmap(2, cg)
cg = p.LCDBitmap([0, 0, 0, 16, 24, 28, 14, 6])
cad.lcd.store_custom_bitmap(3, cg)

# V over 4 chars (down, left)
cg = p.LCDBitmap([24, 24, 24, 12, 12, 12, 6, 6])
cad.lcd.store_custom_bitmap(4, cg)
cg = p.LCDBitmap([6, 6, 3, 3, 3, 1, 1, 1])
cad.lcd.store_custom_bitmap(5, cg)
cg = p.LCDBitmap([3, 3, 3, 6, 6, 6, 12, 12])
cad.lcd.store_custom_bitmap(6, cg)
Esempio n. 10
0
 def __init__(self):
     self.current_index = 0
     self.model = []
     self.bombLCD = pifacecad.LCDBitmap([0x1,0x2,0x4,0xe,0x1f,0x1f,0xe,0x4])
     self.bombLCDIndex = 0
     cad.lcd.store_custom_bitmap(self.bombLCDIndex, self.bombLCD)
from pygame import mixer  # Load the required library
import pifacecad
from time import sleep
import datetime
import threading
import os

cad = pifacecad.PiFaceCAD()
cad.lcd.backlight_on()
cad.lcd.blink_off()
cad.lcd.cursor_off()

# bitmap
bmp_note = pifacecad.LCDBitmap([2, 3, 2, 2, 14, 30, 12, 0])
bmp_play = pifacecad.LCDBitmap([0, 8, 12, 14, 12, 8, 0, 0])
bmp_pause = pifacecad.LCDBitmap([0, 27, 27, 27, 27, 27, 0, 0])
bmp_clock = pifacecad.LCDBitmap([0, 14, 21, 23, 17, 14, 0, 0])
bmp_vol1 = pifacecad.LCDBitmap([1, 3, 15, 15, 15, 3, 1, 0])
bmp_vol2 = pifacecad.LCDBitmap([8, 16, 0, 24, 0, 16, 8, 0])

cad.lcd.store_custom_bitmap(0, bmp_note)
cad.lcd.store_custom_bitmap(1, bmp_play)
cad.lcd.store_custom_bitmap(2, bmp_pause)
cad.lcd.store_custom_bitmap(3, bmp_clock)
cad.lcd.store_custom_bitmap(4, bmp_vol1)
cad.lcd.store_custom_bitmap(5, bmp_vol2)

# music
song = [
    'Closer', 'Shape Of You', 'Starving', 'The Ocean', 'We Don\'t Talk Anymore'
]
    Button0 = 0
    Button1 = 1
    Button2 = 2
    Button3 = 3
    Button4 = 4
    Button5 = 5
    Button6 = 6
    Button7 = 7


#
# lcdstatus - Keep track of LCD backlight status
#
lcdstatus = LCDStatus.OFF

DEGREE_SYMBOL = pifacecad.LCDBitmap(
    [0x0e, 0x0a, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00])
DEGREE_SYMBOL_INDEX = 0


#
# DS18B20 Exception handler
#
class DS18B20Error(Exception):
    pass


class SensorNotFound(DS18B20Error):
    def __init__(self, sensorName):
        super(SensorNotFound,
              self).__init__('Sensor not found\n {}'.format(sensorName))
Esempio n. 13
0
#!/usr/bin/env python3
import sys
import subprocess
from time import sleep
import pifacecad

UPDATE_INTERVAL = 30
URL = "http://menzerath.eu"
GET_STATUS_CMD = "java -jar IMWD.jar " + URL + " 0 --once"

ok_icon = pifacecad.LCDBitmap([0, 1, 3, 22, 28, 8, 0, 0])
bad_icon = pifacecad.LCDBitmap([0, 27, 14, 4, 14, 27, 0, 0])
url_icon = pifacecad.LCDBitmap([0, 8, 12, 14, 12, 8, 0, 0])

prev_status = ""


def run_cmd(cmd):
    return subprocess.check_output(cmd, shell=True).decode('utf-8')


def get_status():
    return run_cmd(GET_STATUS_CMD)[:-1]


def start_testing():
    global prev_status

    while True:
        my_status = get_status()
Esempio n. 14
0
import pifacecad
import pifacecad.tools
from pifacecad.lcd import LCD_WIDTH


WORDS = ["piface", "raspberrypi", "pferd", "eier", "schnitzel", "hund", "knopf", "vogelei"]

TOP_LEFT_INDEX, TOP_MIDDLE_INDEX, TOP_RIGHT_INDEX = range(3)
BOTTOM_LEFT_INDEX, BOTTOM_MIDDLE_INDEX, BOTTOM_RIGHT_INDEX = range(3, 6)

# hangman is in six squares
HANGMAN_WIDTH = 3
stages = [
    # stage 0
    {
    'top-left': pifacecad.LCDBitmap(
        [0x0, 0x0, 0xf, 0x8, 0x8, 0x8, 0x8, 0x8]),
    'top-middle': pifacecad.LCDBitmap(
        [0x0, 0x0, 0x1c, 0x4, 0x0, 0x0, 0x0, 0x0]),
    'top-right': pifacecad.LCDBitmap(
        [0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0]),
    'bottom-left': pifacecad.LCDBitmap(
        [0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x1f]),
    'bottom-middle': pifacecad.LCDBitmap(
        [0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1f]),
    'bottom-right': pifacecad.LCDBitmap(
        [0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x18]),
    },
    # stage 1
    {
    'top-left': pifacecad.LCDBitmap(
        [0x0, 0x0, 0xf, 0x8, 0x8, 0x8, 0x8, 0x8]),
Esempio n. 15
0
        "location": "London",
        "id": "IGREATER13"
    },
    {
        "location": "Paris",
        "id": "IILEDEFR15"
    },
    {
        "location": "New York",
        "id": "KNYNEWYO62"
    },
]
URL_PREFIX = \
    "http://api.wunderground.com/weatherstation/WXCurrentObXML.asp?ID="

TEMP_SYMBOL = pifacecad.LCDBitmap([0x4, 0x4, 0x4, 0x4, 0xe, 0xe, 0xe, 0x0])
WIND_SYMBOL = pifacecad.LCDBitmap([0x0, 0xf, 0x3, 0x5, 0x9, 0x10, 0x0])
TEMP_SYMBOL_INDEX, WIND_SYMBOL_INDEX = 0, 1


class WeatherStation(object):
    def __init__(self, location, weather_id):
        self.location = location
        self.weather_id = weather_id
        self._xmltree = None

    def generate_xmltree(self):
        url = get_current_condition_url(self.weather_id)
        data = urllib.request.urlopen(url)
        self._xmltree = xml.etree.ElementTree.XML(data.read())
Esempio n. 16
0
#!/usr/bin/env python3
import sys
import subprocess
from time import sleep
import pifacecad

UPDATE_INTERVAL = 50 * 5  #5 min
GET_IP_CMD = "hostname --all-ip-addresses"
GET_TEMP_CMD = "/opt/vc/bin/vcgencmd measure_temp"
TOTAL_MEM_CMD = "free | grep 'Mem' | awk '{print $2}'"
USED_MEM_CMD = "free | grep '\-\/+' | awk '{print $3}'"

temperature_symbol = pifacecad.LCDBitmap(
    [0x4, 0x4, 0x4, 0x4, 0xe, 0xe, 0xe, 0x0])
memory_symbol = pifacecad.LCDBitmap(
    [0xe, 0x1f, 0xe, 0x1f, 0xe, 0x1f, 0xe, 0x0])
temp_symbol_index, memory_symbol_index = 0, 1


def run_cmd(cmd):
    return subprocess.check_output(cmd, shell=True).decode('utf-8')


def get_my_ip():
    return run_cmd(GET_IP_CMD)[:-1]


def get_my_temp():
    return run_cmd(GET_TEMP_CMD)[5:9]

Esempio n. 17
0
        'source': 'http://www.bbc.co.uk/radio/listen/live/r5l_aaclca.pls',
        'info': None
    },
    {
        'name': "Radio 4 Extra",
        'source': 'http://www.bbc.co.uk/radio/listen/live/r4x_aaclca.pls',
        'info': None
    },
    {
        'name': "Planet Rock",
        'source': 'http://tx.sharp-stream.com/icecast.php?i=planetrock.mp3',
        'info': None
    },
]

PLAY_SYMBOL = pifacecad.LCDBitmap(
    [0x10, 0x18, 0x1c, 0x1e, 0x1c, 0x18, 0x10, 0x0])
PAUSE_SYMBOL = pifacecad.LCDBitmap(
    [0x0, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x0, 0x0])
INFO_SYMBOL = pifacecad.LCDBitmap([0x6, 0x6, 0x0, 0x1e, 0xe, 0xe, 0xe, 0x1f])
MUSIC_SYMBOL = pifacecad.LCDBitmap([0x2, 0x3, 0x2, 0x2, 0xe, 0x1e, 0xc, 0x0])

PLAY_SYMBOL_INDEX = 0
PAUSE_SYMBOL_INDEX = 1
INFO_SYMBOL_INDEX = 2
MUSIC_SYMBOL_INDEX = 3


class Radio(object):
    def __init__(self, cad, start_station=0):
        self.current_station_index = start_station
        self.playing_process = None
Esempio n. 18
0
from random import randint

# Setup the PiFace screen, clearing it and hiding the cursor
cad = pifacecad.PiFaceCAD()
cad.lcd.backlight_on()
cad.lcd.clear()
cad.lcd.cursor_off()
cad.lcd.blink_off()

# Create the custom characters for our animations
# As the characters are very thin, designs are spread over two characters
# Unfortunately can only store 8 chars :(
# Characters designed with this handy tool: http://www.quinapalus.com/hd44780udg.html

# The coffee cup
cupBM1 = pifacecad.LCDBitmap([0x0, 0xf, 0x1f, 0x17, 0x10, 0x10, 0x8, 0x7])
cad.lcd.store_custom_bitmap(0, cupBM1)
cupBM2 = pifacecad.LCDBitmap([0x0, 0x10, 0x1e, 0x15, 0x5, 0x6, 0x8, 0x10])
cad.lcd.store_custom_bitmap(1, cupBM2)

# Full steam frame (two frames of animation)
steam1BM1 = pifacecad.LCDBitmap([0x9, 0x9, 0x12, 0x12, 0x9, 0x9, 0x0, 0x0])
cad.lcd.store_custom_bitmap(2, steam1BM1)
steam1BM2 = pifacecad.LCDBitmap([0x12, 0x12, 0x9, 0x9, 0x12, 0x12, 0x0, 0x0])
cad.lcd.store_custom_bitmap(3, steam1BM2)

# Less steam (two frames of animation)
steam2BM1 = pifacecad.LCDBitmap([0x4, 0x4, 0x8, 0x8, 0x4, 0x4, 0x0, 0x0])
cad.lcd.store_custom_bitmap(4, steam2BM1)
steam2BM2 = pifacecad.LCDBitmap([0x4, 0x4, 0x2, 0x2, 0x4, 0x4, 0x0, 0x0])
cad.lcd.store_custom_bitmap(5, steam2BM2)