01 May 2015

Raspberry pi setup wifi static IP

This is how I setup wifi on my PI :

In /etc/network/interfaces

auto lo

    iface lo inet loopback
    iface eth0 inet static

    auto wlan0
    allow-hotplug wlan0
    iface wlan0 inet static
    wpa-passphrase password
    wpa-ssid myssid

I have tried everything using /etc/wpa_supplicant/wpa_supplicant.conf, it never works !!!

28 April 2015

Raspberry pi + ola server + art-net + spi output + WS2801 leds

I am running my leds on my raspberry pi now after using a lot the FastLED library on my arduino, which is fantastic by the way.
Here's how to setup the rpi :

Donwload latest ola image from http://dl.openlighting.org/
Write it on a SD card
Start your rpi with this SD card
login : pi / password : openlighting

sudo raspi-config

Enable SPI in advanced options + overclock to turbo

sudo apt-get update

sudo apt-get upgrade

sudo reboot

add the following to /etc/udev/rules.d/99-spi.rulesSUBSYSTEM=="spidev", MODE="0666"

write and run this script :
for pin in 17 21; do
  echo $pin > /sys/class/gpio/export;
  chmod a+w /sys/class/gpio/gpio${pin}/value;
  chmod a+w /sys/class/gpio/gpio${pin}/direction;

sudo reboot

To config your leds :
1. Go to http://192.168.0.XXX:9090/ola.html and click 'STOP OLA'
2. Open file /var/lib/ola/conf/ola-spi.conf
In my case, a string of 25 pixels is

base_uid = 7a70:00000100                                                                                                                                    
device_prefix = spidev
enabled = true
spidev0.0-0-dmx-address = 1
spidev0.0-0-pixel-count = 25
spidev0.0-0-personality = 1
spidev0.0-backend = software
spidev0.0-ports = 1
spidev0.0-spi-speed = 1000000

Go to OLA admin :  http://192.168.0.XXX:9090/ola.html

Click add universe 

Universe ID = 1
Universe name = 1
Choose artnet as input
Choose SPI as output

You should be ready to go, now pick a software that sends data over artnet, like Glediator or Jinx!

Sources :


I have also a pinterest board where I put stuff for inspiration :

Have fun !!!!

17 March 2015

The martian - book by Andy Weir

I just finished reading this book, and I have to say it's fantastic, if you like creative science and thriller, go for it !!!!

The Martian book cover


CFSpreadsheet in coldfusion 10 - what I learned today

I've been struggling with cfspreadsheet recently and here are a few things I learned.

At first I was adding rows to my sheets using the SpreadsheetAddRow method, which worked fine until I met data with special characters and punctuation.
One workaround when building the list of values was surrounding them with quotes, like this :

<cfset value = listAppend(values," ' The value, look a comma, eat it ' ")>
Until it crashed ... I found out that a value starting with a comma was breaking the code, no idea why but I didn't want to start escaping characters from the original data, time to find another way.

That's where SpreadsheetSetCellValue comes to the rescue :

<cfset SpreadsheetSetCellValue(sheet, anyValue, rowIndex, columnIndex)>

When you have cells with a lot of data and others with simple values, it messes the default vertical alignment, time to apply some formatting using SpreadsheetFormatColumns :

<cfset SpreadsheetFormatColumns(sheet, {textwrap=true,verticalalignment='vertical_top'}, columns)>

It looked better, but the columns have the same width by default (very small), resulting in very tall columns, so I searched how to autoSize the columns, like you would do by double clicking between two columns, here's the solution, it requires to use an undocumented method of POI.
- Make the first sheet active, like this :
<cfset mysheet = sheet.getWorkBook().getSheetAt( javacast("int", 0) )>

- Then for each column you want to autoSize :
<cfloop from="0" to="16" index='col'>
<cfset mysheet.autoSizeColumn( javacast("int", col) )>

To prompt the user to download the sheet, I used spreadsheetReadBinary :

<cfheader name="Content-Disposition" value="attachment;filename=Applications.xls">
<cfcontent type="application/msexcel" variable="#spreadsheetReadBinary(sheet)#" reset="true">

No more mystical error messages and now the spreadsheet looks nice when it is opened.