libepaper 2.0.0
A C++23 library for controlling Waveshare e-paper displays on Raspberry Pi, featuring transparent sleep/wake management and a fluent builder API.
Loading...
Searching...
No Matches
/mnt/nas/libepaper/include/epaper/draw/commands.hpp
// Direct construction (rare - prefer builders)
LineCommand cmd1{{10,10}, {100,100}, Color::Black, DotPixel::Pixel1x1, LineStyle::Solid};
// Typical usage via builder
auto cmd2 = LineBuilder().from({10,10}).to({100,100}).build();
display.draw(cmd2);
// Deferred rendering (command queue)
std::vector<LineCommand> lines;
lines.push_back(LineBuilder().from(a).to(b).build());
lines.push_back(LineBuilder().from(c).to(d).build());
for (const auto& cmd : lines) {
display.draw(cmd);
}
See also
builders.hpp, Display::draw(), std::variant for command polymorphism
#pragma once
#include <cstdint>
#include <string>
#include <string_view>
namespace epaper {
struct LineCommand {
Point from;
Point to;
constexpr LineCommand(Point from_pt, Point to_pt, Color c = Color::Black, DotPixel w = DotPixel::Pixel1x1,
: from(from_pt), to(to_pt), color(c), width(w), style(s) {}
};
struct RectangleCommand {
Point top_left;
Point bottom_right;
constexpr RectangleCommand(Point tl, Point br, Color c = Color::Black, DotPixel w = DotPixel::Pixel1x1,
DrawFill f = DrawFill::Empty) noexcept
: top_left(tl), bottom_right(br), color(c), border_width(w), fill(f) {}
};
struct CircleCommand {
Point center;
std::size_t radius;
constexpr CircleCommand(Point ctr, std::size_t r, Color c = Color::Black, DotPixel w = DotPixel::Pixel1x1,
DrawFill f = DrawFill::Empty) noexcept
: center(ctr), radius(r), color(c), border_width(w), fill(f) {}
};
struct PointCommand {
Point position;
constexpr PointCommand(Point pos, Color c = Color::Black, DotPixel s = DotPixel::Pixel1x1) noexcept
: position(pos), color(c), pixel_size(s) {}
};
enum class TextContent {
};
struct TextCommand {
Point position;
std::string text;
const Font *font;
std::int32_t number;
double decimal;
std::uint8_t decimal_places;
TextCommand(Point pos, std::string_view txt, const Font *f, Color fg = Color::Black, Color bg = Color::White) noexcept
decimal(0.0), decimal_places(0) {}
TextCommand(Point pos, std::int32_t num, const Font *f, Color fg = Color::Black, Color bg = Color::White) noexcept
decimal(0.0), decimal_places(0) {}
TextCommand(Point pos, double dec, std::uint8_t places, const Font *f, Color fg = Color::Black,
Color bg = Color::White) noexcept
decimal(dec), decimal_places(places) {}
};
} // namespace epaper
Bitmap font rendering for e-paper displays.
Definition color.hpp:5
DrawFill
Definition types.hpp:151
@ Empty
Draw outline only (border with no fill)
TextContent
Content type for text rendering.
Definition commands.hpp:240
@ String
Direct string content (text field used as-is)
@ Decimal
Decimal number (decimal field formatted with decimal_places precision)
@ Number
Integer number (number field converted to text via sprintf)
DotPixel
Definition types.hpp:92
@ Pixel1x1
Single pixel (finest resolution)
Color
Definition types.hpp:32
@ White
White (or lightest gray in grayscale modes)
@ Black
Black (or darkest gray in grayscale modes)
LineStyle
Definition types.hpp:120
@ Solid
Continuous solid line.
Color color
Circle color.
Definition commands.hpp:177
DotPixel border_width
Border width.
Definition commands.hpp:178
DrawFill fill
Fill mode (empty/full)
Definition commands.hpp:179
std::size_t radius
Circle radius in pixels.
Definition commands.hpp:176
Point center
Center point.
Definition commands.hpp:175
Point from
Starting point.
Definition commands.hpp:85
DotPixel width
Line width.
Definition commands.hpp:88
LineStyle style
Line style (solid/dotted)
Definition commands.hpp:89
Point to
Ending point.
Definition commands.hpp:86
Color color
Line color.
Definition commands.hpp:87
Color color
Point color.
Definition commands.hpp:220
Point position
Point position.
Definition commands.hpp:219
DotPixel pixel_size
Point size.
Definition commands.hpp:221
DrawFill fill
Fill mode (empty/full)
Definition commands.hpp:134
Color color
Rectangle color.
Definition commands.hpp:132
Point top_left
Top-left corner.
Definition commands.hpp:130
Point bottom_right
Bottom-right corner.
Definition commands.hpp:131
DotPixel border_width
Border width.
Definition commands.hpp:133
Color background
Background color.
Definition commands.hpp:286
TextContent content_type
Content type for internal use.
Definition commands.hpp:287
const Font * font
Font to use.
Definition commands.hpp:284
double decimal
Decimal value (for Decimal type)
Definition commands.hpp:289
std::int32_t number
Number value (for Number type)
Definition commands.hpp:288
Point position
Text position.
Definition commands.hpp:282
Color foreground
Foreground (text) color.
Definition commands.hpp:285
std::string text
Text content (or converted number)
Definition commands.hpp:283
std::uint8_t decimal_places
Decimal places (for Decimal type)
Definition commands.hpp:290