示例#1
0
    def __init__(self, lcd_line_num = 2):
        '''
        Initializer for our LCD UI. Activates the LCD and sets a couple of
        internal attributes for process management.
        '''
        if lcd_line_num <= 0:
            raise ValueError("Number of LCD lines cannot be zero or less than zero")
        self.lcd_line_num = lcd_line_num

        self.sensor_array = sensors.SensorArray()

        self.stop_data_acquisition = False

        if not self.sensor_array:
            raise ValueError("Cannot initialize sensor array")

        # Grove LCD at any connector marked as I2C on the Grove Base Shield.
        # This would be I2C bus number 0.
        # Double init is a workaround for a known issue, see
        # https://github.com/intel-iot-devkit/upm/issues/280
        self.grove_lcd = lcd.Jhd1313m1(0)
        del self.grove_lcd
        time.sleep(0.5)
        self.grove_lcd = lcd.Jhd1313m1(0)
        if not self.grove_lcd:
            raise ValueError("Cannot initialize Grove LCD")
        
        # Green backlight, hardcoded for simplicity
        self.grove_lcd.setColor(0, 255, 0)
示例#2
0
def grove_lcd(text_addr, rgb_addr):
    if device_type == DEVICE_TYPE_MRAA:
        return lcd.Jhd1313m1(0, text_addr, rgb_addr)
    elif device_type == DEVICE_TYPE_RPI:
        return lcd
    elif device_type == DEVICE_TYPE_GPI:
        raise NotImplementedError
示例#3
0
 def __init__(self, message, color=(255, 0, 0), time_wait=10):
     threading.Thread.__init__(self)
     self.mLcd = lcd.Jhd1313m1(0, 0x3E, 0x62)
     self.mLcd.setCursor(0, 0)
     self.mLcd.setColor(color[0], color[1], color[2])
     self.message = message
     self.time_wait = time_wait
示例#4
0
def dataRotary(mqttclient):

    knob = grove.GroveRotary(3)
    myLcd = lcd.Jhd1313m1(0, 0x3E, 0x62)
    twythonid = twitterHandler()

    while True:
        abs = knob.abs_value()
        myLcd.setCursor(0, 0)
        myLcd.write('Health System')
        myLcd.setColor(0, 128, 0)
        myLcd.setCursor(1, 0)
        myLcd.write('Heart Rate %s' % abs)
        while (abs > 950):
            myLcd.setColor(255, 0, 0)
            id = str(randint(0, 1000))
            status = "0x" + id + " #IoTLab Health System Heart Rate Warning " + str(
                abs)
            mqttclient.publish("IoTPy/Buzzer", "None")
            twythonid.update_status(status=status)
            data = {}
            data['alive'] = "1"
            data['warning'] = "1"
            data['message'] = status
            dweepy.dweet_for('IoTHealthSystem', data)
            time.sleep(1.5)
            data['warning'] = "0"
            data['message'] = ""
            dweepy.dweet_for('IoTHealthSystem', data)
            break
        time.sleep(0.25)
示例#5
0
    def setScreen(self):
        myLcd = lcd.Jhd1313m1(0, 0x3E, 0x62)
        myLcd.clear()

        myLcd.setColor(int(self.info["r"]), int(self.info["g"]),
                       int(self.info["b"]))
        myLcd.setCursor(int(self.info["y"]), int(self.info["x"]))
        myLcd.write(str(self.info["message"]))

        return "Mensaje enviado"
示例#6
0
def inicializa_LCD():
    sleep(5)
    myLcd = lcd.Jhd1313m1(0, 0x3E, 0x62)  #Inicializo o lcd na variavel myLcd
    myLcd.setCursor(0, 0)  #seta a posicao inicial do cursor
    myLcd.setColor(53, 39, 249)  #cor de fundo em RGB
    myLcd.displayOff()
    sleep(1)
    myLcd.displayOn()

    return myLcd
    def showValues(temperature, humidity):

        # Initialize Jhd1313m1 at 0x3E (LCD_ADDRESS) and 0x62 (RGB_ADDRESS)
        myLcd = lcd.Jhd1313m1(0, 0x3E, 0x62)
        myLcd.setCursor(0, 0)
        myLcd.write('Temperature ')
        myLcd.write(str(temperature))
        myLcd.setCursor(1, 0)
        myLcd.write('Humidty ')
        myLcd.write(str(humidity))
        sleep(30)
