Crate contourwall_core

Source
Expand description

This library provides an interface for controlling the tiles using the ContourWall protocol over serial communication with an ESP32 device mounted on each tile of the ContourWall.

The ContourWallCore struct represents the core functionality, allowing you to initialize a connection to a COM port, send commands to update LED colors, retrieve tile identifiers, and more.

For more details on available commands and usage, refer to the individual function documentation.

§Example Usage

To utilize this library, ensure you have the necessary serial port permissions and ESP32 firmware flashed with the ContourWall protocol support.

§Full Contour Wall mode (6 tiles)

use std::ffi::CString;
use contourwall_core::*;

fn main() {
    let baud_rate = 2_000_000;
    let mut cw = new(baud_rate);

    solid_color(&mut cw, 255, 0, 255); // Sets all LEDs to purple
    show(&mut cw); // Shows the changes on the LED tiles
}

§Single tile mode

use std::ffi::CString;
use contourwall_core::*;

fn main() {
    let com_port = CString::new("/dev/ttyUSB3").expect("CString conversion failed").into_raw();
    let baud_rate = 2_000_000;
    let mut cw = single_new_with_port(com_port, baud_rate);

    solid_color(&mut cw, 255, 0, 255); // Sets all LEDs to purple
    show(&mut cw); // Shows the changes on the LED tiles
}

§Compatibility

This library is compatible with both Windows and Linux systems, It has been tested on Windows devices and a Raspberry Pi 5. MacOS is untested, however it should work.

§Errors

Errors encountered during serial communication or protocol execution are indicated through StatusCode values returned by the library functions.

§Safety

This library uses unsafe Rust code to interface with C-style pointers and raw bytes for serial communication. Extra care should be taken to ensure proper usage to avoid memory unsafety and undefined behavior.

§Protocol Documentation

This library assumes adherence to the ContourWall protocol. Please refer to the protocol documentation for more information on commands and their expected behavior.

§License

This library is distributed under the terms of the MIT license. See the LICENSE file for details.

Modules§

status_code
StatusCodes abstraction, status codes are used to communicate state between tile and library.
tile
Tile struct and implementation. This struct implements the protocol to communicate with individual tiles.
util
Utiliy functions for the ContourWall Core libary.

Structs§

ContourWallCore
ContourWallCore class encapsulates the list of connected tiles.

Functions§

configure_threadpool
Configures the amount of threads for the Rayon threadpool.
drop
Transfers ownership of the ContourWallCore object back to Rust and frees the memory. Also closes the serial connections
new
Initializes the full ContourWall, all the configuration and orchistration happens automatically.
new_with_ports
Initializes the full ContourWall, based on manualy input of COM ports.
show
Executes the command_0_show on each tile to show their current framebuffer
single_new_with_port
Initializes the ContourWall as a single tile
solid_color
Executes the command_1_solid_color on each tile.
update_all
Executes the command_2_update_all on each tile.