Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


currentsong.txt location
#5
I'm not too adventurous, in the meantime I found a couple of nice examples. In this piece of code, depending of the status of MPD (if there's a song currently played), the code print 'system' info (e.g. IP Address, Temperature, other stuff) or song info (retrieving them from MPD, including timing and other stuff).
The only problem that I have to check, is that the example is made for a 4 lines LCD Display. I'm not sure if the LCD_Init function below is valid also for 16x2 Display ...

.......
import smbus
import time

# Define some device parameters
I2C_ADDR  = 0x27 # I2C device address #this must be checked...
LCD_WIDTH = 16   # 20   Maximum characters per line (MODIFIED BY ME)

# Define some device constants
LCD_CHR = 1 # Mode - Sending data
LCD_CMD = 0 # Mode - Sending command

LCD_LINE_1 = 0x80 # LCD RAM address for the 1st line
LCD_LINE_2 = 0xC0 # LCD RAM address for the 2nd line
# LCD_LINE_3 = 0x94 # LCD RAM address for the 3rd line COMMENTED BY ME
# LCD_LINE_4 = 0xD4 # LCD RAM address for the 4th line COMMENTED BY ME

LCD_BACKLIGHT  = 0x08  # On
#LCD_BACKLIGHT = 0x00  # Off

ENABLE = 0b00000100 # Enable bit

# Timing constants
E_PULSE = 0.0005
E_DELAY = 0.0005

#Open I2C interface
#bus = smbus.SMBus(0)  # Rev 1 Pi uses 0
bus = smbus.SMBus(1) # Rev 2 Pi uses 1

def lcd_init():
 # Initialise display
 lcd_byte(0x33,LCD_CMD) # 110011 Initialise
 lcd_byte(0x32,LCD_CMD) # 110010 Initialise
 lcd_byte(0x06,LCD_CMD) # 000110 Cursor move direction
 lcd_byte(0x0C,LCD_CMD) # 001100 Display On,Cursor Off, Blink Off
 lcd_byte(0x28,LCD_CMD) # 101000 Data length, number of lines, font size
 lcd_byte(0x01,LCD_CMD) # 000001 Clear display
 time.sleep(E_DELAY)
.....
Reply


Messages In This Thread
currentsong.txt location - by mancio61 - 04-11-2018, 11:20 PM
RE: currentsong.txt location - by Tim Curtis - 04-11-2018, 11:36 PM
RE: currentsong.txt location - by mancio61 - 04-12-2018, 08:52 AM
RE: currentsong.txt location - by RafaPolit - 04-12-2018, 01:45 PM
RE: currentsong.txt location - by mancio61 - 04-12-2018, 01:54 PM
RE: currentsong.txt location - by RafaPolit - 04-13-2018, 07:13 PM

Forum Jump: