def dispQrCode(data, imageFile='qr-code.lcd'): # setup the QR Code generator qr = qrcode.QRCode( version=3, error_correction=qrcode.constants.ERROR_CORRECT_L, box_size=10, border=1, ) print '> Encoding %d characters' % (len(data)) qr.add_data(data) qr.make(fit=True) matrix = qr.get_matrix() matrixRows = len(matrix) matrixCols = len(matrix[0]) print '> Generated QR Code: %dx%d pixels' % (matrixCols, matrixRows) # check the size if matrixCols > oledImage.SCREEN_WIDTH or matrixRows > oledImage.SCREEN_HEIGHT: print 'ERROR: Generated QR code is too large for the OLED Display! Try less text!' exit() # double the QR code size if it's less than half of the OLED size dMatrix = oledImage.doubleMatrixSize(matrix) xOffset = oledImage.SCREEN_WIDTH / 2 - len(dMatrix[0]) / 2 ## convert the QR code to an OLED image screen = oledImage.convertToOledImg(dMatrix, xOffset, 0) oledImage.printToFile(screen, imageFile) ## display the image on the OLED Expansion oledExp.driverInit() # initialize the screen oledExp.setDisplayMode(1) # invert the colours oledExp.drawFromFile(imageFile) # display the image file
def welcomeMessage(): oledExp.setVerbosity(0) oledExp.driverInit() oledExp.setCursor(3, 0) oledExp.write("Welcome to OnionOmega") oledExp.setCursor(4, 0) oledExp.write("Data Logger Project") time.sleep(2)
def start_write(): if oledExp.driverInit() != 0: print 'ERROR: Could not initialize the OLED Expansion' return False # this clears the screen oledExp.clear() # this sets the colour oledExp.setDisplayMode(0) #this sets it to receive text oledExp.setTextColumns() #this places the cursor on the second row, first column oledExp.setCursor(1, 0) oledExp.write('Welcome.') oledExp.setCursor(3, 0) oledExp.write('Loading ticker..') oledExp.setCursor(5, 0) oledExp.write('Prices in EUR.')
def __init__(self, width, height): self.width = width self.height = height self.tick = 0 self.cells = {} self.cached_directions = [ [-1, 1], [0, 1], [1, 1], # above [-1, 0], [1, 0], # sides [-1, -1], [0, -1], [1, -1] # below ] self.populate_cells() self.prepopulate_neighbours() oledExp.driverInit() oledExp.setBrightness(255) oledExp.setDisplayMode(0)
def oledWriteMonero(text, date): if oledExp.driverInit() != 0: print 'ERROR: Could not initialize the OLED Expansion' return False # write out the monero oledExp.write(text)
def initial_setup(): status_oled = oledExp.driverInit() status_relay = relayExp.driverInit(7) # 7 is the address of the Relay Expansion; 7 is when all relay switches are switched OFF check = relayExp.readChannel(7, 0) # (7, 0) - again 7 is the address and 0 is the relay channel if check == 1: close_lock() with open('data.json') as json_file: # Your UIDs could be different, make changes to the data.json file according to your settings data = json.load(json_file) return data['accepted'] return None
def init_screen(): """ Initalizaed the screen. """ global is_init is_init = not oledExp.driverInit() if is_init: # show a welcome sign for 2 sec, create thread? x = 2 else: print "Problem initializing screen" return is_init
def main(argv): global g_relayAddress, g_pingStarted, g_pingSuccess, g_pingFailCount, g_buttonsConnected g_relayAddress = int(argv[1]) get_ip_address() print("g_relayAddress is " + str(g_relayAddress)) oledExp.driverInit() client.on_message = on_message client.on_connect = on_connect client.on_disconnect = on_disconnect client.connect(broker) oledExp.setDisplayPower(1) relayExp.driverInit(g_relayAddress) g_gpioHandler.setOutputDirection(0) try: client.subscribe("control/#") client.loop_start() while True: time.sleep(1); if g_pingStarted: if g_pingSuccess: g_pingSuccess = False elif g_pingSuccess == False: g_pingFailCount += 1 if g_pingFailCount > 5: turn_pump_off() g_buttonsConnected = False print_status() g_pingStarted = False g_pingFailCount = 0 except KeyboardInterrupt: print("exiting on ctrl-c") client.disconnect() #disconnect client.loop_stop() #stop loop g_buttonsConnected = False relayExp.setChannel(g_relayAddress, 0, 0) relayExp.setChannel(g_relayAddress, 1, 0) time.sleep(2) sys.exit(0)
def oledWriteTweet(user, text, date): if oledExp.driverInit() != 0: print 'ERROR: Could not initialize the OLED Expansion' return False # write out the name of the account oledExp.write('@' + user + ':') # set the cursor to the next line oledExp.setCursor(1, 0) # write out the tweet oledExp.write(text)
def init(dirName): oledExp.setVerbosity(-1) status = oledExp.driverInit() if status != 0: print 'ERROR initializing OLED Expansion' ## setup the display # draw the plant image to the screen imgFile = dirName + "/thermometer.oled" if os.path.exists(imgFile): status = oledExp.drawFromFile(imgFile) ## write the default text # write the first word on the second line and the right side of the screen oledExp.setTextColumns() oledExp.setCursor(1,12) oledExp.write('Temp:')
def writeHeadline(title, time, author): if oledExp.driverInit() != 0: print 'ERROR: Could not initialize the OLED Expansion' return False oledExp.clear() # writes the authors at the bottom - might overflow back to page 0 oledExp.setCursor(6, 0) oledExp.write(author) # writes the headline to the screen to clear overflow from author oledExp.setCursor(0, 0) oledExp.write(' ' + title) # indenting the title to look a bit better # writes timestamp at the end to ensure it doesn't get overwritten oledExp.setCursor(5, 0) oledExp.write(time)
import OmegaExpansion.oledExp as oled oled.driverInit() oled.setDisplayPower(1) oled.setDisplayMode(0) oled.clear() oled.setCursor(0, 0) oled.write("Hello") oled.setCursor(2,0) oled.write("World!")
from OmegaExpansion import oledExp import time print 'Starting to use oled-exp functions...' oledExp.setVerbosity(0) # initialize ret = oledExp.driverInit() print "driverInit return: ", ret if (ret != 0): exit() # write a character ret = oledExp.writeChar('x') print "writeChar return: ", ret if (ret != 0): exit() time.sleep(2) # invert the colours ret = oledExp.setDisplayMode(1) print "setDisplayMode return: ", ret if (ret != 0): exit() time.sleep(2) # dim ret = oledExp.setDim(1)
# oled expansion helper from OmegaExpansion import oledExp MAX_CHARACTERS = 21 oledExp.setVerbosity(-1) oledExp.driverInit() oledExp.clear() def clear(): oledExp.clear() def writeLines(lines, startingRow=0, startingColumn=0, printBlock=False): # set the cursor to the beginning of the row where you want to start printing oledExp.setCursor(startingRow, startingColumn) # write the lines row by row for i in range(0, len(lines)): # choose between printing at column 0 on newlines # or printing from the same column if i == 0 or printBlock: column = startingColumn else: column = 0 oledExp.setCursor(startingRow + i, column) oledExp.write(lines[i])
import time import onionGpio from OmegaExpansion import oledExp from requests import get from dns import resolver from datetime import datetime oledExp.driverInit(1) oledExp.setBrightness(0) oledExp.setTextColumns() gpio_rled = onionGpio.OnionGpio(17) gpio_gled = onionGpio.OnionGpio(16) gpio_bled = onionGpio.OnionGpio(15) gpio_rled.setOutputDirection(0) gpio_gled.setOutputDirection(0) gpio_bled.setOutputDirection(0) time.sleep(0.25) #Blink white 1 second to confirm LED function flag_global_error = False def color_blink(r, g, b, duration=0.25, sleep=0.25): #LED GPIO 1 means LOW and 0 means HIGH gpio_rled.setValue(1 - r) gpio_gled.setValue(1 - g) gpio_bled.setValue(1 - b) if duration > 0: time.sleep(duration) gpio_rled.setValue(1) gpio_gled.setValue(1)
from OmegaExpansion import oledExp import time print 'Starting to use oled-exp functions...' oledExp.setVerbosity(0) # initialize ret = oledExp.driverInit() print "driverInit return: ", ret if (ret != 0): exit() # write a character ret = oledExp.writeChar('x') print "writeChar return: ", ret if (ret != 0): exit() time.sleep(2) # invert the colours ret = oledExp.setDisplayMode(1) print "setDisplayMode return: ", ret if (ret != 0): exit() time.sleep(2) # dim ret = oledExp.setDim(1) print "setDim return: ", ret if (ret != 0):
USB_MOUNT = '/mnt/torrent' SLEEP = 2 import os import time import transmissionrpc from OmegaExpansion import oledExp status = oledExp.driverInit() oledExp.setTextColumns() while True: # find size of free space on USB statvfs = os.statvfs(USB_MOUNT) total = float(statvfs.f_blocks) * statvfs.f_frsize / 1000000000 free = float(statvfs.f_bfree) * statvfs.f_frsize / 1000000000 # find transmission info tc = transmissionrpc.Client('localhost', port=9091) torrents = tc.get_torrents() download = False rateDownload = 0 rateUpload = 0 for t in torrents: if t.status == 'downloading': download = True filename = t.name percentDone = t.percentDone rateUpload += t.rateUpload rateDownload += t.rateDownload oledExp.setCursor(0, 0) oledExp.write('Date: ' + time.strftime("%d %b %y %H:%M"))
def __init__(self): self._status = oledExp.driverInit()
import OmegaExpansion.oledExp as oled oled.driverInit() oled.setDisplayPower(1) oled.setDisplayMode(0) oled.clear() oled.setCursor(0, 0) oled.write("Hello") oled.setCursor(2, 0) oled.write("World!")
# encoding: utf-8 from OmegaExpansion import oledExp import math, time, os ## initialisation print('Starting the program proofingBox...') # initialisation the oled expansion lcd = oledExp.driverInit() if lcd != 0: print('Error initalizing OLED Expansion') # set verbosity oledExp.setVerbosity(0) # set the brightness lcd = oledExp.setBrightness(127) if lcd != 0: print('Error setting the brightness for the OLED Expansion') # set up the boot display (show an image for 10 seconds) imgBoot = "/home/proofingBox/initImg.lcd" if os.path.exists(imgBoot): oledExp.drawFromFile(imgBoot) time.sleep(1) oledExp.clear() ## get the target and actual temperature values ## TODO preparation the readout: https://docs.onion.io/omega2-docs/communicating-with-1w-devices.html tempTrg = "25" # tempAct = awk -F= '/t=/ {printf "%.03f\n", $2/1000}' /sys/devices/w1_bus_master1/XXXXX/w1_slave tempAct = "21"
def write(): ### this gets the date and time date = time.strftime("%d %b %Y %H:%M") #time_now = time.strftime("%X") ### these are the API calls for the four currencies response_1 = urllib2.urlopen( 'https://api.coinmarketcap.com/v1/ticker/bitcoin/?convert=EUR') r_1 = json.load(response_1) response_2 = urllib2.urlopen( 'https://api.coinmarketcap.com/v1/ticker/monero/?convert=EUR') r_2 = json.load(response_2) response_3 = urllib2.urlopen( 'https://api.coinmarketcap.com/v1/ticker/iconomi/?convert=EUR') r_3 = json.load(response_3) response_4 = urllib2.urlopen( 'https://api.coinmarketcap.com/v1/ticker/siacoin/?convert=EUR') r_4 = json.load(response_4) ### this sets a place value for the Decimal round up cents = Decimal('0.001') #cents2 = Decimal('0.0001') ### these set the JSON resturns to variables c_1 = r_1[0] c_2 = r_2[0] c_3 = r_3[0] c_4 = r_4[0] ### this grabs info from the dictionaries, and makes them variables c_1_sym = c_1['symbol'] #c_1_price = round(float(c_1['price_eur']), 2) c_1_price = c_1['price_eur'] c_1_price = Decimal(c_1_price).quantize(cents, ROUND_HALF_UP) c_1_per = c_1['percent_change_24h'] c_2_sym = c_2['symbol'] #c_2_price = round(float(c_2['price_eur']), 2) c_2_price = c_2['price_eur'] c_2_price = Decimal(c_2_price).quantize(cents, ROUND_HALF_UP) c_2_per = c_2['percent_change_24h'] c_3_sym = c_3['symbol'] #c_3_price = round(float(c_3['price_eur']), 2) c_3_price = c_3['price_eur'] c_3_price = Decimal(c_3_price).quantize(cents, ROUND_HALF_UP) c_3_per = c_3['percent_change_24h'] c_4_sym = c_4['symbol'] #c_3_price = round(float(c_3['price_eur']), 2) c_4_price = c_4['price_eur'] c_4_price = Decimal(c_4_price).quantize(cents, ROUND_HALF_UP) c_4_per = c_4['percent_change_24h'] ### this is the write to screen process if oledExp.driverInit() != 0: print 'ERROR: Could not initialize the OLED Expansion' return False ### this clears the screen oledExp.clear() ### this sets the colour oledExp.setDisplayMode(0) ### this sets it to receive text oledExp.setTextColumns() ### this places the cursor on the second row, first column oledExp.setCursor(1, 0) ### oledExp.write(' '+date+' '+time_now) oledExp.write(date) oledExp.setCursor(3, 0) oledExp.write(c_1_sym + ': ' + str(c_1_price) + ' ' + c_1_per + '%') oledExp.setCursor(4, 0) oledExp.write(c_2_sym + ': ' + str(c_2_price) + ' ' + c_2_per + '%') oledExp.setCursor(5, 0) oledExp.write(c_3_sym + ': ' + str(c_3_price) + ' ' + c_3_per + '%') oledExp.setCursor(6, 0) oledExp.write(c_4_sym + ': ' + str(c_4_price) + ' ' + c_4_per + '%') ### this sets the scroll type, speed, etc oledExp.scroll(0, 0, 0, 8 - 1)
def main(): ''' params - so get from db move vare to dict at some point ''' V_S_arr = getV_S_FromDB() #varsArr = getVarsFromDB() varsArr = V_S_arr[:15] minCooldown = varsArr[0] maxCooldown = varsArr[1] maxRunTime = varsArr[2] lowCutOff = varsArr[3] ## ones that are variable and change highCutOff = varsArr[4] ## cooldownTime = int(varsArr[5]) ## runTime = int(varsArr[6]) ## acRunningLowCutOffRaisePercent = varsArr[7] acRunningLowCutOffRaiseTimeMin = varsArr[8] acOffHighCutOffLowerPercent = varsArr[9] acOffHighCutOffLowerPercentNum2 = varsArr[10] acOffHighCutOffLowerTimeMin = varsArr[11] acOffHighCutOffLowerTimeMinNum2 = varsArr[12] state = varsArr[13] #recordID = varsArr[-1] #not sure why it took me this long to change this recordID = varsArr[14] #not sure why it took me this long to change this #settingsArr = getSettngsFromDB() settingsArr = V_S_arr[15:-1] #the idea here (with rough times) is to over cool before midday heat spike '''cooled by 9am or too late it seems''' hour = datetime.datetime.now().hour minute = datetime.datetime.now().minute #''' orig_adjDict = { 5: 0.5, 6: 1.25, 7: 2.0, 8: 2.5, 9: 3.0, 10: 3.25, 11: 3.25, 12: 3.25, 13: 3.25, 14: 3.25, 15: 3.25, 16: 3.25, 17: 3.25, 18: 3.25 } #''' less_far_adjDict = { 5: 0.5, 6: 1.25, 7: 2.0, 8: 2.5, 9: 3.0, 10: 3.0, 11: 3.0, 12: 3.0, 13: 3.0, 14: 3.0, 15: 3.0, 16: 3.0, 17: 3.0, 18: 3.0 } #symetric adjDict = { 3: 0.5, 4: 1.0, 5: 1.5, 6: 2.0, 7: 2.5, 8: 3.0, 9: 3.5, 10: 3.75, 11: 3.5, 12: 3.25, 13: 3.0, 14: 2.5, 15: 2.0, 16: 1.25, 17: 0.5 } #second half neeeds to come back to normal faster preHeatCooling = False #if hour in adjDict:# and getLastOutsideTemp(varsArr[-1]) > 55.0: lastOutsideTemp = V_S_arr[-1] #adjDelta = getAdjDelta(hour, minute, getLastOutsideTemp(recordID), highCutOff) adjDelta = getAdjDelta(hour, minute, lastOutsideTemp, highCutOff) if adjDelta != 0: preHeatCooling = True settingsArr[3] -= adjDelta settingsArr[4] -= adjDelta if hour >= 18: settingsArr[2] += 15 logData('variables loaded, entering readings/logic/settings') logData('recordID: ' + str(recordID)) temp = getTemp(t_id1) temp_source = ' :)' #temporary solution to catch (individual) bad reads #it seems that reading too many reading in close succession might max out the pull up if temp < 40: logData("temp was %s, trying door" % temp) door = getTemp(t_door) temp_source = ' ** door **' if temp < 40: #temp and door failed logData("door was %s, trying hall" % temp) temp = getTemp(t_hall) temp_source = ' ** hall **' #saveTempsToDB([0, 0, temp], varsArr[-1]) #else: #temp failed but door succeeded # #saveTempsToDB([0, temp, 0], varsArr[-1]) #else: # #saveTempsToDB([temp, 0, 0], varsArr[-1]) logData("temp is %s" % temp) logData("temp_source is " + temp_source) logData("state %s" % state) logData("runTime %s" % runTime) logData("cooldownTime %s" % cooldownTime) if temp == -1: #err/senor not registering again logData('temp err') if state == 'ON': #on/ac running if runTime > 10: turnOFF() logData('turned AC OFF, -1') runTime = 0 state = 'OFF' else: runTime += 1 else: #off/ac not running if cooldownTime >= 10: turnON() logData('turned AC ON, -1') cooldownTime = 0 state = 'ON' else: cooldownTime += 1 else: #we good, proceede as normal if state == 'ON': #on/ac running #if (temp < lowCutOff) or (runTime > maxRunTime) or (coolingLimitReached(6, (temp>=((highCutOff+lowCutOff)/2) or preHeatCooling), runTime)): # change limit variable to 4 while running easy till they inspect the unit if (temp < lowCutOff) or (runTime > maxRunTime) or ( coolingLimitReached(6, (temp >= ((highCutOff + lowCutOff) / 2) or preHeatCooling), runTime)): turnOFF() logData('turned AC OFF - ' + str(highCutOff) + ' - ' + str(lowCutOff)) runTime = 0 state = 'OFF' minCooldown = settingsArr[0] maxCooldown = settingsArr[1] maxRunTime = settingsArr[2] lowCutOff = settingsArr[3] highCutOff = settingsArr[4] cooldownTime = settingsArr[5] runTime = settingsArr[6] acRunningLowCutOffRaisePercent = settingsArr[7] acRunningLowCutOffRaiseTimeMin = settingsArr[8] acOffHighCutOffLowerPercent = settingsArr[9] acOffHighCutOffLowerPercentNum2 = settingsArr[10] acOffHighCutOffLowerTimeMin = settingsArr[11] acOffHighCutOffLowerTimeMinNum2 = settingsArr[12] else: runTime += 1 if runTime > acRunningLowCutOffRaiseTimeMin and temp < highCutOff: lowCutOff += acRunningLowCutOffRaisePercent * (temp - lowCutOff) else: #off/ac not running if (temp >= highCutOff and cooldownTime >= minCooldown) or ( cooldownTime > maxCooldown): turnON() logData('turned AC ON - ' + str(highCutOff) + ' - ' + str(lowCutOff)) cooldownTime = 0 state = 'ON' minCooldown = settingsArr[0] maxCooldown = settingsArr[1] maxRunTime = settingsArr[2] lowCutOff = settingsArr[3] highCutOff = settingsArr[4] cooldownTime = settingsArr[5] runTime = settingsArr[6] acRunningLowCutOffRaisePercent = settingsArr[7] acRunningLowCutOffRaiseTimeMin = settingsArr[8] acOffHighCutOffLowerPercent = settingsArr[9] acOffHighCutOffLowerPercentNum2 = settingsArr[10] acOffHighCutOffLowerTimeMin = settingsArr[11] acOffHighCutOffLowerTimeMinNum2 = settingsArr[12] else: cooldownTime += 1 if cooldownTime > acOffHighCutOffLowerTimeMin: ###### this is where weater api comes in...copy out of older code highCutOff -= acOffHighCutOffLowerPercent * (highCutOff - temp) if cooldownTime > acOffHighCutOffLowerTimeMinNum2: #>45 is >15 so it'll lower cutoff twice...reverse order and use if elif or take that into account highCutOff -= acOffHighCutOffLowerPercentNum2 * ( highCutOff - temp) #saveVarsToDB([minCooldown, maxCooldown, maxRunTime, lowCutOff, highCutOff, cooldownTime, runTime, acRunningLowCutOffRaisePercent, acRunningLowCutOffRaiseTimeMin, acOffHighCutOffLowerPercent, acOffHighCutOffLowerPercentNum2, acOffHighCutOffLowerTimeMin, acOffHighCutOffLowerTimeMinNum2, state], recordID) V_T_arr = [] for var in [ minCooldown, maxCooldown, maxRunTime, lowCutOff, highCutOff, cooldownTime, runTime, acRunningLowCutOffRaisePercent, acRunningLowCutOffRaiseTimeMin, acOffHighCutOffLowerPercent, acOffHighCutOffLowerPercentNum2, acOffHighCutOffLowerTimeMin, acOffHighCutOffLowerTimeMinNum2, state ]: V_T_arr.append( var ) #this is to (**) avoid any pointer issues, but since this code runs 1 time and is not a while 1, probably safe to start with V_T_arr = [minC....] and append the temps #(**) help avoid...to make sure i would need to make a None variable and add the var to it and then append it #try: # sendToSite(recordID, temp, highCutOff, lowCutOff, state) #except: # logData("sendToSite failed. temp:"+str(temp)+", highCutOff:"+str(highCutOff)+", lowCutOff:"+str(lowCutOff)+", state:"+state) ### get and update outside temp (l8r other weather details too) try: outside = getWeather(recordID) #saveOutsideTempToDB(outside, varsArr[-1]) #sendOutsideToSite(recordID, outside) except: outside = 82.2882 logData('$ start OLED $') #with regular printing is 8 rows of 21 characters if datetime.datetime.now().hour == 12: #noon hr_min = 'noon:' + str(datetime.datetime.now().minute) elif datetime.datetime.now().hour == 0: #midnight hr_min = 'midnight:' + str(datetime.datetime.now().minute ) #hope those 3 characters arent too much elif datetime.datetime.now().hour > 12: #pm hr_min = str(datetime.datetime.now().hour - 12) + ':' + str( datetime.datetime.now().minute) + ' p' else: #am hr_min = str(datetime.datetime.now().hour) + ':' + str( datetime.datetime.now().minute) + ' a' oledStr = '' #configure fitst line if outside == 82.2882: firstLine = [str(temp)] else: firstLine = [str(temp), 'o: ' + str(outside)] #lastLine = [str(lowCutOff), hr_min, str(highCutOff)] lastLine = [lowCutOff, hr_min, highCutOff] if cooldownTime == 0 and runTime == 0: oledStrArr = [ firstLine, [' cdt: ' + state], [' rnt: ' + state], ['---'], [str(recordID)], [temp_source], lastLine ] else: #display minutes and dash on the mode not active oledStrArr = [ firstLine, [' cdt: ' + str('-' if cooldownTime == 0 else cooldownTime)], [' rnt: ' + str('-' if runTime == 0 else runTime)], ['---'], [str(recordID)], [temp_source], lastLine ] initOled = oledExp.driverInit() MMDD = str(datetime.datetime.now().month) + '-' + str( datetime.datetime.now().day) oledExp.write(prepareOLEDstring(oledStrArr, adjDelta, MMDD)) logData('$ end OLED $') ''' current time to run whole code is ~48 seconds need to narrow timings without locking omega up from too many reads too close together ''' if temp_source == ' :)': #read main sensor no problem #wait 10 seconds and read hall #sleep(10) # running the rest of the script should have given enough time...? try: temp_hall = getTemp(t_hall) logData("*&*&* t_hall = " + str(temp_hall)) #saveHallTempToDB(temp_hall, varsArr[-1]) #sendHallToSite(recordID, temp_hall) except: logData("hall failed") temp_hall = '71.1771' #get attic try: sleep(15) #test showed takes like 27 seconds to run without attic reading #so with sleep 15 still under the 1 minute cronjob mark attic = getTemp(t_attic) logData("AT-_-_-T-_-_-IC* t_attic = " + str(attic)) #saveAtticToDB(attic, varsArr[-1]) #sendAtticToSite(recordID, attic) except: logData("attic failed") attic = '75.5775' #saveTempsToDB([temp, 0, temp_hall, attic, outside], recordID) #for var in [temp, 0, temp_hall]:#, attic, outside]: # V_T_arr.append(var) V_T_arr.extend([temp, 0, temp_hall]) try: #add to oled oledStrArr[2].append('a: ' + str(attic)) #put on oled initOled = oledExp.driverInit() oledExp.write(prepareOLEDstring(oledStrArr, adjDelta, MMDD)) logData('$ OLED contains attic $') except: logData("add attic to oled failed") else: #go back and add get attic here...maybe attic = '75.5775' #this is a failed state so might be better to not so the system has an easy run if temp_source == ' ** door **': #saveTempsToDB([0, temp, 0], recordID) V_T_arr.extend([0, temp, 0]) elif temp_source == ' ** hall **': #saveTempsToDB([0, 0, temp], recordID) V_T_arr.extend([0, 0, temp]) else: logData("!@#$ errorrrrrrrrr $#@!") ############################################ # errorrrrrrrrr ############################################ V_T_arr.extend([attic, outside]) saveV_T_ToDB(V_T_arr, recordID) #sendAllToSite(recordID, temp, highCutOff, lowCutOff, state, temp_hall=71.1771, outside=82.2882, attic=75.5775) try: sendAllToSite(recordID, temp, highCutOff, lowCutOff, state, temp_hall, outside, attic) except Exception as e: logData( "sendAllToSite failed. temp:" + str(temp) + ", highCutOff:" + str(highCutOff) + ", lowCutOff:" + str(lowCutOff) + ", state:" + state + ", temp_hall:" + str(temp_hall) + ", outside:", +str(outside) + ", attic:" + str(attic)) logData('---code run done\n')