Arduino Library for blendixserial Addon

Introduction:

The BlendixSerial library is designed to work in conjunction with the blendixserial addon in Blender. It allows for controlling objects in Blender using serial communication with an Arduino or other microcontrollers. The library provides functions to set coordinates and text for the objects in Blender, as well as retrieve a formatted output string.


Installation:

  1. Download the library files from the given link.
  2. Extract the downloaded files.
  3. 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
  4. Restart the Arduino IDE if it was already open.


API Reference:

BlendixSerial class
BlendixSerial()
  • Constructor for the BlendixSerial class.
  • Initializes the coordinates array.
void resetCoordinates()
  • Resets all coordinates in the coordinates array to zero.
void setCoordinates(int setNum, int xVal, int yVal, int zVal)
  • Sets the x, y, and z values for a specific set in the coordinates array.
  • Parameters:
    • setNum (int): The set number (1 to 3).
    • xVal (int): The x value for the set.
    • yVal (int): The y value for the set.
    • zVal (int): The z value for the set.
void setText(String inputText)
  • Sets the value of the text variable.
  • Parameters:
    • inputText (String): The text to be set.
String getFormattedOutput()
  • Returns a formatted string containing the coordinates and text data.
  • The coordinates are concatenated with commas and each set is separated by a semicolon.
  • Example output: "10,20,30;Hello, Blendix!"


Usage:

  1. Include the library at the top of your sketch:
  2. #include <BlendixSerial.h>
  3. Create an instance of the BlendixSerial class:
  4. BlendixSerial blendix;
  5. Set the coordinates and text using the provided member functions:
  6. 
    
    blendix.setCoordinates(1, 10, 20, 30);
    blendix.setText("Hello, Blendix!");
  7. Retrieve the formatted output using the getFormattedOutput() function:
  8. String output = blendix.getFormattedOutput();

    The output string will contain the formatted coordinates and text data.


  9. Use the output string as needed. For example, you can send it over a serial connection. 
              Serial.println(output);


Example:


#include "BlendixSerial.h"

BlendixSerial blendix;

void setup() {
  Serial.begin(9600);
}

void loop() {
 
  // Setting coordinates for set 1
  blendix.setCoordinates(1, 10, 20, 30);
 
  // Setting text
  blendix.setText("Hello, Blendix!");
 
  // Getting the formatted output
  String Output = blendix.getFormattedOutput();
 
  // Printing the formatted output
  Serial.println(Output);
 
  delay(2000);
 
  // Resetting coordinates
  blendix.resetCoordinates();
 
  // Updating text
  blendix.setText("Reset and Update");
 
  // Getting the updated formatted output
  Output = blendix.getFormattedOutput();
 
  // Printing the updated formatted output
  Serial.println(Output);

  delay(2000);
}
Note: Make sure to include the `BlendixSerial.h` header file and create an instance of the `BlendixSerial` class before using its methods.
The BlendixSerial library can be used in combination with the BlendixSerial addon in Blender to control the objects' coordinates and text in real-time from an external device via serial communication. Refer to the provided example sketches in Library for more usage scenarios and ideas.


License:

This library is released under the terms of the GNU General Public License version 3 (GPLv3).


Download: