Пример #1
0
def getCurrentPanelSettings():
    """get the currently set values for what the light panel is supposed to reflect"""
    global gradientSet, lightOn, currentPosition
    gradientSet = data.getJSONFromDataFile(
        '/home/pi/SolarBar/data/gradient.data')
    lightOn = data.getJSONFromDataFile('/home/pi/SolarBar/data/lightOn.data')
    try:
        currentPosition = int(
            data.getJSONFromDataFile('/home/pi/SolarBar/data/position.data'))
        currentPosition = int(currentPosition * 4.5)
    except:
        currentPosition = 0
    print "getCurrentPanelSettings() = gradientSet: " + str(
        gradientSet) + " / lightOn: " + str(
            lightOn) + " / currentPosition: " + str(currentPosition)
Пример #2
0
def checkLatestNotification():
    ''' get the latest phone notification set from the other script '''
    notificationInfo = data.getJSONFromDataFile('notification.data')
    if notificationInfo == "":
        notificationInfo = Notification.Notification()
        notificationInfo = json.loads(notificationInfo.to_JSON())
    return notificationInfo
Пример #3
0
def showTimeWeather():
    '''show time and weather'''
    global previousTime, previousIndoorTemp, previousOutdoorTemp

    # update time and weather
    now = datetime.now()
    tempInfo = data.getJSONFromDataFile('temp.data')
    weatherInfo = data.getJSONFromDataFile('weather.data')

    if tempInfo != '' and weatherInfo != '':
        time = now.strftime("%I:%M")
        indoorTemp = data.convertToString(data.convertToInt(
            tempInfo['temp'])) + "*F"
        outdoorTemp = data.convertToString(
            data.convertToInt(weatherInfo['apparentTemperature'])) + "*F"

        subprocess.call([digoleCommand, "setFont", "123"])

        subprocess.call([digoleCommand, "setColor", "0"])
        subprocess.call(
            [digoleCommand, "printxy_abs", "170", "50", previousTime])
        subprocess.call([digoleCommand, "setColor", "255"])
        subprocess.call([digoleCommand, "printxy_abs", "170", "50", time])

        subprocess.call([digoleCommand, "setFont", "120"])

        subprocess.call([digoleCommand, "setColor", "0"])
        subprocess.call(
            [digoleCommand, "printxy_abs", "150", "90", previousIndoorTemp])
        subprocess.call([digoleCommand, "setColor", "254"])
        subprocess.call(
            [digoleCommand, "printxy_abs", "150", "90", indoorTemp])

        subprocess.call([digoleCommand, "setColor", "255"])
        subprocess.call([digoleCommand, "printxy_abs", "218", "90", "/"])

        subprocess.call([digoleCommand, "setColor", "0"])
        subprocess.call(
            [digoleCommand, "printxy_abs", "240", "90", previousOutdoorTemp])
        subprocess.call([digoleCommand, "setColor", "223"])
        subprocess.call(
            [digoleCommand, "printxy_abs", "240", "90", outdoorTemp])

        previousTime = time
        previousIndoorTemp = indoorTemp
        previousOutdoorTemp = outdoorTemp
Пример #4
0
 def getData(self):
     '''hydrate from specific json file specified in the object constructor'''
     readings = data.getJSONFromDataFile(self.jsonFile)        
     for attr, value in self.__dict__.iteritems():
         setattr(self, attr, readings[attr])
Пример #5
0
                currentPhoneMessage = notificationInfo['message']
                scrollCurrentMessage = True
                currentScrolledPosition = 0
                prevPhoneMessage = currentPhoneMessage
        except (Exception):
            pass

        try:
            # turn the WiFi icon on / off depending
            toggleWifiIcon()
        except (Exception):
            pass

        try:
            # update inside tempurature data
            tempInfo = data.getJSONFromDataFile('temp.data')
            if tempInfo == "":
                tempInfo = CurrentReadings.CurrentReadings()
                tempInfo = json.loads(tempInfo.to_JSON())

            # update inside and outside weather
            insideTemp = str(tempInfo['temp']) + "f"
            if int(tempInfo['temp']) == 0:
                insideTemp = "--f"
        except (Exception):
            insideTemp = "--f"

        try:
            # get outside weather info
            weatherInfo = data.getJSONFromDataFile('weather.data')
            if weatherInfo == "":
Пример #6
0
import includes.data as data
 
# define fonts
font = ImageFont.load_default()
titleFont = ImageFont.truetype('/home/pi/CarComputer/computer/fonts/DroidSansMono.ttf', 20)
bodyFont = ImageFont.truetype('/home/pi/CarComputer/computer/fonts/TheNextFont.ttf', 24)

# device and screen settings
device = ssd1306()
currentDirection = 0
while True:
    try:
        with canvas(device) as draw:
        
            # location.data
            locationInfo = data.getJSONFromDataFile('location.data')
            if locationInfo != "":
                # calculate line angle from GPS degrees convert to radians, but only if we're moving more than 5mph
                if (int(locationInfo['speed']) > 5):
                    currentDirection = locationInfo['track']
                draw.text((70, 2), str(int(currentDirection)) + "*", font=titleFont, fill=255)
                draw.text((70, 40), str(data.getHeadingByDegrees(currentDirection)), font=bodyFont, fill=255)
                draw.ellipse((2, 2 , 60, 60), outline=255, fill=0)       
                r = radians(currentDirection)
                radius = 30
                px = round(32 + radius * sin(r))
                py = round(32 - radius * cos(r))
                draw.line((32, 32, px, py), fill=255)
            else:
                draw.text((10, 5), str('GPS'), font=titleFont, fill=255)
                draw.text((10, 30), str('Searching'), font=titleFont, fill=255)
