EPaperHatCore
EPaperHatCore is a dotnet core library for Waveshare e-Paper HAT display
Install / Use
/learn @paw3lx/EPaperHatCoreREADME
EPaperHatCore
EPaperHatCore is a .NET 8.0 library for controlling Waveshare e-Paper HAT displays on Raspberry Pi. This library provides a simple and intuitive API for working with e-Paper displays, supporting various screen sizes and drawing operations.
Features
- 🖥️ Support for multiple e-Paper display sizes
- 🎨 Drawing operations: text, lines, rectangles, and points
- 🔄 Screen rotation support (0°, 90°, 180°, 270°)
- 📝 Multiple font sizes (8pt, 12pt, 16pt, 20pt)
- 🎯 Two-color display support (black and red)
- 🔧 Built on System.Device.Gpio for reliable GPIO communication
- ⚡ .NET 8.0 performance and compatibility
Supported E-Paper Displays
| Display Size | Resolution | Class Name | Colors |
|-------------|------------|------------|--------|
| 2.7 inch | 176×264 | Epaper27 | Black, Red |
| 2.13 inch v2 | 128×250 | Epaper213v2 | Black |
Dependencies
- .NET 8.0 or later
- System.Device.Gpio 3.1.0 (automatically installed)
- Raspberry Pi with GPIO support
Installation
EPaperHatCore is available on MyGet
Package Manager
Install-Package EPaperHatCore -Source https://www.myget.org/F/epaperhatcore/api/v3/index.json
.NET CLI
dotnet add package EPaperHatCore --source https://www.myget.org/F/epaperhatcore/api/v3/index.json
Getting Started
Basic Example - 2.7 inch Display
using EPaperHatCore;
using EPaperHatCore.GUI;
using EPaperHatCore.GUI.Fonts;
using static EPaperHatCore.GUI.Enums;
// Initialize the e-Paper display (2.7 inch)
var ePaper = new Epaper27(176, 264);
ePaper.Initialize();
// Create black and red screens
var blackScreen = new Screen(176, 264, Rotate.ROTATE_270, Color.WHITE);
var redScreen = new Screen(176, 264, Rotate.ROTATE_270, Color.WHITE);
// Draw text using different fonts
var font = new Font8();
var font2 = new Font20();
blackScreen.DrawString(10, 20, "Hello World!", font, Color.WHITE, Color.BLACK);
redScreen.DrawString(10, 50, "EPaperHatCore", font2, Color.WHITE, Color.RED);
// Display the screens
ePaper.DisplayScreens(blackScreen, redScreen);
Basic Example - 2.13 inch v2 Display
using EPaperHatCore;
using EPaperHatCore.GUI;
using EPaperHatCore.GUI.Fonts;
using static EPaperHatCore.GUI.Enums;
// Initialize the e-Paper display (2.13 inch v2)
var ePaper = new Epaper213v2(128, 250);
ePaper.Initialize();
// Create a black and white screen
var screen = new Screen(128, 250, Rotate.ROTATE_0, Color.WHITE);
// Draw text and shapes
var font = new Font16();
screen.DrawString(10, 10, "EPaperHatCore", font, Color.WHITE, Color.BLACK);
screen.DrawRectangle(10, 40, 100, 60, Color.BLACK, false, 1);
screen.DrawLine(10, 70, 100, 90, Color.BLACK, LineStyle.LINE_STYLE_SOLID, 1);
// Display the screen
ePaper.DisplayScreens(screen);
Advanced Drawing Operations
// Drawing shapes and text with various options
var screen = new Screen(176, 264, Rotate.ROTATE_0, Color.WHITE);
// Draw filled rectangle
screen.DrawRectangle(20, 20, 80, 60, Color.BLACK, filled: true, dotSize: 1);
// Draw dotted line
screen.DrawLine(10, 100, 150, 120, Color.BLACK, LineStyle.LINE_STYLE_DOTTED, 2);
// Draw points with different sizes
screen.DrawPoint(50, 150, Color.BLACK, dotSize: 3, DotStyle.DOT_FILL_AROUND);
// Text with different font sizes
var font8 = new Font8();
var font12 = new Font12();
var font16 = new Font16();
var font20 = new Font20();
screen.DrawString(10, 180, "Font 8pt", font8, Color.WHITE, Color.BLACK);
screen.DrawString(10, 200, "Font 12pt", font12, Color.WHITE, Color.BLACK);
screen.DrawString(10, 220, "Font 16pt", font16, Color.WHITE, Color.BLACK);
screen.DrawString(10, 240, "Font 20pt", font20, Color.WHITE, Color.BLACK);
API Reference
Core Classes
Epaper27(int width, int height)
Driver for 2.7 inch e-Paper displays with black and red color support.
Epaper213v2(int width, int height)
Driver for 2.13 inch v2 e-Paper displays with black and white support.
Screen(uint width, uint height, Rotate rotation, Color backgroundColor)
Represents a drawable screen buffer with various drawing methods.
Drawing Methods
DrawString(x, y, text, font, bgColor, fgColor)- Draw textDrawRectangle(x1, y1, x2, y2, color, filled, dotSize)- Draw rectanglesDrawLine(x1, y1, x2, y2, color, lineStyle, dotSize)- Draw linesDrawPoint(x, y, color, dotSize, dotStyle)- Draw pointsSetPixel(x, y, color)- Set individual pixelsClear(color)- Clear screen with specified color
Enumerations
Color:BLACK,WHITE,REDRotate:ROTATE_0,ROTATE_90,ROTATE_180,ROTATE_270LineStyle:LINE_STYLE_SOLID,LINE_STYLE_DOTTEDDotStyle:DOT_FILL_AROUND,DOT_FILL_RIGHTUP
Hardware Setup
- Connect the e-Paper HAT to your Raspberry Pi GPIO pins
- Ensure your Raspberry Pi has .NET 8.0 runtime installed
- Run your application with appropriate GPIO permissions
Contributing
Contributions are welcome! Please feel free to submit issues and pull requests.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Related Skills
node-connect
347.0kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
107.8kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
347.0kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
347.0kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