示例#8
0
def main():
    # Initialize Jhd1313m1 at 0x3E (LCD_ADDRESS) and 0x62 (RGB_ADDRESS)
    myLcd = lcd.Jhd1313m1(0, 0x3E, 0x62)

    myLcd.setCursor(0, 0)
    # RGB Blue
    #myLcd.setColor(53, 39, 249)

    # RGB Red
    myLcd.setColor(255, 0, 0)

    myLcd.write('Hello World')
    myLcd.setCursor(1, 2)
    myLcd.write('Hello World')
示例#9
0
 def on_connection_success(self):
     """
     This is called on successful connection to the server. It first sends
     an initial message to the server to initialize the channel by setting
     its mode and also by providing its client name with which to be
     identified.
     """
     from random import randint
     global iot_connected
     if (prefs.getboolean("defaults", "lcd_en")):
         self.thisLCD = lcd.Jhd1313m1(0, 0x3E, 0x62)
     iot_connected = True
     logging.info('IoT Connected! Conn:%s' % str(iot_connected))
     self.send_message('channel', 'setchannelmode', {
         'channelmode': 'control',
         'clientname': 'SB' + str(randint(0, 100))
     })
     pool_tx = ThreadPool(processes=1)
     async_tx = pool_tx.apply_async(self.inspect_queue_for_messages, ())
示例#10
0
    def __init__(self):
        self.screen = pyupm_i2clcd.Jhd1313m1(6, 0x3E, 0x62)
        self.clearScreen()

        self.light = grove.GroveLight(2)

        self.mic = upmMicrophone.Microphone(1)
        self.threshContext = upmMicrophone.thresholdContext()
        self.threshContext.averageReading = 0
        self.threshContext.runningAverage = 0
        self.threshContext.averagedOver = 2

        self.piezo = ldt0028.LDT0028(0)

        self.button = mraa.Gpio(3)
        self.button.dir(mraa.DIR_IN)

        self.buzzer = mraa.Gpio(6)
        self.buzzer.dir(mraa.DIR_OUT)
        self.buzzer.write(0)
示例#11
0
def config_lcd():
    tlcd = lcd.Jhd1313m1(0, 0x3E, 0x62)
    return tlcd
示例#12
0
文件: server.py 项目: ktkirk/HSSI
 def getLCD(self):
     if self.lcd is None:
         # Initialize Jhd1313m1 at 0x3E (LCD_ADDRESS) and 0x62 (RGB_ADDRESS)
         self.lcd = lcd.Jhd1313m1(0, 0x3E, 0x62)
         #self.lcd.old_write = self.lcd.write
     return self.getProxyObject(self.lcd)
RequisitaConsumoAcumuladoAgua = "02014C0000"  #opcode 'L', endereco 0x01
RequisitaVazaoInstantaneaAgua = "0201560000"  #opcode 'V', endereco 0x01
ResetConsumoAgua = "0201520000"  #opcode 'R', endereco 0x01
IniciaCalibracaoAgua = "0201450000"  #opcode 'E', endereco 0x01
FinalizaCalibracaoAgua = "0201530000"  #opcode 'S', endereco 0x01

#definicao dos frames enviados para o sistema bare-metal de luminosidade
ComandoVersaoLuminosidade = "0202560000"  #opcode 'V', endereco 0x02
ComandoLeituraLuminosidade = "02024C0000"  #opcode 'L', endereco 0x02

#definicao dos frames enviados para o sistema bare-metal de temperatura
ComandoVersaoTemperatura = "0203560000"  #opcode 'V', endereco 0x03
ComandoLeituraTemperatura = "0203540000"  #opcode 'T', endereco 0x03

#definicao, configuracao e inicializacao de I/Os da placa
lcdDisplay = lcd.Jhd1313m1(
    0, 0x3E, 0x62)  #Configura e inicializa comunicacao com display LCD
#0x3E: endereco i2c do controlador LCD
#0x62: endereco i2c do controlador responsavel pelo RGB

#definicao de parametros da criptografia proprietaria
ChavePublica = "QCON2016QCON2016"  #Chave publica usada na encriptacao. Deve ser conhecida pelo client que fara a decriptacao


