I needed a considerable amount of time moving from the application skeleton described in Super Smart Home #12 PSoC6 Local Node: Application Skeleton to the first beta version of the PSoC6 Pioneer Kit. The reason is due that I have studied in depth the features of the emWin GUI library (provided by Segger) integrating the logic into the pages view and showing a continuous update when on the right page.
Before seeing in depth how I have implemented this first version of the software, as well as designing the graphic interface, take a look at the video below showing the noise level monitoring page.
So with this version showing the noise level sensor page together with the application main page I have set most of the logic to implement the other sensors and activities of the PSoC6 node.
The Software Business Logic
Developed with Mbed OS the main architecture of the software is similar to most of the microcontrollers software design, including the well-known Arduino sketch; it includes a setup part where the interrupts and the other components are initialized and a loop section. In the loop section, I have implemented a series of interrupt-driven calls so depending on the selected page on the UI the real-time visual monitoring is updated accordingly. There are three levels of priority, corresponding to the three different states, plus a fourth remote low priority level )not yet implemented) that updates periodically the AWS IoT console through shadows.
The Loop Process
During every loop cycle, the sensor's data structure (comprises all the information from the sensors connected to the node) are acquired and updated. Based on a timing check the lowest priority activity, sending data to the AWS IoT console is executed.
Inside the loop when a meaningful change on the sensors – for example, a new package of audio samples is available – it triggered by the highest priority interrupt. Data are collected in a global struct that is used both for sending data to the AWS IoT console (split in the different shadows) and used to eventually update the monitoring page.
When one of the monitoring pages is shown on the TFT screen only the relevant data for this specific visualization is used.
In addition, a lower priority interrupt is driven by the Capsense buttons to scroll between the available pages. When the program starts the main logo page (no activity is shown on it) is displayed. When the user press one of the two Capsense buttons the next page is shown on the TFT screen and every loop cycle the corresponding monitored data are updated.