Nash Ali
Published © MIT

SiPEED MAIX-II Dock - Getting Started!

Machine Learning, AI and neural networks, all in a small package. The V831 brings new possibilities to AI projects. Updated 05-05-22.

IntermediateWork in progress1 hour3,885
SiPEED MAIX-II Dock - Getting Started!

Things used in this project

Hardware components

SIPEED MAIX-II Dock
×1
Flash Memory Card, SD Card
Flash Memory Card, SD Card
×1

Software apps and online services

MobaXterm
balenaEtcher
balenaEtcher

Story

Read more

Code

main.py

Python
replace the default version in root directory with this copy - this one introduces a delay (time.sleep(10)) to allow the network to "catch up" with the app allowing the display to read the correct connected IP.
#!/usr/bin/env python

from PIL import Image, ImageFont, ImageDraw
import asyncio
import time
import os
import socket

time.sleep(10)

try:
  import shutil
  from PIL import ImageShow
  # use fbviewer on linux
  # os.system('ln -s /usr/sbin/fbviewer /usr/sbin/display')
  if shutil.which("fbviewer"):
    class fbViewer(ImageShow.UnixViewer):
      def get_command_ex(self, file, **options):
        command = executable = "fbviewer"
        return command, executable
    ImageShow.register(fbViewer, 0)
except ModuleNotFoundError as e:
  pass

def get_host_ip():
    try:
        s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        s.connect(('8.8.8.8', 80))
        ip = "IP: " + s.getsockname()[0]
    except Exception as e:
        ip = "IP does not exist"
    finally:
        s.close()
    return ip


font = ImageFont.truetype("/home/res/sans.ttf", 22, encoding="unic")

canvas = Image.new("RGB", (240, 240), "#2c3e50")
with Image.open('/home/res/logo.png') as logo:
    canvas.paste(logo, (50, 40, 50 + logo.size[0], 40 + logo.size[1]), logo)

draw = ImageDraw.Draw(canvas)
draw.text((45, 195), get_host_ip(), "#ffffff", font)
canvas.show()

Credits

Nash Ali
13 projects • 13 followers
Put together a transistor radio by "Heathkit" when I was around 10, fell in love with electronics and has been a hobby ever since.
Contact

Comments

Please log in or sign up to comment.