So I have this Digital Picture Frame made from an old laptop at work. It doesn't have that many uses other than to amuse myself and others in the form of a music player and an overpowered clock.
When I use it as a music player I use GNU Screen and Camp, the latter in combination with cp437 of course. This gives me the ability to log in remotely from my work computer to change track, volume and whatnot. The problem is having the correct local IP address of the machine since it gets updated every 8 hours. First I wrote a script that will check the local IP and send me an e-mail with the new one if there has been any changes. I run this script via cron once an hour.
But what I really wanted was to have it display in the status line of GNU Screen. It took some digging but I found this article which mentions an option called "backtick" in GNU Screen. In short backtick allows you to run a command from .screenrc and have it's output displayed in the status line.
An almost 20 year old laptop chugging along on Debian Wheezy playing
music and pulling of a look that might induce wet dreams to retro nerds.
How to do it
I've added the following to my .screenrc backtick 101 600 600 hostname -I
101 is the identifier of this particular backtick that will be used in the status line string, it could just as well be 1 or whatever number I choose. 600 and 600 determines how often to run the program and how often to refresh the line. I use the same number on both mainly because that's what the author of the article did and I don't see any reason to go beyond that. If you're curious read more about it here. hostname -I this is the command I run to get my local IP address.
That's it for the command but you need to add want to display the output in the statusline: hardstatus alwayslastline "%{= g} %{= w}%-Lw%{=r}%n%f* %t %{-}%+LW %-=%| %101` | %D %M %d %Y %c:%s"
So really I just added %101` (yes the ` is required) to the string in order to display the output. That and two | and a couple of spaces to act as dividers.
Now don't come around asking me questions on GNU Screen's status line because that is a whole other story. I barley know what mine does.
Let's get one thing straight, I absolutely love ANSI graphics. But lately, and by lately I mean since 200X, getting my daily fix of this Graffitti-esque artstyle that had it's glory days in the early 90's has become a bit of a hassle. Sure you can mess around with your charset settings and fonts like I've done, but that will probably affect the usability of the rest of your system... in a negative way.
So when I, as a newcomer to reddit, asked for help in the /r/commandline subreddit I got the answer: cp437 an app so easy to use it's almost painful to think of all the headaches I've had trying to get ANSI to display properly in Linux virtual console and assorted terminal emulators.
After installation it's merely a matter of typing "cp437" followed by the app of your choice for instance:
$ cp437 camp $ cp437 duhdraw
It even works under GNU screen, to some extent. To be honest I had trouble with getting DuhDraw to paint properly under GNU screen the first time I tried it.
Camp, in all it's properly rendered ANSI glory.
The image is a bit offset because my virtual console is
larger than 80 columns and 25 lines.
CAMP file selection menu. No there's no little "screen;" thing in the corner. ;)
Since my daughter comes from a long line of droppers her Lucia candle didn't get much mileage before she dropped it and broke the glass bulb. Glass bulb you say, yes. These hand held electric candles haven't seen much product development in the last thirty years or so.
Lucia is a typical Swedish holiday that combines our favourite pastimes mys* and fika**. Usually it's celebrated by a Lucia train err... a better translation would probably be Lucia procession.
* Mys: activity that makes you feel all warm an fuzzy inside i.e. cozy ** Fika: Eating various types of buns and cookies while consuming either coffee, tea or other seasonal beverage.
Anyway as I was picking up the shards I wondered why they didn't use LEDs for kids candles. But a manufacturers apparent failure to satisfy its customers is a perfect reason for a maker to take things into her or his own hands.
But just using a LED wouldn't be very fun, no we definitely need more awesomeness!
Circuitry
Below is the circuit I designed for this project. It's really simple but I did run into some problems when I realized the ATtiny85 only has 2 PWM outputs. Turns out I was wrong it actually has 4 PWM outputs but two of them share the pin with analog input. Since no input is used in this project that wasn't a problem at all.
Please note: There is one major flaw with my circuitry. I calculated the resistors using the 5V output voltage on the Arduino board. Since this is meant to be powered from standard 1.5V button cell batteries it is far from ideal preferably I should have calculated the resistors for 4.5V. However it actually does work with as low as 3V but the colors are a bit off and dim.
Simple circuit using the ATtiny85 microcontroller, an RGB LED and some resistors.
Breathing life into a flame
Ok, so we have the circuit down, now we need some code to run on the microcontroller. I've written a very short code snippet which uses simple randomness to create a flickering effect. Since there are differences in LEDs you might have to fine tune it according to your hardware, however it should be a pretty simple job as the code is pretty much self explanatory and commented where needed.
/*
Flickering Candle
Emulates a candle flickering with a RGB LED
By Markus Ulfberg 2013-02-01
Updated: 2014-11-24
Uses ATtiny85
*/
// Depending on your board, comment out either the ATtiny85/Arduino
// pin variables below.
// LED pins Arduino Board
// int ledRed = 3;
// int ledGreen = 5;
// int ledBlue = 6;
// LED pins Attiny85
int ledRed = 0; // Chip pin 5
int ledGreen = 1; // Chip pin 6
int ledBlue = 4; // Chip pin 3
// LED Power variables
byte redPwr = 0;
byte greenPwr = 0;
byte bluePwr = 0;
void setup()
{
pinMode(ledRed, OUTPUT);
pinMode(ledGreen, OUTPUT);
pinMode(ledBlue, OUTPUT);
}
void loop()
{
lightMyFire();
} // END loop()
void lightMyFire() {
// Flicker will determine how often a fast flare will occur
int flicker;
// set flicker randomness
flicker = random(800);
// Set color of fire, use a short range to make emulate the
// smooth movement of a flame.
// Flicker up
// when flicker occur, the colors shine brighter
// adding blue creates a white shine
if (flicker > 750) {
redPwr = 255;
greenPwr = 55;
bluePwr = 5;
}
// Flicker down
// when flicker occur, the flame goes down in intensity
// and towards a reddish tone
if (flicker < 20) {
redPwr = random(60, 70);
greenPwr = random(5, 15);
bluePwr = 0;
// Main flame color
} else {
redPwr = random(190, 200);
greenPwr = random(40, 50);
bluePwr = 0;
}
// display Colors
colorDisplay();
// Set speed of fire
// The randomness of the delay creates a more natural erratic flame
delay(random(30, 200));
} // END lightMyFire
// Displays the colors when called from lightMyFire
void colorDisplay() {
analogWrite(ledRed, redPwr);
analogWrite(ledGreen, greenPwr);
analogWrite(ledBlue, bluePwr);
}
Programming the ATtiny85 using the Arduino as ISP.
Running the sketch on the ATtiny85, drawing only power from the Arduino.
Building a better candle
I've spent two years trying to make the circuit fit inside the original candle. It's not really that hard but I've restarted this project just in time to realize I won't make the deadline of Lucia and then my interest faded and I shelved the project until next year.
Last year I made this little circuit by cutting a small strip of perfboard that will fit inside the candle body.
Almost done, just need to add power.
Bottom of unfinished circuit on perfboard.
Moving on ...
Some of the main problems that I didn't solve last year was finding a good ON/OFF switch, making a suitable power pack and some sort of diffuser for the LED.
For the ON/OFF switch I decided to take easy way out and just skip it. I could always add it later if I come across a small enough SPST switch. As for power I soldered on the existing power cables from the candle to the perfboard.
Adding power connectors, using the existing ones in the candle.
Just another shot of the back of the circuit.
My power pack consists of three 1.5V LR44 button cell batteries. In order to get them to fit the cradle I just moved the spring closer to the bottom. Et voila, we have a very flimsy battery cradle. I'll probably add some plastic or something to make sure they don't rattle around when we actually use the candle.
The three batteries and the spring prior to hot glueing it into place.
Finished cradle, not pretty but it works.
Nasal spray to the rescue
Around October, I got one of the ten mandatory colds that you get during the season. I also decided to try out a new nasal spray that uses only saline. This means you can spray away as much as you like without the drawbacks of normal nasal spray abuse. It also meant that I finally found a good diffuser for the LED. The cap to the nasal spray had a nice shape of semi transparent plastic, just what I needed for my project.
Nasal spray cap used as a diffuser for the RGB LED.
This is the end ... result.
Ok, so up close the color mixing isn't really perfect. I guess we can blame either the diffuser, my code or my inability to use the correct voltage when calculating what resistor to use. But it works and hey, that's the fun part isn't it?
Prologue: I started writing the below post about a year ago but in the end I never really found a solution to the problem and consequently I never finished the post. Sometime it's best to know when to quit, but maybe this project can be of use to you anyway. Or maybe you'll find the solution that I didn't... well if you do please let me know.
Look Ma no wires!
Ok, so I've built an Arduino based Mood Light Controller and I've managed to get my Arduino to send integers over RF with VirtualWire. Finally I've also built my first Arduino Standalone ATmega / Arduino Bare.
Now I've combined the three into one Wireless Arduino Mood Light Controller. To be honest I had two very different projects planned for my Standalone ATmega and the RF part but those sort of became obsolete in my current living situation.
When I first merged the RGB Mood Light code with the RF Receiver code my Arduino kept hanging. Confident in my own coding skills I quickly aimed my blame towards those who write librarys for the Arduino IDE. The good folks in the Arduino forum managed to deflate my swelling ego and pointed out a few flaws in my code before coming to the conclusion that it might be a hardware problem.
"The rise and fall of a ego" is available as a thread in the Arduino forum.
Meanwhile back on earth ...
I moved my question to the General Electronics part of the Arduino forum, this time with a little more humble attitude. After following the instructions of Grumpy_Mike I quickly learned that my problems came from interference caused by using PWM to control the RGB LED. The trick was to swap out the resistors to 1K Ohm resistors in order to minimize the current and the interference it caused. With 1K Ohm resistors everything worked flawless, well except for the LED that got quite dim.
To minimize the interference Grumpy_Mike suggested the use of capacitors and/or ferrite beads. This actually helped a bit but still not good enough.
Improved circuit with capacitors to stop interference caused by PWM.
Above circuit breadboarded on a protoshield.
Kind of messy and lot's of wires that can cause interference.
Apparently the problem with a circuit like this is that every lead and wire is a source of interference.So I was advised to try to make the circuit tidier, shorten leads and hope for the best.
Leads of the LED and resistors trimmed down ...
... and the RF receiver connected via a ferrite bead as well as an added physically distance.
Also the power supplied to the RF receiver is decoupled with a capacitor.
Dead end?
Unfortunately all this helped very little... and I'm sort of stuck. If you do find a solution to this please let me know as I would love to finish this project.
I recently read about Cupt a rewritten apt-get replacement that apparently would be more suitable for low end machines. Well it's not specifically written for low end machines, I guess it's just less resource demanding.
Anyway I decided to try upgrading my old Toshiba 320CDS from Debian Squeeze to Wheezy using cupt. Upgrading in Cupt comes in a couple of different flavors. I decided to go with the one I know best: sudo cupt update sudo cupt dist-upgrade
Actually all things went fairly smooth apart from conky breaking the upgrade halfway through. I resolved this minor issue by just removing conky (sudo cupt remove conky) when the upgrade broke and then just start the upgrade from scratch (or whatever state my system was left in).
When the upgrade was done, everything seemed to be ok, but at reboot I was dropped to busybox...(sigh) as usual. This happens because I have to used the ide-generic kernel module to boot from my ide disks.
I typed in: modprobe ide-generic
But my system said that no module with that name was available... (this is where I panicked and retyped that about twenty times trying different combinations of ide, -,_ and generic). Naturally that didn't accomplish anything so I googled a bit and found that ide-generic had been removed from the kernel packages and been replaced by pata_legacy.ko
So instead I tried: modprobe pata-legacy
The module loaded and my drives were recognized. I hit CTRL-D and the boot resumed.
As soon as my system was up and running I replaced ide-generic with pata-legacy in /etc/initramfs-tools/modules
and issued: sudo update-initramfs -u
...and rebooted without a hitch. Well actually, first I replaced it with pata-generic, which of course is very wrong and got dropped to busybox again. But I will never admit to that. ;)
Also I must say that cupt feels a tad bit snappier than apt-get.
Today (yesterday) I got an email from the author of CAMP who had found my efforts on getting his old software to work on newer systems. Much to my delight he also offered to do the updates required to get CAMP to work or rather play nice with modern compilers.