watchface/lib.rs
1/* Copyright (C) 2020 Casper Meijn <casper@meijn.net>
2 * SPDX-License-Identifier: GPL-3.0-or-later
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#![no_std]
19
20//! A smartwatch watchface implementation
21//!
22//! This crate provides the `Watchface` struct which can contain watchface data. Then it provides
23//! the `SimpleWatchfaceStyle` for drawing this data to a `embedded_graphics::DrawTarget`.
24//!
25//! # Current state
26//! The current version of this crate is only able to draw the time and the style is ugly.
27//!
28//! # Examples
29//!
30//! ```
31//! use chrono::Local;
32//! use embedded_graphics::Drawable;
33//! use embedded_graphics::mock_display::MockDisplay;
34//! use embedded_graphics::pixelcolor::Rgb888;
35//! use watchface::SimpleWatchfaceStyle;
36//! use watchface::Watchface;
37//!
38//! let style = SimpleWatchfaceStyle::default();
39//!
40//! let styled_watchface = Watchface::build()
41//! .with_time(Local::now())
42//! .into_styled(style);
43//!
44//! let mut display = MockDisplay::<Rgb888>::new();
45//! display.set_allow_out_of_bounds_drawing(true); //MockDisplay is too small for SimpleWatchfaceStyle
46//! display.set_allow_overdraw(true);
47//! styled_watchface.draw(&mut display);
48//! ```
49//!
50//! # Simulator
51//!
52//! A simulator is available for testing a watchface on a desktop. Run the example using:
53//! ```bash
54//! cargo run --example simulator
55//! ```
56
57pub mod battery;
58pub mod battery_icon;
59mod font;
60mod simple_watchface;
61mod styled;
62mod textual_time_watchface;
63pub mod time;
64mod watchface_data;
65
66pub use simple_watchface::SimpleWatchfaceStyle;
67pub use textual_time_watchface::TextualTimeWatchfaceStyle;
68pub use watchface_data::Watchface;
69pub use watchface_data::WatchfaceBuilder;