Yes, the current limit is 16 functions in a DUELink script. That’s what the documentation states, and I verified it. While 16 is true, it’s not entirely accurate.
To better understand developing standalone scripts for a DUELink module, I decided to port a Raspberry Pi Pico application I had developed to a DUELink module.
I started by setting up the application structure, including a substantial number of functions, keeping the 16-function limit in mind. After correcting some syntax errors and running the application, I immediately encountered a “Too many functions” error message.
“Too many?” I carefully counted the methods and found only nine. Why the “too many functions” error?
I won’t delve into the details of how I discovered the cause of this message, but let’s get to the point.
The internal engine of a DUELink module has two regions for code: a driver region and a user region. While I hadn’t given it much thought, I had assumed that the driver region was entirely separate from the user region. This assumption was incorrect. The 16-function limitation is a combination of driver and user functions. For instance, the TFT N18 display module driver has nine functions, leaving seven available for a user script.
What should I do if I need more than the available function count on a module with the drivers installed?
At this point, I see two options: I can refactor my program to reduce the number of functions or reload the firmware without the drivers.
Operating with a reduced number of functions might result in repeating code snippets, which could potentially improve performance. So, it might be something I have to do anyway.
If the drivers are not loaded, I can copy the necessary code from the drivers into my script. The copied code is likely related to hardware initialization.
At this point, I’m not sure what I’ll do.
Here are some things for the community to consider:
-
How important is it to write scripts with up to 16 functions?
-
Should GHI increase the maximum number of functions, assuming this is technically feasible?
-
Should GHI review the current drivers and consider eliminating optional functions?
Please let me know your thoughts.