Created
August 27, 2016 08:40
-
-
Save betzerra/f102520ee6adebefdee394b245f3cf22 to your computer and use it in GitHub Desktop.
Print a twitter stream into an I2C LCD screen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'i2c/drivers/ss1602' # https://github.com/nerab/i2c-ss1602 | |
require 'twitter' # https://github.com/sferik/twitter | |
display = I2C::Drivers::SS1602::Display.new('/dev/i2c-1', 0x27) | |
client = Twitter::Streaming::Client.new do |config| | |
config.consumer_key = "XXX" | |
config.consumer_secret = "XXX" | |
config.access_token = "XXX" | |
config.access_token_secret = "XXX" | |
end | |
topics = ["#Hashtag"] | |
client.filter(track: topics.join(",")) do |object| | |
if object.is_a?(Twitter::Tweet) then | |
puts "#{object.text} - #{object.user.screen_name}" | |
display.clear | |
lines = object.text.scan(/.{1,20}/).take(3) | |
lines.each_with_index do |l,i| | |
display.text(l,i) | |
end | |
display.text("@#{object.user.screen_name}",3) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment