View unanswered posts | View active topics It is currently Wed Aug 21, 2019 4:34 am



Reply to topic  [ 6 posts ] 
 Make Filtet A Colorful Communicator Using Blink1 in Linux 
Author Message

Joined: Mon May 28, 2012 12:25 pm
Posts: 105
Post Make Filtet A Colorful Communicator Using Blink1 in Linux
Overview

Sometimes simple things are quite cool. Blink1 by ThingM is such a simple and cool device. Blink1's manufacturer calls it a "USB LED Notification Light". In actuality, it is small USB dongle which gives a computer the ability to communicate using a wide variety of colors and blink patterns.

Attachment:
FitletBlink1.jpeg
FitletBlink1.jpeg [ 1.98 MiB | Viewed 3812 times ]


See: https://blink1.thingm.com/


Possible uses for Blink1 include:

* Indicate CPU Temperature Using Color
* Indicate SSD Temperature Using Color
* Indicate Server Crashes
* Indicate Computer Loading
* Indicate Arrival of Email
* Indicate Messages on Social Media
* Many More




Hardware

From a hardware perspective, Blink1 is very simple. Its component complement is spartan - consisting of a micro-controller and 2 RGB LEDs. It also includes contains 3 through-holes on the PCB which can be used for connecting additional LEDs.

Attachment:
Blink1Combined.JPG
Blink1Combined.JPG [ 245.18 KiB | Viewed 3812 times ]





Software

Blink1 features good software support. Among the available packages are a GUI control app called Blink1Control, a command line tool called Blink1-tool, and a host of APIs for a good variety of programming languages.

Unfortunately, the Blink1Control App is not available for Linux (Mac OS X and Windows only), so this application note for uses the command line tool, blink1-tool. Blink1-tool runs well on my Fitlet in Linux Mint.

Installing Blink1-Tool

The installation is simple and straightforward:

1. Navigate to
https://github.com/todbot/blink1/releases
and download the latest release.

2. Extract the zip file into a directory of your choice.

3. Modify your udev rules according to the instructions found at
https://github.com/todbot/blink1/blob/m ... ink1.rules
so you won't have to run blink1-tools as a root user.


Using blink1-tools is relatively self explanatory as you can see in the following screenshot.

Attachment:
Blink1-tool.png
Blink1-tool.png [ 270.88 KiB | Viewed 3812 times ]


Wed Mar 23, 2016 2:04 am
Profile

Joined: Mon May 28, 2012 12:25 pm
Posts: 105
Post Make Filtet A Colorful Communicator Using Blink1 in Linux
Custom Blink1 Apps For Fitlet

The following Blink1 Apps are written in Perl and are specific to Fitlet.

CPU Temperature Monitor

This app uses the color progression ##### ##### ##### ##### ##### ##### to represent the CPU temperature from 30 to 70 Degrees C. The color progression is continuous, and the displayed color changes for 2 Degree C. increments in CPU temperature. Both Blink1 and a corresponding program window change color as the CPU temperature varies.

Attachment:
FitletBlink1CPU.jpeg
FitletBlink1CPU.jpeg [ 3.52 MiB | Viewed 3811 times ]


Perl Code

#!/usr/bin/perl -w
#
#CPUTempColor.pl

# Darryl Hassell 3/22/2016

use Tk;
use List::MoreUtils qw(first_index);


# Define & Initialize Variables

my $CPU_Temp = 0.0;
my $CPU_Temp_Color = '#FFFFFF';
my $Element = 0;

# Initialize Blink1 to Blink White 5 Times
system("./blink1-tool --delay 250 --millis 100 --rgb #FFFFFF --blink 5");

# 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'."\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 {

system("./blink1-tool --off");
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';
system("./blink1-tool --rgb #0000FF");
}

elsif ($CPU_Temp > 30 && $CPU_Temp <= 32){
$CPU_Temp_Color = '#0079FF';
system("./blink1-tool --rgb #0079FF");
}

elsif ($CPU_Temp > 32 && $CPU_Temp <= 34){
$CPU_Temp_Color = '#00FFFA';
system("./blink1-tool --rgb #00FFFA");
}

