Interface and Application Programming

Group Assignment
This week for the group assignment we were told to try out and check out another UI creator. For the group assignment I decided to try out Qt for the group assignment while my teamates summarized and tried out stuff can be check out her page HERE.

My experience with Qt was quite straighforward since I have a lot of experience in C++. THe first thing was to get a blank QT file and work from the project file. The project file is QTs version of cmake, so in it I added the needed libraries to compile, set the version of QT, and indicated that I would be making what is known as a widget. I then added a C++ source and made it main.cpp . I then made a main function which takes in an int and character pointer. I then made an object of tupe QApplication called app taking in the two arguemnts from main. It then returns the output of the method exec from the object app. Following I tried running and compiling it and worked, but it showed nothign since there still are no widgets. I followed up by importing QLabel and making a pointer to an object of type Qlabel called label. The constructor takes in one argument being the text that will appear on the label, in this case I put "Hello World". I then could run the code again and get an application to open with the text Hello World. Following I made addeda title to the window with a method under label and called the window Fab Project. Finally I added ran the resize method to resize the window and ran the code one final time.

Though what I made was relatively simply the work to make it is far more complicated than using Tkinter which is a far simpler alternative. I will use Tkinter in this project to make a GUI to communicate with my two I2C boards making nice buttons to get their responces. It has come to my attention now that it says this must be done with an input or output device and due tot he vagueness of the terminology I am counting the I2C message as an output device. If this is not satisfactory for my final project I have a full GUI that displays information from multiple sensors along the time also made in TKinter.
Making Qt Widget
Qt Homepage
Qt Make File


Main File
Hello World
Final Application
Individual Project
For my individual project this week I decided to make an interface for a pair of I2C boards that I used back in networking week. For this interface I used TKinter a Python library that is far simpler to use than Qt and one that I had used briefly in the past. Since I was communicating via I2C I did the whole set up from my Pi. I used pip to install the Tkinter library and I already had SMbus set up. Fortunately I also already had a function made from my network week that would take as an input the slaves address and return the message including the proper buffer of the message.

This meant all I had to do was make the UI and buttons and I can just link the buttons to the functions I wrote beforehand with the proper inputs for their slave device. First I imported all the libraries I would need: tkinter,sys, time, and smbus. I first made a variable of time smbus with argument 1 indicating the first set of I2C ports on the Pi. I then made two variables for the slave address of both devices. I Then made a variable of type tk to hold the information of my UI. I then used methods of the instance to set a title to to the UI and not make it resizable. I then made two near identical instances of buttons using the button method in the tk instance and set their colors, size, and what command would happen when they are pressed which I input functions that would call the function I made in the I2C week to message the board and ask what they're name is and it would then create an instance of message box from the tkinter library creating a pop up which would then say Hi then the name returned from the attiny over I2C. All that was left was to run the pack method for both buttons to line them up on the UI then run the mainloop method of the tkinter variable to keep the gui running till closed.
Slave Code
Wiring
Tkinter in Nano


Application
Hi Frank
Hi Steve



Click Here to Download all the files from these projects!