Display-O-Tron 3000 System Monitor

Hi!

As I mentioned in this post, I am looking at using the DOT3K as a system monitor on my headless RPi running Sonarr and SABnzbd+ as a usenet downloader.

At present, I am using the Piglow as a system monitor using a sligthtly modified version of this script but as nice as the Piglow is, the information it provides is not that easy to interpret (i.e. there is none, some of lots of activity).

Gadgetoid had a great idea of having the DOT3K change colour depending on what system stat was being displayed - i.e. red for CPU workload (in percentage), blue for network traffic, green for storage space available (in percentage), but I have almost no idea where to start!

I’ve ordered my DOT3K and it will be delivered on Friday, so my first plan-of-attack is to test it out using the example scripts Gadgetoid has uploaded here, but after that I’m not sure what to do or where to go.

So as recommended by Gadgetoid, I’ve created this post in projects in the hope the kind community will help me get started!

Thanks in advance!

I think this is a good candidate for an “Advanced” Dot3k example. I notice the script you’re using at the moment is in C++. Do you plan to switch to Python?

Erm… Don’t know! I just managed to get it working by tweaking things and trial and error. I’m not versed in any code really, which is why I struggle to start my own code. I had a play with your menu.py script in the dot3k advanced folder and managed to change some of the menu settings (I’ve added wifi transmission stats, which basically keeps track of data sent & received).

I have no idea how to cycle between different system stats automatically as at the moment, I have to use the joystick to navigate the menu.

Like I said before, I feel cheeky asking for help because that means asking somebody to essentially start me off so I can play around once I get a rough idea of what’s going on…

I think my next purchase will be a beginners guide to Python book!

Okay, automatic cycling is actually easier than it looks… although there’s currently no automagic feature for it. There really should be, though, it sounds like something people might want to do!

I’ll break out a Display-o-Tron ( not sure if I’ll get it done tonight ) and see if I can come up with a code example for you!

I’ve committed a hacky example, just for you!

It just uses the same menu commands that the joystick fires off, only it’s doing it automagically as part of the drawing loop:

I will update it soon to stop auto-advancing when a joystick direction is pressed, or probably find a way to build it into the library neatly since it’s a useful feature! But this should keep you going for now :D

Wow, thanks Phil! Very kind of you to do this.

I will have a play around with this at some point soon!

Quick question - what would I need to do to change the default backlight colour (currently blue)? Is this something I would need to change in the “backlight.py” script in the /python/library/dot3k folder?

This basic example shows how to set the backlight colour.

You need to import dot3k.backlight as bl and then bl.rgb(r,g,b) where r, g and b are RGB values for the colour you want to set.

You can do this in your app, e.g. to set the backlight colour to red if the CPU load is > 90% you could edit the graph.py plugin as follows:

class GraphCPU(MenuOption):
  """
  A simple "plug-in" example, this gets the CPU load
  and draws it to the LCD when active
  """
  def __init__(self):
    self.cpu_samples = [0,0,0,0,0]
    self.last = self.millis()
    MenuOption.__init__(self)
  
  def redraw(self, menu):
    now = self.millis()
    if now - self.last < 1000:
      return false

    self.cpu_samples.append(psutil.cpu_percent())
    self.cpu_samples.pop(0)
    self.cpu_avg = sum(self.cpu_samples) / len(self.cpu_samples)

    menu.write_row(0, 'CPU Load')
    menu.write_row(1, str(self.cpu_avg) + '%')
    menu.write_row(2, '#' * int(16*(self.cpu_avg/100.0)))
    
    dot3k.backlight.set_graph(self.cpu_avg/100.0)

    ## This bit below sets the backlight to red if CPU load > 90% ##
    if self.cpu_avg > 90:
      dot3k.backlight.rgb(0,0,255)
    else:
      dot3k.backlight.rgb(255,255,255)

P.S. I haven’t tested this, but it should work, I think.

1 Like

Fab, thanks.

I think I now have enough to tinker with! Thanks Phil (edited: and you Sandy, sorry!), you’re both legends!

I’ll “report back” with my effort and keep this updated.

The default colour is also taken from dot3k.cfg, which you can change either by editing the file, or using the Backlight plugin if it’s installed.

But I think what you want is Sandy’s example- showing it being set to specific colours on demand in software.

Ok, great - thanks!

I’ve just found an eBook on Amazon that is free at the moment for Python for beginners! Think this will help!

Sorry, late to the party! I have an original RBG dot3k and I set the background colour from green to red programmatically based on CPU load, network bandwidth used, disk space used etc.

It’s quite nice to visually be alerted to a problem… see the Gist here.

Apologies for the bad python ;) And stealing from the examples shamelessly! Great product BTW

–A

1 Like