(1) Finding out how Cypress FreeRTOS Demo Code runs
I wanted to modify as little of the original files as possible. So I put my code around the demo code. This is how the code runs from the main.c until it reaches the demo code.
In main.c (aws_demos/application_code/main.c)
- Startup task is vApplicationDaemonTaskStartupHook()
- It calls DEMO_RUNNER_RunDemos().
- DEMO_RUNNER_RunDemos() will call DEMO_entryFUNCTION().
- DEMO_entryFUNCTION is defined as RunMqttDemo if CONFIG_MQTT_DEMO_ENABLED is defined.
- CONFIG_MQTT_DEMO_ENABLED is defined here.
(2) Modify to run my own code
I created my own app.c and app.h files with the startup function called RunMyApplication().
- I removed #define CONFIG_MQTT_DEMO_ENABLED
- And I added #define CONFIG_MY_APPLICATION
- I pointed to my own function RunMyApplication() by creating a new definition as follows...
(3) How to add TFT display library
I used reference from this blog post:
Right click on the project inside Project Explorer > ModusToolbox > Library Manager
Turn on these Libraries
- Board Utils > CY8CKIT-028-TFT
- PSoC 6 Middleware > emwin
In the Makefile, add this to COMPONENTS. To indicate we are using an OS and it is Non-TouchScreen.
In my RunMyApplication() function, I added these lines. To test the LED and the TFT display.
cyhal_gpio_init(CYBSP_USER_LED5, CYHAL_GPIO_DIR_OUTPUT, CYHAL_GPIO_DRIVE_STRONG, CYBSP_LED_STATE_ON); GUI_Init(); GUI_SetFont(GUI_FONT_32B_1); GUI_DispString("Hello World");
And now it looks like this
(4) How to add CapSense library
Do not add CapSense library. Leave capsense unchecked in the Library Manager. Because Cypress FreeRTOS already includes the CapSense library.
I created a new RTOS task and then initialised the CapSense using code from these examples.
One problem I faced is I cannot get the slider gesture to work (flick left / flick right). But I can get the slider position (value of 0 to 300) working perfectly.
This is a video of my progress for today. It shows the testing of CapSense, TFT display and WiFi working.