Custom Code: Difference between revisions

From Visuino
Jump to navigation Jump to search
Created page with "Image:TArduinoCustomCode.png == Summary == Custom code component allowing direct C/C++ code integration with multiple data type support for input and output operations. == Description == The Custom Code component provides a flexible interface for embedding custom C/C++ code within visual programming environments. It supports multiple data types including analog, digital, complex arrays, images, audio, and specialized types like color and orientation data. The compo..."
 
No edit summary
 
(4 intermediate revisions by the same user not shown)
Line 2: Line 2:


== Summary ==
== Summary ==
Custom code component allowing direct C/C++ code integration with multiple data type support for input and output operations.
The '''Custom Code''' component in '''Visuino Professional''' lets you inject arbitrary C/C++/Arduino code directly into your visual program. 
It removes the limitations of built-in components and allows integration of unsupported sensors, libraries, hardware modules, or protocols — providing nearly unlimited flexibility in what can be created.


== Description ==
== Description ==
The Custom Code component provides a flexible interface for embedding custom C/C++ code within visual programming environments. It supports multiple data types including analog, digital, complex arrays, images, audio, and specialized types like color and orientation data. The component includes hooks for initialization, execution, hardware updates, and supports external libraries and global declarations for complex custom implementations.
The '''Custom Code''' component is one of the most powerful features of ''Visuino Professional''. 
It is designed to fill gaps whenever a sensor, module, protocol, or function is not natively supported by Visuino. 
With this component, you can embed your own C++/Arduino code to extend Visuino’s capabilities with minimal restrictions.
 
'''Key Features:'''
* Full support for external Arduino or C++ libraries, custom modules, and additional functionality.
* Mechanisms for code customization: '''Defines''', '''Includes''', '''Global Declarations/Implementations''', and logic hooks ('''OnInit''', '''OnStart''', '''OnExecute''', '''OnUpdate Hardware''').
* Ability to implement any hardware communication protocol (e.g. Modbus, CANBus, MQTT, REST).
* '''Live Code''' view lets you inspect and debug the generated code in real time.
* Works seamlessly with professional features such as '''SubDiagrams''', industrial protocols, and device-specific customization.


<b>Diagram:</b>
<b>Diagram:</b>
Line 12: Line 22:


== Properties ==
== Properties ==
*'''Defines''' – Preprocessor definitions and macros (Default: 0 items).
* '''Defines''' – Preprocessor definitions and macros inserted at the very top of the generated Arduino sketch (before any `#include` statements)
*'''Global Declarations''' – Global variable and function declarations (Default: 0 items).
Useful for `#define` constants, conditional compilation flags, or macros that must be available globally.
*'''Global Implementations''' – Global function implementations (Default: 0 items).
* '''Includes''' – Header file inclusions and import statements placed near the top of the sketch. 
*'''Includes''' – Header file inclusions and import statements (Default: 0 items).
Use this to add `#include <LibraryName.h>` or other required headers.
*'''Inputs''' – Configurable input data types and parameters (Default: 18 types available).
* '''Global Declarations''' – Global variable and function declarations generated outside of `setup()` and `loop()`.
*'''Libraries''' – External library dependencies and linkages (Default: 0 items).
This is where you declare global variables, custom structs, `extern` references, and function prototypes.
*'''Members''' – Class member variables and methods (Default: 0 items).
* '''Global Implementations''' – Full function implementations placed outside of `setup()` and `loop()`. 
*'''Name''' – Component identifier (Default: CustomCode).
Use this to define helper functions, utility routines, or class method implementations.
*'''On Execute''' – Code executed during main execution cycle.
* '''Libraries''' – External library dependencies and linkages
*'''On Init''' – Code executed during initialization phase.
Automatically manages `#include` statements and library references so the Arduino IDE can compile your project with the required libraries.
*'''On Start''' – Code executed at program start.
* '''Members''' – Class member variables and methods generated as part of the Custom Code component’s internal class. 
*'''On Update Hardware''' – Code executed during hardware update cycles.
Ideal for encapsulating state or creating reusable, object-oriented code segments.
*'''Outputs''' Configurable output data types and parameters (Default: 18 types available).
* '''Name''' – Component identifier used as the instance name of the Custom Code component in the generated sketch.
 
=== Execution Hooks ===
* '''On Init''' – Code executed during the initialization phase of the Arduino program. 
Typically used for hardware initialization. Here you place `begin()` calls or other setup logic that prepares devices before use. 
This code is generated inside the `setup()` function.
* '''On Start''' – Code executed immediately after initialization. 
Useful for sending initial values, printing startup information, or communicating with components right after initialization
This code is also generated inside the `setup()` function, but runs after `On Init`.
* '''On Execute''' – Code executed in the main program loop. 
By default, this runs continuously like `loop()`. 
If a Clock input pin is connected, the code is executed only when a clock event occurs.
* '''On Update Hardware''' – Code executed at the very end of the loop cycle. 
Typically used to update hardware that requires pre-calculated values or last-moment synchronization.
 
=== Inputs ===
Opens a window where you can add input pins of various data types: 
** Clock (digital) – timing and synchronization trigger. 
** Date/Time (complex) – date and time data input. 
** Analog Array (analog array) – array of analog values input. 
** Complex Array (complex array) – array of complex data structures input. 
** Binary (binary) – binary data input. 
** Color (color) – RGB color data input. 
** Alpha Color (alpha color) – RGBA color input with alpha channel. 
** RGBW Color (rgbw color) – RGBW color data input. 
** RGBW Alpha Color (rgbw alpha color) – RGBWA color data input with alpha channel. 
** Orientation 2D (orientation 2d) – 2D orientation and position input. 
** Orientation 3D (orientation 3d) – 3D orientation and position input. 
** Image (image) – image data input. 
** Audio (audio) – audio signal input. 
** CAN bus (can bus) – CAN bus communication data input. 
** Unsigned Array (unsigned array) – array of unsigned integers input.
** Unsigned 64 (unsigned 64) – 64-bit unsigned integer input.
 
=== Outputs ===
Opens a window where you can add output pins of various data types: 
** Clock Out (digital) – processed timing signal output. 
** Data Out (complex) – processed data output. 
** Analog Array Out (analog array) – processed analog array output. 
** Complex Array Out (complex array) – processed complex array output. 
** Binary Out (binary) – processed binary data output. 
** Color Out (color) – processed color data output. 
** Alpha Color Out (alpha color) – processed alpha color output. 
** RGBW Color Out (rgbw color) – processed RGBW color output. 
** RGBW Alpha Color Out (rgbw alpha color) – processed RGBWA color output. 
** Orientation 2D Out (orientation 2d) – processed 2D orientation output. 
** Orientation 3D Out (orientation 3d) – processed 3D orientation output. 
** Image Out (image) – processed image output. 
** Audio Out (audio) processed audio output
** CAN bus Out (can bus) – processed CAN bus data output. 
** Unsigned Array Out (unsigned array) – processed unsigned array output. 
** Unsigned 64 Out (unsigned 64) – processed 64-bit unsigned integer output.


== Pins ==
== Pins ==
=== Input Pins ===
* '''Clock''' (digital) – The only direct input pin. When triggered, it executes the code in the component.
*'''Clock''' (digital) – Timing and synchronization signal input.
 
