flipdot_core/lib.rs
1//! Core types for describing communication with Luminator flip-dot and LED signs.
2//!
3//! For the basic task of sign communication, you likely want to use the high-level API
4//! in the [`flipdot`] crate instead.
5//!
6//! However, `flipdot_core` is useful for crates that want to interact with the sign protocol
7//! at a lower level than the `flipdot` crate, or who want to provide their own [`SignBus`]
8//! implementations for use by `flipdot`.
9//!
10//! Tested with a MAX3000 90 × 7 side sign. Should work with any flip-dot or LED sign that uses the 7-pin circular
11//! connector, but no guarantees.
12//!
13//! Intended only for hobbyist and educational purposes. Not affiliated with Luminator in any way.
14//!
15//! # Examples
16//!
17//! ```no_run
18//! use flipdot_core::{Address, Message, Operation, PageFlipStyle, SignBus, SignType, State};
19//! # use flipdot_testing::{VirtualSign, VirtualSignBus};
20//!
21//! # fn get_bus() -> Box<dyn SignBus> { Box::new(VirtualSignBus::new(vec![VirtualSign::new(Address(3), PageFlipStyle::Manual)])) }
22//! # fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
23//! #
24//! // Assume we have a helper function to obtain a SignBus.
25//! let mut bus: Box<dyn SignBus> = get_bus();
26//!
27//! // Discover the sign and verify that is has not yet been configured.
28//! let message = Message::Hello(Address(3));
29//! let response = bus.process_message(message)?;
30//! assert_eq!(Some(Message::ReportState(Address(3), State::Unconfigured)), response);
31//!
32//! // Request that the sign receive the configuration data and verify that it acknowledges.
33//! let message = Message::RequestOperation(Address(3), Operation::ReceiveConfig);
34//! let response = bus.process_message(message)?;
35//! assert_eq!(Some(Message::AckOperation(Address(3), Operation::ReceiveConfig)), response);
36//!
37//! #
38//! # Ok(()) }
39//! ```
40//!
41//! [`flipdot`]: https://docs.rs/flipdot
42#![doc(html_root_url = "https://docs.rs/flipdot-core/0.8.0")]
43#![deny(
44 missing_copy_implementations,
45 missing_debug_implementations,
46 trivial_casts,
47 trivial_numeric_casts,
48 unsafe_code
49)]
50#![warn(
51 missing_docs,
52 unused_extern_crates,
53 unused_import_braces,
54 unused_qualifications,
55 unused_results
56)]
57
58mod frame;
59mod message;
60mod page;
61mod sign_bus;
62mod sign_type;
63
64pub use self::frame::{Address, Data, Frame, FrameError, MsgType};
65pub use self::message::{ChunkCount, Message, Offset, Operation, State};
66pub use self::page::{Page, PageError, PageFlipStyle, PageId};
67pub use self::sign_bus::SignBus;
68pub use self::sign_type::{SignType, SignTypeError};