Expand description
Abstractions for the UDP protocol of the CCCB servicepoint display.
Your starting point is a std::net::UdpSocket
connected to the display.
With a socket, you can send Commands.
When received, the display will update the state of its pixels.
§Examples
§Clear display
use std::net::UdpSocket;
use servicepoint::*;
// establish a connection
let connection = UdpSocket::bind_connect("127.0.0.1:2342")
.expect("connection failed");
// turn off all pixels on display
connection.send_command(ClearCommand)
.expect("send failed");
§Set all pixels to on
// turn on all pixels in a grid
let mut pixels = Bitmap::max_sized();
pixels.fill(true);
// create command to send pixels
let command = BitmapCommand {
origin: Origin::ZERO,
bitmap: pixels,
compression: CompressionCode::default()
};
// send command to display
connection.send_command(command).expect("send failed");
§Send text
// create a text grid
let mut grid = CharGrid::from("Hello\nCCCB?");
// modify the grid
grid.set(grid.width() - 1, 1, '!');
// create the command to send the data
let command = CharGridCommand { origin: Origin::ZERO, grid };
// send command to display
connection.send_command(command).expect("send failed");
§Convert a packet to a command and back
use servicepoint::{Command, Packet, TypedCommand};
let packet: Packet = command.into();
let command = TypedCommand::try_from(packet).expect("could not read command from packet");
§Convert a packet to bytes and back
use servicepoint::{Command, Packet};
let bytes: Vec<u8> = packet.into();
let packet = Packet::try_from(bytes).expect("could not read packet from bytes");
Modules§
- bitvec
- Re-export of the used library
::bitvec
. - cp437
- Contains functions to convert between UTF-8 and Codepage 437.
Structs§
- BitVec
Command - Set pixel data starting at the pixel offset on screen.
- Bitmap
- A fixed-size 2D grid of booleans.
- Bitmap
Command - Overwrites a rectangular region of pixels.
- Bitmap
Legacy Command Deprecated - Legacy command code, gets ignored by the real display.
- Brightness
- A display brightness value, checked for correct value range
- Brightness
Grid Command - Set the brightness of individual tiles in a rectangular area of the display.
- Char
Grid Command - Show text on the screen.
- Clear
Command - Set all pixels to the off state. Does not affect brightness.
- Cp437
Grid Command - Show text on the screen.
- Fade
OutCommand - Untested
- Fake
Connection - A fake connection for testing that does not actually send anything.
- Global
Brightness Command - Set the brightness of all tiles to the same value.
- Hard
Reset Command - Kills the udp daemon on the display, which usually results in a restart.
- Header
- A raw header.
- Invalid
Char Error - The error occurring when loading an invalid character
- Origin
- An origin marks the top left position of a window sent to the display.
- Packet
- The raw packet.
- Pixels
- Marks something to be measured in number of pixels.
- Tiles
- Marks something to be measured in number of iles.
- Value
Grid - A 2D grid of values.
- Window
- A window into a 2D grid.
- Window
Mut - A window into a 2D grid.
Enums§
- Binary
Operation - Binary operations for use with the
BitVecCommand
command. - Command
Code - The u16 command codes used for the
crate::Command
s. - Compression
Code - Specifies the kind of compression to use. Availability depends on features.
- Load
Bitmap Error - Errors that can happen when loading a bitmap.
- SetValue
Series Error - Error type for methods that change a whole column or row at once
- TryFrom
Packet Error - Err values for
crate::TypedCommand::try_from
. - TryInto
Packet Error - An error that can occur when parsing a raw packet as a command
- TryLoad
Value Grid Error - Errors that can occur when loading a grid
- Typed
Command - This enum contains all commands provided by the library.
This is useful in case you want one data type for all kinds of commands without using
dyn
.
Constants§
- FRAME_
PACING - Actual hardware limit is around 28-29ms/frame. Rounded up for less dropped packets.
- PIXEL_
COUNT - pixel count on whole screen
- PIXEL_
HEIGHT - Display height in pixels
- PIXEL_
WIDTH - Display width in pixels
- TILE_
HEIGHT - Display tile count in the y-direction
- TILE_
SIZE - size of a single tile in one dimension
- TILE_
WIDTH - Display tile count in the x-direction
Traits§
- Char
Grid Ext - Extension methods for any
Grid<char>
- Char
Grid MutExt - Extension methods for any
GridMut<char>
. - Command
- This trait represents a command that can be sent to the display.
- DataRef
- A trait for getting the underlying raw byte slices of data containers.
- Grid
- A two-dimensional readonly grid of
T
- GridMut
- A two-dimensional mutable grid of
T
- UdpSocket
Ext - Provides servicepoint specific extensions for
UdpSocket
- Value
- A type that can be stored in a
ValueGrid
, e.g. char, u8.
Type Aliases§
- Brightness
Grid - A grid containing brightness values.
- Byte
Grid - A 2d grid of bytes - see
ValueGrid
. - Char
Grid - A grid containing UTF-8 characters.
- Cp437
Grid - A grid containing codepage 437 characters.
- Display
BitVec - A byte-packed vector of booleans.
- Offset
- Type alias for documenting the meaning of the u16 in enum values
- Payload
- The raw payload.