Esempio n. 1
0
File: aio.py Progetto: walln3r/home
    def updatelcd(self):

        self.getlcddata()

        if self.lcddata != self.old_lcddata:

            lcd = Lcd((self.unit['lcd'][0]['addr'][0:6]),
                      (self.unit['lcd'][0]['addr'][6:8]))

            for index, item in enumerate(self.lcddata):
                if index < 4:

                    lcd.setCursor(0, index)
                    lcd.printString(item)

                else:
                    print 'To many rows to print, max 4'

            if (
                (not self.unit['pir']) and
                (not self.unit['lcd'][0]['backlightState'])
            ):
                self.pwmLcdBacklight(250)

            self.old_lcddata = self.lcddata

        elif (
            (not self.unit['pir']) and
            (self.unit['lcd'][0]['backlightState'])
        ):
            self.pwmLcdBacklight(0)
from datetime import datetime
from subprocess import *
from time import sleep, strftime
from Queue import Queue
from threading import Thread
import os
from nanpy import Arduino, Lcd

Arduino.pinMode(14, input)

lcd = Lcd([8, 9, 4, 5, 6, 7],
          [16, 2])  # Setup the LCD pins for the Sainsmart Shield
lcd.printString("Jess's Web Radio", 0, 0)
lcd.printString("Loading" + "." * 3, 0, 1)
sleep(5)
max_trax = 74
x = 1
loop_menu = 1
loop_radio = 1


def display_ipaddr():
    show_wlan0 = "ip addr show wlan0 | cut -d/ -f1 | awk '/inet/ {printf \"w%15.15s\", $2}'"
    show_eth0 = "ip addr show eth0  | cut -d/ -f1 | awk '/inet/ {printf \"e%15.15s\", $2}'"
    ipaddr = run_cmd(show_eth0)
    if ipaddr == "":
        ipaddr = run_cmd(show_wlan0)
    lcd.printString('IP Address:', 0, 0)
    lcd.printString(ipaddr, 0, 1)
    sleep(2)
Esempio n. 3
0
            else:
                pass

        self.__data = raw

    def getCelsius(self):
        if self.__fetchAddress():
            self.__fetchData()
        return self.__data / 16.0

    def getFahrenheit(self):
        if self.__fetchAddress():
            self.__fetchData()
        return self.getCelsius() * 1.8 + 32.0


from nanpy import Lcd

if __name__ == "__main__":

    lcd = Lcd([7, 8, 9, 10, 11, 12], [16, 2])
    lcd.printString("Loc. London")

    temp_int = FakeDallasTemperature(6)
    temp_ext = FakeDallasTemperature(5)

    while(1):
        lcd.setCursor(0, 1)
        lcd.printString("Ex.%0.0f\xDFC  In.%0.0f\xDFC" % (temp_int.getCelsius(), temp_ext.getCelsius()))

Esempio n. 4
0
#!/usr/bin/env python

# Author: Andrea Stagi <*****@*****.**>
# Description: get the current time from a ntp server and show it on a lcd
# Dependencies: ntplib (http://pypi.python.org/pypi/ntplib/)

import ntplib
from nanpy import (Arduino, Lcd)
from datetime import datetime

ntp_client = ntplib.NTPClient()
response = ntp_client.request('europe.pool.ntp.org', version=3)

time = int(response.tx_time)

lcd = Lcd([7, 8, 9, 10, 11, 12], [16, 2])

while (1):
    lcd.setCursor(0, 0)
    lcd.printString((datetime.fromtimestamp(time)).strftime('%Y-%m-%d'))
    if time % 2:
        time_format = '%H:%M'
    else:
        time_format = '%H %M'
    lcd.setCursor(0, 1)
    lcd.printString((datetime.fromtimestamp(time)).strftime(time_format))
    Arduino.delay(1000)
    time += 1
Esempio n. 5
0
import os
from nanpy import Arduino, Lcd

# Initialize buttons and states
buttonPin = 7
buttonPin2 = 8
buttonState = 0
buttonState2 = 0

# Activate buttons
Arduino.pinMode(buttonPin, input)
Arduino.pinMode(buttonPin2, input)

# Initialize LCD
lcd = Lcd([12, 11, 5, 4, 3, 2], [16, 2])

# Maximum number of stations held in the mpc list
max_trax = 4


# Print station info to LCD
def getTrack():
    L = [S.strip('\n') for S in os.popen('mpc').readlines()]
    station = L[0][0:15]
    track = L[0][-16:-1]
    lcd.printString(16 * " ", 0, 0)
    lcd.printString(station, 0, 0)
    lcd.printString(16 * " ", 0, 1)
    lcd.printString(track, 0, 1)
    print(L)
    print(station)
