def advanced_settings(): if request.method == 'GET': cfg = ConfigReader.GetConfig() strip = cfg['strip'] geo = cfg['geo'] return render_template("advanced.html", strip=strip, geo=geo) else: cfg = ConfigReader.GetConfig() strip = cfg['strip'] geo = cfg['geo'] strip['count'] = int(request.form.get('ledCount')) strip['pin'] = int(request.form.get('pinNum')) geo['enabled'] = bool(request.form.get('geoEnabled')) geo['api_key'] = str(request.form.get('apiKey')) geo['location'] = str(request.form.get('location')) geo['default_latitude'] = float(request.form.get('lat')) geo['default_longitude'] = float(request.form.get('lon')) cfg = ConfigReader.Dump(cfg) return redirect('index')
def __init__(self): self.cfg = ConfigReader.GetConfig() if self.cfg['geo']['enabled'] == True: location = self.GetLocation() self.Longitude = location[1] self.Latitude = location[0] else: self.Longitude = self.cfg['geo']['default_longitude'] self.Latitude = self.cfg['geo']['default_latitude']
def index(): cfg = ConfigReader.GetConfig() strip = cfg['strip'] animation_list = cfg['animations'] start_animation = cfg['start_animation'] end_animation = cfg['end_animation'] onDuration = cfg['onTime'] return render_template("index.html", strip=strip, animation_list=animation_list, start_animation=start_animation, end_animation=end_animation, onDuration=onDuration)
def __init__(self): self.cfg = ConfigReader.GetConfig() self.MotionSensor = MotionModule.PIRSensor() #self.MotionSensor.SignalMotion.connect(self.Triggered) self.OnTime = self.cfg['onTime'] self.LedController = LedController.LedController() self.LedController.AnimationCompleteEvent.connect( self.AnimationComplete) self.AnimationIsRunning = False self.TimoutTimer = Timer(self.cfg['motion']['timeout'], self.UpdateLatch, ()) self.TimoutLatch = False self.EndLatch = False self.LastMotion = time.time()
def update_settings(): cfg = ConfigReader.GetConfig() cfg['strip']['brightness'] = int(request.form['brightness']) cfg['strip']['less_than_time'] = request.form['onTime'] cfg['strip']['greater_than_time'] = request.form['endTime'] rgbaVal = request.form['activeColor'] cleanVal = re.sub(r'^.*\(', "", rgbaVal) processedVal = re.sub(r'\)', "", cleanVal).split(',') cfg['strip']['active_color']['R'] = int(processedVal[0]) cfg['strip']['active_color']['G'] = int(processedVal[1]) cfg['strip']['active_color']['B'] = int(processedVal[2]) cfg['start_animation'] = request.form['startAnimation'] cfg['end_animation'] = request.form['endAnimation'] cfg['onTime'] = int(request.form['onDuration']) cfg = ConfigReader.Dump(cfg) return redirect(url_for('index'))
import HardwareModule import time import os import sys import ConfigReader import Log if __name__ == '__main__': cfg = ConfigReader.GetConfig() onTime = cfg['strip']['less_than_time'] endTime = cfg['strip']['greater_than_time'] h = HardwareModule.HardwareController() startTime = time.time() prevTime = startTime try: while 1: nowTime = time.strftime('%H:%M') startTime = time.time() # update config every minute if (startTime - prevTime > 60): cfg = ConfigReader.GetConfig() onTime = cfg['strip']['less_than_time'] endTime = cfg['strip']['greater_than_time'] prevTime = startTime if (nowTime <= onTime): h.Update()