Friday, August 8, 2014

Win32 Build of AVRDude 6.0.1

**EDIT** urquan from reddit pointed out you can use an AVRDude available on their site here: http://download.savannah.gnu.org/releases/avrdude/ ***

For a while now, the easily available builds of AVRDude that I could find have been terribly out of date, and I've been building my own.  It just occurred to me it may make sense to release a build here.

This was built from avrdude-6.0.1 on a Linux Mint 15 system using the following commands:

./configure --host=i686-w64-mingw32 AR=i686-w64-mingw32-ar CFLAGS=-m32
make
i686-w64-mingw32-gcc -Wall -Wno-pointer-sign -g -O2 -DWIN32NATIVE  -static avrdude-main.o avrdude-term.o ./libavrdude.a  ser_win32.c crc16.c serbb_win32.c  -lusb  -lm  -o avrdude.exe
 i686-w64-mingw32-strip avrdude.exe

It was that simple.

The download including libusb, etc. can be found right here: http://cnlohr.net/random/avrdude-6.0.1-cnl.zip

You will still need to install "drivers" on Windows XP, Vista, 7 and 8.  There are some ways people have been doing this, but the easiest way I've found is to download win32 lib usb, then run the driver installer and running it right there on the spot.

http://cnlohr.net/random/libusb-win32-bin-1.2.6.0.zip

You can find the driver maker app "inf-wizard" in the "bin" folder of that zip.  Be sure to unzip the whole thing.  Follow the instructions, selecting the device that matches vid/pid pair: 0x1781, 0x0C9F

When done, tell it you want to install right then.

Note that on Windows 8, you will need to reboot with driver signing enforcement turned off. You'll have to look up another guide for that.


P.S. I HATE WINDOWS, I almost exclusively use Linux.  I just have to deal with people who use Windows, so you get to benefit from my misfortune.

Monday, February 3, 2014

To make terrible wordsearches.

A long time ago I saw a "DOG" word search, in which there were a bunch of letters and only one "DOG" so I was curious how hard it would be to write a program to make terrible word searches. The answer was, very easy.

I wrote a program that creates them in C. It took about 30 minutes. It simply produces letters from a list of letters I provide it, and checks to make sure that the word in the search does not show up. If that word does show up, it starts rewriting some letters. Eventually, it creates a wordsearch without the word that you're searching for.

You then have to add the word in the search yourself.

Usage: ./wordsearch [x] [y] [word] [letter dictionary]

For example:
 
./wordsearch 10 10 the the
HITS: 59
h h t h h t t h t t 
h h e e t t e e e h 
h h e t t t e t h h 
h h t t t e e h e e 
e t e h h e e t e e 
h h t h t h t t t e 
e t e h e e t t e e 
h t t e t h h h t t 
e t e e t h h h h h 
t t t h h e h h t h 

Notice how the word "the" does not appear in the word search at all. You simply have to change the letters to add that word and you're set! You have made a terrible word search.

Source code: http://pastebin.com/i2MBCHLQ

Here are some examples:





Happy hunting.

Sunday, October 28, 2012

Obama is Liberal?

A lot of my friends who hit up the liberal side of things have been supporting Barack Obama much to my surprise. I really don't get it considering he's a Nobel prize winner with a kill list, who expanded the drone program at grave cost to thousands civilian lives.

