time_stamp = time.time() time_now = time_stamp def exec_cmd(cmd): p = os.popen(cmd) result = "" while p.readline(): result = result + p.readline() #.rstrip('\n') return result number = 0 lcd.init() todaysdate = strftime("%H:%M %d/%m/%Y") ipaddr = exec_cmd('hostname -I') lcd.line1(str(todaysdate)) lcd.line2(ipaddr) def switch_event_menu(p): time.sleep(0.4) global MERGE global radio global host global current global vol if GPIO.input(MENU_SWITCH): if MERGE == 0: exec_cmd('su - pi -c "vlc '+host+' -I rc --rc-host 127.0.0.1:4222 --novideo -d && ls"') #porneste radioul cu lista de statii
if n_encode<n_body+50: if n_encode>0: n_body=n_encode n_body=msg.find("\n", n_body) m_body=msg.find("--", n_body) if m_body==-1: mesaj = mesaj+ " Body: " + msg[n_body:] else: mesaj = mesaj + " Body: "+ msg[n_body:m_body] mesaj = mesaj.replace('\n', ' ') mesaj = mesaj.replace (' ', ' ') mesaj = mesaj.replace (' ', ' ') mesaj = mesaj.replace (' ', ' ') print mesaj l=len(mesaj) n=int(l/16)+1 for i in range (2): for i in range (n-1): lcd.line1(mesaj[i*16:((i+1)*16)]) lcd.line2(mesaj[(i+1)*16:((i+2)*16)]) time.sleep(3) for i in range (9): mesaj_array[i] = mesaj_array[i+1] mesaj_array[9]=mesaj # maildump = open('maildump', 'w') for i in range (9): maildump = open('maildump', 'w') maildump.write(mesaj_array[i]+"\n") maildump.close
#!/usr/bin/env python # # Imports from lcd_class import Lcd from time import sleep from time import strftime lcd = Lcd() # LCD interrupt scroll routine def interrupt(): return False lcd.init() lcd.setWidth(16) # Display line 1 and 2 lcd.line1("Line 1: Test LCD") lcd.line2("Line 2: defghijk") sleep(3) while True: todaysdate = strftime("%H:%M %d/%m/%Y") lcd.line1(todaysdate) lcd.scroll2("Line 4: abcdefghijklmnopqrstuvwxyz 0123456789",interrupt) # End
def exec_cmd(cmd): p = os.popen(cmd) result = "" while p.readline(): result = result + p.readline() #.rstrip('\n') return result number = 0 lcd.init() todaysdate = strftime("%H:%M %d/%m/%Y") ipaddr = exec_cmd('hostname -I') text_line1= str(todaysdate) lcd.line1(text_line1) text_line2 = ipaddr lcd.line2(text_line2) def switch_event_menu(p): # time.sleep(0.4) GPIO.remove_event_detect(p) global MERGE global radio, time_stamp global host global current, warp global vol global text_line1, text_line2, text_line1_old, text_line2_old time_now = time.time() # print time_now-time_stamp if (time_now - time_stamp) >= 0.8: if GPIO.input(MENU_SWITCH):