Making Raspberry Pi Gauges - The Blog

Non-repair car talk
Adam
Posts: 2273
Joined: Wed Oct 23, 2013 9:50 pm

Re: Making Raspberry Pi Gauges - The Blog

Post by Adam »

Adam wrote:
Adam wrote:
billgiacheri wrote:I just don't have a clue as to how to create Qt objects in Python, or what IDE to use.
Qt Creator should have plugins for PyQt. See code sample here: https://en.wikipedia.org/wiki/PyQt for initializing a Qt object in python.
You can also use Qt designer with Python. Its mode GUI-focused, but has code editing tools as well.
Creator:
http://www.qt.io/ide/

You should be able to get it on the Pi too through the normal Ubuntu channels if that is where you are doing your development.

Code: Select all

sudo apt-get install qtcreator
bill25
Posts: 2583
Joined: Thu Oct 31, 2013 2:20 pm

Re: Making Raspberry Pi Gauges - The Blog

Post by bill25 »

As of now, I am using my Windows 8 laptop to download and try stuff because the pi is ridiculously slow. I also have a small keyboard w/touch pad for the pi that sucks to do any real typing on. My pi only has 2 usb ports and the wifi port takes one of them...

I have Qt Creator, which seems good for QML, Qt, and C++. Python seems like an after thought... I will try to import my PyQt stuff into that. As of now I am using Python IDLE, which sucks for auto generating code options. I was able to get a Pythin GUI app to open the QML Gauges.

The main thing I am working on now is decoding the pyobd code to only read values I care about, removing the crappy squares with paged data (an array of 6 parameters at a time), and to append those values to the Python/Qt GUI. My biggest problem right now is trying to set the "currentValue" parameter of the QML gauges with Python. I just don't know how to access the QML parameters yet to modify them. I was happy to actually get the QML to load from Python today though.

Here is the code for that (main.qml is the primary QML file for the Gauges). This is pretty straight forward, knowing what version of Python and PyQT are compatible, and installing in the correct order to get everything working was more of a challenge... I used Python 3.4, 32 bit, because supposedly 64 bit isn't compatible with PyQt5 which is what I am using.

Code: Select all

import sys
from PyQt5.QtCore import QUrl, QObject
from PyQt5.QtWidgets import QApplication
from PyQt5.QtQuick import QQuickView

from PyQt5.QtGui import QGuiApplication
from PyQt5.QtQml import QQmlApplicationEngine


# Main Function
if __name__ == '__main__':
    # Create main app
    
    myApp = QGuiApplication(sys.argv)
    engine = QQmlApplicationEngine(QUrl("main.qml"))
    window = engine.rootObjects()[0]

    
    window.show()

    sys.exit(myApp.exec_())

    # Execute the Application and Exit
    myApp.exec_()
    sys.exit()


bill25
Posts: 2583
Joined: Thu Oct 31, 2013 2:20 pm

Re: Making Raspberry Pi Gauges - The Blog

Post by bill25 »

billgiacheri wrote:As of now, I am using my Windows 8 laptop to download and try stuff because the pi is ridiculously slow. I also have a small keyboard w/touch pad for the pi that sucks to do any real typing on. My pi only has 2 usb ports and the wifi port takes one of them...

I have Qt Creator, which seems good for QML, Qt, and C++. Python seems like an after thought... I will try to import my PyQt stuff into that. As of now I am using Python IDLE, which sucks for auto generating code options. I was able to get a Python GUI app to open the QML Gauges.

The main thing I am working on now is decoding the pyobd code to only read values I care about, removing the crappy squares with paged data (an array of 6 parameters at a time), and to append those values to the Python/Qt GUI. My biggest problem right now is trying to set the "currentValue" parameter of the QML gauges with Python. I just don't know how to access the QML parameters yet to modify them. I was happy to actually get the QML to load from Python today though.

Here is the code for that (main.qml is the primary QML file for the Gauges). This is pretty straight forward, knowing what version of Python and PyQT are compatible, and installing in the correct order to get everything working was more of a challenge... I used Python 3.4, 32 bit, because supposedly 64 bit isn't compatible with PyQt5 which is what I am using.

Code: Select all

import sys
from PyQt5.QtCore import QUrl, QObject
from PyQt5.QtWidgets import QApplication
from PyQt5.QtQuick import QQuickView

from PyQt5.QtGui import QGuiApplication
from PyQt5.QtQml import QQmlApplicationEngine


# Main Function
if __name__ == '__main__':
    # Create main app
    
    myApp = QGuiApplication(sys.argv)
    engine = QQmlApplicationEngine(QUrl("main.qml"))
    window = engine.rootObjects()[0]

    
    window.show()

    sys.exit(myApp.exec_())

    # Execute the Application and Exit
    myApp.exec_()
    sys.exit()


bill25
Posts: 2583
Joined: Thu Oct 31, 2013 2:20 pm

Re: Making Raspberry Pi Gauges - The Blog

Post by bill25 »

I got the python script to pass values to the QML function, and can successfully drive the gauges from Python. That is a big step forward.

Now, a big step backward: Qt is not officially compatible on the Pi 1 B, which is what I have. It is compatible with the Pi 2. I read multiple forums and found that there was a QtonPi project, but almost all of the download links are broken. I found that it would take 2 days to download and compile various things required. The real problem is that the project basically looks like it was stopped due to the poor performance of Qt on the Pi 1.
Compatibility Link: http://doc.qt.io/QtForDeviceCreation/qt ... forms.html
Also, Downloads: http://www.qt.io/download-open-source/#section-2

I have determined that trying to get Qt installed on the Pi 1 is a waste of time because if it is going to run like crap, I really don't care if it is "possible" to install it.

I have ordered a Pi 2 to continue this project.

The Pi 2 is a quad core processor instead of my singe core, and has double the RAM (1 Gig) and double the USB ports (4). This should make it a lot easier to use and program since I can now use a real mouse and keyboard instead of my little all in one with rubber keys and touchpad for a mouse.

The other good thing about the Pi 2 is that you can get Windows 10 IoT OS for it, and hopefully, I can watch Netflix and my IP camera on it now. My current setup with the Qt gauges is also in Windows 10 so hopefully the setup is similar.
Last edited by bill25 on Tue Aug 25, 2015 6:38 am, edited 1 time in total.
bill25
Posts: 2583
Joined: Thu Oct 31, 2013 2:20 pm

Re: Making Raspberry Pi Gauges - The Blog

Post by bill25 »

Well this could be a problem if I thought I would add Qt to Windows 10 IoT Core:
Windows IoT Core is a light version of the operating system and doesn’t include a windowed interface or desktop experience. Instead, it’s meant for developers to make their own apps using Windows as a backbone.
It also says:
For developers, this should make it a little easier to distribute and share your projects, though you will need a computer running the full version of Windows 10 alongside Visual Studio 2015 to use it
Maybe I will stick to Linux as the OS on the Pi...

Kinda weird that it doesn't support VS 2013, there is a Qt DL for that: http://www.qt.io/download-open-source/#section-2
Adam
Posts: 2273
Joined: Wed Oct 23, 2013 9:50 pm

Re: Making Raspberry Pi Gauges - The Blog

Post by Adam »

billgiacheri wrote: Kinda weird that it doesn't support VS 2013, there is a Qt DL for that: http://www.qt.io/download-open-source/#section-2
You mean on the Pi? Or PyQt bindings?

Also:
http://www.element14.com/community/comm ... ui-display

Short story: no desktop, but one "modern" application can drive the display and you can interact with it through USB peripherals, if attached.
bill25
Posts: 2583
Joined: Thu Oct 31, 2013 2:20 pm

Re: Making Raspberry Pi Gauges - The Blog

Post by bill25 »

I think I need to download Windows 10 for the Pi 2 to see what it really supports. I have a copy of VS 2013, and could probably do all of this development in that since there are modules for Python and Qt for it. The link I referenced states that you need a full Windows 10 running VS 2015 to develop for the Pi Windows 10 Apps. Not sure if that is true. Are VS 2013 Apps really not compatible with Win 10 IoT? Sounds weird.

If it is, I would have to get VS 2015, and integrate Python and Qt, which probably wouldn't be bad, but I am not looking to pay a monthly fee for VS 2015. I haven't looked at their pricing options for that yet.

Buying VS 2015 just to make an app for the Win 10 IoT OS is kind of a deal breaker when I currently have this thing running just by typing python.exe and the .py file from the command line. I could just put this in startup for windows or Linux and be done without having to buy anything.

I guess the next steps are to determine if I can get VS2015 for free for personal use, and if not, once the Pi 2 comes in, I can try to install Qt on the Debian build. Qt specifically states that they support development on the Pi 2 so that shouldn't be a problem.
Adam
Posts: 2273
Joined: Wed Oct 23, 2013 9:50 pm

Re: Making Raspberry Pi Gauges - The Blog

Post by Adam »

bill25
Posts: 2583
Joined: Thu Oct 31, 2013 2:20 pm

Re: Making Raspberry Pi Gauges - The Blog

Post by bill25 »

That looks like a possibility. I have to look into it more. There is a free Community version also, which looks like I could use that as long as I don't plan on selling the app. I guess with Express you can sell the app, so that might be the way to go. I looked at the site really quickly and didn't really get a good feel for hat comes "free".

This could be an interesting turn of events if I end up having the Pi run Windows 10 to display the gauges.
Adam
Posts: 2273
Joined: Wed Oct 23, 2013 9:50 pm

Re: Making Raspberry Pi Gauges - The Blog

Post by Adam »

The free version is also free for commercial use if you are a small-time developer. There is some employee or app-publishing limit to qualify.

I would say try all the platforms/tools and pick what to deploy based on what is the easiest for you to setup/develop/maintain. Worry about licensing later.
Post Reply