Microblog: A very long article Wikipedia article on the orientation of toilet paper [Jun 7th, 22:52] [R]

Saturday, February 26th, 2011

BrewDog Alpha Dog

Categories: [ Beer/Brewdog ]

Brewdog_Alpha_Dog

“The Beer scene is sick. And we are the fucking doctor.”

Right. I'd rather be treated by a non-fucking doctor, if it's all the same to you. Anyway, everybody knows there is only one Doctor.

Smells kind of like raspberries and litchi. Quite bitter, but less than other BrewDog brews. Contains barley.

BrewDog Ltd., Fraserburgh, Scotland. 4.5% alcohol

[ Posted on February 26th, 2011 at 19:50 | no comment | ]

Sunday, February 20th, 2011

Orkney Red MacGregor

Categories: [ Beer/Orkney ]

Orkney_Red_MacGregor

“ruby-red beer, floral and fruity, with notes of violets, cherry, toffee and caramel… hints of roasted malt, with a biscuit malt and spicy hop finish.”

Fruity yes, cherries maybe, the violets I haven't found. Contains malted barley and malted wheat.

Sinclair Breweries Ltd, The Orkney Brewery, Stromness, Orkney, Scotland. 4.0% alcohol.

[ Posted on February 20th, 2011 at 17:47 | no comment | ]

Saturday, February 19th, 2011

Arduino with Vim

Categories: [ DIY/Arduino | IT ]

If you are used to Vim as a text editor, the Arduino IDE is terrible to use. After a little bit of fiddling, here are my tips to program an Arduino using Vim.

Makefile

To compile the Arduino software, I found the Makefile by Alan Burlison and I modified it to suit my needs. You can get the modified version and use it at your own risks.

It has been modified as follows:

  • Support for arduino 0022 only (but you can change the version number in the Makefile). Versions prior to 0018 are not supported.
  • Binaries are located in /usr/bin.
  • The board is by default atmega328.
  • The programming protocol is stk500v1 and the speed is 57600 bauds.
  • The terminal emulator is xterm and the serial communication software is picocom.
  • The serial port is /dev/ttyUSB0.

All these default values can be changed in the Makefile.master file. Moreover, the following changes have been made:

  • After killing the serial communication software, sleep for 1 second
  • Before starting the programmer, the DTR signal is triggered with stty to reset the board (programming would otherwise not be possible)
  • Warnings remain warnings (GCC's -Werror flag has been removed, because I had a weird warning that I don't know how to fix)
  • The sketch's .pde file is hardlinked into the build directory, and is #included in sketchname_pde.cpp instead of copied into it. This allows GCC to report the errors on the proper line of the .pde file as well as report the proper path for this file in its error messages (when compiling sketchname_pde.cpp, GCC is in the build directory; since it would include ../sketch.pde, the error messages relative to this file would point to a file name starting with ../, but since Vim is in the parent directory, the path to sketch.pde would be wrong and Vim's QuickFix fails to find the file).
  • Linking is made by gcc instead of g++ because of a bug in linking to libm (which is needed if you want to do floating point computations, so it links against it by default).
  • A vim: line has been appended to make Vim recognize the file as a Makefile

To use this Makefile, put Makefile.master into your sketchbook directory, and create in your sketch's directory a Makefile which contains include ../Makefile.master. If you want to add extra libraries (here RF12, GLCDlib and Ports), it looks like this:

LIBS = RF12 GLCDlib Ports
LIB_DIRS = $(addprefix ../libraries/,$(LIBS))
include ../Makefile.master

Typing make inside the directory where the Makefile resides builds the sketch. make upload uploads it, make monitor starts the serial communication software on the serial port and make upload_monitor does both sequentially. Finally, make clean cleans up the build directory created when buidling the sketch.

Arduino Syntax File for Vim

Get arduino.vim by Johannes Hoff and put it in your ˜/.vim/syntax/ directory. It will let Vim recognize .pde files are as arduino, turning on C++ syntax highlighting plus Arduino-specific keywords.

