Example #1
0
def init():
  lcd.init()
  lcd.cls()
  lcd.backlight(ON)

  wiringpi.pinMode(BUTTON_OK,INPUT)
  wiringpi.pinMode(BUTTON_FKEY,INPUT)
Example #2
0
def main():
    lcd.init()
    lcd.set_contrast(190)
    lcd.backlight(1)
    lcd.text("adresses:")
    ip = subprocess.check_output("hostname -I", shell=True)
    lcd.locate(0,1)
    lcd.text(str(ip.strip()) )
Example #3
0
def main():
    lcd.init()
    lcd.cls()
    lcd.data(smiley)
    lcd.locate(2,2)
    lcd.data(ch)
    lcd.locate(3,0)
    lcd.text("c.a.h.")
    lcd.backlight(1)
Example #4
0
def main():
    lcd.init()
    lcd.cls()
    lcd.data(smiley)
    lcd.locate(2, 2)
    lcd.data(ch)
    lcd.locate(3, 0)
    lcd.text("c.a.h.")
    lcd.backlight(1)
Example #5
0
def main():
    lcd.init()
    lcd.backlight(1)
    sample = CpuTemperature()
    #sample = LoadAverage()
    buf = RingBuffer(84)

    while True:
        current = sample.data()
        buf.append(current)
        lcd.image(render(buf))
        lcd.locate(0,0)
        lcd.text(sample.format(current))
        time.sleep(1)
Example #6
0
def main():
    lcd.init()
    lcd.backlight(1)
    sample = CpuTemperature()
    #sample = LoadAverage()
    buf = RingBuffer(84)

    while True:
        current = sample.data()
        buf.append(current)
        lcd.image(render(buf))
        lcd.locate(0, 0)
        lcd.text(sample.format(current))
        time.sleep(1)
Example #7
0
    , 832: (95.9, "MBC FM"), 831: (  91.9, "MBC FM4U")
    , 834: (103.5, "SBS 러브 FM"), 835: ( 107.7, "SBS 파워 FM")
    , 822 :( 98.1 ,"CBS 표준 FM"), 821: ( 93.9, "CBS 음악 FM")
    , 823: ( 104.5, "EBS 라디오")
    , 820: ( 101.9, "BBS 불교방송"), 837: ( 95.1, "TBS 교통방송")
      # , 'MILITARY': 101.1
      # , 'EASTPOLE': 106.9, 'AFN': 102.7, 'KYUNGKI': 99.9
      # , 'YTNRADIO': 94.5, 'PYNGHWA': 104.5
}

import json, requests
import sys , time
from PIL import Image,ImageDraw,ImageFont
import pcd8544.lcd as lcd

lcd.init()
lcd.cls()

# load an available True Type font
font = ImageFont.truetype("/usr/share/fonts/truetype/unfonts-core/UnBatang.ttf", 14)

# New b-w image

#im = Image.new('1', (84,48))
# New drawable on image
#draw = ImageDraw.Draw(im)

tea = tea5767()
global isHolding
isHolding = False
global old_val
Example #8
0
          lcd.backlight(OFF)
      except KeyError:
        pass

  def on_error(self, status_code):
    print >> sys.stderr, 'Encountered error with status code:', status_code
    putstr("Error: " + str(status_code), 0, 5)
    return True # Don't kill the stream

  def on_timeout(self):
    print >> sys.stderr, 'Timeout...'
    putstr("Error: Timeout", 0, 5)
    return True # Don't kill the stream

try:
  lcd.init()
  lcd.cls()
  lcd.backlight(ON)
  putstr("Wearable Eject", 0, 0)
  putstr("Starting", 0, 5)

  auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
  auth.set_access_token(access_key, access_secret)
  api = tweepy.API(auth)
  putstr("Connect twtr.", 0, 5)
  me = api.me()
  putstr("Get profile. ", 0, 5)

  sapi = tweepy.streaming.Stream(auth, CustomStreamListener())
  putstr("Start stream.", 0, 5)
  lcd.backlight(OFF)
