Last active
September 21, 2017 00:01
-
-
Save predorock/2178afa869a6b18b391cd65612681dda to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
import fcntl | |
import struct | |
import pyupm_i2clcd as lcd | |
def get_ip_address(ifname): | |
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | |
return socket.inet_ntoa(fcntl.ioctl( | |
s.fileno(), | |
0x8915, # SIOCGIFADDR | |
struct.pack('256s', ifname[:15]) | |
)[20:24]) | |
# Initialize Jhd1313m1 at 0x3E (LCD_ADDRESS) and 0x62 (RGB_ADDRESS) | |
myLcd = lcd.Jhd1313m1(0, 0x3E, 0x62) | |
# Clear | |
myLcd.clear() | |
# Green | |
myLcd.setColor(255, 255, 0) | |
# Zero the cursor | |
myLcd.setCursor(0,0) | |
# Print it. | |
ip_address = get_ip_address('wlan0') | |
myLcd.write(ip_address) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment