A Raspberry Pi based Steemit Notification Module using OLED screens

View this thread on: d.buzz | hive.blog | peakd.com | ecency.com
·@guyverckw·
0.000 HBD
A Raspberry Pi based Steemit Notification Module using OLED screens
I extended my [Raspberry Pi Steemit Notification Module](https://steemit.com/utopian-io/@guyverckw/42avj4-a-raspberry-pi-based-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]( https://github.com/rm-hull)

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](https://res.cloudinary.com/hpiynhbhq/image/upload/v1515188691/w2ox5wijardalf8korme.gif)

![7E4EA3DC-B409-4ABA-A4CC-C5E2CDD825B3.gif](https://res.cloudinary.com/hpiynhbhq/image/upload/v1515189784/rmsuyej8gefmy3vcoz8p.gif)

***
Here is the [notification module on Githut]( https://github.com/guyverckw/Steemit-Notification-Module-for-Raspberry-Pi/blob/master/Steem_notify_oled.py).  Feel free to down it and play with it. Anyway suggestion and comments are welcomed!
***
~~~python
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
~~~

~~~python
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)
~~~

~~~python
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](https://github.com/guyverckw/Steemit-Notification-Module-for-Raspberry-Pi/commit/767417a8417a4bc475876e7e69b274cb88ad0f30)


<br /><hr/><em>Posted on <a href="https://utopian.io/utopian-io/@guyverckw/a-raspberry-pi-based-steemit-notification-module-using-oled-screens">Utopian.io -  Rewarding Open Source Contributors</a></em><hr/>
👍 , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,