from rotary_class_alternative import RotaryEncoderAlternative # To use GPIO 14 and 15 (Serial RX/TX) # Remove references to /dev/ttyAMA0 from /boot/cmdline.txt and /etc/inittab UP = 0 DOWN = 1 CurrentStationFile = "/var/lib/radiod/current_station" CurrentTrackFile = "/var/lib/radiod/current_track" CurrentFile = CurrentStationFile PlaylistsDirectory = "/var/lib/mpd/playlists/" log = Log() radio = Radio() lcd = Lcd() rss = Rss() # Signal SIGTERM handler def signalHandler(signal, frame): global lcd global log pid = os.getpid() log.message("Radio stopped, PID " + str(pid), log.INFO) lcd.line1("Radio stopped") lcd.line2("") lcd.line3("") lcd.line4("") radio.exit()
def setupDisplay(self): global screen dtype = config.getDisplayType() i2c_address = 0x0 configured_i2c = config.i2c_address self.i2c_bus = config.i2c_bus i2c_interface = False # Set up font code page. If 0 use codepage in font file # If > 1 override with the codepage parameter in configuration file code_page = config.codepage # 0, 1 or 2 log.message("Translation code page in radiod.conf = " + str(code_page), log.INFO) if code_page > 0: self.code_page = code_page - 1 else: self.code_page = self.translate.getPrimaryCodePage() if dtype == config.NO_DISPLAY: from no_display import No_Display screen = No_Display() self.has_screen = False elif dtype == config.LCD_I2C_PCF8574: from lcd_i2c_pcf8574 import Lcd_i2c_pcf8574 screen = Lcd_i2c_pcf8574() if configured_i2c != 0: i2c_address = configured_i2c else: i2c_address = 0x27 screen.init(address=i2c_address, busnum=self.i2c_bus, code_page=self.code_page) i2c_interface = True elif dtype == config.LCD_I2C_ADAFRUIT: from lcd_i2c_adafruit import Lcd_i2c_Adafruit screen = Lcd_i2c_Adafruit(code_page=self.code_page) if configured_i2c != 0: i2c_address = configured_i2c else: i2c_address = 0x20 screen.init(address=i2c_address, busnum=self.i2c_bus) i2c_interface = True elif dtype == config.LCD_ADAFRUIT_RGB: from lcd_adafruit_class import Adafruit_lcd screen = Adafruit_lcd() if configured_i2c != 0: i2c_address = configured_i2c else: i2c_address = 0x20 screen.init(address=i2c_address, busnum=self.i2c_bus, callback=self.callback, code_page=self.code_page) # This device has its own buttons on the I2C intertface self.has_buttons = True i2c_interface = True elif dtype == config.OLED_128x64: from oled_class import Oled screen = Oled() self.width = 20 self.lines = 5 # Set vertical display screen.flip_display_vertically(config.flip_display_vertically) self._isOLED = True self._mute_line = 4 elif dtype == config.PIFACE_CAD: from lcd_piface_class import Lcd_Piface_Cad screen = Lcd_Piface_Cad() screen.init(callback=self.callback, code_page=code_page) # This device has its own buttons on the SPI intertface self.has_buttons = True elif dtype == config.ST7789TFT: from st7789tft_class import ST7789 screen = ST7789() screen.init(callback=self.callback, code_page=code_page) self.has_buttons = False # Use standard button ineterface self._isOLED = True self._mute_line = 5 elif dtype == config.SSD1306: from ssd1306_class import SSD1306 screen = SSD1306() screen.init(callback=self.callback, code_page=code_page) self.has_buttons = False # Use standard button interface self._isOLED = True self._mute_line = 4 else: # Default LCD from lcd_class import Lcd screen = Lcd() screen.init(code_page=self.code_page) # Log code files used and codepage log.message("Display code page " + str(hex(self.code_page)), log.INFO) font_files = self.translate.getFontFiles() for i in range(0, len(font_files)): log.message("Loaded " + str(font_files[i]), log.INFO) # Set up screen width (if 0 use default) self.width = config.display_width self.lines = self.getLines() if self.width != 0: screen.setWidth(config.display_width) else: screen.setWidth(SCREEN_WIDTH) sName = self.getDisplayName() msg = 'Screen ' + sName + ' Lines=' + str(self.lines) \ + ' Width=' + str(self.width) if i2c_address > 0 and i2c_interface: msg = msg + ' Address=' + hex(i2c_address) log.message(msg, log.INFO) self.splash() # Set up number of lines and display buffer for i in range(0, self.lines): self.lineBuffer.insert(i, '') return
import sys import time import string import datetime from time import strftime MENU_SWITCH = 25 LEFT_SWITCH = 14 RIGHT_SWITCH = 15 UP_SWITCH = 17 DOWN_SWITCH = 18 MERGE=0 #merge radioul UP = 0 DOWN = 1 from lcd_class import Lcd lcd = Lcd() GPIO.setmode(GPIO.BCM) # Use BCM GPIO numbers GPIO.setup(MENU_SWITCH, GPIO.IN) GPIO.setup(UP_SWITCH, GPIO.IN) GPIO.setup(DOWN_SWITCH, GPIO.IN) GPIO.setup(LEFT_SWITCH, GPIO.IN) GPIO.setup(RIGHT_SWITCH, GPIO.IN) radiolist = open('radiolist', 'r') line = radiolist.readline() radio =[] while line: temp = line.split('&') radio.append((temp[0], temp[1].strip('\n')))
#!/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
# # License: GNU V3, See https://www.gnu.org/copyleft/gpl.html # # Disclaimer: Software is provided as is and absolutly no warranties are implied or given. # The authors shall not be liable for any loss or damage however caused. # import sys import os import atexit import traceback import RPi.GPIO as GPIO from lcd_class import Lcd stderr = sys.stderr.write; lcd = Lcd() # Try to trap any exit errors and cleanup GPIO def exit_fn(): if not traceback.format_exc().startswith('None'): s=traceback.format_exc() # Register atexit.register(exit_fn) def interrupt(): return False boardrevision = 2 stderr("Are you using an old revision 1 board y/n: ") answer = raw_input("")
#!/usr/bin/env python # # $Id: test_lcd.py,v 1.5 2013/07/01 11:51:20 bob Exp $ from radio_class import Radio from lcd_class import Lcd lcd = Lcd() def interrupt(): return False lcd.init() lcd.setWidth(16) lcd.line1("Bob Rathbone") while True: lcd.scroll2("Line 2: abcdefghijklmnopqrstuvwxyz 0123456789",interrupt)
#!/usr/bin/env python # # $Id: display_ip.py,v 1.1 2013/06/11 11:46:56 bob Exp $ import os from lcd_class import Lcd lcd = Lcd() def interrupt(): return False # Execute system command def exec_cmd(cmd): p = os.popen(cmd) result = p.readline().rstrip('\n') return result lcd.init() lcd.setWidth(16) myip = exec_cmd('hostname -I') count = 5 while count > 0: lcd.scroll1("IP:" + myip, interrupt) lcd.line2("Line 2: defghijk") count = count - 1 lcd.line1("IP:" + myip) # End
#!/usr/bin/python import getpass, poplib from lcd_class import Lcd import datetime import time #f=open('maildump.txt', 'w') lcd=Lcd() lcd.init() mesaj_array = ['','','','','','','','','','',''] from time import strftime msg = "" while True: #msg ="" user = '******' Mailbox = poplib.POP3_SSL('pop.googlemail.com', '995') Mailbox.user(user) Mailbox.pass_('frigider') numMessages = len(Mailbox.list()[1]) if numMessages != 0: msg="" todaysdate = strftime("%H:%M") mesaj = "Primit la " +todaysdate + " " lcd.line1(mesaj) # for i in range(numMessages): for txt in Mailbox.retr(1)[1]: # f.write(txt+"\n") msg = msg+"\n"+txt Mailbox.quit()
STATE=METEO #starea in care e sistemul METEO_time = time.time()#cand intra in starea meteo meteo_mesaj = ""#ce afiseaza ca meteo radio_lcd=""#analog, radio MERGE=0#daca merge radioul devine 1 FLAG=""#asta e mesajul curent care se afiseaza pe lcd durata_mesaj= []#cat timp e afisat mesajul curent split_mesaj=[]#fragmentul de mesaj afisat (sirul de fragmente etc.) time_change = 0#cand trebuie sa se schimbe mesajul afisat i_index=0#index de? nr_iteratii=0#daca sirul de afisat s-a terminat, incepe o noua iteratie sau nu first = 0#pentru debounce nr_new_msg = 0#numarul de mesaje noi mail_index=9#mesajul afisat curent #merge radioul lcd = Lcd() #defineste lcd-ul lcd.init() GPIO.setmode(GPIO.BCM) # Use BCM GPIO numbers GPIO.setup(MENU_SWITCH, GPIO.IN) GPIO.setup(UP_SWITCH, GPIO.IN) GPIO.setup(DOWN_SWITCH, GPIO.IN) GPIO.setup(LEFT_SWITCH, GPIO.IN) GPIO.setup(RIGHT_SWITCH, GPIO.IN) radiolist = open('radiolist', 'r')#lista de radiouri curente line = radiolist.readline() radio =[] RADIO_time=time.time() settle_time = 0#timpul cat radioul e activ mail_time_on=time.time()#timpul cat mailul e activ while line: temp = line.split('&')
radio_lcd=""#analog, radio MERGE=0#daca merge radioul devine 1 FLAG=""#asta e mesajul curent care se afiseaza pe lcd durata_mesaj= []#cat timp e afisat mesajul curent split_mesaj=[]#fragmentul de mesaj afisat (sirul de fragmente etc.) time_change = 0#cand trebuie sa se schimbe mesajul afisat i_index=0#index de? nr_iteratii=0#daca sirul de afisat s-a terminat, incepe o noua iteratie sau nu first = 0#pentru debounce nr_new_msg = 0#numarul de mesaje noi mail_index=9#mesajul afisat curent str_mail_http=""#ultimul mesaj primit, va fi afisat in browser #merge radioul toggle_new=0 toggle_old=0 lcd = Lcd() #defineste lcd-ul lcd.init() GPIO.setmode(GPIO.BCM) # Use BCM GPIO numbers GPIO.setup(MENU_SWITCH, GPIO.IN) GPIO.setup(UP_SWITCH, GPIO.IN) GPIO.setup(DOWN_SWITCH, GPIO.IN) GPIO.setup(LEFT_SWITCH, GPIO.IN) GPIO.setup(RIGHT_SWITCH, GPIO.IN) radiolist = open('radiolist', 'r')#lista de radiouri curente line = radiolist.readline() radio =[]#lista interna de radiouri, temporar RADIO_time=time.time()#ar trebui sa tina radioul activ 2 min, dar n-am gasit codul care face asta settle_time = 0#timpul cat radioul e activ mail_time_on=time.time()#timpul cat mailul e activ while line:#revenim la lista de radiouri temp = line.split('&')
WEATHER_NS = 'http://xml.weather.yahoo.com/ns/rss/1.0' def interrupt(): return False MENU_SWITCH = 25 LEFT_SWITCH = 14 RIGHT_SWITCH = 15 UP_SWITCH = 18 DOWN_SWITCH = 17 MERGE=0 #merge radioul UP = 0 DOWN = 1 from lcd_class import Lcd lcd = Lcd() GPIO.setmode(GPIO.BCM) # Use BCM GPIO numbers GPIO.setup(MENU_SWITCH, GPIO.IN) GPIO.setup(UP_SWITCH, GPIO.IN) GPIO.setup(DOWN_SWITCH, GPIO.IN) GPIO.setup(LEFT_SWITCH, GPIO.IN) GPIO.setup(RIGHT_SWITCH, GPIO.IN) radiolist = open('radiolist', 'r') line = radiolist.readline() radio =[] text_line1 = "" text_line2 = "" text_line1_old = "" text_line2_old="" while line:
# # Disclaimer: Software is provided as is and absolutly no warranties are implied or given. # The authors shall not be liable for any loss or damage however caused. # import sys import os import atexit import traceback import RPi.GPIO as GPIO from lcd_class import Lcd from translate_class import Translate stderr = sys.stderr.write; lcd = Lcd() translate = Translate() # Try to trap any exit errors and cleanup GPIO def exit_fn(): if not traceback.format_exc().startswith('None'): s=traceback.format_exc() # Register atexit.register(exit_fn) def interrupt(): return False boardrevision = 2 stderr("Are you using an old revision 1 board y/n: ")