Dothat IP address at boot

Im sure I spotted something along these lines on here a while back but a few searches are not yielding any results?

I would like simple (dismissible with a button press) display of the IP address. I can see its available in the menu.py example but I’m after something simpler.

I found this. https://gist.github.com/transilluminate/bbc1eca2739badaadf58

wondered if anyone has made anything like this fo rthe DOTHAT.

I’m not familiar with the microdot but I’d assume you can just find the relevant lines of code in the menu (or elsewhere on the web) to get the IP address of the pi. Test it in a simple file which just displays the IP as text.

Then find the code which allows you to scroll a value. Test this with a normal phrase like “hello” and see if you can get that to scroll.

Then substitute the IP address code for the ‘hello’. Google and fix any errors you come across on the way (or just post them here).

Sorry I can’t be more helpful with specific code (I’ll try to do this when I can) - but as some phrase puts it, you’re better off learning how to do something than getting the code from me!

here’s an example that should work on the dothat:

#!/usr/bin/env python

import fcntl
import socket
import struct

import dothat.lcd as lcd


def get_addr(ifname):
    try:
        s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        return socket.inet_ntoa(fcntl.ioctl(
            s.fileno(),
            0x8915,  # SIOCGIFADDR
            struct.pack('256s', ifname[:15].encode('utf-8'))
        )[20:24])
    except IOError:
        return 'Not Found!'

wlan0 = get_addr('wlan0')
eth0 = get_addr('eth0')
host = socket.gethostname()

lcd.clear()

lcd.set_cursor_position(0,0)
lcd.write('{}'.format(host))

lcd.set_cursor_position(0,1)
if eth0 != 'Not Found!':
    lcd.write(eth0)
else:
    lcd.write('eth0 {}'.format(eth0))

lcd.set_cursor_position(0,2)
if wlan0 != 'Not Found!':
    lcd.write(wlan0)
else:
    lcd.write('wlan0 {}'.format(wlan0))

it will merely display the IP (and hostname), but it should be easier to integrate in whatever program you wish to to make compared to the plugin class.