elsif ($CPU_Temp > 34 && $CPU_Temp <= 36){
$CPU_Temp_Color = '#00FF67';
system("./blink1-tool --rgb #00FF67");
}

elsif ($CPU_Temp > 36 && $CPU_Temp <= 38){
$CPU_Temp_Color = '#00FF00';
system("./blink1-tool --rgb #00FF00");
}

elsif ($CPU_Temp > 38 && $CPU_Temp <= 40){
$CPU_Temp_Color = '#37FF00';
system("./blink1-tool --rgb #37FF00");
}

elsif ($CPU_Temp > 40 && $CPU_Temp <= 42){
$CPU_Temp_Color = '#85FF00';
system("./blink1-tool --rgb #85FF00");
}

elsif ($CPU_Temp > 42 && $CPU_Temp <= 44){
$CPU_Temp_Color = '#BEFF00';
system("./blink1-tool --rgb #BEFF00");
}

elsif ($CPU_Temp > 44 && $CPU_Temp <= 46){
$CPU_Temp_Color = '#FFFF00';
system("./blink1-tool --rgb #FFFF00");
}

elsif ($CPU_Temp > 46 && $CPU_Temp <= 48){
$CPU_Temp_Color = '#FFEB00';
system("./blink1-tool --rgb #FFEB00");
}

elsif ($CPU_Temp > 48 && $CPU_Temp <= 50){
$CPU_Temp_Color = '#FFDA00';
system("./blink1-tool --rgb #FFDA00");
}

elsif ($CPU_Temp > 50 && $CPU_Temp <= 52){
$CPU_Temp_Color = '#FFCC00';
system("./blink1-tool --rgb #FFCC00");
}

elsif ($CPU_Temp > 52 && $CPU_Temp <= 54){
$CPU_Temp_Color = '#FFA500';
system("./blink1-tool --rgb #FFA500");
}

elsif ($CPU_Temp > 54 && $CPU_Temp <= 56){
$CPU_Temp_Color = '#FF8800';
system("./blink1-tool --rgb #FF8800");
}

elsif ($CPU_Temp > 56 && $CPU_Temp <= 58){
$CPU_Temp_Color = '#FF6500';
system("./blink1-tool --rgb #FF6500");
}

elsif ($CPU_Temp > 58 && $CPU_Temp <= 60){
$CPU_Temp_Color = '#FF3700';
system("./blink1-tool --rgb #FF3700");
}

elsif ($CPU_Temp > 60 && $CPU_Temp <= 62){
$CPU_Temp_Color = '#FF0000';
system("./blink1-tool --rgb #FF0000");
}

elsif ($CPU_Temp > 62 && $CPU_Temp <= 64){
$CPU_Temp_Color = '#FF003E';
system("./blink1-tool --rgb #FF003E");
}

elsif ($CPU_Temp > 64 && $CPU_Temp <= 66){
$CPU_Temp_Color = '#FF0097';
system("./blink1-tool --rgb #FF0097");
}

elsif ($CPU_Temp > 66 && $CPU_Temp <= 68){
$CPU_Temp_Color = '#FF00BD';
system("./blink1-tool --rgb #FF00BD");
}

elsif ($CPU_Temp > 68 && $CPU_Temp <= 70){
$CPU_Temp_Color = '#FF00CA';
system("./blink1-tool --rgb #FF00CA");
}

else {
$CPU_Temp_Color = '#FFB6F5';
system("./blink1-tool --rgb #FFB6F5");
}

$CPU_Temp_Label -> configure (-text => 'Fitlet CPU Temp'."\n"."$CPU_Temp".' Deg. C.', -background => "$CPU_Temp_Color");


}



Solid State Drive (SSD) Temperature Monitor

This app uses the color progression ##### ##### ##### ##### ##### ##### to represent the SSD temperature from 30 to 70 Degrees C. The color progression is continuous, and the displayed color changes for 2 Degree C. increments in SSD temperature. Both Blink1 and a corresponding program window change color as the SSD temperature varies.

Attachment:
FitletBlink1SSD.jpeg
FitletBlink1SSD.jpeg [ 3.5 MiB | Viewed 3811 times ]



Perl Code

