A Raspberry Pi based Steemit Notification Module using OLED screens

in #utopian-io9 years ago (edited)

I extended my Raspberry Pi Steemit Notification Module’s support to small size OLED screens (0.91” 128x32 OLED screen and 0.96” 128x64 screen).

It makes use of the same mechanism on monitoring of Steemit blockchain and extraction of data to be shown on the screens.

In order to drive the OLED screen, I picked the well established Luma libraries from Richard Hull for this purpose. This is where you can find the libraries on Github

The two OLED screens use ssd1306 controllers, which is supported by luma.oled library. It in turns call luma.core library for system and terminal emulation support.

How the module works

Basically, it monitors the STEEM Blockchain, when there is any activities on the user's account, it will grab it, check if it is an upvote or a comment. If yes, it will blink the LED as well as display upvote or comment information on the oled. Like this:

D43EE11A-66FF-47B2-B9E5-971B43F4B23E.gif

7E4EA3DC-B409-4ABA-A4CC-C5E2CDD825B3.gif


Here is the notification module on Githut. Feel free to down it and play with it. Anyway suggestion and comments are welcomed!


from piston.steem import Steem
from piston.account import Account
from piston.blog import Blog
from piston.post import Post
#
from demo_opts import get_device
from luma.core import cmdline
from luma.core.virtual import terminal, viewport
from PIL import ImageFont
#
import os
import threading
import random
import csv
import urllib.request
import time
import RPi.GPIO as GPIO
import sys
def make_font(name, size):
    font_path = os.path.abspath(os.path.join(os.path.dirname(__file__), 'fonts', name))
    return ImageFont.truetype(font_path, size)
def main():
    # Set user account, no. of history retrieve everytime, transaction ID buffer array of 10 
    account_name = 'guyverckw'
    account = Account(account_name)
    steem = Steem()
    first = 9999999999
    limit = 5
    History = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
    History_ID = 1.0
    message = ' '
#
    # Prepare LED indicator
    GPIO.setmode(GPIO.BOARD)
    GPIO.setup(11, GPIO.OUT, initial=GPIO.LOW)
#
    # Prepare for OLED display, first prepare the device with built-in parameter for 12832 screen
    device_args = ['-d', 'ssd1306', '--width', '128', '--height', '32']
    parser = cmdline.create_parser(description='luma.examples arguments')
    args = parser.parse_args(device_args)
    device = cmdline.create_device(args)
#
    # Set font 
    font = make_font('ProggyTiny.ttf', 16)
    term = terminal(device, font)
    term.clear()
    term.animate = False
#
    # keep checking transactions
    while True:
        index = 0
#
        # Get last 5 history, put ID into buffer array
        for his in account.rawhistory(first, limit):
            if History_ID == his[0]:
                break
            if his[1]['op'][0] == 'comment':
                message = 'There is a comment from @' + his[1]['op'][1]['author']
            elif his[1]['op'][0] == 'vote':
                if his[1]['op'][1]['author'] == account_name:
                    message = 'There is a vote from @' + his[1]['op'][1]['voter'] + ' of ' + str(his[1]['op'][1]['weight']/100) +'%'
            else: 
                History[index] = his[0]
                index += 1
                continue
            History[index] = his[0]
            index += 1
            # print (message)
            GPIO.output(11, GPIO.HIGH)
            term.clear()
            term.println(message)
            time.sleep(1)
            GPIO.output(11, GPIO.LOW)
#
        History_ID = History[0]
#

Here is the commit of this module in GitHub : guyverckw/Steemit-Notification-Module-for-Raspberry-Pi : Notification module using OLED



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Hi Great work as always! Can you just link to the corresponding PR/commits before I approve. Thanks

You may edit your post here, as shown below:

You can contact us on Discord.
[utopian-moderator]

Approved

Thank you very much.

Wow beautiful cn post

looks like a bit of programming might be hard to implement for me

i see my username there wow :D

i think this is a big step forward by anyone amazing it looks

my notification will also come there i hope : )

fantastic!

Wow you did a great integration there :)

好羡慕你们这么厉害。我只能翻译:(

這些很簡單的,O大,大鵬,Justyy 他們那些才是利害呀。

对于你可能简单,对于我跟看天书一样:(

so informative post..........thank for sharing

Coin Marketplace

STEEM 0.04
TRX 0.33
JST 0.093
BTC 62934.78
ETH 1756.13
USDT 1.00
SBD 0.39