Пример #7
0
# Log to database the current readings for all known info each second as you're driving
# Kevin Hinds http://www.kevinhinds.com
# License: GPL 2.0
import os, time, json
import includes.data as data
import includes.postgres as postgres
import info.CurrentReadings as CurrentReadings
import info.WeatherDetails as WeatherDetails
import info.GPSInfo as GPSInfo
import info.CurrentReadings as CurrentReadings
import info.LocaleDetails as LocaleDetails

# save full datasets to DB each second
while True:
    try:
        locationInfo = data.getJSONFromDataFile('gps.data')
        if locationInfo == "":
            locationInfo = GPSInfo.GPSInfo()
            locationInfo = json.loads(locationInfo.to_JSON())

        localeInfo = data.getJSONFromDataFile('address.data')
        if localeInfo == "":
            localeInfo = LocaleDetails.LocaleDetails()
            localeInfo = json.loads(localeInfo.to_JSON())

        tempInfo = data.getJSONFromDataFile('temp.data')
        if tempInfo == "":
            tempInfo = CurrentReadings.CurrentReadings()
            tempInfo = json.loads(tempInfo.to_JSON())

        weatherInfo = data.getJSONFromDataFile('weather.data')
Пример #8
0
    segment.set_digit(0, digit1)
    segment.set_digit(1, digit2)
    segment.set_digit(2, digit3)
    segment.set_digit(3, digit4)
    segment.set_colon(False)
    segment.set_brightness(brightness)
    segment.write_display()
    
def setDisplayMessageText(message, brightness):
    display.clear()
    display.set_brightness(brightness)
    display.print_str(message[0:0+4])
    display.write_display()
    
# application values loaded from saved data on filesystem
alarm = data.getJSONFromDataFile('/home/pi/SolarBar/data/alarm.data')
sunriseTimeHour = alarm[0]
sunriseTimeMin = alarm[1]
alarmSet = data.getJSONFromDataFile('/home/pi/SolarBar/data/alarmSet.data')
gradientSet = data.getJSONFromDataFile('/home/pi/SolarBar/data/gradient.data')
lightOn = data.getJSONFromDataFile('/home/pi/SolarBar/data/lightOn.data')
prevPosition = data.getJSONFromDataFile('/home/pi/SolarBar/data/position.data')

# run script, check for button presses
toggleAlarmOnLight(alarmSet)
countDown = 0
newPosition = 0
while True:
    try:

        # capture button press from memcache flag
Пример #9
0
# Kevin Hinds http://www.kevinhinds.com
# License: GPL 2.0
import os, time, json
import includes.data as data
import includes.postgres as postgres
import info.CurrentReadings as CurrentReadings
import info.WeatherDetails as WeatherDetails
import info.GPSInfo as GPSInfo
import info.DrivingStatistics as DrivingStatistics
import info.CurrentReadings as CurrentReadings
import info.LocaleDetails as LocaleDetails

# save full datasets to DB each second
while True:
    try:
        locationInfo = data.getJSONFromDataFile('location.data')
        if locationInfo == "":
            locationInfo = GPSInfo.GPSInfo()
            locationInfo = json.loads(locationInfo.to_JSON())
        
        localeInfo = data.getJSONFromDataFile('locale.data')
        if localeInfo == "":
            localeInfo = LocaleDetails.LocaleDetails()
            localeInfo = json.loads(localeInfo.to_JSON())
        
        tempInfo = data.getJSONFromDataFile('temp.data')
        if tempInfo == "":
            tempInfo = CurrentReadings.CurrentReadings()
            tempInfo = json.loads(tempInfo.to_JSON())
        
        weatherInfo = data.getJSONFromDataFile('weather.data')
Пример #10
0
# License: GPL 2.0
import time, commands, subprocess, re, json, sys, os, memcache, json, datetime
import includes.data as data
mc = memcache.Client(['127.0.0.1:11211'], debug=0)

#-------------------------------------------------------------------------------------------------------------
# cronjob runs this script at 4am sleep till alarm set time, then start the sunrise gradient illumination
#-------------------------------------------------------------------------------------------------------------


def percentage(part, whole):
    return 100 * float(part) / float(whole)


# get the upcoming timestamp for when the alarm is set for today
isAlarmSet = data.getJSONFromDataFile("/home/pi/SolarBar/data/alarmSet.data")
alarmTime = data.getJSONFromDataFile("/home/pi/SolarBar/data/alarm.data")
timeNow = datetime.datetime.now()
timeStruct = (timeNow.year, timeNow.month, timeNow.day,
              alarmTime[0], alarmTime[1], timeNow.second,
              datetime.datetime.now().timetuple().tm_wday,
              datetime.datetime.now().timetuple().tm_yday,
              datetime.datetime.now().timetuple().tm_isdst)
alarmTimestamp = time.mktime(timeStruct)

# how long the alarm will run for
seconds = 60 * 30

# if the alarm is set, then begin the sunrise at the designated time
if isAlarmSet == "True":
    timeTillAlarm = alarmTimestamp - time.time()