Showing posts with label qt. Show all posts
Showing posts with label qt. Show all posts

Thursday, July 30, 2015

Qml item state undefined

I'm working on a info screen application done in Qml that will be run on a Raspberry Pi. I'm doing the main coding on the desktop and everything runs well.

On the Pi I'm using a self build of Qt 5.4.2 and it worked very well, until yesterday that is. Suddenly I got no display of my info slides. Strange thing, it worked perfeclt fine before.

After a good bit of cursing I found that my Image didn't show, because for some odd reason the binding of

visible: root.state=='rotating'

was evaluated as false. Well, how the hell is that possible was the next question. And debug output of the state randomly said "undefined", eh ?? WTF!?

What I don't understand is how it suddenly crept up as I've used states before too in my app. Anyway, it turns out that it is a known bug (QTBUG-41649) in gcc-4.6 on arm that miss compiles a specific file in the Qml library.

 Fix applied and all seems well. I hope.

Thursday, November 13, 2014

Artwork loading added to libqiscp

Worked a bit on libqiscp today and added support for receiving and decoding artwork data the receiver might send. The decoding into a QImage works very well, but the next thing is to somehow get that transferred to the QtQuick side.

Artwork loaded trough ISCP


I imagine a QDeclarativeImageProvider would be the proper way, but the thing is I don't know really how to connect that into the dynamically created QtQuick ISCP object(s).
Any ideas ?

Friday, October 17, 2014

Raspberry Pi doing i2c LCD display in C++

I'm working on a Raspberry Pi project that needs to be running headless but still be able to communicate with the outside world in some way. We are currently using a simple Red (error), Yellow (waiting for something), Green (Ok) (+blinking) to inform the user of various conditions (you can see them in the picture).

For most features that seem to be ok, but we are thinking about having somekind of display for a bit more details. A cheap 16x1/16x2 display would work quite nicely I think.

Today inspiration hit me to look into that a bit more. I had a 16x1 LCD laying around and a PCF8574T i2c I/O-expander backpack. Wired it up to the Raspberry Pi and started to look for some (proper aka C++) code. No luck there. Just some silly python this and python that. meh.
Well, it works fine on the Arduino.. and that is C++.. hmm, let's port it to plain Linux i2c interface (well, ok, wiringPi i2c wrappers). And so I did.

Here you go:

Raspberry Pi controlling LCD display with i2c in C++

I will do a bit cleanup and then code will be up on github.

You can get LCDs and i2c backpacks from Amazon:

Wednesday, September 10, 2014

QtQuick friendly Onkyo ISCP remote protocol library

There are some ready made apps and code around, but none that was easy to plug into QtQuick or in library format so I scratched that itch myself for a change and wrote a simple library.

Still working on figuring out some of the more complicated commands like controlling network playback, but all the basic stuff is there. Will be in a git repo soonish.

Screenshot of test app below, UI is pure QML. (Yes it simple and ugly, it is a test app)

The ultimate ISCP commander!
And yes, this means there will be an application for Jolla and BlackBerry 10 in the near future.

Thursday, March 14, 2013

More QML Box2D progress and github

To start with, I pushed my enhanced version of the qml-box2d bindings to github.

It is based on Box2D 2.2.1 and adds more features:
Joint release/grab, WeldJoint, WheelJoint, FrictionJoint, Edge shape support, more properties and methods (gravityScale, getMass(), getInertia(), angularVelocity, etc) and Body fixture iteration.

Here are some videos showing usage of PulleyJoint and RopeJoin:

PulleyJoint


RopeJoint


Have fun! (oh, Qt 4.7 or 4.8 only!)

Friday, December 07, 2012

A look inside the BDP-150 Frimware, netflix_qt you say?

In my previous post, I showed the basic contents of the Pioneer BDP-150 firmware image.

Looking at the binwalk output listing we can easily find the boot loader, Linux kernel and a squashfs image.

461744     0x70BB0    uImage header, header size: 64 bytes, header CRC: 0x775F4C1C, created: Wed Oct 24 10:43:23 2012, image size: 1573204 bytes, Data Address: 0xDA00000, Entry Point: 0xDA00000, data CRC: 0x782925E7, OS: Linux, CPU: ARM, image type: OS Kernel Image, compression type: none, image name: 
479272     0x75028    gzip compressed data, from Unix, last modified: Wed Oct 24 10:38:55 2012, max compression
2574912    0x274A40   Squashfs filesystem, little endian, version 3.1, size: 59779047 bytes, 471 inodes, blocksize: 131072 bytes, created: Wed Oct 24 10:51:11 2012

Extract the filesystem image with dd, like so:

$ dd if=BDP-150_V01.05.bin of=sqfs.img bs=2574912 skip=1
23+1 records in
23+1 records out
60048084 bytes (60 MB) copied, 1.03521 s, 58.0 MB/s

Now you have a Squashfs image. You can mount it or extract the contents using unsquashfs, like so:

$ unsquashfs sqfs.img 
Parallel unsquashfs: Using 4 processors
726 inodes (1492 blocks) to write

[===================================================================================================================================================================================/] 1492/1492 100%
created 330 files
created 63 directories
created 78 symlinks
created 0 devices
created 0 fifos

Now you have the firmware extracted and you can start looking around. There are some interesting looking bits in there. For example the UI is built on DirectFB and there is a Netflix binary (/usr/local/bin/netflix_qt/netflix ) linked against Qt. Pretty silly of Netflix not to support desktop linux users...

Who knows, with some luck this might run on some other ARM based thingy ? Oh, right.. that is the next thing I'll try :)

Wednesday, December 05, 2012

Pioneer BDP-150 Blu-ray player, Linux Inside

I finally gave in and got myself a Blu-ray player. After much googling and comparing I decided on a Pioneer BDP-150 Player. Luckily I was tired and didn't go to the store directly and so got it even cheaper as they had it on sale, 99€ only.

One of the biggest plus in my book was that the device ARMv6 (mediatek) based, running Linux  2.6.27 kernel with a DirectFB and Qt. Firmware to play with here and available sources here.

binwalk:ing the firmware data file gives:

DECIMAL    HEX        DESCRIPTION
-------------------------------------------------------------------------------------------------------
67512      0x107B8    Mediatek bootloader
67897      0x10939    LZMA compressed data, properties: 0x80, dictionary size: 1073741824 bytes, uncompressed size: 196608 bytes
114580     0x1BF94    Mediatek bootloader
300220     0x494BC    JFFS2 filesystem data little endian, JFFS node length: 8195
417804     0x6600C    LZMA compressed data, properties: 0x90, dictionary size: 738197504 bytes, uncompressed size: 754973620 bytes
430796     0x692CC    JFFS2 filesystem (old) data little endian, JFFS node length: 344
441485     0x6BC8D    LZMA compressed data, properties: 0x5D, dictionary size: 1036255232 bytes, uncompressed size: 327678 bytes
447129     0x6D299    LZMA compressed data, properties: 0x02, dictionary size: 8388608 bytes, uncompressed size: 1073741824 bytes
447153     0x6D2B1    LZMA compressed data, properties: 0x02, dictionary size: 8388608 bytes, uncompressed size: 1073741824 bytes
447177     0x6D2C9    LZMA compressed data, properties: 0x02, dictionary size: 8388608 bytes, uncompressed size: 1073741824 bytes
450404     0x6DF64    LZMA compressed data, properties: 0x80, dictionary size: 1660944384 bytes, uncompressed size: 521134 bytes
461744     0x70BB0    uImage header, header size: 64 bytes, header CRC: 0x775F4C1C, created: Wed Oct 24 10:43:23 2012, image size: 1573204 bytes, Data Address: 0xDA00000, Entry Point: 0xDA00000, data CRC: 0x782925E7, OS: Linux, CPU: ARM, image type: OS Kernel Image, compression type: none, image name: 
479272     0x75028    gzip compressed data, from Unix, last modified: Wed Oct 24 10:38:55 2012, max compression
2574912    0x274A40   Squashfs filesystem, little endian, version 3.1, size: 59779047 bytes, 471 inodes, blocksize: 131072 bytes, created: Wed Oct 24 10:51:11 2012
33020448   0x1F7DA20  JFFS2 filesystem data big endian, JFFS node length: 503796
35336806   0x21B3266  PNG image, 91 x 88, 8-bit/color RGBA, non-interlaced
35439823   0x21CC4CF  PNG image, 97 x 88, 8-bit/color RGBA, non-interlaced
35516856   0x21DF1B8  PNG image, 168 x 161, 8-bit/color RGBA, non-interlaced
52281361   0x31DC011  gzip compressed data, has CRC, was "\031\202\273\253M\021\334\335\276\207\340\356\1771\014@\356\376\013{\023r\367}t\027\271;\005k\026\271\273\027R\034r\367\351\011\202\273\237`\211\221\273\267`\035#w7B\227\220\273\327\025\027\334}\003", last modified: Thu Sep  6 02:46:23 2029
62487104   0x3B97A40  PNG image, 1920 x 1080, 8-bit/color RGB, non-interlaced

Tuesday, November 27, 2012

Drawing lines in QML

QML is very nice way to build stuff, but it does lack some features that has bugged at least myself quite a lot. There is no Line element for drawing arbitrary lines from point x1,y1 to x2,y2.

Fortunately there is the Rectangle element. And what is a rectangle with a height of 1 ? More or less a line. Rectangles can be set to be at x1,y1 and you can specify the rotation. And that gives us a line from x1,y1 with a rotation. And digging deep in your brain for some basic math gives us a line drawing algorithm.

Just calculate the length from x1,y1 to x2,y2 and that gives us the width of the rectangle. Then calculate the slope and we have the rotation we need.


And here you have a Line element ready to go for your QtQuick project, free to use so enjoy!
(Note: This is a workaround for having no canvas like element in Qt 4.7/8, if you are using Qt 5 then you can use the Canvas)

import QtQuick 1.1

Rectangle {
    id: l
    property alias x1: l.x
    property alias y1: l.y

    property real x2: l.x
    property real y2: l.y

    color: "black"
    height: 2
    smooth: true;

    transformOrigin: Item.TopLeft;

    width: getWidth(x1,y1,x2,y2);
    rotation: getSlope(x1,y1,x2,y2);

    function getWidth(sx1,sy1,sx2,sy2)
    {
        var w=Math.sqrt(Math.pow((sx2-sx1),2)+Math.pow((sy2-sy1),2));
        console.debug("W: "+w);
        return w;
    }

    function getSlope(sx1,sy1,sx2,sy2)
    {
        var a,m,d;
        var b=sx2-sx1;
        if (b===0)
            return 0;
        a=sy2-sy1;
        m=a/b;
        d=Math.atan(m)*180/Math.PI;

        console.debug(a)
        console.debug(b)

        if (a<0 a="" b="" d="" else="" if="" return="">=0 && b>=0)
            return d;
        else if (a<0 b="">=0)
            return d;
        else if (a>=0 && b<0 0="" d="" else="" pre="" return="">

Tuesday, November 20, 2012

Retro pinball, game prototype and qml box2d demo

Something I'm working on, not that special, but kinda fun still. Uses my improved Box2D QML plugin, otherwise it is pure QML only (for now).


Wednesday, August 08, 2012

OpenStreetMap Maps with QML Map object

QtQuick/QML comes with a nice ready made Map element that can show map tiles and dots and polygons and stuff. Really nice and all, unfortunately the default and only map available is Nokia maps. And well, I prefer free maps. So, how to get OpenStreetMap working ?

One option is to make your own QML based map element, I started on that but never had enough patience to finish it.

But after some googling around I found qtm-geoservices-extras ! Today I started to look into it a bit more and trying to figure out how to get in working when targeting the N9 as we have the silly problem that anything submitted to the Nokia Store can not depend on any outside packages. Extremely annoying that.

The extra geoservices contain Qt plugins for providing map (and route, search, etc) features from OSM and Google. I didn't care of the goolge plugin at all.

So how to get the plugin working when you make your own app ?

Adding OpenStreetMap Qt map provider to your app


QML Map with OpenStreetMap tiles, running on the simulator


First, checkout qtm-geoservices-extras
git clone git://gitorious.org/qtm-geoservices-extras/qtm-geoservices-extras.git

Then copy the openstreetmap directory into your own project

cp -a qtm-geoservices-extras/openstreetmap your-map-app/

The edit your projects .pro file to include:
include(openstreetmap/openstreetmap.pro)

And in your main.cpp (or whatever), add:

#include <qtplugin>
Q_IMPORT_PLUGIN(qtgeoservices_osm)
Then edit the openstreetmap.pro file in the openstreetmap directory, like this:
  1. Add static to CONFIG
  2. Remove or comment out the include(../common.pri)
  3. Remove or comment out TARGET=
  4. Remove or comment out TEMPLATE=
  5. Add 
    INCLUDEPATH += $$PWD
    DEPENDPATH += $$PWD
End result should look something like this:

#TEMPLATE = lib
CONFIG += plugin
#TARGET = $$qtLibraryTarget(qtgeoservices_osm)
PLUGIN_TYPE=geoservices
# include(../common.pri)
QT += network
CONFIG += mobility static
MOBILITY = location
INCLUDEPATH += $$PWD
DEPENDPATH += $$PWD

Then add the map element to your QML code

import QtMobility.location 1.2

    Map {
        id: nmap
        width: 480;
        height: 300;
        anchors.top: osm.bottom;
        zoomLevel: 10
        center: mypos;
        connectivityMode: Map.OfflineMode;
        plugin : Plugin {
                name : "openstreetmap"
                PluginParameter{ name:  "mapping.cache.directory" ; value: "/tmp/qtmap" }
                PluginParameter{ name:  "mapping.cache.size" ; value: "200000" }
            }
    }

    Coordinate {
        id: mypos
        latitude: 60.45;
        longitude: 22.25;
    }

And that should do it. Build your app and try it out!

Tuesday, December 27, 2011

Qt and QtQuick/QML resources for N9/N950 development

Finding documentation and other resources for N9 (and N950) development is not hard, but it's a bit too spread around. Generic Qt information can be found on the Nokia Qt site, then N9 specific stuff are in another place. Then there are at least 3 forums to follow.

I started writing this some time ago already, I was going to write some more later when I had time but this post is more or less what I was about to write. So there, go read it.

Sunday, November 13, 2011

Qt SDK upgrade

So there is an update for the SDK now. Should I just do it ? I've had too many problems with previous upgrades that I'm just a tiny bit skeptical that it-will-just-work.

Monday, October 17, 2011

QML DatePicker giving a headache ?

More as a note-to-self but maybe someone else has the same problem. I was trying out the QML DatePicker from com.nokia.extras and it just didn't like to work in the Simulator. After some random clicking around I found the solution, make sure you have selected "Harmattan" as the com.nokia.extras platform in the Simulators "Application" configuration tab.

Friday, October 07, 2011

Qt SDK install problems

I've installed the Qt SDK many months ago, kept it updated and so on but never really got motivated enough to start trying out anything more than looking at the examples and tutorials.

Finally got motivated to trying out some QML and everything was broken. Missing files, simulator didn't do anything just got stuck.

For example this (and I'm not alone with this, see comments here):
module “Qt.labs.components” is not installed 

Re-installed using off-line installer, that didn't work, even after installing everything for Harmattan available in the maintenance tool the simulator didn't have an entry for the N9. So after a rm -rf ~/QtSDK and re-install using the on-line installer I finally got it working.

The strange thing was that everything works perfectly on my home computer, 64-bit and using own linux distro. All problems was on my work Ubuntu laptop.

Anyway, now I'm able to do my first proper QML app, more on that later, stay tuned.