def on_message(client, userdata, msg):
    """
		Callback - chamado quando alguma mensagem eh recebida
		Corresponde a parte do sistema que opera sob demanda.
	"""
    global EmailConsumoJaFoiEnviado
    global EstaEmCalibracao
示例#14
0
#define the buttons connected to the intel edison
button1 = grove.GroveButton(4)
button2 = grove.GroveButton(3)
button1b = grove.GroveButton(5)
button2b = grove.GroveButton(6)

#initialization of our variables
check = True  #to avoid measuring press and hold
checkb = True  #to avoid measuring press and hold
pressed = False  #this way we can determine if a button was already pressed
same1 = False  #in case the same button has been pressed
same2 = False  #in case the same button has been pressed
pressedb = False  #this way we can determine if a button was already pressed
same1b = False  #in case the same button has been pressed
same2b = False  #in case the same button has been pressed
mylcd = lcd.Jhd1313m1(0, 0x3E,
                      0x62)  #make mylcd reference the lcd screen connected
writeScreen(mylcd, total, count)
screenColor(mylcd, total, count)

while 1:

    if button1.value(
    ) and check:  #if button is pressed and it's not the case of a press and hold
        check = False  #check changes to false to avoid a press and hold
        if same1:  #if it was pressed twice in a row, it changes the values back to normal
            same1 = False
            pressed = False
        elif pressed and not (
                same1
        ):  #if it's the second press and it's not the same button twice
            count += 1  #count increases since a car entered the zone
示例#15
0
    for i in range(0,int(ceil(len(cQuote)/16)-1)):
            myLCD.setCursor(0,0)
            myLCD.write(cQuote[i*16:i*16+15])
            myLCD.setCursor(1,0)
        myLCD.write(cQuote[(i+1)*16:(i+1)*16+15])
        sleep(1)
