#serial-communication #tile #serial-port #identifier #esp32 #com #contour-wall

contourwall_core

Provides a low-level interface to control the Contour Wall

2 unstable releases

new 0.2.0 May 15, 2024
0.1.0 Mar 12, 2024

#907 in Hardware support

Download history 138/week @ 2024-03-06 39/week @ 2024-03-13 1/week @ 2024-03-20 6/week @ 2024-03-27 13/week @ 2024-04-03

122 downloads per month

MIT license

46KB
771 lines

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.

Dependencies

~6–15MB
~180K SLoC