Core Dump

To content | To menu | To search

Wednesday, November 12 2014

Battery backup for Adafruit Ultimate GPS Breakout - 66 channel w/10 Hz updates - Version 3

I was testing that [1] gps chip for a last few weeks - it was great, but it was preforming "cold start" every time it was turned on. Today I finally soldiered the battery holder and slided a CR1220 battery in. If you're using the same board without the battery get one immediately. Time to fix is now a few seconds (used to be up to 15 minutes) and it gets the fix fairly quickly indoor as well!!

I'm planning to use that board in the Open Cycling Computer project. More to come.


Wednesday, October 15 2014

PiTFT capacitive calibration for vertical layout

PiTFT capacitive doesn't require calibration according to Adafruit, but for some reason I couldn't make it work properly with vertical layout and the default values suggsted here [1].

The default values are:

320 65536 0 -65536 0 15728640 65536

I needed to use the screen with Adafruit logo at the bottom [fbtft_device.rotate=90] and with the default /etc/pointercal values I had x axis swapped with y axis.

Explanation how the pointercal values works is here [2]. Some matrix math:



x,y - the touchscreen coordinates returned by the kernel driver

a,b,c,d,e,f,s - pointercal values

u,v - the screen coordinates

The above equation converts to:

u = (x*a + y*b +1*c)/s

v = (x*d + y*e +1*f)/s

For the default values:

a = 320, b = 65536, c = 0 d = -65536, e = 0, f = 15728640, s = 65536

u = (x*320 + y*65536 + 0) / 65536

v = (x*(-65536) + y*0 + 15728640) / 65536

I wanted to flip x<->y, so

u = (x*(-65536) + y*0 + 15728640) / 65536

v = (x*320 + y*65536 + 0) / 65536

and now a = -65536, b = 0, c = 15728640 d = 320, e =65536 , f = 0,  s = 65536.

However when I tried to use those values in the pointercal file:

-65536 0 15728640 320 65536 0 65536

I found out that x axis is OK, but y axis is still flipped. To fix it we have to change sign of v and add a shift.

v = -(x*320 + y*65536 + 0) / 65536 +320

v = (x*(-320) + y*(-65536) +0)/65536 + 320

v= (x*(-320) + y*(-65536) +0)/65536 + 320*65536/65536

v= (x*(-320) + y*(-65536) +320*65536)/65536

v= (x*(-320) + y*(-65536) + 20971520)/65536

so d = -320, e = -65536 and f = 20971520

Proper pointercal values for vertical layout [fbtft_device.rotate=90] are:

-65536 0 15728640 -320 -65536 20971520 65536

Friday, August 22 2014

Bosch BMP183 with SPI by Adafruit in python on Raspberry PI

How to measure temperature and pressure with raspberry pi and BMP183


- raspberry Pi
- BMP183 with SPI by Adafruit
- 6 wire female-to-female cable or any other to connect 6 pins between RPI and BMP183


Temperature: 18.9 deg C

Pressure: 1013.39 hPa

RPI + BMP183: rpi_a_and_bmp183.jpg

Schematic (png): rasperry_pi_and_bmp183_sensor.png

That entry is the first part of Open Cycling Computer project

Schematic (QElectroTech): rasperry_pi_and_bmp183_sensor.qet

BMP183 at Adafruit

All files on github

BMP183 datasheet

Thursday, April 17 2014

i4oled-gui is ready!

Now there is a way of setting OLED icons on Wacom Intuos4 tablets using simple GUI:

The source code can be downloaded from GitHub.

It requires gnome & dconf, but it doesn't require root access rights as it works by writing to dconf. I hope that some of the ideas tested in i4oled-gui will be used in gnome.

Installing on Fedora 20:

1. Install required packages: sudo yum install git autoconf automake gcc gtk3-devel dconf-devel

2. Clone the repository

git clone

3. Enter & build

cd i4oled-gui




sudo make install

If there is a message about missing gtk+-3.0 during configure stage it means that there is no gtk3-devel package. Same for dconf - it means that there is no dconf-devel package. Ubuntu uses different names: gtk3-dev and dconf-dev.

i4oled-gui looks for icons in 3 locations:




The first two are shown when "System" button is pressed, The last path is linked with "User" button.

