Python library for Raspberry PI for Ultimate GPS based on MTK3339 with serial interface as sold by Adafruit

Python library for Raspberry PI for Ultimate GPS based on MTK3339 with serial interface as sold by Adafruit. The library helps to set different chip parameters in a sane way. Currently supports minimum functional set of commands:

CMD_HOT_START – hot_start()

CMD_WARM_START – warm_start()

CMD_COLD_START – cold_start()

CMD_FULL_COLD_START – cold_reset()

SET_NMEA_UPDATERATE – set_nmea_update_rate()

SET_NMEA_BAUDRATE – set_baudrate()

API_SET_FIX_CTL – set_fix_update_rate()

API_SET_NMEA_OUTPUT – set_nmea_output()

SET_NAV_SPEED_TRESHOLD – set_nav_speed_threshold()

All functions are preforming basic range check to make sure values are accepted by MTK3339 as there is no check if a call was successful or not.

Example usage:

import mkt3339

gps = mt3339(“/dev/ttyAMA0”)






gps.set_nmea_output(gll = 0, rmc = 1, vtg = 0, gga = 5, gsa = 5, gsv = 5)

That library is part of Open Cycling Computer project


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.



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 suggested 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


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:

Schematic (png):

That entry is the first part of Open Cycling Computer project

BMP183 at Adafruit

All files on gitlab

BMP183 datasheet


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:


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 GitLab.

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 until 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 GitLab or przemo (at) firszt (dot) eu


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.


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:


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:


i4oled – bluetooth support

4oled 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