#!/usr/bin/perl -w
#
#SSDTempColor.pl

# Darryl Hassell 3/22/2016

use Tk;
use List::MoreUtils qw(first_index);


# Define & Initialize Variables

my $SSD_Temp = 0.0;
my $SSD_Temp_Color = '#FFFFFF';

# Initialize Blink1 to Blink White 5 Times
system("./blink1-tool --delay 250 --millis 100 --rgb #FFFFFF --blink 5");

# Create Main Window
$WinMain = MainWindow->new;
$WinMain -> resizable (0,0);

# Label Main Window
$myframe = $WinMain -> Frame ->pack();
$SSD_Temp_Label = $myframe -> Label (-text => 'Fitlet SSD Temp'."\n"."$SSD_Temp".' Deg. C.', -background => "$SSD_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, \&GetSSDTemp);

MainLoop();

################################ Exit Program ################################

sub Exit {

system("./blink1-tool --off");
exit;
}

################################ SSD Temperature Data ################################

sub GetSSDTemp {

$SSD_Temp_Unfiltered1 = `sudo hddtemp /dev/sda`;

# Read Unfiltered SSD Temperature Data Into Array
@SSD_Temp_Array1 = split ' ', $SSD_Temp_Unfiltered1;

# Read SSD Temp Out Of Array - 4th Element
$SSD_Temp_Unfiltered2 = $SSD_Temp_Array1[3];

# Capture Only Numbers From String
@SSD_Temp_Array2 = split '°', $SSD_Temp_Unfiltered2;

$SSD_Temp = $SSD_Temp_Array2[0];

$SSD_Temp_Label -> configure (-text => $SSD_Temp.' Deg. C.');


if ($SSD_Temp <= 30){
$SSD_Temp_Color = '#0000FF';
system("./blink1-tool --rgb #0000FF");
}

elsif ($SSD_Temp > 30 && $SSD_Temp <= 32){
$SSD_Temp_Color = '#0079FF';
system("./blink1-tool --rgb #0079FF");
}

elsif ($SSD_Temp > 32 && $SSD_Temp <= 34){
$SSD_Temp_Color = '#00FFFA';
system("./blink1-tool --rgb #00FFFA");
}

elsif ($SSD_Temp > 34 && $SSD_Temp <= 36){
$SSD_Temp_Color = '#00FF67';
system("./blink1-tool --rgb #00FF67");
}

elsif ($SSD_Temp > 36 && $SSD_Temp <= 38){
$SSD_Temp_Color = '#00FF00';
system("./blink1-tool --rgb #00FF00");
}

elsif ($SSD_Temp > 38 && $SSD_Temp <= 40){
$SSD_Temp_Color = '#37FF00';
system("./blink1-tool --rgb #37FF00");
}

elsif ($SSD_Temp > 40 && $SSD_Temp <= 42){
$SSD_Temp_Color = '#85FF00';
system("./blink1-tool --rgb #85FF00");
}

elsif ($SSD_Temp > 42 && $SSD_Temp <= 44){
$SSD_Temp_Color = '#BEFF00';
system("./blink1-tool --rgb #BEFF00");
}

elsif ($SSD_Temp > 44 && $SSD_Temp <= 46){
$SSD_Temp_Color = '#FFFF00';
system("./blink1-tool --rgb #FFFF00");
}

elsif ($SSD_Temp > 46 && $SSD_Temp <= 48){
$SSD_Temp_Color = '#FFEB00';
system("./blink1-tool --rgb #FFEB00");
}

elsif ($SSD_Temp > 48 && $SSD_Temp <= 50){
$SSD_Temp_Color = '#FFDA00';
system("./blink1-tool --rgb #FFDA00");
}

elsif ($SSD_Temp > 50 && $SSD_Temp <= 52){
$SSD_Temp_Color = '#FFCC00';
system("./blink1-tool --rgb #FFCC00");
}

elsif ($SSD_Temp > 52 && $SSD_Temp <= 54){
$SSD_Temp_Color = '#FFA500';
system("./blink1-tool --rgb #FFA500");
}

elsif ($SSD_Temp > 54 && $SSD_Temp <= 56){
$SSD_Temp_Color = '#FF8800';
system("./blink1-tool --rgb #FF8800");
}

elsif ($SSD_Temp > 56 && $SSD_Temp <= 58){
$SSD_Temp_Color = '#FF6500';
system("./blink1-tool --rgb #FF6500");
}

elsif ($SSD_Temp > 58 && $SSD_Temp <= 60){
$SSD_Temp_Color = '#FF3700';
system("./blink1-tool --rgb #FF3700");
}

elsif ($SSD_Temp > 60 && $SSD_Temp <= 62){
$SSD_Temp_Color = '#FF0000';
system("./blink1-tool --rgb #FF0000");
}

elsif ($SSD_Temp > 62 && $SSD_Temp <= 64){
$SSD_Temp_Color = '#FF003E';
system("./blink1-tool --rgb #FF003E");
}

elsif ($SSD_Temp > 64 && $SSD_Temp <= 66){
$SSD_Temp_Color = '#FF0097';
system("./blink1-tool --rgb #FF0097");
}

elsif ($SSD_Temp > 66 && $SSD_Temp <= 68){
$SSD_Temp_Color = '#FF00BD';
system("./blink1-tool --rgb #FF00BD");
}

elsif ($SSD_Temp > 68 && $SSD_Temp <= 70){
$SSD_Temp_Color = '#FF00CA';
system("./blink1-tool --rgb #FF00CA");
}

else {
$SSD_Temp_Color = '#FFB6F5';
system("./blink1-tool --rgb #FFB6F5");
}

$SSD_Temp_Label -> configure (-text => 'Fitlet SSD Temp'."\n"."$SSD_Temp".' Deg. C.', -background => "$SSD_Temp_Color");


}





Results

The results of using Blink1 with Fitlet were good. Simple apps are relatively easy to create by calling the Blink1-tool command line utility. Although, it would be nice to have a Linux version of the more capable Blink1Control GUI app.




Conclusions

1. Blink1 is an interesting device which offers many possibilities for Fitlet with a "non-monitor" visual indicator for a variety of applications.

2. At over $20 US, Blink1 is a little pricey considering its complexity.

3. Fitlet again demonstrates its versatility.


Wed Mar 23, 2016 2:54 am
Profile

Joined: Fri Nov 21, 2014 5:01 pm
Posts: 5
Post Re: Make Filtet A Colorful Communicator Using Blink1
No Linux - well rats. I was hoping to maybe get those for our Linux Mintbox Mini's we're going to use in our manufacturing plant.

We will be running a java based MES/MOM software called "Ignition" from Inductive Automation (very cool - written in Java, allows Python custom code).

I was hoping to run the Blink on a usb extension cable for a visual indicator that a Quality check needed to be performed.

Maybe I could WINE it, but I don't have that kind of time to play.

Oh well, doesn't mean I can't use the built in Awesome GPIO for the same thing! (Now i just need to learn Python and how to use the GPIO, and build a device...oh well, maybe next year).


Wed Mar 30, 2016 5:27 pm
Profile

Joined: Fri Nov 21, 2014 5:01 pm
Posts: 5
Post Re: Make Filtet A Colorful Communicator Using Blink1
well, actually, the blink site says they do work with Linux :)

http://blink1.thingm.com/libraries/

Oh, you said Linux GUI app. Well - yes. Maybe that'd make a good first GTK+ project some day


Wed Mar 30, 2016 5:35 pm
Profile

Joined: Mon May 28, 2012 12:25 pm
Posts: 105
Post Re: Make Filtet A Colorful Communicator Using Blink1
This project was developed in Linux Mint 17.3. The command line tool "blink1-tool" works fine in Linux, so I designed the apps to call that tool as opposed to the APIs.

It is the Graphical Interface "blinkcontrol" that is only available for Windows and OSx. Hopefully, that tool will become available for Linux in the future.

Good luck with your project.


Wed Mar 30, 2016 9:28 pm
Profile

Joined: Fri Nov 21, 2014 5:01 pm
Posts: 5
Post Re: Make Filtet A Colorful Communicator Using Blink1 in Linu
oh, ok thanks


Wed Mar 30, 2016 9:33 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 6 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.