His administration demanded US citizens be included in section 1021 of the NDAA. This allows US citizens to be detained indefinitely under suspicision of terrorist activities without any charge or trial. When a judge found this section to be unconstitutional and blocked it, Obama sent out his team of lawyers to get an emergency stay... and got it. So, now you, a US citizen on US soil can be sent to places like Gitmo (which he didn't close).

He acted as though he would welcome participation by the people in their governance with his We The People, yet ignores actual petitions and arbitrarily just pulls them down. You have to go far right wing in order to find someone who won't bust states for legal use of medical marijuana. Like that makes any semblance of sense?

Some people say: "well at least he's trying" to avoid military force. Try googling things to see if you can find any legitimate attempts. He keeps calling in drone strikes against non-citizens and US citizens alike - and is fighting to do the latter in secrecy! He even goes as far as going to war with Libya without a Congressional act - at least Bush got permission. After Democrats in Congress started the impeachment proceedings over this, he tried reclassifying it as a kinetic military action. What does that even mean?

Remember SOPA? PIPA? And the "big brother" ACTA? Turns out Obama signed ACTA even before it hit Congress. He even says it shouldn't need Congressional approval!. Funny how that's the opposite sort of thing than what he campaigned on.

He's also ignoring the blatantly criminal behavior Wall Street is engaging in, which I think is the real reason our economy is so messed up.

So, this is why I'm not voting for the peace loving Barack Obama. Or voting for pro-war Mitt Romney (who's basically pro- these bigger issues, as he'll outright tell you). There is no "lesser of two evils" this time around. We had our shot with Ron Paul who was surprisingly electable in retrospect. But now that that's over, it like the only people left we can get behind are Gary Johnson or Jill Stein.

Monday, August 1, 2011

Desktop QR Code Reader for Ubuntu

So, for a long time, I wanted something that could go from this:



to this:



And, I was frustrated that no one made it. I would have made it but decoding QR codes is just so darn difficult... that is until ZBar came along with QR Code support. Now, I have a button I can click to move it over. Unfortunately, it isn't /that/ easy. I genned this app up by taking a Gtk demo for making a system tray applet, adding some screen shot capabilities, pumping it into ZBar, then using some of the xosc overlay stuff to draw the outlines. It was pretty straightforward. You can get the code here:

https://cnlohr.net/pubsvn/projects/X11QR/x11qr

ZBar is just awesome, it even gets the bizarre QR Codes:



Also, for your enjoyment, here's a video demonstrating it:




HOW TO INSTALL:
sudo add-apt-repository ppa:charles-cnlohr/qroverlay
sudo apt-get install qroverlay


NOTE: I do not have a menu icon for this so you will need to run it either from a terminal (qroverlay) OR you can type Alt+F2 and type qroverlay and click run (once it's installed).

Anyone who can help me to make it have a menu icon would be really great.

Saturday, February 19, 2011

How to make an animal factory in Minecraft

So, I am sure there's a number of ways of doing this, some more reliable than others. I've had a lot of trouble making lava-based mob factories in Minecraft (the lava destroys the goodies). So, I found way of doing it entirely with water.

It goes like this:
1) Make your trap with the top about 12 cells below where ground level is. Plug the top of the death trap until ready.
2) Dig ditches with feeding streams into one another, all leading up to the death trap.
3) Activate the streams of water, and unplug your death trap.
4) Place lots of torches everywhere around to attract animals.
5) Animals and mobs will come, fall into your streams, get sucked into the trap and die.
6) Their parts will fall out of the death trap and come on the floor ready for you to just pick up and profit.

As an oddity, you get eggs from chickens since they don't get sucked under, and you get feathers from zombies.

OPTIONAL: You can make your trap even deeper, then make stream systems through underground caverns that are very dark. Zombies, creepers, and skeletons will spawn, fall into the streams and perish. If you do this, be sure to make everything double-wide with some cacuts sitting around places to get rid of the spiders else they'll clog everything up.

Making the trap is relatively easy. I would suggest making your trap two cells of water wide. I have had good luck with ones only one cell wide, though.

The first thing you need to understand is the basics of water physics. While you can use streams that flow down hill, it makes it much easier to make 8-wide stream segments. At the end of the segment, you can drop off into another stream. Be sure to have walls around the sides of your stream so animals can't hop out.



The next thing you need to think about is the death trap. I strongly suggest making the blocks that constitute your death trap out of glass. This makes it possible to see inside and see what broke if something went wrong. Below is my template death trap. I strongly suggest putting the doors on the bottom, and installing from the inside. This prevents animals from breathing in the space where the door is, but still lets you escape your own trap if you fall in. Also, it makes it possible to bat at sheep while inside the chamber, to get them to drop their wool.




The grass blocks indicate the blocks that are on the same plane as the water. The rock blocks are only there to indicate that you need something on the front/back of your trap to prevent the water or animals from flowing out.


The next thing you need to worry about is your system of channels leading the creatures to your death trap. I suggest you use this basic template. Streams of eight cells, condensing further to streams of 8 cells, finally coming together in your central area. Sometimes making these streams 2 cells wide is helpful, but not mandatory.



Be sure that all of your walls are AT LEAST two cells high, lest the creatures escape.

Below is an example of a double-wide one with a top exit. This can be useful, since it can accelerate the speed at which goodies can exit the kill chamber.




One last note - you cannot have the water come straight down and T out. If you do, all animals except pigs will be killed. If you have plans to do an animal sorter and kill pigs later, that may help, but you need to add the zigzag at the end pictures in my diagram above.


If all goes well, when you turn the water on, you'll get animals that get sucked under after a while, and get their goodies.



Here's a final view from the side:

Thursday, November 18, 2010

ColorChord Sound Lighting