def daemon():
    client = InfluxDBClient('localhost',
                            8086,
                            'USER',
                            'PASSWORD',
                            DBNAME,
                            timeout=30)
    ow.init('localhost:4304')
    lcd.init()
    logging.debug("Daemon starting")
    logging.debug("Create INFLUX database: " + DBNAME)
    errors = 0
    try:
        client.create_database(DBNAME)
    except InfluxDBClientError:
        logging.debug("%s DB already exist" % DBNAME)
        pass
    except:
        logging.exception("Error")
        lcd.text("Exception")
    try:
        client.create_retention_policy('awesome_policy', '3d', 3, default=True)
    except InfluxDBClientError:
        logging.debug("%s policy already exist" % DBNAME)
        pass

    for i in range(10):
        try:
            devices = ow.Sensor('/').sensorList()
            date = datetime.now()
            points = []
            for o in read_dht11():
                devices.append(o)
            devices.append(calc_power())
            devices.append(read_max6675())
            for sensor in devices:
                name = sensor.address
                try:
                    value = float(sensor.value)
                except:
                    value = float(ow.Sensor('/%s' % name).temperature11)
                desc = name
                json_body = {
                    "time": date.strftime('%Y-%m-%dT%H:%M:%SZ'),
                    "measurement": "rosma_temps",
                    "tags": {
                        "sensor": name,
                    },
                    "fields": {
                        "value": value
                    }
                }

                points.append(json_body)
                value2lcd(date.strftime('%d/%m/%y %H:%M:%S'), name, desc,
                          value)
                logging.debug(json_body)
                cms = EmonCms(cms_url)
                cms.append(name, value)
                #cms_status = cms.post()
                cms_status = True
                if cms_status:
                    logging.debug("CMS Post ok")
                else:
                    logging.debug("CMS Post failed")
            status = client.write_points(points)
            if status:
                lcd.text("Sent<-OK")
                logging.debug(status)
            else:
                lcd.text("Error!")
                logging.error(status)
            #Show status
            s = 0
            lcd.cls()
            while s < sleep:
                lcdstatusupdate(len(devices), s)
                time.sleep(1)
                s += 1
        except:
            logging.exception("Error occurred %s" % sys.exc_info()[1])
            lcd.text("%s Exception!" % errors)
            time.sleep(1)
            if errors == 10:
                lcd_blink("Rebooting!")
                d = threading.Thread(name='beeper', target=beeper)
                d.setDaemon(True)
                d.start()
                #os.system("reboot")
                d.join()
            else:
                errors += 1
    logging.debug("Daemon exiting")
    return (0)
Example #10
0
 def __init__(self):
   # Initialize LCD
   lcd.init()
   # Turn the backlight on/off and adjust it
   lcd.backlight(0)
            fields = []
            continue

        field = line.strip().split('=')
        # print(field)
        fields.append(field[1].decode('utf-8'))

    fd.close()
    os.close(fifo)

    lcd.cls()


if __name__ == '__main__':

    lcd.init(contrast=0xBB)
    demo()

    time.sleep(2)
    lcd.cls()

    display_volume_bar()
    display_banner()

    font_info = {
        'font': Font('Zpix.ttf', 12),
        'imageFont1': ImageFont.truetype("Zpix.ttf", 12),
        'imageFont2': ImageFont.truetype("DejaVuSansMono.ttf", 12),
    }

    read_now_playing(**font_info)
Example #12
0
 def __init__(self):
     # Initialize LCD
     lcd.init()
     # Turn the backlight on/off and adjust it
     lcd.backlight(0)
Example #13
0
def main():
    lcd.init()
    lcd.backlight(1)
    stats()
def daemon():
    client = InfluxDBClient('cms.emon.ee', 8086, 'USER', 'PASSWORD', DBNAME,timeout=30)
    ow.init('localhost:4304')
    lcd.init()
    logging.debug("Daemon starting")
    logging.debug("Create INFLUX database: " + DBNAME)
    errors = 0
    try:
        client.create_database(DBNAME)
    except InfluxDBClientError:
        logging.debug("%s DB already exist" % DBNAME)
        pass
    except:
        logging.exception("Error")
        lcd.text("Exception")
   # try:
   #     client.create_retention_policy('awesome_policy', '3d', 3, default=True)
   # except InfluxDBClientError:
   #     logging.debug("%s policy already exist" % DBNAME)
   #     pass

    
    while True:
        try:
            devices = ow.Sensor('/').sensorList()
            date = datetime.now()
            points=[]
            for o in read_dht11():
                devices.append(o)
            devices.append(calc_power())
            for sensor in devices:
                name = sensor.address
                try:
                    value = float(sensor.value)
                except:
                    value = float(ow.Sensor('/%s' % name).temperature11)
                desc = name
                json_body = {   
                       "time": date.strftime('%Y-%m-%dT%H:%M:%SZ'),
                       "measurement": "rosma_temps",
                       "tags": {
                           "sensor": name,
                       },
                       "fields": {
                           "value": value
                       }
                   }
                points.append(json_body)
                value2lcd(date.strftime('%d/%m/%y %H:%M:%S'),name,desc,value)
                logging.debug(json_body)
            status=client.write_points(points)
            if status:
                lcd.text("Sent<-OK")
                logging.debug(status)
            else:
                lcd.text("Error!")
                logging.error(status)
            #Show status
            s=0
            lcd.cls()
            while s<sleep:
                lcdstatusupdate(len(devices),s)
                time.sleep(1)
                s+=1
        except:
                logging.exception("Error occurred %s" % sys.exc_info()[1])
                lcd.text("%s Exception!" % errors)
                time.sleep(1)
                if errors == 10:
                     lcd_blink("Rebooting!")
                     d = threading.Thread(name='beeper', target=beeper)
                     d.setDaemon(True)
                     d.start()
                     #os.system("reboot")
                     d.join()
                else:
                    errors += 1
    logging.debug("Daemon exiting")
    return(0)
Example #15
0
 def __init__(self):
     lcd.init()
     lcd.backlight(1)
     lcd.cls()