The last mouse modification had gone so well I had to try it again on the secondary mouse I use for my laptop. The tin foil idea came from metku mods.
And this is what happened…see the whole photo stream here. I found the one pcb in the mouse “Microsoft Tail Lite PCB” particularly amusing, it was mostly blank with only two traces and an LED.
So, the left mouse button in my beatiful mouse, the Logitech mx518, decided to stop working. I noticed this when I was losing very badly playing Team Fortress 2…things weren’t happening when I was clicking!
Naturally, instead of throwing it into the trash pile and ordering a new one, I decided to investigate further into the cause of this failure. It wasn’t software, something was wrong with the button. So the mouse gets opened up.
Turns out, nearly all mice use the same little tactile switches for their mouse buttons. These buttons all have the same pinouts. Luckily, I had another, older, deader, mouse that I had pillaged for its infrared LEDs, and, it still had its mouse button switches. Guess what happens next - mouse button transplant is what.
A quick desolder and resolder later and I have my mouse working again. But working is simply not enough…while I have it open I have to add at least one LED. The best place was on the logitech logo, which looks really nice once I discovered its black coating rubs off to reveal this nice metallic finish. A quick dremel drill press and datasheet lookup on the IC sitting on the pcb (to find +5v and gnd) later and we have a mouse with a new glow.
The new button from the older mouse actual has more of a “click” to it and is much more tactile than the old one. I actually like it better. In fact, I like it so much, I might have to swap the right mouse button switch even though it isn’t broken.
See the whole thing with notes in the photostream!
This is is a project I’ve been working on for a little while now. It started when I was inspired by the ambient lightstrips article on hackaday. I had a few hundred of these bright blue LEDs sitting around, and I had been meaning to use them for something eventually, specifically something to do with audio. I had also wanted to get USB working on my atmega8 AVR, so I combined the two into this project: Oonceleds!
I began by wiring up the LEDs in parallel and working out what resistor values to use. ledcalc was great for this, it tells you the exact resistance and a closet match actual resistor value for parallel or series LED circuits. For 20 of my LEDs in parallel (I measured a voltage drop of 3.2v) it was around 4.7ohms; of course you can be a little above or below this number and things work fine. I just had 1/4 watt resistors, so I doubled up (parallel) with two resistors of double the value (10ohms). This means the ~700mW going through won’t heat them up too much.
Now, the AVR can’t drive that much current (~400mA) from a single pin! So, a transistor was needed…specifically a 2N3906, a fairly standard PNP switching transistor. It is hooked up to the micro like this. The Rb I used was 100ohms, to protect the micro in case the transistor died and something bad happened. The base of the transistor is connected the OC1A PWM output on the AVR.
Next, the AVR needed some code. Once I set up my AVR dev environment again (article on this soon), I fired up Emacs and began coding. I use avrusb to do the usb communication (the two leds by the USB connector in the video are used to convert the 5V signals to 3V for the usb bus, its a hack, I know, but it works great, and also a visual indication of usb communication), it works very well and the documentation is great (good sample code as well). I got USB working then added some simple code to do hardware PWM on the OC1A pin. The AVR receives commands through custom USB SETUP packets, where it receives a value between 0-1023 from the PC. This 10bit value is copied into the OCR1A register on the AVR, which effectively sets the brightness value (0 = full on, 1023 = full off).
Then, software was needed on the PC to control the USB device. I wrote a simple daemon (27 lines without golfing!) in ruby that listens on a socket, and when it receives input, and that input is a line with number between 0-1023, it sends that value over USB to the AVR device.
Finally, I found a template for XMMS plugins and added the code to grab the average amplitude of all the frequencies and keep a running average of that information. If the average level exceeds the running average by a set factor, it sends a 0 to the USB daemon, which causes a flash of the LEDs. It just sends a 1022 (very dim) if the average is just…average.
Coincidentally, this was just posted on hackaday. He uses a similar approach with a running average (his way of keeping the average is much better than the way I had originally done it, so I was able to speed up my xmms plugin by adopting that approach). He uses a mic, which probably provides a quicker response to audio peaks. I considered trying out a mic as well, but I like the plugin approach because it means it works with headphones :). Maybe I’ll add it and a switch to select between modes…all this for ooncleds v2.
I’ve also received a bag of 100 RGB leds from eBay (very nicely packaged (shipping free!), with free resistors), so I’ll be expanding the next version with full colour. Now I just need more spare time…
I’ll post the source code once I have a chance to clean it up and fix a few of the hacks that happen when trying to get things working at 3am :P. If there is enough interest I’ll create a dedictaed PCB and publish the whole design.
The songs in the first vid are Nine Inch Nails - Demon Seed (from their free album, woot!), and DJ Deval - Drop Kick (no oonceleds project is complete without drum and bass). The second vid is Nine Inch Nails - Discipline.
So, if you don’t know already, my Linux distro of choice is Archlinux. I like Arch because the stock install is just that…the basic system and you can add just what you want (X11, fluxbox for a desktop, leave X out for a server, whatever), it gives you choice without forceing you into a certain set of software. Also the package manager, pacman, is one of the best ones I’ve ever used…its fast, and I’ve never had an issue with it breaking something (or itself).
Anyway, Archlinux is an i686 optimized distro, which is fine for any recent computer, but I was disapointed to find that when I went to install it on my VIA EPIA-5000 (passive cooled, cpu integrated mobo) that the onboard processor was only i586 compatible. So, I began the search for a similar distro that would work for my needs (simple server, and Xorg if I wanted to use it as a media pc later on).
First, I tried CentOS (the Red Hat clone, kinda)…it installed very nicely, but took upwards of 20 minutes to boot the first time, and also used 480M of my 512M (!!) on a stock installation…so that had to go. Next in line was Slackware, which people told me was the best for below i686. Slackware is a “vanilla” distro, they don’t brand everything and all the packages are pretty much packaged straight from the sources. The package manager is lacking a bit in that it doesn’t handle dependencies, but its a great distro if you want to set it up and forget it. So I gave Slackware a chance…(its still running on the machine currently)…but I still wanted to get Archlinux running on it. So, finally, the subject of this post!
Right now, I’m recompiling the core Archlinux repository for i586…It’s actually really simple to do, Arch has a build system called the Arch Build System. Every package has what is called a PKGBUILD, which is like a build script. The program makepkg parses the PKGBUILD, downloads any needed source code, compiles, and installs the package to a directory. Then it packages up that directory into a nice .tar.gz package that pacman can install. With the makeworld command, you can compile an entire repository. So I simply made a copy of the two makepkg and makeworld scripts, changed them to point to a seperate configuration file, and changed that configuration to tell them to build for the i586 architecture. So by morning I should have a directory full of Arch packages that can run on i586, ready to install to the VIA.
Also, I’m using ccache and distcc to speed up compiles. distcc distributes compiles to other computers on the network, in this case my desktop and my laptop, which is 8 threads total). I’ll write an article on setting that up sometime.
Anyway, with any luck I’ll be able to get Archlinux running on i586, update tommorow!
Ok, so at CWSF this year I was introduced to the Ruby programming language by one Brohan. Ruby is one of the nicest languages I’ve ever had the pleasure of coding in, the syntax is great and there are a tonne of libraries (gems in ruby-speak) to do pretty much whatever you require. I’ve experimented with Ruby and Ruby on Rails (which also rocks, article to come) and so far I haven’t found anything I didn’t like about it. Ruby is easy to use, fast, and fun (yes fun).
Anyway, I whipped this up today. Its a script that checks your gmail every 30 seconds, and if you have a new message, it will pop open the CD drive to let you know.
while(1)
resp = client.get(url)
if (resp.content.to_s =~ /<fullcount>(\d+)<\/fullcount>/i)
newcount = $~[1].to_i
if newcount > oldcount
`sudo eject`
end
oldcount = newcount
file.pos = 0
file.write $~[1]
end
sleep(30)
end
Hmmm. I’ll have to get a plugin for Wordpress to make that code look nicer. Grab the file here.
Try Ruby! They have a Ruby in 20 minutes article on their site, if you’ve done any sort high level programming before the syntax will be easy. I guarantee you’ll find a million uses for it. Personally, I’m never going to touch Perl again :P
I haven’t posted about my educational future after high school so here goes. I’ve been accepted to the University of Waterloo for Computer Engineering (woo!), and they are even going to give me a $2500 Engineering scholarship and a $2000 President’s Scholarship (90%-94.9% avg required, hopefully I can maintain it). I also recieved a $4000 Millennium Scholarship earlier this year, which will help too. No one has offered to pay for my whole education yet but it all adds up :p.
So I’ll be going there in September, which I’m pretty excited about. A nice thing about Waterloo is I get to do co-op my second term, which will help balance the books as well. I’m looking forward to Comp Eng…should be some fun times with some FPGAs eventually.