About a year and a half ago, I wanted to put some LEDs in a clear guitar. This has been done before, but I wanted to give it a try and see if I could come up with something really cool. I bought a clear guitar, put USB controlled LEDs into it and plugged it up to my computer before I found out: No one has any tone-based algorithms to convert sound into color! What did I do? I invented ColorChord (TM).



ColorChord is the name for the technology that can select colors according to sound. Unlike most systems that look for a beat, or classify sound into various sound ranges, ColorChord is unique in that it looks at the sound exclusively on a chromatic scale. In my opinion, if you assign "A" to be purple, then A440 should be purple, A220 should be purple and so should all the other A's.

Many people have attempted to assign colors to sound in the past. Many of them were either synesthetic, had perfect pitch (or worse) both. Why is this worse? Because most people aren't synesthetic and don't have perfect pitch. Many of the systems that these people produced involved unusual color associations to sounds, or revolved around a given note always applying to a given color regardless of the key of the music it was used in. Many others had color systems that were unable to transition smoothly while increasing in pitch up a musical scale.

The concept of ColorChord here is that the primary color (most times Yellow) is applied to the note that the piece's key is. I.e. If you're playing many guitar songs, you're playing in the key of E. Therefore, the E note will be Yellow. If you're playing something in C major, the C note will become Yellow.

After much experimentation, some friends and I found that the chromatic color wheel applies surprisingly well to the chromatic scale. I have noticed that in some situations sliding the scale slightly seems to work better, but for the most part this seems generally applicable and is what is used in all of the videos.



There are some neat properties that immediately jump out of this. Chords make some semblance of artistic color sense. In this picture, it is a wheel turned to C major. A C Chord would produce [Yellow, Bluish purple, and Red] (in descending brightness) You'll notice that fifths produce nearly complementary? colors. This works out very well. After trying some other combinations this is the layout that I just couldn't do any better than. This is the color mode I use for all of the videos I'm releasing.

Speaking of which, here's another on Youtube that really shows off the complements.


Technically, this process is very complicated, and if people want the source code, I have no problem publishing it. But here's a rough overview. Just as a word of warning, everything has to happen with very low latency. This system takes sound in via a microphone and transforms it into colors in real time. More than 1/30th or 1/20th of a second and it starts to get annoying.

Step 1: Record the sound (512 to 1024 samples at a time) must be constantly streaming, minimise any buffering.
Step 2: Copy the sound to a buffer on the GPU. Because I'm using GLSL, this is just a 1D texture.
Step 3: Perform a windowed DFT, with the beginning of the sound niblet and ends tapering off to silence. This DFT cannot be implemented as an FFT. It needs to be in chromatic space. For example, on some of these demos, every octave may have 24-512 individual bins. The output is "folded." This means a C in one octave will contribute to the same bucket as a C in another octave. Several octaves may fall into the same bucket.
Step 4: Copy back to the CPU, and filter against previous samples. More filtering produces a less jittery result, but also adds latency in the response of the lights.
Step 5: Find all the peaks. These are the pitches within the octave that are loudest in the sample.
Step 6: Select the highest few peaks.
Step 7: Assign your lights to your peaks. Try to keep some inter-frame coherence here. Also, assign your lights based on the brightness of your peaks. Very high peaks may take over several lights (or all) while quieter peaks may only take on a few. If you're playing a chord, you should get roughly even distribution among all three peaks).
Step 8: Assign your peaks (or lights) the colors according to the wheel.
Step 9: Modify the brightness of the lights based on the strength of the peak. Don't worry here - percussion will simply raise the noise floor of the output because of the DFT we performed earlier, it will not show up.
Step 10: Output to the lights.

Additionally, if you're taking input via MIDI, this process is greatly simplified: the audio capture/DFT process turns into simple MIDI capture. I found that MIDI does work relatively well with this system but I don't have any videos on hand.

One point of future work I never got around to was automatically figuring out the key of a song. I tried neural networks, but that just didn't cut it. Oh well.

If you want to use this technology commercially or just for for a project, feel free to contact me.

Note that all of this material is patent pending.

Another few videos:





Wednesday, June 9, 2010

Comparison of different cloths for projector screen

I purchased a HD20 Optoma 1080p projector and fell in love with using it against the wall in my old dorm room. Recently, though, there have been more and more cases where I needed to use the projector somewhere where a wall was unavailable.

