There seems to be plenty of LCD screen that fit onto the front of a desktop pc which display time, sometimes temperatures and fan speeds. I'm looking to expand on this and create an LCD screen that can be used to monitor the system performance such as memory and cpu usage.
The current LCD's take their data from temperature headers (some boards have them) and usually fan speeds directly from the fans themselves, to include system performance stats we need to be able to get that information out of the operating system and onto the LCD screen.
A great way of doing this would be through the serial (COM) header on the main board, most desktop computers don't have a physical serial port anymore but they do usually have a header on the main board. Since the LCD is to be mounted onto the front of the desktop case, we can connect directly to that header inside.
This is an overview of the system I have in mind:
Python script on PC >>> COM port >>> Arduino >>> LCD
An Arduino acts as the main system holding the drawing functions for the LCD. When the Arduino wants to refresh the data on the screen, it polls the COM port which signals a Python script on the PC to collect the performance figures and send them back to the Arduino. The Arduino can then update the LCD.
It would be a great way for gamers, content producers and others who put their computer under heavy load to keep an eye on their systems performance.
I'm waiting on an LCD coming but have gotten on with the software aspect to test whether it is possible to get the information we need using Python. Since I don't have the LCD yet I used pygame to replicate it.
and a video of it in action...
Here is the Python script I used:
import sys import psutil import threading import pygame import pygame.locals #SETUP PYGAME pygame.init() pygame.display.set_caption('sysmon') #CREATE COLORS backgroundColor = (100,100,100) tbackgroundColor = (0,100,100) titleColor = (255,255,0) labelColor = (255,0,0) labelYellowColor = (255,255,0) #CREATE FONTS titleFont = pygame.font.SysFont("monospace", 25) labelFont = pygame.font.SysFont("monospace", 15) #CREATE DRAWING SCREEN WIDTH = 400 HEIGHT = 300 screen = pygame.display.set_mode((WIDTH, HEIGHT), 0, 32) screen.fill(backgroundColor) pygame.draw.rect(screen,tbackgroundColor,(0,50,400,250)) #CREATE AND DRAW STATIC LABELS titleLabel = titleFont.render("SYSTEM MONITOR", 1,titleColor) screen.blit(titleLabel, (100, 0)) coreLabelValue = "cores: " + str(psutil.cpu_count(logical=False)) coreLabel = labelFont.render(coreLabelValue, 1, labelColor) screen.blit(coreLabel, (0, 30)) threadLabelValue = "threads: " + str(psutil.cpu_count()) threadLabel = labelFont.render(threadLabelValue, 1, labelColor) screen.blit(threadLabel, (100, 30)) memTotalLabelValue = "total mem: " + str("%.2f" %(float(psutil.virtual_memory().total) / 1073741824)) + "GB" memTotalLabel = labelFont.render(memTotalLabelValue, 1, labelColor) screen.blit(memTotalLabel, (220, 30)) cpuUsageLabel = labelFont.render("cpu_usage", 1,labelYellowColor) screen.blit(cpuUsageLabel, (100, 100)) memUsageLabel = labelFont.render("mem_usage", 1,labelYellowColor) screen.blit(memUsageLabel, (100, 130)) #DEFINE A THREAD OBJECT class ConstantThread(threading.Thread): def run(self): #use a while loop to keep the thread and app alive while True: #grab the system data and convert to a string cpuuse = str(psutil.cpu_percent(interval=0.5)) + "%" memuse1 = str(psutil.virtual_memory().percent) + "%" memuse2 = "("+ str("%.2f" %(float(psutil.virtual_memory().used) / 1073741824)) + "GB)" #send the system data to be drawn to the screen updateScreen(cpuuse,memuse1,memuse2) #if the exit button on the pygame window is pressed, close the app for event in pygame.event.get(): if event.type == pygame.locals.QUIT: pygame.quit() sys.exit() #FUNCTION TO RESFRESH ACTIVE LABELS AND REDRAW SCREEN AREAS def updateScreen(cpuuse,memuse1,memuse2): pygame.draw.rect(screen,tbackgroundColor,(200,50,200,250)) cpuLabel = labelFont.render(cpuuse, 1, labelYellowColor) screen.blit(cpuLabel, (200, 100)) mem1Label = labelFont.render(memuse1, 1, labelYellowColor) screen.blit(mem1Label, (200,130)) mem2Label = labelFont.render(memuse2, 1, labelYellowColor) screen.blit(mem2Label, (260,130)) pygame.display.flip() thread1 = ConstantThread() #create the thread instance thread1.start() #start the thread sys.exit()
If you want to try it out remember to use pip to install pygame and psutil first
The next stage is to get the Arduino to communicate with this script through the COM port which I can get on with while waiting for the LCD to arrive