*'''Intrigger''' (digital) – Interrupt trigger input for event-driven execution.
== Resources ==
*'''Date/Time''' (complex) – Date and time data input.
=== Tutorials & Guides ===
*'''Analog Array''' (analog array) – Array of analog values input.
* [https://www.instructables.com/Adafruit-MPRLS-Pressure-Sensor-Using-Visuino-Custo Adafruit MPRLS Pressure Sensor Using Visuino Custom Code]
*'''Complex Array''' (complex array) – Array of complex data structures input.
* [https://www.instructables.com/Control-Stepper-Motor-Nema17-How-to-Use-Custom-Cod Control Stepper Motor Nema17 How to Use Custom Code in Visuino PRO]
*'''Binary''' (binary) – Binary data input.
* [https://www.instructables.com/MFRC522-RFID-Reader-How-to-Use-Custom-Code-in-Visu MFRC522 RFID Reader How to Use Custom Code in Visuino PRO]
*'''Color''' (color) – RGB color data input.
* [https://www.instructables.com/MAX30100-Heart-Rate-Sensor-Oximeter-How-to-Use-Cus MAX30100 Heart Rate Sensor & Oximeter How to Use Custom Code in Visuino PRO]
*'''Alpha Color''' (alpha color) – RGBA color with alpha channel input.
*'''RGBW Color''' (rgbw color) – RGBW color data input.
*'''RGBW Alpha Color''' (rgbw alpha color) RGBWA color with alpha channel input.
*'''Orientation 2D''' (orientation 2d) – 2D orientation and position data input.
*'''Orientation 3D''' (orientation 3d) – 3D orientation and position data input.
*'''Image''' (image) Image data input.
*'''Audio''' (audio) – Audio signal input.
*'''CAN bus''' (can bus) – CAN bus communication data input.
*'''Unsigned Array''' (unsigned array) Array of unsigned integers input.
*'''Unsigned 64''' (unsigned 64) – 64-bit unsigned integer input.


=== Output Pins ===
=== Video Tutorials ===
*'''Clock Out''' (digital) Processed timing signal output.
* [https://www.youtube.com/watch?v=dBBtTwn5jJw Visuino Custom Code Part 101 OnData Element]
*'''Data Out''' (complex) – Processed data output.
* [https://youtu.be/JISPq7HfRBA Visuino Custom Code Part 102 – On Execute VS On Data Loops]
*'''Analog Array Out''' (analog array) Processed analog array output.
* [https://youtu.be/DJMKRzkLddU Visuino Custom Code Part 103 Working with and Outputting Data]
*'''Complex Array Out''' (complex array) – Processed complex array output.
* [https://youtu.be/631Yjuc8POE Visuino Custom Code Part 104 Adding User Input and Multiple Loops]
*'''Binary Out''' (binary) Processed binary data output.
* [https://youtu.be/uJ5vESK6uyY Visuino Custom Code Part 105 On Execute (System Loop)]
*'''Color Out''' (color) – Processed color data output.
* [https://youtu.be/nhqrB8zMRCs Visuino Custom Code Part 106 Includes, Defines, Arrays, and Custom Library]
*'''Alpha Color Out''' (alpha color) Processed alpha color output.
* [https://youtu.be/NYJYwj1y7KM Visuino Custom Code Part 107 Using the Clock Output Pins]
*'''RGBW Color Out''' (rgbw color) – Processed RGBW color output.
* [https://youtu.be/O_BJRXq6QuM Visuino Custom Code Part 108 Using Hardware Libraries and Pin Attachments]
*'''RGBW Alpha Color Out''' (rgbw alpha color) – Processed RGBWA color output.
* [https://youtu.be/JNphV3EHzyI Visuino Custom Code Part 109 OnInit, OnStart, and Direct Pin Manipulation/Reading]
*'''Orientation 2D Out''' (orientation 2d) Processed 2D orientation output.
*'''Orientation 3D Out''' (orientation 3d) – Processed 3D orientation output.
*'''Image Out''' (image) Processed image output.
*'''Audio Out''' (audio) – Processed audio output.
*'''CAN bus Out''' (can bus) Processed CAN bus data output.
*'''Unsigned Array Out''' (unsigned array) – Processed unsigned array output.
*'''Unsigned 64 Out''' (unsigned 64) Processed 64-bit unsigned integer output.


== Categories ==
== Categories ==
*[[Image:Programming.png]] [[Category:Programming]] – Code and programming components.
* [[Image:Programming.png]] [[Category:Programming]] – Code and programming components.
*[[Image:Custom.png]] [[Category:Custom Components]] – User-customizable components.
* [[Image:Custom.png]] [[Category:Custom Components]] – User-customizable components.
*[[Image:Interface.png]] [[Category:Interface]] – Data interface and conversion components.
* [[Image:Interface.png]] [[Category:Interface]] – Data interface and conversion components.
*[[Image:DataProcessing.png]] [[Category:Data Processing]] – Data manipulation and processing components.
* [[Image:DataProcessing.png]] [[Category:Data Processing]] – Data manipulation and processing components.
*[[Image:Advanced.png]] [[Category:Advanced]] – Advanced programming components.
* [[Image:Advanced.png]] [[Category:Advanced]] – Advanced programming components.

Latest revision as of 13:31, 11 September 2025

File:TArduinoCustomCode.png

Summary

The Custom Code component in Visuino Professional lets you inject arbitrary C/C++/Arduino code directly into your visual program. It removes the limitations of built-in components and allows integration of unsupported sensors, libraries, hardware modules, or protocols — providing nearly unlimited flexibility in what can be created.

Description

The Custom Code component is one of the most powerful features of Visuino Professional. It is designed to fill gaps whenever a sensor, module, protocol, or function is not natively supported by Visuino. With this component, you can embed your own C++/Arduino code to extend Visuino’s capabilities with minimal restrictions.

Key Features:

  • Full support for external Arduino or C++ libraries, custom modules, and additional functionality.
  • Mechanisms for code customization: Defines, Includes, Global Declarations/Implementations, and logic hooks (OnInit, OnStart, OnExecute, OnUpdate Hardware).
  • Ability to implement any hardware communication protocol (e.g. Modbus, CANBus, MQTT, REST).
  • Live Code view lets you inspect and debug the generated code in real time.
  • Works seamlessly with professional features such as SubDiagrams, industrial protocols, and device-specific customization.

Diagram:

Properties

  • Defines – Preprocessor definitions and macros inserted at the very top of the generated Arduino sketch (before any `#include` statements).

Useful for `#define` constants, conditional compilation flags, or macros that must be available globally.

  • Includes – Header file inclusions and import statements placed near the top of the sketch.

Use this to add `#include <LibraryName.h>` or other required headers.

  • Global Declarations – Global variable and function declarations generated outside of `setup()` and `loop()`.

This is where you declare global variables, custom structs, `extern` references, and function prototypes.

  • Global Implementations – Full function implementations placed outside of `setup()` and `loop()`.

Use this to define helper functions, utility routines, or class method implementations.

  • Libraries – External library dependencies and linkages.

Automatically manages `#include` statements and library references so the Arduino IDE can compile your project with the required libraries.

  • Members – Class member variables and methods generated as part of the Custom Code component’s internal class.

Ideal for encapsulating state or creating reusable, object-oriented code segments.

  • Name – Component identifier used as the instance name of the Custom Code component in the generated sketch.

Execution Hooks

  • On Init – Code executed during the initialization phase of the Arduino program.

Typically used for hardware initialization. Here you place `begin()` calls or other setup logic that prepares devices before use. This code is generated inside the `setup()` function.

  • On Start – Code executed immediately after initialization.

Useful for sending initial values, printing startup information, or communicating with components right after initialization. This code is also generated inside the `setup()` function, but runs after `On Init`.

  • On Execute – Code executed in the main program loop.

By default, this runs continuously like `loop()`. If a Clock input pin is connected, the code is executed only when a clock event occurs.

  • On Update Hardware – Code executed at the very end of the loop cycle.

Typically used to update hardware that requires pre-calculated values or last-moment synchronization.

Inputs

Opens a window where you can add input pins of various data types:

    • Clock (digital) – timing and synchronization trigger.
    • Date/Time (complex) – date and time data input.
    • Analog Array (analog array) – array of analog values input.
    • Complex Array (complex array) – array of complex data structures input.
    • Binary (binary) – binary data input.
    • Color (color) – RGB color data input.
    • Alpha Color (alpha color) – RGBA color input with alpha channel.
    • RGBW Color (rgbw color) – RGBW color data input.
    • RGBW Alpha Color (rgbw alpha color) – RGBWA color data input with alpha channel.
    • Orientation 2D (orientation 2d) – 2D orientation and position input.
    • Orientation 3D (orientation 3d) – 3D orientation and position input.
    • Image (image) – image data input.
    • Audio (audio) – audio signal input.
    • CAN bus (can bus) – CAN bus communication data input.
    • Unsigned Array (unsigned array) – array of unsigned integers input.
    • Unsigned 64 (unsigned 64) – 64-bit unsigned integer input.

Outputs

Opens a window where you can add output pins of various data types:

    • Clock Out (digital) – processed timing signal output.
    • Data Out (complex) – processed data output.
    • Analog Array Out (analog array) – processed analog array output.
    • Complex Array Out (complex array) – processed complex array output.
    • Binary Out (binary) – processed binary data output.
    • Color Out (color) – processed color data output.
    • Alpha Color Out (alpha color) – processed alpha color output.
    • RGBW Color Out (rgbw color) – processed RGBW color output.
    • RGBW Alpha Color Out (rgbw alpha color) – processed RGBWA color output.
    • Orientation 2D Out (orientation 2d) – processed 2D orientation output.
    • Orientation 3D Out (orientation 3d) – processed 3D orientation output.
    • Image Out (image) – processed image output.
    • Audio Out (audio) – processed audio output.
    • CAN bus Out (can bus) – processed CAN bus data output.
    • Unsigned Array Out (unsigned array) – processed unsigned array output.
    • Unsigned 64 Out (unsigned 64) – processed 64-bit unsigned integer output.

Pins

  • Clock (digital) – The only direct input pin. When triggered, it executes the code in the component.

Resources

Tutorials & Guides

Video Tutorials

Categories