1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
//! 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 [Command]s.
//! When received, the display will update the state of its pixels.
//!
//! # Examples
//!
//! ### Clear display
//!
//! ```rust
//! use std::net::UdpSocket;
//! use servicepoint::*;
//!
//! // establish a connection
//! let connection = UdpSocket::bind_connect("127.0.0.1:2342")
//! .expect("connection failed");
//!
//! # let connection = FakeConnection; // do not fail tests
//! // turn off all pixels on display
//! connection.send_command(ClearCommand)
//! .expect("send failed");
//! ```
//!
//! ### Set all pixels to on
//!
//! ```rust
//! # use std::net::UdpSocket;
//! # use servicepoint::*;
//! # let connection = FakeConnection;
//! // 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
//!
//! ```rust
//! # use std::net::UdpSocket;
//! # use servicepoint::*;
//! # let connection = FakeConnection;
//! // 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
//!
//! ```rust
//! use servicepoint::{Command, Packet, TypedCommand};
//! # let command = servicepoint::ClearCommand;
//! 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
//!
//! ```rust
//! use servicepoint::{Command, Packet};
//! # let command = servicepoint::ClearCommand;
//! # let packet: Packet = command.into();
//! let bytes: Vec<u8> = packet.into();
//! let packet = Packet::try_from(bytes).expect("could not read packet from bytes");
//! ```
pub use crateBrightness;
pub use crateCommandCode;
pub use crate*;
pub use crateCompressionCode;
pub use crate*;
pub use crate*;
pub use crate*;
pub use crate;
pub use crate;
// include README.md in doctest
;
/// Type alias for documenting the meaning of the u16 in enum values
pub type Offset = usize;