We ended up doing rock band in a number of unusual places, we we needed a solution.
This prompted the purchase of a sheet from target. This was fraught with problems. The sheet allowed too much light through from behind. When there wasn't much light, light would pass through the sheet, bounce off of whatever was behind it and then come back through the sheet causing "echoes" of sorts. The king size bed sheet technique failed miserably.

This first picture shows the echo effect, you can see it around the Pin Panic and ACK in Attack.

One fun thing that happened was we were able to play though the sheet. NOTE: This is actually TWO sheets. These king size sheets are ridiculously translucent.



Now that I have gotten around to it, I went to Jo Ann Fabrics and bought 1.5" of every white fabric that I thought would be reasonable.

These cloths include (in order of increasing appeal after tests)
  1. Wool Felt - 37" Wide, $9.99/yd, 2.0 oz for 3 sqft, capable of making a [37"x65"]; [75" or 6.25' diag.]; [17 sqft] screen @ $19 and 11 oz. - Fail immediately, produced a "lumpy" surface in terms of brightness.
  2. Polyester Felt - 72" Wide, $4.99/yd, 1.5 oz for 3 sqft, capable of making a [72"x128"]; [146" or 12.2' diag]; [64 sqft] screen @ $18 and 32 oz. - Fail immediately, produced a "lumpy" surface in terms of brightness.
  3. Polyester Fleece - 62" Wide, $7.99/yd, 3.0 oz for 3 sqft, capable of making a [62"x110"]; [126" or 10.5' diag]; [47.3 sqft] screen @ $25 and 47 oz. - Fail immediately, produced a blurry picture.
  4. Cotton Denim - 56" Wide, $9.99/yd, 3.5 oz for 3 sqft, capable of making a [56"x99"]; [114" or 9.5' diag]; [37.5 sqft] screen @ $28 and 44 oz. - Fail after a bit of consideration, produced unusual patterns because the ridges in the denim interacted with the pixels. It also wrinkles very easily.
Now, we move on to the winners.
  1. Polyester Pleather - 54" Wide, $8.99/yd, 2.0 oz for 3sqft, capable of making a [54"x96"]; [110" or 9.1' diag]; [36 sqft] screen @ $24 and 24 oz. - One side is blurry, the other is very shiny but sharp. This unfortunately allows the projector to reflect back in your face, so there's bright spots. This is usable for rear or front projection, but would not be my first choice. Does not allow much light through but you can still see it on the other side. This means echoes will be very minor. If this is used for rear projection, it will eat a lot of the light but will not have a bright spot where the projector is.
  2. Target 30% Cotton 70% Polyester - 56" Wide, $6.99/yd, 2.0 oz for 3 sqft, capable of making a [56"x99"]; [114" or 9.5' diag]; [37.5 sqft] screen @ $20 and 25 oz. - Probably best material if you still wanted rear projection to be possible. Both sides are relatively good and very similar. Picture quality almost as good as #1 and #2. This allows you to do rear projection. Front projection will have a worse echo problem then the pleather. I am considering this, since I may want to do rear projection. Also this will have a bright spot where the projector is.
  3. Multipurpose Cloth - 54" Wide, $19.99/yd, 4.5 oz for 3sqft, capable of making a [54"x96"]; [110" or 9.1' diag]; [36 sqft] screen @ $54 and 54 oz. - Completely opaque, no chance of echo. Sharp picture, almost the same as blackout cloth. Prohibitively expensive and very heavy. This could double as a thick blanket in an emergency. :-p
  4. ***Black Out Cloth (70% Polyester, 30% Cotton) - 54" Wide, $5.99/yd, 3.5 oz for 3sqft, capable of making a [54"x96"]; [110" or 9.1' diag]; [36 sqft] screen @ $16 and 42 oz. - Opaque, nice, sharp picture. Very similar to multipurpose cloth. Fabric does not breathe, would not use as a blanket. Does not seem very easy to clean either. BUT! It's CHEAP, OPAQUE and not too heavy! This is what I will be building my screen out of. There's a lot of guides that go about ways of doing this. If I find a particularly innovative way, I may post it.
I took a number of pictures to compare.

You can see the pictures over at http://cnlohr.net/Pics/ProjectorTestPreview/

Some interesting pics are: [Poly Felt, Denim, Fleece, Target, Pleather, Wool Felt]

Comparison of the front and back side of the pleather:

You can see the problems with the denim and the moire effect

Just to make it completely obvious how bad the fleece is: Here is the fleece compared to the target.



Comparison from behind [Target-Blackout-Multicloth-Denim-Pleather]

You may not want to use Target if you are concerned about a bright spot coming through from the other side.



I cannot begin to stress how bad felt is at this: