Python Command Wrapper

GTT TFT Support

Moderator: Mods

Post Reply
nasax
LCD?
Posts: 1
Joined: Thu Aug 01, 2019 4:13 pm

Python Command Wrapper

Post by nasax » Thu Aug 01, 2019 5:15 pm

Hi, everyone as part of a project involving a GTT50A I wrote a python command wrapper for a number of the GTT50A commands.

In the hopes of saving a few other people some heartache I'm going to upload part of my project code base, including most of the GTT Designer portion and the classes for interfacing with the screen. A short demo code is also given in the main method.

This code was designed to do real-time display updates to the screen and quickly update the plotting for a given application. The plotting is a polar plot that corresponds to directional unit vectors. A short parameter file is also provided for the demo.

My software stack is as follows:

The GUI was designed on Windows 10 Home Premium 64-bit and connected to the first USB on the Matrix Orbital board. The backend python code was designed, tested and written on Fedora 29 using Anaconda-Python 3.6 that was run as a root user. The code has also been tested on Ubuntu 18. To run the code make sure you connect to the 2nd USB port the mass serial usb I believe and verify that the line:

"self.connect = serial.Serial('/dev/ttyUSB0',115200,timeout=t)" corresponds to the correct USB device. The 0 after 'USB' might be a 1 or 2 depending on the usb you are using.

Here are some other useful python resources:

https://www.matrixorbital.ca/simple-python-appnote
viewtopic.php?t=4471

Other Notes:

I deleted a few image files that I was not using from the assets folder to get under the file size limit since the original project was too big.

I was unable to connect to the usb mass serial port on Windows 10 but this maybe different since the tech that I asked about this was able to do so on Windows 10 Professional.

The sleep times are a little finicky and occasionally yield non-ideal behavior.

point_data.txt and the python code should be in the same folder. If you want to change the folder layout then append the file path in readFile.

Program Synopsis:

The documentation is relatively sparse but the code should be fairly straight forward to use. Each of the buttons on the screen sends a different value or in this state to Customer Data which is constantly prompted by my program for inputs.

When I see that a user has selected a menu option the code then either runs the plotting routine or writes text from the text file to the screen on the Log page.

The array configuration allows the user to define and reset an array of numbers to be fed back into the main program.

The runRoutine and Main method act as a demo to test the interface code.

Other Notes:

I received some technical support from Matrix Orbital regarding the display. Some things like changing the font size were much easier to do using the GTT Designer App than in the python code so I opted for them there.

There are about 25 individual scripts that the Display is running for all the buttons and menu options, so the python code is not doing everything.

If there is a lot of interest in this, I can update my code with more notes and comments.

P.S

Forgive my unprofessional code I'm an engineer.
Attachments
GTT Open Source with Python.tar
(11.19 MiB) Downloaded 19 times
point_data.txt
(13.81 KiB) Downloaded 23 times

robertg
LCD?
Posts: 1
Joined: Tue Aug 13, 2019 9:13 pm

Re: Python Command Wrapper

Post by robertg » Tue Aug 13, 2019 9:32 pm

Big thanks!

Had me stumped why my code that worked perfectly in python 2 didn't work in python 3.
IE to clear a matrix orbial screen this worked for a clear screen.
def ClearScreen(self):
clearscreen = [chr(254), chr(88)]
try:
for i in clearscreen:
self.portdisplay.write(i)
except:
pass
Tried all sorts of variations using encode() until I looked at your code tweaked it and it works! whoo hoo!
def ClearScreen(self):
try:
self.portdisplay.write([254,88])
except:
pass

Now the next step is to understand why it's friggen changed!!!!!

Daniel Divino
Matrix Orbital
Matrix Orbital
Posts: 247
Joined: Thu Sep 24, 2015 9:38 am

Re: Python Command Wrapper

Post by Daniel Divino » Mon Aug 19, 2019 4:30 pm

Hey nasax,

Wow, that's quite the wrapper. We really appreciate all of the work you've done and I'm sure plenty of people with find your wrapper very useful in their product development.

Thanks again,
Daniel
Daniel Divino
Technical Support
Matrix Orbital

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest