tenderlove/pixoo-rb: Pixoo client for Ruby

💥 Read this awesome post from Hacker News 📖

📂 **Category**:

💡 **What You’ll Learn**:

This is just a client for the Pixoo 64 sign written in Ruby.

Draw some stuff and then display it as an animated image:

include Pixoo::Utils

images = [7, 17, 29].map  

dev = Pixoo::Client.find_all.first
dev.send_animation images
sleep 1

# add some text
dev.send_text "Hello", x: 0, y: 0, id: 1
dev.send_text "World", x: 0, y: 40, id: 2, font: 6

Read a PNG and display it:

img = Pixoo::ImageBuffer.from_png ARGV[0]

dev = Pixoo::Client.find_all.first
dev.send_animation [img]

Reading from a remote server

This thing supports reading values from a remote server.
I have a server that collects PM2.5 / CO2 sensors I have in the house.
On the server, I have a webrick server that response to requests for sensor info.
For example to get the PM2.5 data from my office, I can do this:

$ curl 'http://tender.home:9292/reading?floor=main&room=office&measurement=pm2.5'
💬

The response is important because this display will parse the response and display it on the sign.
I’ve configured the sign as follows:

dev = Pixoo::Client.find_all.first

label = dev.new_display_item(id: 1,
  type: Pixoo::DisplayItem::TEXT_MESSAGE,
  x: 0,
  y: 0,
  dir: 0,
  font: 18,
  width: 64,
  height: 5,
  string: "PM2-5:",
  speed: 10,
  color: "#FF0000",
  align: 1)

value = dev.new_display_item(id: 2,
  type: Pixoo::DisplayItem::NET_TEXT_MESSAGE,
  x: 23,
  y: 0,
  dir: 0,
  font: 18,
  width: 64,
  height: 5,
  string: "http://tender.home:9292/reading?floor=main&room=office&measurement=pm2.5",
  speed: 10,
  color: "#FFFFFF",
  align: 1)

The sign will automatically fetch data from my server and update the display.

⚡ **What’s your take?**
Share your thoughts in the comments below!

#️⃣ **#tenderlovepixoorb #Pixoo #client #Ruby**

🕒 **Posted on**: 1767516664

🌟 **Want more?** Click here for more info! 🌟

By

Leave a Reply

Your email address will not be published. Required fields are marked *