Overview
For most of us, color vision is a most effective means of receiving meaningful information. We instantly understand the message being conveyed by the green, yellow, and red lights of a traffic signal. While driving, flashing red or blue lights may indicate trouble - if you are speeding.
Why then can't color be used to indicate certain operational parameters of your computer? The answer is - color can most certainly be used to provide you with a wide variety of information about your computer and the processes it is running.
An Example - CPU Temperature
What's your computer's CPU temperature?
Certainly there are applets which display your computer's CPU temperature to the tenth of a degree C in the system tray or some other such place. However, do you really want to know that temp to the tenth of a degree, or is it sufficient for your purposes to simply know in general how warm your CPU is running? Why not use a color indicator such as fit-statUSB to provide a general idea of CPU temperature.?
The perl app listed below does just that - it provides a color indication of CPU temperature beginning at blue for cold and hot pink for really warm. CPU temperature is displayed by fit-statUSB via a 20 step color continuum.
COLD------------------------WARM--------------------------HOT
######-######-######-######-######-######-######
Sample Output of Perl App Showing App Window and fit-statUSB Output
Cold CPU
Warm CPU
Hot CPU
Perl App Listing
***********************************************************************************************************************************************************
Important Note:
The following perl app has been specifically written to work with fitlet RM running Linux Mint. Without modification, it is unlikely it will work for other computers. This is because the app determines CPU temperature by processing the output of the bash sensor command, and the output format of the sensor command varies from one computer type to the next. This app has been successfully modified to work on a HP15 laptop running Linux Mint, so with proper modification it may work for your computer type as well.
***************************************************************************************************************************************************************
#!/usr/bin/perl -w
#
#fitletCPUtemp.pl
# Darryl Hassell 8/4/2018
use Tk;
use List::MoreUtils qw(first_index);
use Device::SerialPort;
use Time::HiRes ('sleep');
# Define & Initialize Variables
my $CPU_Temp = 0.0;
my $CPU_Temp_Color = '#FFFFFF';
my $Element = 0;
# Configure Serial Port
my $port = Device::SerialPort -> new("/dev/ttyACM0");
$port -> baudrate(115200);
$port -> databits(8);
$port -> parity("none");
$port -> stopbits(1);
$port -> write_settings;
# Set Sleep Delay After Writes in Seconds
our $delay = 0.1;
# Initialize fit-statUSB to Red - Green - Blue - White
$port -> write("#FF0000\n");
$port -> purge_rx;
sleep(2);
$port -> write("#00FF00\n");
$port -> purge_rx;
sleep(2);
$port -> write("#0000FF\n");
$port -> purge_rx;
sleep(2);
$port -> write("#FFFFFF\n");
$port -> purge_rx;
sleep(2);
# Create Main Window
$WinMain = MainWindow->new;
$WinMain -> resizable (0,0);
# Label Main Window
$myframe = $WinMain -> Frame ->pack();
$CPU_Temp_Label = $myframe -> Label (-text => 'fitlet CPU Temp Monitor'."\n"."$CPU_Temp".' Deg. C.', -background => "$CPU_Temp_Color", -font => "helvetica 9 bold")->pack(-ipadx => 20,-ipady => 20);
# Exit Program Button
$stopbutton = $myframe -> Button (-text => 'Exit', -command => \&Exit, -foreground => 'black', -background => 'lightblue');
$stopbutton -> pack (-side => 'bottom');
$WinMain -> repeat(2000, \&GetCPUTemp);
MainLoop();
################################ Exit Program ################################
sub Exit {
$port -> write("#000000\n");
$port -> purge_rx;
sleep($delay);
exit;
}
################################ CPU Temperature Data ################################
sub GetCPUTemp {
$CPU_Temp_Unfiltered1 = `sensors`;
# Read Unfiltered CPU Temperature Data Into Array
@CPU_Temp_Array1 = split ' ', $CPU_Temp_Unfiltered1;
# Determine Array Index of CPU Indicator k10temp-pci-00c3
my $ArrayIndex1 = first_index { $_ eq 'k10temp-pci-00c3' } @CPU_Temp_Array1;
# Determine Array Index of CPU Temperature
my $ArrayIndex2 = $ArrayIndex1 + 5;
# Read CPU Temp Out Of Array
$CPU_Temp_Unfiltered2 = $CPU_Temp_Array1[$ArrayIndex2];
# Capture Only Numbers From String
@CPU_Temp_Array2 = split '°', $CPU_Temp_Unfiltered2;
$CPU_Temp = $CPU_Temp_Array2[0];
if ($CPU_Temp <= 30){
$CPU_Temp_Color = '#0000FF';
$port -> write("#0000FF\n");
$port -> purge_rx;
sleep($delay);
}
elsif ($CPU_Temp > 30 && $CPU_Temp <= 32){
$CPU_Temp_Color = '#0079FF';
$port -> write("#0079FF\n");
$port -> purge_rx;
sleep($delay);
}
elsif ($CPU_Temp > 32 && $CPU_Temp <= 34){
$CPU_Temp_Color = '#00FFFA';
$port -> write("#00FFFA\n");
$port -> purge_rx;
sleep($delay);
}
elsif ($CPU_Temp > 34 && $CPU_Temp <= 36){
$CPU_Temp_Color = '#00FF67';
$port -> write("#00FF67\n");
$port -> purge_rx;
sleep($delay);
}
elsif ($CPU_Temp > 36 && $CPU_Temp <= 38){
$CPU_Temp_Color = '#00FF00';
$port -> write("#00FF00\n");
$port -> purge_rx;
sleep($delay);
}
elsif ($CPU_Temp > 38 && $CPU_Temp <= 40){
$CPU_Temp_Color = '#37FF00';
$port -> write("#37FF00\n");
$port -> purge_rx;
sleep($delay);
}
elsif ($CPU_Temp > 40 && $CPU_Temp <= 42){
$CPU_Temp_Color = '#85FF00';
$port -> write("#85FF00\n");
$port -> purge_rx;
sleep($delay);
}
elsif ($CPU_Temp > 42 && $CPU_Temp <= 44){
$CPU_Temp_Color = '#BEFF00';
$port -> write("#BEFF00\n");
$port -> purge_rx;
sleep($delay);
}
elsif ($CPU_Temp > 44 && $CPU_Temp <= 46){
$CPU_Temp_Color = '#FFFF00';
$port -> write("#FFFF00\n");
$port -> purge_rx;
sleep($delay);
}
elsif ($CPU_Temp > 46 && $CPU_Temp <= 48){
$CPU_Temp_Color = '#FFEB00';
$port -> write("#FFEB00\n");
$port -> purge_rx;
sleep($delay);
}
elsif ($CPU_Temp > 48 && $CPU_Temp <= 50){
$CPU_Temp_Color = '#FFDA00';
$port -> write("#FFDA00\n");
$port -> purge_rx;
sleep($delay);
}
elsif ($CPU_Temp > 50 && $CPU_Temp <= 52){
$CPU_Temp_Color = '#FFCC00';
$port -> write("#FFCC00\n");
$port -> purge_rx;
sleep($delay);
}
elsif ($CPU_Temp > 52 && $CPU_Temp <= 54){
$CPU_Temp_Color = '#FFA500';
$port -> write("#FFA500\n");
$port -> purge_rx;
sleep($delay);
}
elsif ($CPU_Temp > 54 && $CPU_Temp <= 56){
$CPU_Temp_Color = '#FF8800';
$port -> write("#FF8800\n");
$port -> purge_rx;
sleep($delay);
}
elsif ($CPU_Temp > 56 && $CPU_Temp <= 58){
$CPU_Temp_Color = '#FF6500';
$port -> write("#FF6500\n");
$port -> purge_rx;
sleep($delay);
}
elsif ($CPU_Temp > 58 && $CPU_Temp <= 60){
$CPU_Temp_Color = '#FF3700';
$port -> write("#FF3700\n");
$port -> purge_rx;
sleep($delay);
}
elsif ($CPU_Temp > 60 && $CPU_Temp <= 62){
$CPU_Temp_Color = '#FF0000';
$port -> write("#FF0000\n");
$port -> purge_rx;
sleep($delay);
}
elsif ($CPU_Temp > 62 && $CPU_Temp <= 64){
$CPU_Temp_Color = '#FF003E';
$port -> write("#FF003E\n");
$port -> purge_rx;
sleep($delay);
}
elsif ($CPU_Temp > 64 && $CPU_Temp <= 66){
$CPU_Temp_Color = '#FF0097';
$port -> write("#FF0097\n");
$port -> purge_rx;
sleep($delay);
}
elsif ($CPU_Temp > 66 && $CPU_Temp <= 68){
$CPU_Temp_Color = '#FF00BD';
$port -> write("#FF00BD\n");
$port -> purge_rx;
sleep($delay);
}
elsif ($CPU_Temp > 68 && $CPU_Temp <= 70){
$CPU_Temp_Color = '#FF00CA';
$port -> write("#FF00CA\n");
$port -> purge_rx;
sleep($delay);
}
else {
$CPU_Temp_Color = '#FFB6F5';
$port -> write("#FFB6F5\n");
$port -> purge_rx;
sleep($delay);
}
$CPU_Temp_Label -> configure (-text => 'fitlet CPU Temp Monitor'."\n"."$CPU_Temp".' Deg. C.', -background => "$CPU_Temp_Color");
}
Conclusions
fitstat-USB is a very useful tool for displaying CPU temperature. It makes a great accessory for Compulab's fitlet computer.
fit-statUSB: Perl App for Displaying CPU Temp
programmable multi-color LED that plugs into a USB port
-
- Posts: 106
- Joined: Mon May 28, 2012 12:25 pm
Jump to
- Announcements
- ↳ Read me first
- ↳ News
- ↳ Ordering
- Tensor-PC
- ↳ General Tensor-PC questions
- ↳ Tensor-PC Hardware
- ↳ Tensor-PC Software
- fitlet3
- ↳ General fitlet3 questions
- ↳ fitlet3 hardware
- ↳ fitlet3 software
- ↳ fitlet3 FACET Cards
- Airtop3
- ↳ General Airtop3 questions
- ↳ Airtop3 Hardware
- ↳ Airtop3 Software
- ↳ Airtop3 I3M
- fitlet2 and MBM2
- ↳ General fitlet2 questions
- ↳ fitlet2 hardware
- ↳ fitlet2 software
- ↳ fitlet2 FACET Cards
- ↳ Cool stuff with fitlet2
- Airtop2
- ↳ General Airtop2 questions
- ↳ Airtop2 Software
- ↳ Airtop2 Hardware
- ↳ Airtop2 I3M
- Mature products
- ↳ Airtop
- ↳ General Airtop questions
- ↳ I3M
- ↳ IPC2 (Intense PC2)
- ↳ General IPC2 questions
- ↳ IPC2 availability
- ↳ IPC2 Hardware
- ↳ Linux on IPC2
- ↳ Windows on IPC2
- ↳ Other operating systems on IPC2
- ↳ IPC2 BIOS
- ↳ IPC2 faults and troubleshooting
- ↳ Intense PC and MintBox 2
- ↳ General Intense PC questions
- ↳ Intense PC hardware
- ↳ CPU & Chipset
- ↳ Display interface
- ↳ Memory
- ↳ Storage
- ↳ Ethernet
- ↳ WLAN and miniPCI-e
- ↳ Audio
- ↳ USB
- ↳ Power and heat
- ↳ Linux on Intense PC
- ↳ Linux Mint
- ↳ Other distributions
- ↳ Windows on Intense PC
- ↳ Win7 on Intense PC
- ↳ Win8 on Intense PC
- ↳ Audio
- ↳ Intense PC BIOS
- ↳ Android on Intense PC
- ↳ Intense PC faults and troubleshooting
- ↳ fitlet and MintBox Mini
- ↳ General fitlet questions
- ↳ fitlet performance
- ↳ fitlet hardware
- ↳ Memory
- ↳ Storage
- ↳ Power and heat
- ↳ Mechanical
- ↳ fitlet BIOS
- ↳ Linux on MintBox Mini / Linux on fitlet
- ↳ Windows on fitlet
- ↳ Other operating systems on fitlet
- ↳ FACET Cards
- ↳ fitlet compatible devices
- ↳ Cool stuff with fitlet
- ↳ fitlet faults and troubleshooting
- ↳ fit-PC4
- ↳ General fit-PC4 questions
- ↳ fit-PC4 hardware
- ↳ Windows on fit-PC4
- ↳ Linux on fit-PC4
- ↳ Other operating systems on fit-PC4
- ↳ fit-PC4 BIOS
- ↳ fit-PC4 faults and troubleshooting
- ↳ fit-PC3
- ↳ General fit-PC3 questions
- ↳ fit-PC3 hardware
- ↳ Display interface
- ↳ Storage
- ↳ Audio
- ↳ WLAN and miniPCI-e
- ↳ USB
- ↳ Power and Heat
- ↳ Ethernet
- ↳ Windows on fit-PC3
- ↳ Linux on fit-PC3
- ↳ Other operating systems on fit-PC3
- ↳ fit-PC3 BIOS
- ↳ fit-PC3 accessories
- ↳ Using fit-PC3
- ↳ fit-PC3 faults and troubleshooting
- ↳ fit-PC2
- ↳ General fit-PC2 questions
- ↳ Buying fit-PC2
- ↳ Linux on fit-PC2
- ↳ Linux Mint
- ↳ Ubuntu 9.10
- ↳ Ubuntu 10.04
- ↳ Ubuntu 10.10
- ↳ Ubuntu 11.04
- ↳ Other Linux distributions
- ↳ Ubuntu 8.04
- ↳ Ubuntu 9.04
- ↳ Display driver
- ↳ Multimedia in Linux
- ↳ Multimedia in Mint
- ↳ Windows on fit-PC2
- ↳ Windows 7
- ↳ Windows 7 display driver
- ↳ Audio in Win7
- ↳ Windows XP
- ↳ XP installation
- ↳ Display driver
- ↳ Video playback
- ↳ Audio in XP
- ↳ Other Windows versions
- ↳ Other operating systems on fit-PC2
- ↳ FreeBSD
- ↳ fit-PC2 hardware
- ↳ fit-PC2i hardware
- ↳ Display interface
- ↳ Storage
- ↳ Audio
- ↳ WLAN and miniPCI-e
- ↳ USB
- ↳ Auto-ON
- ↳ Power and Heat
- ↳ Ethernet
- ↳ RTC & System clock
- ↳ fit-PC2 BIOS
- ↳ BIOS updates fit-PC2
- ↳ BIOS updates fit-PC2i
- ↳ fit-PC2 accessories
- ↳ Using fit-PC2
- ↳ HTPC
- ↳ Server
- ↳ Control
- ↳ Verified displays
- ↳ Car PC
- ↳ fit-PC1 questions
- ↳ fit-PC Slim questions
- ↳ uSVR
- ↳ General uSVR questions
- ↳ IPC3
- ↳ General IPC3 questions
- ↳ IPC3 Software
- ↳ IPC3 Hardware
- ↳ FACE modules
- ↳ FACE Modules
- ↳ General FACE Module questions
- Compulab accessories
- ↳ fit-Headless and fit-Headless 4K
- ↳ fit-Uptime
- ↳ fit-statUSB
- ECN/PCN
- ↳ fitlet3 ECN/PCN
- ↳ Tensor-I20 ECN/PCN
- ↳ Tensor-I22 ECN/PCN
- ↳ fitlet2 ECN/PCN
- ↳ Airtop3 ECN/PCN
- ↳ IPC3 ECN
- ↳ fitlet1 ECN
- ↳ IPC2 ECN
- ↳ IPC1 ECN
- ↳ Airtop2 ECN
- ↳ Airtop1 ECN
- ↳ fit-PC4 ECN
- ↳ fit-PC3 ECN
- ↳ fit-PC2 ECN
- ↳ FACE Modules ECN
- ↳ FACET Cards ECN
- Wish list
- ↳ Addressed requests