from nanpy import Arduino
from nanpy import Lcd
import time

lcd = Lcd([12, 11, 5, 4, 3, 2], [16, 2])
lcd.printString('Hello World!')

def taha(N):
	Arduino.pinMode(13, Arduino.OUTPUT)
	while True:
		Arduino.digitalWrite(13, Arduino.HIGH)
		time.sleep(float(N))
		Arduino.digitalWrite(13, Arduino.LOW)
		time.sleep(float(N))
		lcd.setCursor(0, 1)
		lcd.printString(N)
		print N

Esempio n. 7
0
import os
from nanpy import Arduino, Lcd

Arduino.pinMode(14, input)

lcd = Lcd([8, 9, 4, 5, 6, 7], [16, 2])

max_trax = 6


def getKey():
    val = Arduino.analogRead(14)
    if val == 1023:
        return "NONE"
    elif val < 100:
        return "RIGHT"
    elif val < 150:
        return "UP"
    elif val < 330:
        return "DOWN"
    elif val < 510:
        return "LEFT"
    elif val < 750:
        return "SEL"
    else:
        return "KBD_FAULT"


def getTrack():
    L = [S.strip('\n') for S in os.popen('mpc').readlines()]
    station = L[0][0:15]
Esempio n. 8
0
from nanpy import Arduino
from nanpy import Lcd
import time

lcd = Lcd([12, 11, 5, 4, 3, 2], [16, 2])
lcd.printString('Hello World!')


def taha(N):
    Arduino.pinMode(13, Arduino.OUTPUT)
    while True:
        Arduino.digitalWrite(13, Arduino.HIGH)
        time.sleep(float(N))
        Arduino.digitalWrite(13, Arduino.LOW)
        time.sleep(float(N))
        lcd.setCursor(0, 1)
        lcd.printString(N)
        print N
Esempio n. 9
0
# Description: get the current time from a ntp server and show it on a lcd
# Dependencies: ntplib (http://pypi.python.org/pypi/ntplib/)

import ntplib
from nanpy import (SerialManager, Lcd)
from datetime import datetime
from time import sleep

connection = SerialManager()

ntp_client = ntplib.NTPClient()
response = ntp_client.request('europe.pool.ntp.org', version=3)

time = int(response.tx_time)

pins = [7, 8, 9, 10, 11, 12]
cols, rows = 16, 2
lcd = Lcd(pins, [cols, rows], connection=connection)

while (1):
    lcd.setCursor(0, 0)
    lcd.printString((datetime.fromtimestamp(time)).strftime('%Y-%m-%d'))
    if time % 2:
        time_format = '%H:%M'
    else:
        time_format = '%H %M'
    lcd.setCursor(0, 1) 
    lcd.printString((datetime.fromtimestamp(time)).strftime(time_format))
    sleep(1)
    time += 1
Esempio n. 10
0
# Description: get the current time from a ntp server and show it on a lcd
# Dependencies: ntplib (http://pypi.python.org/pypi/ntplib/)

import ntplib
from nanpy import (SerialManager, Lcd)
from datetime import datetime
from time import sleep

connection = SerialManager()

ntp_client = ntplib.NTPClient()
response = ntp_client.request('europe.pool.ntp.org', version=3)

time = int(response.tx_time)

pins = [7, 8, 9, 10, 11, 12]
cols, rows = 16, 2
lcd = Lcd(pins, [cols, rows], connection=connection)

while (1):
    lcd.setCursor(0, 0)
    lcd.printString((datetime.fromtimestamp(time)).strftime('%Y-%m-%d'))
    if time % 2:
        time_format = '%H:%M'
    else:
        time_format = '%H %M'
    lcd.setCursor(0, 1)
    lcd.printString((datetime.fromtimestamp(time)).strftime(time_format))
    sleep(1)
    time += 1
from nanpy import (ArduinoApi, SerialManager, Lcd)
from time import sleep
import datetime

lcd = Lcd([8, 9, 4, 5, 6, 7], [16, 2])
status = 't'
while status == 't':
    lcd.clear()
    lcd.printString(datetime.datetime.now())

    status = input("What status do you want: ")
lcd.clear()
lcd.printString('Dead!!!')

ledPin = 13
ledState = True

try:
    connection = SerialManager()
    a = ArduinoApi(connection=connection)
except:
    print("Failed to connect to Arduino")

a.pinMode(ledPin, a.OUTPUT)

try:
    while True:
        if ledState:
            a.digitalWrite(ledPin, a.LOW)
            ledState = False
            lcd.clear()