Lamp
ODROID-Magazine-201509
ODROID-Magazine-201509
- No tags were found...
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
QT5<br />
Figure 5 - Changing the text element to “Blinky for ODROID”<br />
Figure 7 - Adding the QGPIO class to the project<br />
bar, then choose Qt Quick Application. Next, give the project<br />
a name and choose the directory, and configure the Qt5 project<br />
using the “Desktop” kit.<br />
Continue through the dialogs until the project is created.<br />
Then, under the projects dock on the left, navigate and open<br />
Resources -> qml.qrc-> / -> main.qml. After opening the file,<br />
change the text inside the Text element to from “Hello World”<br />
to “Blinky For ODROID”. Then, build and run the project<br />
by pressing Ctrl + R. After clicking the application to close it,<br />
open a terminal and navigate to the projects directory. At the<br />
top of the project directory, run the following command in<br />
order to clone the QGPIO class:<br />
$ git clone http://github.com/Tpimp/qgpio.git<br />
Figure 8 - Modifying the QGPIO class<br />
the C++, create a QGpio element and set the ID to gpio200<br />
and the number to “200”. Next, create the function callback<br />
that will be invoked when the component is complete. In the<br />
function, set the GPIO direction to Out, set the edge to Falling,<br />
set active_low to false, and the value to false. Then, in the<br />
MouseArea object, replace the onClicked function statements<br />
to simple toggle the GPIO value:<br />
gpio200.value = !gpio200.value;<br />
Figure 6 - Cloning the QGPIO project<br />
Go back to the QtCreator application and right-click<br />
“blinky-ODROID” in the project dock, select “Add Existing<br />
Directory…” from the context menu, then choose the directories<br />
as shown in Figure 7. After adding the directory from the<br />
projects dock, navigate and open Sources -> main.cpp. Alter<br />
it to look like Figure 8. Note that this step is related to using<br />
QGPIO, not writing a general Qt5 application.<br />
Next, we can make the “Blinky” part of the application. Reopen<br />
the main.qml file for editing.<br />
After importing the com.embedded.io module defined in<br />
Figure 9 - Modifying the main.qml file<br />
Run the program and click on the center, then observe the<br />
value of GPIO 200 changing by typing the following command<br />
into a Terminal window:<br />
ODROID MAGAZINE 29