Beispiel #1
0
    def setup_screen(self):
        """ Set up the screen and the labels that display
            values on it. 
        """
        ugfx.init()
        width=ugfx.width()
        height=ugfx.height()
        ugfx.clear(ugfx.html_color(0x800080))
        style = ugfx.Style()
        style.set_enabled([ugfx.WHITE, ugfx.html_color(0x800080), ugfx.html_color(0x800080), ugfx.html_color(0x800080)])
        style.set_background(ugfx.html_color(0x800080))
        ugfx.set_default_style(style)
        ugfx.orientation(90)
        ugfx.set_default_font(ugfx.FONT_TITLE)
        ugfx.Label(0, 0, width, 60,"Air Quality", justification=ugfx.Label.CENTER)
        label_height=45
        self.ppm10_label = ugfx.Label(0, label_height, width, label_height,"PPM 10: starting", justification=ugfx.Label.CENTER)
        self.ppm25_label = ugfx.Label(0, label_height*2, width, label_height,"PPM 2.5: starting", justification=ugfx.Label.CENTER)

        self.temp_label = ugfx.Label(0, label_height*3, width, label_height,"Temp: starting", justification=ugfx.Label.CENTER)
        self.humid_label = ugfx.Label(0, label_height*4, width, label_height,"Humid: starting", justification=ugfx.Label.CENTER)
        self.error_label = ugfx.Label(0, label_height*5, width, label_height,"", justification=ugfx.Label.CENTER)
        self.message_label = ugfx.Label(0, label_height*6, width, label_height,"", justification=ugfx.Label.CENTER)
        self.error_count = 0
        self.error_message = ""
        self.neopix = Neopix()
        self.p10_decode = ((100,0x00ff00),(250,0xffff00),(350,0xff8000),(430,0xff0000),(-1,0xcc6600))
        self.p25_decode = ((60, 0x00ff00),(91, 0xffff00), (121,0xff8000),(251,0xff0000),(-1,0xcc6600))
Beispiel #2
0
___title___        = "EMFCamp Rainbow Homescreen"
___license___      = "MIT"
___categories___   = ["Homescreens"]
___dependencies___ = ["homescreen"]
___launchable___   = False
___bootstrapped___ = False

import ugfx
from homescreen import *
import time
from tilda import Buttons
from machine import Pin
from machine import Neopix

torch = Pin(Pin.GPIO_FET)
neo = Neopix()

# Padding for name
intro_height = 30
intro_text = "Hi! I'm"
name_height = 60
status_height = 20
info_height = 30
logo_path = "emfcampqueer_home/pridelogo.png"
logo_height = 150
logo_width = 56

# Maximum length of name before downscaling
max_name = 8

torch_on = False
Beispiel #3
0
    0xEBEBEB, 0xE8E8E8, 0xE5E5E5, 0xE3E3E3, 0xE0E0E0, 0xDEDEDE, 0xDBDBDB,
    0xD9D9D9, 0xD6D6D6, 0xD4D4D4, 0xD1D1D1, 0xCFCFCF, 0xCCCCCC, 0xC9C9C9,
    0xC7C7C7, 0xC4C4C4, 0xC2C2C2, 0xBFBFBF, 0xBDBDBD, 0xBABABA, 0xB8B8B8,
    0xB5B5B5, 0xB3B3B3, 0xB0B0B0, 0xADADAD, 0xABABAB, 0xA8A8A8, 0xA6A6A6,
    0xA3A3A3, 0xA1A1A1, 0x9E9E9E, 0x9C9C9C, 0x999999, 0x969696, 0x949494,
    0x919191, 0x8F8F8F, 0x8C8C8C, 0x8A8A8A, 0x878787, 0x858585, 0x828282,
    0x7F7F7F, 0x7D7D7D, 0x7A7A7A, 0x787878, 0x757575, 0x737373, 0x707070,
    0x6E6E6E, 0x6B6B6B, 0x696969, 0x666666, 0x636363, 0x616161, 0x5E5E5E,
    0x5C5C5C, 0x595959, 0x575757, 0x545454, 0x525252, 0x4F4F4F, 0x4D4D4D,
    0x4A4A4A, 0x474747, 0x454545, 0x424242, 0x404040, 0x3D3D3D, 0x3B3B3B,
    0x383838, 0x363636, 0x333333, 0x303030, 0x2E2E2E, 0x2B2B2B, 0x292929,
    0x262626, 0x242424, 0x212121, 0x1F1F1F, 0x1C1C1C, 0x1A1A1A, 0x171717,
    0x141414, 0x121212, 0x0F0F0F, 0x0D0D0D, 0x0A0A0A, 0x080808, 0x050505,
    0x030303
]
n = Neopix()
ugfx.init()
ugfx.clear()
ugfx.text(5, 5, "PRESS B TO PARTY, A TO QUIT", ugfx.BLACK)


def ledChange():
    print("led change!")
    RedLEDNum = random.randint(0, 1)
    GreenLEDNum = random.randint(0, 1)

    if RedLEDNum == 0:
        LED(LED.RED).on()
    else:
        LED(LED.RED).off()
