def inloop(textchange=False, activity=False, offset=0): if textchange: text2.regen() if peripherals.touch_pressed: peripherals.touch_pressed = False if peripherals.clicked(Up.x, Up.y): peripherals.eg_object.max_backlight += 1 if peripherals.eg_object.max_backlight > 31: peripherals.eg_object.max_backlight = 31 peripherals.controlbacklight(peripherals.eg_object.max_backlight) text2.regen() elif peripherals.clicked(Down.x, Down.y): peripherals.eg_object.max_backlight -= 1 if peripherals.eg_object.max_backlight < 1: peripherals.eg_object.max_backlight = 1 peripherals.controlbacklight(peripherals.eg_object.max_backlight) text2.regen() elif peripherals.clicked(wifi.x, wifi.y): config.subslide = 'wifisetup' if offset != 0: offset = graphics.slider_change(text2.text, offset) if offset == 0: text2.regen() text2.draw() return activity, offset
def inloop(textchange = False,activity = False, offset = 0): if textchange: text2.regen() if shutterUp.y != -100 and shutterUp.colouring.colour[2] == 1: shutterUp.set_position(y=-100) if (shutterUp.colouring.colour[2] == 0): if shutterUp.y > 0: shutterUp.set_position(y=-100) shutterUp.set_position(y=(shutterUp.y+2)) activity = True if shutterDown.y != -100 and shutterDown.colouring.colour[2] == 1: shutterDown.set_position(y=-100) if (shutterDown.colouring.colour[2] == 0): if shutterDown.y < -99: shutterDown.set_position(y=0) shutterDown.set_position(y=(shutterDown.y-2)) activity = True if peripherals.touch_pressed: peripherals.touch_pressed = False if peripherals.clicked(shutterUp.x,shutterUp.y): peripherals.controlrelays(config.shutterdown, 0) mqttclient.publish("scheinwerfer", '0') peripherals.controlrelays(config.shutterup, 1) shutterUp.colouring.set_colour([0,1,0]) shutterUp.set_text(text_format= chr(0xe00f)) shutterDown.colouring.set_colour([1,1,1]) elif peripherals.clicked(shutterDown.x,shutterDown.y): peripherals.controlrelays(config.shutterup, 0) peripherals.controlrelays(config.shutterdown, 1) mqttclient.publish("scheinwerfer", '1') shutterUp.colouring.set_colour([1,1,1]) shutterDown.colouring.set_colour([0,1,0]) else: peripherals.controlrelays(config.shutterdown, 0) peripherals.controlrelays(config.shutterup, 0) shutterUp.colouring.set_colour([1,1,1]) shutterDown.colouring.set_colour([1,1,1]) if offset != 0: offset = graphics.slider_change(text2.text, offset) if offset == 0: text2.regen() text2.draw() return activity,offset
def inloop(textchange = False,activity = False): str1.draw() str2.draw() str4.draw() if peripherals.touched(): if peripherals.clicked(400,-150): str5.draw() #we deactivate speaker, while talking, to avaoid feedback and increase privacy for door intercoms os.popen('gpio -g write 27 0') #deactivate amplifier os.popen('i2cset -y 2 0x2A 0x93 0xFF') #deactivate vent os.popen("amixer -c 1 set 'PCM' 0%") #deactivate soundcard out os.popen("amixer -c 1 set 'Mic' 100%") #enable mic else: str3.draw() os.popen('gpio -g write 27 1') #deactivate amplifier os.popen('i2cset -y 2 0x2A 0x93 210') #deactivate vent os.popen("amixer -c 1 set 'PCM' 100%") #deactivate soundcard out os.popen("amixer -c 1 set 'Mic' 0%") #enable mic if (peripherals.touch_pressed and (peripherals.lastx < 0)): #only close if left side touched peripherals.touch_pressed = False os.popen('killall nc') #warning just a test os.popen('killall ./videoplayer') os.popen('killall raspivid') config.subslide = None return activity
def inloop(textchange=False, activity=False, offset=0): if textchange: text.regen() text2.regen() if httpbutton.status == 'unknown': get_button_status() if httpbutton.status == 'error': httpbutton.colouring.set_colour([0, 0, 1]) if peripherals.touch_pressed: peripherals.touch_pressed = False if peripherals.clicked(httpbutton.x, httpbutton.y): if httpbutton.status == 'OFF': try: a = urllib.request.urlopen('http://blabla/relais1=1') except: print('error httpbutton') else: #if a.getcode() == 200: #checks http status code 200 = OK httpbutton.colouring.set_colour( [0, 1, 0]) #we change color of button to green httpbutton.status = 'ON' # we could also check response content #if a.read() == 'OK': check content elif httpbutton.status == 'ON': try: a = urllib.request.urlopen('http://blabla/relais1=0') except: print('error httpbutton') else: #if a.getcode() == 200: #checks http status code 200 = OK httpbutton.colouring.set_colour( [1, 0, 0]) #we change color of button to red httpbutton.status = 'OFF' if offset != 0: graphics.slider_change(text2.text, offset) offset = graphics.slider_change(text.text, offset) if offset == 0: httpbutton.status = 'unknown' text.regen() text2.regen() text.draw() text2.draw() return activity, offset
def inloop(textchange=False, activity=False, offset=0): global shuttertimer if textchange: text2.regen() if shutterUp.y != -100 and shutterUp.colouring.colour[2] == 1: shutterUp.set_position(y=-100) if (shutterUp.colouring.colour[2] == 0): if shutterUp.y > 0: shutterUp.set_position(y=-100) shutterUp.set_position(y=(shutterUp.y + 2)) activity = True if shutterDown.y != -100 and shutterDown.colouring.colour[2] == 1: shutterDown.set_position(y=-100) if (shutterDown.colouring.colour[2] == 0): if shutterDown.y < -99: shutterDown.set_position(y=0) shutterDown.set_position(y=(shutterDown.y - 2)) activity = True if (shuttertimer > 0): if (shuttertimer > time.time()): peripherals.eg_object.uhrzeit = str(int(shuttertimer - time.time())) text2.regen() elif (shuttertimer < time.time()): shuttertimer = 0 peripherals.eg_object.uhrzeit = time.strftime("%H:%M") text2.regen() peripherals.controlrelays(config.shutterdown, 0) peripherals.controlrelays(config.shutterup, 0) shutterDown.colouring.set_colour([1, 1, 1]) shutterUp.colouring.set_colour([1, 1, 1]) if peripherals.touch_pressed: peripherals.touch_pressed = False if peripherals.clicked(shutterUp.x, shutterUp.y): peripherals.controlrelays(config.shutterdown, 0) peripherals.controlrelays(config.shutterup, 1) shuttertimer = time.time() + config.shuttertimer shutterUp.colouring.set_colour([0, 1, 0]) shutterDown.colouring.set_colour([1, 1, 1]) elif peripherals.clicked(shutterDown.x, shutterDown.y): peripherals.controlrelays(config.shutterup, 0) peripherals.controlrelays(config.shutterdown, 1) shuttertimer = time.time() + config.shuttertimer shutterUp.colouring.set_colour([1, 1, 1]) shutterDown.colouring.set_colour([0, 1, 0]) else: shuttertimer = 0 peripherals.eg_object.uhrzeit = time.strftime("%H:%M") text2.regen() peripherals.controlrelays(config.shutterdown, 0) peripherals.controlrelays(config.shutterup, 0) shutterUp.colouring.set_colour([1, 1, 1]) shutterDown.colouring.set_colour([1, 1, 1]) if offset != 0: offset = graphics.slider_change(text2.text, offset) if offset == 0: text2.regen() text2.draw() return activity, offset
def inloop(textchange=False, activity=False, offset=0): global controls_alpha if textchange: if peripherals.eg_object.tempoffset > 0: offset_temp_block.colouring.set_colour([1, 0, 0]) elif peripherals.eg_object.tempoffset < 0: offset_temp_block.colouring.set_colour([0, 0, 1]) else: offset_temp_block.colouring.set_colour([1, 1, 1]) red = (0.01 * (peripherals.eg_object.a4 / 4)) if (red > 1): red = 1 green = (0.01 * (120 - peripherals.eg_object.a4 / 4)) if green < 0: green = 0 if green > 1: green = 1 cloud.colouring.set_colour([red, green, 0, 1.0]) if config.coolingrelay: if getattr(peripherals.eg_object, 'relais' + (str)(config.coolingrelay)): cooling.colouring.set_colour([0, 0, 1]) else: cooling.colouring.set_colour([1, 1, 1]) if config.heatingrelay: if getattr(peripherals.eg_object, 'relais' + (str)(config.heatingrelay)): heating.colouring.set_colour([1, 1, 0]) else: heating.colouring.set_colour([1, 1, 1]) if hasattr(peripherals.eg_object, 'pressure'): normalizedpressure = (peripherals.eg_object.pressure - 950) if normalizedpressure < 0: normalizedpressure = 0 if normalizedpressure > 100: normalizedpressure = 100 green = 0.02 * (normalizedpressure) if green > 1: green = 1 red = 0.02 * (100 - normalizedpressure) if red > 1: red = 1 barometer.colouring.set_colour([red, green, 0, 1.0]) baroneedle.set_material([red, green, 0]) baroneedle.rotateToZ(100 - (normalizedpressure * 2)) text.regen() if hasattr(peripherals.eg_object, 'pressure') and offset == 0: baroneedle.draw() if (peripherals.eg_object.motion): motiondetection.colouring.set_colour([1, 0, 0]) else: motiondetection.colouring.set_colour([1, 1, 1]) if peripherals.touch_pressed: peripherals.touch_pressed = False if config.heatingrelay or config.coolingrelay: if peripherals.clicked(increaseTemp.x, increaseTemp.y): controls_alpha = 1 peripherals.eg_object.set_temp += 0.5 set_temp_block.colouring.set_colour([1, 0, 0]) text.regen() if peripherals.clicked(decreaseTemp.x, decreaseTemp.y): controls_alpha = 1 peripherals.eg_object.set_temp -= 0.5 set_temp_block.colouring.set_colour([0, 0, 1]) text.regen() if peripherals.clicked(-330, -180): config.subslide = 'videostream' try: os.popen('killall omxplayer.bin') except: pass os.popen( 'omxplayer --threshold 0.5 --display 4 rtsp://username:[email protected]:554/mpeg4cif --win "0 0 800 450"' ) # loading time depends on keyframes in stream, only h264 recommended! if 'intercom' in config.subslides and peripherals.clicked(-230, -180): config.subslide = 'intercom' try: os.popen('killall omxplayer.bin') os.popen('killall raspivid') except: pass os.popen('gpio -g write 27 1') # deactivate amplifier os.popen('i2cset -y 2 0x2A 0x93 210') # deactivate vent os.popen("amixer -c 1 set 'PCM' 0%") # deactivate soundcard out os.popen("amixer -c 1 set 'Mic' 0%") # enable mic config.iip = '192.168.1.22' config.iuser = '******' config.ipw = 'raspberry' os.popen( 'sshpass -p \'raspberry\' ssh -o StrictHostKeyChecking=no pi@' + config.iip + ' "raspivid -t 0 -w 640 -h 480 -g 10 -ih -fps 25 -l -p \'640,0,160,120\' -o tcp://0.0.0.0:5001"' ) os.popen( 'sshpass -p \'raspberry\' ssh -o StrictHostKeyChecking=no pi@' + config.iip + ' "arecord -D plughw:1,0 -r 12000 -f S16_LE -c1 -B 300 -t wav | nc -l 5003"' ) os.popen( 'raspivid -t 0 -w 640 -h 480 -g 10 -ih -fps 25 -hf -vf -l -p \'640,0,160,120\' -o tcp://0.0.0.0:5002' ) os.popen('sleep 2 && nc ' + config.iip + ' 5001 | ./videoplayer 0 0 640 480') os.popen( 'sleep 2 && nc ' + config.iip + ' 5003 | { dd bs=60K count=1 iflag=fullblock of=/dev/null; aplay -c 1 --device=plughw:1,0 -B 0 -f S16_LE -c1 -r 12000 -t wav; }' ) os.popen( 'arecord -D plughw:1,0 -r 12000 -f S16_LE -c1 -B 300 -t wav | nc -l 5004' ) os.popen( 'sshpass -p \'raspberry\' ssh -o StrictHostKeyChecking=no pi@' + config.iip + ' "nc 192.168.1.33 5002 | ./videoplayer 0 0 640 480"') os.popen( 'sshpass -p \'raspberry\' ssh -o StrictHostKeyChecking=no pi@' + config.iip + ' "nc 192.168.1.33 5004 | { dd bs=60K count=1 iflag=fullblock of=/dev/null; aplay -c 1 --device=plughw:1,0 -B 0 -f S16_LE -c1 -r 12000 -t wav; }"' ) # nc 192.168.1.33 5003 | { dd bs=60K count=1 iflag=fullblock of=/dev/null; aplay -c 1 --device=plughw:1,0 -B 0 -f S16_LE -c1 -r 12000 -t wav; } # arecord -D plughw:1,0 -r 12000 -f S16_LE -c1 -B 300 -t wav | nc -l 5003 if controls_alpha > 0.3: activity = True controls_alpha -= 0.01 if config.heatingrelay or config.coolingrelay: increaseTemp.colouring.set_colour(alpha=controls_alpha) decreaseTemp.colouring.set_colour(alpha=controls_alpha) set_temp_block.colouring.set_colour(alpha=controls_alpha) offset_temp_block.colouring.set_colour(alpha=controls_alpha) if controls_alpha < 0.3: if config.heatingrelay or config.coolingrealy: set_temp_block.colouring.set_colour([1, 1, 1]) if offset != 0: offset = graphics.slider_change(text.text, offset) if offset == 0: text.regen() text.draw() return activity, offset