abstracting display, touch and sd
This commit is contained in:
@@ -1,2 +1,3 @@
|
|||||||
build
|
build
|
||||||
!.vscode/*
|
!.vscode/*
|
||||||
|
build*
|
||||||
@@ -0,0 +1,311 @@
|
|||||||
|
# Agent Guide - Building and Compiling
|
||||||
|
|
||||||
|
This document provides the correct procedures for building this RP2350 project. Follow these instructions to avoid common pitfalls.
|
||||||
|
|
||||||
|
## Build System
|
||||||
|
|
||||||
|
This project uses:
|
||||||
|
- **CMake** for configuration
|
||||||
|
- **Ninja** as the build system (not Make)
|
||||||
|
- **Pico SDK 2.2.0** with the VS Code extension
|
||||||
|
|
||||||
|
## Initial Setup
|
||||||
|
|
||||||
|
The project must be configured with CMake using the **Ninja generator** before building:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd /Users/adolforeyna/Projects/pico-bare-metal/Adolfo/basic1
|
||||||
|
rm -rf build # Clean start
|
||||||
|
cmake -B build -G Ninja -DPICO_BOARD=adafruit_feather_rp2350
|
||||||
|
```
|
||||||
|
|
||||||
|
**IMPORTANT:** Always specify `-G Ninja` when running cmake. Without it, CMake generates Makefiles which won't work with the ninja command.
|
||||||
|
|
||||||
|
## Building
|
||||||
|
|
||||||
|
### Using Ninja Directly
|
||||||
|
|
||||||
|
After cmake configuration:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd /Users/adolforeyna/Projects/pico-bare-metal/Adolfo/basic1/build
|
||||||
|
ninja
|
||||||
|
```
|
||||||
|
|
||||||
|
Or from project root:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd /Users/adolforeyna/Projects/pico-bare-metal/Adolfo/basic1
|
||||||
|
ninja -C build
|
||||||
|
```
|
||||||
|
|
||||||
|
### Using VS Code Task
|
||||||
|
|
||||||
|
The project has a "Compile Project" task that runs:
|
||||||
|
```bash
|
||||||
|
/Users/adolforeyna/.pico-sdk/ninja/v1.12.1/ninja -C /path/to/build
|
||||||
|
```
|
||||||
|
|
||||||
|
However, this task will fail if `build.ninja` doesn't exist. You must run cmake first.
|
||||||
|
|
||||||
|
### Quick Rebuild
|
||||||
|
|
||||||
|
If you only changed source files (not CMakeLists.txt):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd build
|
||||||
|
ninja
|
||||||
|
```
|
||||||
|
|
||||||
|
If you changed CMakeLists.txt or added/removed files:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd build
|
||||||
|
cmake -G Ninja ..
|
||||||
|
ninja
|
||||||
|
```
|
||||||
|
|
||||||
|
## Building for Different Boards
|
||||||
|
|
||||||
|
### Single Board
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Clean and configure for specific board
|
||||||
|
rm -rf build
|
||||||
|
cmake -B build -G Ninja -DPICO_BOARD=pico2
|
||||||
|
cd build && ninja
|
||||||
|
```
|
||||||
|
|
||||||
|
Available boards:
|
||||||
|
- `adafruit_feather_rp2350` (default)
|
||||||
|
- `pico2`
|
||||||
|
- `pico2_w`
|
||||||
|
|
||||||
|
### All Boards at Once
|
||||||
|
|
||||||
|
Use the provided script:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./build_all_boards.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
This creates:
|
||||||
|
- `build_adafruit_feather_rp2350/basic1.uf2` → `basic1_adafruit_feather_rp2350.uf2`
|
||||||
|
- `build_pico2/basic1.uf2` → `basic1_pico2.uf2`
|
||||||
|
- `build_pico2_w/basic1.uf2` → `basic1_pico2_w.uf2`
|
||||||
|
|
||||||
|
## Verifying Build Success
|
||||||
|
|
||||||
|
### Check for Output Files
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ls -lh build/basic1.{uf2,elf,bin}
|
||||||
|
```
|
||||||
|
|
||||||
|
Successful build produces:
|
||||||
|
- `basic1.uf2` - Flash file for bootloader (≈150KB)
|
||||||
|
- `basic1.elf` - Executable with debug symbols (≈1.1MB)
|
||||||
|
- `basic1.bin` - Raw binary (≈74KB)
|
||||||
|
- `basic1.hex` - Intel HEX format
|
||||||
|
- `basic1.dis` - Disassembly (≈877KB)
|
||||||
|
|
||||||
|
### Check File Timestamp
|
||||||
|
|
||||||
|
```bash
|
||||||
|
stat build/basic1.uf2
|
||||||
|
```
|
||||||
|
|
||||||
|
Verify the modification time is recent.
|
||||||
|
|
||||||
|
### Look for Ninja Success Message
|
||||||
|
|
||||||
|
Successful build ends with:
|
||||||
|
```
|
||||||
|
[90/90] Linking CXX executable basic1.elf
|
||||||
|
```
|
||||||
|
|
||||||
|
Failed build shows:
|
||||||
|
```
|
||||||
|
ninja: build stopped: subcommand failed.
|
||||||
|
```
|
||||||
|
|
||||||
|
## Common Issues and Solutions
|
||||||
|
|
||||||
|
### Issue: "ninja: error: loading 'build.ninja': No such file or directory"
|
||||||
|
|
||||||
|
**Cause:** CMake wasn't run or didn't generate Ninja files
|
||||||
|
|
||||||
|
**Solution:**
|
||||||
|
```bash
|
||||||
|
cd /Users/adolforeyna/Projects/pico-bare-metal/Adolfo/basic1
|
||||||
|
cmake -B build -G Ninja -DPICO_BOARD=adafruit_feather_rp2350
|
||||||
|
```
|
||||||
|
|
||||||
|
### Issue: Build directory has Makefiles instead of build.ninja
|
||||||
|
|
||||||
|
**Cause:** CMake was run without `-G Ninja`
|
||||||
|
|
||||||
|
**Solution:**
|
||||||
|
```bash
|
||||||
|
rm -rf build
|
||||||
|
cmake -B build -G Ninja -DPICO_BOARD=adafruit_feather_rp2350
|
||||||
|
```
|
||||||
|
|
||||||
|
### Issue: Compilation errors after adding new files
|
||||||
|
|
||||||
|
**Cause:** CMakeLists.txt not updated or cmake not re-run
|
||||||
|
|
||||||
|
**Solution:**
|
||||||
|
1. Add new files to `CMakeLists.txt` in the `add_executable()` section
|
||||||
|
2. Re-run cmake:
|
||||||
|
```bash
|
||||||
|
cd build
|
||||||
|
cmake -G Ninja ..
|
||||||
|
ninja
|
||||||
|
```
|
||||||
|
|
||||||
|
### Issue: Changes not reflected in build
|
||||||
|
|
||||||
|
**Cause:** Stale build cache
|
||||||
|
|
||||||
|
**Solution:**
|
||||||
|
```bash
|
||||||
|
cd build
|
||||||
|
ninja clean
|
||||||
|
ninja
|
||||||
|
```
|
||||||
|
|
||||||
|
Or full rebuild:
|
||||||
|
```bash
|
||||||
|
rm -rf build
|
||||||
|
cmake -B build -G Ninja -DPICO_BOARD=adafruit_feather_rp2350
|
||||||
|
cd build && ninja
|
||||||
|
```
|
||||||
|
|
||||||
|
## Checking for Errors
|
||||||
|
|
||||||
|
### Compilation Errors
|
||||||
|
|
||||||
|
Look for errors in ninja output:
|
||||||
|
```
|
||||||
|
[12/90] Building CXX object CMakeFiles/basic1.dir/basic1.cpp.o
|
||||||
|
FAILED: CMakeFiles/basic1.dir/basic1.cpp.o
|
||||||
|
...
|
||||||
|
error: 'foo' was not declared in this scope
|
||||||
|
```
|
||||||
|
|
||||||
|
### Viewing Recent Build Output
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd build
|
||||||
|
ninja 2>&1 | tail -50 # Last 50 lines
|
||||||
|
```
|
||||||
|
|
||||||
|
### Viewing Full Build Output
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd build
|
||||||
|
ninja 2>&1 | tee build.log
|
||||||
|
```
|
||||||
|
|
||||||
|
## Build Output Location
|
||||||
|
|
||||||
|
```
|
||||||
|
build/
|
||||||
|
├── basic1.uf2 # Main flash file
|
||||||
|
├── basic1.elf # Executable with symbols
|
||||||
|
├── basic1.bin # Raw binary
|
||||||
|
├── basic1.hex # Intel HEX
|
||||||
|
├── basic1.dis # Disassembly
|
||||||
|
├── basic1.elf.map # Memory map
|
||||||
|
├── build.ninja # Ninja build file (must exist!)
|
||||||
|
├── CMakeCache.txt # CMake configuration
|
||||||
|
└── compile_commands.json # For IDE integration
|
||||||
|
```
|
||||||
|
|
||||||
|
## Integration with Tools
|
||||||
|
|
||||||
|
### VS Code Tasks
|
||||||
|
|
||||||
|
The project includes pre-configured tasks in `.vscode/tasks.json`:
|
||||||
|
- **Compile Project** - Runs ninja in build directory
|
||||||
|
|
||||||
|
These tasks expect `build/build.ninja` to exist.
|
||||||
|
|
||||||
|
### CMake Extension
|
||||||
|
|
||||||
|
If using CMake Tools extension:
|
||||||
|
1. Select kit: "Pico ARM GCC"
|
||||||
|
2. Configure with Ninja generator
|
||||||
|
3. Build target: "basic1"
|
||||||
|
|
||||||
|
## Quick Reference Commands
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Full clean build (default board)
|
||||||
|
rm -rf build && cmake -B build -G Ninja && ninja -C build
|
||||||
|
|
||||||
|
# Full clean build (specific board)
|
||||||
|
rm -rf build && cmake -B build -G Ninja -DPICO_BOARD=pico2 && ninja -C build
|
||||||
|
|
||||||
|
# Incremental build
|
||||||
|
ninja -C build
|
||||||
|
|
||||||
|
# Build all boards
|
||||||
|
./build_all_boards.sh
|
||||||
|
|
||||||
|
# Check build output
|
||||||
|
ls -lh build/basic1.uf2
|
||||||
|
|
||||||
|
# View compile commands
|
||||||
|
cat build/compile_commands.json | grep -A5 basic1.cpp
|
||||||
|
```
|
||||||
|
|
||||||
|
## Testing Build Success
|
||||||
|
|
||||||
|
After building, you can verify the binary contains expected symbols:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
arm-none-eabi-nm build/basic1.elf | grep -i main
|
||||||
|
arm-none-eabi-size build/basic1.elf
|
||||||
|
```
|
||||||
|
|
||||||
|
## Important Notes
|
||||||
|
|
||||||
|
1. **Always use `-G Ninja`** when running cmake
|
||||||
|
2. **The build directory must be recreated** when switching boards
|
||||||
|
3. **ninja must be run from the build directory** or with `-C build`
|
||||||
|
4. **CMake must be re-run** after modifying CMakeLists.txt
|
||||||
|
5. **The Pico SDK path** is at `~/.pico-sdk/sdk/2.2.0`
|
||||||
|
6. **The toolchain** is at `~/.pico-sdk/toolchain/14_2_Rel1`
|
||||||
|
7. **Output files** are always in the `build/` directory (or board-specific build dirs)
|
||||||
|
|
||||||
|
## When Making Changes
|
||||||
|
|
||||||
|
| Change Type | Required Action |
|
||||||
|
|-------------|-----------------|
|
||||||
|
| Source code (.cpp, .c) | `ninja -C build` |
|
||||||
|
| Header files (.h) | `ninja -C build` |
|
||||||
|
| CMakeLists.txt | `cd build && cmake -G Ninja .. && ninja` |
|
||||||
|
| New board | `rm -rf build && cmake -B build -G Ninja -DPICO_BOARD=<board> && ninja -C build` |
|
||||||
|
| New files | Update CMakeLists.txt, then re-run cmake |
|
||||||
|
| board_config.h | `ninja -C build` |
|
||||||
|
|
||||||
|
## Flashing
|
||||||
|
|
||||||
|
After successful build:
|
||||||
|
|
||||||
|
1. **Manual:** Hold BOOTSEL, connect USB, copy `build/basic1.uf2` to mounted drive
|
||||||
|
2. **Script:** `./build_and_flash.sh` (requires openocd or picotool)
|
||||||
|
3. **VS Code:** Use "Run Project" or "Flash" tasks
|
||||||
|
|
||||||
|
## Serial Monitor
|
||||||
|
|
||||||
|
View serial output:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
screen /dev/cu.usbmodem101
|
||||||
|
# Exit: Ctrl-A, then K, then Y
|
||||||
|
```
|
||||||
|
|
||||||
|
Or use VS Code's serial monitor extension.
|
||||||
+26
-12
@@ -23,7 +23,11 @@ if (EXISTS ${picoVscode})
|
|||||||
include(${picoVscode})
|
include(${picoVscode})
|
||||||
endif()
|
endif()
|
||||||
# ====================================================================================
|
# ====================================================================================
|
||||||
set(PICO_BOARD adafruit_feather_rp2350 CACHE STRING "Board type")
|
# Default to Feather RP2350, but allow override via -DPICO_BOARD=<board>
|
||||||
|
if(NOT PICO_BOARD)
|
||||||
|
set(PICO_BOARD adafruit_feather_rp2350 CACHE STRING "Board type")
|
||||||
|
endif()
|
||||||
|
message(STATUS "Building for board: ${PICO_BOARD}")
|
||||||
|
|
||||||
# Pull in Raspberry Pi Pico SDK (must be before project)
|
# Pull in Raspberry Pi Pico SDK (must be before project)
|
||||||
include(pico_sdk_import.cmake)
|
include(pico_sdk_import.cmake)
|
||||||
@@ -37,16 +41,22 @@ pico_sdk_init()
|
|||||||
|
|
||||||
add_executable(basic1
|
add_executable(basic1
|
||||||
basic1.cpp
|
basic1.cpp
|
||||||
st7796.c
|
lib/st7796/st7796.c
|
||||||
ft6336u.c
|
lib/ft6336u/ft6336u.c
|
||||||
sd_card.c
|
lib/sd_card/sd_card.c
|
||||||
low_level_render.cpp
|
display/low_level_render.cpp
|
||||||
low_level_gui.cpp
|
display/low_level_gui.cpp
|
||||||
|
display/low_level_display_factory.cpp
|
||||||
|
display/low_level_display_st7796.cpp
|
||||||
|
display/low_level_display_st7789.cpp
|
||||||
|
display/low_level_display_epaper.cpp
|
||||||
|
display/low_level_touch_factory.cpp
|
||||||
|
display/low_level_touch_ft6336u.cpp
|
||||||
diskio_sdcard.c
|
diskio_sdcard.c
|
||||||
fatfs_time.c
|
fatfs_time.c
|
||||||
fatfs/source/ff.c
|
lib/fatfs/source/ff.c
|
||||||
fatfs/source/ffsystem.c
|
lib/fatfs/source/ffsystem.c
|
||||||
fatfs/source/ffunicode.c
|
lib/fatfs/source/ffunicode.c
|
||||||
)
|
)
|
||||||
|
|
||||||
pico_set_program_name(basic1 "basic1")
|
pico_set_program_name(basic1 "basic1")
|
||||||
@@ -62,8 +72,12 @@ target_link_libraries(basic1
|
|||||||
|
|
||||||
# Add the standard include files to the build
|
# Add the standard include files to the build
|
||||||
target_include_directories(basic1 PRIVATE
|
target_include_directories(basic1 PRIVATE
|
||||||
${CMAKE_CURRENT_LIST_DIR}
|
${CMAKE_CURRENT_LIST_DIR}
|
||||||
${CMAKE_CURRENT_LIST_DIR}/fatfs/source
|
${CMAKE_CURRENT_LIST_DIR}/lib/fatfs/source
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/lib/st7796
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/lib/ft6336u
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/lib/sd_card
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/display
|
||||||
)
|
)
|
||||||
|
|
||||||
# Add any user requested libraries
|
# Add any user requested libraries
|
||||||
@@ -71,7 +85,7 @@ target_link_libraries(basic1
|
|||||||
hardware_spi
|
hardware_spi
|
||||||
hardware_i2c
|
hardware_i2c
|
||||||
m
|
m
|
||||||
)
|
)
|
||||||
|
|
||||||
pico_add_extra_outputs(basic1)
|
pico_add_extra_outputs(basic1)
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,357 @@
|
|||||||
|
# RP2350 TFT Display with Touch and SD Card Demo
|
||||||
|
|
||||||
|
A modular embedded application for RP2350 microcontrollers featuring display, touch, and SD card support with hardware abstraction layers.
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- **Display Abstraction Layer** - Support for multiple display types (ST7796, ST7789, E-Paper)
|
||||||
|
- **Touch Abstraction Layer** - Extensible touch controller support (FT6336U)
|
||||||
|
- **SD Card with FatFS** - File system support with board-aware initialization
|
||||||
|
- **Multi-Board Support** - Automatic pin configuration for different RP2350 boards
|
||||||
|
- **1-bit Rendering** - Memory-efficient monochrome graphics with GUI widgets
|
||||||
|
- **Board Configuration** - Single configuration file for all hardware settings
|
||||||
|
|
||||||
|
## Supported Hardware
|
||||||
|
|
||||||
|
### Boards
|
||||||
|
1. **Adafruit Feather RP2350** (default)
|
||||||
|
2. **Raspberry Pi Pico 2**
|
||||||
|
3. **Raspberry Pi Pico 2 W**
|
||||||
|
|
||||||
|
### Displays
|
||||||
|
- ST7796 (480x320 TFT LCD) - Fully implemented
|
||||||
|
- ST7789 - Ready for driver implementation
|
||||||
|
- E-Paper - Ready for driver implementation
|
||||||
|
|
||||||
|
### Touch Controllers
|
||||||
|
- FT6336U (I2C capacitive touch) - Fully implemented
|
||||||
|
- Extensible for additional controllers
|
||||||
|
|
||||||
|
### Storage
|
||||||
|
- SD Card via SPI with FatFS file system
|
||||||
|
|
||||||
|
## Quick Start
|
||||||
|
|
||||||
|
### Building for Default Board (Feather RP2350)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mkdir -p build
|
||||||
|
cd build
|
||||||
|
cmake -G Ninja ..
|
||||||
|
ninja
|
||||||
|
```
|
||||||
|
|
||||||
|
### Building for Specific Board
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cmake -G Ninja -DPICO_BOARD=pico2 ..
|
||||||
|
ninja
|
||||||
|
```
|
||||||
|
|
||||||
|
Available boards: `adafruit_feather_rp2350`, `pico2`, `pico2_w`
|
||||||
|
|
||||||
|
### Building for All Boards
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./build_all_boards.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
Generates:
|
||||||
|
- `basic1_adafruit_feather_rp2350.uf2`
|
||||||
|
- `basic1_pico2.uf2`
|
||||||
|
- `basic1_pico2_w.uf2`
|
||||||
|
|
||||||
|
### Flashing
|
||||||
|
|
||||||
|
1. Hold BOOTSEL button while connecting USB
|
||||||
|
2. Copy the `.uf2` file to the mounted drive
|
||||||
|
3. Device will automatically reboot and run
|
||||||
|
|
||||||
|
Or use the flash script:
|
||||||
|
```bash
|
||||||
|
./build_and_flash.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
## Project Structure
|
||||||
|
|
||||||
|
```
|
||||||
|
basic1/
|
||||||
|
├── basic1.cpp # Main application
|
||||||
|
├── board_config.h # Board-specific pin configuration
|
||||||
|
├── CMakeLists.txt # Build configuration
|
||||||
|
├── build_all_boards.sh # Multi-board build script
|
||||||
|
├── build_and_flash.sh # Build and flash helper
|
||||||
|
│
|
||||||
|
├── display/ # Display and GUI abstraction
|
||||||
|
│ ├── low_level_display.h # Display interface
|
||||||
|
│ ├── low_level_display_*.cpp # Display implementations
|
||||||
|
│ ├── low_level_touch.h # Touch interface
|
||||||
|
│ ├── low_level_touch_*.cpp # Touch implementations
|
||||||
|
│ ├── low_level_render.h/cpp # 1-bit rendering engine
|
||||||
|
│ └── low_level_gui.h/cpp # GUI widgets
|
||||||
|
│
|
||||||
|
├── lib/ # Hardware drivers
|
||||||
|
│ ├── ft6336u/ # FT6336U touch driver
|
||||||
|
│ ├── st7796/ # ST7796 display driver
|
||||||
|
│ ├── sd_card/ # SD card driver with FatFS test
|
||||||
|
│ └── fatfs/ # FatFS filesystem
|
||||||
|
│
|
||||||
|
├── fonts/ # Bitmap font definitions
|
||||||
|
└── fatfs_time.c # FatFS timestamp (uses compile time)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
### Board Configuration (`board_config.h`)
|
||||||
|
|
||||||
|
All hardware settings are defined per board:
|
||||||
|
|
||||||
|
```c
|
||||||
|
// Display configuration
|
||||||
|
#define DISPLAY_WIDTH 480
|
||||||
|
#define DISPLAY_HEIGHT 320
|
||||||
|
#define DISPLAY_TYPE_SELECTED 0 // DISPLAY_TYPE_ST7796
|
||||||
|
|
||||||
|
// Touch configuration
|
||||||
|
#define TOUCH_TYPE_SELECTED 0 // TOUCH_TYPE_FT6336U
|
||||||
|
#define TOUCH_SWAP_XY true
|
||||||
|
#define TOUCH_INVERT_X true
|
||||||
|
#define TOUCH_INVERT_Y false
|
||||||
|
|
||||||
|
// SPI pins for display
|
||||||
|
#define DISPLAY_SPI_PORT spi1
|
||||||
|
#define DISPLAY_SCK_PIN 18
|
||||||
|
#define DISPLAY_MOSI_PIN 19
|
||||||
|
#define DISPLAY_MISO_PIN 20
|
||||||
|
#define DISPLAY_CS_PIN 17
|
||||||
|
// ... more pins
|
||||||
|
```
|
||||||
|
|
||||||
|
### Changing Display Type
|
||||||
|
|
||||||
|
Modify `DISPLAY_TYPE_SELECTED` in `board_config.h`:
|
||||||
|
- `0` = ST7796 (480x320 TFT)
|
||||||
|
- `1` = ST7789
|
||||||
|
- `2` = E-Paper
|
||||||
|
|
||||||
|
### Changing Touch Type
|
||||||
|
|
||||||
|
Modify `TOUCH_TYPE_SELECTED` in `board_config.h`:
|
||||||
|
- `0` = FT6336U
|
||||||
|
- `1` = None (disable touch)
|
||||||
|
|
||||||
|
### Touch Coordinate Transformation
|
||||||
|
|
||||||
|
Adjust orientation in `board_config.h`:
|
||||||
|
```c
|
||||||
|
#define TOUCH_SWAP_XY true // Swap X/Y coordinates
|
||||||
|
#define TOUCH_INVERT_X true // Invert X axis
|
||||||
|
#define TOUCH_INVERT_Y false // Invert Y axis
|
||||||
|
```
|
||||||
|
|
||||||
|
## Architecture
|
||||||
|
|
||||||
|
### Display Abstraction Layer
|
||||||
|
|
||||||
|
Provides a unified interface for different display types:
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
class LowLevelDisplay {
|
||||||
|
public:
|
||||||
|
virtual bool init() = 0;
|
||||||
|
virtual void clear(bool white = true) = 0;
|
||||||
|
virtual void draw_buffer(const uint8_t* bit_buffer) = 0;
|
||||||
|
virtual void refresh() = 0;
|
||||||
|
// ... more methods
|
||||||
|
|
||||||
|
static LowLevelDisplay* create(DisplayType type, int width, int height);
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
```cpp
|
||||||
|
LowLevelDisplay* display = LowLevelDisplay::create(
|
||||||
|
(DisplayType)DISPLAY_TYPE_SELECTED, V_WIDTH, V_HEIGHT);
|
||||||
|
display->init();
|
||||||
|
display->draw_buffer(buffer);
|
||||||
|
display->refresh();
|
||||||
|
```
|
||||||
|
|
||||||
|
### Touch Abstraction Layer
|
||||||
|
|
||||||
|
Unified interface for touch controllers:
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
class LowLevelTouch {
|
||||||
|
public:
|
||||||
|
virtual bool init() = 0;
|
||||||
|
virtual bool read_touch(TouchData* data) = 0;
|
||||||
|
virtual bool is_touched() = 0;
|
||||||
|
// ... more methods
|
||||||
|
|
||||||
|
static LowLevelTouch* create(TouchType type, int width, int height,
|
||||||
|
bool swap_xy, bool invert_x, bool invert_y);
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
```cpp
|
||||||
|
LowLevelTouch* touch = LowLevelTouch::create(
|
||||||
|
(TouchType)TOUCH_TYPE_SELECTED, V_WIDTH, V_HEIGHT,
|
||||||
|
TOUCH_SWAP_XY, TOUCH_INVERT_X, TOUCH_INVERT_Y);
|
||||||
|
|
||||||
|
TouchData touch_data;
|
||||||
|
if (touch->read_touch(&touch_data)) {
|
||||||
|
int x = touch_data.points[0].x;
|
||||||
|
int y = touch_data.points[0].y;
|
||||||
|
// Handle touch
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### SD Card Abstraction
|
||||||
|
|
||||||
|
Board-aware initialization:
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
// Initialize with board configuration
|
||||||
|
if (sd_card_init_with_board_config()) {
|
||||||
|
// Test FatFS functionality
|
||||||
|
sd_card_test_fatfs();
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
The test function:
|
||||||
|
- Mounts FatFS
|
||||||
|
- Lists directory contents
|
||||||
|
- Creates and reads test file
|
||||||
|
- Safely unmounts filesystem
|
||||||
|
|
||||||
|
## Pin Configurations
|
||||||
|
|
||||||
|
### Adafruit Feather RP2350
|
||||||
|
- **Display (SPI1):** SCK=18, MOSI=19, MISO=20, CS=17, DC=16, RST=15, BL=14
|
||||||
|
- **Touch (I2C0):** SDA=4, SCL=5, INT=6, RST=7
|
||||||
|
- **SD Card (SPI1):** CS=10 (shares SPI with display)
|
||||||
|
|
||||||
|
### Raspberry Pi Pico 2 / Pico 2 W
|
||||||
|
- **Display (SPI0):** SCK=2, MOSI=3, MISO=4, CS=5, DC=6, RST=7, BL=8
|
||||||
|
- **Touch (I2C0):** SDA=12, SCL=13, INT=14, RST=15
|
||||||
|
- **SD Card (SPI1):** CS=17
|
||||||
|
|
||||||
|
## Adding New Hardware
|
||||||
|
|
||||||
|
### Adding a New Display Driver
|
||||||
|
|
||||||
|
1. Create implementation files:
|
||||||
|
```cpp
|
||||||
|
display/low_level_display_mydriver.h
|
||||||
|
display/low_level_display_mydriver.cpp
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Implement the `LowLevelDisplay` interface
|
||||||
|
|
||||||
|
3. Add to factory in `low_level_display_factory.cpp`:
|
||||||
|
```cpp
|
||||||
|
case DISPLAY_TYPE_MYDRIVER:
|
||||||
|
display = new LowLevelDisplayMyDriver(width, height);
|
||||||
|
break;
|
||||||
|
```
|
||||||
|
|
||||||
|
4. Update `CMakeLists.txt` to include new files
|
||||||
|
|
||||||
|
### Adding a New Touch Controller
|
||||||
|
|
||||||
|
1. Create implementation files:
|
||||||
|
```cpp
|
||||||
|
display/low_level_touch_mydriver.h
|
||||||
|
display/low_level_touch_mydriver.cpp
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Implement the `LowLevelTouch` interface
|
||||||
|
|
||||||
|
3. Add to factory in `low_level_touch_factory.cpp`
|
||||||
|
|
||||||
|
4. Update `CMakeLists.txt`
|
||||||
|
|
||||||
|
### Adding a New Board
|
||||||
|
|
||||||
|
Edit `board_config.h`:
|
||||||
|
|
||||||
|
```c
|
||||||
|
#elif defined(PICO_BOARD_MY_CUSTOM_BOARD)
|
||||||
|
#define BOARD_NAME "My Custom Board"
|
||||||
|
|
||||||
|
// Display configuration
|
||||||
|
#define DISPLAY_WIDTH 480
|
||||||
|
#define DISPLAY_HEIGHT 320
|
||||||
|
#define DISPLAY_TYPE_SELECTED 0
|
||||||
|
|
||||||
|
// Touch configuration
|
||||||
|
#define TOUCH_TYPE_SELECTED 0
|
||||||
|
// ... define all pins
|
||||||
|
#endif
|
||||||
|
```
|
||||||
|
|
||||||
|
## Memory Usage
|
||||||
|
|
||||||
|
- **1-bit framebuffer:** 480×320÷8 = 19.2 KB
|
||||||
|
- **Display conversion:** Automatic 1-bit → RGB565/monochrome
|
||||||
|
- **Stack/heap:** Minimal, uses static buffers where possible
|
||||||
|
|
||||||
|
## Known Issues & Troubleshooting
|
||||||
|
|
||||||
|
### Touch Not Working
|
||||||
|
- **I2C Communication Failure:** Check wiring, pull-up resistors, I2C address
|
||||||
|
- **Wrong Coordinates:** Adjust `TOUCH_SWAP_XY`, `TOUCH_INVERT_X/Y` settings
|
||||||
|
|
||||||
|
### SD Card Not Detected
|
||||||
|
- **CMD0 Returns 0x00:** Check card insertion, CS pin, SPI wiring
|
||||||
|
- **Mount Fails:** Ensure card is formatted as FAT/FAT32
|
||||||
|
|
||||||
|
### Display Shows Nothing
|
||||||
|
- Check SPI wiring and CS/DC/RST pins
|
||||||
|
- Verify backlight is connected and enabled
|
||||||
|
- Check voltage levels (3.3V logic)
|
||||||
|
|
||||||
|
## Features by Component
|
||||||
|
|
||||||
|
### Display Features
|
||||||
|
- 1-bit monochrome rendering
|
||||||
|
- RGB565 color support (ST7796)
|
||||||
|
- Drawing primitives (lines, rectangles, circles)
|
||||||
|
- GUI widgets (windows, gauges, status bars)
|
||||||
|
- Multiple font support
|
||||||
|
|
||||||
|
### Touch Features
|
||||||
|
- Multi-touch support (up to 2 points)
|
||||||
|
- Coordinate transformation
|
||||||
|
- Touch debouncing
|
||||||
|
- Event types (press, lift, contact)
|
||||||
|
|
||||||
|
### SD Card Features
|
||||||
|
- SPI mode support
|
||||||
|
- FatFS integration
|
||||||
|
- Directory listing
|
||||||
|
- File read/write
|
||||||
|
- Automatic timestamps from compile time
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
Copyright (c) 2021 Arm Limited and Contributors. All rights reserved.
|
||||||
|
SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
## Dependencies
|
||||||
|
|
||||||
|
- Raspberry Pi Pico SDK 2.2.0+
|
||||||
|
- FatFS (included)
|
||||||
|
- TinyUSB (via SDK)
|
||||||
|
- Hardware drivers (included in `lib/`)
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
When adding new features:
|
||||||
|
1. Follow the abstraction layer pattern
|
||||||
|
2. Update `board_config.h` for hardware settings
|
||||||
|
3. Keep application code hardware-agnostic
|
||||||
|
4. Test on multiple boards if possible
|
||||||
|
5. Update this README
|
||||||
+62
-250
@@ -8,17 +8,15 @@
|
|||||||
|
|
||||||
#include "pico/stdlib.h"
|
#include "pico/stdlib.h"
|
||||||
#include "pico/binary_info.h"
|
#include "pico/binary_info.h"
|
||||||
#include "st7796.h"
|
#include "board_config.h" // Board-specific pin configuration
|
||||||
#include "ft6336u.h"
|
|
||||||
#include "sd_card.h"
|
#include "sd_card.h"
|
||||||
#include "hardware/spi.h"
|
|
||||||
#include "hardware/i2c.h"
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "low_level_render.h"
|
#include "display/low_level_render.h"
|
||||||
#include "low_level_gui.h"
|
#include "display/low_level_gui.h"
|
||||||
#include "ff.h" // FatFS
|
#include "display/low_level_display.h"
|
||||||
|
#include "display/low_level_touch.h"
|
||||||
|
|
||||||
|
|
||||||
// Binary info for RP2350 - ensures proper boot image structure
|
// Binary info for RP2350 - ensures proper boot image structure
|
||||||
@@ -26,69 +24,9 @@ bi_decl(bi_program_description("4.0\" TFT ST7796 with Touch and SD Card Demo"));
|
|||||||
bi_decl(bi_program_version_string("0.1"));
|
bi_decl(bi_program_version_string("0.1"));
|
||||||
bi_decl(bi_program_build_date_string(__DATE__));
|
bi_decl(bi_program_build_date_string(__DATE__));
|
||||||
|
|
||||||
const int V_WIDTH = 480;
|
// Screen dimensions and configuration from board_config.h
|
||||||
const int V_HEIGHT = 320;
|
const int V_WIDTH = DISPLAY_WIDTH;
|
||||||
|
const int V_HEIGHT = DISPLAY_HEIGHT;
|
||||||
// Feather RP2350 with 4.0" TFT (480x320) ST7796 configuration
|
|
||||||
const struct st7796_config lcd_config = {
|
|
||||||
.spi = spi1,
|
|
||||||
.gpio_din = 11, // MOSI (D11)
|
|
||||||
.gpio_clk = 10, // SCK (D10)
|
|
||||||
.gpio_cs = 7, // CS (D13)
|
|
||||||
.gpio_dc = 4, // DC (D4)
|
|
||||||
.gpio_rst = 9, // RST (D9)
|
|
||||||
.gpio_bl = 6, // Backlight (D6)
|
|
||||||
};
|
|
||||||
|
|
||||||
// Touch screen configuration (adjust pins based on your wiring)
|
|
||||||
// Feather RP2350 I2C pin options:
|
|
||||||
// - I2C0: SDA can be GPIO0,4,8,12,16,20,24,28 / SCL can be GPIO1,5,9,13,17,21,25,29
|
|
||||||
// - I2C1: SDA can be GPIO2,6,10,14,18,22,26 / SCL can be GPIO3,7,11,15,19,23,27
|
|
||||||
// Note: GPIO2/3 are the Feather's default I2C pins (STEMMA QT connector)
|
|
||||||
// Using I2C1 to match GPIO2/3 pins
|
|
||||||
//
|
|
||||||
// Coordinate transformation options - adjust based on your screen orientation:
|
|
||||||
// Try different combinations if touch doesn't align:
|
|
||||||
// swap_xy=false, invert_x=false, invert_y=false (default)
|
|
||||||
// swap_xy=true, invert_x=false, invert_y=false (90° rotation)
|
|
||||||
// swap_xy=false, invert_x=true, invert_y=true (180° rotation)
|
|
||||||
// swap_xy=true, invert_x=true, invert_y=true (270° rotation)
|
|
||||||
const ft6336u_config_t touch_config = {
|
|
||||||
.i2c = i2c1, // Changed to i2c1 to match GPIO2/3
|
|
||||||
.gpio_sda = 2, // SDA (Feather I2C default, valid for I2C1)
|
|
||||||
.gpio_scl = 3, // SCL (Feather I2C default, valid for I2C1)
|
|
||||||
.gpio_rst = 28, // Touch RST (can use any free GPIO)
|
|
||||||
.gpio_int = 25, // Touch INT (can use any free GPIO)
|
|
||||||
.screen_width = V_WIDTH,
|
|
||||||
.screen_height = V_HEIGHT,
|
|
||||||
.swap_xy = true, // Try this first for landscape mode
|
|
||||||
.invert_x = true, // Adjust if X is backwards
|
|
||||||
.invert_y = false // Adjust if Y is backwards
|
|
||||||
};
|
|
||||||
|
|
||||||
// SD Card configuration (shares SPI with display)
|
|
||||||
const sd_card_config_t sd_config = {
|
|
||||||
.spi = spi1, // Same SPI as display
|
|
||||||
.gpio_cs = 5, // SD CS (adjust to your setup)
|
|
||||||
.gpio_miso = 24, // MISO (adjust to your setup)
|
|
||||||
.gpio_mosi = 11, // Same as display MOSI
|
|
||||||
.gpio_sck = 10 // Same as display SCK
|
|
||||||
};
|
|
||||||
|
|
||||||
const int lcd_width = V_WIDTH;
|
|
||||||
const int lcd_height = V_HEIGHT;
|
|
||||||
|
|
||||||
// RGB565 color definitions
|
|
||||||
#define COLOR_BLACK 0x0000
|
|
||||||
#define COLOR_WHITE 0xFFFF
|
|
||||||
#define COLOR_RED 0xF800
|
|
||||||
#define COLOR_GREEN 0x07E0
|
|
||||||
#define COLOR_BLUE 0x001F
|
|
||||||
#define COLOR_YELLOW 0xFFE0
|
|
||||||
#define COLOR_CYAN 0x07FF
|
|
||||||
#define COLOR_MAGENTA 0xF81F
|
|
||||||
#define COLOR_ORANGE 0xFC00
|
|
||||||
#define COLOR_PURPLE 0x8010
|
|
||||||
|
|
||||||
// Touch indicator settings
|
// Touch indicator settings
|
||||||
#define TOUCH_RADIUS 10
|
#define TOUCH_RADIUS 10
|
||||||
@@ -96,162 +34,20 @@ const int lcd_height = V_HEIGHT;
|
|||||||
uint8_t bit_buffer[V_WIDTH * V_HEIGHT / 8];
|
uint8_t bit_buffer[V_WIDTH * V_HEIGHT / 8];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Convert 1-bit buffer to RGB565 and refresh the screen
|
* @brief Refresh the screen with the 1-bit buffer
|
||||||
*
|
*
|
||||||
* Efficiently updates the entire display by:
|
* Displays work directly with 1-bit monochrome buffers.
|
||||||
* 1. Converting the 1-bit buffer to RGB565 format
|
* The display driver internally converts to its native format (RGB565, etc.)
|
||||||
* 2. Sending the entire frame in one bulk write operation
|
|
||||||
*
|
*
|
||||||
* @param buffer Pointer to 1-bit framebuffer (width*height/8 bytes)
|
* @param buffer Pointer to 1-bit framebuffer (width*height/8 bytes)
|
||||||
|
* @param display Pointer to display abstraction layer
|
||||||
*/
|
*/
|
||||||
void refresh_screen(const uint8_t *buffer) {
|
void refresh_screen(const uint8_t *buffer, LowLevelDisplay* display) {
|
||||||
// Allocate RGB565 buffer (2 bytes per pixel)
|
display->draw_buffer(buffer);
|
||||||
uint16_t *rgb_buffer = (uint16_t *)malloc(V_WIDTH * V_HEIGHT * sizeof(uint16_t));
|
display->refresh();
|
||||||
if (!rgb_buffer) {
|
|
||||||
printf("Error: Failed to allocate RGB buffer for screen refresh\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert bit buffer to RGB565
|
|
||||||
for (int y = 0; y < V_HEIGHT; y++) {
|
|
||||||
for (int x = 0; x < V_WIDTH; x++) {
|
|
||||||
int byte_index = (y * V_WIDTH + x) / 8;
|
|
||||||
int bit_index = 7 - (x % 8);
|
|
||||||
bool pixel_on = (buffer[byte_index] >> bit_index) & 0x01;
|
|
||||||
rgb_buffer[y * V_WIDTH + x] = pixel_on ? COLOR_WHITE : COLOR_BLACK;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw entire buffer at once - MUCH faster than pixel-by-pixel!
|
|
||||||
st7796_set_cursor(0, 0);
|
|
||||||
st7796_write(rgb_buffer, V_WIDTH * V_HEIGHT);
|
|
||||||
|
|
||||||
free(rgb_buffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Test SD card and FatFS functionality
|
|
||||||
*
|
|
||||||
* Initializes SD card, mounts FatFS, performs read/write tests,
|
|
||||||
* and safely unmounts the filesystem.
|
|
||||||
*/
|
|
||||||
void test_sd_card_and_fatfs(void) {
|
|
||||||
// Initialize SD card
|
|
||||||
bool sd_ok = sd_card_init(&sd_config);
|
|
||||||
if (!sd_ok) {
|
|
||||||
printf("SD Card initialization failed or no card present\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
sd_card_info_t sd_info;
|
|
||||||
sd_card_get_info(&sd_info);
|
|
||||||
printf("SD Card initialized: Type=%d\n", sd_info.type);
|
|
||||||
|
|
||||||
// Try to read first block
|
|
||||||
uint8_t buffer[512];
|
|
||||||
if (sd_card_read_block(0, buffer)) {
|
|
||||||
printf("Read block 0: ");
|
|
||||||
for (int i = 0; i < 16; i++) {
|
|
||||||
printf("%02X ", buffer[i]);
|
|
||||||
}
|
|
||||||
printf("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test FatFS filesystem
|
|
||||||
printf("\n=== FatFS Test ===\n");
|
|
||||||
FATFS fs;
|
|
||||||
FRESULT res = f_mount(&fs, "0:", 1); // Mount drive 0
|
|
||||||
|
|
||||||
if (res != FR_OK) {
|
|
||||||
printf("✗ FatFS mount failed (error: %d)\n", res);
|
|
||||||
printf(" Make sure SD card is formatted as FAT/FAT32\n");
|
|
||||||
printf("==================\n\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("✓ FatFS mounted successfully\n");
|
|
||||||
|
|
||||||
// Get volume information
|
|
||||||
DWORD fre_clust, fre_sect, tot_sect;
|
|
||||||
FATFS *fs_ptr;
|
|
||||||
res = f_getfree("0:", &fre_clust, &fs_ptr);
|
|
||||||
if (res == FR_OK) {
|
|
||||||
tot_sect = (fs_ptr->n_fatent - 2) * fs_ptr->csize;
|
|
||||||
fre_sect = fre_clust * fs_ptr->csize;
|
|
||||||
printf(" Total: %lu KB, Free: %lu KB\n",
|
|
||||||
tot_sect / 2, fre_sect / 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
// List root directory
|
|
||||||
printf("\nRoot directory contents:\n");
|
|
||||||
DIR dir;
|
|
||||||
FILINFO fno;
|
|
||||||
res = f_opendir(&dir, "/");
|
|
||||||
if (res == FR_OK) {
|
|
||||||
int file_count = 0;
|
|
||||||
while (1) {
|
|
||||||
res = f_readdir(&dir, &fno);
|
|
||||||
if (res != FR_OK || fno.fname[0] == 0) break;
|
|
||||||
|
|
||||||
printf(" %s %s (%lu bytes)\n",
|
|
||||||
(fno.fattrib & AM_DIR) ? "[DIR]" : "[FILE]",
|
|
||||||
fno.fname, fno.fsize);
|
|
||||||
file_count++;
|
|
||||||
|
|
||||||
if (file_count >= 10) {
|
|
||||||
printf(" ... (showing first 10 entries)\n");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
f_closedir(&dir);
|
|
||||||
|
|
||||||
if (file_count == 0) {
|
|
||||||
printf(" (empty)\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test file write
|
|
||||||
printf("\nTesting file write...\n");
|
|
||||||
FIL fil;
|
|
||||||
res = f_open(&fil, "test.txt", FA_CREATE_ALWAYS | FA_WRITE);
|
|
||||||
if (res == FR_OK) {
|
|
||||||
const char *test_str = "Hello from RP2350 with FatFS!\n";
|
|
||||||
UINT bytes_written;
|
|
||||||
res = f_write(&fil, test_str, strlen(test_str), &bytes_written);
|
|
||||||
f_close(&fil);
|
|
||||||
|
|
||||||
if (res == FR_OK) {
|
|
||||||
printf("✓ Wrote %u bytes to test.txt\n", bytes_written);
|
|
||||||
|
|
||||||
// Read it back
|
|
||||||
res = f_open(&fil, "test.txt", FA_READ);
|
|
||||||
if (res == FR_OK) {
|
|
||||||
char read_buffer[64];
|
|
||||||
UINT bytes_read;
|
|
||||||
res = f_read(&fil, read_buffer, sizeof(read_buffer)-1, &bytes_read);
|
|
||||||
f_close(&fil);
|
|
||||||
|
|
||||||
if (res == FR_OK) {
|
|
||||||
read_buffer[bytes_read] = '\0';
|
|
||||||
printf("✓ Read back: %s", read_buffer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
printf("✗ Failed to create test.txt (error: %d)\n", res);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Safely unmount filesystem
|
|
||||||
printf("\nUnmounting filesystem...\n");
|
|
||||||
res = f_unmount("0:");
|
|
||||||
if (res == FR_OK) {
|
|
||||||
printf("✓ Filesystem unmounted successfully\n");
|
|
||||||
} else {
|
|
||||||
printf("✗ Unmount failed (error: %d)\n", res);
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("==================\n\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
@@ -261,11 +57,27 @@ int main()
|
|||||||
stdio_init_all();
|
stdio_init_all();
|
||||||
sleep_ms(5000); // Wait for USB connection (if present)
|
sleep_ms(5000); // Wait for USB connection (if present)
|
||||||
|
|
||||||
|
printf("\n=== %s Demo ===\n", BOARD_NAME);
|
||||||
|
|
||||||
|
// Create display abstraction using factory method
|
||||||
|
// The factory handles all board-specific configuration internally
|
||||||
|
LowLevelDisplay* display = LowLevelDisplay::create((DisplayType)DISPLAY_TYPE_SELECTED, V_WIDTH, V_HEIGHT);
|
||||||
|
|
||||||
|
if (!display) {
|
||||||
|
printf("Failed to create display!\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
printf("Initializing 4.0\" TFT with Touch and SD Card...\n");
|
printf("Initializing 4.0\" TFT with Touch and SD Card...\n");
|
||||||
|
|
||||||
// Initialize the LCD
|
// Initialize the display
|
||||||
st7796_init(&lcd_config, lcd_width, lcd_height);
|
if (!display->init()) {
|
||||||
st7796_fill(COLOR_BLACK);
|
printf("Display initialization failed!\n");
|
||||||
|
delete display;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
display->clear(false); // Clear to black
|
||||||
|
|
||||||
LowLevelRenderer renderer(bit_buffer, V_WIDTH, V_HEIGHT);
|
LowLevelRenderer renderer(bit_buffer, V_WIDTH, V_HEIGHT);
|
||||||
renderer.set_font(&font_5x5_obj);
|
renderer.set_font(&font_5x5_obj);
|
||||||
@@ -276,31 +88,32 @@ int main()
|
|||||||
gui.draw_circular_gauge(w1, 10, 100 - 10, 200, "SYSTEM EFF.", 68);
|
gui.draw_circular_gauge(w1, 10, 100 - 10, 200, "SYSTEM EFF.", 68);
|
||||||
|
|
||||||
// Refresh the screen with the rendered GUI
|
// Refresh the screen with the rendered GUI
|
||||||
refresh_screen(bit_buffer);
|
refresh_screen(bit_buffer, display);
|
||||||
|
|
||||||
// Initialize touch screen
|
// Initialize touch screen using abstraction
|
||||||
bool touch_ok = ft6336u_init(&touch_config);
|
LowLevelTouch* touch = LowLevelTouch::create((TouchType)TOUCH_TYPE_SELECTED, V_WIDTH, V_HEIGHT,
|
||||||
if (touch_ok) {
|
TOUCH_SWAP_XY, TOUCH_INVERT_X, TOUCH_INVERT_Y);
|
||||||
uint8_t chip_id = ft6336u_get_chip_id();
|
|
||||||
uint8_t fw_ver = ft6336u_get_firmware_version();
|
if (touch) {
|
||||||
printf("Touch initialized: Chip ID=0x%02X, FW Ver=0x%02X\n", chip_id, fw_ver);
|
printf("Touch initialized successfully\n");
|
||||||
|
|
||||||
// Run I2C communication test
|
// Run communication test if available
|
||||||
printf("\nRunning I2C reliability test...\n");
|
printf("\nRunning touch reliability test...\n");
|
||||||
ft6336u_test_i2c();
|
touch->test_communication();
|
||||||
printf("\n");
|
printf("\n");
|
||||||
} else {
|
} else {
|
||||||
printf("Touch initialization failed!\n");
|
printf("Touch initialization failed or not configured\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test SD card and FatFS
|
// Test SD card and FatFS
|
||||||
test_sd_card_and_fatfs();
|
if (sd_card_init_with_board_config()) {
|
||||||
|
sd_card_test_fatfs();
|
||||||
|
} else {
|
||||||
|
printf("SD Card initialization failed or no card present\n");
|
||||||
|
}
|
||||||
|
|
||||||
// Main loop - handle touch events
|
// Main loop - handle touch events
|
||||||
int last_x = -1, last_y = -1;
|
int last_x = -1, last_y = -1;
|
||||||
uint16_t current_color = COLOR_CYAN;
|
|
||||||
int color_index = 0;
|
|
||||||
uint16_t colors[] = {COLOR_CYAN, COLOR_YELLOW, COLOR_MAGENTA, COLOR_GREEN, COLOR_RED};
|
|
||||||
|
|
||||||
// Touch debouncing
|
// Touch debouncing
|
||||||
uint32_t last_touch_time = 0;
|
uint32_t last_touch_time = 0;
|
||||||
@@ -320,13 +133,13 @@ int main()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_touched = touch_ok && ft6336u_is_touched();
|
bool is_touched = touch && touch->is_touched();
|
||||||
|
|
||||||
// Only process touch if state changed or still touching
|
// Only process touch if state changed or still touching
|
||||||
if (is_touched) {
|
if (is_touched) {
|
||||||
ft6336u_touch_data_t touch_data;
|
TouchData touch_data;
|
||||||
|
|
||||||
if (ft6336u_read_touch(&touch_data)) {
|
if (touch->read_touch(&touch_data)) {
|
||||||
touch_success_count++;
|
touch_success_count++;
|
||||||
|
|
||||||
if (touch_data.touch_count > 0) {
|
if (touch_data.touch_count > 0) {
|
||||||
@@ -340,18 +153,16 @@ int main()
|
|||||||
touch_success_count, touch_fail_count);
|
touch_success_count, touch_fail_count);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
// Check if touch is in title area to change color
|
// Check if touch is in title area to clear screen
|
||||||
if (y < 30) {
|
if (y < 30) {
|
||||||
if (!was_touched) { // Only on new touch
|
if (!was_touched) { // Only on new touch
|
||||||
color_index = (color_index + 1) % 5;
|
// Clear drawing area in bit buffer
|
||||||
current_color = colors[color_index];
|
renderer.draw_filled_rectangle(11, 130, V_WIDTH - 11 - 11, V_HEIGHT - 11 - 130, false, 1);
|
||||||
|
refresh_screen(bit_buffer, display);
|
||||||
// Clear drawing area
|
printf("Drawing area cleared\n");
|
||||||
st7796_fill_rect(11, 130, lcd_width - 11, lcd_height - 11, COLOR_BLACK);
|
|
||||||
printf("Color changed to index %d\n", color_index);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Draw in touch area
|
// Draw in touch area (white line)
|
||||||
else if (y > 100) {
|
else if (y > 100) {
|
||||||
|
|
||||||
// Draw line from last position (for smooth drawing)
|
// Draw line from last position (for smooth drawing)
|
||||||
@@ -360,7 +171,8 @@ int main()
|
|||||||
int dy = abs(y - last_y);
|
int dy = abs(y - last_y);
|
||||||
// Only draw line if movement is reasonable (filter noise)
|
// Only draw line if movement is reasonable (filter noise)
|
||||||
if (dx < 50 && dy < 50) {
|
if (dx < 50 && dy < 50) {
|
||||||
st7796_draw_line(last_x, last_y, x, y, current_color);
|
renderer.draw_line(last_x, last_y, x, y, true);
|
||||||
|
refresh_screen(bit_buffer, display);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
+126
@@ -0,0 +1,126 @@
|
|||||||
|
#ifndef BOARD_CONFIG_H
|
||||||
|
#define BOARD_CONFIG_H
|
||||||
|
|
||||||
|
#include "pico/stdlib.h"
|
||||||
|
|
||||||
|
// Forward declare display and touch types (actual enums in respective headers)
|
||||||
|
// Display options: DISPLAY_TYPE_ST7796, DISPLAY_TYPE_ST7789, DISPLAY_TYPE_EPAPER
|
||||||
|
// Touch options: TOUCH_TYPE_FT6336U, TOUCH_TYPE_NONE
|
||||||
|
|
||||||
|
// Board-specific pin definitions and configurations
|
||||||
|
|
||||||
|
#if defined(PICO_BOARD_ADAFRUIT_FEATHER_RP2350)
|
||||||
|
// Adafruit Feather RP2350 pinout
|
||||||
|
#define BOARD_NAME "Adafruit Feather RP2350"
|
||||||
|
|
||||||
|
// Display configuration
|
||||||
|
#define DISPLAY_WIDTH 480
|
||||||
|
#define DISPLAY_HEIGHT 320
|
||||||
|
#define DISPLAY_TYPE_SELECTED 0 // DISPLAY_TYPE_ST7796
|
||||||
|
|
||||||
|
// Touch configuration
|
||||||
|
#define TOUCH_TYPE_SELECTED 0 // TOUCH_TYPE_FT6336U
|
||||||
|
#define TOUCH_SWAP_XY true
|
||||||
|
#define TOUCH_INVERT_X true
|
||||||
|
#define TOUCH_INVERT_Y false
|
||||||
|
|
||||||
|
// SPI pins for display
|
||||||
|
#define DISPLAY_SPI_PORT spi1
|
||||||
|
#define DISPLAY_SCK_PIN 18
|
||||||
|
#define DISPLAY_MOSI_PIN 19
|
||||||
|
#define DISPLAY_MISO_PIN 20
|
||||||
|
#define DISPLAY_CS_PIN 17
|
||||||
|
#define DISPLAY_DC_PIN 16
|
||||||
|
#define DISPLAY_RST_PIN 15
|
||||||
|
#define DISPLAY_BL_PIN 14
|
||||||
|
#define DISPLAY_BUSY_PIN 13 // For e-paper displays
|
||||||
|
|
||||||
|
// I2C pins for touch
|
||||||
|
#define TOUCH_I2C_PORT i2c0
|
||||||
|
#define TOUCH_SDA_PIN 4
|
||||||
|
#define TOUCH_SCL_PIN 5
|
||||||
|
#define TOUCH_INT_PIN 6
|
||||||
|
#define TOUCH_RST_PIN 7
|
||||||
|
|
||||||
|
// SD card pins (shared SPI with display)
|
||||||
|
#define SD_SPI_PORT spi1
|
||||||
|
#define SD_CS_PIN 10
|
||||||
|
|
||||||
|
#elif defined(PICO_BOARD) && (PICO_BOARD == pico2 || PICO_BOARD == pico2_w)
|
||||||
|
// Raspberry Pi Pico 2 / Pico 2 W pinout
|
||||||
|
#define BOARD_NAME "Raspberry Pi Pico 2"
|
||||||
|
|
||||||
|
// Display configuration
|
||||||
|
#define DISPLAY_WIDTH 480
|
||||||
|
#define DISPLAY_HEIGHT 320
|
||||||
|
#define DISPLAY_TYPE_SELECTED 0 // DISPLAY_TYPE_ST7796
|
||||||
|
|
||||||
|
// Touch configuration
|
||||||
|
#define TOUCH_TYPE_SELECTED 0 // TOUCH_TYPE_FT6336U
|
||||||
|
#define TOUCH_SWAP_XY true
|
||||||
|
#define TOUCH_INVERT_X true
|
||||||
|
#define TOUCH_INVERT_Y false
|
||||||
|
|
||||||
|
// SPI pins for display (using SPI0)
|
||||||
|
#define DISPLAY_SPI_PORT spi0
|
||||||
|
#define DISPLAY_SCK_PIN 2 // GP2
|
||||||
|
#define DISPLAY_MOSI_PIN 3 // GP3
|
||||||
|
#define DISPLAY_MISO_PIN 4 // GP4
|
||||||
|
#define DISPLAY_CS_PIN 5 // GP5
|
||||||
|
#define DISPLAY_DC_PIN 6 // GP6
|
||||||
|
#define DISPLAY_RST_PIN 7 // GP7
|
||||||
|
#define DISPLAY_BL_PIN 8 // GP8
|
||||||
|
#define DISPLAY_BUSY_PIN 9 // GP9 - For e-paper displays
|
||||||
|
|
||||||
|
// I2C pins for touch (using I2C0)
|
||||||
|
#define TOUCH_I2C_PORT i2c0
|
||||||
|
#define TOUCH_SDA_PIN 12 // GP12
|
||||||
|
#define TOUCH_SCL_PIN 13 // GP13
|
||||||
|
#define TOUCH_INT_PIN 14 // GP14
|
||||||
|
#define TOUCH_RST_PIN 15 // GP15
|
||||||
|
|
||||||
|
// SD card pins (separate SPI1)
|
||||||
|
#define SD_SPI_PORT spi1
|
||||||
|
#define SD_CS_PIN 17 // GP17
|
||||||
|
|
||||||
|
#else
|
||||||
|
#warning "Unknown board! Using default Pico 2 pinout"
|
||||||
|
#define BOARD_NAME "Unknown Board (Pico 2 defaults)"
|
||||||
|
|
||||||
|
// Display configuration
|
||||||
|
#define DISPLAY_WIDTH 480
|
||||||
|
#define DISPLAY_HEIGHT 320
|
||||||
|
#define DISPLAY_TYPE_SELECTED 0 // DISPLAY_TYPE_ST7796
|
||||||
|
|
||||||
|
// Touch configuration
|
||||||
|
#define TOUCH_TYPE_SELECTED 0 // TOUCH_TYPE_FT6336U
|
||||||
|
#define TOUCH_SWAP_XY true
|
||||||
|
#define TOUCH_INVERT_X true
|
||||||
|
#define TOUCH_INVERT_Y false
|
||||||
|
|
||||||
|
// Default to Pico 2 pinout
|
||||||
|
#define DISPLAY_SPI_PORT spi0
|
||||||
|
#define DISPLAY_SCK_PIN 2
|
||||||
|
#define DISPLAY_MOSI_PIN 3
|
||||||
|
#define DISPLAY_MISO_PIN 4
|
||||||
|
#define DISPLAY_CS_PIN 5
|
||||||
|
#define DISPLAY_DC_PIN 6
|
||||||
|
#define DISPLAY_RST_PIN 7
|
||||||
|
#define DISPLAY_BL_PIN 8
|
||||||
|
#define DISPLAY_BUSY_PIN 9 // For e-paper displays
|
||||||
|
|
||||||
|
#define TOUCH_I2C_PORT i2c0
|
||||||
|
#define TOUCH_SDA_PIN 12
|
||||||
|
#define TOUCH_SCL_PIN 13
|
||||||
|
#define TOUCH_INT_PIN 14
|
||||||
|
#define TOUCH_RST_PIN 15
|
||||||
|
|
||||||
|
#define SD_SPI_PORT spi1
|
||||||
|
#define SD_CS_PIN 17
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Common configuration
|
||||||
|
#define SPI_BAUDRATE (32 * 1000 * 1000) // 32 MHz for display
|
||||||
|
#define I2C_BAUDRATE (400 * 1000) // 400 kHz for touch
|
||||||
|
|
||||||
|
#endif // BOARD_CONFIG_H
|
||||||
+2
-2
@@ -2,8 +2,8 @@
|
|||||||
/* Low level disk I/O module for FatFs with SD card support */
|
/* Low level disk I/O module for FatFs with SD card support */
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "fatfs/source/ff.h"
|
#include "ff.h"
|
||||||
#include "fatfs/source/diskio.h"
|
#include "diskio.h"
|
||||||
#include "sd_card.h"
|
#include "sd_card.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
#ifndef LOW_LEVEL_DISPLAY_H
|
||||||
|
#define LOW_LEVEL_DISPLAY_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
// Display type enumeration
|
||||||
|
typedef enum {
|
||||||
|
DISPLAY_TYPE_ST7796,
|
||||||
|
DISPLAY_TYPE_ST7789,
|
||||||
|
DISPLAY_TYPE_EPAPER
|
||||||
|
} DisplayType;
|
||||||
|
|
||||||
|
// Abstract display interface
|
||||||
|
class LowLevelDisplay {
|
||||||
|
public:
|
||||||
|
virtual ~LowLevelDisplay() {}
|
||||||
|
|
||||||
|
// Core display operations - all work with 1-bit monochrome buffers
|
||||||
|
virtual bool init() = 0;
|
||||||
|
virtual void clear(bool white = true) = 0; // Clear to white or black
|
||||||
|
virtual void draw_pixel(int x, int y, bool white) = 0;
|
||||||
|
virtual void draw_buffer(const uint8_t* bit_buffer) = 0; // 1-bit buffer (width*height/8 bytes)
|
||||||
|
virtual void refresh() = 0; // Update display (converts 1-bit to native format)
|
||||||
|
|
||||||
|
// Display properties
|
||||||
|
virtual int get_width() const = 0;
|
||||||
|
virtual int get_height() const = 0;
|
||||||
|
virtual DisplayType get_type() const = 0;
|
||||||
|
virtual bool is_color() const = 0;
|
||||||
|
|
||||||
|
// Optional: Backlight control (if supported)
|
||||||
|
virtual void set_backlight(bool on) { (void)on; }
|
||||||
|
|
||||||
|
// Optional: Orientation control (not commonly needed for bitmap displays)
|
||||||
|
virtual void set_rotation(uint8_t rotation) { (void)rotation; }
|
||||||
|
|
||||||
|
// Factory method - creates display based on type, using board_config.h for pins
|
||||||
|
static LowLevelDisplay* create(DisplayType type, int width, int height);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LOW_LEVEL_DISPLAY_H
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
#include "low_level_display_epaper.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
// Note: This is a placeholder implementation
|
||||||
|
// You'll need to add the actual e-paper driver code to lib/epaper/
|
||||||
|
|
||||||
|
LowLevelDisplayEPaper::LowLevelDisplayEPaper(const epaper_config* cfg, int w, int h)
|
||||||
|
: config(cfg), width(w), height(h), initialized(false), framebuffer(nullptr), dirty(false) {
|
||||||
|
|
||||||
|
// Allocate framebuffer (1 bit per pixel for monochrome e-paper)
|
||||||
|
int buffer_size = (width * height + 7) / 8; // Round up to nearest byte
|
||||||
|
framebuffer = (uint8_t*)malloc(buffer_size);
|
||||||
|
if (framebuffer) {
|
||||||
|
memset(framebuffer, 0xFF, buffer_size); // White
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LowLevelDisplayEPaper::~LowLevelDisplayEPaper() {
|
||||||
|
if (framebuffer) {
|
||||||
|
free(framebuffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LowLevelDisplayEPaper::init() {
|
||||||
|
if (initialized) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!framebuffer) {
|
||||||
|
printf("Failed to allocate framebuffer for e-paper display\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Implement e-paper initialization
|
||||||
|
// epaper_init(config, width, height);
|
||||||
|
printf("E-paper display initialized: %dx%d (stub)\n", width, height);
|
||||||
|
initialized = true;
|
||||||
|
return false; // Return false until actual driver is implemented
|
||||||
|
}
|
||||||
|
|
||||||
|
void LowLevelDisplayEPaper::clear(bool white) {
|
||||||
|
if (!framebuffer) return;
|
||||||
|
|
||||||
|
int buffer_size = (width * height + 7) / 8;
|
||||||
|
memset(framebuffer, white ? 0xFF : 0x00, buffer_size);
|
||||||
|
dirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LowLevelDisplayEPaper::draw_pixel(int x, int y, bool white) {
|
||||||
|
if (!framebuffer || x < 0 || x >= width || y < 0 || y >= height) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int byte_index = (y * width + x) / 8;
|
||||||
|
int bit_index = 7 - ((y * width + x) % 8);
|
||||||
|
|
||||||
|
if (white) {
|
||||||
|
framebuffer[byte_index] |= (1 << bit_index);
|
||||||
|
} else {
|
||||||
|
framebuffer[byte_index] &= ~(1 << bit_index);
|
||||||
|
}
|
||||||
|
|
||||||
|
dirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LowLevelDisplayEPaper::draw_buffer(const uint8_t* bit_buffer) {
|
||||||
|
if (!bit_buffer || !framebuffer) return;
|
||||||
|
|
||||||
|
// Direct copy of 1-bit buffer
|
||||||
|
int buffer_size = (width * height + 7) / 8;
|
||||||
|
memcpy(framebuffer, bit_buffer, buffer_size);
|
||||||
|
dirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LowLevelDisplayEPaper::refresh() {
|
||||||
|
if (!dirty || !framebuffer) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Implement actual e-paper refresh
|
||||||
|
// epaper_update(framebuffer);
|
||||||
|
printf("E-paper refresh (stub)\n");
|
||||||
|
|
||||||
|
dirty = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LowLevelDisplayEPaper::clear_display() {
|
||||||
|
clear(true); // Fill with white
|
||||||
|
refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LowLevelDisplayEPaper::sleep() {
|
||||||
|
// TODO: Implement e-paper sleep mode
|
||||||
|
// epaper_sleep();
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
#ifndef LOW_LEVEL_DISPLAY_EPAPER_H
|
||||||
|
#define LOW_LEVEL_DISPLAY_EPAPER_H
|
||||||
|
|
||||||
|
#include "low_level_display.h"
|
||||||
|
|
||||||
|
// E-paper display configuration structure
|
||||||
|
struct epaper_config {
|
||||||
|
void* spi; // SPI instance
|
||||||
|
int gpio_din; // MOSI pin
|
||||||
|
int gpio_clk; // Clock pin
|
||||||
|
int gpio_cs; // Chip select pin
|
||||||
|
int gpio_dc; // Data/Command pin
|
||||||
|
int gpio_rst; // Reset pin
|
||||||
|
int gpio_busy; // Busy pin
|
||||||
|
};
|
||||||
|
|
||||||
|
class LowLevelDisplayEPaper : public LowLevelDisplay {
|
||||||
|
private:
|
||||||
|
const epaper_config* config;
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
bool initialized;
|
||||||
|
uint8_t* framebuffer; // E-paper needs a framebuffer
|
||||||
|
bool dirty; // Track if display needs refresh
|
||||||
|
|
||||||
|
public:
|
||||||
|
LowLevelDisplayEPaper(const epaper_config* cfg, int w, int h);
|
||||||
|
~LowLevelDisplayEPaper() override;
|
||||||
|
|
||||||
|
// Core display operations - native 1-bit monochrome
|
||||||
|
bool init() override;
|
||||||
|
void clear(bool white = true) override;
|
||||||
|
void draw_pixel(int x, int y, bool white) override;
|
||||||
|
void draw_buffer(const uint8_t* bit_buffer) override;
|
||||||
|
void refresh() override; // Actually update the e-paper display
|
||||||
|
|
||||||
|
// Display properties
|
||||||
|
int get_width() const override { return width; }
|
||||||
|
int get_height() const override { return height; }
|
||||||
|
DisplayType get_type() const override { return DISPLAY_TYPE_EPAPER; }
|
||||||
|
bool is_color() const override { return false; } // Most e-paper is monochrome
|
||||||
|
|
||||||
|
// E-paper specific
|
||||||
|
void clear_display();
|
||||||
|
void sleep(); // Put display in low power mode
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LOW_LEVEL_DISPLAY_EPAPER_H
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
#include "low_level_display.h"
|
||||||
|
#include "board_config.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
// Include display implementations based on what's available
|
||||||
|
#include "low_level_display_st7796.h"
|
||||||
|
#include "low_level_display_st7789.h"
|
||||||
|
#include "low_level_display_epaper.h"
|
||||||
|
|
||||||
|
// Factory method - creates display with board-specific configuration
|
||||||
|
LowLevelDisplay* LowLevelDisplay::create(DisplayType type, int width, int height) {
|
||||||
|
switch (type) {
|
||||||
|
case DISPLAY_TYPE_ST7796: {
|
||||||
|
// Create ST7796 configuration from board_config.h
|
||||||
|
static const st7796_config lcd_config = {
|
||||||
|
.spi = DISPLAY_SPI_PORT,
|
||||||
|
.gpio_din = DISPLAY_MOSI_PIN,
|
||||||
|
.gpio_clk = DISPLAY_SCK_PIN,
|
||||||
|
.gpio_cs = DISPLAY_CS_PIN,
|
||||||
|
.gpio_dc = DISPLAY_DC_PIN,
|
||||||
|
.gpio_rst = DISPLAY_RST_PIN,
|
||||||
|
.gpio_bl = DISPLAY_BL_PIN,
|
||||||
|
};
|
||||||
|
printf("Creating ST7796 display (%dx%d)\n", width, height);
|
||||||
|
return new LowLevelDisplayST7796(&lcd_config, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
case DISPLAY_TYPE_ST7789: {
|
||||||
|
// Create ST7789 configuration from board_config.h
|
||||||
|
static const st7789_config st7789_cfg = {
|
||||||
|
.spi = DISPLAY_SPI_PORT,
|
||||||
|
.gpio_din = DISPLAY_MOSI_PIN,
|
||||||
|
.gpio_clk = DISPLAY_SCK_PIN,
|
||||||
|
.gpio_cs = DISPLAY_CS_PIN,
|
||||||
|
.gpio_dc = DISPLAY_DC_PIN,
|
||||||
|
.gpio_rst = DISPLAY_RST_PIN,
|
||||||
|
.gpio_bl = DISPLAY_BL_PIN,
|
||||||
|
};
|
||||||
|
printf("Creating ST7789 display (%dx%d) - STUB (driver not implemented)\n", width, height);
|
||||||
|
return new LowLevelDisplayST7789(&st7789_cfg, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
case DISPLAY_TYPE_EPAPER: {
|
||||||
|
// Create E-Paper configuration from board_config.h
|
||||||
|
static const epaper_config epaper_cfg = {
|
||||||
|
.spi = DISPLAY_SPI_PORT,
|
||||||
|
.gpio_din = DISPLAY_MOSI_PIN,
|
||||||
|
.gpio_clk = DISPLAY_SCK_PIN,
|
||||||
|
.gpio_cs = DISPLAY_CS_PIN,
|
||||||
|
.gpio_dc = DISPLAY_DC_PIN,
|
||||||
|
.gpio_rst = DISPLAY_RST_PIN,
|
||||||
|
.gpio_busy = DISPLAY_BUSY_PIN,
|
||||||
|
};
|
||||||
|
printf("Creating E-Paper display (%dx%d) - STUB (driver not implemented)\n", width, height);
|
||||||
|
return new LowLevelDisplayEPaper(&epaper_cfg, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
printf("Error: Unknown display type %d\n", type);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
#include "low_level_display_st7789.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
// Note: This is a placeholder implementation
|
||||||
|
// You'll need to add the actual ST7789 driver code to lib/st7789/
|
||||||
|
|
||||||
|
LowLevelDisplayST7789::LowLevelDisplayST7789(const st7789_config* cfg, int w, int h)
|
||||||
|
: config(cfg), width(w), height(h), initialized(false) {
|
||||||
|
}
|
||||||
|
|
||||||
|
LowLevelDisplayST7789::~LowLevelDisplayST7789() {
|
||||||
|
// Cleanup if needed
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LowLevelDisplayST7789::init() {
|
||||||
|
if (initialized) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Implement ST7789 initialization
|
||||||
|
// st7789_init(config, width, height);
|
||||||
|
printf("ST7789 display initialized: %dx%d (stub)\n", width, height);
|
||||||
|
initialized = true;
|
||||||
|
return false; // Return false until actual driver is implemented
|
||||||
|
}
|
||||||
|
|
||||||
|
void LowLevelDisplayST7789::clear(bool white) {
|
||||||
|
// TODO: Implement
|
||||||
|
(void)white;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LowLevelDisplayST7789::draw_pixel(int x, int y, bool white) {
|
||||||
|
// TODO: Implement
|
||||||
|
(void)x; (void)y; (void)white;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LowLevelDisplayST7789::draw_buffer(const uint8_t* bit_buffer) {
|
||||||
|
// TODO: Implement - convert 1-bit to RGB565 and write
|
||||||
|
(void)bit_buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LowLevelDisplayST7789::refresh() {
|
||||||
|
// ST7789 updates immediately
|
||||||
|
}
|
||||||
|
|
||||||
|
void LowLevelDisplayST7789::set_backlight(bool on) {
|
||||||
|
// TODO: Implement
|
||||||
|
(void)on;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LowLevelDisplayST7789::set_rotation(uint8_t rotation) {
|
||||||
|
// TODO: Implement
|
||||||
|
(void)rotation;
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
#ifndef LOW_LEVEL_DISPLAY_ST7789_H
|
||||||
|
#define LOW_LEVEL_DISPLAY_ST7789_H
|
||||||
|
|
||||||
|
#include "low_level_display.h"
|
||||||
|
|
||||||
|
// ST7789 configuration structure (similar to ST7796)
|
||||||
|
struct st7789_config {
|
||||||
|
void* spi; // SPI instance
|
||||||
|
int gpio_din; // MOSI pin
|
||||||
|
int gpio_clk; // Clock pin
|
||||||
|
int gpio_cs; // Chip select pin
|
||||||
|
int gpio_dc; // Data/Command pin
|
||||||
|
int gpio_rst; // Reset pin
|
||||||
|
int gpio_bl; // Backlight pin
|
||||||
|
};
|
||||||
|
|
||||||
|
class LowLevelDisplayST7789 : public LowLevelDisplay {
|
||||||
|
private:
|
||||||
|
const st7789_config* config;
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
bool initialized;
|
||||||
|
|
||||||
|
public:
|
||||||
|
LowLevelDisplayST7789(const st7789_config* cfg, int w, int h);
|
||||||
|
~LowLevelDisplayST7789() override;
|
||||||
|
|
||||||
|
// Core display operations - converts 1-bit to RGB565 internally
|
||||||
|
bool init() override;
|
||||||
|
void clear(bool white = true) override;
|
||||||
|
void draw_pixel(int x, int y, bool white) override;
|
||||||
|
void draw_buffer(const uint8_t* bit_buffer) override;
|
||||||
|
void refresh() override;
|
||||||
|
|
||||||
|
// Display properties
|
||||||
|
int get_width() const override { return width; }
|
||||||
|
int get_height() const override { return height; }
|
||||||
|
DisplayType get_type() const override { return DISPLAY_TYPE_ST7789; }
|
||||||
|
bool is_color() const override { return true; }
|
||||||
|
|
||||||
|
// Backlight control
|
||||||
|
void set_backlight(bool on) override;
|
||||||
|
|
||||||
|
// Orientation control
|
||||||
|
void set_rotation(uint8_t rotation) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LOW_LEVEL_DISPLAY_ST7789_H
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
#include "low_level_display_st7796.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
// RGB565 color definitions
|
||||||
|
#define COLOR_BLACK 0x0000
|
||||||
|
#define COLOR_WHITE 0xFFFF
|
||||||
|
|
||||||
|
LowLevelDisplayST7796::LowLevelDisplayST7796(const st7796_config* cfg, int w, int h)
|
||||||
|
: config(cfg), width(w), height(h), initialized(false) {
|
||||||
|
}
|
||||||
|
|
||||||
|
LowLevelDisplayST7796::~LowLevelDisplayST7796() {
|
||||||
|
// Cleanup if needed
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LowLevelDisplayST7796::init() {
|
||||||
|
if (initialized) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
st7796_init(config, width, height);
|
||||||
|
initialized = true;
|
||||||
|
printf("ST7796 display initialized: %dx%d\n", width, height);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LowLevelDisplayST7796::clear(bool white) {
|
||||||
|
st7796_fill(white ? COLOR_WHITE : COLOR_BLACK);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LowLevelDisplayST7796::draw_pixel(int x, int y, bool white) {
|
||||||
|
st7796_draw_pixel(x, y, white ? COLOR_WHITE : COLOR_BLACK);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LowLevelDisplayST7796::draw_buffer(const uint8_t* bit_buffer) {
|
||||||
|
if (!bit_buffer) return;
|
||||||
|
|
||||||
|
// Allocate RGB565 buffer for entire screen
|
||||||
|
uint16_t *rgb_buffer = (uint16_t *)malloc(width * height * sizeof(uint16_t));
|
||||||
|
if (!rgb_buffer) {
|
||||||
|
printf("Error: Failed to allocate RGB buffer\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert 1-bit buffer to RGB565
|
||||||
|
for (int y = 0; y < height; y++) {
|
||||||
|
for (int x = 0; x < width; x++) {
|
||||||
|
int byte_index = (y * width + x) / 8;
|
||||||
|
int bit_index = 7 - (x % 8);
|
||||||
|
bool pixel_white = (bit_buffer[byte_index] >> bit_index) & 0x01;
|
||||||
|
rgb_buffer[y * width + x] = pixel_white ? COLOR_WHITE : COLOR_BLACK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw entire buffer at once
|
||||||
|
st7796_set_cursor(0, 0);
|
||||||
|
st7796_write(rgb_buffer, width * height);
|
||||||
|
|
||||||
|
free(rgb_buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LowLevelDisplayST7796::refresh() {
|
||||||
|
// ST7796 updates immediately, no refresh needed
|
||||||
|
}
|
||||||
|
|
||||||
|
void LowLevelDisplayST7796::set_backlight(bool on) {
|
||||||
|
// ST7796 driver doesn't have backlight control yet
|
||||||
|
// TODO: Add GPIO control for backlight pin
|
||||||
|
(void)on;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LowLevelDisplayST7796::set_rotation(uint8_t rotation) {
|
||||||
|
// ST7796 driver doesn't have rotation control yet
|
||||||
|
// TODO: Add MADCTL register manipulation for rotation
|
||||||
|
(void)rotation;
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
#ifndef LOW_LEVEL_DISPLAY_ST7796_H
|
||||||
|
#define LOW_LEVEL_DISPLAY_ST7796_H
|
||||||
|
|
||||||
|
#include "low_level_display.h"
|
||||||
|
#include "st7796.h"
|
||||||
|
|
||||||
|
class LowLevelDisplayST7796 : public LowLevelDisplay {
|
||||||
|
private:
|
||||||
|
const st7796_config* config;
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
bool initialized;
|
||||||
|
|
||||||
|
public:
|
||||||
|
LowLevelDisplayST7796(const st7796_config* cfg, int w, int h);
|
||||||
|
~LowLevelDisplayST7796() override;
|
||||||
|
|
||||||
|
// Core display operations - converts 1-bit to RGB565 internally
|
||||||
|
bool init() override;
|
||||||
|
void clear(bool white = true) override;
|
||||||
|
void draw_pixel(int x, int y, bool white) override;
|
||||||
|
void draw_buffer(const uint8_t* bit_buffer) override;
|
||||||
|
void refresh() override;
|
||||||
|
|
||||||
|
// Display properties
|
||||||
|
int get_width() const override { return width; }
|
||||||
|
int get_height() const override { return height; }
|
||||||
|
DisplayType get_type() const override { return DISPLAY_TYPE_ST7796; }
|
||||||
|
bool is_color() const override { return true; }
|
||||||
|
|
||||||
|
// Backlight control
|
||||||
|
void set_backlight(bool on) override;
|
||||||
|
|
||||||
|
// Orientation control
|
||||||
|
void set_rotation(uint8_t rotation) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LOW_LEVEL_DISPLAY_ST7796_H
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
#ifndef LOW_LEVEL_TOUCH_H
|
||||||
|
#define LOW_LEVEL_TOUCH_H
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
using std::int16_t;
|
||||||
|
using std::uint8_t;
|
||||||
|
using std::uint32_t;
|
||||||
|
|
||||||
|
// Touch driver type enumeration
|
||||||
|
typedef enum {
|
||||||
|
TOUCH_TYPE_FT6336U,
|
||||||
|
TOUCH_TYPE_NONE // For boards without touch
|
||||||
|
} TouchType;
|
||||||
|
|
||||||
|
// Maximum touch points (most capacitive touch controllers support 1-5 points)
|
||||||
|
#define TOUCH_MAX_POINTS 2
|
||||||
|
|
||||||
|
// Touch event types
|
||||||
|
typedef enum {
|
||||||
|
TOUCH_EVENT_PRESS_DOWN = 0,
|
||||||
|
TOUCH_EVENT_LIFT_UP = 1,
|
||||||
|
TOUCH_EVENT_CONTACT = 2,
|
||||||
|
TOUCH_EVENT_NO_EVENT = 3
|
||||||
|
} TouchEvent;
|
||||||
|
|
||||||
|
// Touch point structure
|
||||||
|
typedef struct {
|
||||||
|
int16_t x;
|
||||||
|
int16_t y;
|
||||||
|
uint8_t event;
|
||||||
|
uint8_t id;
|
||||||
|
uint8_t pressure; // Touch pressure/area/weight
|
||||||
|
} TouchPoint;
|
||||||
|
|
||||||
|
// Touch data structure
|
||||||
|
typedef struct {
|
||||||
|
uint8_t touch_count;
|
||||||
|
TouchPoint points[TOUCH_MAX_POINTS];
|
||||||
|
uint8_t gesture;
|
||||||
|
} TouchData;
|
||||||
|
|
||||||
|
// Abstract touch interface
|
||||||
|
class LowLevelTouch {
|
||||||
|
public:
|
||||||
|
virtual ~LowLevelTouch() {}
|
||||||
|
|
||||||
|
// Core touch operations
|
||||||
|
virtual bool init() = 0;
|
||||||
|
virtual bool read_touch(TouchData* data) = 0;
|
||||||
|
virtual bool is_touched() = 0;
|
||||||
|
|
||||||
|
// Touch properties
|
||||||
|
virtual int get_screen_width() const = 0;
|
||||||
|
virtual int get_screen_height() const = 0;
|
||||||
|
virtual TouchType get_type() const = 0;
|
||||||
|
virtual uint8_t get_max_touch_points() const = 0;
|
||||||
|
|
||||||
|
// Optional: Device information
|
||||||
|
virtual uint8_t get_chip_id() { return 0xFF; }
|
||||||
|
virtual uint8_t get_firmware_version() { return 0xFF; }
|
||||||
|
|
||||||
|
// Optional: Coordinate transformation (handled internally by driver)
|
||||||
|
virtual void set_coordinate_transform(bool swap_xy, bool invert_x, bool invert_y) {
|
||||||
|
(void)swap_xy; (void)invert_x; (void)invert_y;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Optional: Interrupt callback
|
||||||
|
virtual void set_interrupt_callback(void (*callback)(unsigned int gpio, uint32_t events)) {
|
||||||
|
(void)callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Optional: Test/diagnostic
|
||||||
|
virtual bool test_communication() { return false; }
|
||||||
|
|
||||||
|
// Factory method - creates touch controller based on type and screen dimensions
|
||||||
|
// Uses board_config.h for pin definitions and optional transform parameters
|
||||||
|
static LowLevelTouch* create(TouchType type, int screen_width, int screen_height,
|
||||||
|
bool swap_xy = false, bool invert_x = false, bool invert_y = false);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LOW_LEVEL_TOUCH_H
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
#include "low_level_touch.h"
|
||||||
|
#include "low_level_touch_ft6336u.h"
|
||||||
|
#include <cstdio>
|
||||||
|
|
||||||
|
LowLevelTouch* LowLevelTouch::create(TouchType type, int screen_width, int screen_height,
|
||||||
|
bool swap_xy, bool invert_x, bool invert_y) {
|
||||||
|
LowLevelTouch* touch = nullptr;
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case TOUCH_TYPE_FT6336U:
|
||||||
|
printf("Creating FT6336U touch controller...\n");
|
||||||
|
touch = new LowLevelTouchFT6336U(screen_width, screen_height, swap_xy, invert_x, invert_y);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TOUCH_TYPE_NONE:
|
||||||
|
printf("No touch controller configured\n");
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
default:
|
||||||
|
printf("Unknown touch type: %d\n", type);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (touch && !touch->init()) {
|
||||||
|
printf("Failed to initialize touch controller\n");
|
||||||
|
delete touch;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return touch;
|
||||||
|
}
|
||||||
@@ -0,0 +1,107 @@
|
|||||||
|
#include "low_level_touch_ft6336u.h"
|
||||||
|
#include "board_config.h"
|
||||||
|
#include <cstdio>
|
||||||
|
|
||||||
|
LowLevelTouchFT6336U::LowLevelTouchFT6336U(int width, int height, bool swap_xy,
|
||||||
|
bool invert_x, bool invert_y)
|
||||||
|
: screen_width(width)
|
||||||
|
, screen_height(height)
|
||||||
|
, swap_xy(swap_xy)
|
||||||
|
, invert_x(invert_x)
|
||||||
|
, invert_y(invert_y)
|
||||||
|
, initialized(false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
LowLevelTouchFT6336U::~LowLevelTouchFT6336U() {
|
||||||
|
// Cleanup if needed
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LowLevelTouchFT6336U::init() {
|
||||||
|
if (initialized) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build configuration from board_config.h
|
||||||
|
ft6336u_config_t config = {
|
||||||
|
.i2c = TOUCH_I2C_PORT,
|
||||||
|
.gpio_sda = TOUCH_SDA_PIN,
|
||||||
|
.gpio_scl = TOUCH_SCL_PIN,
|
||||||
|
.gpio_rst = TOUCH_RST_PIN,
|
||||||
|
.gpio_int = TOUCH_INT_PIN,
|
||||||
|
.screen_width = (uint16_t)screen_width,
|
||||||
|
.screen_height = (uint16_t)screen_height,
|
||||||
|
.swap_xy = swap_xy,
|
||||||
|
.invert_x = invert_x,
|
||||||
|
.invert_y = invert_y
|
||||||
|
};
|
||||||
|
|
||||||
|
initialized = ft6336u_init(&config);
|
||||||
|
|
||||||
|
if (initialized) {
|
||||||
|
printf("Touch FT6336U initialized: Chip ID=0x%02X, FW Ver=0x%02X\n",
|
||||||
|
get_chip_id(), get_firmware_version());
|
||||||
|
} else {
|
||||||
|
printf("Touch FT6336U initialization failed!\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return initialized;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LowLevelTouchFT6336U::read_touch(TouchData* data) {
|
||||||
|
if (!initialized || !data) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ft6336u_touch_data_t ft_data;
|
||||||
|
if (!ft6336u_read_touch(&ft_data)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert from FT6336U format to our abstract format
|
||||||
|
data->touch_count = ft_data.touch_count;
|
||||||
|
data->gesture = ft_data.gesture;
|
||||||
|
|
||||||
|
for (int i = 0; i < ft_data.touch_count && i < TOUCH_MAX_POINTS; i++) {
|
||||||
|
data->points[i].x = ft_data.points[i].x;
|
||||||
|
data->points[i].y = ft_data.points[i].y;
|
||||||
|
data->points[i].event = ft_data.points[i].event;
|
||||||
|
data->points[i].id = ft_data.points[i].id;
|
||||||
|
data->points[i].pressure = ft_data.points[i].weight;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LowLevelTouchFT6336U::is_touched() {
|
||||||
|
if (!initialized) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return ft6336u_is_touched();
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t LowLevelTouchFT6336U::get_chip_id() {
|
||||||
|
return ft6336u_get_chip_id();
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t LowLevelTouchFT6336U::get_firmware_version() {
|
||||||
|
return ft6336u_get_firmware_version();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LowLevelTouchFT6336U::set_coordinate_transform(bool swap_xy, bool invert_x, bool invert_y) {
|
||||||
|
this->swap_xy = swap_xy;
|
||||||
|
this->invert_x = invert_x;
|
||||||
|
this->invert_y = invert_y;
|
||||||
|
|
||||||
|
// Note: This only updates internal state. To apply to the driver,
|
||||||
|
// you would need to reinitialize with the new settings.
|
||||||
|
printf("Touch coordinate transform updated (requires re-init to apply)\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void LowLevelTouchFT6336U::set_interrupt_callback(void (*callback)(unsigned int gpio, uint32_t events)) {
|
||||||
|
ft6336u_set_interrupt_callback(callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LowLevelTouchFT6336U::test_communication() {
|
||||||
|
return ft6336u_test_i2c();
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
#ifndef LOW_LEVEL_TOUCH_FT6336U_H
|
||||||
|
#define LOW_LEVEL_TOUCH_FT6336U_H
|
||||||
|
|
||||||
|
#include "low_level_touch.h"
|
||||||
|
#include "../lib/ft6336u/ft6336u.h"
|
||||||
|
|
||||||
|
// FT6336U Touch Driver Implementation
|
||||||
|
class LowLevelTouchFT6336U : public LowLevelTouch {
|
||||||
|
private:
|
||||||
|
int screen_width;
|
||||||
|
int screen_height;
|
||||||
|
bool swap_xy;
|
||||||
|
bool invert_x;
|
||||||
|
bool invert_y;
|
||||||
|
bool initialized;
|
||||||
|
|
||||||
|
public:
|
||||||
|
LowLevelTouchFT6336U(int width, int height, bool swap_xy = false,
|
||||||
|
bool invert_x = false, bool invert_y = false);
|
||||||
|
virtual ~LowLevelTouchFT6336U();
|
||||||
|
|
||||||
|
// Core operations
|
||||||
|
bool init() override;
|
||||||
|
bool read_touch(TouchData* data) override;
|
||||||
|
bool is_touched() override;
|
||||||
|
|
||||||
|
// Touch properties
|
||||||
|
int get_screen_width() const override { return screen_width; }
|
||||||
|
int get_screen_height() const override { return screen_height; }
|
||||||
|
TouchType get_type() const override { return TOUCH_TYPE_FT6336U; }
|
||||||
|
uint8_t get_max_touch_points() const override { return 2; }
|
||||||
|
|
||||||
|
// Device information
|
||||||
|
uint8_t get_chip_id() override;
|
||||||
|
uint8_t get_firmware_version() override;
|
||||||
|
|
||||||
|
// Coordinate transformation
|
||||||
|
void set_coordinate_transform(bool swap_xy, bool invert_x, bool invert_y) override;
|
||||||
|
|
||||||
|
// Interrupt callback
|
||||||
|
void set_interrupt_callback(void (*callback)(unsigned int gpio, uint32_t events)) override;
|
||||||
|
|
||||||
|
// Test/diagnostic
|
||||||
|
bool test_communication() override;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LOW_LEVEL_TOUCH_FT6336U_H
|
||||||
+34
-8
@@ -4,19 +4,45 @@
|
|||||||
|
|
||||||
#include "ff.h"
|
#include "ff.h"
|
||||||
#include "pico/stdlib.h"
|
#include "pico/stdlib.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
// Parse compilation date/time macros
|
||||||
|
static int get_month_from_string(const char* month_str) {
|
||||||
|
const char* months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||||
|
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
|
||||||
|
for (int i = 0; i < 12; i++) {
|
||||||
|
if (strncmp(month_str, months[i], 3) == 0) {
|
||||||
|
return i + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1; // Default to January
|
||||||
|
}
|
||||||
|
|
||||||
/* Get current time */
|
/* Get current time */
|
||||||
DWORD get_fattime (void)
|
DWORD get_fattime (void)
|
||||||
{
|
{
|
||||||
// Return a fixed timestamp (2024-01-01 00:00:00)
|
// Use compilation date/time from __DATE__ and __TIME__ macros
|
||||||
// In a real application, you would get this from an RTC
|
// __DATE__ format: "Jan 28 2026"
|
||||||
|
// __TIME__ format: "HH:MM:SS"
|
||||||
// Format: bit31:25=Year(0-127 +1980), bit24:21=Month(1-12), bit20:16=Day(1-31)
|
// Format: bit31:25=Year(0-127 +1980), bit24:21=Month(1-12), bit20:16=Day(1-31)
|
||||||
// bit15:11=Hour(0-23), bit10:5=Minute(0-59), bit4:0=Second/2(0-29)
|
// bit15:11=Hour(0-23), bit10:5=Minute(0-59), bit4:0=Second/2(0-29)
|
||||||
|
|
||||||
return ((DWORD)(2024 - 1980) << 25) // Year: 2024
|
// Parse __DATE__ (e.g., "Jan 28 2026")
|
||||||
| ((DWORD)1 << 21) // Month: January
|
char month_str[4] = {__DATE__[0], __DATE__[1], __DATE__[2], 0};
|
||||||
| ((DWORD)1 << 16) // Day: 1
|
int day = (__DATE__[4] == ' ' ? 0 : (__DATE__[4] - '0') * 10) + (__DATE__[5] - '0');
|
||||||
| ((DWORD)0 << 11) // Hour: 0
|
int year = ((__DATE__[7] - '0') * 1000) + ((__DATE__[8] - '0') * 100) +
|
||||||
| ((DWORD)0 << 5) // Minute: 0
|
((__DATE__[9] - '0') * 10) + (__DATE__[10] - '0');
|
||||||
| ((DWORD)0 >> 1); // Second: 0
|
int month = get_month_from_string(month_str);
|
||||||
|
|
||||||
|
// Parse __TIME__ (e.g., "12:34:56")
|
||||||
|
int hour = ((__TIME__[0] - '0') * 10) + (__TIME__[1] - '0');
|
||||||
|
int minute = ((__TIME__[3] - '0') * 10) + (__TIME__[4] - '0');
|
||||||
|
int second = ((__TIME__[6] - '0') * 10) + (__TIME__[7] - '0');
|
||||||
|
|
||||||
|
return ((DWORD)(year - 1980) << 25)
|
||||||
|
| ((DWORD)month << 21)
|
||||||
|
| ((DWORD)day << 16)
|
||||||
|
| ((DWORD)hour << 11)
|
||||||
|
| ((DWORD)minute << 5)
|
||||||
|
| ((DWORD)(second / 2));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
build/
|
||||||
@@ -0,0 +1,674 @@
|
|||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you
|
||||||
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
|
that there is no warranty for this free software. For both users' and
|
||||||
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the manufacturer
|
||||||
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
|
protecting users' freedom to change the software. The systematic
|
||||||
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
|
avoid the special danger that patents applied to a free program could
|
||||||
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program does terminal interaction, make it output a short
|
||||||
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
|
<program> Copyright (C) <year> <name of author>
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, your program's commands
|
||||||
|
might be different; for a GUI interface, you would use an "about box".
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
|
<https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
The GNU General Public License does not permit incorporating your program
|
||||||
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
|
may consider it more useful to permit linking proprietary applications with
|
||||||
|
the library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License. But first, please read
|
||||||
|
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
# Pico_ePaper_Code
|
||||||
|
## waveshare electronics
|
||||||
|

|
||||||
|
|
||||||
|
## 中文:
|
||||||
|
微雪电子 Pico-ePaper 系列驱动代码,支持C和Python
|
||||||
|
|
||||||
|
更多资料请在官网搜索相关产品:
|
||||||
|
> https://www.waveshare.net or https://www.waveshare.net/wiki
|
||||||
|
***
|
||||||
|
## English:
|
||||||
|
Waveshrae Pico-ePaper series drivers code, Support C and Python.
|
||||||
|
|
||||||
|
For more information, please search on the official website:
|
||||||
|
> https://www.waveshare.com or https://www.waveshare.com/wiki/Main_Page
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
2021-02-04:新创建,添加2.13 & 2.9程序
|
||||||
|
2021-03-17:新添加2.13-B、2.13-C、2.9-B、2.9-C程序
|
||||||
|
2021-05-12:新添加2.66程序,解决python程序自启动乱码的问题
|
||||||
|
2021-05-14:新添加2.66-B、2.13-D、2.9-D程序
|
||||||
|
2021-05-27:新添加5.83、5.83-B、7.5、7.5-B程序
|
||||||
|
2021-06-01:新添加3.7程序
|
||||||
|
2021-06-15:新添加2.7程序
|
||||||
|
2021-07-13:新添加4.2、4.2-B、5.65程序
|
||||||
|
2021-11-01:添加新程序2.13inch V3 e-Paper例程。
|
||||||
|
2022-08-22:添加新程序2.13Binch V4 e-Paper例程。
|
||||||
|
2023-03-16:添加新程序2.7inch V2 e-Paper例程。
|
||||||
|
2023-08-12:添加新程序2.13inch V4 e-Paper例程。
|
||||||
|
2023-08-31:更新 2.9inch V2 e-Paper 的例程,添加四灰度显示
|
||||||
|
2023-09-13:添加新程序4.2inch V2 e-Paper例程。
|
||||||
|
2024-04-22:添加新程序2.9inch e-Paper (B) V4 例程。
|
||||||
|
2024-04-22:更新4.2inch e-Paper (B) V2 例程。
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
2021-02-04: newly built, add 2.13 & 2.9 programs.
|
||||||
|
2021-03-17: add 2.13-B & 2.13-C & 2.9-B & 2.9-C programs.
|
||||||
|
2021-05-12: add 2.66 program, Solve the Python program to start the problem of garbled code
|
||||||
|
2021-05-14: add 2.66-B & 2.13-D & 2.9-D programs.
|
||||||
|
2021-05-27:add 5.83 & 5.83-B & 7.5 & 7.5-B programs.
|
||||||
|
2021-06-01:add 3.7 programs.
|
||||||
|
2021-06-15:add 2.7 programs.
|
||||||
|
2021-07-13:add 4.2 & 4.2-B & 5.65 programs.
|
||||||
|
2021-11-01: Added new program 2.13inch V3 e-Paper routine.
|
||||||
|
2022-08-22: Added new program 2.13Binch V4 e-Paper routine.
|
||||||
|
2023-03-16: Added new program 2.7inch V2 e-Paper routine.
|
||||||
|
2023-08-12: Added new program 2.13inch V4 e-Paper routine.
|
||||||
|
2023-08-31: Update the routines of the 2.9inch V2 e-Paper to add a four-grayscale display
|
||||||
|
2023-09-13: Added new program 4.2inch V2 e-Paper routine.
|
||||||
|
2024-04-22: Added new program 2.9inch e-Paper (B) V4 routine added.
|
||||||
|
2024-04-22: Update 4.2inch e-Paper (B) V2 routine.
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.12)
|
||||||
|
include(pico_sdk_import.cmake)
|
||||||
|
project(Pico_ePaper_Code)
|
||||||
|
pico_sdk_init()
|
||||||
|
|
||||||
|
# add a compilation subdirectory
|
||||||
|
add_subdirectory(lib/Config)
|
||||||
|
add_subdirectory(lib/e-Paper)
|
||||||
|
add_subdirectory(lib/Fonts)
|
||||||
|
add_subdirectory(lib/GUI)
|
||||||
|
add_subdirectory(examples)
|
||||||
|
|
||||||
|
# add a header directory
|
||||||
|
include_directories(examples)
|
||||||
|
include_directories(./lib/Config)
|
||||||
|
include_directories(./lib/GUI)
|
||||||
|
|
||||||
|
# generate an executable file
|
||||||
|
add_executable(epd
|
||||||
|
main.c
|
||||||
|
)
|
||||||
|
|
||||||
|
# enable usb output, disable uart output
|
||||||
|
pico_enable_stdio_usb(epd 1)
|
||||||
|
pico_enable_stdio_uart(epd 0)
|
||||||
|
|
||||||
|
# create map/bin/hex/uf2 file etc.
|
||||||
|
pico_add_extra_outputs(epd)
|
||||||
|
|
||||||
|
target_link_libraries(epd examples ePaper GUI Fonts Config pico_stdlib hardware_spi)
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : Readme_CN.txt
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : Help with use
|
||||||
|
* | Info :
|
||||||
|
*----------------
|
||||||
|
* | This version: V1.0
|
||||||
|
* | Date : 2021-02-04
|
||||||
|
* | Info : 在这里提供一个中文版本的使用文档,以便你的快速使用
|
||||||
|
******************************************************************************/
|
||||||
|
这个文件是帮助您使用本例程。
|
||||||
|
由于我们的墨水屏越来越多,不便于我们的维护,因此把所有的墨水屏程序做成一个工程。
|
||||||
|
在这里简略的描述本工程的使用:
|
||||||
|
|
||||||
|
1.基本信息:
|
||||||
|
本例程使用相对应的模块搭配Pico进行了验证,你可以在工程的examples\中查看对应的测试例程;
|
||||||
|
|
||||||
|
2.管脚连接:
|
||||||
|
管脚连接你可以在\lib\Config目录下查看DEV_Config.c/h中查看,这里也再重述一次:
|
||||||
|
EPD => Pico
|
||||||
|
VCC -> VSYS
|
||||||
|
GND -> GND
|
||||||
|
DIN -> 11
|
||||||
|
CLK -> 10
|
||||||
|
CS -> 9
|
||||||
|
DC -> 8
|
||||||
|
RST -> 12
|
||||||
|
BUSY -> 13
|
||||||
|
|
||||||
|
3.基本使用:
|
||||||
|
由于本工程是一个综合工程,对于使用而言,你可能需要阅读以下内容:
|
||||||
|
你可以在main.c中的12行到22行看到已经进行了注释的9个函数,
|
||||||
|
请注意你购买的是哪一款的墨水屏。
|
||||||
|
栗子1:
|
||||||
|
如果你购买的 Pico-ePaper-2.13,那么你应该把对应的18(或19,取决于您屏幕的版本)行代码的注释去掉,即:
|
||||||
|
// EPD_2in13_V2_test();
|
||||||
|
修改成:
|
||||||
|
EPD_2in13_V2_test();
|
||||||
|
栗子2:
|
||||||
|
如果你购买的 Pico-ePaper-2.9-B,那么你应该把对应的21行代码的注释去掉,即:
|
||||||
|
// EPD_2in13b_V3_test();
|
||||||
|
修改成:
|
||||||
|
EPD_2in13b_V3_test();
|
||||||
|
注意:对于屏幕的版本请注意你的屏幕背面是否贴有V2/V3等标识。
|
||||||
|
|
||||||
|
然后你需要执行:
|
||||||
|
创建build目录:打开终端,在 Pico_ePaper_Code/c 目录下输入:
|
||||||
|
mkdir build
|
||||||
|
进入build目录,在终端输入:
|
||||||
|
cd build
|
||||||
|
执行cmake,自动生成Makefile文件,在终端输入:
|
||||||
|
cmake ..
|
||||||
|
执行make,生成可执行文件,在终端输入:
|
||||||
|
make -j4
|
||||||
|
|
||||||
|
4.目录结构(选读):
|
||||||
|
如果你经常使用我们的产品,对我们的程序目录结构会十分熟悉,关于具体的函数的我们有一份
|
||||||
|
函数的API手册,你可以在我们的WIKI上下载或像售后客服索取,这里简单介绍一次:
|
||||||
|
\lib\Config\:此目录为硬件接口层文件,在DEV_Config.c(.h)可以看到很多定义,包括:
|
||||||
|
数据类型;
|
||||||
|
GPIO;
|
||||||
|
读写GPIO;
|
||||||
|
延时:注意:此延时函数并未使用示波器测量具体数值,因此会不准;
|
||||||
|
模块初始化与退出的处理:
|
||||||
|
void DEV_Module_Init(void);
|
||||||
|
void DEV_Module_Exit(void);
|
||||||
|
注意:1.这里是处理使用墨水屏前与使用完之后一些GPIO的处理。
|
||||||
|
2.对于PCB带有Rev2.1的,DEV_Module_Exit()之后整个模块会进入低功耗,经过测试这个功耗基本为0;
|
||||||
|
|
||||||
|
\lib\GUI\:此目录为一些基本的图像处理函数,在GUI_Paint.c(.h)中:
|
||||||
|
常用图像处理:创建图形、翻转图形、镜像图形、设置像素点、清屏等;
|
||||||
|
常用画图处理:画点、线、框、圆、中文字符、英文字符、数字等;
|
||||||
|
常用时间显示:提供一个常用的显示时间函数;
|
||||||
|
常用显示图片:提供一个显示位图的函数;
|
||||||
|
|
||||||
|
\lib\Fonts\:为一些常用的字体:
|
||||||
|
Ascii:
|
||||||
|
font8: 5*8
|
||||||
|
font12: 7*12
|
||||||
|
font16: 11*16
|
||||||
|
font20: 14*20
|
||||||
|
font24: 17*24
|
||||||
|
中文:
|
||||||
|
font12CN: 16*21
|
||||||
|
font24CN: 32*41
|
||||||
|
|
||||||
|
\lib\e-paper\:此目录下为墨水屏驱动函数;
|
||||||
|
examples\:此目录下为墨水屏的测试程序,你可在其中看到具体的使用方法;
|
||||||
@@ -0,0 +1,91 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : Readme_EN.txt
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : Help with use
|
||||||
|
* | Info :
|
||||||
|
*----------------
|
||||||
|
* | This version: V1.0
|
||||||
|
* | Date : 2021-02-04
|
||||||
|
* | Info : Here is an English version of the documentation for your quick use.
|
||||||
|
******************************************************************************/
|
||||||
|
This file is to help you use this routine.
|
||||||
|
Since our ink screens are getting more and more, it is not convenient for our maintenance, so all the ink screen programs are made into one project.
|
||||||
|
A brief description of the use of this project is here:
|
||||||
|
|
||||||
|
1. Basic information:
|
||||||
|
This routine is verified using the corresponding module with the PICO.
|
||||||
|
You can see the corresponding test routine in the examples\ of the project.
|
||||||
|
|
||||||
|
2. Pin connection:
|
||||||
|
Pin connection You can look at dev_config.c/h in \lib\Config. Again, here:
|
||||||
|
EPD => Pico
|
||||||
|
VCC -> VSYS
|
||||||
|
GND -> GND
|
||||||
|
DIN -> 11
|
||||||
|
CLK -> 10
|
||||||
|
CS -> 9
|
||||||
|
DC -> 8
|
||||||
|
RST -> 12
|
||||||
|
BUSY -> 13
|
||||||
|
|
||||||
|
3. Basic use:
|
||||||
|
As this project is a comprehensive project, for use, you may need to read the following:
|
||||||
|
You can see the nine functions that have been commented in main.c on lines 12 through 22,
|
||||||
|
Please pay attention to which type of ink screen you buy.
|
||||||
|
eg.1:
|
||||||
|
If you purchased pico-epaper 2.13,
|
||||||
|
then you should uncomment the corresponding 18(or 19, depending on the version of your screen) lines of code, i.e. :
|
||||||
|
// EPD_2in13_V2_test();
|
||||||
|
change to:
|
||||||
|
EPD_2in13_V2_test();
|
||||||
|
eg.2:
|
||||||
|
If you bought pico-epaper 2.9-b,
|
||||||
|
then you should uncomment the corresponding 21 lines of code, i.e. :
|
||||||
|
// EPD_2in13b_V3_test();
|
||||||
|
change to:
|
||||||
|
EPD_2in13b_V3_test();
|
||||||
|
Note: For the version of the screen, please pay attention to whether the back of your screen is labeled with V2/V3 etc.
|
||||||
|
|
||||||
|
Then you need to implement:
|
||||||
|
Create the build directory: Open the terminal and type in the Pico_ePaper_Code/c directory:
|
||||||
|
mkdir build
|
||||||
|
Go to the build directory and type:
|
||||||
|
cd build
|
||||||
|
Execute cmake to automatically generate the Makefile file and type:
|
||||||
|
cmake ..
|
||||||
|
To create an executable file, type:
|
||||||
|
make -j4
|
||||||
|
|
||||||
|
4. Directory structure (selection):
|
||||||
|
If you use our products frequently, we will be very familiar with our program directory structure. We have a copy of the specific function.
|
||||||
|
The API manual for the function, you can download it on our WIKI or request it as an after-sales customer service. Here is a brief introduction:
|
||||||
|
Config\: This directory is a hardware interface layer file. You can see many definitions in DEV_Config.c(.h), including:
|
||||||
|
type of data;
|
||||||
|
GPIO;
|
||||||
|
Read and write GPIO;
|
||||||
|
Delay: Note: This delay function does not use an oscilloscope to measure specific values.
|
||||||
|
Module Init and exit processing:
|
||||||
|
void DEV_Module_Init(void);
|
||||||
|
void DEV_Module_Exit(void);
|
||||||
|
Note: 1. Here is the processing of some GPIOs before and after using the ink screen.
|
||||||
|
2. For the PCB with Rev2.1, the entire module will enter low power consumption after DEV_Module_Exit(). After testing, the power consumption is basically 0;
|
||||||
|
|
||||||
|
\lib\GUI\: This directory is some basic image processing functions, in GUI_Paint.c(.h):
|
||||||
|
Common image processing: creating graphics, flipping graphics, mirroring graphics, setting pixels, clearing screens, etc.
|
||||||
|
Common drawing processing: drawing points, lines, boxes, circles, Chinese characters, English characters, numbers, etc.;
|
||||||
|
Common time display: Provide a common display time function;
|
||||||
|
Commonly used display pictures: provide a function to display bitmaps;
|
||||||
|
|
||||||
|
\lib\Fonts\: for some commonly used fonts:
|
||||||
|
Ascii:
|
||||||
|
Font8: 5*8
|
||||||
|
Font12: 7*12
|
||||||
|
Font16: 11*16
|
||||||
|
Font20: 14*20
|
||||||
|
Font24: 17*24
|
||||||
|
Chinese:
|
||||||
|
font12CN: 16*21
|
||||||
|
font24CN: 32*41
|
||||||
|
|
||||||
|
\lib\e-paper\: This screen is the ink screen driver function;
|
||||||
|
examples\: This is the test program for the ink screen. You can see the specific usage method in it.
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
# Find all source files in a single current directory
|
||||||
|
# Save the name to DIR_examples_SRCS
|
||||||
|
aux_source_directory(. DIR_examples_SRCS)
|
||||||
|
|
||||||
|
include_directories(../lib/Config)
|
||||||
|
include_directories(../lib/GUI)
|
||||||
|
include_directories(../lib/e-Paper)
|
||||||
|
|
||||||
|
# Generate the link library
|
||||||
|
add_library(examples ${DIR_examples_SRCS})
|
||||||
|
target_link_libraries(examples PUBLIC Config)
|
||||||
@@ -0,0 +1,196 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : EPD_2IN13_V2_test.c
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : 2.13inch e-paper(V2) test demo
|
||||||
|
* | Info :
|
||||||
|
*----------------
|
||||||
|
* | This version: V1.0
|
||||||
|
* | Date : 2019-06-13
|
||||||
|
* | Info :
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documnetation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in
|
||||||
|
# all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
# THE SOFTWARE.
|
||||||
|
#
|
||||||
|
******************************************************************************/
|
||||||
|
#include "EPD_Test.h"
|
||||||
|
#include "EPD_2in13_V2.h"
|
||||||
|
|
||||||
|
int EPD_2in13_V2_test(void)
|
||||||
|
{
|
||||||
|
printf("EPD_2IN13_V2_test Demo\r\n");
|
||||||
|
if(DEV_Module_Init()!=0){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("e-Paper Init and Clear...\r\n");
|
||||||
|
EPD_2IN13_V2_Init(EPD_2IN13_V2_FULL);
|
||||||
|
EPD_2IN13_V2_Clear();
|
||||||
|
DEV_Delay_ms(500);
|
||||||
|
|
||||||
|
//Create a new image cache
|
||||||
|
UBYTE *BlackImage;
|
||||||
|
/* you have to edit the startup_stm32fxxx.s file and set a big enough heap size */
|
||||||
|
UWORD Imagesize = ((EPD_2IN13_V2_WIDTH % 8 == 0)? (EPD_2IN13_V2_WIDTH / 8 ): (EPD_2IN13_V2_WIDTH / 8 + 1)) * EPD_2IN13_V2_HEIGHT;
|
||||||
|
if((BlackImage = (UBYTE *)malloc(Imagesize)) == NULL) {
|
||||||
|
printf("Failed to apply for black memory...\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
printf("Paint_NewImage\r\n");
|
||||||
|
Paint_NewImage(BlackImage, EPD_2IN13_V2_WIDTH, EPD_2IN13_V2_HEIGHT, 270, WHITE);
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_SetMirroring(MIRROR_HORIZONTAL); //
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
|
||||||
|
#if 1 //show image for array
|
||||||
|
printf("show image for array\r\n");
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_DrawBitMap(gImage_2in13);
|
||||||
|
|
||||||
|
EPD_2IN13_V2_Display(BlackImage);
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1 // Drawing on the image
|
||||||
|
printf("Drawing\r\n");
|
||||||
|
//1.Select Image
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
|
||||||
|
// 2.Drawing on the image
|
||||||
|
Paint_DrawPoint(5, 10, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(5, 25, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(5, 40, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(5, 55, BLACK, DOT_PIXEL_4X4, DOT_STYLE_DFT);
|
||||||
|
|
||||||
|
Paint_DrawLine(20, 10, 70, 60, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(70, 10, 20, 60, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawRectangle(20, 10, 70, 60, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawRectangle(85, 10, 135, 60, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
|
||||||
|
Paint_DrawLine(45, 15, 45, 55, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawLine(25, 35, 70, 35, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawCircle(45, 35, 20, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawCircle(110, 35, 20, WHITE, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
|
||||||
|
Paint_DrawString_EN(140, 15, "waveshare", &Font16, BLACK, WHITE);
|
||||||
|
Paint_DrawNum(140, 40, 123456789, &Font16, BLACK, WHITE);
|
||||||
|
|
||||||
|
Paint_DrawString_CN(140, 60, "ÄãºÃabc", &Font12CN, BLACK, WHITE);
|
||||||
|
Paint_DrawString_CN(5, 65, "΢ѩµç×Ó", &Font24CN, WHITE, BLACK);
|
||||||
|
|
||||||
|
EPD_2IN13_V2_Display(BlackImage);
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1 // Drawing on the image
|
||||||
|
printf("Drawing\r\n");
|
||||||
|
//1.Select Image
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
|
||||||
|
// 2.Drawing on the image
|
||||||
|
Paint_DrawLine(1, 1, 250,1, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(250, 1, 250,122, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(250, 122,1, 122, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(1, 122,1, 1, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
|
||||||
|
Paint_DrawLine(3, 3, 248,3, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(248, 3, 248,120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(248, 120,3, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(3, 120,3, 3, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
|
||||||
|
Paint_DrawLine(5, 5, 246,5, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(246, 5, 246,118, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(246, 118,5, 118, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(5, 118,5, 5, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
|
||||||
|
Paint_DrawLine(7, 7, 244,7, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(244, 7, 244,116, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(244, 116,7, 116, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(7, 116,7, 7, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
|
||||||
|
Paint_DrawLine(9, 9, 242,9, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(242, 9, 242,114, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(242, 114,9, 114, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(9, 114,9, 9, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
|
||||||
|
Paint_DrawString_EN(60, 25, "waveshare", &Font16, BLACK, WHITE);
|
||||||
|
Paint_DrawString_CN(60, 55, "΢ѩµç×Ó", &Font24CN, WHITE, BLACK);
|
||||||
|
|
||||||
|
EPD_2IN13_V2_Display(BlackImage);
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1 //Partial refresh, example shows time
|
||||||
|
printf("Partial refresh\r\n");
|
||||||
|
EPD_2IN13_V2_Init(EPD_2IN13_V2_FULL);
|
||||||
|
EPD_2IN13_V2_DisplayPartBaseImage(BlackImage);
|
||||||
|
|
||||||
|
EPD_2IN13_V2_Init(EPD_2IN13_V2_PART);
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
PAINT_TIME sPaint_time;
|
||||||
|
sPaint_time.Hour = 12;
|
||||||
|
sPaint_time.Min = 34;
|
||||||
|
sPaint_time.Sec = 56;
|
||||||
|
UBYTE num = 20;
|
||||||
|
for (;;) {
|
||||||
|
sPaint_time.Sec = sPaint_time.Sec + 1;
|
||||||
|
if (sPaint_time.Sec == 60) {
|
||||||
|
sPaint_time.Min = sPaint_time.Min + 1;
|
||||||
|
sPaint_time.Sec = 0;
|
||||||
|
if (sPaint_time.Min == 60) {
|
||||||
|
sPaint_time.Hour = sPaint_time.Hour + 1;
|
||||||
|
sPaint_time.Min = 0;
|
||||||
|
if (sPaint_time.Hour == 24) {
|
||||||
|
sPaint_time.Hour = 0;
|
||||||
|
sPaint_time.Min = 0;
|
||||||
|
sPaint_time.Sec = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Paint_ClearWindows(140, 90, 140 + Font20.Width * 7, 90 + Font20.Height, WHITE);
|
||||||
|
Paint_DrawTime(140, 90, &sPaint_time, &Font20, WHITE, BLACK);
|
||||||
|
|
||||||
|
num = num - 1;
|
||||||
|
if(num == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
EPD_2IN13_V2_DisplayPart(BlackImage);
|
||||||
|
DEV_Delay_ms(500);//Analog clock 1s
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
printf("Clear...\r\n");
|
||||||
|
|
||||||
|
EPD_2IN13_V2_Init(EPD_2IN13_V2_FULL);
|
||||||
|
EPD_2IN13_V2_Clear();
|
||||||
|
DEV_Delay_ms(2000);//Analog clock 1s
|
||||||
|
|
||||||
|
printf("Goto Sleep...\r\n");
|
||||||
|
EPD_2IN13_V2_Sleep();
|
||||||
|
free(BlackImage);
|
||||||
|
BlackImage = NULL;
|
||||||
|
DEV_Delay_ms(2000);//important, at least 2s
|
||||||
|
// close 5V
|
||||||
|
printf("close 5V, Module enters 0 power consumption ...\r\n");
|
||||||
|
DEV_Module_Exit();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,149 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : EPD_2in13_V3_test.c
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : 2.13inch e-paper V3 test demo
|
||||||
|
* | Info :
|
||||||
|
*----------------
|
||||||
|
* | This version: V1.0
|
||||||
|
* | Date : 2020-12-22
|
||||||
|
* | Info :
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documnetation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in
|
||||||
|
# all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
# THE SOFTWARE.
|
||||||
|
#
|
||||||
|
******************************************************************************/
|
||||||
|
#include "EPD_Test.h"
|
||||||
|
#include "EPD_2in13_V3.h"
|
||||||
|
|
||||||
|
int EPD_2in13_V3_test(void)
|
||||||
|
{
|
||||||
|
printf("EPD_2in13_V3_test Demo\r\n");
|
||||||
|
if(DEV_Module_Init()!=0){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("e-Paper Init and Clear...\r\n");
|
||||||
|
EPD_2in13_V3_Init();
|
||||||
|
EPD_2in13_V3_Clear();
|
||||||
|
|
||||||
|
//Create a new image cache
|
||||||
|
UBYTE *BlackImage;
|
||||||
|
UWORD Imagesize = ((EPD_2in13_V3_WIDTH % 8 == 0)? (EPD_2in13_V3_WIDTH / 8 ): (EPD_2in13_V3_WIDTH / 8 + 1)) * EPD_2in13_V3_HEIGHT;
|
||||||
|
if((BlackImage = (UBYTE *)malloc(Imagesize)) == NULL) {
|
||||||
|
printf("Failed to apply for black memory...\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
printf("Paint_NewImage\r\n");
|
||||||
|
Paint_NewImage(BlackImage, EPD_2in13_V3_WIDTH, EPD_2in13_V3_HEIGHT, 90, WHITE);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
|
||||||
|
#if 1 //show image for array
|
||||||
|
printf("show image for array\r\n");
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_DrawBitMap(gImage_2in13_2);
|
||||||
|
|
||||||
|
EPD_2in13_V3_Display(BlackImage);
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1 // Drawing on the image
|
||||||
|
Paint_NewImage(BlackImage, EPD_2in13_V3_WIDTH, EPD_2in13_V3_HEIGHT, 90, WHITE);
|
||||||
|
printf("Drawing\r\n");
|
||||||
|
//1.Select Image
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
|
||||||
|
// 2.Drawing on the image
|
||||||
|
Paint_DrawPoint(5, 10, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(5, 25, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(5, 40, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(5, 55, BLACK, DOT_PIXEL_4X4, DOT_STYLE_DFT);
|
||||||
|
|
||||||
|
Paint_DrawLine(20, 10, 70, 60, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(70, 10, 20, 60, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawRectangle(20, 10, 70, 60, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawRectangle(85, 10, 135, 60, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
|
||||||
|
Paint_DrawLine(45, 15, 45, 55, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawLine(25, 35, 70, 35, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawCircle(45, 35, 20, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawCircle(110, 35, 20, WHITE, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
|
||||||
|
Paint_DrawString_EN(140, 15, "waveshare", &Font16, BLACK, WHITE);
|
||||||
|
Paint_DrawNum(140, 40, 123456789, &Font16, BLACK, WHITE);
|
||||||
|
|
||||||
|
Paint_DrawString_CN(140, 60, "ÄãºÃabc", &Font12CN, BLACK, WHITE);
|
||||||
|
Paint_DrawString_CN(5, 65, "΢ѩµç×Ó", &Font24CN, WHITE, BLACK);
|
||||||
|
|
||||||
|
EPD_2in13_V3_Display_Base(BlackImage);
|
||||||
|
DEV_Delay_ms(3000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1 //Partial refresh, example shows time
|
||||||
|
Paint_NewImage(BlackImage, EPD_2in13_V3_WIDTH, EPD_2in13_V3_HEIGHT, 90, WHITE);
|
||||||
|
printf("Partial refresh\r\n");
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
|
||||||
|
PAINT_TIME sPaint_time;
|
||||||
|
sPaint_time.Hour = 12;
|
||||||
|
sPaint_time.Min = 34;
|
||||||
|
sPaint_time.Sec = 56;
|
||||||
|
UBYTE num = 10;
|
||||||
|
for (;;) {
|
||||||
|
sPaint_time.Sec = sPaint_time.Sec + 1;
|
||||||
|
if (sPaint_time.Sec == 60) {
|
||||||
|
sPaint_time.Min = sPaint_time.Min + 1;
|
||||||
|
sPaint_time.Sec = 0;
|
||||||
|
if (sPaint_time.Min == 60) {
|
||||||
|
sPaint_time.Hour = sPaint_time.Hour + 1;
|
||||||
|
sPaint_time.Min = 0;
|
||||||
|
if (sPaint_time.Hour == 24) {
|
||||||
|
sPaint_time.Hour = 0;
|
||||||
|
sPaint_time.Min = 0;
|
||||||
|
sPaint_time.Sec = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Paint_ClearWindows(150, 80, 150 + Font20.Width * 7, 80 + Font20.Height, WHITE);
|
||||||
|
Paint_DrawTime(150, 80, &sPaint_time, &Font20, WHITE, BLACK);
|
||||||
|
|
||||||
|
num = num - 1;
|
||||||
|
if(num == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
EPD_2in13_V3_Display_Partial(BlackImage);
|
||||||
|
DEV_Delay_ms(500);//Analog clock 1s
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
printf("Clear...\r\n");
|
||||||
|
EPD_2in13_V3_Init();
|
||||||
|
EPD_2in13_V3_Clear();
|
||||||
|
|
||||||
|
printf("Goto Sleep...\r\n");
|
||||||
|
EPD_2in13_V3_Sleep();
|
||||||
|
free(BlackImage);
|
||||||
|
BlackImage = NULL;
|
||||||
|
DEV_Delay_ms(2000);//important, at least 2s
|
||||||
|
// close 5V
|
||||||
|
printf("close 5V, Module enters 0 power consumption ...\r\n");
|
||||||
|
DEV_Module_Exit();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,152 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : EPD_2in13_V4_test.c
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : 2.13inch e-paper V4 test demo
|
||||||
|
* | Info :
|
||||||
|
*----------------
|
||||||
|
* | This version: V1.0
|
||||||
|
* | Date : 2023-08-12
|
||||||
|
* | Info :
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documnetation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in
|
||||||
|
# all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
# THE SOFTWARE.
|
||||||
|
#
|
||||||
|
******************************************************************************/
|
||||||
|
#include "EPD_Test.h"
|
||||||
|
#include "EPD_2in13_V4.h"
|
||||||
|
|
||||||
|
int EPD_2in13_V4_test(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
Debug("EPD_2in13_V4_test Demo\r\n");
|
||||||
|
if(DEV_Module_Init()!=0){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Debug("e-Paper Init and Clear...\r\n");
|
||||||
|
EPD_2in13_V4_Init();
|
||||||
|
EPD_2in13_V4_Clear();
|
||||||
|
|
||||||
|
//Create a new image cache
|
||||||
|
UBYTE *BlackImage;
|
||||||
|
UWORD Imagesize = ((EPD_2in13_V4_WIDTH % 8 == 0)? (EPD_2in13_V4_WIDTH / 8 ): (EPD_2in13_V4_WIDTH / 8 + 1)) * EPD_2in13_V4_HEIGHT;
|
||||||
|
if((BlackImage = (UBYTE *)malloc(Imagesize)) == NULL) {
|
||||||
|
Debug("Failed to apply for black memory...\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
Debug("Paint_NewImage\r\n");
|
||||||
|
Paint_NewImage(BlackImage, EPD_2in13_V4_WIDTH, EPD_2in13_V4_HEIGHT, 90, WHITE);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
|
||||||
|
#if 1 //show image for array
|
||||||
|
Debug("show image for array\r\n");
|
||||||
|
EPD_2in13_V4_Init_Fast();
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_DrawBitMap(gImage_2in13_2);
|
||||||
|
|
||||||
|
EPD_2in13_V4_Display_Fast(BlackImage);
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1 // Drawing on the image
|
||||||
|
Paint_NewImage(BlackImage, EPD_2in13_V4_WIDTH, EPD_2in13_V4_HEIGHT, 90, WHITE);
|
||||||
|
Debug("Drawing\r\n");
|
||||||
|
//1.Select Image
|
||||||
|
EPD_2in13_V4_Init();
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
|
||||||
|
// 2.Drawing on the image
|
||||||
|
Paint_DrawPoint(5, 10, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(5, 25, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(5, 40, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(5, 55, BLACK, DOT_PIXEL_4X4, DOT_STYLE_DFT);
|
||||||
|
|
||||||
|
Paint_DrawLine(20, 10, 70, 60, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(70, 10, 20, 60, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawRectangle(20, 10, 70, 60, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawRectangle(85, 10, 135, 60, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
|
||||||
|
Paint_DrawLine(45, 15, 45, 55, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawLine(25, 35, 70, 35, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawCircle(45, 35, 20, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawCircle(110, 35, 20, WHITE, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
|
||||||
|
Paint_DrawString_EN(140, 15, "waveshare", &Font16, BLACK, WHITE);
|
||||||
|
Paint_DrawNum(140, 40, 123456789, &Font16, BLACK, WHITE);
|
||||||
|
|
||||||
|
Paint_DrawString_CN(140, 60, "ÄãºÃabc", &Font12CN, BLACK, WHITE);
|
||||||
|
Paint_DrawString_CN(5, 65, "΢ѩµç×Ó", &Font24CN, WHITE, BLACK);
|
||||||
|
|
||||||
|
EPD_2in13_V4_Display_Base(BlackImage);
|
||||||
|
DEV_Delay_ms(3000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1 //Partial refresh, example shows time
|
||||||
|
Paint_NewImage(BlackImage, EPD_2in13_V4_WIDTH, EPD_2in13_V4_HEIGHT, 90, WHITE);
|
||||||
|
Debug("Partial refresh\r\n");
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
|
||||||
|
PAINT_TIME sPaint_time;
|
||||||
|
sPaint_time.Hour = 12;
|
||||||
|
sPaint_time.Min = 34;
|
||||||
|
sPaint_time.Sec = 56;
|
||||||
|
UBYTE num = 10;
|
||||||
|
for (;;) {
|
||||||
|
sPaint_time.Sec = sPaint_time.Sec + 1;
|
||||||
|
if (sPaint_time.Sec == 60) {
|
||||||
|
sPaint_time.Min = sPaint_time.Min + 1;
|
||||||
|
sPaint_time.Sec = 0;
|
||||||
|
if (sPaint_time.Min == 60) {
|
||||||
|
sPaint_time.Hour = sPaint_time.Hour + 1;
|
||||||
|
sPaint_time.Min = 0;
|
||||||
|
if (sPaint_time.Hour == 24) {
|
||||||
|
sPaint_time.Hour = 0;
|
||||||
|
sPaint_time.Min = 0;
|
||||||
|
sPaint_time.Sec = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Paint_ClearWindows(150, 80, 150 + Font20.Width * 7, 80 + Font20.Height, WHITE);
|
||||||
|
Paint_DrawTime(150, 80, &sPaint_time, &Font20, WHITE, BLACK);
|
||||||
|
|
||||||
|
num = num - 1;
|
||||||
|
if(num == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
EPD_2in13_V4_Display_Partial(BlackImage);
|
||||||
|
DEV_Delay_ms(500);//Analog clock 1s
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Debug("Clear...\r\n");
|
||||||
|
EPD_2in13_V4_Init();
|
||||||
|
EPD_2in13_V4_Clear();
|
||||||
|
|
||||||
|
Debug("Goto Sleep...\r\n");
|
||||||
|
EPD_2in13_V4_Sleep();
|
||||||
|
free(BlackImage);
|
||||||
|
BlackImage = NULL;
|
||||||
|
DEV_Delay_ms(2000);//important, at least 2s
|
||||||
|
// close 5V
|
||||||
|
Debug("close 5V, Module enters 0 power consumption ...\r\n");
|
||||||
|
DEV_Module_Exit();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,123 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : EPD_2in13b_V3_test.c
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : 2.13inch B V3 e-paper test demo
|
||||||
|
* | Info :
|
||||||
|
*----------------
|
||||||
|
* | This version: V1.0
|
||||||
|
* | Date : 2020-04-13
|
||||||
|
* | Info :
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documnetation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in
|
||||||
|
# all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
# THE SOFTWARE.
|
||||||
|
#
|
||||||
|
******************************************************************************/
|
||||||
|
#include "EPD_Test.h"
|
||||||
|
#include "EPD_2in13b_V3.h"
|
||||||
|
|
||||||
|
int EPD_2in13b_V3_test(void)
|
||||||
|
{
|
||||||
|
printf("EPD_2IN13B_V3_test Demo\r\n");
|
||||||
|
if(DEV_Module_Init()!=0){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("e-Paper Init and Clear...\r\n");
|
||||||
|
EPD_2IN13B_V3_Init();
|
||||||
|
EPD_2IN13B_V3_Clear();
|
||||||
|
DEV_Delay_ms(500);
|
||||||
|
|
||||||
|
//Create a new image cache named IMAGE_BW and fill it with white
|
||||||
|
UBYTE *BlackImage, *RYImage; // Red or Yellow
|
||||||
|
UWORD Imagesize = ((EPD_2IN13B_V3_WIDTH % 8 == 0)? (EPD_2IN13B_V3_WIDTH / 8 ): (EPD_2IN13B_V3_WIDTH / 8 + 1)) * EPD_2IN13B_V3_HEIGHT;
|
||||||
|
if((BlackImage = (UBYTE *)malloc(Imagesize)) == NULL) {
|
||||||
|
printf("Failed to apply for black memory...\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if((RYImage = (UBYTE *)malloc(Imagesize)) == NULL) {
|
||||||
|
printf("Failed to apply for red memory...\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
printf("NewImage:BlackImage and RYImage\r\n");
|
||||||
|
Paint_NewImage(BlackImage, EPD_2IN13B_V3_WIDTH, EPD_2IN13B_V3_HEIGHT, 270, WHITE);
|
||||||
|
Paint_NewImage(RYImage, EPD_2IN13B_V3_WIDTH, EPD_2IN13B_V3_HEIGHT, 270, WHITE);
|
||||||
|
|
||||||
|
//Select Image
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_SelectImage(RYImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
|
||||||
|
#if 1 // show image for array
|
||||||
|
printf("show image for array\r\n");
|
||||||
|
// EPD_2IN13B_V3_Display(gImage_2in13b_b, gImage_2in13b_r);
|
||||||
|
|
||||||
|
EPD_2IN13B_V3_Display(gImage_2in13c_b, gImage_2in13c_y);
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 0 // Drawing on the image
|
||||||
|
/*Horizontal screen*/
|
||||||
|
//1.Draw black image
|
||||||
|
printf("Draw black image\r\n");
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_DrawPoint(5, 70, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(5, 80, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawLine(20, 70, 50, 100, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(50, 70, 20, 100, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawRectangle(60, 70, 90, 100, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawCircle(125, 85, 15, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawString_CN(5, 15, "ÄãºÃabc", &Font12CN, WHITE, BLACK);
|
||||||
|
|
||||||
|
//2.Draw red image
|
||||||
|
printf("Draw red image\r\n");
|
||||||
|
Paint_SelectImage(RYImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_DrawPoint(5, 90, RED, DOT_PIXEL_3X3, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(5, 100, RED, DOT_PIXEL_4X4, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawLine(125, 70, 125, 100, RED, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawLine(110, 85, 140, 85, RED, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawRectangle(20, 70, 50, 100, RED, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawCircle(165, 85, 15, RED, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawString_EN(5, 0, "waveshare Electronics", &Font12, BLACK, WHITE);
|
||||||
|
Paint_DrawNum(5, 50, 987654321, &Font16, WHITE, RED);
|
||||||
|
|
||||||
|
printf("EPD_Display\r\n");
|
||||||
|
EPD_2IN13B_V3_Display(BlackImage, RYImage);
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
printf("Clear...\r\n");
|
||||||
|
EPD_2IN13B_V3_Clear();
|
||||||
|
|
||||||
|
printf("Goto Sleep...\r\n");
|
||||||
|
EPD_2IN13B_V3_Sleep();
|
||||||
|
free(BlackImage);
|
||||||
|
free(RYImage);
|
||||||
|
BlackImage = NULL;
|
||||||
|
RYImage = NULL;
|
||||||
|
DEV_Delay_ms(2000);//important, at least 2s
|
||||||
|
// close 5V
|
||||||
|
printf("close 5V, Module enters 0 power consumption ...\r\n");
|
||||||
|
DEV_Module_Exit();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,122 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : EPD_2in13b_V4_test.c
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : 2.13inch B V4 e-paper test demo
|
||||||
|
* | Info :
|
||||||
|
*----------------
|
||||||
|
* | This version: V1.0
|
||||||
|
* | Date : 2022-08-20
|
||||||
|
* | Info :
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documnetation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in
|
||||||
|
# all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
# THE SOFTWARE.
|
||||||
|
#
|
||||||
|
******************************************************************************/
|
||||||
|
#include "EPD_Test.h"
|
||||||
|
#include "EPD_2in13b_V4.h"
|
||||||
|
#include "time.h"
|
||||||
|
|
||||||
|
int EPD_2in13b_V4_test(void)
|
||||||
|
{
|
||||||
|
printf("EPD_2IN13B_V4_test Demo\r\n");
|
||||||
|
if(DEV_Module_Init()!=0){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("e-Paper Init and Clear...\r\n");
|
||||||
|
EPD_2IN13B_V4_Init();
|
||||||
|
EPD_2IN13B_V4_Clear();
|
||||||
|
DEV_Delay_ms(500);
|
||||||
|
|
||||||
|
//Create a new image cache named IMAGE_BW and fill it with white
|
||||||
|
UBYTE *BlackImage, *RYImage; // Red or Yellow
|
||||||
|
UWORD Imagesize = ((EPD_2IN13B_V4_WIDTH % 8 == 0)? (EPD_2IN13B_V4_WIDTH / 8 ): (EPD_2IN13B_V4_WIDTH / 8 + 1)) * EPD_2IN13B_V4_HEIGHT;
|
||||||
|
if((BlackImage = (UBYTE *)malloc(Imagesize)) == NULL) {
|
||||||
|
printf("Failed to apply for black memory...\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if((RYImage = (UBYTE *)malloc(Imagesize)) == NULL) {
|
||||||
|
printf("Failed to apply for red memory...\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
printf("NewImage:BlackImage and RYImage\r\n");
|
||||||
|
Paint_NewImage(BlackImage, EPD_2IN13B_V4_WIDTH, EPD_2IN13B_V4_HEIGHT, 90, WHITE);
|
||||||
|
Paint_NewImage(RYImage, EPD_2IN13B_V4_WIDTH, EPD_2IN13B_V4_HEIGHT, 90, WHITE);
|
||||||
|
|
||||||
|
//Select Image
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_SelectImage(RYImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
|
||||||
|
#if 1 // show image for array
|
||||||
|
printf("show image for array\r\n");
|
||||||
|
EPD_2IN13B_V4_Display(gImage_2in13b_V4b, gImage_2in13b_V4r);
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1 // Drawing on the image
|
||||||
|
/*Horizontal screen*/
|
||||||
|
//1.Draw black image
|
||||||
|
printf("Draw black image\r\n");
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_DrawPoint(5, 70, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(5, 80, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawLine(20, 70, 50, 100, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(50, 70, 20, 100, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawRectangle(60, 70, 90, 100, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawCircle(125, 85, 15, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawString_CN(5, 15, "ÄãºÃabc", &Font12CN, WHITE, BLACK);
|
||||||
|
|
||||||
|
//2.Draw red image
|
||||||
|
printf("Draw red image\r\n");
|
||||||
|
Paint_SelectImage(RYImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_DrawPoint(5, 90, RED, DOT_PIXEL_3X3, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(5, 100, RED, DOT_PIXEL_4X4, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawLine(125, 70, 125, 100, RED, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawLine(110, 85, 140, 85, RED, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawRectangle(20, 70, 50, 100, RED, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawCircle(165, 85, 15, RED, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawString_EN(5, 0, "waveshare Electronics", &Font12, BLACK, WHITE);
|
||||||
|
Paint_DrawNum(5, 50, 987654321, &Font16, WHITE, RED);
|
||||||
|
|
||||||
|
printf("EPD_Display\r\n");
|
||||||
|
EPD_2IN13B_V4_Display(BlackImage, RYImage);
|
||||||
|
DEV_Delay_ms(5000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
printf("Clear...\r\n");
|
||||||
|
EPD_2IN13B_V4_Clear();
|
||||||
|
|
||||||
|
printf("Goto Sleep...\r\n");
|
||||||
|
EPD_2IN13B_V4_Sleep();
|
||||||
|
free(BlackImage);
|
||||||
|
free(RYImage);
|
||||||
|
BlackImage = NULL;
|
||||||
|
RYImage = NULL;
|
||||||
|
DEV_Delay_ms(2000);//important, at least 2s
|
||||||
|
// close 5V
|
||||||
|
printf("close 5V, Module enters 0 power consumption ...\r\n");
|
||||||
|
DEV_Module_Exit();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,122 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : EPD_2in13bc_test.c
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : 2.13inch B&C e-paper test demo
|
||||||
|
* | Info :
|
||||||
|
*----------------
|
||||||
|
* | This version: V1.0
|
||||||
|
* | Date : 2019-06-13
|
||||||
|
* | Info :
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documnetation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in
|
||||||
|
# all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
# THE SOFTWARE.
|
||||||
|
#
|
||||||
|
******************************************************************************/
|
||||||
|
#include "EPD_Test.h"
|
||||||
|
#include "EPD_2in13bc.h"
|
||||||
|
|
||||||
|
int EPD_2in13bc_test(void)
|
||||||
|
{
|
||||||
|
printf("EPD_2IN13BC_test Demo\r\n");
|
||||||
|
if(DEV_Module_Init()!=0){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("e-Paper Init and Clear...\r\n");
|
||||||
|
EPD_2IN13BC_Init();
|
||||||
|
EPD_2IN13BC_Clear();
|
||||||
|
DEV_Delay_ms(500);
|
||||||
|
|
||||||
|
//Create a new image cache named IMAGE_BW and fill it with white
|
||||||
|
UBYTE *BlackImage, *RYImage; // Red or Yellow
|
||||||
|
UWORD Imagesize = ((EPD_2IN13BC_WIDTH % 8 == 0)? (EPD_2IN13BC_WIDTH / 8 ): (EPD_2IN13BC_WIDTH / 8 + 1)) * EPD_2IN13BC_HEIGHT;
|
||||||
|
if((BlackImage = (UBYTE *)malloc(Imagesize)) == NULL) {
|
||||||
|
printf("Failed to apply for black memory...\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if((RYImage = (UBYTE *)malloc(Imagesize)) == NULL) {
|
||||||
|
printf("Failed to apply for red memory...\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
printf("NewImage:BlackImage and RYImage\r\n");
|
||||||
|
Paint_NewImage(BlackImage, EPD_2IN13BC_WIDTH, EPD_2IN13BC_HEIGHT, 270, WHITE);
|
||||||
|
Paint_NewImage(RYImage, EPD_2IN13BC_WIDTH, EPD_2IN13BC_HEIGHT, 270, WHITE);
|
||||||
|
|
||||||
|
//Select Image
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_SelectImage(RYImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
|
||||||
|
#if 1 // show image for array
|
||||||
|
printf("show image for array\r\n");
|
||||||
|
// EPD_2IN13BC_Display(gImage_2in13b_b, gImage_2in13b_r);
|
||||||
|
|
||||||
|
EPD_2IN13BC_Display(gImage_2in13c_b, gImage_2in13c_y);
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1 // Drawing on the image
|
||||||
|
/*Horizontal screen*/
|
||||||
|
//1.Draw black image
|
||||||
|
printf("Draw black image\r\n");
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_DrawPoint(5, 70, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(5, 80, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawLine(20, 70, 50, 100, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(50, 70, 20, 100, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawRectangle(60, 70, 90, 100, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawCircle(125, 85, 15, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawString_CN(5, 15, "ÄãºÃabc", &Font12CN, WHITE, BLACK);
|
||||||
|
|
||||||
|
//2.Draw red image
|
||||||
|
printf("Draw red image\r\n");
|
||||||
|
Paint_SelectImage(RYImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_DrawPoint(5, 90, RED, DOT_PIXEL_3X3, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(5, 100, RED, DOT_PIXEL_4X4, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawLine(125, 70, 125, 100, RED, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawLine(110, 85, 140, 85, RED, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawRectangle(20, 70, 50, 100, RED, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawCircle(165, 85, 15, RED, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawString_EN(5, 0, "waveshare Electronics", &Font12, BLACK, WHITE);
|
||||||
|
Paint_DrawNum(5, 50, 987654321, &Font16, WHITE, RED);
|
||||||
|
|
||||||
|
printf("EPD_Display\r\n");
|
||||||
|
EPD_2IN13BC_Display(BlackImage, RYImage);
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
printf("Clear...\r\n");
|
||||||
|
EPD_2IN13BC_Clear();
|
||||||
|
|
||||||
|
printf("Goto Sleep...\r\n");
|
||||||
|
EPD_2IN13BC_Sleep();
|
||||||
|
free(BlackImage);
|
||||||
|
free(RYImage);
|
||||||
|
BlackImage = NULL;
|
||||||
|
RYImage = NULL;
|
||||||
|
DEV_Delay_ms(2000);//important, at least 2s
|
||||||
|
// close 5V
|
||||||
|
printf("close 5V, Module enters 0 power consumption ...\r\n");
|
||||||
|
DEV_Module_Exit();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,147 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : EPD_2in13d_test.c
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : 2.9inch e-paper test demo
|
||||||
|
* | Info :
|
||||||
|
*----------------
|
||||||
|
* | This version: V1.0
|
||||||
|
* | Date : 2019-06-13
|
||||||
|
* | Info :
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documnetation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in
|
||||||
|
# all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
# THE SOFTWARE.
|
||||||
|
#
|
||||||
|
******************************************************************************/
|
||||||
|
#include "EPD_Test.h"
|
||||||
|
#include "EPD_2in13d.h"
|
||||||
|
|
||||||
|
int EPD_2in13d_test(void)
|
||||||
|
{
|
||||||
|
printf("EPD_2IN13D_test Demo\r\n");
|
||||||
|
if(DEV_Module_Init()!=0){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("e-Paper Init and Clear...\r\n");
|
||||||
|
EPD_2IN13D_Init();
|
||||||
|
EPD_2IN13D_Clear();
|
||||||
|
DEV_Delay_ms(500);
|
||||||
|
|
||||||
|
//Create a new image cache
|
||||||
|
UBYTE *BlackImage;
|
||||||
|
/* you have to edit the startup_stm32fxxx.s file and set a big enough heap size */
|
||||||
|
UWORD Imagesize = ((EPD_2IN13D_WIDTH % 8 == 0)? (EPD_2IN13D_WIDTH / 8 ): (EPD_2IN13D_WIDTH / 8 + 1)) * EPD_2IN13D_HEIGHT;
|
||||||
|
if((BlackImage = (UBYTE *)malloc(Imagesize)) == NULL) {
|
||||||
|
printf("Failed to apply for black memory...\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
printf("Paint_NewImage\r\n");
|
||||||
|
Paint_NewImage(BlackImage, EPD_2IN13D_WIDTH, EPD_2IN13D_HEIGHT, 270, WHITE);
|
||||||
|
|
||||||
|
#if 1 //show image for array
|
||||||
|
printf("show image for array\r\n");
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_DrawBitMap(gImage_2in13d);
|
||||||
|
|
||||||
|
EPD_2IN13D_Display(BlackImage);
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1 // Drawing on the image
|
||||||
|
printf("Drawing\r\n");
|
||||||
|
//1.Select Image
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
|
||||||
|
// 2.Drawing on the image
|
||||||
|
Paint_DrawString_EN(5, 5, "waveshare", &Font16, BLACK, WHITE);
|
||||||
|
Paint_DrawNum(5, 25, 123456789, &Font16, BLACK, WHITE);
|
||||||
|
Paint_DrawString_CN(5, 35,"ÄãºÃabc", &Font12CN, BLACK, WHITE);
|
||||||
|
Paint_DrawString_CN(5, 60,"΢ѩµç×Ó", &Font24CN, WHITE, BLACK);
|
||||||
|
EPD_2IN13D_Display(BlackImage);
|
||||||
|
DEV_Delay_ms(1000);
|
||||||
|
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_DrawPoint(5, 10, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(5, 25, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(5, 40, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(5, 55, BLACK, DOT_PIXEL_4X4, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawLine(20, 10, 70, 60, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(70, 10, 20, 60, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(170, 15, 170, 55, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawLine(150, 35, 190, 35, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawRectangle(20, 10, 70, 60, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawRectangle(85, 10, 130, 60, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawCircle(170, 35, 20, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawCircle(170, 80, 20, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
EPD_2IN13D_Display(BlackImage);
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 0 //Partial refresh, example shows time
|
||||||
|
printf("Partial refresh\r\n");
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
PAINT_TIME sPaint_time;
|
||||||
|
sPaint_time.Hour = 12;
|
||||||
|
sPaint_time.Min = 34;
|
||||||
|
sPaint_time.Sec = 56;
|
||||||
|
UBYTE num = 10;
|
||||||
|
for (;;) {
|
||||||
|
sPaint_time.Sec = sPaint_time.Sec + 1;
|
||||||
|
if (sPaint_time.Sec == 60) {
|
||||||
|
sPaint_time.Min = sPaint_time.Min + 1;
|
||||||
|
sPaint_time.Sec = 0;
|
||||||
|
if (sPaint_time.Min == 60) {
|
||||||
|
sPaint_time.Hour = sPaint_time.Hour + 1;
|
||||||
|
sPaint_time.Min = 0;
|
||||||
|
if (sPaint_time.Hour == 24) {
|
||||||
|
sPaint_time.Hour = 0;
|
||||||
|
sPaint_time.Min = 0;
|
||||||
|
sPaint_time.Sec = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Paint_ClearWindows(15, 65, 15 + Font20.Width * 7, 65 + Font20.Height, WHITE);
|
||||||
|
Paint_DrawTime(15, 65, &sPaint_time, &Font20, WHITE, BLACK);
|
||||||
|
|
||||||
|
num = num - 1;
|
||||||
|
if(num == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
EPD_2IN13D_DisplayPart(BlackImage);
|
||||||
|
DEV_Delay_ms(500);//Analog clock 1s
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
printf("Clear...\r\n");
|
||||||
|
EPD_2IN13D_Init();
|
||||||
|
EPD_2IN13D_Clear();
|
||||||
|
|
||||||
|
printf("Goto Sleep...\r\n");
|
||||||
|
EPD_2IN13D_Sleep();
|
||||||
|
free(BlackImage);
|
||||||
|
BlackImage = NULL;
|
||||||
|
DEV_Delay_ms(2000);//important, at least 2s
|
||||||
|
|
||||||
|
// close 5V
|
||||||
|
printf("close 5V, Module enters 0 power consumption ...\r\n");
|
||||||
|
DEV_Module_Exit();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,160 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : EPD_2IN66_test.c
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : 2.66inch e-paper test demo
|
||||||
|
* | Info :
|
||||||
|
*----------------
|
||||||
|
* | This version: V1.0
|
||||||
|
* | Date : 2020-07-29
|
||||||
|
* | Info :
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documnetation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in
|
||||||
|
# all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
# THE SOFTWARE.
|
||||||
|
#
|
||||||
|
******************************************************************************/
|
||||||
|
#include "EPD_Test.h"
|
||||||
|
#include "EPD_2in66.h"
|
||||||
|
|
||||||
|
int EPD_2in66_test(void)
|
||||||
|
{
|
||||||
|
printf("EPD_2IN66_test Demo\r\n");
|
||||||
|
if(DEV_Module_Init()!=0){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("e-Paper Init and Clear...\r\n");
|
||||||
|
EPD_2IN66_Init();
|
||||||
|
EPD_2IN66_Clear();
|
||||||
|
DEV_Delay_ms(500);
|
||||||
|
|
||||||
|
//Create a new image cache
|
||||||
|
UBYTE *BlackImage;
|
||||||
|
/* you have to edit the startup_stm32fxxx.s file and set a big enough heap size */
|
||||||
|
UWORD Imagesize = ((EPD_2IN66_WIDTH % 8 == 0)? (EPD_2IN66_WIDTH / 8 ): (EPD_2IN66_WIDTH / 8 + 1)) * EPD_2IN66_HEIGHT;
|
||||||
|
if((BlackImage = (UBYTE *)malloc(Imagesize)) == NULL) {
|
||||||
|
printf("Failed to apply for black memory...\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
printf("Paint_NewImage\r\n");
|
||||||
|
Paint_NewImage(BlackImage, EPD_2IN66_WIDTH, EPD_2IN66_HEIGHT, 270, WHITE);
|
||||||
|
|
||||||
|
#if 1 //show image for array
|
||||||
|
printf("show image for array\r\n");
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_DrawBitMap(gImage_2in66);
|
||||||
|
|
||||||
|
EPD_2IN66_Display(BlackImage);
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1 // Drawing on the image
|
||||||
|
//1.Select Image
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
|
||||||
|
// 2.Drawing on the image
|
||||||
|
printf("Drawing:BlackImage\r\n");
|
||||||
|
Paint_DrawPoint(10, 80, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 90, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 100, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT);
|
||||||
|
|
||||||
|
Paint_DrawLine(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(70, 70, 20, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
|
||||||
|
Paint_DrawRectangle(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawRectangle(80, 70, 130, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
|
||||||
|
Paint_DrawCircle(45, 95, 20, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawCircle(105, 95, 20, WHITE, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
|
||||||
|
Paint_DrawLine(85, 95, 125, 95, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawLine(105, 75, 105, 115, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
|
||||||
|
Paint_DrawString_EN(10, 0, "waveshare", &Font16, BLACK, WHITE);
|
||||||
|
Paint_DrawString_EN(10, 20, "hello world", &Font12, WHITE, BLACK);
|
||||||
|
|
||||||
|
Paint_DrawNum(10, 33, 123456789, &Font12, BLACK, WHITE);
|
||||||
|
Paint_DrawNum(10, 50, 987654321, &Font16, WHITE, BLACK);
|
||||||
|
|
||||||
|
Paint_DrawString_CN(130, 0,"ÄãºÃabc", &Font12CN, BLACK, WHITE);
|
||||||
|
Paint_DrawString_CN(130, 20, "΢ѩµç×Ó", &Font24CN, WHITE, BLACK);
|
||||||
|
|
||||||
|
EPD_2IN66_Display(BlackImage);
|
||||||
|
DEV_Delay_ms(4000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1 //partial refresh, show time
|
||||||
|
printf("EPD_2IN66_DisplayPart\r\n");
|
||||||
|
EPD_2IN66_Init_Partial();
|
||||||
|
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
|
||||||
|
PAINT_TIME sPaint_time; //time struct
|
||||||
|
sPaint_time.Hour = 12;
|
||||||
|
sPaint_time.Min = 34;
|
||||||
|
sPaint_time.Sec = 56;
|
||||||
|
UWORD num = 10;
|
||||||
|
for (;;) {
|
||||||
|
sPaint_time.Sec = sPaint_time.Sec + 1;
|
||||||
|
if (sPaint_time.Sec == 60) {
|
||||||
|
sPaint_time.Min = sPaint_time.Min + 1;
|
||||||
|
sPaint_time.Sec = 0;
|
||||||
|
if (sPaint_time.Min == 60) {
|
||||||
|
sPaint_time.Hour = sPaint_time.Hour + 1;
|
||||||
|
sPaint_time.Min = 0;
|
||||||
|
if (sPaint_time.Hour == 24) {
|
||||||
|
sPaint_time.Hour = 0;
|
||||||
|
sPaint_time.Min = 0;
|
||||||
|
sPaint_time.Sec = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Paint_ClearWindows(180, 100, 296, 152, WHITE);
|
||||||
|
Paint_DrawTime(180, 110, &sPaint_time, &Font20, WHITE, BLACK);
|
||||||
|
|
||||||
|
//num = num - 1;
|
||||||
|
if(num == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Part refresh...\r\n");
|
||||||
|
EPD_2IN66_Display(BlackImage);
|
||||||
|
|
||||||
|
DEV_Delay_ms(500);
|
||||||
|
}
|
||||||
|
EPD_2IN66_Clear();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
printf("Clear...\r\n");
|
||||||
|
EPD_2IN66_Init();
|
||||||
|
EPD_2IN66_Clear();
|
||||||
|
|
||||||
|
printf("Goto Sleep...\r\n");
|
||||||
|
EPD_2IN66_Sleep();
|
||||||
|
|
||||||
|
free(BlackImage);
|
||||||
|
BlackImage = NULL;
|
||||||
|
// close 5V
|
||||||
|
printf("close 5V, Module enters 0 power consumption ...\r\n");
|
||||||
|
DEV_Module_Exit();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,129 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : EPD_2IN66b_test.c
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : 2.66inch e-paper b test demo
|
||||||
|
* | Info :
|
||||||
|
*----------------
|
||||||
|
* | This version: V1.0
|
||||||
|
* | Date : 2020-12-02
|
||||||
|
* | Info :
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documnetation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in
|
||||||
|
# all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
# THE SOFTWARE.
|
||||||
|
#
|
||||||
|
******************************************************************************/
|
||||||
|
#include "EPD_Test.h"
|
||||||
|
#include "EPD_2in66b.h"
|
||||||
|
|
||||||
|
int EPD_2in66b_test(void)
|
||||||
|
{
|
||||||
|
printf("EPD_2IN66B_test Demo\r\n");
|
||||||
|
if(DEV_Module_Init()!=0){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("e-Paper Init and Clear...\r\n");
|
||||||
|
EPD_2IN66B_Init();
|
||||||
|
EPD_2IN66B_Clear();
|
||||||
|
DEV_Delay_ms(500);
|
||||||
|
|
||||||
|
//Create a new image cache
|
||||||
|
UBYTE *BlackImage, *RedImage;
|
||||||
|
/* you have to edit the startup_stm32fxxx.s file and set a big enough heap size */
|
||||||
|
UWORD Imagesize = ((EPD_2IN66B_WIDTH % 8 == 0)? (EPD_2IN66B_WIDTH / 8 ): (EPD_2IN66B_WIDTH / 8 + 1)) * EPD_2IN66B_HEIGHT;
|
||||||
|
if((BlackImage = (UBYTE *)malloc(Imagesize)) == NULL) {
|
||||||
|
printf("Failed to apply for black memory...\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if((RedImage = (UBYTE *)malloc(Imagesize)) == NULL) {
|
||||||
|
printf("Failed to apply for red memory...\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
printf("Paint_NewImage\r\n");
|
||||||
|
Paint_NewImage(BlackImage, EPD_2IN66B_WIDTH, EPD_2IN66B_HEIGHT, 270, WHITE);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_NewImage(RedImage, EPD_2IN66B_WIDTH, EPD_2IN66B_HEIGHT, 270, WHITE);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
|
||||||
|
|
||||||
|
#if 1 //show image for array
|
||||||
|
printf("show image for array\r\n");
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_DrawBitMap(gImage_2in66bb);
|
||||||
|
|
||||||
|
Paint_SelectImage(RedImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_DrawBitMap(gImage_2in66br);
|
||||||
|
|
||||||
|
EPD_2IN66B_Display(BlackImage, RedImage);
|
||||||
|
DEV_Delay_ms(3000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1 // Drawing on the image
|
||||||
|
printf("Drawing\r\n");
|
||||||
|
|
||||||
|
//1.Draw black image
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_DrawPoint(10, 80, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 90, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 100, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 110, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawLine(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(70, 70, 20, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawRectangle(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawRectangle(80, 70, 130, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawString_EN(10, 0, "waveshare", &Font16, BLACK, WHITE);
|
||||||
|
Paint_DrawString_CN(130, 20, "΢ѩµç×Ó", &Font24CN, WHITE, BLACK);
|
||||||
|
Paint_DrawNum(10, 50, 987654321, &Font16, WHITE, BLACK);
|
||||||
|
|
||||||
|
//2.Draw red image
|
||||||
|
Paint_SelectImage(RedImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_DrawCircle(160, 95, 20, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawCircle(210, 95, 20, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawLine(85, 95, 125, 95, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawLine(105, 75, 105, 115, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawString_CN(130, 0,"ÄãºÃabc", &Font12CN, BLACK, WHITE);
|
||||||
|
Paint_DrawString_EN(10, 20, "hello world", &Font12, WHITE, BLACK);
|
||||||
|
Paint_DrawNum(10, 33, 123456789, &Font12, BLACK, WHITE);
|
||||||
|
|
||||||
|
EPD_2IN66B_Display(BlackImage, RedImage);
|
||||||
|
DEV_Delay_ms(3000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
printf("Clear...\r\n");
|
||||||
|
EPD_2IN66B_Clear();
|
||||||
|
|
||||||
|
printf("Goto Sleep...\r\n");
|
||||||
|
EPD_2IN66B_Sleep();
|
||||||
|
free(BlackImage);
|
||||||
|
BlackImage = NULL;
|
||||||
|
free(RedImage);
|
||||||
|
RedImage = NULL;
|
||||||
|
|
||||||
|
DEV_Delay_ms(2000);//important, at least 2s
|
||||||
|
// close 5V
|
||||||
|
printf("close 5V, Module enters 0 power consumption ...\r\n");
|
||||||
|
DEV_Module_Exit();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,325 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : EPD_2in7_V2.c
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : 2.7inch V2 e-paper
|
||||||
|
* | Info :
|
||||||
|
*----------------
|
||||||
|
* | This version: V1.0
|
||||||
|
* | Date : 2022-08-18
|
||||||
|
* | Info :
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documnetation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in
|
||||||
|
# all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
# THE SOFTWARE.
|
||||||
|
#
|
||||||
|
******************************************************************************/
|
||||||
|
#include "EPD_Test.h"
|
||||||
|
#include "EPD_2in7_V2.h"
|
||||||
|
|
||||||
|
int EPD_2in7_V2_test(void)
|
||||||
|
{
|
||||||
|
printf("EPD_2IN7_V2_test Demo\r\n");
|
||||||
|
if(DEV_Module_Init()!=0){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("e-Paper Init and Clear...\r\n");
|
||||||
|
EPD_2IN7_V2_Init();
|
||||||
|
EPD_2IN7_V2_Clear();
|
||||||
|
|
||||||
|
|
||||||
|
//Create a new image cache
|
||||||
|
UBYTE *BlackImage;
|
||||||
|
UWORD Imagesize = ((EPD_2IN7_V2_WIDTH % 8 == 0)? (EPD_2IN7_V2_WIDTH / 8 ): (EPD_2IN7_V2_WIDTH / 8 + 1)) * EPD_2IN7_V2_HEIGHT;
|
||||||
|
if((BlackImage = (UBYTE *)malloc(Imagesize)) == NULL) {
|
||||||
|
printf("Failed to apply for black memory...\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
printf("Paint_NewImage\r\n");
|
||||||
|
Paint_NewImage(BlackImage, EPD_2IN7_V2_WIDTH, EPD_2IN7_V2_HEIGHT, 90, WHITE);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
|
||||||
|
#if 1 // show bmp
|
||||||
|
printf("show image for array\r\n");
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_DrawBitMap(gImage_2in7);
|
||||||
|
EPD_2IN7_V2_Display(BlackImage);
|
||||||
|
DEV_Delay_ms(500);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1 // Drawing on the image
|
||||||
|
Paint_NewImage(BlackImage, EPD_2IN7_V2_WIDTH, EPD_2IN7_V2_HEIGHT, 90, WHITE);
|
||||||
|
printf("Drawing\r\n");
|
||||||
|
//1.Select Image
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
|
||||||
|
// 2.Drawing on the image
|
||||||
|
printf("Drawing:BlackImage\r\n");
|
||||||
|
Paint_DrawPoint(10, 80, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 90, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 100, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT);
|
||||||
|
|
||||||
|
Paint_DrawLine(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(70, 70, 20, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
|
||||||
|
Paint_DrawRectangle(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawRectangle(80, 70, 130, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
|
||||||
|
Paint_DrawCircle(45, 95, 20, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawCircle(105, 95, 20, WHITE, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
|
||||||
|
Paint_DrawLine(85, 95, 125, 95, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawLine(105, 75, 105, 115, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
|
||||||
|
Paint_DrawString_EN(10, 0, "waveshare", &Font16, BLACK, WHITE);
|
||||||
|
Paint_DrawString_EN(10, 20, "hello world", &Font12, WHITE, BLACK);
|
||||||
|
|
||||||
|
Paint_DrawNum(10, 33, 123456789, &Font12, BLACK, WHITE);
|
||||||
|
Paint_DrawNum(10, 50, 987654321, &Font16, WHITE, BLACK);
|
||||||
|
|
||||||
|
Paint_DrawString_CN(130, 0,"ÄãºÃabc", &Font12CN, BLACK, WHITE);
|
||||||
|
Paint_DrawString_CN(130, 20, "΢ѩµç×Ó", &Font24CN, WHITE, BLACK);
|
||||||
|
|
||||||
|
EPD_2IN7_V2_Display_Base(BlackImage);
|
||||||
|
DEV_Delay_ms(3000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1 // Fast Drawing on the image
|
||||||
|
// Fast refresh
|
||||||
|
printf("This is followed by a quick refresh demo\r\n");
|
||||||
|
printf("First, clear the screen\r\n");
|
||||||
|
EPD_2IN7_V2_Init();
|
||||||
|
EPD_2IN7_V2_Clear();
|
||||||
|
|
||||||
|
printf("e-Paper Init Fast\r\n");
|
||||||
|
EPD_2IN7_V2_Init_Fast();
|
||||||
|
Paint_NewImage(BlackImage, EPD_2IN7_V2_WIDTH, EPD_2IN7_V2_HEIGHT, 90, WHITE);
|
||||||
|
printf("Drawing\r\n");
|
||||||
|
//1.Select Image
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
|
||||||
|
printf("show window BMP-----------------\r\n");
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_DrawBitMap(gImage_2in7);
|
||||||
|
EPD_2IN7_V2_Display_Fast(BlackImage);
|
||||||
|
DEV_Delay_ms(500);
|
||||||
|
|
||||||
|
// 2.Drawing on the image
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
printf("Drawing:BlackImage\r\n");
|
||||||
|
Paint_DrawPoint(10, 80, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 90, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 100, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT);
|
||||||
|
|
||||||
|
Paint_DrawLine(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(70, 70, 20, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
|
||||||
|
Paint_DrawRectangle(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawRectangle(80, 70, 130, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
|
||||||
|
Paint_DrawCircle(45, 95, 20, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawCircle(105, 95, 20, WHITE, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
|
||||||
|
Paint_DrawLine(85, 95, 125, 95, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawLine(105, 75, 105, 115, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
|
||||||
|
Paint_DrawString_EN(10, 0, "waveshare", &Font16, BLACK, WHITE);
|
||||||
|
Paint_DrawString_EN(10, 20, "hello world", &Font12, WHITE, BLACK);
|
||||||
|
|
||||||
|
Paint_DrawNum(10, 33, 123456789, &Font12, BLACK, WHITE);
|
||||||
|
Paint_DrawNum(10, 50, 987654321, &Font16, WHITE, BLACK);
|
||||||
|
|
||||||
|
Paint_DrawString_CN(130, 0,"ÄãºÃabc", &Font12CN, BLACK, WHITE);
|
||||||
|
Paint_DrawString_CN(130, 20, "΢ѩµç×Ó", &Font24CN, WHITE, BLACK);
|
||||||
|
|
||||||
|
EPD_2IN7_V2_Display_Fast(BlackImage);
|
||||||
|
DEV_Delay_ms(3000);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1 //Partial refresh, example shows time
|
||||||
|
// If you didn't use the EPD_2IN7_V2_Display_Base() function to refresh the image before,
|
||||||
|
// use the EPD_2IN7_V2_Display_Base_color() function to refresh the background color,
|
||||||
|
// otherwise the background color will be garbled
|
||||||
|
EPD_2IN7_V2_Init();
|
||||||
|
// EPD_2IN7_V2_Display_Base_color(WHITE);
|
||||||
|
Paint_NewImage(BlackImage, 50, 120, 90, WHITE);
|
||||||
|
|
||||||
|
printf("Partial refresh\r\n");
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_SetScale(2);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
|
||||||
|
PAINT_TIME sPaint_time;
|
||||||
|
sPaint_time.Hour = 12;
|
||||||
|
sPaint_time.Min = 34;
|
||||||
|
sPaint_time.Sec = 56;
|
||||||
|
UBYTE num = 15;
|
||||||
|
for (;;) {
|
||||||
|
sPaint_time.Sec = sPaint_time.Sec + 1;
|
||||||
|
if (sPaint_time.Sec == 60) {
|
||||||
|
sPaint_time.Min = sPaint_time.Min + 1;
|
||||||
|
sPaint_time.Sec = 0;
|
||||||
|
if (sPaint_time.Min == 60) {
|
||||||
|
sPaint_time.Hour = sPaint_time.Hour + 1;
|
||||||
|
sPaint_time.Min = 0;
|
||||||
|
if (sPaint_time.Hour == 24) {
|
||||||
|
sPaint_time.Hour = 0;
|
||||||
|
sPaint_time.Min = 0;
|
||||||
|
sPaint_time.Sec = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_DrawRectangle(1, 1, 120, 50, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawTime(10, 15, &sPaint_time, &Font20, WHITE, BLACK);
|
||||||
|
|
||||||
|
num = num - 1;
|
||||||
|
if(num == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
printf("Part refresh...\r\n");
|
||||||
|
EPD_2IN7_V2_Display_Partial(BlackImage, 60, 134, 110, 254); // Xstart must be a multiple of 8
|
||||||
|
DEV_Delay_ms(500);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1 // show image for array
|
||||||
|
free(BlackImage);
|
||||||
|
printf("show Gray------------------------\r\n");
|
||||||
|
Imagesize = ((EPD_2IN7_V2_WIDTH % 4 == 0)? (EPD_2IN7_V2_WIDTH / 4 ): (EPD_2IN7_V2_WIDTH / 4 + 1)) * EPD_2IN7_V2_HEIGHT;
|
||||||
|
if((BlackImage = (UBYTE *)malloc(Imagesize)) == NULL) {
|
||||||
|
printf("Failed to apply for black memory...\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
EPD_2IN7_V2_Init_4GRAY();
|
||||||
|
printf("4 grayscale display\r\n");
|
||||||
|
Paint_NewImage(BlackImage, EPD_2IN7_V2_WIDTH, EPD_2IN7_V2_HEIGHT, 90, WHITE);
|
||||||
|
Paint_SetScale(4);
|
||||||
|
Paint_Clear(0xff);
|
||||||
|
|
||||||
|
Paint_DrawPoint(10, 80, GRAY4, DOT_PIXEL_1X1, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 90, GRAY4, DOT_PIXEL_2X2, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 100, GRAY4, DOT_PIXEL_3X3, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawLine(20, 70, 70, 120, GRAY4, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(70, 70, 20, 120, GRAY4, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawRectangle(20, 70, 70, 120, GRAY4, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawRectangle(80, 70, 130, 120, GRAY4, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawCircle(45, 95, 20, GRAY4, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawCircle(105, 95, 20, GRAY2, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawLine(85, 95, 125, 95, GRAY4, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawLine(105, 75, 105, 115, GRAY4, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawString_EN(10, 0, "waveshare", &Font16, GRAY4, GRAY1);
|
||||||
|
Paint_DrawString_EN(10, 20, "hello world", &Font12, GRAY3, GRAY1);
|
||||||
|
Paint_DrawNum(10, 33, 123456789, &Font12, GRAY4, GRAY2);
|
||||||
|
Paint_DrawNum(10, 50, 987654321, &Font16, GRAY1, GRAY4);
|
||||||
|
Paint_DrawString_CN(150, 0,"ÄãºÃabc", &Font12CN, GRAY4, GRAY1);
|
||||||
|
Paint_DrawString_CN(150, 20,"ÄãºÃabc", &Font12CN, GRAY3, GRAY2);
|
||||||
|
Paint_DrawString_CN(150, 40,"ÄãºÃabc", &Font12CN, GRAY2, GRAY3);
|
||||||
|
Paint_DrawString_CN(150, 60,"ÄãºÃabc", &Font12CN, GRAY1, GRAY4);
|
||||||
|
Paint_DrawString_CN(10, 130, "΢ѩµç×Ó", &Font24CN, GRAY1, GRAY4);
|
||||||
|
EPD_2IN7_V2_4GrayDisplay(BlackImage);
|
||||||
|
DEV_Delay_ms(3000);
|
||||||
|
|
||||||
|
Paint_NewImage(BlackImage, EPD_2IN7_V2_WIDTH, EPD_2IN7_V2_HEIGHT, 0, WHITE);
|
||||||
|
Paint_SetScale(4);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
EPD_2IN7_V2_4GrayDisplay(gImage_2in7_4Gray);
|
||||||
|
DEV_Delay_ms(3000);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
|
||||||
|
EPD_2IN7_V2_Init();
|
||||||
|
EPD_2IN7_V2_Clear();
|
||||||
|
printf("Goto Sleep...\r\n");
|
||||||
|
EPD_2IN7_V2_Sleep();
|
||||||
|
|
||||||
|
int key=0;
|
||||||
|
|
||||||
|
gpio_set_dir(KEY0, GPIO_IN);
|
||||||
|
gpio_pull_up(KEY0);//Need to pull up
|
||||||
|
|
||||||
|
gpio_set_dir(KEY1, GPIO_IN);
|
||||||
|
gpio_pull_up(KEY1);//Need to pull up
|
||||||
|
|
||||||
|
gpio_set_dir(KEY2, GPIO_IN);
|
||||||
|
gpio_pull_up(KEY2);//Need to pull up
|
||||||
|
while(1)
|
||||||
|
{
|
||||||
|
if(DEV_Digital_Read(KEY0 ) == 0 && key==0)
|
||||||
|
{
|
||||||
|
key=1;
|
||||||
|
EPD_2IN7_V2_Init();
|
||||||
|
Paint_DrawBitMap(gImage_2in7);
|
||||||
|
EPD_2IN7_V2_Display(BlackImage);
|
||||||
|
DEV_Delay_ms(3000);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(DEV_Digital_Read(KEY1 ) == 0 && key==0)
|
||||||
|
{
|
||||||
|
key=1;
|
||||||
|
EPD_2IN7_V2_Init_4GRAY();
|
||||||
|
EPD_2IN7_V2_4GrayDisplay(gImage_2in7_4Gray);
|
||||||
|
DEV_Delay_ms(3000);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(DEV_Digital_Read(KEY2 ) == 0 && key==0)
|
||||||
|
{
|
||||||
|
key=1;
|
||||||
|
EPD_2IN7_V2_Init_4GRAY();
|
||||||
|
EPD_2IN7_V2_4GrayDisplay(gImage_2in7_4Gray_1);
|
||||||
|
DEV_Delay_ms(3000);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(DEV_Digital_Read(KEY0 ) == 1&&DEV_Digital_Read(KEY1 ) == 1&&DEV_Digital_Read(KEY2 ) == 1 && key == 1 )
|
||||||
|
{
|
||||||
|
key=0;
|
||||||
|
EPD_2IN7_V2_Init();
|
||||||
|
EPD_2IN7_V2_Clear();
|
||||||
|
printf("Goto Sleep...\r\n");
|
||||||
|
EPD_2IN7_V2_Sleep();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
printf("Clear...\r\n");
|
||||||
|
EPD_2IN7_V2_Init();
|
||||||
|
EPD_2IN7_V2_Clear();
|
||||||
|
|
||||||
|
printf("Goto Sleep...\r\n");
|
||||||
|
EPD_2IN7_V2_Sleep();
|
||||||
|
free(BlackImage);
|
||||||
|
BlackImage = NULL;
|
||||||
|
DEV_Delay_ms(2000);//important, at least 2s
|
||||||
|
// close 5V
|
||||||
|
printf("close 5V, Module enters 0 power consumption ...\r\n");
|
||||||
|
DEV_Module_Exit();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,206 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : EPD_2IN7_test.c
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : 2.9inch e-paper V2 test demo
|
||||||
|
* | Info :
|
||||||
|
*----------------
|
||||||
|
* | This version: V1.0
|
||||||
|
* | Date : 2021-06-03
|
||||||
|
* | Info :
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documnetation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in
|
||||||
|
# all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
# THE SOFTWARE.
|
||||||
|
#
|
||||||
|
******************************************************************************/
|
||||||
|
#include "EPD_Test.h"
|
||||||
|
#include "EPD_2in7.h"
|
||||||
|
|
||||||
|
int EPD_2in7_test(void)
|
||||||
|
{
|
||||||
|
printf("EPD_2IN7_test Demo\r\n");
|
||||||
|
DEV_Module_Init();
|
||||||
|
|
||||||
|
printf("e-Paper Init and Clear...\r\n");
|
||||||
|
EPD_2IN7_Init();
|
||||||
|
EPD_2IN7_Clear();
|
||||||
|
DEV_Delay_ms(500);
|
||||||
|
|
||||||
|
//Create a new image cache
|
||||||
|
UBYTE *BlackImage;
|
||||||
|
/* you have to edit the startup_stm32fxxx.s file and set a big enough heap size */
|
||||||
|
UWORD Imagesize = ((EPD_2IN7_WIDTH % 8 == 0)? (EPD_2IN7_WIDTH / 8 ): (EPD_2IN7_WIDTH / 8 + 1)) * EPD_2IN7_HEIGHT;
|
||||||
|
if((BlackImage = (UBYTE *)malloc(Imagesize)) == NULL) {
|
||||||
|
printf("Failed to apply for black memory...\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
printf("Paint_NewImage\r\n");
|
||||||
|
Paint_NewImage(BlackImage, EPD_2IN7_WIDTH, EPD_2IN7_HEIGHT, 270, WHITE);
|
||||||
|
|
||||||
|
#if 0 // show image for array
|
||||||
|
printf("show image for array\r\n");
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_DrawBitMap(gImage_2in7);
|
||||||
|
EPD_2IN7_Display(BlackImage);
|
||||||
|
DEV_Delay_ms(500);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1 // Drawing on the image
|
||||||
|
//1.Select Image
|
||||||
|
printf("SelectImage:BlackImage\r\n");
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
|
||||||
|
// 2.Drawing on the image
|
||||||
|
printf("Drawing:BlackImage\r\n");
|
||||||
|
Paint_DrawPoint(10, 80, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 90, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 100, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawLine(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(70, 70, 20, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawRectangle(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawRectangle(80, 70, 130, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawCircle(45, 95, 20, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawCircle(105, 95, 20, WHITE, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawLine(85, 95, 125, 95, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawLine(105, 75, 105, 115, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawString_EN(10, 0, "waveshare", &Font16, BLACK, WHITE);
|
||||||
|
Paint_DrawString_EN(10, 20, "hello world", &Font12, WHITE, BLACK);
|
||||||
|
Paint_DrawNum(10, 33, 123456789, &Font12, BLACK, WHITE);
|
||||||
|
Paint_DrawNum(10, 50, 987654321, &Font16, WHITE, BLACK);
|
||||||
|
Paint_DrawString_CN(130, 0,"ÄãºÃabc", &Font12CN, BLACK, WHITE);
|
||||||
|
Paint_DrawString_CN(130, 20, "΢ѩµç×Ó", &Font24CN, WHITE, BLACK);
|
||||||
|
|
||||||
|
printf("EPD_Display\r\n");
|
||||||
|
EPD_2IN7_Display(BlackImage);
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
#endif
|
||||||
|
free(BlackImage);
|
||||||
|
#if 1 // show image for array
|
||||||
|
printf("show Gray------------------------\r\n");
|
||||||
|
Imagesize = ((EPD_2IN7_WIDTH % 4 == 0)? (EPD_2IN7_WIDTH / 4 ): (EPD_2IN7_WIDTH / 4 + 1)) * EPD_2IN7_HEIGHT;
|
||||||
|
if((BlackImage = (UBYTE *)malloc(Imagesize)) == NULL) {
|
||||||
|
printf("Failed to apply for black memory...\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
printf("4 grayscale display\r\n");
|
||||||
|
EPD_2IN7_Init_4Gray();
|
||||||
|
Paint_NewImage(BlackImage, EPD_2IN7_WIDTH, EPD_2IN7_HEIGHT, 270, WHITE);
|
||||||
|
Paint_SetScale(4);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
|
||||||
|
Paint_DrawPoint(10, 80, GRAY4, DOT_PIXEL_1X1, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 90, GRAY4, DOT_PIXEL_2X2, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 100, GRAY4, DOT_PIXEL_3X3, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawLine(20, 70, 70, 120, GRAY4, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(70, 70, 20, 120, GRAY4, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawRectangle(20, 70, 70, 120, GRAY4, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawRectangle(80, 70, 130, 120, GRAY4, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawCircle(45, 95, 20, GRAY4, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawCircle(105, 95, 20, GRAY2, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawLine(85, 95, 125, 95, GRAY4, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawLine(105, 75, 105, 115, GRAY4, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawString_EN(10, 0, "waveshare", &Font16, GRAY4, GRAY1);
|
||||||
|
Paint_DrawString_EN(10, 20, "hello world", &Font12, GRAY3, GRAY1);
|
||||||
|
Paint_DrawNum(10, 33, 123456789, &Font12, GRAY4, GRAY2);
|
||||||
|
Paint_DrawNum(10, 50, 987654321, &Font16, GRAY1, GRAY4);
|
||||||
|
Paint_DrawString_CN(150, 0,"ÄãºÃabc", &Font12CN, GRAY4, GRAY1);
|
||||||
|
Paint_DrawString_CN(150, 20,"ÄãºÃabc", &Font12CN, GRAY3, GRAY2);
|
||||||
|
Paint_DrawString_CN(150, 40,"ÄãºÃabc", &Font12CN, GRAY2, GRAY3);
|
||||||
|
Paint_DrawString_CN(150, 60,"ÄãºÃabc", &Font12CN, GRAY1, GRAY4);
|
||||||
|
Paint_DrawString_CN(10, 130, "΢ѩµç×Ó", &Font24CN, GRAY1, GRAY4);
|
||||||
|
EPD_2IN7_4GrayDisplay(BlackImage);
|
||||||
|
DEV_Delay_ms(3000);
|
||||||
|
/*
|
||||||
|
EPD_2IN7_4GrayDisplay(gImage_2in7_4Gray);
|
||||||
|
DEV_Delay_ms(3000);*/
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
|
||||||
|
EPD_2IN7_Init();
|
||||||
|
EPD_2IN7_Clear();
|
||||||
|
printf("Goto Sleep...\r\n");
|
||||||
|
EPD_2IN7_Sleep();
|
||||||
|
|
||||||
|
int key=0;
|
||||||
|
|
||||||
|
gpio_set_dir(KEY0, GPIO_IN);
|
||||||
|
gpio_pull_up(KEY0);//Need to pull up
|
||||||
|
|
||||||
|
gpio_set_dir(KEY1, GPIO_IN);
|
||||||
|
gpio_pull_up(KEY1);//Need to pull up
|
||||||
|
|
||||||
|
gpio_set_dir(KEY2, GPIO_IN);
|
||||||
|
gpio_pull_up(KEY2);//Need to pull up
|
||||||
|
while(1)
|
||||||
|
{
|
||||||
|
if(DEV_Digital_Read(KEY0 ) == 0 && key==0)
|
||||||
|
{
|
||||||
|
key=1;
|
||||||
|
EPD_2IN7_Init();
|
||||||
|
Paint_DrawBitMap(gImage_2in7);
|
||||||
|
EPD_2IN7_Display(BlackImage);
|
||||||
|
DEV_Delay_ms(3000);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(DEV_Digital_Read(KEY1 ) == 0 && key==0)
|
||||||
|
{
|
||||||
|
key=1;
|
||||||
|
EPD_2IN7_Init_4Gray();
|
||||||
|
EPD_2IN7_4GrayDisplay(gImage_2in7_4Gray);
|
||||||
|
DEV_Delay_ms(3000);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(DEV_Digital_Read(KEY2 ) == 0 && key==0)
|
||||||
|
{
|
||||||
|
key=1;
|
||||||
|
EPD_2IN7_Init_4Gray();
|
||||||
|
EPD_2IN7_4GrayDisplay(gImage_2in7_4Gray_1);
|
||||||
|
DEV_Delay_ms(3000);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(DEV_Digital_Read(KEY0 ) == 1&&DEV_Digital_Read(KEY1 ) == 1&&DEV_Digital_Read(KEY2 ) == 1 && key == 1 )
|
||||||
|
{
|
||||||
|
key=0;
|
||||||
|
EPD_2IN7_Init();
|
||||||
|
EPD_2IN7_Clear();
|
||||||
|
printf("Goto Sleep...\r\n");
|
||||||
|
EPD_2IN7_Sleep();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
EPD_2IN7_Init();
|
||||||
|
printf("Clear...\r\n");
|
||||||
|
EPD_2IN7_Clear();
|
||||||
|
|
||||||
|
printf("Goto Sleep...\r\n");
|
||||||
|
EPD_2IN7_Sleep();
|
||||||
|
free(BlackImage);
|
||||||
|
BlackImage = NULL;
|
||||||
|
|
||||||
|
// close 5V
|
||||||
|
printf("close 5V, Module enters 0 power consumption ...\r\n");
|
||||||
|
DEV_Module_Exit();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,204 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : EPD_2IN9_V2_test.c
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : 2.9inch e-paper V2 test demo
|
||||||
|
* | Info :
|
||||||
|
*----------------
|
||||||
|
* | This version: V1.0
|
||||||
|
* | Date : 2020-10-20
|
||||||
|
* | Info :
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documnetation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in
|
||||||
|
# all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
# THE SOFTWARE.
|
||||||
|
#
|
||||||
|
******************************************************************************/
|
||||||
|
#include "EPD_Test.h"
|
||||||
|
#include "EPD_2in9_V2.h"
|
||||||
|
|
||||||
|
int EPD_2in9_V2_test(void)
|
||||||
|
{
|
||||||
|
printf("EPD_2IN9_V2_test Demo\r\n");
|
||||||
|
if(DEV_Module_Init()!=0){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("e-Paper Init and Clear...\r\n");
|
||||||
|
EPD_2IN9_V2_Init();
|
||||||
|
EPD_2IN9_V2_Clear();
|
||||||
|
|
||||||
|
//Create a new image cache
|
||||||
|
UBYTE *BlackImage;
|
||||||
|
// Additional `*2` on the end to account for four-colour images
|
||||||
|
UWORD Imagesize = ((EPD_2IN9_V2_WIDTH % 8 == 0)? (EPD_2IN9_V2_WIDTH / 8 ): (EPD_2IN9_V2_WIDTH / 8 + 1)) * EPD_2IN9_V2_HEIGHT * 2;
|
||||||
|
if((BlackImage = (UBYTE *)malloc(Imagesize)) == NULL) {
|
||||||
|
printf("Failed to apply for black memory...\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
printf("Paint_NewImage\r\n");
|
||||||
|
Paint_NewImage(BlackImage, EPD_2IN9_V2_WIDTH, EPD_2IN9_V2_HEIGHT, 90, WHITE);
|
||||||
|
Paint_SetScale(2); // b&w
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
|
||||||
|
#if 1 //show image for array
|
||||||
|
Paint_NewImage(BlackImage, EPD_2IN9_V2_WIDTH, EPD_2IN9_V2_HEIGHT, 90, WHITE);
|
||||||
|
Paint_SetScale(2); // b&w
|
||||||
|
printf("show image for array\r\n");
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_DrawBitMap(gImage_2in9);
|
||||||
|
|
||||||
|
EPD_2IN9_V2_Display(BlackImage);
|
||||||
|
DEV_Delay_ms(3000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1 // Drawing on the image
|
||||||
|
Paint_NewImage(BlackImage, EPD_2IN9_V2_WIDTH, EPD_2IN9_V2_HEIGHT, 90, WHITE);
|
||||||
|
Paint_SetScale(2); // b&w
|
||||||
|
printf("Drawing\r\n");
|
||||||
|
//1.Select Image
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
|
||||||
|
// 2.Drawing on the image
|
||||||
|
printf("Drawing:BlackImage\r\n");
|
||||||
|
Paint_DrawPoint(10, 80, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 90, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 100, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT);
|
||||||
|
|
||||||
|
Paint_DrawLine(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(70, 70, 20, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
|
||||||
|
Paint_DrawRectangle(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawRectangle(80, 70, 130, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
|
||||||
|
Paint_DrawCircle(45, 95, 20, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawCircle(105, 95, 20, WHITE, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
|
||||||
|
Paint_DrawLine(85, 95, 125, 95, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawLine(105, 75, 105, 115, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
|
||||||
|
Paint_DrawString_EN(10, 0, "waveshare", &Font16, BLACK, WHITE);
|
||||||
|
Paint_DrawString_EN(10, 20, "hello world", &Font12, WHITE, BLACK);
|
||||||
|
|
||||||
|
Paint_DrawNum(10, 33, 123456789, &Font12, BLACK, WHITE);
|
||||||
|
Paint_DrawNum(10, 50, 987654321, &Font16, WHITE, BLACK);
|
||||||
|
|
||||||
|
Paint_DrawString_CN(130, 0,"ÄãºÃabc", &Font12CN, BLACK, WHITE);
|
||||||
|
Paint_DrawString_CN(130, 20, "΢ѩµç×Ó", &Font24CN, WHITE, BLACK);
|
||||||
|
|
||||||
|
EPD_2IN9_V2_Display_Base(BlackImage);
|
||||||
|
DEV_Delay_ms(3000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1 //Partial refresh, example shows time
|
||||||
|
Paint_NewImage(BlackImage, EPD_2IN9_V2_WIDTH, EPD_2IN9_V2_HEIGHT, 90, WHITE);
|
||||||
|
printf("Partial refresh\r\n");
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
|
||||||
|
PAINT_TIME sPaint_time;
|
||||||
|
sPaint_time.Hour = 12;
|
||||||
|
sPaint_time.Min = 34;
|
||||||
|
sPaint_time.Sec = 56;
|
||||||
|
UBYTE num = 10;
|
||||||
|
for (;;) {
|
||||||
|
sPaint_time.Sec = sPaint_time.Sec + 1;
|
||||||
|
if (sPaint_time.Sec == 60) {
|
||||||
|
sPaint_time.Min = sPaint_time.Min + 1;
|
||||||
|
sPaint_time.Sec = 0;
|
||||||
|
if (sPaint_time.Min == 60) {
|
||||||
|
sPaint_time.Hour = sPaint_time.Hour + 1;
|
||||||
|
sPaint_time.Min = 0;
|
||||||
|
if (sPaint_time.Hour == 24) {
|
||||||
|
sPaint_time.Hour = 0;
|
||||||
|
sPaint_time.Min = 0;
|
||||||
|
sPaint_time.Sec = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Paint_ClearWindows(150, 80, 150 + Font20.Width * 7, 80 + Font20.Height, WHITE);
|
||||||
|
Paint_DrawTime(150, 80, &sPaint_time, &Font20, WHITE, BLACK);
|
||||||
|
|
||||||
|
num = num - 1;
|
||||||
|
if(num == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
EPD_2IN9_V2_Display_Partial(BlackImage);
|
||||||
|
DEV_Delay_ms(500);//Analog clock 1s
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1 //show 4colour image for array
|
||||||
|
free(BlackImage);
|
||||||
|
printf("show Gray------------------------\r\n");
|
||||||
|
Imagesize = ((EPD_2IN9_V2_WIDTH % 4 == 0)? (EPD_2IN9_V2_WIDTH / 4 ): (EPD_2IN9_V2_WIDTH / 4 + 1)) * EPD_2IN9_V2_HEIGHT;
|
||||||
|
if((BlackImage = (UBYTE *)malloc(Imagesize)) == NULL) {
|
||||||
|
printf("Failed to apply for black memory...\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
EPD_2IN9_V2_Gray4_Init();
|
||||||
|
printf("4 grayscale display\r\n");
|
||||||
|
Paint_NewImage(BlackImage, EPD_2IN9_V2_WIDTH, EPD_2IN9_V2_HEIGHT, 90, WHITE);
|
||||||
|
Paint_SetScale(4);
|
||||||
|
Paint_Clear(0xff);
|
||||||
|
|
||||||
|
Paint_DrawPoint(10, 80, GRAY4, DOT_PIXEL_1X1, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 90, GRAY4, DOT_PIXEL_2X2, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 100, GRAY4, DOT_PIXEL_3X3, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawLine(20, 70, 70, 120, GRAY4, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(70, 70, 20, 120, GRAY4, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawRectangle(20, 70, 70, 120, GRAY4, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawRectangle(80, 70, 130, 120, GRAY4, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawCircle(45, 95, 20, GRAY4, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawCircle(105, 95, 20, GRAY2, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawLine(85, 95, 125, 95, GRAY4, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawLine(105, 75, 105, 115, GRAY4, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawString_EN(10, 0, "waveshare", &Font16, GRAY4, GRAY1);
|
||||||
|
Paint_DrawString_EN(10, 20, "hello world", &Font12, GRAY3, GRAY1);
|
||||||
|
Paint_DrawNum(10, 33, 123456789, &Font12, GRAY4, GRAY2);
|
||||||
|
Paint_DrawNum(10, 50, 987654321, &Font16, GRAY1, GRAY4);
|
||||||
|
Paint_DrawString_CN(150, 0,"ÄãºÃabc", &Font12CN, GRAY4, GRAY1);
|
||||||
|
Paint_DrawString_CN(150, 20,"ÄãºÃabc", &Font12CN, GRAY3, GRAY2);
|
||||||
|
Paint_DrawString_CN(150, 40,"ÄãºÃabc", &Font12CN, GRAY2, GRAY3);
|
||||||
|
Paint_DrawString_CN(150, 60,"ÄãºÃabc", &Font12CN, GRAY1, GRAY4);
|
||||||
|
Paint_DrawString_CN(150, 80, "΢ѩµç×Ó", &Font24CN, GRAY1, GRAY4);
|
||||||
|
EPD_2IN9_V2_4GrayDisplay(BlackImage);
|
||||||
|
DEV_Delay_ms(3000);
|
||||||
|
|
||||||
|
Paint_NewImage(BlackImage, EPD_2IN9_V2_WIDTH, EPD_2IN9_V2_HEIGHT, 0, WHITE);
|
||||||
|
Paint_SetScale(4);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_DrawBitMap(gImage_2in9_4gray);
|
||||||
|
EPD_2IN9_V2_4GrayDisplay(BlackImage);
|
||||||
|
DEV_Delay_ms(3000);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
printf("Clear...\r\n");
|
||||||
|
EPD_2IN9_V2_Init();
|
||||||
|
EPD_2IN9_V2_Clear();
|
||||||
|
|
||||||
|
printf("Goto Sleep...\r\n");
|
||||||
|
EPD_2IN9_V2_Sleep();
|
||||||
|
free(BlackImage);
|
||||||
|
BlackImage = NULL;
|
||||||
|
DEV_Delay_ms(2000);//important, at least 2s
|
||||||
|
// close 5V
|
||||||
|
printf("close 5V, Module enters 0 power consumption ...\r\n");
|
||||||
|
DEV_Module_Exit();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,121 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : EPD_2in9b_V3_test.c
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : 2.9inch B V3 e-paper test demo
|
||||||
|
* | Info :
|
||||||
|
*----------------
|
||||||
|
* | This version: V1.1
|
||||||
|
* | Date : 2020-12-03
|
||||||
|
* | Info :
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documnetation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in
|
||||||
|
# all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
# THE SOFTWARE.
|
||||||
|
#
|
||||||
|
******************************************************************************/
|
||||||
|
#include "EPD_Test.h"
|
||||||
|
#include "EPD_2in9b_V3.h"
|
||||||
|
|
||||||
|
int EPD_2in9b_V3_test(void)
|
||||||
|
{
|
||||||
|
printf("EPD_2IN9B_V3_test Demo\r\n");
|
||||||
|
if(DEV_Module_Init()!=0){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("e-Paper Init and Clear...\r\n");
|
||||||
|
EPD_2IN9B_V3_Init();
|
||||||
|
EPD_2IN9B_V3_Clear();
|
||||||
|
DEV_Delay_ms(500);
|
||||||
|
|
||||||
|
//Create a new image cache named IMAGE_BW and fill it with white
|
||||||
|
UBYTE *BlackImage, *RYImage; // Red or Yellow
|
||||||
|
UWORD Imagesize = ((EPD_2IN9B_V3_WIDTH % 8 == 0)? (EPD_2IN9B_V3_WIDTH / 8 ): (EPD_2IN9B_V3_WIDTH / 8 + 1)) * EPD_2IN9B_V3_HEIGHT;
|
||||||
|
if((BlackImage = (UBYTE *)malloc(Imagesize)) == NULL) {
|
||||||
|
printf("Failed to apply for black memory...\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if((RYImage = (UBYTE *)malloc(Imagesize)) == NULL) {
|
||||||
|
printf("Failed to apply for red memory...\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
printf("NewImage:BlackImage and RYImage\r\n");
|
||||||
|
Paint_NewImage(BlackImage, EPD_2IN9B_V3_WIDTH, EPD_2IN9B_V3_HEIGHT, 270, WHITE);
|
||||||
|
Paint_NewImage(RYImage, EPD_2IN9B_V3_WIDTH, EPD_2IN9B_V3_HEIGHT, 270, WHITE);
|
||||||
|
|
||||||
|
//Select Image
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_SelectImage(RYImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
|
||||||
|
#if 1 // show image for array
|
||||||
|
printf("show image for array\r\n");
|
||||||
|
EPD_2IN9B_V3_Display(gImage_2in9bc_b, gImage_2in9bc_ry);
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1 // Drawing on the image
|
||||||
|
/*Horizontal screen*/
|
||||||
|
//1.Draw black image
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_DrawPoint(10, 80, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 90, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 100, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 110, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawLine(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(70, 70, 20, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawRectangle(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawRectangle(80, 70, 130, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawString_EN(10, 0, "waveshare", &Font16, BLACK, WHITE);
|
||||||
|
Paint_DrawString_CN(130, 20, "΢ѩµç×Ó", &Font24CN, WHITE, BLACK);
|
||||||
|
Paint_DrawNum(10, 50, 987654321, &Font16, WHITE, BLACK);
|
||||||
|
|
||||||
|
//2.Draw red image
|
||||||
|
Paint_SelectImage(RYImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_DrawCircle(160, 95, 20, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawCircle(210, 95, 20, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawLine(85, 95, 125, 95, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawLine(105, 75, 105, 115, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawString_CN(130, 0,"ÄãºÃabc", &Font12CN, BLACK, WHITE);
|
||||||
|
Paint_DrawString_EN(10, 20, "hello world", &Font12, WHITE, BLACK);
|
||||||
|
Paint_DrawNum(10, 33, 123456789, &Font12, BLACK, WHITE);
|
||||||
|
|
||||||
|
printf("EPD_Display\r\n");
|
||||||
|
EPD_2IN9B_V3_Display(BlackImage, RYImage);
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
printf("Clear...\r\n");
|
||||||
|
EPD_2IN9B_V3_Clear();
|
||||||
|
|
||||||
|
printf("Goto Sleep...\r\n");
|
||||||
|
EPD_2IN9B_V3_Sleep();
|
||||||
|
free(BlackImage);
|
||||||
|
free(RYImage);
|
||||||
|
BlackImage = NULL;
|
||||||
|
RYImage = NULL;
|
||||||
|
DEV_Delay_ms(2000);//important, at least 2s
|
||||||
|
// close 5V
|
||||||
|
printf("close 5V, Module enters 0 power consumption ...\r\n");
|
||||||
|
DEV_Module_Exit();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,175 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : EPD_2in9b_V4_test.c
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : 2.9inch B V4 e-paper test demo
|
||||||
|
* | Info :
|
||||||
|
*----------------
|
||||||
|
* | This version: V1.0
|
||||||
|
* | Date : 2023-12-18
|
||||||
|
* | Info :
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documnetation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in
|
||||||
|
# all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
# THE SOFTWARE.
|
||||||
|
#
|
||||||
|
******************************************************************************/
|
||||||
|
#include "EPD_Test.h"
|
||||||
|
#include "EPD_2in9b_V4.h"
|
||||||
|
|
||||||
|
int EPD_2in9b_V4_test(void)
|
||||||
|
{
|
||||||
|
printf("EPD_2IN9B_V4_test Demo\r\n");
|
||||||
|
if(DEV_Module_Init()!=0){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("e-Paper Init and Clear...\r\n");
|
||||||
|
EPD_2IN9B_V4_Init();
|
||||||
|
EPD_2IN9B_V4_Clear();
|
||||||
|
DEV_Delay_ms(500);
|
||||||
|
|
||||||
|
|
||||||
|
//Create a new image cache named IMAGE_BW and fill it with white
|
||||||
|
UBYTE *BlackImage, *RYImage; // Red or Yellow
|
||||||
|
UWORD Imagesize = ((EPD_2IN9B_V4_WIDTH % 8 == 0)? (EPD_2IN9B_V4_WIDTH / 8 ): (EPD_2IN9B_V4_WIDTH / 8 + 1)) * EPD_2IN9B_V4_HEIGHT;
|
||||||
|
if((BlackImage = (UBYTE *)malloc(Imagesize)) == NULL) {
|
||||||
|
printf("Failed to apply for black memory...\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if((RYImage = (UBYTE *)malloc(Imagesize)) == NULL) {
|
||||||
|
printf("Failed to apply for red memory...\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
printf("NewImage:BlackImage and RYImage\r\n");
|
||||||
|
Paint_NewImage(BlackImage, EPD_2IN9B_V4_WIDTH, EPD_2IN9B_V4_HEIGHT, 270, WHITE);
|
||||||
|
Paint_NewImage(RYImage, EPD_2IN9B_V4_WIDTH, EPD_2IN9B_V4_HEIGHT, 270, WHITE);
|
||||||
|
|
||||||
|
//Select Image
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_SelectImage(RYImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
|
||||||
|
#if 1 // show image for array
|
||||||
|
EPD_2IN9B_V4_Init_Fast();
|
||||||
|
printf("show image for array\r\n");
|
||||||
|
EPD_2IN9B_V4_Display_Fast(gImage_2in9bc_b, gImage_2in9bc_ry);
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1 // Drawing on the image
|
||||||
|
/*Horizontal screen*/
|
||||||
|
//1.Draw black image
|
||||||
|
EPD_2IN9B_V4_Init();
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_DrawPoint(10, 80, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 90, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 100, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 110, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawLine(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(70, 70, 20, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawRectangle(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawRectangle(80, 70, 130, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawString_EN(10, 0, "waveshare", &Font16, BLACK, WHITE);
|
||||||
|
Paint_DrawString_CN(130, 20, "΢ѩµç×Ó", &Font24CN, WHITE, BLACK);
|
||||||
|
Paint_DrawNum(10, 50, 987654321, &Font16, WHITE, BLACK);
|
||||||
|
|
||||||
|
//2.Draw red image
|
||||||
|
Paint_SelectImage(RYImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
// Paint_DrawCircle(160, 95, 20, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
// Paint_DrawCircle(210, 95, 20, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawLine(85, 95, 125, 95, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawLine(105, 75, 105, 115, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawString_CN(130, 0,"ÄãºÃabc", &Font12CN, BLACK, WHITE);
|
||||||
|
Paint_DrawString_EN(10, 20, "hello world", &Font12, WHITE, BLACK);
|
||||||
|
Paint_DrawNum(10, 33, 123456789, &Font12, BLACK, WHITE);
|
||||||
|
|
||||||
|
printf("EPD_Display\r\n");
|
||||||
|
EPD_2IN9B_V4_Display_Base(BlackImage, RYImage);
|
||||||
|
// EPD_2IN9B_V4_Display(BlackImage, RYImage);
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1 //Partial refresh, example shows time
|
||||||
|
// If you didn't use the EPD_2IN9B_V4_Display_Base() function to refresh the image before,
|
||||||
|
// use the EPD_2IN9B_V4_Display_Base_color() function to refresh the background color,
|
||||||
|
// otherwise the background color will be garbled
|
||||||
|
// EPD_2IN9B_V4_Init();
|
||||||
|
// EPD_2IN9B_V4_Display_Base(BlackImage, RYImage);
|
||||||
|
// EPD_2IN9B_V4_Display_Base_color(WHITE);
|
||||||
|
Paint_NewImage(BlackImage, 50, 120, 270, WHITE);
|
||||||
|
|
||||||
|
printf("Partial refresh\r\n");
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_SetScale(2);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
|
||||||
|
PAINT_TIME sPaint_time;
|
||||||
|
sPaint_time.Hour = 12;
|
||||||
|
sPaint_time.Min = 34;
|
||||||
|
sPaint_time.Sec = 56;
|
||||||
|
UBYTE num = 15;
|
||||||
|
for (;;) {
|
||||||
|
sPaint_time.Sec = sPaint_time.Sec + 1;
|
||||||
|
if (sPaint_time.Sec == 60) {
|
||||||
|
sPaint_time.Min = sPaint_time.Min + 1;
|
||||||
|
sPaint_time.Sec = 0;
|
||||||
|
if (sPaint_time.Min == 60) {
|
||||||
|
sPaint_time.Hour = sPaint_time.Hour + 1;
|
||||||
|
sPaint_time.Min = 0;
|
||||||
|
if (sPaint_time.Hour == 24) {
|
||||||
|
sPaint_time.Hour = 0;
|
||||||
|
sPaint_time.Min = 0;
|
||||||
|
sPaint_time.Sec = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_DrawRectangle(1, 1, 120, 50, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawTime(10, 15, &sPaint_time, &Font20, WHITE, BLACK);
|
||||||
|
|
||||||
|
num = num - 1;
|
||||||
|
if(num == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
printf("Part refresh...\r\n");
|
||||||
|
EPD_2IN9B_V4_Display_Partial(BlackImage, 70, 35, 120, 155); // Xstart must be a multiple of 8
|
||||||
|
DEV_Delay_ms(500);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
printf("Clear...\r\n");
|
||||||
|
EPD_2IN9B_V4_Init();
|
||||||
|
EPD_2IN9B_V4_Clear();
|
||||||
|
|
||||||
|
printf("Goto Sleep...\r\n");
|
||||||
|
EPD_2IN9B_V4_Sleep();
|
||||||
|
free(BlackImage);
|
||||||
|
free(RYImage);
|
||||||
|
BlackImage = NULL;
|
||||||
|
RYImage = NULL;
|
||||||
|
DEV_Delay_ms(2000);//important, at least 2s
|
||||||
|
// close 5V
|
||||||
|
printf("close 5V, Module enters 0 power consumption ...\r\n");
|
||||||
|
DEV_Module_Exit();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,121 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : EPD_2in9bc_test.c
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : 2.9inch B&C e-paper test demo
|
||||||
|
* | Info :
|
||||||
|
*----------------
|
||||||
|
* | This version: V1.0
|
||||||
|
* | Date : 2019-06-12
|
||||||
|
* | Info :
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documnetation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in
|
||||||
|
# all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
# THE SOFTWARE.
|
||||||
|
#
|
||||||
|
******************************************************************************/
|
||||||
|
#include "EPD_Test.h"
|
||||||
|
#include "EPD_2in9bc.h"
|
||||||
|
|
||||||
|
int EPD_2in9bc_test(void)
|
||||||
|
{
|
||||||
|
printf("EPD_2IN9BC_test Demo\r\n");
|
||||||
|
if(DEV_Module_Init()!=0){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("e-Paper Init and Clear...\r\n");
|
||||||
|
EPD_2IN9BC_Init();
|
||||||
|
EPD_2IN9BC_Clear();
|
||||||
|
DEV_Delay_ms(500);
|
||||||
|
|
||||||
|
//Create a new image cache named IMAGE_BW and fill it with white
|
||||||
|
UBYTE *BlackImage, *RYImage; // Red or Yellow
|
||||||
|
UWORD Imagesize = ((EPD_2IN9BC_WIDTH % 8 == 0)? (EPD_2IN9BC_WIDTH / 8 ): (EPD_2IN9BC_WIDTH / 8 + 1)) * EPD_2IN9BC_HEIGHT;
|
||||||
|
if((BlackImage = (UBYTE *)malloc(Imagesize)) == NULL) {
|
||||||
|
printf("Failed to apply for black memory...\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if((RYImage = (UBYTE *)malloc(Imagesize)) == NULL) {
|
||||||
|
printf("Failed to apply for red memory...\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
printf("NewImage:BlackImage and RYImage\r\n");
|
||||||
|
Paint_NewImage(BlackImage, EPD_2IN9BC_WIDTH, EPD_2IN9BC_HEIGHT, 270, WHITE);
|
||||||
|
Paint_NewImage(RYImage, EPD_2IN9BC_WIDTH, EPD_2IN9BC_HEIGHT, 270, WHITE);
|
||||||
|
|
||||||
|
//Select Image
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_SelectImage(RYImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
|
||||||
|
#if 1 // show image for array
|
||||||
|
printf("show image for array\r\n");
|
||||||
|
EPD_2IN9BC_Display(gImage_2in9bc_b, gImage_2in9bc_ry);
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1 // Drawing on the image
|
||||||
|
/*Horizontal screen*/
|
||||||
|
//1.Draw black image
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_DrawPoint(10, 80, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 90, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 100, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 110, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawLine(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(70, 70, 20, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawRectangle(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawRectangle(80, 70, 130, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawString_EN(10, 0, "waveshare", &Font16, BLACK, WHITE);
|
||||||
|
Paint_DrawString_CN(130, 20, "΢ѩµç×Ó", &Font24CN, WHITE, BLACK);
|
||||||
|
Paint_DrawNum(10, 50, 987654321, &Font16, WHITE, BLACK);
|
||||||
|
|
||||||
|
//2.Draw red image
|
||||||
|
Paint_SelectImage(RYImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_DrawCircle(160, 95, 20, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawCircle(210, 95, 20, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawLine(85, 95, 125, 95, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawLine(105, 75, 105, 115, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawString_CN(130, 0,"ÄãºÃabc", &Font12CN, BLACK, WHITE);
|
||||||
|
Paint_DrawString_EN(10, 20, "hello world", &Font12, WHITE, BLACK);
|
||||||
|
Paint_DrawNum(10, 33, 123456789, &Font12, BLACK, WHITE);
|
||||||
|
|
||||||
|
printf("EPD_Display\r\n");
|
||||||
|
EPD_2IN9BC_Display(BlackImage, RYImage);
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
printf("Clear...\r\n");
|
||||||
|
EPD_2IN9BC_Clear();
|
||||||
|
|
||||||
|
printf("Goto Sleep...\r\n");
|
||||||
|
EPD_2IN9BC_Sleep();
|
||||||
|
free(BlackImage);
|
||||||
|
free(RYImage);
|
||||||
|
BlackImage = NULL;
|
||||||
|
RYImage = NULL;
|
||||||
|
DEV_Delay_ms(2000);//important, at least 2s
|
||||||
|
// close 5V
|
||||||
|
printf("close 5V, Module enters 0 power consumption ...\r\n");
|
||||||
|
DEV_Module_Exit();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,146 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : EPD_2in9d_test.c
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : 2.9inch e-paper d test demo
|
||||||
|
* | Info :
|
||||||
|
*----------------
|
||||||
|
* | This version: V1.0
|
||||||
|
* | Date : 2019-06-13
|
||||||
|
* | Info :
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documnetation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in
|
||||||
|
# all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
# THE SOFTWARE.
|
||||||
|
#
|
||||||
|
******************************************************************************/
|
||||||
|
#include "EPD_Test.h"
|
||||||
|
#include "EPD_2in9d.h"
|
||||||
|
|
||||||
|
int EPD_2in9d_test(void)
|
||||||
|
{
|
||||||
|
printf("EPD_2IN9D_test Demo\r\n");
|
||||||
|
if(DEV_Module_Init()!=0){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("e-Paper Init and Clear...\r\n");
|
||||||
|
EPD_2IN9D_Init();
|
||||||
|
EPD_2IN9D_Clear();
|
||||||
|
DEV_Delay_ms(500);
|
||||||
|
|
||||||
|
//Create a new image cache
|
||||||
|
UBYTE *BlackImage;
|
||||||
|
/* you have to edit the startup_stm32fxxx.s file and set a big enough heap size */
|
||||||
|
UWORD Imagesize = ((EPD_2IN9D_WIDTH % 8 == 0)? (EPD_2IN9D_WIDTH / 8 ): (EPD_2IN9D_WIDTH / 8 + 1)) * EPD_2IN9D_HEIGHT;
|
||||||
|
if((BlackImage = (UBYTE *)malloc(Imagesize)) == NULL) {
|
||||||
|
printf("Failed to apply for black memory...\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
printf("Paint_NewImage\r\n");
|
||||||
|
Paint_NewImage(BlackImage, EPD_2IN9D_WIDTH, EPD_2IN9D_HEIGHT, 270, WHITE);
|
||||||
|
|
||||||
|
#if 1 //show image for array
|
||||||
|
printf("show image for array\r\n");
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_DrawBitMap(gImage_2in9);
|
||||||
|
|
||||||
|
EPD_2IN9D_Display(BlackImage);
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1 // Drawing on the image
|
||||||
|
//1.Select Image
|
||||||
|
printf("SelectImage:BlackImage\r\n");
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
|
||||||
|
// 2.Drawing on the image
|
||||||
|
printf("Drawing:BlackImage\r\n");
|
||||||
|
Paint_DrawPoint(10, 80, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 90, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 100, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawLine(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(70, 70, 20, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawRectangle(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawRectangle(80, 70, 130, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawCircle(45, 95, 20, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawCircle(105, 95, 20, WHITE, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawLine(85, 95, 125, 95, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawLine(105, 75, 105, 115, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawString_EN(10, 0, "waveshare", &Font16, BLACK, WHITE);
|
||||||
|
Paint_DrawString_EN(10, 20, "hello world", &Font12, WHITE, BLACK);
|
||||||
|
Paint_DrawNum(10, 33, 123456789, &Font12, BLACK, WHITE);
|
||||||
|
Paint_DrawNum(10, 50, 987654321, &Font16, WHITE, BLACK);
|
||||||
|
Paint_DrawString_CN(130, 0, "ÄãºÃabc", &Font12CN, BLACK, WHITE);
|
||||||
|
Paint_DrawString_CN(130, 20, "΢ѩµç×Ó", &Font24CN, WHITE, BLACK);
|
||||||
|
|
||||||
|
printf("EPD_Display\r\n");
|
||||||
|
EPD_2IN9D_Display(BlackImage);
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1 //Partial refresh, example shows time
|
||||||
|
printf("Partial refresh\r\n");
|
||||||
|
PAINT_TIME sPaint_time;
|
||||||
|
sPaint_time.Hour = 12;
|
||||||
|
sPaint_time.Min = 34;
|
||||||
|
sPaint_time.Sec = 56;
|
||||||
|
UBYTE num = 20;
|
||||||
|
for (;;) {
|
||||||
|
sPaint_time.Sec = sPaint_time.Sec + 1;
|
||||||
|
if (sPaint_time.Sec == 60) {
|
||||||
|
sPaint_time.Min = sPaint_time.Min + 1;
|
||||||
|
sPaint_time.Sec = 0;
|
||||||
|
if (sPaint_time.Min == 60) {
|
||||||
|
sPaint_time.Hour = sPaint_time.Hour + 1;
|
||||||
|
sPaint_time.Min = 0;
|
||||||
|
if (sPaint_time.Hour == 24) {
|
||||||
|
sPaint_time.Hour = 0;
|
||||||
|
sPaint_time.Min = 0;
|
||||||
|
sPaint_time.Sec = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Paint_ClearWindows(150, 80, 150 + Font20.Width * 7, 80 + Font20.Height, WHITE);
|
||||||
|
Paint_DrawTime(150, 80, &sPaint_time, &Font20, WHITE, BLACK);
|
||||||
|
|
||||||
|
num = num - 1;
|
||||||
|
if(num == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
EPD_2IN9D_DisplayPart(BlackImage);
|
||||||
|
DEV_Delay_ms(500);//Analog clock 1s
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
printf("Clear...\r\n");
|
||||||
|
// EPD_2IN9D_Init();
|
||||||
|
EPD_2IN9D_Clear();
|
||||||
|
|
||||||
|
printf("Goto Sleep...\r\n");
|
||||||
|
EPD_2IN9D_Sleep();
|
||||||
|
free(BlackImage);
|
||||||
|
BlackImage = NULL;
|
||||||
|
DEV_Delay_ms(2000);//important, at least 2s
|
||||||
|
// close 5V
|
||||||
|
printf("close 5V, Module enters 0 power consumption ...\r\n");
|
||||||
|
DEV_Module_Exit();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,151 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : EPD_3IN7_test.c
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : 3.7inch e-paper test demo
|
||||||
|
* | Info :
|
||||||
|
*----------------
|
||||||
|
* | This version: V1.0
|
||||||
|
* | Date : 2020-07-16
|
||||||
|
* | Info :
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documnetation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in
|
||||||
|
# all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
# THE SOFTWARE.
|
||||||
|
#
|
||||||
|
******************************************************************************/
|
||||||
|
#include "EPD_Test.h"
|
||||||
|
#include "EPD_3in7.h"
|
||||||
|
|
||||||
|
int EPD_3in7_test(void)
|
||||||
|
{
|
||||||
|
printf("EPD_3IN7_test Demo\r\n");
|
||||||
|
if(DEV_Module_Init()!=0){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("e-Paper Init and Clear...\r\n");
|
||||||
|
EPD_3IN7_4Gray_Init();
|
||||||
|
EPD_3IN7_4Gray_Clear();
|
||||||
|
DEV_Delay_ms(500);
|
||||||
|
|
||||||
|
//Create a new image cache
|
||||||
|
UBYTE *BlackImage;
|
||||||
|
/* you have to edit the startup_stm32fxxx.s file and set a big enough heap size */
|
||||||
|
UWORD Imagesize = ((EPD_3IN7_WIDTH % 4 == 0)? (EPD_3IN7_WIDTH / 4 ): (EPD_3IN7_WIDTH / 4 + 1)) * EPD_3IN7_HEIGHT;
|
||||||
|
if((BlackImage = (UBYTE *)malloc(Imagesize)) == NULL) {
|
||||||
|
printf("Failed to apply for black memory...\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Paint_NewImage\r\n");
|
||||||
|
Paint_NewImage(BlackImage, EPD_3IN7_WIDTH, EPD_3IN7_HEIGHT, 90, WHITE);
|
||||||
|
Paint_SetScale(4);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
|
||||||
|
#if 1 // Drawing on the image, partial display
|
||||||
|
//1.Select Image
|
||||||
|
printf("SelectImage:BlackImage\r\n");
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_SetScale(4);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
|
||||||
|
// 2.Drawing on the image
|
||||||
|
printf("Drawing:BlackImage\r\n");
|
||||||
|
Paint_DrawPoint(10, 80, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 90, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 100, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawLine(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(70, 70, 20, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawRectangle(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawRectangle(80, 70, 130, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawCircle(45, 95, 20, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawCircle(105, 95, 20, WHITE, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawLine(85, 95, 125, 95, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawLine(105, 75, 105, 115, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawString_EN(10, 0, "waveshare", &Font16, BLACK, WHITE);
|
||||||
|
Paint_DrawString_EN(10, 20, "hello world", &Font12, WHITE, BLACK);
|
||||||
|
Paint_DrawNum(10, 33, 123456789, &Font12, BLACK, WHITE);
|
||||||
|
Paint_DrawNum(10, 50, 987654321, &Font16, WHITE, BLACK);
|
||||||
|
Paint_DrawString_EN(10, 150, "GRAY1 with black background", &Font24, BLACK, GRAY1);
|
||||||
|
Paint_DrawString_EN(10, 175, "GRAY2 with white background", &Font24, WHITE, GRAY2);
|
||||||
|
Paint_DrawString_EN(10, 200, "GRAY3 with white background", &Font24, WHITE, GRAY3);
|
||||||
|
Paint_DrawString_EN(10, 225, "GRAY4 with white background", &Font24, WHITE, GRAY4);
|
||||||
|
printf("EPD_Display\r\n");
|
||||||
|
EPD_3IN7_4Gray_Display(BlackImage);
|
||||||
|
DEV_Delay_ms(4000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1 // partial update, just 1 Gray mode
|
||||||
|
Paint_NewImage(BlackImage, 50, 120, 90, WHITE);
|
||||||
|
EPD_3IN7_1Gray_Init(); //init 1 Gray mode
|
||||||
|
EPD_3IN7_1Gray_Clear();
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_SetScale(2);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
printf("show time, partial update, just 1 Gary mode\r\n");
|
||||||
|
PAINT_TIME sPaint_time;
|
||||||
|
sPaint_time.Hour = 12;
|
||||||
|
sPaint_time.Min = 34;
|
||||||
|
sPaint_time.Sec = 56;
|
||||||
|
UBYTE num = 15;
|
||||||
|
for (;;) {
|
||||||
|
sPaint_time.Sec = sPaint_time.Sec + 1;
|
||||||
|
if (sPaint_time.Sec == 60) {
|
||||||
|
sPaint_time.Min = sPaint_time.Min + 1;
|
||||||
|
sPaint_time.Sec = 0;
|
||||||
|
if (sPaint_time.Min == 60) {
|
||||||
|
sPaint_time.Hour = sPaint_time.Hour + 1;
|
||||||
|
sPaint_time.Min = 0;
|
||||||
|
if (sPaint_time.Hour == 24) {
|
||||||
|
sPaint_time.Hour = 0;
|
||||||
|
sPaint_time.Min = 0;
|
||||||
|
sPaint_time.Sec = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_DrawRectangle(1, 1, 120, 50, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawTime(10, 15, &sPaint_time, &Font20, WHITE, BLACK);
|
||||||
|
|
||||||
|
num = num - 1;
|
||||||
|
if(num == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Part refresh...\r\n");
|
||||||
|
EPD_3IN7_1Gray_Display_Part(BlackImage, 210, 340, 260, 460); // Xstart must be a multiple of 8
|
||||||
|
DEV_Delay_ms(500);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
EPD_3IN7_4Gray_Init();
|
||||||
|
printf("Clear...\r\n");
|
||||||
|
EPD_3IN7_4Gray_Clear();
|
||||||
|
|
||||||
|
// Sleep & close 5V
|
||||||
|
printf("Goto Sleep...\r\n");
|
||||||
|
EPD_3IN7_Sleep();
|
||||||
|
|
||||||
|
free(BlackImage);
|
||||||
|
BlackImage = NULL;
|
||||||
|
DEV_Delay_ms(2000);//important, at least 2s
|
||||||
|
printf("close 5V, Module enters 0 power consumption ...\r\n");
|
||||||
|
DEV_Module_Exit();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,263 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : EPD_4in2_V2_test.c
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : 4.2inch e-paper V2 test demo
|
||||||
|
* | Info :
|
||||||
|
*----------------
|
||||||
|
* | This version: V1.0
|
||||||
|
* | Date : 2023-09-12
|
||||||
|
* | Info :
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documnetation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in
|
||||||
|
# all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
# THE SOFTWARE.
|
||||||
|
#
|
||||||
|
******************************************************************************/
|
||||||
|
#include "EPD_Test.h"
|
||||||
|
#include "EPD_4in2_V2.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
int EPD_4in2_V2_test(void)
|
||||||
|
{
|
||||||
|
printf("EPD_4IN2_V2_test Demo\r\n");
|
||||||
|
if(DEV_Module_Init()!=0){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("e-Paper Init and Clear...\r\n");
|
||||||
|
EPD_4IN2_V2_Init();
|
||||||
|
EPD_4IN2_V2_Clear();
|
||||||
|
DEV_Delay_ms(500);
|
||||||
|
|
||||||
|
//Create a new image cache
|
||||||
|
UBYTE *BlackImage;
|
||||||
|
/* you have to edit the startup_stm32fxxx.s file and set a big enough heap size */
|
||||||
|
UWORD Imagesize = ((EPD_4IN2_V2_WIDTH % 8 == 0)? (EPD_4IN2_V2_WIDTH / 8 ): (EPD_4IN2_V2_WIDTH / 8 + 1)) * EPD_4IN2_V2_HEIGHT;
|
||||||
|
if((BlackImage = (UBYTE *)malloc(Imagesize)) == NULL) {
|
||||||
|
printf("Failed to apply for black memory...\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
printf("Paint_NewImage\r\n");
|
||||||
|
Paint_NewImage(BlackImage, EPD_4IN2_V2_WIDTH, EPD_4IN2_V2_HEIGHT, 0, WHITE);
|
||||||
|
|
||||||
|
#if 1 // show bmp
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_DrawBitMap(gImage_4in2);
|
||||||
|
EPD_4IN2_V2_Display(BlackImage);
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 0 // show image for array
|
||||||
|
EPD_4IN2_V2_Init_Fast(Seconds_1S);
|
||||||
|
printf("show image for array\r\n");
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_DrawBitMap(gImage_4in2);
|
||||||
|
EPD_4IN2_V2_Display_Fast(BlackImage);
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1 // Drawing on the image
|
||||||
|
|
||||||
|
EPD_4IN2_V2_Init();
|
||||||
|
//1.Select Image
|
||||||
|
printf("SelectImage:BlackImage\r\n");
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
|
||||||
|
// 2.Drawing on the image
|
||||||
|
printf("Drawing:BlackImage\r\n");
|
||||||
|
Paint_DrawPoint(10, 80, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 90, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 100, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawLine(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(70, 70, 20, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawRectangle(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawRectangle(80, 70, 130, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawCircle(45, 95, 20, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawCircle(105, 95, 20, WHITE, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawLine(85, 95, 125, 95, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawLine(105, 75, 105, 115, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawString_EN(10, 0, "waveshare", &Font16, BLACK, WHITE);
|
||||||
|
Paint_DrawString_EN(10, 20, "hello world", &Font12, WHITE, BLACK);
|
||||||
|
Paint_DrawNum(10, 33, 123456789, &Font12, BLACK, WHITE);
|
||||||
|
Paint_DrawNum(10, 50, 987654321, &Font16, WHITE, BLACK);
|
||||||
|
Paint_DrawString_CN(130, 0, " ???abc", &Font12CN, BLACK, WHITE);
|
||||||
|
Paint_DrawString_CN(130, 20, "??????", &Font24CN, WHITE, BLACK);
|
||||||
|
|
||||||
|
printf("EPD_Display\r\n");
|
||||||
|
// EPD_4IN2_V2_Display(BlackImage);
|
||||||
|
EPD_4IN2_V2_Display(BlackImage);
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
printf("Partial refresh\r\n");
|
||||||
|
Paint_NewImage(BlackImage, 120, 50, 0, WHITE);
|
||||||
|
PAINT_TIME sPaint_time;
|
||||||
|
sPaint_time.Hour = 12;
|
||||||
|
sPaint_time.Min = 34;
|
||||||
|
sPaint_time.Sec = 56;
|
||||||
|
UBYTE num = 10;
|
||||||
|
for (;;) {
|
||||||
|
sPaint_time.Sec = sPaint_time.Sec + 1;
|
||||||
|
if (sPaint_time.Sec == 60) {
|
||||||
|
sPaint_time.Min = sPaint_time.Min + 1;
|
||||||
|
sPaint_time.Sec = 0;
|
||||||
|
if (sPaint_time.Min == 60) {
|
||||||
|
sPaint_time.Hour = sPaint_time.Hour + 1;
|
||||||
|
sPaint_time.Min = 0;
|
||||||
|
if (sPaint_time.Hour == 24) {
|
||||||
|
sPaint_time.Hour = 0;
|
||||||
|
sPaint_time.Min = 0;
|
||||||
|
sPaint_time.Sec = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_DrawRectangle(1, 1, 120, 50, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawTime(10, 15, &sPaint_time, &Font20, WHITE, BLACK);
|
||||||
|
EPD_4IN2_V2_PartialDisplay(BlackImage, 200, 80, 320, 130);
|
||||||
|
DEV_Delay_ms(500);//Analog clock 1s
|
||||||
|
num = num - 1;
|
||||||
|
if(num == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
// EPD_4IN2_V2_Init();
|
||||||
|
// EPD_4IN2_V2_Clear();
|
||||||
|
EPD_4IN2_V2_Init_4Gray();
|
||||||
|
printf("show Gray------------------------\r\n");
|
||||||
|
free(BlackImage);
|
||||||
|
BlackImage = NULL;
|
||||||
|
Imagesize = ((EPD_4IN2_V2_WIDTH % 8 == 0)? (EPD_4IN2_V2_WIDTH / 4 ): (EPD_4IN2_V2_WIDTH / 4 + 1)) * EPD_4IN2_V2_HEIGHT;
|
||||||
|
if((BlackImage = (UBYTE *)malloc(Imagesize)) == NULL) {
|
||||||
|
printf("Failed to apply for black memory...\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
Paint_NewImage(BlackImage, EPD_4IN2_V2_WIDTH, EPD_4IN2_V2_HEIGHT, 0, WHITE);
|
||||||
|
Paint_SetScale(4);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
|
||||||
|
Paint_DrawPoint(10, 80, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 90, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 100, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawLine(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(70, 70, 20, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawRectangle(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawRectangle(80, 70, 130, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawCircle(45, 95, 20, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawCircle(105, 95, 20, WHITE, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawLine(85, 95, 125, 95, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawLine(105, 75, 105, 115, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawString_EN(10, 0, "waveshare", &Font16, BLACK, WHITE);
|
||||||
|
Paint_DrawString_EN(10, 20, "hello world", &Font12, WHITE, BLACK);
|
||||||
|
Paint_DrawNum(10, 33, 123456789, &Font12, BLACK, WHITE);
|
||||||
|
Paint_DrawNum(10, 50, 987654321, &Font16, WHITE, BLACK);
|
||||||
|
Paint_DrawString_CN(140, 0, "???abc", &Font12CN, GRAY1, GRAY4);
|
||||||
|
Paint_DrawString_CN(140, 40, "???abc", &Font12CN, GRAY2, GRAY3);
|
||||||
|
Paint_DrawString_CN(140, 80, "???abc", &Font12CN, GRAY3, GRAY2);
|
||||||
|
Paint_DrawString_CN(140, 120, "???abc", &Font12CN, GRAY4, GRAY1);
|
||||||
|
|
||||||
|
Paint_DrawString_CN(220, 0, "??????", &Font24CN, GRAY1, GRAY4);
|
||||||
|
Paint_DrawString_CN(220, 40, "??????", &Font24CN, GRAY2, GRAY3);
|
||||||
|
Paint_DrawString_CN(220, 80, "??????", &Font24CN, GRAY3, GRAY2);
|
||||||
|
Paint_DrawString_CN(220, 120, "??????", &Font24CN, GRAY4, GRAY1);
|
||||||
|
|
||||||
|
EPD_4IN2_V2_Display_4Gray(BlackImage);
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_DrawBitMap(gImage_4in2_4Gray1);
|
||||||
|
EPD_4IN2_V2_Display_4Gray(BlackImage);
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
|
||||||
|
free(BlackImage);
|
||||||
|
BlackImage = NULL;
|
||||||
|
Imagesize = ((EPD_4IN2_V2_WIDTH % 8 == 0)? (EPD_4IN2_V2_WIDTH / 4 ): (EPD_4IN2_V2_WIDTH / 4 + 1)) * EPD_4IN2_V2_HEIGHT;
|
||||||
|
if((BlackImage = (UBYTE *)malloc(Imagesize)) == NULL) {
|
||||||
|
printf("Failed to apply for black memory...\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
Paint_NewImage(BlackImage, EPD_4IN2_V2_WIDTH, EPD_4IN2_V2_HEIGHT, 0, WHITE);
|
||||||
|
Paint_SetScale(4);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
|
||||||
|
int key=0;
|
||||||
|
|
||||||
|
gpio_set_dir(KEY0, GPIO_IN);
|
||||||
|
gpio_pull_up(KEY0);//Need to pull up
|
||||||
|
|
||||||
|
gpio_set_dir(KEY1, GPIO_IN);
|
||||||
|
gpio_pull_up(KEY1);//Need to pull up
|
||||||
|
|
||||||
|
while(1)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(DEV_Digital_Read(KEY0 ) == 0 && key==0)
|
||||||
|
{
|
||||||
|
key=1;
|
||||||
|
EPD_4IN2_V2_Init();
|
||||||
|
Paint_DrawBitMap(gImage_4in2);
|
||||||
|
EPD_4IN2_V2_Display(BlackImage);
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(DEV_Digital_Read(KEY1 ) == 0 && key==0)
|
||||||
|
{
|
||||||
|
key=1;
|
||||||
|
EPD_4IN2_V2_Init_4Gray();
|
||||||
|
Paint_DrawBitMap(gImage_4in2_4Gray1);
|
||||||
|
EPD_4IN2_V2_Display_4Gray(BlackImage);
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(DEV_Digital_Read(KEY0 ) == 1 && DEV_Digital_Read(KEY1 ) == 1 && key == 1 )
|
||||||
|
{
|
||||||
|
key=0;
|
||||||
|
EPD_4IN2_V2_Init();
|
||||||
|
EPD_4IN2_V2_Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
EPD_4IN2_V2_Init();
|
||||||
|
EPD_4IN2_V2_Clear();
|
||||||
|
printf("Goto Sleep...\r\n");
|
||||||
|
EPD_4IN2_V2_Sleep();
|
||||||
|
free(BlackImage);
|
||||||
|
BlackImage = NULL;
|
||||||
|
DEV_Delay_ms(2000);//important, at least 2s
|
||||||
|
// close 5V
|
||||||
|
printf("close 5V, Module enters 0 power consumption ...\r\n");
|
||||||
|
DEV_Module_Exit();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,227 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : EPD_4in2_test.c
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : 4.2inch e-paper test demo
|
||||||
|
* | Info :
|
||||||
|
*----------------
|
||||||
|
* | This version: V1.0
|
||||||
|
* | Date : 2019-06-13
|
||||||
|
* | Info :
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documnetation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in
|
||||||
|
# all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
# THE SOFTWARE.
|
||||||
|
#
|
||||||
|
******************************************************************************/
|
||||||
|
#include "EPD_Test.h"
|
||||||
|
#include "EPD_4in2.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
int EPD_4in2_test(void)
|
||||||
|
{
|
||||||
|
printf("EPD_4IN2_test Demo\r\n");
|
||||||
|
if(DEV_Module_Init()!=0){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("e-Paper Init and Clear...\r\n");
|
||||||
|
EPD_4IN2_Init_Fast();
|
||||||
|
EPD_4IN2_Clear();
|
||||||
|
DEV_Delay_ms(500);
|
||||||
|
|
||||||
|
//Create a new image cache
|
||||||
|
UBYTE *BlackImage;
|
||||||
|
/* you have to edit the startup_stm32fxxx.s file and set a big enough heap size */
|
||||||
|
UWORD Imagesize = ((EPD_4IN2_WIDTH % 8 == 0)? (EPD_4IN2_WIDTH / 8 ): (EPD_4IN2_WIDTH / 8 + 1)) * EPD_4IN2_HEIGHT;
|
||||||
|
if((BlackImage = (UBYTE *)malloc(Imagesize)) == NULL) {
|
||||||
|
printf("Failed to apply for black memory...\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
printf("Paint_NewImage\r\n");
|
||||||
|
Paint_NewImage(BlackImage, EPD_4IN2_WIDTH, EPD_4IN2_HEIGHT, 0, WHITE);
|
||||||
|
|
||||||
|
#if 1 // show image for array
|
||||||
|
printf("show image for array\r\n");
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_DrawBitMap(gImage_4in2);
|
||||||
|
EPD_4IN2_Display(BlackImage);
|
||||||
|
DEV_Delay_ms(500);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1 // Drawing on the image
|
||||||
|
//1.Select Image
|
||||||
|
printf("SelectImage:BlackImage\r\n");
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
|
||||||
|
// 2.Drawing on the image
|
||||||
|
printf("Drawing:BlackImage\r\n");
|
||||||
|
Paint_DrawPoint(10, 80, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 90, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 100, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawLine(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(70, 70, 20, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawRectangle(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawRectangle(80, 70, 130, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawCircle(45, 95, 20, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawCircle(105, 95, 20, WHITE, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawLine(85, 95, 125, 95, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawLine(105, 75, 105, 115, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawString_EN(10, 0, "waveshare", &Font16, BLACK, WHITE);
|
||||||
|
Paint_DrawString_EN(10, 20, "hello world", &Font12, WHITE, BLACK);
|
||||||
|
Paint_DrawNum(10, 33, 123456789, &Font12, BLACK, WHITE);
|
||||||
|
Paint_DrawNum(10, 50, 987654321, &Font16, WHITE, BLACK);
|
||||||
|
Paint_DrawString_CN(130, 0, "���abc", &Font12CN, BLACK, WHITE);
|
||||||
|
Paint_DrawString_CN(130, 20, "ѩ����", &Font24CN, WHITE, BLACK);
|
||||||
|
|
||||||
|
printf("EPD_Display\r\n");
|
||||||
|
EPD_4IN2_Display(BlackImage);
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
printf("Support for partial refresh, but the refresh effect is not good, but it is not recommended\r\n");
|
||||||
|
printf("Partial refresh\r\n");
|
||||||
|
EPD_4IN2_Init_Partial();
|
||||||
|
PAINT_TIME sPaint_time;
|
||||||
|
sPaint_time.Hour = 12;
|
||||||
|
sPaint_time.Min = 34;
|
||||||
|
sPaint_time.Sec = 56;
|
||||||
|
UBYTE num = 20;
|
||||||
|
for (;;) {
|
||||||
|
sPaint_time.Sec = sPaint_time.Sec + 1;
|
||||||
|
if (sPaint_time.Sec == 60) {
|
||||||
|
sPaint_time.Min = sPaint_time.Min + 1;
|
||||||
|
sPaint_time.Sec = 0;
|
||||||
|
if (sPaint_time.Min == 60) {
|
||||||
|
sPaint_time.Hour = sPaint_time.Hour + 1;
|
||||||
|
sPaint_time.Min = 0;
|
||||||
|
if (sPaint_time.Hour == 24) {
|
||||||
|
sPaint_time.Hour = 0;
|
||||||
|
sPaint_time.Min = 0;
|
||||||
|
sPaint_time.Sec = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Paint_ClearWindows(150, 80, 150 + Font20.Width * 7, 80 + Font20.Height, WHITE);
|
||||||
|
Paint_DrawTime(150, 80, &sPaint_time, &Font20, WHITE, BLACK);
|
||||||
|
EPD_4IN2_PartialDisplay(150, 80, 150 + Font20.Width * 7, 80 + Font20.Height, BlackImage);
|
||||||
|
DEV_Delay_ms(500);//Analog clock 1s
|
||||||
|
num = num - 1;
|
||||||
|
if(num == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
EPD_4IN2_Init_4Gray();
|
||||||
|
printf("show Gray------------------------\r\n");
|
||||||
|
free(BlackImage);
|
||||||
|
BlackImage = NULL;
|
||||||
|
Imagesize = ((EPD_4IN2_WIDTH % 8 == 0)? (EPD_4IN2_WIDTH / 4 ): (EPD_4IN2_WIDTH / 4 + 1)) * EPD_4IN2_HEIGHT;
|
||||||
|
if((BlackImage = (UBYTE *)malloc(Imagesize)) == NULL) {
|
||||||
|
printf("Failed to apply for black memory...\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
Paint_NewImage(BlackImage, EPD_4IN2_WIDTH, EPD_4IN2_HEIGHT, 0, WHITE);
|
||||||
|
Paint_SetScale(4);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
|
||||||
|
Paint_DrawPoint(10, 80, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 90, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 100, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawLine(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(70, 70, 20, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawRectangle(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawRectangle(80, 70, 130, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawCircle(45, 95, 20, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawCircle(105, 95, 20, WHITE, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawLine(85, 95, 125, 95, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawLine(105, 75, 105, 115, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawString_EN(10, 0, "waveshare", &Font16, BLACK, WHITE);
|
||||||
|
Paint_DrawString_EN(10, 20, "hello world", &Font12, WHITE, BLACK);
|
||||||
|
Paint_DrawNum(10, 33, 123456789, &Font12, BLACK, WHITE);
|
||||||
|
Paint_DrawNum(10, 50, 987654321, &Font16, WHITE, BLACK);
|
||||||
|
Paint_DrawString_CN(140, 0, "���abc", &Font12CN, GRAY1, GRAY4);
|
||||||
|
Paint_DrawString_CN(140, 40, "���abc", &Font12CN, GRAY2, GRAY3);
|
||||||
|
Paint_DrawString_CN(140, 80, "���abc", &Font12CN, GRAY3, GRAY2);
|
||||||
|
Paint_DrawString_CN(140, 120, "���abc", &Font12CN, GRAY4, GRAY1);
|
||||||
|
|
||||||
|
Paint_DrawString_CN(220, 0, "ѩ����", &Font24CN, GRAY1, GRAY4);
|
||||||
|
Paint_DrawString_CN(220, 40, "ѩ����", &Font24CN, GRAY2, GRAY3);
|
||||||
|
Paint_DrawString_CN(220, 80, "ѩ����", &Font24CN, GRAY3, GRAY2);
|
||||||
|
Paint_DrawString_CN(220, 120, "ѩ����", &Font24CN, GRAY4, GRAY1);
|
||||||
|
|
||||||
|
EPD_4IN2_4GrayDisplay(BlackImage);
|
||||||
|
DEV_Delay_ms(500);
|
||||||
|
|
||||||
|
EPD_4IN2_Clear();
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
|
||||||
|
int key=0;
|
||||||
|
|
||||||
|
gpio_set_dir(KEY0, GPIO_IN);
|
||||||
|
gpio_pull_up(KEY0);//Need to pull up
|
||||||
|
|
||||||
|
gpio_set_dir(KEY1, GPIO_IN);
|
||||||
|
gpio_pull_up(KEY1);//Need to pull up
|
||||||
|
|
||||||
|
while(1)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(DEV_Digital_Read(KEY0 ) == 0 && key==0)
|
||||||
|
{
|
||||||
|
key=1;
|
||||||
|
EPD_4IN2_Init();
|
||||||
|
Paint_DrawBitMap(gImage_4in2);
|
||||||
|
EPD_4IN2_Display(BlackImage);
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(DEV_Digital_Read(KEY1 ) == 0 && key==0)
|
||||||
|
{
|
||||||
|
key=1;
|
||||||
|
EPD_4IN2_Init_4Gray();
|
||||||
|
EPD_4IN2_4GrayDisplay(gImage_4in2_4Gray);
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(DEV_Digital_Read(KEY0 ) == 1 && DEV_Digital_Read(KEY1 ) == 1 && key == 1 )
|
||||||
|
{
|
||||||
|
key=0;
|
||||||
|
EPD_4IN2_Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
EPD_4IN2_Init_Fast();
|
||||||
|
EPD_4IN2_Clear();
|
||||||
|
|
||||||
|
printf("Goto Sleep...\r\n");
|
||||||
|
EPD_4IN2_Sleep();
|
||||||
|
free(BlackImage);
|
||||||
|
BlackImage = NULL;
|
||||||
|
|
||||||
|
// close 5V
|
||||||
|
printf("close 5V, Module enters 0 power consumption ...\r\n");
|
||||||
|
DEV_Module_Exit();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,191 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : EPD_4in2b_V2_test.c
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : 4.2inch B V2 e-paper test demo
|
||||||
|
* | Info :
|
||||||
|
*----------------
|
||||||
|
* | This version: V1.0
|
||||||
|
* | Date : 2020-11-25
|
||||||
|
* | Info :
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documnetation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in
|
||||||
|
# all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
# THE SOFTWARE.
|
||||||
|
#
|
||||||
|
******************************************************************************/
|
||||||
|
#include "EPD_Test.h"
|
||||||
|
#include "EPD_4in2b_V2.h"
|
||||||
|
|
||||||
|
int EPD_4in2b_V2_test(void)
|
||||||
|
{
|
||||||
|
printf("EPD_4IN2B_V2_test Demo\r\n");
|
||||||
|
if(DEV_Module_Init()!=0){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("e-Paper Init and Clear...\r\n");
|
||||||
|
EPD_4IN2B_V2_Init();
|
||||||
|
EPD_4IN2B_V2_Clear();
|
||||||
|
DEV_Delay_ms(500);
|
||||||
|
|
||||||
|
//Create a new image cache named IMAGE_BW and fill it with white
|
||||||
|
UBYTE *BlackImage, *RYImage; // Red or Yellow
|
||||||
|
UWORD Imagesize = ((EPD_4IN2B_V2_WIDTH % 8 == 0)? (EPD_4IN2B_V2_WIDTH / 8 ): (EPD_4IN2B_V2_WIDTH / 8 + 1)) * EPD_4IN2B_V2_HEIGHT;
|
||||||
|
if((BlackImage = (UBYTE *)malloc(Imagesize)) == NULL) {
|
||||||
|
printf("Failed to apply for black memory...\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if((RYImage = (UBYTE *)malloc(Imagesize)) == NULL) {
|
||||||
|
printf("Failed to apply for red memory...\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
printf("NewImage:BlackImage and RYImage\r\n");
|
||||||
|
Paint_NewImage(BlackImage, EPD_4IN2B_V2_WIDTH, EPD_4IN2B_V2_HEIGHT, 180, WHITE);
|
||||||
|
Paint_NewImage(RYImage, EPD_4IN2B_V2_WIDTH, EPD_4IN2B_V2_HEIGHT, 180, WHITE);
|
||||||
|
|
||||||
|
//Select Image
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_SelectImage(RYImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
|
||||||
|
#if 1 // show image for array
|
||||||
|
printf("show image for array\r\n");
|
||||||
|
EPD_4IN2B_V2_Display(gImage_4in2bc_b, gImage_4in2bc_ry);
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1 // Drawing on the image
|
||||||
|
/*Horizontal screen*/
|
||||||
|
//1.Draw black image
|
||||||
|
printf("Draw black image\r\n");
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_DrawPoint(10, 80, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 90, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 100, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 110, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawLine(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(70, 70, 20, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawRectangle(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawRectangle(80, 70, 130, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawString_EN(10, 0, "waveshare", &Font16, BLACK, WHITE);
|
||||||
|
Paint_DrawString_CN(130, 20, "΢ѩµç×Ó", &Font24CN, WHITE, BLACK);
|
||||||
|
Paint_DrawNum(10, 50, 987654321, &Font16, WHITE, BLACK);
|
||||||
|
|
||||||
|
//2.Draw red image
|
||||||
|
printf("Draw red image\r\n");
|
||||||
|
Paint_SelectImage(RYImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_DrawCircle(160, 95, 20, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawCircle(210, 95, 20, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawLine(85, 95, 125, 95, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawLine(105, 75, 105, 115, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawString_CN(130, 0,"ÄãºÃabc", &Font12CN, BLACK, WHITE);
|
||||||
|
Paint_DrawString_EN(10, 20, "hello world", &Font12, WHITE, BLACK);
|
||||||
|
Paint_DrawNum(10, 33, 123456789, &Font12, BLACK, WHITE);
|
||||||
|
|
||||||
|
printf("EPD_Display\r\n");
|
||||||
|
EPD_4IN2B_V2_Display(BlackImage, RYImage);
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
|
||||||
|
EPD_4IN2B_V2_Clear();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
|
||||||
|
int key=0;
|
||||||
|
|
||||||
|
gpio_set_dir(KEY0, GPIO_IN);
|
||||||
|
gpio_pull_up(KEY0);//Need to pull up
|
||||||
|
|
||||||
|
gpio_set_dir(KEY1, GPIO_IN);
|
||||||
|
gpio_pull_up(KEY1);//Need to pull up
|
||||||
|
|
||||||
|
while(1)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(DEV_Digital_Read(KEY0 ) == 0 && key==0)
|
||||||
|
{
|
||||||
|
key=1;
|
||||||
|
printf("show image for array\r\n");
|
||||||
|
EPD_4IN2B_V2_Display(gImage_4in2bc_b, gImage_4in2bc_ry);
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(DEV_Digital_Read(KEY1 ) == 0 && key==0)
|
||||||
|
{
|
||||||
|
key=1;
|
||||||
|
//1.Draw black image
|
||||||
|
printf("Draw black image\r\n");
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_DrawPoint(10, 80, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 90, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 100, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 110, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawLine(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(70, 70, 20, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawRectangle(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawRectangle(80, 70, 130, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawString_EN(10, 0, "waveshare", &Font16, BLACK, WHITE);
|
||||||
|
Paint_DrawString_CN(130, 20, "΢ѩµç×Ó", &Font24CN, WHITE, BLACK);
|
||||||
|
Paint_DrawNum(10, 50, 987654321, &Font16, WHITE, BLACK);
|
||||||
|
|
||||||
|
//2.Draw red image
|
||||||
|
printf("Draw red image\r\n");
|
||||||
|
Paint_SelectImage(RYImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_DrawCircle(160, 95, 20, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawCircle(210, 95, 20, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawLine(85, 95, 125, 95, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawLine(105, 75, 105, 115, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawString_CN(130, 0,"ÄãºÃabc", &Font12CN, BLACK, WHITE);
|
||||||
|
Paint_DrawString_EN(10, 20, "hello world", &Font12, WHITE, BLACK);
|
||||||
|
Paint_DrawNum(10, 33, 123456789, &Font12, BLACK, WHITE);
|
||||||
|
|
||||||
|
printf("EPD_Display\r\n");
|
||||||
|
EPD_4IN2B_V2_Display(BlackImage, RYImage);
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(DEV_Digital_Read(KEY0 ) == 1 && DEV_Digital_Read(KEY1 ) == 1 && key == 1 )
|
||||||
|
{
|
||||||
|
key=0;
|
||||||
|
EPD_4IN2B_V2_Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
printf("Clear...\r\n");
|
||||||
|
EPD_4IN2B_V2_Clear();
|
||||||
|
|
||||||
|
printf("Goto Sleep...\r\n");
|
||||||
|
EPD_4IN2B_V2_Sleep();
|
||||||
|
free(BlackImage);
|
||||||
|
free(RYImage);
|
||||||
|
BlackImage = NULL;
|
||||||
|
RYImage = NULL;
|
||||||
|
DEV_Delay_ms(2000);//important, at least 2s
|
||||||
|
// close 5V
|
||||||
|
printf("close 5V, Module enters 0 power consumption ...\r\n");
|
||||||
|
DEV_Module_Exit();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,122 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : EPD_4in2b_V2_test.c
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : 4.2inch B V2 e-paper test demo
|
||||||
|
* | Info :
|
||||||
|
*----------------
|
||||||
|
* | This version: V1.0
|
||||||
|
* | Date : 2020-04-23
|
||||||
|
* | Info :
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documnetation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in
|
||||||
|
# all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
# THE SOFTWARE.
|
||||||
|
#
|
||||||
|
******************************************************************************/
|
||||||
|
#include "EPD_Test.h"
|
||||||
|
#include "EPD_4in2b_V2_old.h"
|
||||||
|
|
||||||
|
int EPD_4in2b_V2_test_old(void)
|
||||||
|
{
|
||||||
|
printf("EPD_4IN2B_V2_test Demo\r\n");
|
||||||
|
if(DEV_Module_Init()!=0){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("e-Paper Init and Clear...\r\n");
|
||||||
|
EPD_4IN2B_V2_Init_1();
|
||||||
|
EPD_4IN2B_V2_Clear_1();
|
||||||
|
DEV_Delay_ms(500);
|
||||||
|
|
||||||
|
//Create a new image cache named IMAGE_BW and fill it with white
|
||||||
|
UBYTE *BlackImage, *RYImage; // Red or Yellow
|
||||||
|
UWORD Imagesize = ((EPD_4IN2B_V2_WIDTH % 8 == 0)? (EPD_4IN2B_V2_WIDTH / 8 ): (EPD_4IN2B_V2_WIDTH / 8 + 1)) * EPD_4IN2B_V2_HEIGHT;
|
||||||
|
if((BlackImage = (UBYTE *)malloc(Imagesize)) == NULL) {
|
||||||
|
printf("Failed to apply for black memory...\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if((RYImage = (UBYTE *)malloc(Imagesize)) == NULL) {
|
||||||
|
printf("Failed to apply for red memory...\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
printf("NewImage:BlackImage and RYImage\r\n");
|
||||||
|
Paint_NewImage(BlackImage, EPD_4IN2B_V2_WIDTH, EPD_4IN2B_V2_HEIGHT, 180, WHITE);
|
||||||
|
Paint_NewImage(RYImage, EPD_4IN2B_V2_WIDTH, EPD_4IN2B_V2_HEIGHT, 180, WHITE);
|
||||||
|
|
||||||
|
//Select Image
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_SelectImage(RYImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
#if 1 // show image for array
|
||||||
|
printf("show image for array\r\n");
|
||||||
|
EPD_4IN2B_V2_Display_1(gImage_4in2bc_b, gImage_4in2bc_ry);
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1 // Drawing on the image
|
||||||
|
/*Horizontal screen*/
|
||||||
|
//1.Draw black image
|
||||||
|
printf("Draw black image\r\n");
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_DrawPoint(10, 80, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 90, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 100, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 110, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawLine(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(70, 70, 20, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawRectangle(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawRectangle(80, 70, 130, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawString_EN(10, 0, "waveshare", &Font16, BLACK, WHITE);
|
||||||
|
Paint_DrawString_CN(130, 20, "΢ѩµç×Ó", &Font24CN, WHITE, BLACK);
|
||||||
|
Paint_DrawNum(10, 50, 987654321, &Font16, WHITE, BLACK);
|
||||||
|
|
||||||
|
//2.Draw red image
|
||||||
|
printf("Draw red image\r\n");
|
||||||
|
Paint_SelectImage(RYImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_DrawCircle(160, 95, 20, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawCircle(210, 95, 20, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawLine(85, 95, 125, 95, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawLine(105, 75, 105, 115, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawString_CN(130, 0,"ÄãºÃabc", &Font12CN, BLACK, WHITE);
|
||||||
|
Paint_DrawString_EN(10, 20, "hello world", &Font12, WHITE, BLACK);
|
||||||
|
Paint_DrawNum(10, 33, 123456789, &Font12, BLACK, WHITE);
|
||||||
|
|
||||||
|
printf("EPD_Display\r\n");
|
||||||
|
EPD_4IN2B_V2_Display_1(BlackImage, RYImage);
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
printf("Clear...\r\n");
|
||||||
|
EPD_4IN2B_V2_Clear_1();
|
||||||
|
|
||||||
|
printf("Goto Sleep...\r\n");
|
||||||
|
EPD_4IN2B_V2_Sleep_1();
|
||||||
|
free(BlackImage);
|
||||||
|
free(RYImage);
|
||||||
|
BlackImage = NULL;
|
||||||
|
RYImage = NULL;
|
||||||
|
DEV_Delay_ms(2000);//important, at least 2s
|
||||||
|
// close 5V
|
||||||
|
printf("close 5V, Module enters 0 power consumption ...\r\n");
|
||||||
|
DEV_Module_Exit();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,195 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : EPD_2IN9_V2_test.c
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : 2.9inch e-paper V2 test demo
|
||||||
|
* | Info :
|
||||||
|
*----------------
|
||||||
|
* | This version: V1.0
|
||||||
|
* | Date : 2021-06-03
|
||||||
|
* | Info :
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documnetation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in
|
||||||
|
# all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
# THE SOFTWARE.
|
||||||
|
#
|
||||||
|
******************************************************************************/
|
||||||
|
#include "EPD_5in65f.h"
|
||||||
|
#include "EPD_Test.h"
|
||||||
|
|
||||||
|
int EPD_5in65f_test(void)
|
||||||
|
{
|
||||||
|
printf("EPD_5in65F_test Demo\r\n");
|
||||||
|
if(DEV_Module_Init()!=0){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("e-Paper Init and Clear...\r\n");
|
||||||
|
EPD_5IN65F_Init();
|
||||||
|
EPD_5IN65F_Clear(EPD_5IN65F_WHITE);
|
||||||
|
DEV_Delay_ms(100);
|
||||||
|
|
||||||
|
UBYTE *BlackImage;
|
||||||
|
/* you have to edit the startup_stm32fxxx.s file and set a big enough heap size */
|
||||||
|
UDOUBLE Imagesize = ((EPD_5IN65F_WIDTH % 2 == 0)? (EPD_5IN65F_WIDTH / 2 ): (EPD_5IN65F_WIDTH / 2 + 1)) * EPD_5IN65F_HEIGHT;
|
||||||
|
Imagesize = Imagesize/4;
|
||||||
|
printf("Not enough memory, only part of the window is displayed\r\n");
|
||||||
|
printf("Imagesize %d\r\n",Imagesize);
|
||||||
|
if((BlackImage = (UBYTE *)malloc(Imagesize)) == NULL) {
|
||||||
|
printf("Failed to apply for black memory...\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
Paint_NewImage(BlackImage, EPD_5IN65F_WIDTH/2, EPD_5IN65F_HEIGHT/2, 0, EPD_5IN65F_WHITE);
|
||||||
|
Paint_SetScale(7);
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
printf("show image for array\r\n");
|
||||||
|
|
||||||
|
EPD_5IN65F_Display(flagimage);
|
||||||
|
|
||||||
|
DEV_Delay_ms(4000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
EPD_5IN65F_Display(gImage_5in65f);
|
||||||
|
//EPD_5IN65F_Display_part(gImage_5in65f, 204, 153, 192, 143);
|
||||||
|
DEV_Delay_ms(5000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
Paint_Clear(EPD_5IN65F_GREEN);
|
||||||
|
printf("Drawing:BlackImage\r\n");
|
||||||
|
Paint_DrawPoint(10, 80, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 90, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 100, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawLine(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(70, 70, 20, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawRectangle(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawRectangle(80, 70, 130, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawCircle(45, 95, 20, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawCircle(105, 95, 20, WHITE, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawLine(85, 95, 125, 95, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawLine(105, 75, 105, 115, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawString_EN(10, 0, "waveshare", &Font16, BLACK, WHITE);
|
||||||
|
Paint_DrawString_EN(10, 20, "hello world", &Font12, WHITE, BLACK);
|
||||||
|
Paint_DrawNum(10, 33, 123456789, &Font12, BLACK, WHITE);
|
||||||
|
Paint_DrawNum(10, 50, 987654321, &Font16, WHITE, BLACK);
|
||||||
|
Paint_DrawString_CN(10, 120, "你好abc", &Font12CN, EPD_5IN65F_BLACK, WHITE);
|
||||||
|
Paint_DrawString_CN(10, 140, "你好abc", &Font12CN, EPD_5IN65F_GREEN, WHITE);
|
||||||
|
Paint_DrawString_CN(10, 160, "你好abc", &Font12CN, EPD_5IN65F_BLUE, WHITE);
|
||||||
|
Paint_DrawString_CN(10, 180, "你好abc", &Font12CN, EPD_5IN65F_RED, WHITE);
|
||||||
|
Paint_DrawString_CN(10, 200, "你好abc", &Font12CN, EPD_5IN65F_ORANGE, WHITE);
|
||||||
|
|
||||||
|
Paint_DrawString_CN(150, 0, "微雪?子", &Font24CN, WHITE, BLACK);
|
||||||
|
Paint_DrawString_CN(150, 40, "微雪?子", &Font24CN, EPD_5IN65F_GREEN, BLACK);
|
||||||
|
Paint_DrawString_CN(150, 80, "微雪?子", &Font24CN, EPD_5IN65F_BLUE, BLACK);
|
||||||
|
Paint_DrawString_CN(150, 120, "微雪?子", &Font24CN, EPD_5IN65F_RED, BLACK);
|
||||||
|
Paint_DrawString_CN(150, 160, "微雪?子", &Font24CN, EPD_5IN65F_YELLOW, BLACK);
|
||||||
|
|
||||||
|
EPD_5IN65F_Display_part(BlackImage, 0, 0, 300, 224);
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
EPD_5IN65F_Clear(EPD_5IN65F_WHITE);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
|
||||||
|
int key=0;
|
||||||
|
|
||||||
|
gpio_set_dir(KEY0, GPIO_IN);
|
||||||
|
gpio_pull_up(KEY0);//Need to pull up
|
||||||
|
|
||||||
|
gpio_set_dir(KEY1, GPIO_IN);
|
||||||
|
gpio_pull_up(KEY1);//Need to pull up
|
||||||
|
|
||||||
|
gpio_set_dir(KEY2, GPIO_IN);
|
||||||
|
gpio_pull_up(KEY2);//Need to pull up
|
||||||
|
while(1)
|
||||||
|
{
|
||||||
|
if(DEV_Digital_Read(KEY0 ) == 0 && key==0)
|
||||||
|
{
|
||||||
|
key=1;
|
||||||
|
EPD_5IN65F_Display(flagimage);
|
||||||
|
DEV_Delay_ms(3000);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(DEV_Digital_Read(KEY1 ) == 0 && key==0)
|
||||||
|
{
|
||||||
|
key=1;
|
||||||
|
EPD_5IN65F_Display(gImage_5in65f);
|
||||||
|
DEV_Delay_ms(3000);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(DEV_Digital_Read(KEY2 ) == 0 && key==0)
|
||||||
|
{
|
||||||
|
key=1;
|
||||||
|
Paint_Clear(EPD_5IN65F_GREEN);
|
||||||
|
printf("Drawing:BlackImage\r\n");
|
||||||
|
Paint_DrawPoint(10, 80, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 90, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 100, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawLine(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(70, 70, 20, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawRectangle(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawRectangle(80, 70, 130, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawCircle(45, 95, 20, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawCircle(105, 95, 20, WHITE, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawLine(85, 95, 125, 95, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawLine(105, 75, 105, 115, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawString_EN(10, 0, "waveshare", &Font16, BLACK, WHITE);
|
||||||
|
Paint_DrawString_EN(10, 20, "hello world", &Font12, WHITE, BLACK);
|
||||||
|
Paint_DrawNum(10, 33, 123456789, &Font12, BLACK, WHITE);
|
||||||
|
Paint_DrawNum(10, 50, 987654321, &Font16, WHITE, BLACK);
|
||||||
|
Paint_DrawString_CN(10, 120, "你好abc", &Font12CN, EPD_5IN65F_BLACK, WHITE);
|
||||||
|
Paint_DrawString_CN(10, 140, "你好abc", &Font12CN, EPD_5IN65F_GREEN, WHITE);
|
||||||
|
Paint_DrawString_CN(10, 160, "你好abc", &Font12CN, EPD_5IN65F_BLUE, WHITE);
|
||||||
|
Paint_DrawString_CN(10, 180, "你好abc", &Font12CN, EPD_5IN65F_RED, WHITE);
|
||||||
|
Paint_DrawString_CN(10, 200, "你好abc", &Font12CN, EPD_5IN65F_ORANGE, WHITE);
|
||||||
|
|
||||||
|
Paint_DrawString_CN(150, 0, "微雪?子", &Font24CN, WHITE, BLACK);
|
||||||
|
Paint_DrawString_CN(150, 40, "微雪?子", &Font24CN, EPD_5IN65F_GREEN, BLACK);
|
||||||
|
Paint_DrawString_CN(150, 80, "微雪?子", &Font24CN, EPD_5IN65F_BLUE, BLACK);
|
||||||
|
Paint_DrawString_CN(150, 120, "微雪?子", &Font24CN, EPD_5IN65F_RED, BLACK);
|
||||||
|
Paint_DrawString_CN(150, 160, "微雪?子", &Font24CN, EPD_5IN65F_YELLOW, BLACK);
|
||||||
|
|
||||||
|
EPD_5IN65F_Display_part(BlackImage, 0, 0, 300, 224);
|
||||||
|
DEV_Delay_ms(3000);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(DEV_Digital_Read(KEY0 ) == 1&&DEV_Digital_Read(KEY1 ) == 1&&DEV_Digital_Read(KEY2 ) == 1 && key == 1 )
|
||||||
|
{
|
||||||
|
key=0;
|
||||||
|
EPD_5IN65F_Clear(EPD_5IN65F_WHITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
printf("e-Paper Clear...\r\n");
|
||||||
|
EPD_5IN65F_Clear(EPD_5IN65F_WHITE);
|
||||||
|
DEV_Delay_ms(1000);
|
||||||
|
EPD_5IN65F_Sleep();
|
||||||
|
|
||||||
|
free(BlackImage);
|
||||||
|
BlackImage = NULL;
|
||||||
|
|
||||||
|
// close 5V
|
||||||
|
printf("close 5V, Module enters 0 power consumption ...\r\n");
|
||||||
|
DEV_Module_Exit();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,110 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : EPD_5in83_V2_test.c
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : 5.83inch e-paper test demo
|
||||||
|
* | Info :
|
||||||
|
*----------------
|
||||||
|
* | This version: V1.0
|
||||||
|
* | Date : 2020-11-23
|
||||||
|
* | Info :
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documnetation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in
|
||||||
|
# all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
# THE SOFTWARE.
|
||||||
|
#
|
||||||
|
******************************************************************************/
|
||||||
|
#include "EPD_Test.h"
|
||||||
|
#include "EPD_5in83_V2.h"
|
||||||
|
|
||||||
|
int EPD_5in83_V2_test(void)
|
||||||
|
{
|
||||||
|
printf("EPD_5IN83_V2_test Demo\r\n");
|
||||||
|
if(DEV_Module_Init()!=0){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("e-Paper Init and Clear...\r\n");
|
||||||
|
EPD_5in83_V2_Init();
|
||||||
|
EPD_5in83_V2_Clear();
|
||||||
|
DEV_Delay_ms(500);
|
||||||
|
|
||||||
|
//Create a new image cache
|
||||||
|
UBYTE *BlackImage;
|
||||||
|
/* you have to edit the startup_stm32fxxx.s file and set a big enough heap size */
|
||||||
|
UWORD Imagesize = ((EPD_5in83_V2_WIDTH % 8 == 0)? (EPD_5in83_V2_WIDTH / 8 ): (EPD_5in83_V2_WIDTH / 8 + 1)) * EPD_5in83_V2_HEIGHT;
|
||||||
|
if((BlackImage = (UBYTE *)malloc(Imagesize)) == NULL) {
|
||||||
|
printf("Failed to apply for black memory...\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
printf("Paint_NewImage\r\n");
|
||||||
|
Paint_NewImage(BlackImage, EPD_5in83_V2_WIDTH, EPD_5in83_V2_HEIGHT, 180, WHITE);
|
||||||
|
|
||||||
|
#if 1 // show image for array
|
||||||
|
printf("show image for array\r\n");
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_DrawBitMap(gImage_5in83_V2);
|
||||||
|
EPD_5in83_V2_Display(BlackImage);
|
||||||
|
DEV_Delay_ms(500);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1 // Drawing on the image
|
||||||
|
//1.Select Image
|
||||||
|
printf("SelectImage:BlackImage\r\n");
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
|
||||||
|
// 2.Drawing on the image
|
||||||
|
printf("Drawing:BlackImage\r\n");
|
||||||
|
Paint_DrawPoint(10, 80, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 90, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 100, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawLine(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(70, 70, 20, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawRectangle(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawRectangle(80, 70, 130, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawCircle(45, 95, 20, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawCircle(105, 95, 20, WHITE, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawLine(85, 95, 125, 95, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawLine(105, 75, 105, 115, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawString_EN(10, 0, "waveshare", &Font16, BLACK, WHITE);
|
||||||
|
Paint_DrawString_EN(10, 20, "hello world", &Font12, WHITE, BLACK);
|
||||||
|
Paint_DrawNum(10, 33, 123456789, &Font12, BLACK, WHITE);
|
||||||
|
Paint_DrawNum(10, 50, 987654321, &Font16, WHITE, BLACK);
|
||||||
|
Paint_DrawString_CN(130, 0, "ÄãºÃAbc", &Font12CN, BLACK, WHITE);
|
||||||
|
Paint_DrawString_CN(130, 20, "΢ѩµç×Ó", &Font24CN, WHITE, BLACK);
|
||||||
|
|
||||||
|
printf("EPD_Display\r\n");
|
||||||
|
EPD_5in83_V2_Display(BlackImage);
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
printf("Clear...\r\n");
|
||||||
|
EPD_5in83_V2_Clear();
|
||||||
|
|
||||||
|
printf("Goto Sleep...\r\n");
|
||||||
|
EPD_5in83_V2_Sleep();
|
||||||
|
free(BlackImage);
|
||||||
|
BlackImage = NULL;
|
||||||
|
DEV_Delay_ms(2000);//important, at least 2s
|
||||||
|
// close 5V
|
||||||
|
printf("close 5V, Module enters 0 power consumption ...\r\n");
|
||||||
|
DEV_Module_Exit();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,121 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : EPD_5in83b_V2_test.c
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : 5.83inch B V2 e-paper test demo
|
||||||
|
* | Info :
|
||||||
|
*----------------
|
||||||
|
* | This version: V1.0
|
||||||
|
* | Date : 2020-07-04
|
||||||
|
* | Info :
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documnetation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in
|
||||||
|
# all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
# THE SOFTWARE.
|
||||||
|
#
|
||||||
|
******************************************************************************/
|
||||||
|
#include "EPD_Test.h"
|
||||||
|
#include "EPD_5in83b_V2.h"
|
||||||
|
|
||||||
|
int EPD_5in83b_V2_test(void)
|
||||||
|
{
|
||||||
|
printf("EPD_5in83b_V2_test Demo\r\n");
|
||||||
|
if(DEV_Module_Init()!=0){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("e-Paper Init and Clear...\r\n");
|
||||||
|
EPD_5IN83B_V2_Init();
|
||||||
|
EPD_5IN83B_V2_Clear();
|
||||||
|
DEV_Delay_ms(500);
|
||||||
|
|
||||||
|
//Create a new image cache named IMAGE_BW and fill it with white
|
||||||
|
UBYTE *BlackImage, *RYImage;
|
||||||
|
UWORD Imagesize = ((EPD_5IN83B_V2_WIDTH % 8 == 0)? (EPD_5IN83B_V2_WIDTH / 8 ): (EPD_5IN83B_V2_WIDTH / 8 + 1)) * EPD_5IN83B_V2_HEIGHT;
|
||||||
|
if((BlackImage = (UBYTE *)malloc(Imagesize)) == NULL) {
|
||||||
|
printf("Failed to apply for black memory...\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if((RYImage = (UBYTE *)malloc(Imagesize)) == NULL) {
|
||||||
|
printf("Failed to apply for red memory...\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
printf("NewImage:BlackImage and RYImage\r\n");
|
||||||
|
Paint_NewImage(BlackImage, EPD_5IN83B_V2_WIDTH, EPD_5IN83B_V2_HEIGHT, 0, WHITE);
|
||||||
|
Paint_NewImage(RYImage, EPD_5IN83B_V2_WIDTH, EPD_5IN83B_V2_HEIGHT, 0, WHITE);
|
||||||
|
|
||||||
|
//Select Image
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_SelectImage(RYImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
|
||||||
|
#if 1 // show image for array
|
||||||
|
printf("show image for array\r\n");
|
||||||
|
EPD_5IN83B_V2_Display(gImage_5in83b_V2_b, gImage_5in83b_V2_r);
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1 // Drawing on the image
|
||||||
|
/*Horizontal screen*/
|
||||||
|
//1.Draw black image
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_DrawPoint(10, 80, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 90, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 100, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 110, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawLine(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(70, 70, 20, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawRectangle(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawRectangle(80, 70, 130, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawString_EN(10, 0, "waveshare", &Font16, BLACK, WHITE);
|
||||||
|
Paint_DrawString_CN(130, 20, "΢ѩµç×Ó", &Font24CN, WHITE, BLACK);
|
||||||
|
Paint_DrawNum(10, 50, 987654321, &Font16, WHITE, BLACK);
|
||||||
|
|
||||||
|
//2.Draw red image
|
||||||
|
Paint_SelectImage(RYImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_DrawCircle(160, 95, 20, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawCircle(210, 95, 20, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawLine(85, 95, 125, 95, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawLine(105, 75, 105, 115, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawString_CN(130, 0,"ÄãºÃAbc", &Font12CN, BLACK, WHITE);
|
||||||
|
Paint_DrawString_EN(10, 20, "hello world", &Font12, WHITE, BLACK);
|
||||||
|
Paint_DrawNum(10, 33, 123456789, &Font12, BLACK, WHITE);
|
||||||
|
|
||||||
|
printf("EPD_Display\r\n");
|
||||||
|
EPD_5IN83B_V2_Display(BlackImage, RYImage);
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
printf("Clear...\r\n");
|
||||||
|
EPD_5IN83B_V2_Clear();
|
||||||
|
|
||||||
|
printf("Goto Sleep...\r\n");
|
||||||
|
EPD_5IN83B_V2_Sleep();
|
||||||
|
free(BlackImage);
|
||||||
|
free(RYImage);
|
||||||
|
BlackImage = NULL;
|
||||||
|
RYImage = NULL;
|
||||||
|
DEV_Delay_ms(2000);//important, at least 2s
|
||||||
|
// close 5V
|
||||||
|
printf("close 5V, Module enters 0 power consumption ...\r\n");
|
||||||
|
DEV_Module_Exit();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,194 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : EPD_7in5_V2_test.c
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : 7.5inch e-paper test demo
|
||||||
|
* | Info :
|
||||||
|
*----------------
|
||||||
|
* | This version: V1.0
|
||||||
|
* | Date : 2019-06-13
|
||||||
|
* | Info :
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documnetation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in
|
||||||
|
# all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
# THE SOFTWARE.
|
||||||
|
#
|
||||||
|
******************************************************************************/
|
||||||
|
#include "EPD_Test.h"
|
||||||
|
#include "EPD_7in5_V2.h"
|
||||||
|
|
||||||
|
int EPD_7in5_V2_test(void)
|
||||||
|
{
|
||||||
|
printf("EPD_7IN5_V2_test Demo\r\n");
|
||||||
|
if(DEV_Module_Init()!=0){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("e-Paper Init and Clear...\r\n");
|
||||||
|
EPD_7IN5_V2_Init();
|
||||||
|
|
||||||
|
EPD_7IN5_V2_Clear();
|
||||||
|
DEV_Delay_ms(500);
|
||||||
|
|
||||||
|
//Create a new image cache
|
||||||
|
UBYTE *BlackImage;
|
||||||
|
/* you have to edit the startup_stm32fxxx.s file and set a big enough heap size */
|
||||||
|
UDOUBLE Imagesize = ((EPD_7IN5_V2_WIDTH % 8 == 0)? (EPD_7IN5_V2_WIDTH / 8 ): (EPD_7IN5_V2_WIDTH / 8 + 1)) * EPD_7IN5_V2_HEIGHT;
|
||||||
|
if((BlackImage = (UBYTE *)malloc(Imagesize)) == NULL) {
|
||||||
|
printf("Failed to apply for black memory...\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
printf("Paint_NewImage\r\n");
|
||||||
|
Paint_NewImage(BlackImage, EPD_7IN5_V2_WIDTH, EPD_7IN5_V2_HEIGHT, 0, WHITE);
|
||||||
|
|
||||||
|
#if 1 // show image for array
|
||||||
|
EPD_7IN5_V2_Init_Fast();
|
||||||
|
printf("show image for array\r\n");
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_DrawBitMap(gImage_7in5_V2);
|
||||||
|
EPD_7IN5_V2_Display(BlackImage);
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1 // Drawing on the image
|
||||||
|
//1.Select Image
|
||||||
|
EPD_7IN5_V2_Init();
|
||||||
|
printf("SelectImage:BlackImage\r\n");
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
|
||||||
|
// 2.Drawing on the image
|
||||||
|
printf("Drawing:BlackImage\r\n");
|
||||||
|
Paint_DrawPoint(10, 80, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 90, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 100, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawLine(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(70, 70, 20, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawRectangle(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawRectangle(80, 70, 130, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawCircle(45, 95, 20, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawCircle(105, 95, 20, WHITE, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawLine(85, 95, 125, 95, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawLine(105, 75, 105, 115, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawString_EN(10, 0, "waveshare", &Font16, BLACK, WHITE);
|
||||||
|
Paint_DrawString_EN(10, 20, "hello world", &Font12, WHITE, BLACK);
|
||||||
|
Paint_DrawNum(10, 33, 123456789, &Font12, BLACK, WHITE);
|
||||||
|
Paint_DrawNum(10, 50, 987654321, &Font16, WHITE, BLACK);
|
||||||
|
Paint_DrawString_CN(130, 0, " ÄãºÃabc", &Font12CN, BLACK, WHITE);
|
||||||
|
Paint_DrawString_CN(130, 20, "΢ѩµç×Ó", &Font24CN, WHITE, BLACK);
|
||||||
|
|
||||||
|
printf("EPD_Display\r\n");
|
||||||
|
EPD_7IN5_V2_Display(BlackImage);
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1 //Partial refresh, example shows time
|
||||||
|
EPD_7IN5_V2_Init_Part();
|
||||||
|
Paint_NewImage(BlackImage, Font20.Width * 7, Font20.Height, 0, WHITE);
|
||||||
|
Debug("Partial refresh\r\n");
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
|
||||||
|
PAINT_TIME sPaint_time;
|
||||||
|
sPaint_time.Hour = 12;
|
||||||
|
sPaint_time.Min = 34;
|
||||||
|
sPaint_time.Sec = 56;
|
||||||
|
UBYTE num = 10;
|
||||||
|
for (;;) {
|
||||||
|
sPaint_time.Sec = sPaint_time.Sec + 1;
|
||||||
|
if (sPaint_time.Sec == 60) {
|
||||||
|
sPaint_time.Min = sPaint_time.Min + 1;
|
||||||
|
sPaint_time.Sec = 0;
|
||||||
|
if (sPaint_time.Min == 60) {
|
||||||
|
sPaint_time.Hour = sPaint_time.Hour + 1;
|
||||||
|
sPaint_time.Min = 0;
|
||||||
|
if (sPaint_time.Hour == 24) {
|
||||||
|
sPaint_time.Hour = 0;
|
||||||
|
sPaint_time.Min = 0;
|
||||||
|
sPaint_time.Sec = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Paint_ClearWindows(0, 0, Font20.Width * 7, Font20.Height, WHITE);
|
||||||
|
Paint_DrawTime(0, 0, &sPaint_time, &Font20, WHITE, BLACK);
|
||||||
|
|
||||||
|
num = num - 1;
|
||||||
|
if(num == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
EPD_7IN5_V2_Display_Part(BlackImage, 150, 80, 150 + Font20.Width * 7, 80 + Font20.Height);
|
||||||
|
DEV_Delay_ms(500);//Analog clock 1s
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
The feature will only be available on screens sold after 24/10/23
|
||||||
|
*/
|
||||||
|
#if 1 // show image for array
|
||||||
|
free(BlackImage);
|
||||||
|
printf("show Gray------------------------\r\n");
|
||||||
|
Imagesize = ((EPD_7IN5_V2_WIDTH % 4 == 0)? (EPD_7IN5_V2_WIDTH / 4 ): (EPD_7IN5_V2_WIDTH / 4 + 1)) * EPD_7IN5_V2_HEIGHT;
|
||||||
|
if((BlackImage = (UBYTE *)malloc(Imagesize)) == NULL) {
|
||||||
|
printf("Failed to apply for black memory...\r\n");
|
||||||
|
while (1);
|
||||||
|
}
|
||||||
|
EPD_7IN5_V2_Init_4Gray();
|
||||||
|
printf("4 grayscale display\r\n");
|
||||||
|
Paint_NewImage(BlackImage, EPD_7IN5_V2_WIDTH, EPD_7IN5_V2_HEIGHT, 0, WHITE);
|
||||||
|
Paint_SetScale(4);
|
||||||
|
Paint_Clear(0xff);
|
||||||
|
|
||||||
|
Paint_DrawPoint(10, 80, GRAY4, DOT_PIXEL_1X1, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 90, GRAY4, DOT_PIXEL_2X2, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 100, GRAY4, DOT_PIXEL_3X3, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawLine(20, 70, 70, 120, GRAY4, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(70, 70, 20, 120, GRAY4, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawRectangle(20, 70, 70, 120, GRAY4, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawRectangle(80, 70, 130, 120, GRAY4, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawCircle(45, 95, 20, GRAY4, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawCircle(105, 95, 20, GRAY2, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawLine(85, 95, 125, 95, GRAY4, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawLine(105, 75, 105, 115, GRAY4, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawString_EN(10, 0, "waveshare", &Font16, GRAY4, GRAY1);
|
||||||
|
Paint_DrawString_EN(10, 20, "hello world", &Font12, GRAY3, GRAY1);
|
||||||
|
Paint_DrawNum(10, 33, 123456789, &Font12, GRAY4, GRAY2);
|
||||||
|
Paint_DrawNum(10, 50, 987654321, &Font16, GRAY1, GRAY4);
|
||||||
|
Paint_DrawString_CN(150, 0,"ÄãºÃabc", &Font12CN, GRAY4, GRAY1);
|
||||||
|
Paint_DrawString_CN(150, 20,"ÄãºÃabc", &Font12CN, GRAY3, GRAY2);
|
||||||
|
Paint_DrawString_CN(150, 40,"ÄãºÃabc", &Font12CN, GRAY2, GRAY3);
|
||||||
|
Paint_DrawString_CN(150, 60,"ÄãºÃabc", &Font12CN, GRAY1, GRAY4);
|
||||||
|
Paint_DrawString_CN(10, 130, "΢ѩµç×Ó", &Font24CN, GRAY1, GRAY4);
|
||||||
|
EPD_7IN5_V2_Display_4Gray(BlackImage);
|
||||||
|
DEV_Delay_ms(3000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
printf("Clear...\r\n");
|
||||||
|
EPD_7IN5_V2_Init();
|
||||||
|
EPD_7IN5_V2_Clear();
|
||||||
|
|
||||||
|
printf("Goto Sleep...\r\n");
|
||||||
|
EPD_7IN5_V2_Sleep();
|
||||||
|
free(BlackImage);
|
||||||
|
BlackImage = NULL;
|
||||||
|
DEV_Delay_ms(2000);//important, at least 2s
|
||||||
|
// close 5V
|
||||||
|
printf("close 5V, Module enters 0 power consumption ...\r\n");
|
||||||
|
DEV_Module_Exit();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,149 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : EPD_7in5_V2_test.c
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : 7.5inch e-paper test demo
|
||||||
|
* | Info :
|
||||||
|
*----------------
|
||||||
|
* | This version: V1.0
|
||||||
|
* | Date : 2023-12-18
|
||||||
|
* | Info :
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documnetation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in
|
||||||
|
# all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
# THE SOFTWARE.
|
||||||
|
#
|
||||||
|
******************************************************************************/
|
||||||
|
#include "EPD_Test.h"
|
||||||
|
#include "EPD_7in5_V2_old.h"
|
||||||
|
|
||||||
|
int EPD_7in5_V2_test_old(void)
|
||||||
|
{
|
||||||
|
printf("EPD_7IN5_V2_test Demo\r\n");
|
||||||
|
if(DEV_Module_Init()!=0){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
printf("e-Paper Init and Clear...\r\n");
|
||||||
|
EPD_7IN5_V2_Init_old();
|
||||||
|
EPD_7IN5_V2_Clear_old();
|
||||||
|
DEV_Delay_ms(500);
|
||||||
|
|
||||||
|
//Create a new image cache
|
||||||
|
UBYTE *BlackImage;
|
||||||
|
/* you have to edit the startup_stm32fxxx.s file and set a big enough heap size */
|
||||||
|
UWORD Imagesize = ((EPD_7IN5_V2_WIDTH % 8 == 0)? (EPD_7IN5_V2_WIDTH / 8 ): (EPD_7IN5_V2_WIDTH / 8 + 1)) * EPD_7IN5_V2_HEIGHT;
|
||||||
|
if((BlackImage = (UBYTE *)malloc(Imagesize)) == NULL) {
|
||||||
|
printf("Failed to apply for black memory...\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
printf("Paint_NewImage\r\n");
|
||||||
|
Paint_NewImage(BlackImage, EPD_7IN5_V2_WIDTH, EPD_7IN5_V2_HEIGHT, 0, WHITE);
|
||||||
|
|
||||||
|
#if 1 // show image for array
|
||||||
|
printf("show image for array\r\n");
|
||||||
|
EPD_7IN5_V2_Init_Fast_old();
|
||||||
|
EPD_7IN5_V2_Display_old(gImage_7in5_V2);
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1 // Drawing on the image
|
||||||
|
//1.Select Image
|
||||||
|
printf("SelectImage:BlackImage\r\n");
|
||||||
|
EPD_7IN5_V2_Init_old();
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
|
||||||
|
// 2.Drawing on the image
|
||||||
|
printf("Drawing:BlackImage\r\n");
|
||||||
|
Paint_DrawPoint(10, 80, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 90, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 100, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawLine(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(70, 70, 20, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawRectangle(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawRectangle(80, 70, 130, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawCircle(45, 95, 20, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawCircle(105, 95, 20, WHITE, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawLine(85, 95, 125, 95, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawLine(105, 75, 105, 115, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawString_EN(10, 0, "waveshare", &Font16, BLACK, WHITE);
|
||||||
|
Paint_DrawString_EN(10, 20, "hello world", &Font12, WHITE, BLACK);
|
||||||
|
Paint_DrawNum(10, 33, 123456789, &Font12, BLACK, WHITE);
|
||||||
|
Paint_DrawNum(10, 50, 987654321, &Font16, WHITE, BLACK);
|
||||||
|
Paint_DrawString_CN(130, 0, "ÄãºÃabc", &Font12CN, BLACK, WHITE);
|
||||||
|
Paint_DrawString_CN(130, 20, "΢ѩµç×Ó", &Font24CN, WHITE, BLACK);
|
||||||
|
|
||||||
|
printf("EPD_Display\r\n");
|
||||||
|
EPD_7IN5_V2_Display_old(BlackImage);
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1 //Partial refresh, example shows time
|
||||||
|
EPD_7IN5_V2_Init_Partial_old();
|
||||||
|
Paint_NewImage(BlackImage, Font20.Width * 7, Font20.Height, 0, WHITE);
|
||||||
|
printf("Partial refresh\r\n");
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
|
||||||
|
PAINT_TIME sPaint_time;
|
||||||
|
sPaint_time.Hour = 12;
|
||||||
|
sPaint_time.Min = 34;
|
||||||
|
sPaint_time.Sec = 56;
|
||||||
|
UBYTE num = 10;
|
||||||
|
for (;;) {
|
||||||
|
sPaint_time.Sec = sPaint_time.Sec + 1;
|
||||||
|
if (sPaint_time.Sec == 60) {
|
||||||
|
sPaint_time.Min = sPaint_time.Min + 1;
|
||||||
|
sPaint_time.Sec = 0;
|
||||||
|
if (sPaint_time.Min == 60) {
|
||||||
|
sPaint_time.Hour = sPaint_time.Hour + 1;
|
||||||
|
sPaint_time.Min = 0;
|
||||||
|
if (sPaint_time.Hour == 24) {
|
||||||
|
sPaint_time.Hour = 0;
|
||||||
|
sPaint_time.Min = 0;
|
||||||
|
sPaint_time.Sec = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Paint_ClearWindows(0, 0, Font20.Width * 7, Font20.Height, WHITE);
|
||||||
|
Paint_DrawTime(0, 0, &sPaint_time, &Font20, WHITE, BLACK);
|
||||||
|
|
||||||
|
num = num - 1;
|
||||||
|
if(num == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
EPD_7IN5_V2_Display_Partial_old(BlackImage, 150, 80, 150 + Font20.Width * 7, 80 + Font20.Height);
|
||||||
|
DEV_Delay_ms(500);//Analog clock 1s
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
printf("Clear...\r\n");
|
||||||
|
EPD_7IN5_V2_Init_old();
|
||||||
|
EPD_7IN5_V2_Clear_old();
|
||||||
|
|
||||||
|
printf("Goto Sleep...\r\n");
|
||||||
|
EPD_7IN5_V2_Sleep_old();
|
||||||
|
free(BlackImage);
|
||||||
|
BlackImage = NULL;
|
||||||
|
DEV_Delay_ms(2000);//important, at least 2s
|
||||||
|
// close 5V
|
||||||
|
printf("close 5V, Module enters 0 power consumption ...\r\n");
|
||||||
|
DEV_Module_Exit();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,163 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : EPD_7in5b_V2_test.c
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : 7.5inch B e-paper test demo
|
||||||
|
* | Info :
|
||||||
|
*----------------
|
||||||
|
* | This version: V1.0
|
||||||
|
* | Date : 2020-11-30
|
||||||
|
* | Info :
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documnetation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in
|
||||||
|
# all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
# THE SOFTWARE.
|
||||||
|
#
|
||||||
|
******************************************************************************/
|
||||||
|
#include "EPD_Test.h"
|
||||||
|
#include "EPD_7in5b_V2.h"
|
||||||
|
|
||||||
|
int EPD_7in5b_V2_test(void)
|
||||||
|
{
|
||||||
|
printf("EPD_7IN5B_V2_test Demo\r\n");
|
||||||
|
if(DEV_Module_Init()!=0){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("e-Paper Init and Clear...\r\n");
|
||||||
|
EPD_7IN5B_V2_Init();
|
||||||
|
|
||||||
|
EPD_7IN5B_V2_Clear();
|
||||||
|
DEV_Delay_ms(500);
|
||||||
|
|
||||||
|
//Create a new image cache named IMAGE_BW and fill it with white
|
||||||
|
UBYTE *BlackImage, *RYImage;
|
||||||
|
UWORD Imagesize = ((EPD_7IN5B_V2_WIDTH % 8 == 0)? (EPD_7IN5B_V2_WIDTH / 8 ): (EPD_7IN5B_V2_WIDTH / 8 + 1)) * EPD_7IN5B_V2_HEIGHT;
|
||||||
|
if((BlackImage = (UBYTE *)malloc(Imagesize)) == NULL) {
|
||||||
|
printf("Failed to apply for black memory...\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if((RYImage = (UBYTE *)malloc(Imagesize)) == NULL) {
|
||||||
|
printf("Failed to apply for red memory...\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
printf("NewImage:BlackImage and RYImage\r\n");
|
||||||
|
Paint_NewImage(BlackImage, EPD_7IN5B_V2_WIDTH, EPD_7IN5B_V2_HEIGHT , 0, WHITE);
|
||||||
|
Paint_NewImage(RYImage, EPD_7IN5B_V2_WIDTH, EPD_7IN5B_V2_HEIGHT , 0, WHITE);
|
||||||
|
|
||||||
|
//Select Image
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_SelectImage(RYImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
|
||||||
|
#if 1 // show image for array
|
||||||
|
printf("show image for array\r\n");
|
||||||
|
EPD_7IN5B_V2_Display(gImage_7in5_V2_b, gImage_7in5_V2_ry);
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1 // Drawing on the image
|
||||||
|
/*Horizontal screen*/
|
||||||
|
//1.Draw black image
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_DrawPoint(10, 80, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 90, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 100, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 110, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawLine(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(70, 70, 20, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawRectangle(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawRectangle(80, 70, 130, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawString_EN(10, 0, "waveshare", &Font16, BLACK, WHITE);
|
||||||
|
Paint_DrawString_CN(130, 20, "微雪电子", &Font24CN, WHITE, BLACK);
|
||||||
|
Paint_DrawNum(10, 50, 987654321, &Font16, WHITE, BLACK);
|
||||||
|
|
||||||
|
//2.Draw red image
|
||||||
|
Paint_SelectImage(RYImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_DrawCircle(160, 95, 20, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawCircle(210, 95, 20, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawLine(85, 95, 125, 95, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawLine(105, 75, 105, 115, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawString_CN(130, 0,"你好Abc", &Font12CN, BLACK, WHITE);
|
||||||
|
Paint_DrawString_EN(10, 20, "hello world", &Font12, WHITE, BLACK);
|
||||||
|
Paint_DrawNum(10, 33, 123456789, &Font12, BLACK, WHITE);
|
||||||
|
|
||||||
|
printf("EPD_Display\r\n");
|
||||||
|
EPD_7IN5B_V2_Display(BlackImage, RYImage);
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1 //Partial refresh, example shows time
|
||||||
|
EPD_7IN5B_V2_Init_Part();
|
||||||
|
EPD_7IN5B_V2_Display_Base_color(WHITE);
|
||||||
|
Paint_NewImage(BlackImage, Font20.Width * 7, Font20.Height, 0, WHITE);
|
||||||
|
Debug("Partial refresh\r\n");
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
|
||||||
|
PAINT_TIME sPaint_time;
|
||||||
|
sPaint_time.Hour = 12;
|
||||||
|
sPaint_time.Min = 34;
|
||||||
|
sPaint_time.Sec = 56;
|
||||||
|
UBYTE num = 10;
|
||||||
|
for (;;) {
|
||||||
|
sPaint_time.Sec = sPaint_time.Sec + 1;
|
||||||
|
if (sPaint_time.Sec == 60) {
|
||||||
|
sPaint_time.Min = sPaint_time.Min + 1;
|
||||||
|
sPaint_time.Sec = 0;
|
||||||
|
if (sPaint_time.Min == 60) {
|
||||||
|
sPaint_time.Hour = sPaint_time.Hour + 1;
|
||||||
|
sPaint_time.Min = 0;
|
||||||
|
if (sPaint_time.Hour == 24) {
|
||||||
|
sPaint_time.Hour = 0;
|
||||||
|
sPaint_time.Min = 0;
|
||||||
|
sPaint_time.Sec = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Paint_ClearWindows(0, 0, Font20.Width * 7, Font20.Height, WHITE);
|
||||||
|
Paint_DrawTime(0, 0, &sPaint_time, &Font20, WHITE, BLACK);
|
||||||
|
|
||||||
|
num = num - 1;
|
||||||
|
if(num == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
EPD_7IN5B_V2_Display_Partial(BlackImage, 10, 130, 10 + Font20.Width * 7, 130 + Font20.Height);
|
||||||
|
DEV_Delay_ms(500);//Analog clock 1s
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
printf("Clear...\r\n");
|
||||||
|
EPD_7IN5B_V2_Init();
|
||||||
|
EPD_7IN5B_V2_Clear();
|
||||||
|
|
||||||
|
printf("Goto Sleep...\r\n");
|
||||||
|
EPD_7IN5B_V2_Sleep();
|
||||||
|
free(BlackImage);
|
||||||
|
free(RYImage);
|
||||||
|
BlackImage = NULL;
|
||||||
|
RYImage = NULL;
|
||||||
|
DEV_Delay_ms(2000);//important, at least 2s
|
||||||
|
// close 5V
|
||||||
|
printf("close 5V, Module enters 0 power consumption ...\r\n");
|
||||||
|
DEV_Module_Exit();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,121 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : EPD_7in5b_V2_test.c
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : 5.83inch B&C e-paper test demo
|
||||||
|
* | Info :
|
||||||
|
*----------------
|
||||||
|
* | This version: V1.0
|
||||||
|
* | Date : 2020-11-30
|
||||||
|
* | Info :
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documnetation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in
|
||||||
|
# all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
# THE SOFTWARE.
|
||||||
|
#
|
||||||
|
******************************************************************************/
|
||||||
|
#include "EPD_Test.h"
|
||||||
|
#include "EPD_7in5b_V2_old.h"
|
||||||
|
|
||||||
|
int EPD_7in5b_V2_test_old(void)
|
||||||
|
{
|
||||||
|
printf("EPD_7IN5B_V2_test Demo\r\n");
|
||||||
|
if(DEV_Module_Init()!=0){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("e-Paper Init and Clear...\r\n");
|
||||||
|
EPD_7IN5B_V2_Init_old();
|
||||||
|
EPD_7IN5B_V2_Clear_old();
|
||||||
|
DEV_Delay_ms(500);
|
||||||
|
|
||||||
|
//Create a new image cache named IMAGE_BW and fill it with white
|
||||||
|
UBYTE *BlackImage, *RYImage;
|
||||||
|
UWORD Imagesize = ((EPD_7IN5B_V2_WIDTH % 8 == 0)? (EPD_7IN5B_V2_WIDTH / 8 ): (EPD_7IN5B_V2_WIDTH / 8 + 1)) * EPD_7IN5B_V2_HEIGHT;
|
||||||
|
if((BlackImage = (UBYTE *)malloc(Imagesize)) == NULL) {
|
||||||
|
printf("Failed to apply for black memory...\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if((RYImage = (UBYTE *)malloc(Imagesize)) == NULL) {
|
||||||
|
printf("Failed to apply for red memory...\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
printf("NewImage:BlackImage and RYImage\r\n");
|
||||||
|
Paint_NewImage(BlackImage, EPD_7IN5B_V2_WIDTH, EPD_7IN5B_V2_HEIGHT , 0, WHITE);
|
||||||
|
Paint_NewImage(RYImage, EPD_7IN5B_V2_WIDTH, EPD_7IN5B_V2_HEIGHT , 0, WHITE);
|
||||||
|
|
||||||
|
//Select Image
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_SelectImage(RYImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
|
||||||
|
#if 1 // show image for array
|
||||||
|
printf("show image for array\r\n");
|
||||||
|
EPD_7IN5B_V2_Display_old(gImage_7in5_V2_b, gImage_7in5_V2_ry);
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1 // Drawing on the image
|
||||||
|
/*Horizontal screen*/
|
||||||
|
//1.Draw black image
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_DrawPoint(10, 80, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 90, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 100, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(10, 110, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawLine(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(70, 70, 20, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawRectangle(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawRectangle(80, 70, 130, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawString_EN(10, 0, "waveshare", &Font16, BLACK, WHITE);
|
||||||
|
Paint_DrawString_CN(130, 20, "΢ѩµç×Ó", &Font24CN, WHITE, BLACK);
|
||||||
|
Paint_DrawNum(10, 50, 987654321, &Font16, WHITE, BLACK);
|
||||||
|
|
||||||
|
//2.Draw red image
|
||||||
|
Paint_SelectImage(RYImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
Paint_DrawCircle(160, 95, 20, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
|
||||||
|
Paint_DrawCircle(210, 95, 20, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
|
||||||
|
Paint_DrawLine(85, 95, 125, 95, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawLine(105, 75, 105, 115, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
|
||||||
|
Paint_DrawString_CN(130, 0,"ÄãºÃabc", &Font12CN, BLACK, WHITE);
|
||||||
|
Paint_DrawString_EN(10, 20, "hello world", &Font12, WHITE, BLACK);
|
||||||
|
Paint_DrawNum(10, 33, 123456789, &Font12, BLACK, WHITE);
|
||||||
|
|
||||||
|
printf("EPD_Display\r\n");
|
||||||
|
EPD_7IN5B_V2_Display_old(BlackImage, RYImage);
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
printf("Clear...\r\n");
|
||||||
|
EPD_7IN5B_V2_Clear_old();
|
||||||
|
|
||||||
|
printf("Goto Sleep...\r\n");
|
||||||
|
EPD_7IN5B_V2_Sleep_old();
|
||||||
|
free(BlackImage);
|
||||||
|
free(RYImage);
|
||||||
|
BlackImage = NULL;
|
||||||
|
RYImage = NULL;
|
||||||
|
DEV_Delay_ms(2000);//important, at least 2s
|
||||||
|
// close 5V
|
||||||
|
printf("close 5V, Module enters 0 power consumption ...\r\n");
|
||||||
|
DEV_Module_Exit();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : EPD_Test.h
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : e-Paper test Demo
|
||||||
|
* | Info :
|
||||||
|
*----------------
|
||||||
|
* | This version: V1.0
|
||||||
|
* | Date : 2019-06-11
|
||||||
|
* | Info :
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documnetation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in
|
||||||
|
# all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
# THE SOFTWARE.
|
||||||
|
#
|
||||||
|
******************************************************************************/
|
||||||
|
#ifndef _EPD_TEST_H_
|
||||||
|
#define _EPD_TEST_H_
|
||||||
|
|
||||||
|
#include "DEV_Config.h"
|
||||||
|
#include "GUI_Paint.h"
|
||||||
|
#include "ImageData.h"
|
||||||
|
#include "Debug.h"
|
||||||
|
#include <stdlib.h> // malloc() free()
|
||||||
|
|
||||||
|
int EPD_2in9_V2_test(void);
|
||||||
|
int EPD_2in9bc_test(void);
|
||||||
|
int EPD_2in9b_V3_test(void);
|
||||||
|
int EPD_2in9b_V4_test(void);
|
||||||
|
int EPD_2in9d_test(void);
|
||||||
|
|
||||||
|
int EPD_2in13_V2_test(void);
|
||||||
|
int EPD_2in13_V3_test(void);
|
||||||
|
int EPD_2in13_V4_test(void);
|
||||||
|
int EPD_2in13bc_test(void);
|
||||||
|
int EPD_2in13b_V3_test(void);
|
||||||
|
int EPD_2in13b_V4_test(void);
|
||||||
|
int EPD_2in13d_test(void);
|
||||||
|
|
||||||
|
int EPD_2in66_test(void);
|
||||||
|
int EPD_2in66b_test(void);
|
||||||
|
|
||||||
|
int EPD_2in7_test(void);
|
||||||
|
int EPD_2in7_V2_test(void);
|
||||||
|
|
||||||
|
int EPD_3in7_test(void);
|
||||||
|
|
||||||
|
int EPD_4in2_test(void);
|
||||||
|
int EPD_4in2_V2_test(void);
|
||||||
|
int EPD_4in2b_V2_test(void);
|
||||||
|
int EPD_4in2b_V2_test_old(void);
|
||||||
|
|
||||||
|
int EPD_5in65f_test(void);
|
||||||
|
|
||||||
|
int EPD_5in83_V2_test(void);
|
||||||
|
int EPD_5in83b_V2_test(void);
|
||||||
|
|
||||||
|
int EPD_7in5_V2_test(void);
|
||||||
|
int EPD_7in5_V2_test_old(void);
|
||||||
|
int EPD_7in5b_V2_test(void);
|
||||||
|
int EPD_7in5b_V2_test_old(void);
|
||||||
|
|
||||||
|
#endif
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,83 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : ImageData.h
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function :
|
||||||
|
*----------------
|
||||||
|
* | This version: V1.0
|
||||||
|
* | Date : 2018-10-23
|
||||||
|
* | Info :
|
||||||
|
*
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documnetation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in
|
||||||
|
# all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
# THE SOFTWARE.
|
||||||
|
#
|
||||||
|
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#ifndef _IMAGEDATA_H_
|
||||||
|
#define _IMAGEDATA_H_
|
||||||
|
|
||||||
|
extern const unsigned char flagimage[];
|
||||||
|
|
||||||
|
extern const unsigned char gImage_2in13_2[];
|
||||||
|
extern const unsigned char gImage_2in9[];
|
||||||
|
extern const unsigned char gImage_2in9_4gray[];
|
||||||
|
extern const unsigned char gImage_2in9bc_b[];
|
||||||
|
extern const unsigned char gImage_2in9bc_ry[];
|
||||||
|
|
||||||
|
extern const unsigned char gImage_2in13[];
|
||||||
|
extern const unsigned char gImage_2in13b_V4b[];
|
||||||
|
extern const unsigned char gImage_2in13b_V4r[];
|
||||||
|
extern const unsigned char gImage_2in13b_b[];
|
||||||
|
extern const unsigned char gImage_2in13b_r[];
|
||||||
|
extern const unsigned char gImage_2in13c_b[];
|
||||||
|
extern const unsigned char gImage_2in13c_y[];
|
||||||
|
extern const unsigned char gImage_2in13d[];
|
||||||
|
|
||||||
|
extern const unsigned char gImage_2in66[];
|
||||||
|
extern const unsigned char gImage_2in66br[];
|
||||||
|
extern const unsigned char gImage_2in66bb[];
|
||||||
|
|
||||||
|
extern const unsigned char gImage_2in7[];
|
||||||
|
extern const unsigned char gImage_2in7b_Black[5808];
|
||||||
|
extern const unsigned char gImage_2in7b_Red[5808];
|
||||||
|
extern const unsigned char gImage_2in7b_Black_V2[5808];
|
||||||
|
extern const unsigned char gImage_2in7b_Red_V2[5808];
|
||||||
|
extern const unsigned char gImage_2in7_4Gray[];
|
||||||
|
extern const unsigned char gImage_2in7_4Gray_1[];
|
||||||
|
|
||||||
|
extern const unsigned char gImage_4in2[];
|
||||||
|
extern const unsigned char gImage_4in2_4Gray[];
|
||||||
|
extern const unsigned char gImage_4in2_4Gray1[];
|
||||||
|
extern const unsigned char gImage_4in2bc_b[];
|
||||||
|
extern const unsigned char gImage_4in2bc_ry[];
|
||||||
|
|
||||||
|
extern const unsigned char gImage_5in65f[];
|
||||||
|
|
||||||
|
extern const unsigned char gImage_5in83_V2[];
|
||||||
|
extern const unsigned char gImage_5in83b_V2_b[];
|
||||||
|
extern const unsigned char gImage_5in83b_V2_r[];
|
||||||
|
|
||||||
|
extern const unsigned char gImage_7in5_V2[];
|
||||||
|
extern const unsigned char gImage_7in5_V2_b[];
|
||||||
|
extern const unsigned char gImage_7in5_V2_ry[];
|
||||||
|
|
||||||
|
#endif
|
||||||
|
/* FILE END */
|
||||||
|
|
||||||
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,6 @@
|
|||||||
|
English:
|
||||||
|
This directory holds our pre-compiled sample programs.
|
||||||
|
You can use them for evaluation if you have trouble setting up your environment.
|
||||||
|
|
||||||
|
中文:
|
||||||
|
本目录存放的是我们预先编译好的示例程序。如果您在环境搭建时遇到了麻烦,可以使用它们进行评估。
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user