'''



factlist = makeList(open("factlist.txt", "r"))
print factlist
firebase = firebase.FirebaseApplication('https://shining-heat-4946.firebaseio.com', authentication=None)
result = firebase.get('/Coffee Status', None)
servo = s.ES08A(5)
lcd = l.Jhd1313m1(0, 0x3E, 0x62)
lcd.setCursor(0, 0)
lcd.write("Initializing...")
api = twitter.Api(consumer_key='oXjVRo8KcyBHEcrR76rzdiwf3', consumer_secret='tHRflbSX73giyVkkYZJ3H2h09rVUrnyllRbFOJ8qMibNGAjanS',
    access_token_key='701115311790149634-fiW66eYxY9xv46kvVpgTP7BcHTmF6D7', access_token_secret='UhgInppxQszb795xsiy6reB8nNfjjpwHvLWmPitvmfbqj')
sleep(1)


def turnOn():
        servo.setAngle(100)
        sleep(2)
        fact = scrollRand()
    tweet(fact)

def tweet(message):
    api.PostUpdate('Espresso started. ' + message) {}
示例#16
0
import pyupm_i2clcd as lcd
import mraa
import time
import sys

pot = mraa.Aio(0)
EdisonLCD = lcd.Jhd1313m1(0, 0x3E, 0x62)
EdisonLCD.setColor(0, 255, 0)

while 1:
    potVal = float(pot.read())
    EdisonLCD.setCursor(0, 0)
    EdisonLCD.write(str(potVal))
    time.sleep(1)
    EdisonLCD.clear()
示例#17
0
文件: lcd.py 项目: JerryLui/galileo
import pyupm_i2clcd as upm_lcd
import pyupm_grove, time, mraa
from datetime import datetime
from pytz import timezone
import pytz

CET = timezone('CET')
lcd = upm_lcd.Jhd1313m1(0, 0x3E, 0x62)
temp = pyupm_grove.GroveTemp(2)
light = mraa.Aio(0)
var = 25
oldtime = 'holder'
lcd.setColor(var,0,0)

while 1:
    newtime = datetime.strftime(datetime.now(tz=CET), '%Y-%m-%d %H:%M')
    if oldtime != newtime: 
        lcd.clear()
        if light.read() < 480 and light.read() > 200:
            if var > 50:
                var -= 5
                lcd.setColor(var,0,0)
            elif var < 50:
                var += 5
                lcd.setColor(var,0,0)
        elif light.read() < 180:
            if var > 25:
                var -= 5
                lcd.setColor(var,0,0)
        else:
            if var < 125:
示例#18
0
    myLCD.clear()
    myLCD.setColor(255, 255, 255)
    myLCD.setCursor(0, 0)
    myLCD.write("FaceLock")
    myLCD.setCursor(1, 0)
    myLCD.write("Press button")

    servo.write(0)


BUTTON_PIN = 2
button = mraa.Gpio(BUTTON_PIN)
button.dir(mraa.DIR_IN)

## The LCD can only display 16 characters per line
myLCD = lcd.Jhd1313m1(0, 0x3E, 0x62)

servo = Servo("Lock")
servo.attach(3)

greeting()

while True:

    if button.read():

        permissionGranted = authenticate()

        if permissionGranted:
            granted()
        else:
示例#19
0
                apagado = True

        if len(linha) >= 14:
            if linha[len(linha) - 14] == 'X':  #caracteristica do enter
                lendo = False

        myLcd.setCursor(0, 0)
        for j in range(tam):
            myLcd.write('*')

    return str(linha)


####################### MAIN BEHAVIOUR ################################
sleep(5)
myLcd = lcd.Jhd1313m1(0, 0x3E, 0x62)  #Inicializo o lcd na variavel myLcd

myLcd.setCursor(0, 0)  #seta a posicao inicial do cursor

myLcd.setColor(53, 39, 249)  #cor de fundo em RGB

myLcd.displayOff()
sleep(1)
myLcd.displayOn()

#adiciona_usuario()

erro = 0
is_blocked = False
counter = 0
示例#20
0
#! /usr/bin/python

import cv2
import numpy
import socket
import zbar
import Image
import time
import mraa
import pyupm_i2clcd as grove_lcd

## I2C LCD e LED
lcd = grove_lcd.Jhd1313m1(0, 0x3E, 0x62)
led = mraa.Gpio(2)
led.dir(mraa.DIR_OUT)
led.write(0)


## funcao para escrever no LDC
def write(L1, L2, C1=255, C2=0, C3=0):
    lcd.clear()
    lcd.setColor(C1, C2, C3)
    lcd.setCursor(0, 0)
    lcd.write(L1)
    lcd.setCursor(1, 0)
    lcd.write(L2)
    return


## OpenCV e mraa Version
OpenCV_version = str(cv2.__version__)
def alert_lcd():
    x = lcd.Jhd1313m1(0, 0x3E, 0x62)
    tempstr = "                  "
    x.setCursor(0, 0)
    x.setColor(255, 0, 0)
    x.write('High Temp!!!')
示例#22
0
import signal
import sys
import time

import pyupm_grove as grove
import pyupm_grovespeaker as upmGrovespeaker
import pyupm_i2clcd as lcd

from telegram.ext import Updater, CommandHandler, MessageHandler, Filters

credentials = ConfigParser.ConfigParser()
credentialsfile = "credentials.config"
credentials.read(credentialsfile)

button = grove.GroveButton(8)
display = lcd.Jhd1313m1(0, 0x3E, 0x62)
light = grove.GroveLight(0)
relay = grove.GroveRelay(2)


def functionLight(bot, update):
    luxes = light.value()
    bot.sendMessage(update.message.chat_id, text='Light ' + str(luxes))


def functionMessage(bot, update):
    bot.sendMessage(update.message.chat_id, text=message)


def functionRelay(bot, update):
    relay.on()
示例#23
0
 def __init__(self):
     self.ID = 2010
     self.myLcd = lcd.Jhd1313m1(0, 0x3E, 0x62)
     print "LCD Actuator init success"
 def __init__(self, bus, red, green, blue):
     self.lcd = upmLcd.Jhd1313m1(bus, self.__class__.lcd_i2c_address,
                                 self.__class__.rgb_i2c_address)
     self.lcd.clear()
     self.set_background_color(red, green, blue)
from datetime import datetime
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters

credentials = ConfigParser.ConfigParser()
credentialsfile = "credentials.config"
credentials.read(credentialsfile)
controlmode = 1
Angle = 0

# Create the button object usind D3
button = grove.GroveButton(3)
# Create the servo object using D6
gServo = servo.ES08A(6)
# Initialize Jhd1313m1 at 0x3E (LCD_ADDRESS) and 0x62 (RGB_ADDRESS)
myLcd = lcd.Jhd1313m1(0, 0x3E, 0x62)
# Create the light sensor object using AIO pin 2
light = grove.GroveLight(2)
# Create the temperature sensor object using AIO pin 2
#temp = grove.GroveTemp(2)
# Create relay object using D5
relay = grove.GroveRelay(5)
# Initialize TH02 temperature sensor at 0x40
gTemp = temp.TH02(0, 0x40)

# Initialize servo to 0 degrees
gServo.setAngle(Angle)


def functionLight(bot, update):
    luxes = light.value()
示例#26
0
#!/usr/bin/python

# ========== * IMPORT SECTION * ========== #

# UPM Modules
import pyupm_i2clcd as lcd
import pyupm_grove as g
from time import sleep

# BT Needed Modules
import spp as s

# ========= * SETTING UP GPIOS * ========= #
light = g.GroveLight(0)  # Light sensor is connected to slot A0
display = lcd.Jhd1313m1(0, 0x3E, 0x62)  # LCD goes on any I2C slot
relay = g.GroveRelay(4)  # Relay module is connected to slot D4

# ========= * PROJECT FUNCTIONS * ======== #

# ------------ LCD Functions ------------- #


# Display light sensor data
def displayLightInfo():
    display.clear()  # Clear LCD
    display.setCursor(0, 0)  # Set LCD cursor position (top left corner)
    display.write('Light:%s' % str(light.value()))  # Display light sensor data
    sleep(1)


# Display message on LCD
def norm_lcd():
    x = lcd.Jhd1313m1(0, 0x3E, 0x62)
    tempstr = "                  "
    x.setCursor(0, 0)
    x.setColor(0, 0, 255)
    x.write('Normal Temp')
示例#28
0
import paho.mqtt.client as mqtt
import mraa
import pyupm_i2clcd as lcd

lcdDisplay = lcd.Jhd1313m1(0, 0x3E, 0x62)  #LCD initialization

#Callback  - called when the connection is established
def on_connect(client, userdata, flags, rc):
    print("Connected to server. Connection code: "+str(rc))

    # Do a subscribe to "MQTTEdison" topic whenever a new connection is 
done 
    client.subscribe("MQTTEdison")

# Callback - called when a new message is received / published
def on_message(client, userdata, msg):
	#writes on console screen the topic and the message received
	print("Topico: "+msg.topic+" - Mensagem recebida: 
"+str(msg.payload)) 
	
	#writes on LCD Display the message received
	lcdDisplay.setColor(0,255,255)
	lcdDisplay.setCursor(0, 0)
	lcdDisplay.write("Mensagem:")
	lcdDisplay.setCursor(1, 0)
	lcdDisplay.write(str(msg.payload))
	
#main program
client = mqtt.Client()
client.on_connect = on_connect   #configures callback for new connection 
established
示例#29
0
import mraa
import pyupm_i2clcd
import pyupm_grove as grove
import pyupm_buzzer as upmBuzzer
import time

#redlight on port D8
#self.redLightState = 0
#self.redLight = mraa.Gpio(8)
#self.redLight.dir(mraa.DIR_OUT)

#lcd on i2c
lcd = pyupm_i2clcd.Jhd1313m1(6, 0x3E, 0x62)
lcd.clear()
lcd.setColor(50, 50, 255)
lcd.setCursor(0, 0)
lcd.write("Hello!")
time.sleep(1)
lcd.write("ck!")
time.sleep(1)
示例#30
0
import serial, pyupm_i2clcd

ard = serial.Serial('/dev/tty96B0', 9600)
lcd = pyupm_i2clcd.Jhd1313m1(0, 0x3e, 0x62)


def showTemp(humid, temp):
    lcd.clear()
    lcd.setCursor(0, 0)
    lcd.write(humid)
    lcd.setCursor(1, 0)
    lcd.write("Temp:" + temp + " C")
    lcd.setColor(255, 180, 180)


if __name__ == '__main__':
    print("Welcome to the Humidity & Temperature reader!!!")
    try:
        while True:
            ardOut = ard.readline()
            if ardOut.find("Humidity:") != -1:
                ardHumid = ardOut.split('Temperature')[0]
                ardTemp = ardOut.split('Temperature:')[1]
                showTemp(ardHumid, ardTemp)
    except KeyboardInterrupt:
        lcd.setColor(0, 0, 0)
        lcd.clear()
        print("CTRL-C!! Exiting...")