Display host; ip and gateway for Oled 1.3' raspberry pi python3

preview_player
Показать описание
Raspberry Pi Model B+, 512MB, python3.2.3.

Source code:
!/usr/bin/env python3.2.3

import os
import time
import socket
from time import sleep
from lib_sh1106 import sh1106
from PIL import ImageFont, ImageDraw, Image
from smbus import SMBus

i2cbus = SMBus(1)
oled = sh1106(i2cbus)

gateway = gw[2]
print ("IP:", ipaddr, " GW:", gateway, " Host:", host)

while True:

Рекомендации по теме
Комментарии
Автор

@Real Martel> I accidentally deleted ur comment. It is google problem html5
I wrote it by myself

supra
Автор

python test.py
Traceback (most recent call last):
File "test.py", line 10, in <module>
oled = sh1106(i2cbus)
File "/usr/local/lib/python2.7/dist-packages/oled/device.py", line 97, in __init__
super(sh1106, self).__init__(port, address)
File "/usr/local/lib/python2.7/dist-packages/oled/device.py", line 64, in __init__
self.bus = smbus.SMBus(port)
TypeError: an integer is required

บงกชตุ่นทอง-ภฃ
Автор

while True:
font = ImageFont.truetype('FreeSans.ttf', 12)
draw.text((0, 0), ("Host : " + host), font=font, fill=1)
draw.text((0, 20), ("GW : " + gateway), font=font, fill=1)
draw.text((0, 40), ("IP : " + ipaddr), font=font, fill=1)

#draw.text(("IP:", ipaddr, " GW:", gateway, " Host:", host), font=font, fill=1 )
oled.display()
oled.cls()

supra
Автор

better put the link to the code in the description

protektwar