Tabs

Vim allows to open multiple tabs: run vim -p *.* in your sketch's directory, and it opens all the files (except the Makefile) in separate tabs. Use Ctrl-PgUp and Ctrl-PgDown to switch between tabs.

To close all tabs at once, you can use :tabd q, but this is tedious, so I made a shortcut: Add command Q tabd q to your .vimrc and you can close all the tabs at once using :Q. You can do the same with :w, :wq and :x if you want.

Type :help tab to learn more about tabs (especially, :tabe xyz opens file xyz in a new tab. I thought you'd be glad to know).

QuickFix

You can call make from within Vim by typing :make but that's tedious also. I added the following mappings to my .vimrc:
imap <F9> <ESC>:make<CR>
map <F9> :make<CR>

This lets F9 calls :make (whether you're in command mode or in insert mode). You may want to add set autowrite in your .vimrc so that your files are automatically written when you call make.

Now, at least in Debian, after the call to :make has completed, when you return to your file's screen Vim redirects you to the file that contains the first error in make's output. In my setup, this is a warning in a file belonging to Arduino's core, which I don't want to modify. I could of course press Ctrl-O to return to the file I was editing just before running :make, but that's too much work. What I wanted is to be able to let Vim jump to the files containing warnings and errors, but to force it to ignore system files. The solution is then to add to your ˜/.vimrc the following (all in one line, without spaces after the equal sign):

autocmd Filetype arduino set errorformatˆ=\%-G../libraries\%.\%#,\%-G../../libraries\%.\%#,%-G/space/mweber/tmp/arduino-0022\%.\%#

It requires some tuning, because your Arduino directory is probably not in /space/mweber/tmp/arduino-0022, but since you're smart, you have already understood how to adapt it to your setup.

Please note that to get this setup to work properly, you need to append // vim:ft=arduino to all of the .pde, .cpp and .h files belonging to your sketches, otherwise the Vim will not do the ignoring above. And for this to work, modelines must be enabled by adding set modeline to your ˜/.vimrc.

Finally, since you opened all your files in tabs already, tell Vim not to open the file containing a warning/error in the current tab, but rather in the tab that already contains the file. You do this by adding set switchbuf=usetab in your ˜/.vimrc.

In short, your ˜/.vimrc has now these extra lines:

command Q tabd q
command W tabd w
set modeline
set autowrite
set switchbuf=usetab
imap <F9> <ESC>:make<CR>
map <F9> :make<CR>
autocmd Filetype arduino set errorformatˆ=\%-G../libraries\%.\%#,\%-G../../libraries\%.\%#,%-G/space/mweber/tmp/arduino-0022\%.\%#

[ Posted on February 19th, 2011 at 19:22 | 2 comments | ]

Saturday, February 12th, 2011

Button Box

Categories: [ DIY ]

ButtonBox7

Here's the Button Box. It has three illuminated push-buttons, one knob (which also acts as a push-button) and one light-dependent resistor (the small thinggy on the lower-right corner) which are controlled by an RBBB microcontrller (software-compatible with the Arduino). Here's the control software.

ButtonBox9

The push-buttons contain each one bi-color LED (red-green); its color depends on the direction of the current. Each LED which is controlled using PWM, which allows to quickly reverse the direction of the current and create the illusion of a yellow/orange color. Moreover, the Box senses the amount of ambient light (with the light-dependent resistor) and adjust the intensity of the light depending on that: by night, the LEDs are on only 1/64th of the time, while in daylight they are on at 100%, making them more visible.

ButtonBox8

It connects to the computer through a serial-to-USB adapter. It's a bit ugly like that, but who cares.

ButtonBox1

The current through the LEDs is limited by a 150 Ω resistor. The push-buttons use the microconstroller's internal pull-up resistors. The light-dependent resistor (rated 4 – 11 kΩ, whatever this exactly means) forms a voltage divider with a 1 kΩ resistor, and its value is read by one of the analog inputs of the microcontroller.

ButtonBox3

The white PCB is the RBBB, which is powered by the USB-BUB (serial-to-USB adapter, based on an FTDI chip). It's not the cheapest solution, but those components were the easiest to obtain.

ButtonBox4

The USB-BUB has its outputs rewired to the row of holes along its side, and is soldered sideways to the RBBB using a row of pin headers. The RBBB is then screwed through one ready-made hole to the bottom of the box through an additional piece of plastic glued (with cyanoacrylate glue) to the bottom. This gives a thickness of almost 5 mm which is enough to hold the screw (a bit thicker would have been better). The same is done to the other end of the RBBB which has a similar hole. This holds the USB-BUB enough for the USB cable to be inserted and removed.

ButtonBox5

Side view. ABS project boxed are nice, because they are easy to drill and cut through with a hacksaw or even with a knife for smaller details.

ButtonBox6

Inside view with the side walls removed. It's quite tight inside, but it fits nicely.

[ Posted on February 12th, 2011 at 23:04 | 3 comments | ]

Friday, February 11th, 2011

BrewDog Thrashy Blond

Categories: [ Beer/Brewdog ]

Brewdog_Trashy_Blond

“malt body… passion fruit hop”

The first sniff reminded me of litchi, but after that it was just another ale. Quite bitter, it seems to be a characteristic of this brewer. Contains barley.

BrewDog Ltd., Fraserburgh, Scotland. 4.1% alcohol

[ Posted on February 11th, 2011 at 19:01 | no comment | ]

Monday, February 7th, 2011

Starman

Categories: [ TV/Cinema ]

http://en.wikipedia.org/wiki/Starman_%28film%29

Wikipedia

After Voyager 2 transported a message to the distant stars, a UFO flies over the USA and is shot by the Air Force. The alien arrives near Jenny's house, where it takes the form of her late husband. He then asks her to drive him to Winslow, Arizona where he must rendez-vous with his mothership 3 days later. On the way, he learns some amount of English, and about the ways of humans. Jenny is at first afraid, but she eventually falls in love with him. They are chased by the federal police and the army, but eventually manage to escape thanks to the help of a SETI scientist, advisor the the federal police, but who doesn't approve of the methods of the government. The alien eventually leaves, leaving Jenny pregnant with a son who will one day teach the humans about the alien's civilization.

[ Posted on February 7th, 2011 at 22:59 | 3 comments | ]

Sunday, February 6th, 2011

St Peter's Golden Ale

Categories: [ Beer/St Peters ]

St_Peters_Golden_Ale

“Traditional malts and English hops… delicate, fresh, grainy after-taste.”

Quite strong hop flavour. Contains malted barley.

St. Peter's Brewery, Bungay, Suffolk, England. 4.7% alcohol.

[ Posted on February 6th, 2011 at 11:07 | no comment | ]

Saturday, February 5th, 2011

Meantime London Lager

Categories: [ Beer/Meantime ]

Meantime_London_Lager

“Kentish hops and East Anglian malting barley”

Just another beer. Contains barley.

Meantime Brewing, London, England. 4.5% alcohol.

[ Posted on February 5th, 2011 at 19:01 | no comment | ]

Friday, February 4th, 2011

Orkney Dragonhead

Categories: [ Beer/Orkney ]

Orkney_Dragonhead

“tribute to the Vikings and their cultural legacy in Orkney… roasted malt aroma, bitter chocolate, dark roasted coffee and smokey notes balanced by hints of spicy Goldings hop… chocolate, toast and nut flavours… spicy hop finish.”

Definitely chocolatey and coffey, only slightly bitter. Quite nice. Contains malted barley and malted wheat.

Sinclair Breweries Ltd, The Orkney Brewery, Stromness, Orkney, Scotland. 4.0% alcohol.

[ Posted on February 4th, 2011 at 18:35 | no comment | ]