Icons have to be PNG files, 64 x 32, 8-bit/color RGBA, non-interlaced There is a script in data/pixmaps/svg/ that converts SVG to the desired format. Also all icons generated by i4oled can be used. Text entry fields also accepts base64 strings generated by i4oled, but it's not yet a fully finished feature (stop & start of i4oled-gui is required to see the icon)

Known limitations: i4oled-gui works on first usb tablet found in dconf user file, so if you have more than one tablet .. tough luck (at least untill i4oled-gui lands in gnome). There is no bluetooth support yet. Also there is no live preview of rendered text in the icon field.

If you read this entry this far (well done!!) it means that you're interested in using i4oled-gui, so if you want to send me a feedback use GitHub or przemo (at) firszt (dot) eu

Tuesday, March 11 2014

OLEDs-over-bluetooth are on the way to gnome

Hopefully soon gnome users will be able to fully utilise OLED displays on wacom Intuos4 wireless tables. More (technical) details here:

Friday, February 28 2014

i4oled v1.2 is out

Version 1.2 of OLED handling tool for Wacom Intuos4 Wireless is out! Most important changes are that now i4oled allows to use base64 encoded strings as input or output and it allows multiple outputs at the same time. The base64 strings can be used with gnome dconf-editor to show an icon instead of text. The base64: string should be pasteed into oled-label field instead of normal description. Gnome-settings-daemon will do the rest and convert it back into nice icon on the tablet. The version 1.2 can be downloaded here.

Thursday, February 27 2014

Using Wacom Intuos4 Wireless in unusual way

How to make clock out of your wacom tablet (with OLEDs obviously)?


There is one thing required - it's i4oled

The "clock" can be set up over usb or bluetooth link. The example below uses bluetooth

1. Connect tablet. 2. Change permissions for OLEDs as we want to use i4oled without root access.

sudo chmod a+w /sys/bus/hid/drivers/wacom/0005\:056A\:00BD.0001/oled?_img

3. Change permissions for LED selector - it's brightness is linked to OLEDs

sudo chmod a+w /sys/bus/hid/drivers/wacom/0005\:056A\:00BD.0001/leds/0005\:056A\:00BD.0001\:selector\:0/brightness

4. Change the brightness

echo 200 > /sys/bus/hid/drivers/wacom/0005\:056A\:00BD.0001/leds/0005\:056A\:00BD.0001\:selector\:0/brightness

Now we're ready to test i4oled:

i4oled -b -t TEST -d /sys/bus/hid/drivers/wacom/0005\:056A\:00BD.0001/oled7_img

If text TEST shows up next to the bottom button it means that everything works fine and we can set up the clock:

while [ 1 ]; do i4oled -d /sys/bus/hid/drivers/wacom/0005\:056A\:00BD.0001/oled7_img -b -t $(date +%D+%T); sleep 1; done

The above command converts current date & time into image and sends it to the OLED screen:

Monday, February 17 2014

How to change OLED label on Intuos4 tablets on gnome

If you have that tablet you probably want to have full control of what is being displayed on those little OLED screens on the tablet. Currently gnome doesn't give option to change it - you just have to accept whatever was generated for you. Or, do you?

This is a workaround and I hope in long run we wont need it.

Hit Alt-F2 and type "dconf-editor" Go to org -> gnome -> settings-daemon -> peripherials -> wacom

You should see there a ID string that look very user unfriendly, like here:


Open the item and find buttons section and edit OLED label:


That's it! You should see this on your tablet:


Tuesday, June 25 2013

i4oled - bluetooth support

i4oled just got bluetooth support. Wacom Intuos4 WL supports 4-bit images over USB connection, but only 1-bit when connected over bluetooth. i4oled now supports both with --bluetooth switch. Example usage:

i4oled -d /sys/class/hidraw/hidraw0/device/oled5_img -t "Alt+Ctrl" --bluetooth
i4oled -d /sys/class/hidraw/hidraw0/device/oled7_img -i help.png -b

And that's how it looks on the device:

Wacom OLEDs ovet bluetooth

Sunday, June 23 2013

Galaxy S4 3D printed car holder

S4 holder

S4 holder closeupS4 holder with phoneS4 holder in car

The cradle for S4 is based on an old S2 car holder:S2 holder

S2 holder part 2

All designed using FreeCAD and Blender 3D.

S4 holder.blend

The model _will_ require some cutting after printing otherwise it won't fit the phone. Additional cutting might be required if battery cover has been replaced.

Friday, May 31 2013

