Introduction

The blendixserial library is designed to work in conjunction with the blendixserial addon in Blender. It allows you to transfer 3D coordinates (either integer or floating point) from Arduino to Blender, as well as receive and process coordinates sent from Blender to Arduino. This library offers functions to configure the coordinate type, set and reset coordinates, send text information along with coordinates, and parse received data.

Features

  • Set Coordinates: Ability to send multiple sets of 3D coordinates.
  • Coordinate Types: Support for both integer and floating point coordinate types.
  • Dynamic Sets: You can configure the number of coordinate sets to send and receive.
  • Data Parsing: Automatically parses received coordinate data in a predefined format.
  • Formatted Output: Returns the coordinates in a formatted string for easy transmission.
  • Text Handling: Sends and stores additional text information alongside coordinates

Installation

  • Download the library files from the given link.
  • Extract the downloaded files.
  • Copy the entire extracted folder into the Arduino libraries folder. The default location for this folder is:
    • Windows: Documents\Arduino\libraries
    • macOS: Documents/Arduino/libraries
    • Linux: Documents/Arduino/libraries
  • Restart the Arduino IDE if it was already open

Class Reference

Constants

Configuration Constants

  • BLENDIX_MAX_SETS: Maximum number of coordinate sets (default: 5).
  • BLENDIX_TEXT_BUFFER_SIZE: Size of the text buffer (default: 50).

Coordinate Type Strings

  • COORD_TYPE_INT: String identifier for integer coordinates ("int").
  • COORD_TYPE_FLOAT: String identifier for floating-point coordinates ("float").

Class: blendixserial

Public Methods

Constructor

  • blendixserial():
    • Initializes the object with default settings.

Coordinate Type Management

  • bool setCoordinateType(const char* type):
    • Sets the coordinate type to integer or float.
    • Parameters:
      • type"int" or "float".
    • Returns: true if successful, false otherwise.

Coordinate Set Management

  • bool setTxSets(int sets):

    • Sets the number of transmission coordinate sets.
    • Parameters:
      • sets: Number of sets to configure.
    • Returns: true if successful, false otherwise.
  • bool setRxSets(int sets):

    • Sets the number of reception coordinate sets.
    • Parameters:
      • sets: Number of sets to configure.
    • Returns: true if successful, false otherwise.

Coordinate Setting

  • bool setCoordinates(int setNum, int xVal, int yVal, int zVal):

    • Sets the coordinates for a specific set (integer type).
    • Parameters:
      • setNum: Set index (1-based).
      • xValyValzVal: Coordinate values.
    • Returns: true if successful, false otherwise.
  • bool setCoordinates(int setNum, float xVal, float yVal, float zVal):

    • Sets the coordinates for a specific set (float type).
    • Parameters:
      • setNum: Set index (1-based).
      • xValyValzVal: Coordinate values.
    • Returns: true if successful, false otherwise.
  • void resetCoordinates():

    • Resets all coordinate values to default (0 for integers, 0.0 for floats).

Text Management

  • void setText(const char* inputText):
    • Sets the text buffer content.
    • Parameters:
      • inputText: String to set in the text buffer.

Data Serialization

  • void getFormattedOutput(uint8_t* outputBuffer, size_t bufferSize):
    • Serializes coordinate data and text into the output buffer.
    • Parameters:
      • outputBuffer: Pointer to the buffer where serialized data will be written.
      • bufferSize: Size of the output buffer.

Data Parsing

  • bool parseReceivedData(const String& inputData):
    • Parses received data string and stores the extracted coordinates.
    • Parameters:
      • inputData: String containing serialized coordinate data.
    • Returns: true if parsing is successful, false otherwise.

Received Data Access

  • int getReceivedNumSets() const:

    • Returns the number of received coordinate sets.
    • Returns: Number of valid received sets.
  • bool getReceivedCoordinates(int index, float& x, float& y, float& z) const:

    • Retrieves coordinates for a specific received set.
    • Parameters:
      • index: Index of the set (0-based).
      • x, y, z: References to store coordinate values.
    • Returns: true if successful, false otherwise.

Internal Methods

Private

  • bool setCoordinateTypeInternal(CoordinateType type):
    • Helper method for setting coordinate type.
  • bool validateAndParseData(const char* inputData, ReceivedCoordinates*& tempCoords, int& tempNumSets):
    • Validates and parses raw data into coordinates.

Data Formats

Transmitting Coordinates

The formatted output for transmitting coordinates will be a comma-separated list of 3D coordinates. Each coordinate set contains three values (x, y, z), followed by optional text information.

1,2,3,4,5,6;Extra information
Where 1,2,3 and 4,5,6 are two sets of 3D coordinates, and "Extra information" is the additional text.

Receiving Coordinates

The input data from Blender should follow the format:

1.0,2.0,3.0,4.0,5.0,6.0;

Each set of three floating point values corresponds to a coordinate set.

Notes

  • Ensure that the combined number of Tx and Rx sets does not exceed BLENDIX_MAX_SETS.
  • The text buffer size is limited by BLENDIX_TEXT_BUFFER_SIZE.
  • Floating-point serialization uses 2 decimal places for precision.

License

This library is released under the terms of the GNU General Public License version 3 (GPLv3). Refer to the accompanying LICENSE file for details.

Download Library

Video Gide