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): global nextsensorcheck, graph now = time.time() if (now > nextsensorcheck ) and offset == 0 and peripherals.touched() == False: peripherals.get_sensors() peripherals.get_infrared() nextsensorcheck = now + 0.1 text.regen() i = 0 for varname in showvars: y_vals[i][:-1] = y_vals[i][1:] y_vals[i][-1] = getattr(peripherals.eg_object, varname) i += 1 graph.update(y_vals) grapharea.draw() if offset != 0: offset = graphics.slider_change(text.text, offset) else: graph.draw() text.draw() activity = False return activity, offset
if config.show_airquality: redvalue = 255 if peripherals.eg_object.a4 > 600 else int(0.03 * peripherals.eg_object.a4) greenvalue = 0 if peripherals.eg_object.a4 > 400 else int(0.02*(400 - peripherals.eg_object.a4)) peripherals.controlled([redvalue,greenvalue,0]) if config.startmqttclient: mqttclient.publishall() textchange = True if not config.subslide: if now > nexttm and not peripherals.touched(): # change background nexttm = now + config.TMDELAY a = 0.0 sbg = sfg sbg.positionZ(5) pic_num = (pic_num + 1) % nFi sfg = graphics.tex_load(iFiles[pic_num]) if a < 1.0: # fade to new background activity = True #we calculate more frames, when there is activity, otherwise we add sleep.time at end a += 0.01 sbg.draw() sfg.set_alpha(a) sfg.draw()
while graphics.DISPLAY.loop_running(): now = time.time() if not config.subslide: if a < 1.0: # fade to new background activity = True # we calculate more frames, when there is activity, otherwise we add sleep.time at end a += 0.01 sbg.draw() sfg.set_alpha(a) sfg.draw() if peripherals.touched( ): # and (peripherals.lasttouch + 0.4 > time.time()): # check if touch is pressed, to detect sliding x, y = peripherals.get_touch() activity = True if ((x != 400) and peripherals.lastx): # catch 0,0 -> 400,-240 movex = (peripherals.lastx - x) if (abs(movex) > 40): # calculate slider movement slide_offset = movex else: # autoslide demo mode if len( config.autoslides ) and peripherals.eg_object.backlight_level > 0 and peripherals.lasttouch + 10 < now and now > autoslide: movex += 10