OpenSCAD - first battle

My first attempts to use OpenSCAD:

module hc_hexagon(size, height) {
box_width = size/1.75;
for (r = [-60, 0, 60]) rotate([0,0,r]) cube([box_width, size, height],
module hc_column(length, height, cell_size, wall_thickness) {
no_of_cells = floor(1 + length / (cell_size + wall_thickness)) ;
for (i = [0 : no_of_cells]) {
translate([0,(i * (cell_size + wall_thickness)),0])
hc_hexagon(cell_size, height + 1);
module honeycomb (length, width, height, cell_size, wall_thickness) {
no_of_rows = floor(1.75 * length / (cell_size + wall_thickness)) ;
tr_mod = cell_size + wall_thickness;
tr_x = sqrt(3)/2 * tr_mod;
tr_y = tr_mod / 2;
off_x = -1 * wall_thickness / 2;
off_y = wall_thickness / 2;
cube([length, width, height]);
for (i = [0 : no_of_rows]) {
translate([i * tr_x + off_x, (i % 2) * tr_y + off_y, (height) / 2])
hc_column(width, height, cell_size, wall_thickness);
//honeycomb(length, width, height, cell_size, wall_thickness);
honeycomb(140, 80, 20, 5, 1);

Formatting doesn't look very good in narrow blog, it looks better here: honeycomb.scad

Honeycomb - blender render

And more files: honeycomb.csg , honeycomb.stl and blender model honeycomb.blend

P.S. Thanks to help from OpenSCAD forum I have a new, improved & much faster honeycomb script:

module hc_column(length, cell_size, wall_thickness) {
        no_of_cells = floor(length / (cell_size + wall_thickness)) ;

        for (i = [0 : no_of_cells]) {
                translate([0,(i * (cell_size + wall_thickness)),0])
                         circle($fn = 6, r = cell_size * (sqrt(3)/3));

module honeycomb (length, width, height, cell_size, wall_thickness) {
        no_of_rows = floor(1.2 * length / (cell_size + wall_thickness)) ;

        tr_mod = cell_size + wall_thickness;
        tr_x = sqrt(3)/2 * tr_mod;
        tr_y = tr_mod / 2;
        off_x = -1 * wall_thickness / 2;
        off_y = wall_thickness / 2;
        linear_extrude(height = height, center = true, convexity = 10, twist = 0, slices = 1)
                        square([length, width]);
                        for (i = [0 : no_of_rows]) {
                                translate([i * tr_x + off_x, (i % 2) * tr_y + off_y,0])
                                        hc_column(width, cell_size, wall_thickness);

//honeycomb(length, width, height, cell_size, wall_thickness);
honeycomb(140, 80, 20, 5, 1);

Friday, April 26 2013

Gnome and Intuos4 OLEDs

Another day, another patch. Gnome will be getting wacom intuos4 OLEDs support. It's going to look like this: Wacom OLEDs in action in gnome

More details here: Light up the OLEDs

Hopefully those patches will land in gnome 3.10. Things that are waiting to be implemented:
  • bluetooth support for status led and OLEDs (kernel side ready, user side non existing)
  • multi keystroke sequences
  • editable labels i.e. mapping to Ctrl-S, but OLED label showing "Save"
  • icons instead of labels

Update: Basic handling of wacom OLEDs has been included in gnome-settings-daemon and gnome-control-center

Monday, November 12 2012

Rooting Sanei N10 Deluxe on linux command line

The Sanei N10 Deluxe tablet is _potentially_ a good tablet. Unfortunately the original firmware is absolutely useless. To get rid of it the device has to be rooted and re-flashed with something more SANE(I) ;-)


1. the device itself - Sanei N10 Deluxe

2. usb cable

3. linux box with installed Android SDK

4. internet connection - for downloading AndroidRoot

The procedure below is based on bat file from AndroidRoot:

1. Download and unzip AndroidRoot

It contains some windows executables, a .bat file and 2 files that are important for linux users: "su" and "superuser.apk"

Copy those 2 files to your home directory (or any other, I assume they are in the home dir)

3. Switch on "USB Debugging" on the tablet. It's in Settings -> Developer Options

4. Connect the device and make sure it's detected by the system:

Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 003 Device 002: ID 8087:07da Intel Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 010: ID 18d1:0003 Google Inc.

The last line show that the tablet is connected.

5. Make sure you have rights to access the device (adb command is part of Android SDK):

przemo@localhost:$~/android-sdk-linux/platform-tools/adb devices
List of devices attached
20080411    device

If there is no device check here

6. Go to Android SDK directory -> platform-tools. On my linux box it's:

cd ~/android-sdk-linux/platform-tools/

7. Now time to start rooting

./adb shell mv /data/local/tmp /data/local/tmp.bak
./adb shell ln -s /data /data/local/tmp
./adb reboot

8. Wait for the tablet to complete reboot and type:

./adb shell rm /data/local.prop > nul
./adb shell "echo \"ro.kernel.qemu=1\" > /data/local.prop"
./adb reboot

9. Again, wait for the tablet to complete reboot and confirm that we have root access:

./adb shell id

The result should be:

uid=0(root) gid=0(root)

10. Now we can install "su" (make sure correct location of "su" is used - that's the file from AndroidRoot):

./adb remount
./adb push ~/su /system/xbin/su
./adb shell chown 0.0 /system/xbin/su
./adb shell chmod 06755 /system/xbin/su

11. Revert the changes that gave us root access:

./adb shell rm /data/local.prop
./adb shell rm /data/local/tmp
./adb shell mv /data/local/tmp.bak /data/local/tmp

12. Install superuser.apk (same comment about location of apk file as for point 10)

./adb push ~/superuser.apk /system/app/superuser.apk

13. Reboot and enjoy rooted tablet:

./adb reboot

That's it - now the Sanei N10 Deluxe is ROOTED.

Monday, September 10 2012

3 steps to have live tracking in JOSM

What you have to have: - JOSM + LiveGPS plugin - android SDK - TetherGPS on you android phone.

1: Start TetherGPS and connect the phone using USB cable (turn on "Debugging" - it's in settings) 2: Type: adb tcp:2947 tcp:2947 - this forwards port 2947 from your phone to your computer. "adb" is part of Android SDK 3: Open JOSM (with LiveGPS pugin) and Click in the main menu LiveGPS->Autocenter

That's all. As soon as you mobile phone gets GPS fix JOSM will start updating your location on the map! You can save the track and help improving OpenStreetMap

That's how it looks: JOSM live tracking

Sunday, September 9 2012

OLED icons on Intuos4 tablets [v0.1]

I made a simple helper for setting OLED icons on Intuos4 tablets. It can be cloned from here:

git clone git://

The helper accepts PNG images (64 x 32, 8-bit/color RGBA, non-interlaced) and it uses only red channel from the PNG file. There are some example icons in icons/ directory. The kernel patch mentioned in 'usage' option is not yet ready for release, but '-s' (scramble) option should allow to use i4oled with any kernel with wacom OLED support.

Please test and report back - I have only Intuos4 Wireless tablet, so i4oled hasn't been tested on any other model.

I'm waiting for reports if it works with the whole Intuos4 family - I'm going to implement an option for setting OLED icons as part of the button mapping in the wacom panel in gnome system settings.

UPDATE [11 Sep 2012]: now the helper renders text using pango/cairo. It's still rough on edges, so be careful! That's how it looks on Intuos4 Wireless:

OLED text rendered by pango on Intuos4

UPDATE [4 Oct 2012] v1.0 is out, scrambling is now default

OLEDs on Intuos4 Wireless are 4-bit!!

I found out that OLEDs on my Intuos4 Wireless are actually 4-bit colour instead of 1-bit. I don't know (yet) a method of setting 4-bit icons over bluetooth, but I have a proof that it can be done over USB. The proof:

Intuos4 Wireless 4-bit OLEDs

It's close up of one of the OLED displays on Intuos4 Wireless connected with USB cable.

Monday, August 6 2012

How to use an android phone as a GPS receiver with GPS-less tablet using only GPL software....

... or how to use GPS-less tablet as big screen GPS car navigation. The setup that I tested:

- tablet Sanei N10 Deluxe with Android 4.0.3

- Samsung Galaxy S2 with CyanogenMod9

The tablet has no GPS receiver, so my favourite navigation/tracking OSMAnd cannot be used directly. To solve that problem I downloaded BlueGPS for the tablet and BlueNMEA for the phone. BlueNMEA works as GPS data server, the location is transmitter over bluetooth to BlueGPS on the tablet. BlueGPS uses "mock location" function to provire real GPS location for all the software runnng on the tablet.

How to set it up?

1. Allow use "mock locations" in

Settings -> Developer Options -> Allow mock locations on the tablet.

2. Pair tablet and phone using normal bluetooth functions in

Settings -> Bluetooth

3. Start BlueGPS on tablet

4. Start BlueNMEA on the phone

BlueNMEA before connection 5. Wait for the tablet to appear on devices list

BlueNMEA connected

6. As soon as the phone GPS get fix the info is passed to the tablet, so it can be used by i.e. OSMAnd or any other navigation software.

Thursday, August 2 2012

OLED icons on Wacom Intuos4 Wireless PTK-540WL - part 2

Full workflow how to get a custom icon on Wacom Intuos4 WL (this doesn't work for other Intuos4 family members!)

Make a 1-bit 64x32 pixels image. Let's say it's the recycling symbol:

recycle icon 64x32 1-bit png

Save it to PBM format, raw version. GIMP is perfect for that. Open the newly created file in a text editor. The header should look similar to this:

# CREATOR: GIMP PNM Filter Version 1.1
64 32

It means that we created "portable bitmap/binary" using GIMP and the dimensions are 64 by 32 pixels. The rest of the file contains actual image, saved in 256 bytes, 8 pixels per byte. Some PBM icons here or here (full pack).

Now strip the header and save the "raw" icon. The file should hve exactly 256 bytes. If it has more or less it might mean that your text editor cannot handle binary files (try vim!) And again you can download "raw" icons - link above (same as PBM icons). Save the file to "recycle.i4wl" or download ready "recycle" icon from the pack.

Now connect the tablet using bluetooth connection. If you have applied the patches from this entry (I'll update the info here if the patches are accepted to the mainline kernel) you should see some oled_*img files in /sys/class/hidraw/hidraw(dev_number)/device directory. Each of those 8 files represents one icon on wacom Intuos4 wireless tablet. See this entry for information how to set the icon on your tablet using "dd" command. Hopefully setting the icons will be included into wacom gnome-control-center panel (any volunteers? ;-) )

Come back later to see how to batch create icons!

Sunday, July 29 2012

OLED icons on Wacom Intuos4 Wireless PTK-540WL

I just submitted 2 kernel patches [PATCH 1, PATCH 2 there is a good chance that it's not the final version, but it works] that will allow to set OLED icons on Wacom Intuos4 Wireless PTK-540WL tablet. The patechs create some "control" files in /sys/class/hidraw/hidraw/dev_no/device. The files are named oled*_img where * is number 0 to 7. Each of them represents one icon on the tablet. Sending a 256 bytes long file to an oled*_img control file writes it to tablet memory. The result can look like this:

Tux on wacom intuos4wl 1  

or thisTux on wacom intuos4wl

or just this:

Arrows on wacom intuos4wl

The control files accept simple pbm format but without the header. The image has to be 64 by 32 pixels, so the lenght withut the header is 256 bytes. If the file has different lenght if won't be accepted as kernel performs lenght check. Some example icons are here:


The photo above shows them on tablet.

Example of command line method for sending the icon:

dd bs=256 if=icon_file.i4wl of=/sys/class/hidraw/hidraw1/device/oled1_img count=1

To see the icon we have to change it's brightness (it also lits one of the wheels leds):

echo 50 > /sys/class/hidraw/hidraw1/device/leds/0005\:056A\:00BD.0001\:selector\:0/brightness

More icons and full workflow from an image to icon on the tablet soon.

P.S. Look here for *.i4wl files if you want more icons

Wednesday, July 11 2012

Setting device permissions for Samsung Galaxy S2 with udev

As SYSFS is now obsolete on some systems the rule for Samsung Galaxy S2 should be now:

SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", MODE="0666"

See here a previous entry for more details how and where set the rule for udev.

Saturday, August 27 2011

Samsung S2 - best phone ever?

Finally I got my Samsung Galaxy S2. Stay tuned for a tutorial how to root it and install Cynanogenmod in a linux way (no Kies, no Odin, no windows - only Heindall and linux command line)

Monday, June 27 2011

CyanogenMod on LG P500

I finally found some time to play with CyanogenMod. Installation is easy if you know where are the pitfalls - I didn't know. First and foremost: backup! Backup of contacts, backup of text messages, backup of current rom. Then installation of flash_image, recovery-RA-GNM-thunderg-1.1.0.img and ClockWorkMod - it has to be done manually, but hopefully will be changed soon. Having that set installed phone is ready to be wiped out (data & cache). The final step: CyanogenMod is easy. I'm was going to make tutorial how to install CyanogenMod on LG P500 starting from original LG rom, but things are changing at the speed of light - I might make tutorial on Samsung Galaxy S2 soon (whatever soon means this time).

Wednesday, February 9 2011

Hello World, my first android application in 3 steps (CLI only)

The official android webpage suggests that Eclipse is the best tool for devloping. I tried really hard to set it up, but after 2 days, 6 IRC channels and many differen config switches tested I gave up. PermGen out of memory error finally won with my patience. Looks like my problems were caused by java virtual machine I tried to use, but it makes no difference at all - Eclipse was unusable. I decided to got the CLI way and I'm not dissapointed.

A few words of explanation: I'll show how to create a simple "Hello World" app using just one console (or terminal window), but it's much more convinient to use 2 or 3 of them to avoid changing directory all the time.

Three steps to my first application

1. Go to "tools" directory in android-sdk:
przemo@pldmachine ~$ cd ~/android/sdk/tools/
and type (in one line):

./android create project
--target android-8
--name Test
--path /home/users/przemo/workspace/Test
--activity TestActivity

przemo@pldmachine$ ./android create project --target android-8 --name Test --path /home/users/przemo/workspace/Test --activity TestActivity --package
Created project directory: /home/users/przemo/workspace/Test
Created directory /home/users/przemo/workspace/Test/src/com/android/test
Added file /home/users/przemo/workspace/Test/src/com/android/test/
Created directory /home/users/przemo/workspace/Test/res
Created directory /home/users/przemo/workspace/Test/bin
Created directory /home/users/przemo/workspace/Test/libs
Created directory /home/users/przemo/workspace/Test/res/values
Added file /home/users/przemo/workspace/Test/res/values/strings.xml
Created directory /home/users/przemo/workspace/Test/res/layout
Added file /home/users/przemo/workspace/Test/res/layout/main.xml
Created directory /home/users/przemo/workspace/Test/res/drawable-hdpi
Created directory /home/users/przemo/workspace/Test/res/drawable-mdpi
Created directory /home/users/przemo/workspace/Test/res/drawable-ldpi
Added file /home/users/przemo/workspace/Test/AndroidManifest.xml
Added file /home/users/przemo/workspace/Test/build.xml
Added file /home/users/przemo/workspace/Test/proguard.cfg

As you can see "android" did all the boring job of creating app skeleton for us.

2. Go to the application directory and compile it.

przemo@pldmachine$ cd ~/workspace/Test/
przemo@pldmachine$ ant debug

[removed compile output]
.. debug:
        echo Running zip align on final apk...
        echo Debug Package: /home/users/przemo/workspace/Test/bin/Test-debug.apk
Total time: 4 seconds
przemo@pldmachine ~/workspace/Test$

Those are only last few lines of a succesful build. Now we're ready to install the app

3. Go to "platform-tools" and upload the app to phone:

przemo@pldmachine$ cd ~/android/sdk/platform-tools/
przemo@pldmachine$ ./adb -d install /home/users/przemo/workspace/Test/bin/Test-debug.apk
*daemon not running. starting it now on port 5037 *
*daemon started successfully *
233 KB/s (13223 bytes in 0.055s) pkg: /data/local/tmp/Test-debug.apk Success

Now you should see a new application named TestActivity in your phone. It doesn't do anything usefull, but that's my first android app!

Thursday, February 3 2011

LG Optimus One P500 - first steps of an android developer

I got my LG P500 roughtly 30 hours ago, so it's high time to share the first impressions. If you're looking for a review if the phone is good, responsive, have a good display and so on - yes, the phone is quite good and I like it. I bought P500 to get some hands-on experience with android, so the most important thing for me was to get access from android sdk. It's really easy if you're a linux user. If you're still using windows - I'm sorry that's a linux fanboy blog. Switch and come back later....

Now let's move to some more interesting stuff.

First, you have to switch on USB debugging on P500. It's in Settings/Applications/Development. Next connect USB cable. Do not select option to connect as an USB storage. Open a terminal and type "lsusb" to check if your linuxbox sees the phone:

przemo@pldmachine ~$ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 002: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
Bus 003 Device 002: ID 03f0:011d Hewlett-Packard Integrated Bluetooth Module
Bus 001 Device 015: ID 1004:618e LG Electronics, Inc.

OK, we've got it! Now go to your android sdk directory (how to install android-sdk) and type:

przemo@pldmachine ~/android/sdk$ platform-tools/adb devices

The result will look probably like this:

przemo@pldmachine ~/android/sdk$ platform-tools/adb devices
List of devices attached
???????????? no permissions

Which means that the LG P500 is connected but you don't have enough access rights. To fix it we have to define a new rule for udev. You have to be root or use sudo to do it. The file should be located in /etc/udev/rules.d/51-android.rules and it should contain just one line:

SUBSYSTEM=="usb", [SYSFS]ATTR{idVendor}=="1004", MODE="0666"

It used to be SYSFS, but now it's ATTR. It defines that udev should give you full access rights when a LG device (idVendor="1004") is connected - 1004 is the same number that is bolded in the results of lsusb command. The last touch, changing access rights to the rules file:

chmod a+r /etc/udev/rules.d/51-android.rules

Now reconnect your phone to get full access rights:

przemo@pldmachine ~/android/sdk$ platform-tools/adb devices
List of devices attached
80A354043043410507 device

We can test if it really works, let's try to open remote shell on our shiny P500:
przemo@pldmachine ~/android/sdk$ platform-tools/adb shell

$ ls -l
dr-x------ root    root             2011-02-02 13:03 config
drwxrwx--- system  cache            2011-02-03 18:23 cache
lrwxrwxrwx root    root             2011-02-02 13:03 sdcard -> /mnt/sdcard
drwxr-xr-x root    root             2011-02-02 13:03 acct
drwxrwxr-x root    system           2011-02-02 13:03 mnt
lrwxrwxrwx root    root             2011-02-02 13:03 d -> /sys/kernel/debug
lrwxrwxrwx root    root             2011-02-02 13:03 etc -> /system/etc
drwxrwx--- lgdrm   lgdrm_acc        1980-01-06 00:19 lgdrm
drwxrwx--x system  system           2011-02-02 13:03 persist
drwxr-xr-x root    root             2010-10-01 22:48 system
drwxr-xr-x root    root             1970-01-01 01:00 sys
drwxr-x--- root    root             1970-01-01 01:00 sbin
dr-xr-xr-x root    root             1970-01-01 01:00 proc
-rwxr-x--- root    root       16316 1970-01-01 01:00 initlogo.rle
-rwxr-x--- root    root        9323 1970-01-01 01:00 init.thunderg.rc
-rwxr-x--- root    root       18323 1970-01-01 01:00 init.rc
-rwxr-x--- root    root        4869 1970-01-01 01:00 init.qcom.rc
-rwxr-x--- root    root        3352 1970-01-01 01:00
-rwxr-x--- root    root         122 1970-01-01 01:00
-rwxr-x--- root    root      357656 1970-01-01 01:00 initv
-rw-r--r-- root    root        1152 1970-01-01 01:00 fota.rc
-rw-r--r-- root    root         118 1970-01-01 01:00 default.prop
drwxrwx--x system  system           1980-01-06 00:19 data
drwxr-xr-x root    root             1970-01-01 01:00 chargerimages
drwxr-xr-x root    root             1970-01-01 01:00 bootimages
drwx------ root    root             2010-10-01 22:03 root
drwxr-xr-x root    root             2011-02-03 22:35 dev

Hey, it looks almost like a normal linux box root directory! I like it.... :-)

Sunday, December 5 2010

Git - the beginning

So, you prepared a bug fix for your favourite piece of software, you're sure that it fixes all problems (also future problems!!) you've ever had and, of course, it's a perfect piece of code. But after sending the perfect patch to relevant discussion list you received something like that:

The patch seems to be OK. Can you remove trailing spaces, fix formatting, submit the patch in git format and add signed-off-by?

After reading it for the third time you knew that you had to learn more about how git works and why trailing spaces are bad.. I had the same problem some time ago. There are quite a few howtos, quick starts and tutorials for git, but nonetheless some information is hard to find, especially if you're not sure what you're looking for.
Let's start with "trailing spaces". If you're using a normal editor you might not even notice that there are some "trailing spaces" in your code. And at the end of the day, tha patch works, so why bother? A short example:

przemo@pldmachine /tmp$ touch test
przemo@pldmachine /tmp$ touch "test "
przemo@pldmachine /tmp$ ls -l
-rw-rr 1 przemo users 0 12-05 01:17 test
-rw-rr 1 przemo users 0 12-05 01:17 test
przemo@pldmachine /tmp$

How do you like having 2 "identical" files in the same directory? The same thing can happen in your code - trailing spaces can give false positives when comparing two files. Another example:

przemo@pldmachine /tmp$ diff -Nru test1 test2
--- test1 2010-12-05 14:20:11.282835872 +0000
+++ test2 2010-12-05 14:18:48.271759248 +0000
@@ -1 +1 @@
-This is a line of comment
+This is a line of comment
przemo@pldmachine /tmp$

Are those 2 lines the same or they are different? "Trailinig spaces" are bad!
A next issue is code formatting. On some projects there are very loose rules, on some, like linux kernel, rules are the strict. Anyway you shoud always know what are the rules for the project you're working on and adhere to them. If in doubt - ask. If you're not sure why code formatting is an important thing, try to find something in a piece of badly formatted php code - it's very, very hard.
The last part of the fix-your-code email was request for a git formatted patch. I presume you already have a git repository withthe project (git clone path-to-the-project) and you made the modifications to the code. A next step is to commit your modifications to the git repository:

git commit -a

"-a" switch tells git that you want to include all modified files to the repo. After issuing that command you'll see an editor window with some information about the changes you made. git is expecting you to type name for the commit in first line of the editor (a short description what your patch is). The second line should be empty and starting from 3rd line you should give detailed description how your patch works. The title of the patch and it's description may seem to be a silly idea for beginners - my patch works, I know how it works, so simple "Fix that annoying bug" comment should do. Let me say that I can bet that in six month time you will not know what was the bug, how the code works and if it was required at all! Another thing is that you're not working alone - the patch you made should be easy to read and to understand for the person responsible for the project. You should not expect that he or she is going to analyse your code without good explanation. Now the "signed-off-by". It's meaning can be different for different projects, but in generel it maens that the patch is complete, ready for review and that you agree to use it in the project. Adding "signed-off-by" is very easy. "-s" option does it for you:

git commit -a -s

If you already commited you changes to the repo you can use "--amend" option:

git commit --amend -s

This time git opens editor window, with your previous title of the patch and the description, but there is one new thing - below the last line of the description git adds an empty line and somethinglike this:

Signed-off-by: John Doe <>

Now we have the patch commited, with proper title, description and signed-off-by line. We want git to save the patch as a file:

git format-patch HEAD~1

The HEAD~1 part means the we want to generate patch for HEAD (it's the current state of the repo) minus one commit. You can also use HEAD~2 or HEAD~5 to generate more that just one patch. If you open the file that git just created and you'll see that it contains all the required information: title, description, signed-off-by and all the changes you made to the code.

Tuesday, November 9 2010

GpsMid icons or how to convert svg to png with ImageMagick

I'm working on a new set of icons for GpsMid. If you're curious how they look check here. The full set of svg and pngs and a sample GpsMid midlet is here. The pngs were created using"Export as bitmap" function in Inkscape, but now I found a better solution: ImageMagick. I started with simple:

convert i_about.svg i_about.png

but the generated icon was too small:

i_about.png 39x39

I wanted 100x100 pixels with transparent background. Next I tried: 

convert i_about.svg -extent 100x100 i_about.png

but again, the result was not good enough:


Adding -geometry helped a little bit:


The image is very fuzzy. To solve it we have to add -density option. 


Now it looks quite good except for the missing piece - a transparent background. "-background none" solves the last issue: 

convert -density 1000x1000 -background none i_about.svg -geometry 100x100 i_about.png 


This is my perfect ;-) icon for GpsMid!

Friday, November 5 2010

GpsMid now oficially using git repo

Project GpsMid has oficially moved from CVS to git. The git repo can be found here. If you want to test it type:

git clone git://

and enjoy!
I'm not sure how to do it under window$, so please convert to linux and then try it, if you're still a window$ user ;-) There is also a repo for OSM2GpsMid - essential if you're baking your own midlets with OSM maps.

Tuesday, November 2 2010

Yea, that's just another blog on the net...

I thought it will never happen - I don't need a blog. But a blog seems to be the easiest option to publish some information that are screaming to hit the net. Things related to GpsMid, git for beginers, linuxwacom, OpenStreetMap and other. More to come.. soon.