Beispiel #4
0
"""Scan for and display nearby bluetooth devices"""

___title___ = "Bluetooth Scan"
___license___ = "MIT"
___dependencies___ = ["sleep", "app", "sim800"]
___categories___ = ["Other", "System"]

import ugfx, app
from machine import Neopix
np = Neopix()

import sim800
from tilda import Buttons
from time import sleep

btrestore = False
duration = 10
status_height = 20

ugfx.init()
ugfx.clear()
ugfx.set_default_font(ugfx.FONT_FIXED)


def instructions(duration):
    ugfx.Label(5, 180, 240, 30,
               "Press A to start, B to change scan length or MENU to exit")
    ugfx.Label(5, 210, 240, 15, "Scan requires ~{0} seconds".format(duration))


if not sim800.btison():
Beispiel #5
0
class Air_Quality_Display():
    
    def setup_screen(self):
        """ Set up the screen and the labels that display
            values on it. 
        """
        ugfx.init()
        width=ugfx.width()
        height=ugfx.height()
        ugfx.clear(ugfx.html_color(0x800080))
        style = ugfx.Style()
        style.set_enabled([ugfx.WHITE, ugfx.html_color(0x800080), ugfx.html_color(0x800080), ugfx.html_color(0x800080)])
        style.set_background(ugfx.html_color(0x800080))
        ugfx.set_default_style(style)
        ugfx.orientation(90)
        ugfx.set_default_font(ugfx.FONT_TITLE)
        ugfx.Label(0, 0, width, 60,"Air Quality", justification=ugfx.Label.CENTER)
        label_height=45
        self.ppm10_label = ugfx.Label(0, label_height, width, label_height,"PPM 10: starting", justification=ugfx.Label.CENTER)
        self.ppm25_label = ugfx.Label(0, label_height*2, width, label_height,"PPM 2.5: starting", justification=ugfx.Label.CENTER)

        self.temp_label = ugfx.Label(0, label_height*3, width, label_height,"Temp: starting", justification=ugfx.Label.CENTER)
        self.humid_label = ugfx.Label(0, label_height*4, width, label_height,"Humid: starting", justification=ugfx.Label.CENTER)
        self.error_label = ugfx.Label(0, label_height*5, width, label_height,"", justification=ugfx.Label.CENTER)
        self.message_label = ugfx.Label(0, label_height*6, width, label_height,"", justification=ugfx.Label.CENTER)
        self.error_count = 0
        self.error_message = ""
        self.neopix = Neopix()
        self.p10_decode = ((100,0x00ff00),(250,0xffff00),(350,0xff8000),(430,0xff0000),(-1,0xcc6600))
        self.p25_decode = ((60, 0x00ff00),(91, 0xffff00), (121,0xff8000),(251,0xff0000),(-1,0xcc6600))

    def get_reading_color(self, value, decode):
        for item in decode:
            if item[0] < 0:
                # reached the upper limit - return
                return item[1]
            if value < item[0]:
                return item[1]
    
    def new_readings(self,ppm10_value, ppm25_value):
        """ Called by the sensor to deliver new values to the screen.
            Will also trigger the reading of the temperature and humidity
            values.
        """
        self.ppm10_label.text("PPM 10: "+str(ppm10_value))
        self.ppm25_label.text("PPM 2.5: "+str(ppm25_value))
        temp = Sensors.get_hdc_temperature()
        temp_string = "Temp: {0:2.1f}".format(temp)
        self.temp_label.text(temp_string)
        humid = Sensors.get_hdc_humidity()
        humid_string = "Humidity: {0:2.1f}".format(humid)
        self.humid_label.text(humid_string)
        # Calculate some colours
        self.neopix.display((self.get_reading_color(ppm25_value, self.p25_decode),self.get_reading_color(ppm10_value, self.p10_decode)))

    def error(self, error_message):
        """ Called by the sensor to deliver an error message. 
        Args:
            error_message: error message string
        """
        self.error_count = self.error_count + 1
        self.error_label.text( "Errors: " +str(self.error_count))
        self.message_label.text(str(error_message))
Beispiel #6
0
           ugfx.width(),
           info_height,
           "Press MENU",
           justification=ugfx.Label.CENTER)

ugfx.set_default_font(ugfx.FONT_SMALL)
status = ugfx.Label(0,
                    ugfx.height() - info_height * 2 - status_height,
                    ugfx.width(),
                    status_height,
                    "",
                    justification=ugfx.Label.CENTER)

from tilda import Sensors
from machine import Neopix
n = Neopix()
# update loop
while True:
    text = ""
    value_wifi_strength = wifi_strength()
    value_battery = battery()
    lux = Sensors.get_lux()
    if lux < 1000:
        n.display([0xffffff, 0xffffff])
    elif lux < 2000:
        n.display([0xff00ff, 0xff00ff])
    elif lux < 3000:
        n.display([0x0000ff, 0x0000ff])
    elif lux < 4000:
        n.display([0x00ffff, 0x00ffff])
    elif lux < 5000:
Beispiel #7
0
'''Party thing
'''

