Deutsch

Implement multi-level menu switching with minimal code? A Deep Dive into the Development of the TSD-TSS013004A
Nov 14 , 2025

Low-Cost Rotary Knob Display from Team Source Display

  • Reposted from AI Diantang, part2

 

In this article, we'll delve deeper into building a 2D carousel. By creating multiple functional pages and writing a simple switch statement in the menu interface, we'll utilize TouchGFX's actions, interactions, and custom functions to construct a secondary menu with minimal code

 

TouchGFX Action Basics

Reference link: https://support.touchgfx.com/docs/development/ui-development/touchgfx-engine-features/custom-triggers-and-actions#custom-actions In short, when you want an interaction to be triggered in code, you can try creating an action for it. An action can both be a trigger for an interaction and be triggered by an interaction.

 

In this project, we use the action as the trigger for the interaction, making it triggerable in code. Then, we forward the trigger signal to the TouchGFX base, triggering the screen switching interaction, indirectly achieving screen switching triggered in code.

Let's use the previous project first:

Create two actions in the menu interface, corresponding to the two menu elements we designed. Then, go to the interaction tab on the right and create an interaction that connects the two screen switching elements (the functional pages need to be created beforehand).

 

At this point, we have completed the creation of the interface portion based on actions and interactions.

 

Carousel Element Positioning and API Integration

When we interact with a menu control, the menu itself needs to know which element is selected so that clicking it can determine which page it points to based on the label written in the UI. We must clarify this before calling the API we've built.

In TouchGFX, the menu control already integrates a function `scrollWheel1.getSelectedItem()` specifically for retrieving the selected element. However, we need to assign this data to other files in the application layer so that the program understands which sub-demo is being selected.

 

Therefore, we use `Model.cpp`, where we add data transfer functionality.

This successfully connects the scrollWheel menu to our application.

 

So, how do we interface the transmitted data with our API? Essentially, we call our action directly as a function. For simplicity, we just transmitted the selected element as "DemoNumber," allowing us to directly write a switch statement with several case statements to invoke the corresponding screen-switching functionality. This is basic C language knowledge.

 

As you can see, because the TouchGFX library is very comprehensive, we don't actually need to write much code to implement the functionality.

 

Compile, flash, and see the results, click below link to check more performance of our Rotary knob display module:

https://www.youtube.com/watch?v=WnhW_CznyXY

 

  •  
Holen Sie Sich Ein Angebot
Holen Sie Sich Ein Angebot
Wenn Sie an unseren Produkten interessiert sind und mehr details wissen wollen,bitte hier eine Nachricht hinterlassen,wir Antworten Ihnen so schnell wie wir können.

Startseite

Produkte

Über

Kontakt