___author___ = 'Skybound - ECS'
___name___ = 'Party'
___license___ = 'MIT'
___categories___ = ['LEDs']
___bootstrapped___ = False

from app import restart_to_default
import random
from machine import Neopix
from tilda import Buttons

n = Neopix()

mapping = {0: 0x000001, 1: 0x000100, 2: 0x010000}

exit = False


def breakout(x):
    global exit
    exit = True


Buttons.enable_interrupt(Buttons.BTN_Menu,
                         breakout,
                         on_press=True,
                         on_release=False)
import os, tilda
from machine import Neopix

n=Neopix()
n.display([0,0,0])
n.display([0,0,0])

print("EMF: boot.py")
os.sync()
root = os.listdir()

def app(a):
    if (a in root) and ("main.py" in os.listdir(a)):
        return a + "/main.py"

def file(file, remove):
    try:
        a = None
        with open(file, 'r') as f:
            a = f.read().strip()
        if remove:
            os.remove(file)
        return app(a)
    except Exception as e:
        print("Not found: %s" % file)

def any_home():
    h = [a for a in root if a.startswith("home")]
    return h[0] if len(h) else False

if "no_boot" in root:
Beispiel #9
0
    0x00FFFF,
    0x0000FF,
    0xFF00FF,
    0xFA8072,
]
ledColourCount = len(ledColours)

logo_path = "shared/sw.png"
logo_height = 121
logo_width = 240

mute = False

# Setup
init()
neopix = Neopix()
ugfx_helper.init()
speaker.enabled(True)

####################
####################
####################

notes = [
    {
        "name": "G3",
        "midi": 55,
        "time": 1.5,
        "velocity": 0.6299212598425197,
        "duration": 0.1572916666666666
    },
Beispiel #10
0
"""This app tests all the onboard sensors and system info"""

___title___ = "Memobadge"
___license___ = "MIT"
___dependencies___ = ["app", "sim800", "sleep", "ugfx_helper"]
___categories___ = ["Sound"]

import ugfx, app, sim800, time
from tilda import Buttons
from machine import Neopix

ugfx.init()
ugfx.clear()
ugfx.set_default_font(ugfx.FONT_FIXED)

neopix = Neopix()


def displayControls():
    ugfx.Label(5, 0, 240, 15, "Controls:")
    ugfx.Label(5, 15, 240, 15, "  A: Start / Stop recording")
    ugfx.Label(5, 30, 240, 15, "  B: playback")
    ugfx.Label(5, 45, 240, 15, "  Menu: exit")


def displayStatus(status):
    ugfx.Label(5, 90, 240, 15, status)


def setRecordingStatus():
    global neopix, isRecording
Beispiel #11
0

def show_boot():
    ugfx.display_image(0, 0, "holland/start.png")


ugfx_helper.init()
ugfx.clear()
show_boot()

import sim800
import time
from tilda import Buttons

sim800.poweron()
n = Neopix()

vip = False
vip_inv = False
strobe = False


def cbButtonA(button_id):
    global vip
    vip = False
    show_flag()


def cbButtonB(button_id):
    global vip
    vip = True
Beispiel #12
0
                                                  ((1 - ((6 * angle) - 4)) *
                                                   (intensity - 1)),
                                                  (intensity - 1), 1)
    else:
        return (intensity, 0, intensity * 6 *
                (1 - angle)) if intensity < 1 else (1, (intensity - 1),
                                                    (6 * (1 - angle)) +
                                                    ((1 - (6 * (1 - angle))) *
                                                     (intensity - 1)))


ugfx_helper.init()
ugfx.clear()

maxHeight = ugfx.height()
n = Neopix()

# Draw colour swatch
for x in range(ugfx.width()):
    intensity = x / ugfx.width()
    for y in range(maxHeight):
        (r, g, b) = getColour(intensity, y / ugfx.height())
        colour = (int(31 * r) << 11) + (int(63 * g) << 5) + int(31 * b)
        ugfx.area(x, y, 1, 1, colour)

i = 0
j = 0
ugfx.area((i - 1) if i > 0 else 0, (j - 1) if j > 0 else 0, 3 if
          (i > 0 and i < (ugfx.width() - 1)) else 2, 3 if
          (j > 0 and j < (maxHeight - 1)) else 2, ugfx.WHITE)
while (not Buttons.is_pressed(Buttons.BTN_A)) and (not Buttons.is_pressed(
Beispiel #13
0
import ugfx_helper, os, wifi, ugfx, http, time, sleep, app
import sim800
from tilda import Buttons
from machine import Neopix
import utime
import random

playback_start = 0
last_update = 0

ugfx_helper.init()
ugfx.clear()

# Clear LEDs
leds = Neopix()
YELLOW = 0xffff00
RED = 0xff0000
BLACK = 0x000000

CURRENT = YELLOW, RED

db = ugfx.html_color(0x843c06)
lb = ugfx.html_color(0xe1962d)

PACKETSIZE = 1024
SPEED = 0


def setup_audio():
    with open('robotnik/robotnik.amr', 'rb') as wavefile: