Touchscreen driver POC
Example documentation
@@ -1,14 +1,30 @@
|
|||||||
# Waveshare 2.9" E-Paper LVGL Project
|
# Waveshare 2.9" E-Paper LVGL Project
|
||||||
|
|
||||||
## Goal Summary
|
## Goal Summary
|
||||||
- Extend the native waveshare_epaper component of esphome to support 2-bit grayscale
|
- Waveshare 2.9" Touch ePaper HAT driving LVGL UI via ESPHome on ESP32
|
||||||
- Only concerned with this one target board: `2.90inv2-r2`
|
- 2-bit grayscale display support implemented via custom ESPHome component
|
||||||
|
- Touchscreen integration in progress
|
||||||
|
|
||||||
## Hardware
|
## Hardware
|
||||||
- ESP32-WROOM-32 (nodemcu-32s board)
|
- ESP32-WROOM-32 (nodemcu-32s board)
|
||||||
- Waveshare 2.9inch Touch ePaper HAT (296x128, 2-bit grayscale)
|
- Waveshare 2.9inch Touch ePaper HAT (296x128, SSD1680 display, GT1151 touchscreen)
|
||||||
- Display model string: `2.90inv2-r2` (SSD1680 controller)
|
|
||||||
- Pin mapping: SCLK=GPIO23, MOSI=GPIO22, CS=GPIO19, DC=GPIO18, BUSY=GPIO4, RST=GPIO5
|
### Pin Mapping
|
||||||
|
| Function | ESP Pin | HAT Pin |
|
||||||
|
|--- |--- |--- |
|
||||||
|
| Display SCLK | GPIO18 | Pin23/GPIO11/SPI0_SCLK |
|
||||||
|
| Display MOSI | GPIO23 | Pin19/GPIO10/SPI0_MOSI |
|
||||||
|
| Display CS | GPIO19 | Pin24/GPIO8/SPI0_CE0 |
|
||||||
|
| Display DC | GPIO17 | Pin22/GPIO25 |
|
||||||
|
| Display BUSY | GPIO4 | Pin24/GPIO24 |
|
||||||
|
| Display RST | GPIO5 | Pin11/GPIO17/SPI1_CE1 |
|
||||||
|
| Touch SDA | GPIO21 | Pin3/GPIO2/I2C1_SDA |
|
||||||
|
| Touch SCL | GPIO22 | Pin5/GPIO3/I2C1_SCL |
|
||||||
|
| Touch RST | GPIO15 | Pin13/GPIO27 |
|
||||||
|
| Touch INT | GPIO16 | Pin15/GPIO22 |
|
||||||
|
|
||||||
|
Note: GPIO15 (Touch RST) is an ESP32 strapping pin, but only affects boot log
|
||||||
|
output (LOW silences it). No impact on UART download mode or OTA flashing.
|
||||||
|
|
||||||
## Software
|
## Software
|
||||||
- ESPHome 2026.1.0
|
- ESPHome 2026.1.0
|
||||||
@@ -16,37 +32,41 @@
|
|||||||
- Project directory: ~/Projects/waveshare-panel
|
- Project directory: ~/Projects/waveshare-panel
|
||||||
|
|
||||||
## Current Status
|
## Current Status
|
||||||
- Display working correctly via ESPHome's native display library
|
- 2-bit grayscale fully working via custom component `waveshare_epaper_2bit`
|
||||||
- LVGL rendering confirmed working (black background visible)
|
- LVGL rendering working, 4-shade colorspace confirmed
|
||||||
- Custom component `waveshare_epaper_2bit` created and flashed, working identically to built-in driver
|
- Bayer ordered dithering implemented for gradient smoothing
|
||||||
- Custom model name: `2.90inv2-r2-2bpp`
|
- Touchscreen wiring complete, driver integration in progress
|
||||||
|
|
||||||
## Known Issues / Quirks
|
## Grayscale Implementation
|
||||||
- LVGL color depth is hardcoded to 16-bit (RGB565) in ESPHome — only supported value
|
Custom component model name: `2.90inv2-r2-2bpp`
|
||||||
- Display renders in 1-bit monochrome despite panel supporting 2-bit grayscale
|
|
||||||
- Colors are inverted by default (bg_color: 0x000000 produces white background)
|
|
||||||
- Resolved: original timeout errors were caused by on_draw_end hammering the display
|
|
||||||
|
|
||||||
## Working LVGL Config
|
Key implementation details:
|
||||||
- refer to the file waveshare-test.yaml
|
- Gray4 waveform LUT loaded via register 0x32 on every display() call
|
||||||
|
- Activation uses 0xC7 (custom LUT), not 0xF7 (which reloads OTP LUT)
|
||||||
## Goal: 2-bit Grayscale Support
|
- Always does full refresh — partial update removed from 2bpp class
|
||||||
The SSD1680 controller supports 4-shade grayscale via two bitplanes:
|
- Second bitplane buffer (`buffer2_`) allocated in `initialize()`
|
||||||
- Register 0x24: bitplane 1
|
|
||||||
- Register 0x26: bitplane 2
|
|
||||||
|
|
||||||
|
Confirmed bitplane table for this panel with Gray4 LUT:
|
||||||
| 0x24 | 0x26 | Result |
|
| 0x24 | 0x26 | Result |
|
||||||
|------|------|------------|
|
|------|------|------------|
|
||||||
| 1 | 1 | White |
|
| 0 | 0 | White |
|
||||||
| 1 | 0 | Light grey |
|
| 1 | 0 | Light grey |
|
||||||
| 0 | 1 | Dark grey |
|
| 0 | 1 | Dark grey |
|
||||||
| 0 | 0 | Black |
|
| 1 | 1 | Black |
|
||||||
|
|
||||||
The ESPHome driver only writes to 0x24, discarding grayscale information.
|
Color convention: 0xFFFFFF=white, 0x000000=black (no inversion).
|
||||||
The real problem is upstream — RGB565 is converted to 1-bit before display() is
|
LVGL 4-shade palette: 0xFFFFFF, 0xAAAAAA, 0x555555, 0x000000
|
||||||
called, so grayscale data is lost before the driver even sees it. Next step is to
|
|
||||||
find where this conversion happens in the ESPHome display pipeline so the patch
|
Dithering: 4×4 Bayer ordered dither, bias = bayer*2 - 15 (±15 range).
|
||||||
can preserve grayscale information through to the two-bitplane write.
|
Amplitude chosen to keep 0xAAAAAA and 0x555555 as solid fills.
|
||||||
|
|
||||||
|
## Touchscreen
|
||||||
|
- Controller: ICNT86X (I2C address 0x48; 0x30 also ACKs, likely DFU/bootloader interface)
|
||||||
|
- Custom component: `custom_components/icnt86x/` (ESPHome has no native ICNT86X driver)
|
||||||
|
- Touch count at register 0x1001, touch data at 0x1002 (7 bytes/point), clear by writing 0x00 to 0x1001
|
||||||
|
- Waveshare's own driver inverts both axes: X = 295 - raw_x, Y = 127 - raw_y
|
||||||
|
- INT pulse is very brief (sub-ms); component works in polling mode regardless
|
||||||
|
- Coordinate transform (mirror_x, mirror_y, swap_xy) to be confirmed after first flash
|
||||||
|
|
||||||
## Relevant Files
|
## Relevant Files
|
||||||
- Custom component: `custom_components/waveshare_epaper_2bit/`
|
- Custom component: `custom_components/waveshare_epaper_2bit/`
|
||||||
@@ -54,6 +74,6 @@ can preserve grayscale information through to the two-bitplane write.
|
|||||||
- `display.py` — component schema and model registration
|
- `display.py` — component schema and model registration
|
||||||
- `waveshare_epaper_2bit.cpp` — driver implementation
|
- `waveshare_epaper_2bit.cpp` — driver implementation
|
||||||
- `waveshare_epaper_2bit.h` — header
|
- `waveshare_epaper_2bit.h` — header
|
||||||
|
- Main config: `waveshare-test.yaml` (pin table here is source of truth)
|
||||||
- Build cache: `.esphome/build/waveshare-epaper-test/src/esphome/components/`
|
- Build cache: `.esphome/build/waveshare-epaper-test/src/esphome/components/`
|
||||||
- ESPHome source (venv): ~/Code/esphome-2026.1.0/
|
- ESPHome source (venv): ~/Code/esphome-2026.1.0/
|
||||||
- Applicable ESPHome source is copied into .esphome/build by the build system at compile time
|
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
import esphome.codegen as cg
|
||||||
|
|
||||||
|
CODEOWNERS = ["@andrewmv"]
|
||||||
|
DEPENDENCIES = ["i2c"]
|
||||||
|
|
||||||
|
icnt86x_ns = cg.esphome_ns.namespace("icnt86x")
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
from esphome import pins
|
||||||
|
import esphome.codegen as cg
|
||||||
|
from esphome.components import i2c, touchscreen
|
||||||
|
import esphome.config_validation as cv
|
||||||
|
from esphome.const import CONF_ID, CONF_INTERRUPT_PIN, CONF_RESET_PIN
|
||||||
|
|
||||||
|
from .. import icnt86x_ns
|
||||||
|
|
||||||
|
ICNT86XTouchscreen = icnt86x_ns.class_(
|
||||||
|
"ICNT86XTouchscreen",
|
||||||
|
touchscreen.Touchscreen,
|
||||||
|
i2c.I2CDevice,
|
||||||
|
)
|
||||||
|
|
||||||
|
CONFIG_SCHEMA = touchscreen.TOUCHSCREEN_SCHEMA.extend(
|
||||||
|
{
|
||||||
|
cv.GenerateID(): cv.declare_id(ICNT86XTouchscreen),
|
||||||
|
cv.Optional(CONF_INTERRUPT_PIN): pins.internal_gpio_input_pin_schema,
|
||||||
|
cv.Optional(CONF_RESET_PIN): pins.gpio_output_pin_schema,
|
||||||
|
}
|
||||||
|
).extend(i2c.i2c_device_schema(0x48))
|
||||||
|
|
||||||
|
|
||||||
|
async def to_code(config):
|
||||||
|
var = cg.new_Pvariable(config[CONF_ID])
|
||||||
|
await touchscreen.register_touchscreen(var, config)
|
||||||
|
await i2c.register_i2c_device(var, config)
|
||||||
|
|
||||||
|
if interrupt_pin := config.get(CONF_INTERRUPT_PIN):
|
||||||
|
cg.add(var.set_interrupt_pin(await cg.gpio_pin_expression(interrupt_pin)))
|
||||||
|
if reset_pin := config.get(CONF_RESET_PIN):
|
||||||
|
cg.add(var.set_reset_pin(await cg.gpio_pin_expression(reset_pin)))
|
||||||
@@ -0,0 +1,131 @@
|
|||||||
|
#include "icnt86x_touchscreen.h"
|
||||||
|
#include "esphome/core/log.h"
|
||||||
|
|
||||||
|
namespace esphome {
|
||||||
|
namespace icnt86x {
|
||||||
|
|
||||||
|
static const char *const TAG = "icnt86x.touchscreen";
|
||||||
|
|
||||||
|
static const uint16_t REG_VERSION = 0x000A;
|
||||||
|
static const uint16_t REG_TOUCH_CNT = 0x1001;
|
||||||
|
static const uint16_t REG_TOUCH_DAT = 0x1002;
|
||||||
|
|
||||||
|
static const uint8_t MAX_TOUCHES = 2;
|
||||||
|
static const uint8_t BYTES_PER_TOUCH = 7;
|
||||||
|
|
||||||
|
// Observed event codes from protocol analysis
|
||||||
|
static const uint8_t EVENT_MOVE = 0x02;
|
||||||
|
static const uint8_t EVENT_DOWN = 0x03;
|
||||||
|
// 0x04 = idle/no-contact — chip reports count=1 with this code when untouched
|
||||||
|
|
||||||
|
void ICNT86XTouchscreen::setup() {
|
||||||
|
if (this->reset_pin_ != nullptr) {
|
||||||
|
this->reset_pin_->setup();
|
||||||
|
// Drive INT low before and during reset release. Many touch controllers
|
||||||
|
// sample INT at reset release to select interrupt output mode; if INT is
|
||||||
|
// left pulled high by the level shifter the chip comes up with INT disabled.
|
||||||
|
if (this->interrupt_pin_ != nullptr) {
|
||||||
|
this->interrupt_pin_->pin_mode(gpio::FLAG_OUTPUT);
|
||||||
|
this->interrupt_pin_->digital_write(false);
|
||||||
|
}
|
||||||
|
this->reset_pin_->digital_write(true);
|
||||||
|
delay(100);
|
||||||
|
this->reset_pin_->digital_write(false);
|
||||||
|
delay(100);
|
||||||
|
this->reset_pin_->digital_write(true); // INT still driven low at release
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allow chip 100ms to boot, then reconfigure INT as input before attaching ISR
|
||||||
|
this->set_timeout(100, [this]() { this->setup_internal_(); });
|
||||||
|
}
|
||||||
|
|
||||||
|
void ICNT86XTouchscreen::setup_internal_() {
|
||||||
|
if (this->interrupt_pin_ != nullptr) {
|
||||||
|
this->interrupt_pin_->setup(); // reconfigure as input after driving low during reset
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t ver[4];
|
||||||
|
if (!this->read_reg16_(REG_VERSION, ver, sizeof(ver))) {
|
||||||
|
this->mark_failed();
|
||||||
|
ESP_LOGE(TAG, "Failed to communicate with ICNT86X at 0x%02X", this->address_);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ESP_LOGI(TAG, "ICNT86X IC version: %02X%02X, FW version: %02X%02X",
|
||||||
|
ver[0], ver[1], ver[2], ver[3]);
|
||||||
|
|
||||||
|
if (this->interrupt_pin_ != nullptr) {
|
||||||
|
this->attach_interrupt_(this->interrupt_pin_, gpio::INTERRUPT_FALLING_EDGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
this->setup_done_ = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ICNT86XTouchscreen::update_touches() {
|
||||||
|
// In polling mode loop() never runs, so is_touched_ is never reset between
|
||||||
|
// cycles. Reset it here so send_touches_() can detect the press→release
|
||||||
|
// transition via !is_touched_ && was_touched_.
|
||||||
|
this->is_touched_ = false;
|
||||||
|
|
||||||
|
if (!this->setup_done_) {
|
||||||
|
this->skip_update_ = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t count = 0;
|
||||||
|
if (!this->read_reg16_(REG_TOUCH_CNT, &count, 1)) {
|
||||||
|
this->status_set_warning();
|
||||||
|
this->skip_update_ = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->write_reg16_(REG_TOUCH_CNT, 0x00);
|
||||||
|
|
||||||
|
// Always allow send_touches_() to run — even with zero touches it needs to
|
||||||
|
// fire to propagate the release event when !is_touched_ && was_touched_.
|
||||||
|
this->skip_update_ = false;
|
||||||
|
|
||||||
|
if (count == 0 || count > MAX_TOUCHES)
|
||||||
|
return;
|
||||||
|
|
||||||
|
uint8_t data[MAX_TOUCHES * BYTES_PER_TOUCH];
|
||||||
|
if (!this->read_reg16_(REG_TOUCH_DAT, data, count * BYTES_PER_TOUCH)) {
|
||||||
|
this->status_set_warning();
|
||||||
|
this->skip_update_ = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < count; i++) {
|
||||||
|
// Per-point layout (7 bytes): [id, x_lo, x_hi, y_lo, y_hi, pressure, event]
|
||||||
|
const uint8_t *p = &data[i * BYTES_PER_TOUCH];
|
||||||
|
uint8_t event = p[6];
|
||||||
|
if (event != EVENT_DOWN && event != EVENT_MOVE)
|
||||||
|
continue;
|
||||||
|
uint8_t id = p[0];
|
||||||
|
int16_t x = ((uint16_t)p[2] << 8) | p[1];
|
||||||
|
int16_t y = ((uint16_t)p[4] << 8) | p[3];
|
||||||
|
this->add_raw_touch_position_(id, x, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ICNT86XTouchscreen::read_reg16_(uint16_t reg, uint8_t *data, size_t len) {
|
||||||
|
uint8_t reg_buf[2] = {(uint8_t)(reg >> 8), (uint8_t)(reg & 0xFF)};
|
||||||
|
if (this->write(reg_buf, 2) != i2c::ERROR_OK)
|
||||||
|
return false;
|
||||||
|
return this->read(data, len) == i2c::ERROR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ICNT86XTouchscreen::write_reg16_(uint16_t reg, uint8_t value) {
|
||||||
|
uint8_t buf[3] = {(uint8_t)(reg >> 8), (uint8_t)(reg & 0xFF), value};
|
||||||
|
return this->write(buf, 3) == i2c::ERROR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ICNT86XTouchscreen::dump_config() {
|
||||||
|
ESP_LOGCONFIG(TAG, "ICNT86X Touchscreen:");
|
||||||
|
LOG_I2C_DEVICE(this);
|
||||||
|
LOG_PIN(" Interrupt Pin: ", this->interrupt_pin_);
|
||||||
|
LOG_PIN(" Reset Pin: ", this->reset_pin_);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace icnt86x
|
||||||
|
} // namespace esphome
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "esphome/components/i2c/i2c.h"
|
||||||
|
#include "esphome/components/touchscreen/touchscreen.h"
|
||||||
|
#include "esphome/core/component.h"
|
||||||
|
#include "esphome/core/hal.h"
|
||||||
|
|
||||||
|
namespace esphome {
|
||||||
|
namespace icnt86x {
|
||||||
|
|
||||||
|
class ICNT86XTouchscreen : public touchscreen::Touchscreen, public i2c::I2CDevice {
|
||||||
|
public:
|
||||||
|
void setup() override;
|
||||||
|
void dump_config() override;
|
||||||
|
bool can_proceed() override { return this->setup_done_; }
|
||||||
|
|
||||||
|
void set_interrupt_pin(InternalGPIOPin *pin) { this->interrupt_pin_ = pin; }
|
||||||
|
void set_reset_pin(GPIOPin *pin) { this->reset_pin_ = pin; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void update_touches() override;
|
||||||
|
void setup_internal_();
|
||||||
|
|
||||||
|
bool read_reg16_(uint16_t reg, uint8_t *data, size_t len);
|
||||||
|
bool write_reg16_(uint16_t reg, uint8_t value);
|
||||||
|
|
||||||
|
InternalGPIOPin *interrupt_pin_{nullptr};
|
||||||
|
GPIOPin *reset_pin_{nullptr};
|
||||||
|
bool setup_done_{false};
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace icnt86x
|
||||||
|
} // namespace esphome
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
2021-03-03:新创建。
|
||||||
|
2021-06-05:新添加 2.9inch Touch e-Paper HAT 例程。
|
||||||
|
2022-04-13:新添加 2.13inch_V3 Touch e-Paper HAT 例程。
|
||||||
|
2023-08-14:新添加 2.13inch_V4 Touch e-Paper HAT 例程。
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
2021-03-03: newly built.
|
||||||
|
2021-06-05: Added 2.9inch Touch e-paper HAT routine.
|
||||||
|
2022-04-13: Added 2.13inch_V3 Touch e-paper HAT routine.
|
||||||
|
2023-08-14: Added 2.13inch_V4 Touch e-paper HAT routine.
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
DIR_Config = ./lib/Config
|
||||||
|
DIR_Driver = ./lib/Driver
|
||||||
|
DIR_GUI = ./lib/GUI
|
||||||
|
DIR_FONTS = ./lib/Fonts
|
||||||
|
DIR_EPD = ./lib/EPD
|
||||||
|
DIR_Examples = ./examples
|
||||||
|
DIR_BIN = ./bin
|
||||||
|
|
||||||
|
OBJ_C = $(wildcard ${DIR_Driver}/*.c ${DIR_GUI}/*.c ${DIR_EPD}/*.c ${DIR_Config}/*.c ${DIR_Examples}/*.c ${DIR_FONTS}/*.c )
|
||||||
|
OBJ_O = $(patsubst %.c,${DIR_BIN}/%.o,$(notdir ${OBJ_C}))
|
||||||
|
|
||||||
|
TARGET = main
|
||||||
|
|
||||||
|
# USELIB = USE_BCM2835_LIB
|
||||||
|
# USELIB = USE_WIRINGPI_LIB
|
||||||
|
USELIB = USE_LGPIO_LIB
|
||||||
|
# USELIB = USE_GPIOD_LIB
|
||||||
|
|
||||||
|
DEBUG = -D $(USELIB)
|
||||||
|
|
||||||
|
ifeq ($(USELIB), USE_BCM2835_LIB)
|
||||||
|
LIB = -lbcm2835 -lm
|
||||||
|
OBJ_O := $(filter-out ${DIR_BIN}/RPI_gpiod.o ${DIR_BIN}/dev_hardware_SPI.o ${DIR_BIN}/dev_hardware_i2c.o, ${OBJ_O})
|
||||||
|
else ifeq ($(USELIB), USE_WIRINGPI_LIB)
|
||||||
|
LIB = -lwiringPi -lm
|
||||||
|
OBJ_O := $(filter-out ${DIR_BIN}/RPI_gpiod.o ${DIR_BIN}/dev_hardware_SPI.o ${DIR_BIN}/dev_hardware_i2c.o, ${OBJ_O})
|
||||||
|
else ifeq ($(USELIB), USE_LGPIO_LIB)
|
||||||
|
LIB += -llgpio -lm
|
||||||
|
OBJ_O := $(filter-out ${DIR_BIN}/RPI_gpiod.o ${DIR_BIN}/dev_hardware_SPI.o ${DIR_BIN}/dev_hardware_i2c.o, ${OBJ_O})
|
||||||
|
else ifeq ($(USELIB), USE_GPIOD_LIB)
|
||||||
|
LIB = -lgpiod -lm
|
||||||
|
endif
|
||||||
|
LIB += -lpthread
|
||||||
|
|
||||||
|
CC = gcc
|
||||||
|
MSG = -g -O0 -Wall
|
||||||
|
CFLAGS += $(MSG) $(DEBUG)
|
||||||
|
|
||||||
|
${TARGET}:${OBJ_O}
|
||||||
|
$(CC) $(CFLAGS) $(OBJ_O) -o $@ $(LIB)
|
||||||
|
|
||||||
|
$(shell mkdir -p $(DIR_BIN))
|
||||||
|
|
||||||
|
${DIR_BIN}/%.o:$(DIR_Examples)/%.c
|
||||||
|
$(CC) $(CFLAGS) -c $< -o $@ -I $(DIR_Config) -I $(DIR_Driver) -I $(DIR_EPD) -I $(DIR_GUI)
|
||||||
|
|
||||||
|
${DIR_BIN}/%.o:$(DIR_Driver)/%.c
|
||||||
|
$(CC) $(CFLAGS) -c $< -o $@ -I $(DIR_Config) $(DEBUG)
|
||||||
|
|
||||||
|
${DIR_BIN}/%.o:$(DIR_EPD)/%.c
|
||||||
|
$(CC) $(CFLAGS) -c $< -o $@ -I $(DIR_Config) $(DEBUG)
|
||||||
|
|
||||||
|
${DIR_BIN}/%.o:$(DIR_FONTS)/%.c
|
||||||
|
$(CC) $(CFLAGS) -c $< -o $@ $(DEBUG)
|
||||||
|
|
||||||
|
${DIR_BIN}/%.o:$(DIR_GUI)/%.c
|
||||||
|
$(CC) $(CFLAGS) -c $< -o $@ -I $(DIR_Config) $(DEBUG)
|
||||||
|
|
||||||
|
${DIR_BIN}/%.o:$(DIR_Config)/%.c
|
||||||
|
$(CC) $(CFLAGS) -c $< -o $@ $(LIB)
|
||||||
|
|
||||||
|
|
||||||
|
clean :
|
||||||
|
rm $(DIR_BIN)/*.*
|
||||||
|
rm $(TARGET)
|
||||||
@@ -0,0 +1,263 @@
|
|||||||
|
#include "Test.h"
|
||||||
|
#include "EPD_2in13_V2.h"
|
||||||
|
#include "GT1151.h"
|
||||||
|
|
||||||
|
extern GT1151_Dev Dev_Now, Dev_Old;
|
||||||
|
extern int IIC_Address;
|
||||||
|
static pthread_t t1;
|
||||||
|
UBYTE flag_t = 1;
|
||||||
|
|
||||||
|
char *PhotoPath_S[7] = {"./pic/2in13/Photo_1_0.bmp",
|
||||||
|
"./pic/2in13/Photo_1_1.bmp", "./pic/2in13/Photo_1_2.bmp", "./pic/2in13/Photo_1_3.bmp", "./pic/2in13/Photo_1_4.bmp",
|
||||||
|
"./pic/2in13/Photo_1_5.bmp", "./pic/2in13/Photo_1_6.bmp",
|
||||||
|
};
|
||||||
|
char *PhotoPath_L[7] = {"./pic/2in13/Photo_2_0.bmp",
|
||||||
|
"./pic/2in13/Photo_2_1.bmp", "./pic/2in13/Photo_2_2.bmp", "./pic/2in13/Photo_2_3.bmp", "./pic/2in13/Photo_2_4.bmp",
|
||||||
|
"./pic/2in13/Photo_2_5.bmp", "./pic/2in13/Photo_2_6.bmp",
|
||||||
|
};
|
||||||
|
char *PagePath[4] = {"./pic/2in13/Menu.bmp", "./pic/2in13/White_board.bmp", "./pic/2in13/Photo_1.bmp", "./pic/2in13/Photo_2.bmp"};
|
||||||
|
|
||||||
|
|
||||||
|
void Handler(int signo)
|
||||||
|
{
|
||||||
|
//System Exit
|
||||||
|
printf("\r\nHandler:exit\r\n");
|
||||||
|
EPD_2IN13_V2_Sleep();
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
flag_t = 0;
|
||||||
|
pthread_join(t1, NULL);
|
||||||
|
DEV_ModuleExit();
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *pthread_irq(void *arg)
|
||||||
|
{
|
||||||
|
while(flag_t) {
|
||||||
|
if(DEV_Digital_Read(INT) == 0) {
|
||||||
|
Dev_Now.Touch = 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Dev_Now.Touch = 0;
|
||||||
|
}
|
||||||
|
DEV_Delay_ms(0.01);
|
||||||
|
}
|
||||||
|
printf("thread:exit\r\n");
|
||||||
|
pthread_exit(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Show_Photo_Small(UBYTE small)
|
||||||
|
{
|
||||||
|
for(UBYTE t=1; t<5; t++) {
|
||||||
|
// printf("t= %d , small= %d \r\n", t, small);
|
||||||
|
if(small*2+t > 6)
|
||||||
|
GUI_ReadBmp(PhotoPath_S[0], (t-1)/2*45+2, (t%2)*124+2);
|
||||||
|
else
|
||||||
|
GUI_ReadBmp(PhotoPath_S[small*2+t], (t-1)/2*45+2, (t%2)*124+2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Show_Photo_Large(UBYTE large)
|
||||||
|
{
|
||||||
|
if(large > 6)
|
||||||
|
GUI_ReadBmp(PhotoPath_L[0], 2, 2);
|
||||||
|
else
|
||||||
|
GUI_ReadBmp(PhotoPath_L[large], 2, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
int TestCode_2in13(void)
|
||||||
|
{
|
||||||
|
IIC_Address = 0x14;
|
||||||
|
|
||||||
|
UDOUBLE i=0, j=0, k=0;
|
||||||
|
UBYTE Page=0, Photo_L=0, Photo_S=0;
|
||||||
|
UBYTE ReFlag=0, SelfFlag=0;
|
||||||
|
signal(SIGINT, Handler);
|
||||||
|
DEV_ModuleInit();
|
||||||
|
|
||||||
|
pthread_create(&t1, NULL, pthread_irq, NULL);
|
||||||
|
|
||||||
|
EPD_2IN13_V2_Init(EPD_2IN13_V2_FULL);
|
||||||
|
|
||||||
|
EPD_2IN13_V2_Clear();
|
||||||
|
|
||||||
|
GT_Init();
|
||||||
|
DEV_Delay_ms(100);
|
||||||
|
//Create a new image cache
|
||||||
|
UBYTE *BlackImage;
|
||||||
|
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, 0, WHITE);
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_SetMirroring(MIRROR_HORIZONTAL);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
GUI_ReadBmp("./pic/2in13/Menu.bmp", 0, 0);
|
||||||
|
EPD_2IN13_V2_DisplayPartBaseImage(BlackImage);
|
||||||
|
EPD_2IN13_V2_Init(EPD_2IN13_V2_PART);
|
||||||
|
|
||||||
|
while(1) {
|
||||||
|
// k++;
|
||||||
|
if(i > 12 || ReFlag == 1) {
|
||||||
|
if(Page == 1 && SelfFlag != 1)
|
||||||
|
EPD_2IN13_V2_DisplayPart(BlackImage);
|
||||||
|
else
|
||||||
|
EPD_2IN13_V2_DisplayPart_Wait(BlackImage);
|
||||||
|
i = 0;
|
||||||
|
k = 0;
|
||||||
|
j++;
|
||||||
|
ReFlag = 0;
|
||||||
|
printf("*** Draw Refresh ***\r\n");
|
||||||
|
}else if(k++>30000000 && i>0 && Page == 1) {
|
||||||
|
EPD_2IN13_V2_DisplayPart(BlackImage);
|
||||||
|
i = 0;
|
||||||
|
k = 0;
|
||||||
|
j++;
|
||||||
|
printf("*** Overtime Refresh ***\r\n");
|
||||||
|
}else if(j > 100 || SelfFlag) {
|
||||||
|
SelfFlag = 0;
|
||||||
|
j = 0;
|
||||||
|
EPD_2IN13_V2_Init(EPD_2IN13_V2_FULL);
|
||||||
|
EPD_2IN13_V2_DisplayPartBaseImage(BlackImage);
|
||||||
|
EPD_2IN13_V2_Init(EPD_2IN13_V2_PART);
|
||||||
|
printf("--- Self Refresh ---\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(GT_Scan()==1 || (Dev_Now.X[0] == Dev_Old.X[0] && Dev_Now.Y[0] == Dev_Old.Y[0])) { // No new touch
|
||||||
|
// printf("%d %d \r\n", j, SelfFlag);
|
||||||
|
// printf("No new touch \r\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Dev_Now.TouchpointFlag) {
|
||||||
|
i++;
|
||||||
|
Dev_Now.TouchpointFlag = 0;
|
||||||
|
|
||||||
|
if(Page == 0 && ReFlag == 0) { //main menu
|
||||||
|
if(Dev_Now.X[0] > 29 && Dev_Now.X[0] < 92 && Dev_Now.Y[0] > 56 && Dev_Now.Y[0] < 95) {
|
||||||
|
printf("Photo ...\r\n");
|
||||||
|
Page = 2;
|
||||||
|
GUI_ReadBmp(PagePath[Page], 0, 0);
|
||||||
|
Show_Photo_Small(Photo_S);
|
||||||
|
ReFlag = 1;
|
||||||
|
}
|
||||||
|
else if(Dev_Now.X[0] > 29 && Dev_Now.X[0] < 92 && Dev_Now.Y[0] > 153 && Dev_Now.Y[0] < 193) {
|
||||||
|
printf("Draw ...\r\n");
|
||||||
|
Page = 1;
|
||||||
|
GUI_ReadBmp(PagePath[Page], 0, 0);
|
||||||
|
ReFlag = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Page == 1 && ReFlag == 0) { //white board
|
||||||
|
Paint_DrawPoint(Dev_Now.X[0], Dev_Now.Y[0], BLACK, Dev_Now.S[0]/8+1, DOT_STYLE_DFT);
|
||||||
|
|
||||||
|
if(Dev_Now.X[0] > 96 && Dev_Now.X[0] < 118 && Dev_Now.Y[0] > 6 && Dev_Now.Y[0] < 30) {
|
||||||
|
printf("Home ...\r\n");
|
||||||
|
Page = 1;
|
||||||
|
GUI_ReadBmp(PagePath[Page], 0, 0);
|
||||||
|
ReFlag = 1;
|
||||||
|
}
|
||||||
|
else if(Dev_Now.X[0] > 96 && Dev_Now.X[0] < 118 && Dev_Now.Y[0] > 113 && Dev_Now.Y[0] < 136) {
|
||||||
|
printf("Clear ...\r\n");
|
||||||
|
Page = 0;
|
||||||
|
GUI_ReadBmp(PagePath[Page], 0, 0);
|
||||||
|
ReFlag = 1;
|
||||||
|
}
|
||||||
|
else if(Dev_Now.X[0] > 96 && Dev_Now.X[0] < 118 && Dev_Now.Y[0] > 220 && Dev_Now.Y[0] < 242) {
|
||||||
|
printf("Refresh ...\r\n");
|
||||||
|
SelfFlag = 1;
|
||||||
|
ReFlag = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Page == 2 && ReFlag == 0) { //photo menu
|
||||||
|
if(Dev_Now.X[0] > 97 && Dev_Now.X[0] < 119 && Dev_Now.Y[0] > 113 && Dev_Now.Y[0] < 136) {
|
||||||
|
printf("Home ...\r\n");
|
||||||
|
Page = 0;
|
||||||
|
GUI_ReadBmp(PagePath[Page], 0, 0);
|
||||||
|
ReFlag = 1;
|
||||||
|
}
|
||||||
|
else if(Dev_Now.X[0] > 97 && Dev_Now.X[0] < 119 && Dev_Now.Y[0] > 57 && Dev_Now.Y[0] < 78) {
|
||||||
|
printf("Next page ...\r\n");
|
||||||
|
Photo_S++;
|
||||||
|
if(Photo_S > 2) // 6 photos is a maximum of three pages
|
||||||
|
Photo_S=0;
|
||||||
|
ReFlag = 2;
|
||||||
|
}
|
||||||
|
else if(Dev_Now.X[0] > 97 && Dev_Now.X[0] < 119 && Dev_Now.Y[0] > 169 && Dev_Now.Y[0] < 190) {
|
||||||
|
printf("Last page ...\r\n");
|
||||||
|
if(Photo_S == 0)
|
||||||
|
printf("Top page ...\r\n");
|
||||||
|
else {
|
||||||
|
Photo_S--;
|
||||||
|
ReFlag = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(Dev_Now.X[0] > 97 && Dev_Now.X[0] < 119 && Dev_Now.Y[0] > 220 && Dev_Now.Y[0] < 242) {
|
||||||
|
printf("Refresh ...\r\n");
|
||||||
|
SelfFlag = 1;
|
||||||
|
ReFlag = 1;
|
||||||
|
}
|
||||||
|
else if(Dev_Now.X[0] > 2 && Dev_Now.X[0] < 90 && Dev_Now.Y[0] > 2 && Dev_Now.Y[0] < 248 && ReFlag == 0) {
|
||||||
|
printf("Select photo ...\r\n");
|
||||||
|
Page = 3;
|
||||||
|
GUI_ReadBmp(PagePath[Page], 0, 0);
|
||||||
|
Photo_L = Dev_Now.X[0]/46*2 + 2-Dev_Now.Y[0]/124 + Photo_S*2;
|
||||||
|
Show_Photo_Large(Photo_L);
|
||||||
|
ReFlag = 1;
|
||||||
|
}
|
||||||
|
if(ReFlag == 2) { // Refresh small photo
|
||||||
|
ReFlag = 1;
|
||||||
|
GUI_ReadBmp(PagePath[Page], 0, 0);
|
||||||
|
Show_Photo_Small(Photo_S); // show small photo
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Page == 3 && ReFlag == 0) { //view the photo
|
||||||
|
if(Dev_Now.X[0] > 96 && Dev_Now.X[0] < 117 && Dev_Now.Y[0] > 4 && Dev_Now.Y[0] < 25) {
|
||||||
|
printf("Photo menu ...\r\n");
|
||||||
|
Page = 2;
|
||||||
|
GUI_ReadBmp(PagePath[Page], 0, 0);
|
||||||
|
Show_Photo_Small(Photo_S);
|
||||||
|
ReFlag = 1;
|
||||||
|
}
|
||||||
|
else if(Dev_Now.X[0] > 96 && Dev_Now.X[0] < 117 && Dev_Now.Y[0] > 57 && Dev_Now.Y[0] < 78) {
|
||||||
|
printf("Next photo ...\r\n");
|
||||||
|
Photo_L++;
|
||||||
|
if(Photo_L > 6)
|
||||||
|
Photo_L=1;
|
||||||
|
ReFlag = 2;
|
||||||
|
}
|
||||||
|
else if(Dev_Now.X[0] > 96 && Dev_Now.X[0] < 117 && Dev_Now.Y[0] > 113 && Dev_Now.Y[0] < 136) {
|
||||||
|
printf("Home ...\r\n");
|
||||||
|
Page = 0;
|
||||||
|
GUI_ReadBmp(PagePath[Page], 0, 0);
|
||||||
|
ReFlag = 1;
|
||||||
|
}
|
||||||
|
else if(Dev_Now.X[0] > 96 && Dev_Now.X[0] < 117 && Dev_Now.Y[0] > 169 && Dev_Now.Y[0] < 190) {
|
||||||
|
printf("Last page ...\r\n");
|
||||||
|
if(Photo_L == 1)
|
||||||
|
printf("Top photo ...\r\n");
|
||||||
|
else {
|
||||||
|
Photo_L--;
|
||||||
|
ReFlag = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(Dev_Now.X[0] > 96 && Dev_Now.X[0] < 117 && Dev_Now.Y[0] > 220 && Dev_Now.Y[0] < 242) {
|
||||||
|
printf("Refresh photo ...\r\n");
|
||||||
|
SelfFlag = 1;
|
||||||
|
ReFlag = 1;
|
||||||
|
}
|
||||||
|
if(ReFlag == 2) { // Refresh large photo
|
||||||
|
ReFlag = 1;
|
||||||
|
Show_Photo_Large(Photo_L);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,264 @@
|
|||||||
|
#include "Test.h"
|
||||||
|
#include "EPD_2in13_V3.h"
|
||||||
|
#include "GT1151.h"
|
||||||
|
|
||||||
|
extern GT1151_Dev Dev_Now, Dev_Old;
|
||||||
|
extern int IIC_Address;
|
||||||
|
static pthread_t t1_2in13_V3;
|
||||||
|
UBYTE flag_t_2in13_V3 = 1;
|
||||||
|
|
||||||
|
char *PhotoPath_S_2in13_V3[7] = {"./pic/2in13/Photo_1_0.bmp",
|
||||||
|
"./pic/2in13/Photo_1_1.bmp", "./pic/2in13/Photo_1_2.bmp", "./pic/2in13/Photo_1_3.bmp", "./pic/2in13/Photo_1_4.bmp",
|
||||||
|
"./pic/2in13/Photo_1_5.bmp", "./pic/2in13/Photo_1_6.bmp",
|
||||||
|
};
|
||||||
|
char *PhotoPath_L_2in13_V3[7] = {"./pic/2in13/Photo_2_0.bmp",
|
||||||
|
"./pic/2in13/Photo_2_1.bmp", "./pic/2in13/Photo_2_2.bmp", "./pic/2in13/Photo_2_3.bmp", "./pic/2in13/Photo_2_4.bmp",
|
||||||
|
"./pic/2in13/Photo_2_5.bmp", "./pic/2in13/Photo_2_6.bmp",
|
||||||
|
};
|
||||||
|
char *PagePath_2in13_V3[4] = {"./pic/2in13/Menu.bmp", "./pic/2in13/White_board.bmp", "./pic/2in13/Photo_1.bmp", "./pic/2in13/Photo_2.bmp"};
|
||||||
|
|
||||||
|
|
||||||
|
void Handler_2in13_V3(int signo)
|
||||||
|
{
|
||||||
|
//System Exit
|
||||||
|
printf("\r\nHandler:exit\r\n");
|
||||||
|
EPD_2in13_V3_Sleep();
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
flag_t_2in13_V3 = 0;
|
||||||
|
pthread_join(t1_2in13_V3, NULL);
|
||||||
|
DEV_ModuleExit();
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *pthread_irq_2in13_V3(void *arg)
|
||||||
|
{
|
||||||
|
while(flag_t_2in13_V3) {
|
||||||
|
if(DEV_Digital_Read(INT) == 0) {
|
||||||
|
Dev_Now.Touch = 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Dev_Now.Touch = 0;
|
||||||
|
}
|
||||||
|
DEV_Delay_ms(0.01);
|
||||||
|
}
|
||||||
|
printf("thread:exit\r\n");
|
||||||
|
pthread_exit(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Show_Photo_Small_2in13_V3(UBYTE small)
|
||||||
|
{
|
||||||
|
for(UBYTE t=1; t<5; t++) {
|
||||||
|
// printf("t= %d , small= %d \r\n", t, small);
|
||||||
|
if(small*2+t > 6)
|
||||||
|
GUI_ReadBmp(PhotoPath_S_2in13_V3[0], (t-1)/2*45+2, (t%2)*124+2);
|
||||||
|
else
|
||||||
|
GUI_ReadBmp(PhotoPath_S_2in13_V3[small*2+t], (t-1)/2*45+2, (t%2)*124+2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Show_Photo_Large_2in13_V3(UBYTE large)
|
||||||
|
{
|
||||||
|
if(large > 6)
|
||||||
|
GUI_ReadBmp(PhotoPath_L_2in13_V3[0], 2, 2);
|
||||||
|
else
|
||||||
|
GUI_ReadBmp(PhotoPath_L_2in13_V3[large], 2, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
int TestCode_2in13_V3(void)
|
||||||
|
{
|
||||||
|
IIC_Address = 0x14;
|
||||||
|
|
||||||
|
UDOUBLE i=0, j=0, k=0;
|
||||||
|
UBYTE Page=0, Photo_L=0, Photo_S=0;
|
||||||
|
UBYTE ReFlag=0, SelfFlag=0;
|
||||||
|
signal(SIGINT, Handler_2in13_V3);
|
||||||
|
DEV_ModuleInit();
|
||||||
|
|
||||||
|
pthread_create(&t1_2in13_V3, NULL, pthread_irq_2in13_V3, NULL);
|
||||||
|
|
||||||
|
EPD_2in13_V3_Init(EPD_2IN13_V3_FULL);
|
||||||
|
|
||||||
|
EPD_2in13_V3_Clear();
|
||||||
|
|
||||||
|
GT_Init();
|
||||||
|
DEV_Delay_ms(100);
|
||||||
|
//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, 0, WHITE);
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_SetMirroring(MIRROR_ORIGIN);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
GUI_ReadBmp("./pic/2in13/Menu.bmp", 0, 0);
|
||||||
|
EPD_2in13_V3_Display(BlackImage);
|
||||||
|
EPD_2in13_V3_Init(EPD_2IN13_V3_PART);
|
||||||
|
EPD_2in13_V3_Display_Partial_Wait(BlackImage);
|
||||||
|
|
||||||
|
while(1) {
|
||||||
|
// k++;
|
||||||
|
if(i > 12 || ReFlag == 1) {
|
||||||
|
if(Page == 1 && SelfFlag != 1)
|
||||||
|
EPD_2in13_V3_Display_Partial(BlackImage);
|
||||||
|
else
|
||||||
|
EPD_2in13_V3_Display_Partial_Wait(BlackImage);
|
||||||
|
i = 0;
|
||||||
|
k = 0;
|
||||||
|
j++;
|
||||||
|
ReFlag = 0;
|
||||||
|
printf("*** Draw Refresh ***\r\n");
|
||||||
|
}else if(k++>30000000 && i>0 && Page == 1) {
|
||||||
|
EPD_2in13_V3_Display_Partial(BlackImage);
|
||||||
|
i = 0;
|
||||||
|
k = 0;
|
||||||
|
j++;
|
||||||
|
printf("*** Overtime Refresh ***\r\n");
|
||||||
|
}else if(j > 100 || SelfFlag) {
|
||||||
|
SelfFlag = 0;
|
||||||
|
j = 0;
|
||||||
|
EPD_2in13_V3_Init(EPD_2IN13_V3_FULL);
|
||||||
|
EPD_2in13_V3_Display_Base(BlackImage);
|
||||||
|
EPD_2in13_V3_Init(EPD_2IN13_V3_PART);
|
||||||
|
printf("--- Self Refresh ---\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(GT_Scan()==1 || (Dev_Now.X[0] == Dev_Old.X[0] && Dev_Now.Y[0] == Dev_Old.Y[0])) { // No new touch
|
||||||
|
// printf("%d %d \r\n", j, SelfFlag);
|
||||||
|
// printf("No new touch \r\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Dev_Now.TouchpointFlag) {
|
||||||
|
i++;
|
||||||
|
Dev_Now.TouchpointFlag = 0;
|
||||||
|
|
||||||
|
if(Page == 0 && ReFlag == 0) { //main menu
|
||||||
|
if(Dev_Now.X[0] > 29 && Dev_Now.X[0] < 92 && Dev_Now.Y[0] > 56 && Dev_Now.Y[0] < 95) {
|
||||||
|
printf("Photo ...\r\n");
|
||||||
|
Page = 2;
|
||||||
|
GUI_ReadBmp(PagePath_2in13_V3[Page], 0, 0);
|
||||||
|
Show_Photo_Small_2in13_V3(Photo_S);
|
||||||
|
ReFlag = 1;
|
||||||
|
}
|
||||||
|
else if(Dev_Now.X[0] > 29 && Dev_Now.X[0] < 92 && Dev_Now.Y[0] > 153 && Dev_Now.Y[0] < 193) {
|
||||||
|
printf("Draw ...\r\n");
|
||||||
|
Page = 1;
|
||||||
|
GUI_ReadBmp(PagePath_2in13_V3[Page], 0, 0);
|
||||||
|
ReFlag = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Page == 1 && ReFlag == 0) { //white board
|
||||||
|
Paint_DrawPoint(Dev_Now.X[0], Dev_Now.Y[0], BLACK, Dev_Now.S[0]/8+1, DOT_STYLE_DFT);
|
||||||
|
|
||||||
|
if(Dev_Now.X[0] > 96 && Dev_Now.X[0] < 118 && Dev_Now.Y[0] > 6 && Dev_Now.Y[0] < 30) {
|
||||||
|
printf("Home ...\r\n");
|
||||||
|
Page = 1;
|
||||||
|
GUI_ReadBmp(PagePath_2in13_V3[Page], 0, 0);
|
||||||
|
ReFlag = 1;
|
||||||
|
}
|
||||||
|
else if(Dev_Now.X[0] > 96 && Dev_Now.X[0] < 118 && Dev_Now.Y[0] > 113 && Dev_Now.Y[0] < 136) {
|
||||||
|
printf("Clear ...\r\n");
|
||||||
|
Page = 0;
|
||||||
|
GUI_ReadBmp(PagePath_2in13_V3[Page], 0, 0);
|
||||||
|
ReFlag = 1;
|
||||||
|
}
|
||||||
|
else if(Dev_Now.X[0] > 96 && Dev_Now.X[0] < 118 && Dev_Now.Y[0] > 220 && Dev_Now.Y[0] < 242) {
|
||||||
|
printf("Refresh ...\r\n");
|
||||||
|
SelfFlag = 1;
|
||||||
|
ReFlag = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Page == 2 && ReFlag == 0) { //photo menu
|
||||||
|
if(Dev_Now.X[0] > 97 && Dev_Now.X[0] < 119 && Dev_Now.Y[0] > 113 && Dev_Now.Y[0] < 136) {
|
||||||
|
printf("Home ...\r\n");
|
||||||
|
Page = 0;
|
||||||
|
GUI_ReadBmp(PagePath_2in13_V3[Page], 0, 0);
|
||||||
|
ReFlag = 1;
|
||||||
|
}
|
||||||
|
else if(Dev_Now.X[0] > 97 && Dev_Now.X[0] < 119 && Dev_Now.Y[0] > 57 && Dev_Now.Y[0] < 78) {
|
||||||
|
printf("Next page ...\r\n");
|
||||||
|
Photo_S++;
|
||||||
|
if(Photo_S > 2) // 6 photos is a maximum of three pages
|
||||||
|
Photo_S=0;
|
||||||
|
ReFlag = 2;
|
||||||
|
}
|
||||||
|
else if(Dev_Now.X[0] > 97 && Dev_Now.X[0] < 119 && Dev_Now.Y[0] > 169 && Dev_Now.Y[0] < 190) {
|
||||||
|
printf("Last page ...\r\n");
|
||||||
|
if(Photo_S == 0)
|
||||||
|
printf("Top page ...\r\n");
|
||||||
|
else {
|
||||||
|
Photo_S--;
|
||||||
|
ReFlag = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(Dev_Now.X[0] > 97 && Dev_Now.X[0] < 119 && Dev_Now.Y[0] > 220 && Dev_Now.Y[0] < 242) {
|
||||||
|
printf("Refresh ...\r\n");
|
||||||
|
SelfFlag = 1;
|
||||||
|
ReFlag = 1;
|
||||||
|
}
|
||||||
|
else if(Dev_Now.X[0] > 2 && Dev_Now.X[0] < 90 && Dev_Now.Y[0] > 2 && Dev_Now.Y[0] < 248 && ReFlag == 0) {
|
||||||
|
printf("Select photo ...\r\n");
|
||||||
|
Page = 3;
|
||||||
|
GUI_ReadBmp(PagePath_2in13_V3[Page], 0, 0);
|
||||||
|
Photo_L = Dev_Now.X[0]/46*2 + 2-Dev_Now.Y[0]/124 + Photo_S*2;
|
||||||
|
Show_Photo_Large_2in13_V3(Photo_L);
|
||||||
|
ReFlag = 1;
|
||||||
|
}
|
||||||
|
if(ReFlag == 2) { // Refresh small photo
|
||||||
|
ReFlag = 1;
|
||||||
|
GUI_ReadBmp(PagePath_2in13_V3[Page], 0, 0);
|
||||||
|
Show_Photo_Small_2in13_V3(Photo_S); // show small photo
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Page == 3 && ReFlag == 0) { //view the photo
|
||||||
|
if(Dev_Now.X[0] > 96 && Dev_Now.X[0] < 117 && Dev_Now.Y[0] > 4 && Dev_Now.Y[0] < 25) {
|
||||||
|
printf("Photo menu ...\r\n");
|
||||||
|
Page = 2;
|
||||||
|
GUI_ReadBmp(PagePath_2in13_V3[Page], 0, 0);
|
||||||
|
Show_Photo_Small_2in13_V3(Photo_S);
|
||||||
|
ReFlag = 1;
|
||||||
|
}
|
||||||
|
else if(Dev_Now.X[0] > 96 && Dev_Now.X[0] < 117 && Dev_Now.Y[0] > 57 && Dev_Now.Y[0] < 78) {
|
||||||
|
printf("Next photo ...\r\n");
|
||||||
|
Photo_L++;
|
||||||
|
if(Photo_L > 6)
|
||||||
|
Photo_L=1;
|
||||||
|
ReFlag = 2;
|
||||||
|
}
|
||||||
|
else if(Dev_Now.X[0] > 96 && Dev_Now.X[0] < 117 && Dev_Now.Y[0] > 113 && Dev_Now.Y[0] < 136) {
|
||||||
|
printf("Home ...\r\n");
|
||||||
|
Page = 0;
|
||||||
|
GUI_ReadBmp(PagePath_2in13_V3[Page], 0, 0);
|
||||||
|
ReFlag = 1;
|
||||||
|
}
|
||||||
|
else if(Dev_Now.X[0] > 96 && Dev_Now.X[0] < 117 && Dev_Now.Y[0] > 169 && Dev_Now.Y[0] < 190) {
|
||||||
|
printf("Last page ...\r\n");
|
||||||
|
if(Photo_L == 1)
|
||||||
|
printf("Top photo ...\r\n");
|
||||||
|
else {
|
||||||
|
Photo_L--;
|
||||||
|
ReFlag = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(Dev_Now.X[0] > 96 && Dev_Now.X[0] < 117 && Dev_Now.Y[0] > 220 && Dev_Now.Y[0] < 242) {
|
||||||
|
printf("Refresh photo ...\r\n");
|
||||||
|
SelfFlag = 1;
|
||||||
|
ReFlag = 1;
|
||||||
|
}
|
||||||
|
if(ReFlag == 2) { // Refresh large photo
|
||||||
|
ReFlag = 1;
|
||||||
|
Show_Photo_Large_2in13_V3(Photo_L);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,264 @@
|
|||||||
|
#include "Test.h"
|
||||||
|
#include "EPD_2in13_V4.h"
|
||||||
|
#include "GT1151.h"
|
||||||
|
|
||||||
|
extern GT1151_Dev Dev_Now, Dev_Old;
|
||||||
|
extern int IIC_Address;
|
||||||
|
static pthread_t t1_2in13_V4;
|
||||||
|
UBYTE flag_t_2in13_V4 = 1;
|
||||||
|
|
||||||
|
char *PhotoPath_S_2in13_V4[7] = {"./pic/2in13/Photo_1_0.bmp",
|
||||||
|
"./pic/2in13/Photo_1_1.bmp", "./pic/2in13/Photo_1_2.bmp", "./pic/2in13/Photo_1_3.bmp", "./pic/2in13/Photo_1_4.bmp",
|
||||||
|
"./pic/2in13/Photo_1_5.bmp", "./pic/2in13/Photo_1_6.bmp",
|
||||||
|
};
|
||||||
|
char *PhotoPath_L_2in13_V4[7] = {"./pic/2in13/Photo_2_0.bmp",
|
||||||
|
"./pic/2in13/Photo_2_1.bmp", "./pic/2in13/Photo_2_2.bmp", "./pic/2in13/Photo_2_3.bmp", "./pic/2in13/Photo_2_4.bmp",
|
||||||
|
"./pic/2in13/Photo_2_5.bmp", "./pic/2in13/Photo_2_6.bmp",
|
||||||
|
};
|
||||||
|
char *PagePath_2in13_V4[4] = {"./pic/2in13/Menu.bmp", "./pic/2in13/White_board.bmp", "./pic/2in13/Photo_1.bmp", "./pic/2in13/Photo_2.bmp"};
|
||||||
|
|
||||||
|
|
||||||
|
void Handler_2in13_V4(int signo)
|
||||||
|
{
|
||||||
|
//System Exit
|
||||||
|
printf("\r\nHandler:exit\r\n");
|
||||||
|
EPD_2in13_V4_Sleep();
|
||||||
|
DEV_Delay_ms(2000);
|
||||||
|
flag_t_2in13_V4 = 0;
|
||||||
|
pthread_join(t1_2in13_V4, NULL);
|
||||||
|
DEV_ModuleExit();
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *pthread_irq_2in13_V4(void *arg)
|
||||||
|
{
|
||||||
|
while(flag_t_2in13_V4) {
|
||||||
|
if(DEV_Digital_Read(INT) == 0) {
|
||||||
|
Dev_Now.Touch = 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Dev_Now.Touch = 0;
|
||||||
|
}
|
||||||
|
DEV_Delay_ms(0.01);
|
||||||
|
}
|
||||||
|
printf("thread:exit\r\n");
|
||||||
|
pthread_exit(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Show_Photo_Small_2in13_V4(UBYTE small)
|
||||||
|
{
|
||||||
|
for(UBYTE t=1; t<5; t++) {
|
||||||
|
// printf("t= %d , small= %d \r\n", t, small);
|
||||||
|
if(small*2+t > 6)
|
||||||
|
GUI_ReadBmp(PhotoPath_S_2in13_V4[0], (t-1)/2*45+2, (t%2)*124+2);
|
||||||
|
else
|
||||||
|
GUI_ReadBmp(PhotoPath_S_2in13_V4[small*2+t], (t-1)/2*45+2, (t%2)*124+2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Show_Photo_Large_2in13_V4(UBYTE large)
|
||||||
|
{
|
||||||
|
if(large > 6)
|
||||||
|
GUI_ReadBmp(PhotoPath_L_2in13_V4[0], 2, 2);
|
||||||
|
else
|
||||||
|
GUI_ReadBmp(PhotoPath_L_2in13_V4[large], 2, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
int TestCode_2in13_V4(void)
|
||||||
|
{
|
||||||
|
IIC_Address = 0x14;
|
||||||
|
|
||||||
|
UDOUBLE i=0, j=0, k=0;
|
||||||
|
UBYTE Page=0, Photo_L=0, Photo_S=0;
|
||||||
|
UBYTE ReFlag=0, SelfFlag=0;
|
||||||
|
signal(SIGINT, Handler_2in13_V4);
|
||||||
|
DEV_ModuleInit();
|
||||||
|
|
||||||
|
pthread_create(&t1_2in13_V4, NULL, pthread_irq_2in13_V4, NULL);
|
||||||
|
|
||||||
|
EPD_2in13_V4_Init(EPD_2IN13_V4_FULL);
|
||||||
|
|
||||||
|
EPD_2in13_V4_Clear();
|
||||||
|
|
||||||
|
GT_Init();
|
||||||
|
DEV_Delay_ms(100);
|
||||||
|
//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) {
|
||||||
|
printf("Failed to apply for black memory...\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
printf("Paint_NewImage\r\n");
|
||||||
|
Paint_NewImage(BlackImage, EPD_2in13_V4_WIDTH, EPD_2in13_V4_HEIGHT, 0, WHITE);
|
||||||
|
Paint_SelectImage(BlackImage);
|
||||||
|
Paint_SetMirroring(MIRROR_ORIGIN);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
GUI_ReadBmp("./pic/2in13/Menu.bmp", 0, 0);
|
||||||
|
EPD_2in13_V4_Display(BlackImage);
|
||||||
|
EPD_2in13_V4_Init(EPD_2IN13_V4_PART);
|
||||||
|
EPD_2in13_V4_Display_Partial_Wait(BlackImage);
|
||||||
|
|
||||||
|
while(1) {
|
||||||
|
// k++;
|
||||||
|
if(i > 12 || ReFlag == 1) {
|
||||||
|
if(Page == 1 && SelfFlag != 1)
|
||||||
|
EPD_2in13_V4_Display_Partial(BlackImage);
|
||||||
|
else
|
||||||
|
EPD_2in13_V4_Display_Partial_Wait(BlackImage);
|
||||||
|
i = 0;
|
||||||
|
k = 0;
|
||||||
|
j++;
|
||||||
|
ReFlag = 0;
|
||||||
|
printf("*** Draw Refresh ***\r\n");
|
||||||
|
}else if(k++>30000000 && i>0 && Page == 1) {
|
||||||
|
EPD_2in13_V4_Display_Partial(BlackImage);
|
||||||
|
i = 0;
|
||||||
|
k = 0;
|
||||||
|
j++;
|
||||||
|
printf("*** Overtime Refresh ***\r\n");
|
||||||
|
}else if(j > 100 || SelfFlag) {
|
||||||
|
SelfFlag = 0;
|
||||||
|
j = 0;
|
||||||
|
EPD_2in13_V4_Init(EPD_2IN13_V4_FULL);
|
||||||
|
EPD_2in13_V4_Display_Base(BlackImage);
|
||||||
|
EPD_2in13_V4_Init(EPD_2IN13_V4_PART);
|
||||||
|
printf("--- Self Refresh ---\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(GT_Scan()==1 || (Dev_Now.X[0] == Dev_Old.X[0] && Dev_Now.Y[0] == Dev_Old.Y[0])) { // No new touch
|
||||||
|
// printf("%d %d \r\n", j, SelfFlag);
|
||||||
|
// printf("No new touch \r\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Dev_Now.TouchpointFlag) {
|
||||||
|
i++;
|
||||||
|
Dev_Now.TouchpointFlag = 0;
|
||||||
|
|
||||||
|
if(Page == 0 && ReFlag == 0) { //main menu
|
||||||
|
if(Dev_Now.X[0] > 29 && Dev_Now.X[0] < 92 && Dev_Now.Y[0] > 56 && Dev_Now.Y[0] < 95) {
|
||||||
|
printf("Photo ...\r\n");
|
||||||
|
Page = 2;
|
||||||
|
GUI_ReadBmp(PagePath_2in13_V4[Page], 0, 0);
|
||||||
|
Show_Photo_Small_2in13_V4(Photo_S);
|
||||||
|
ReFlag = 1;
|
||||||
|
}
|
||||||
|
else if(Dev_Now.X[0] > 29 && Dev_Now.X[0] < 92 && Dev_Now.Y[0] > 153 && Dev_Now.Y[0] < 193) {
|
||||||
|
printf("Draw ...\r\n");
|
||||||
|
Page = 1;
|
||||||
|
GUI_ReadBmp(PagePath_2in13_V4[Page], 0, 0);
|
||||||
|
ReFlag = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Page == 1 && ReFlag == 0) { //white board
|
||||||
|
Paint_DrawPoint(Dev_Now.X[0], Dev_Now.Y[0], BLACK, Dev_Now.S[0]/8+1, DOT_STYLE_DFT);
|
||||||
|
|
||||||
|
if(Dev_Now.X[0] > 96 && Dev_Now.X[0] < 118 && Dev_Now.Y[0] > 6 && Dev_Now.Y[0] < 30) {
|
||||||
|
printf("Home ...\r\n");
|
||||||
|
Page = 1;
|
||||||
|
GUI_ReadBmp(PagePath_2in13_V4[Page], 0, 0);
|
||||||
|
ReFlag = 1;
|
||||||
|
}
|
||||||
|
else if(Dev_Now.X[0] > 96 && Dev_Now.X[0] < 118 && Dev_Now.Y[0] > 113 && Dev_Now.Y[0] < 136) {
|
||||||
|
printf("Clear ...\r\n");
|
||||||
|
Page = 0;
|
||||||
|
GUI_ReadBmp(PagePath_2in13_V4[Page], 0, 0);
|
||||||
|
ReFlag = 1;
|
||||||
|
}
|
||||||
|
else if(Dev_Now.X[0] > 96 && Dev_Now.X[0] < 118 && Dev_Now.Y[0] > 220 && Dev_Now.Y[0] < 242) {
|
||||||
|
printf("Refresh ...\r\n");
|
||||||
|
SelfFlag = 1;
|
||||||
|
ReFlag = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Page == 2 && ReFlag == 0) { //photo menu
|
||||||
|
if(Dev_Now.X[0] > 97 && Dev_Now.X[0] < 119 && Dev_Now.Y[0] > 113 && Dev_Now.Y[0] < 136) {
|
||||||
|
printf("Home ...\r\n");
|
||||||
|
Page = 0;
|
||||||
|
GUI_ReadBmp(PagePath_2in13_V4[Page], 0, 0);
|
||||||
|
ReFlag = 1;
|
||||||
|
}
|
||||||
|
else if(Dev_Now.X[0] > 97 && Dev_Now.X[0] < 119 && Dev_Now.Y[0] > 57 && Dev_Now.Y[0] < 78) {
|
||||||
|
printf("Next page ...\r\n");
|
||||||
|
Photo_S++;
|
||||||
|
if(Photo_S > 2) // 6 photos is a maximum of three pages
|
||||||
|
Photo_S=0;
|
||||||
|
ReFlag = 2;
|
||||||
|
}
|
||||||
|
else if(Dev_Now.X[0] > 97 && Dev_Now.X[0] < 119 && Dev_Now.Y[0] > 169 && Dev_Now.Y[0] < 190) {
|
||||||
|
printf("Last page ...\r\n");
|
||||||
|
if(Photo_S == 0)
|
||||||
|
printf("Top page ...\r\n");
|
||||||
|
else {
|
||||||
|
Photo_S--;
|
||||||
|
ReFlag = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(Dev_Now.X[0] > 97 && Dev_Now.X[0] < 119 && Dev_Now.Y[0] > 220 && Dev_Now.Y[0] < 242) {
|
||||||
|
printf("Refresh ...\r\n");
|
||||||
|
SelfFlag = 1;
|
||||||
|
ReFlag = 1;
|
||||||
|
}
|
||||||
|
else if(Dev_Now.X[0] > 2 && Dev_Now.X[0] < 90 && Dev_Now.Y[0] > 2 && Dev_Now.Y[0] < 248 && ReFlag == 0) {
|
||||||
|
printf("Select photo ...\r\n");
|
||||||
|
Page = 3;
|
||||||
|
GUI_ReadBmp(PagePath_2in13_V4[Page], 0, 0);
|
||||||
|
Photo_L = Dev_Now.X[0]/46*2 + 2-Dev_Now.Y[0]/124 + Photo_S*2;
|
||||||
|
Show_Photo_Large_2in13_V4(Photo_L);
|
||||||
|
ReFlag = 1;
|
||||||
|
}
|
||||||
|
if(ReFlag == 2) { // Refresh small photo
|
||||||
|
ReFlag = 1;
|
||||||
|
GUI_ReadBmp(PagePath_2in13_V4[Page], 0, 0);
|
||||||
|
Show_Photo_Small_2in13_V4(Photo_S); // show small photo
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Page == 3 && ReFlag == 0) { //view the photo
|
||||||
|
if(Dev_Now.X[0] > 96 && Dev_Now.X[0] < 117 && Dev_Now.Y[0] > 4 && Dev_Now.Y[0] < 25) {
|
||||||
|
printf("Photo menu ...\r\n");
|
||||||
|
Page = 2;
|
||||||
|
GUI_ReadBmp(PagePath_2in13_V4[Page], 0, 0);
|
||||||
|
Show_Photo_Small_2in13_V4(Photo_S);
|
||||||
|
ReFlag = 1;
|
||||||
|
}
|
||||||
|
else if(Dev_Now.X[0] > 96 && Dev_Now.X[0] < 117 && Dev_Now.Y[0] > 57 && Dev_Now.Y[0] < 78) {
|
||||||
|
printf("Next photo ...\r\n");
|
||||||
|
Photo_L++;
|
||||||
|
if(Photo_L > 6)
|
||||||
|
Photo_L=1;
|
||||||
|
ReFlag = 2;
|
||||||
|
}
|
||||||
|
else if(Dev_Now.X[0] > 96 && Dev_Now.X[0] < 117 && Dev_Now.Y[0] > 113 && Dev_Now.Y[0] < 136) {
|
||||||
|
printf("Home ...\r\n");
|
||||||
|
Page = 0;
|
||||||
|
GUI_ReadBmp(PagePath_2in13_V4[Page], 0, 0);
|
||||||
|
ReFlag = 1;
|
||||||
|
}
|
||||||
|
else if(Dev_Now.X[0] > 96 && Dev_Now.X[0] < 117 && Dev_Now.Y[0] > 169 && Dev_Now.Y[0] < 190) {
|
||||||
|
printf("Last page ...\r\n");
|
||||||
|
if(Photo_L == 1)
|
||||||
|
printf("Top photo ...\r\n");
|
||||||
|
else {
|
||||||
|
Photo_L--;
|
||||||
|
ReFlag = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(Dev_Now.X[0] > 96 && Dev_Now.X[0] < 117 && Dev_Now.Y[0] > 220 && Dev_Now.Y[0] < 242) {
|
||||||
|
printf("Refresh photo ...\r\n");
|
||||||
|
SelfFlag = 1;
|
||||||
|
ReFlag = 1;
|
||||||
|
}
|
||||||
|
if(ReFlag == 2) { // Refresh large photo
|
||||||
|
ReFlag = 1;
|
||||||
|
Show_Photo_Large_2in13_V4(Photo_L);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,364 @@
|
|||||||
|
#include "Test.h"
|
||||||
|
#include "EPD_2in9_V2.h"
|
||||||
|
#include "ICNT86X.h"
|
||||||
|
#include "time.h"
|
||||||
|
|
||||||
|
extern ICNT86_Dev ICNT86_Dev_Now, ICNT86_Dev_Old;
|
||||||
|
extern int IIC_Address;
|
||||||
|
static pthread_t t1, t2;
|
||||||
|
UBYTE flag_2in9=1, dis_lock=1, dis_flag=1;
|
||||||
|
UBYTE *BlackImage, *BlackImage_ASYNC;
|
||||||
|
|
||||||
|
char *PhotoPath_S_2in9[10] = {"./pic/2in9/Photo_1_0.bmp",
|
||||||
|
"./pic/2in9/Photo_1_1.bmp", "./pic/2in9/Photo_1_2.bmp", "./pic/2in9/Photo_1_3.bmp", "./pic/2in9/Photo_1_4.bmp",
|
||||||
|
"./pic/2in9/Photo_1_5.bmp", "./pic/2in9/Photo_1_6.bmp", "./pic/2in9/Photo_1_7.bmp", "./pic/2in9/Photo_1_8.bmp",
|
||||||
|
"./pic/2in9/Photo_1_9.bmp",
|
||||||
|
};
|
||||||
|
char *PhotoPath_L_2in9[10] = {"./pic/2in9/Photo_2_0.bmp",
|
||||||
|
"./pic/2in9/Photo_2_1.bmp", "./pic/2in9/Photo_2_2.bmp", "./pic/2in9/Photo_2_3.bmp", "./pic/2in9/Photo_2_4.bmp",
|
||||||
|
"./pic/2in9/Photo_2_5.bmp", "./pic/2in9/Photo_2_6.bmp", "./pic/2in9/Photo_2_7.bmp", "./pic/2in9/Photo_2_8.bmp",
|
||||||
|
"./pic/2in9/Photo_2_9.bmp",
|
||||||
|
};
|
||||||
|
char *PagePath_2in9[4] = {"./pic/2in9/Menu.bmp", "./pic/2in9/White_board.bmp", "./pic/2in9/Photo_1.bmp", "./pic/2in9/Photo_2.bmp"};
|
||||||
|
|
||||||
|
|
||||||
|
void Handler_2in9(int signo)
|
||||||
|
{
|
||||||
|
//System Exit
|
||||||
|
printf("\r\nHandler_2in9:exit\r\n");
|
||||||
|
EPD_2IN9_V2_Sleep();
|
||||||
|
DEV_Delay_ms(1000);
|
||||||
|
flag_2in9 = 0;
|
||||||
|
pthread_join(t1, NULL);
|
||||||
|
pthread_join(t2, NULL);
|
||||||
|
DEV_ModuleExit();
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *pthread_irq_2in9(void *arg)
|
||||||
|
{
|
||||||
|
while(flag_2in9) {
|
||||||
|
if(DEV_Digital_Read(INT) == 0) {
|
||||||
|
ICNT86_Dev_Now.Touch = 1;
|
||||||
|
// printf("!");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ICNT86_Dev_Now.Touch = 0;
|
||||||
|
}
|
||||||
|
DEV_Delay_ms(0.01);
|
||||||
|
}
|
||||||
|
printf("thread1:exit\r\n");
|
||||||
|
pthread_exit(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *pthread_dis_2in9(void *arg)
|
||||||
|
{
|
||||||
|
while(flag_2in9) {
|
||||||
|
if(dis_flag) {
|
||||||
|
dis_lock = 1;
|
||||||
|
EPD_2IN9_V2_Display_Partial(BlackImage_ASYNC);
|
||||||
|
dis_flag = 0;
|
||||||
|
dis_lock = 0;
|
||||||
|
printf("ASYNC display over, unlock \r\n");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
dis_lock = 0;
|
||||||
|
}
|
||||||
|
// DEV_Delay_ms(0.01);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("thread2:exit\r\n");
|
||||||
|
pthread_exit(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Show_Photo_Small_2in9(UBYTE small)
|
||||||
|
{
|
||||||
|
for(UBYTE t=1; t<7; t++) {
|
||||||
|
// printf("t= %d , small= %d \r\n", t, small);
|
||||||
|
if(small*3+t > 9) // Max image is 9
|
||||||
|
GUI_ReadBmp(PhotoPath_S_2in9[0], (t-1)%3*98+2, (t-1)/3*48+2);
|
||||||
|
else {
|
||||||
|
// printf("x is %d, y is %d \r\n", (t-1)%3*98, (t-1)/3*48);
|
||||||
|
GUI_ReadBmp(PhotoPath_S_2in9[small*3+t], (t-1)%3*98+2, (t-1)/3*48+2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Show_Photo_Large_2in9(UBYTE large)
|
||||||
|
{
|
||||||
|
if(large > 9) // Max image is 9
|
||||||
|
GUI_ReadBmp(PhotoPath_L_2in9[0], 2, 2);
|
||||||
|
else
|
||||||
|
GUI_ReadBmp(PhotoPath_L_2in9[large], 2, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Get_Current_Time(PAINT_TIME *pTime)
|
||||||
|
{
|
||||||
|
time_t t;
|
||||||
|
struct tm *nowtime;
|
||||||
|
|
||||||
|
time(&t);
|
||||||
|
nowtime = localtime(&t);
|
||||||
|
|
||||||
|
pTime->Year = nowtime->tm_year + 1900;
|
||||||
|
pTime->Month = nowtime->tm_mon + 1;
|
||||||
|
pTime->Day = nowtime->tm_mday;
|
||||||
|
pTime->Hour = nowtime->tm_hour;
|
||||||
|
pTime->Min = nowtime->tm_min;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int Test4gray_2in9(void)
|
||||||
|
{
|
||||||
|
EPD_2IN9_V2_Gray4_Init();
|
||||||
|
UWORD 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;
|
||||||
|
}
|
||||||
|
Paint_NewImage(BlackImage, EPD_2IN9_V2_WIDTH, EPD_2IN9_V2_HEIGHT, 0, WHITE);
|
||||||
|
Paint_SetScale(4);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
GUI_ReadBmp_4Gray("./pic/2in9/2in9_Scale.bmp", 0, 0);
|
||||||
|
EPD_2IN9_V2_4GrayDisplay(BlackImage);
|
||||||
|
DEV_Delay_ms(3000);
|
||||||
|
free(BlackImage);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int TestCode_2in9(void)
|
||||||
|
{
|
||||||
|
IIC_Address = 0x48;
|
||||||
|
|
||||||
|
UDOUBLE i=0, j=0, k=0;
|
||||||
|
UBYTE Page=0, Photo_L=0, Photo_S=0;
|
||||||
|
UBYTE ReFlag=0, SelfFlag=0;
|
||||||
|
signal(SIGINT, Handler_2in9);
|
||||||
|
DEV_ModuleInit();
|
||||||
|
|
||||||
|
pthread_create(&t1, NULL, pthread_irq_2in9, NULL);
|
||||||
|
|
||||||
|
/*
|
||||||
|
Because the touch display requires a relatively fast refresh speed, the default
|
||||||
|
needs to use partial refresh, and four gray levels cannot be used in this mode.
|
||||||
|
Here, only four gray level picture refresh demonstration is used
|
||||||
|
*/
|
||||||
|
// Test4gray_2in9();
|
||||||
|
|
||||||
|
EPD_2IN9_V2_Init();
|
||||||
|
|
||||||
|
EPD_2IN9_V2_Clear();
|
||||||
|
|
||||||
|
ICNT_Init();
|
||||||
|
DEV_Delay_ms(100);
|
||||||
|
//Create a new image cache
|
||||||
|
UWORD Imagesize = ((EPD_2IN9_V2_WIDTH % 8 == 0)? (EPD_2IN9_V2_WIDTH / 8 ): (EPD_2IN9_V2_WIDTH / 8 + 1)) * EPD_2IN9_V2_HEIGHT;
|
||||||
|
if((BlackImage = (UBYTE *)malloc(Imagesize)) == NULL) {
|
||||||
|
printf("Failed to apply for black memory...\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if((BlackImage_ASYNC = (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_SelectImage(BlackImage);
|
||||||
|
Paint_Clear(WHITE);
|
||||||
|
GUI_ReadBmp("./pic/2in9/Menu.bmp", 0, 0);
|
||||||
|
|
||||||
|
PAINT_TIME sPaint_time, sPaint_time_f;
|
||||||
|
Get_Current_Time(&sPaint_time);
|
||||||
|
Get_Current_Time(&sPaint_time_f);
|
||||||
|
Paint_DrawTime(210, 45, &sPaint_time, &Font24, WHITE, WHITE);
|
||||||
|
Paint_DrawDate(212, 80, &sPaint_time, &Font12, WHITE, WHITE);
|
||||||
|
|
||||||
|
EPD_2IN9_V2_Display_Base(BlackImage);
|
||||||
|
memcpy(BlackImage_ASYNC, BlackImage, Imagesize);
|
||||||
|
pthread_create(&t2, NULL, pthread_dis_2in9, NULL);
|
||||||
|
while(1) {
|
||||||
|
// k++;
|
||||||
|
if(i > 30 || ReFlag == 1) {
|
||||||
|
if(Page == 0) {
|
||||||
|
Get_Current_Time(&sPaint_time);
|
||||||
|
Paint_ClearWindows(210, 40, 290, 100, BLACK);
|
||||||
|
Paint_DrawTime(212, 45, &sPaint_time, &Font24, WHITE, WHITE);
|
||||||
|
Paint_DrawDate(212, 80, &sPaint_time, &Font12, WHITE, WHITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Page == 1 && SelfFlag != 1 && dis_lock != 1) {
|
||||||
|
memcpy(BlackImage_ASYNC, BlackImage, Imagesize);
|
||||||
|
dis_flag = 1;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
k = 0;
|
||||||
|
j++;
|
||||||
|
ReFlag = 0;
|
||||||
|
printf("*** Draw Refresh ***\r\n");
|
||||||
|
}
|
||||||
|
else if(!dis_lock){
|
||||||
|
EPD_2IN9_V2_Display_Partial_Wait(BlackImage);
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
k = 0;
|
||||||
|
j++;
|
||||||
|
ReFlag = 0;
|
||||||
|
printf("*** Touch Refresh ***\r\n");
|
||||||
|
}
|
||||||
|
}else if(k++>50000000 && i>0 && Page == 1) {
|
||||||
|
EPD_2IN9_V2_Display_Partial(BlackImage);
|
||||||
|
i = 0;
|
||||||
|
k = 0;
|
||||||
|
j++;
|
||||||
|
printf("*** Overtime Refresh ***\r\n");
|
||||||
|
}else if(j > 100 || SelfFlag) {
|
||||||
|
SelfFlag = 0;
|
||||||
|
j = 0;
|
||||||
|
EPD_2IN9_V2_Init();
|
||||||
|
EPD_2IN9_V2_Display_Base(BlackImage);
|
||||||
|
printf("--- Self Refresh ---\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Page == 0 && ReFlag == 0) { //main menu
|
||||||
|
Get_Current_Time(&sPaint_time_f);
|
||||||
|
if(sPaint_time_f.Min != sPaint_time.Min) {
|
||||||
|
ReFlag = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(ICNT_Scan()==1 || (ICNT86_Dev_Now.X[0] == ICNT86_Dev_Old.X[0] && ICNT86_Dev_Now.Y[0] == ICNT86_Dev_Old.Y[0])) { // No new touch
|
||||||
|
// printf("%d %d \r\n", j, SelfFlag);
|
||||||
|
// printf("No new touch \r\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(ICNT86_Dev_Now.TouchCount) {
|
||||||
|
i++;
|
||||||
|
if(Page == 0 && ReFlag == 0) { //main menu
|
||||||
|
if(ICNT86_Dev_Now.X[0] > 119 && ICNT86_Dev_Now.X[0] < 152 && ICNT86_Dev_Now.Y[0] > 31 && ICNT86_Dev_Now.Y[0] < 96) {
|
||||||
|
printf("Photo ...\r\n");
|
||||||
|
Page = 2;
|
||||||
|
GUI_ReadBmp(PagePath_2in9[Page], 0, 0);
|
||||||
|
Show_Photo_Small_2in9(Photo_S);
|
||||||
|
ReFlag = 1;
|
||||||
|
}
|
||||||
|
else if(ICNT86_Dev_Now.X[0] > 39 && ICNT86_Dev_Now.X[0] < 80 && ICNT86_Dev_Now.Y[0] > 31 && ICNT86_Dev_Now.Y[0] < 96) {
|
||||||
|
printf("Draw ...\r\n");
|
||||||
|
Page = 1;
|
||||||
|
GUI_ReadBmp(PagePath_2in9[Page], 0, 0);
|
||||||
|
ReFlag = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Page == 1 && ReFlag == 0) { //white board
|
||||||
|
// Paint_DrawPoint(ICNT86_Dev_Now.X[0], ICNT86_Dev_Now.Y[0], BLACK, ICNT86_Dev_Now.P[0]/8+1, DOT_STYLE_DFT);
|
||||||
|
Paint_DrawPoint(ICNT86_Dev_Now.X[0], ICNT86_Dev_Now.Y[0], BLACK, 3, DOT_STYLE_DFT);
|
||||||
|
|
||||||
|
if(ICNT86_Dev_Now.X[0] > 136 && ICNT86_Dev_Now.X[0] < 159 && ICNT86_Dev_Now.Y[0] > 101 && ICNT86_Dev_Now.Y[0] < 124) {
|
||||||
|
printf("Home ...\r\n");
|
||||||
|
Page = 0;
|
||||||
|
GUI_ReadBmp(PagePath_2in9[Page], 0, 0);
|
||||||
|
ReFlag = 1;
|
||||||
|
}
|
||||||
|
else if(ICNT86_Dev_Now.X[0] > 266 && ICNT86_Dev_Now.X[0] < 289 && ICNT86_Dev_Now.Y[0] > 101 && ICNT86_Dev_Now.Y[0] < 124) {
|
||||||
|
printf("Clear ...\r\n");
|
||||||
|
Page = 1;
|
||||||
|
GUI_ReadBmp(PagePath_2in9[Page], 0, 0);
|
||||||
|
ReFlag = 1;
|
||||||
|
}
|
||||||
|
else if(ICNT86_Dev_Now.X[0] > 5 && ICNT86_Dev_Now.X[0] < 27 && ICNT86_Dev_Now.Y[0] > 101 && ICNT86_Dev_Now.Y[0] < 124) {
|
||||||
|
printf("Refresh ...\r\n");
|
||||||
|
SelfFlag = 1;
|
||||||
|
ReFlag = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Page == 2 && ReFlag == 0) { //photo menu
|
||||||
|
if(ICNT86_Dev_Now.X[0] > 135 && ICNT86_Dev_Now.X[0] < 160 && ICNT86_Dev_Now.Y[0] > 101 && ICNT86_Dev_Now.Y[0] < 124) {
|
||||||
|
printf("Home ...\r\n");
|
||||||
|
Page = 0;
|
||||||
|
GUI_ReadBmp(PagePath_2in9[Page], 0, 0);
|
||||||
|
ReFlag = 1;
|
||||||
|
}
|
||||||
|
else if(ICNT86_Dev_Now.X[0] > 203 && ICNT86_Dev_Now.X[0] < 224 && ICNT86_Dev_Now.Y[0] > 101 && ICNT86_Dev_Now.Y[0] < 124) {
|
||||||
|
printf("Next page ...\r\n");
|
||||||
|
Photo_S++;
|
||||||
|
if(Photo_S > 2) // 9 photos is a maximum of three pages
|
||||||
|
Photo_S=0;
|
||||||
|
ReFlag = 2;
|
||||||
|
}
|
||||||
|
else if(ICNT86_Dev_Now.X[0] > 71 && ICNT86_Dev_Now.X[0] < 92 && ICNT86_Dev_Now.Y[0] > 101 && ICNT86_Dev_Now.Y[0] < 124) {
|
||||||
|
printf("Last page ...\r\n");
|
||||||
|
if(Photo_S == 0)
|
||||||
|
printf("Top page ...\r\n");
|
||||||
|
else {
|
||||||
|
Photo_S--;
|
||||||
|
ReFlag = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(ICNT86_Dev_Now.X[0] > 5 && ICNT86_Dev_Now.X[0] < 27 && ICNT86_Dev_Now.Y[0] > 101 && ICNT86_Dev_Now.Y[0] < 124) {
|
||||||
|
printf("Refresh ...\r\n");
|
||||||
|
SelfFlag = 1;
|
||||||
|
ReFlag = 1;
|
||||||
|
}
|
||||||
|
else if(ICNT86_Dev_Now.X[0] > 2 && ICNT86_Dev_Now.X[0] < 293 && ICNT86_Dev_Now.Y[0] > 2 && ICNT86_Dev_Now.Y[0] < 96 && ReFlag == 0) {
|
||||||
|
printf("Select photo ...\r\n");
|
||||||
|
Page = 3;
|
||||||
|
GUI_ReadBmp(PagePath_2in9[Page], 0, 0);
|
||||||
|
Photo_L = ICNT86_Dev_Now.X[0]/96 + ICNT86_Dev_Now.Y[0]/48*3 + Photo_S*3 + 1;
|
||||||
|
Show_Photo_Large_2in9(Photo_L);
|
||||||
|
ReFlag = 1;
|
||||||
|
}
|
||||||
|
if(ReFlag == 2) { // Refresh small photo
|
||||||
|
ReFlag = 1;
|
||||||
|
GUI_ReadBmp(PagePath_2in9[Page], 0, 0);
|
||||||
|
Show_Photo_Small_2in9(Photo_S); // show small photo
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Page == 3 && ReFlag == 0) { //view the photo
|
||||||
|
if(ICNT86_Dev_Now.X[0] > 268 && ICNT86_Dev_Now.X[0] < 289 && ICNT86_Dev_Now.Y[0] > 101 && ICNT86_Dev_Now.Y[0] < 124) {
|
||||||
|
printf("Photo menu ...\r\n");
|
||||||
|
Page = 2;
|
||||||
|
GUI_ReadBmp(PagePath_2in9[Page], 0, 0);
|
||||||
|
Show_Photo_Small_2in9(Photo_S);
|
||||||
|
ReFlag = 1;
|
||||||
|
}
|
||||||
|
else if(ICNT86_Dev_Now.X[0] > 203 && ICNT86_Dev_Now.X[0] < 224 && ICNT86_Dev_Now.Y[0] > 101 && ICNT86_Dev_Now.Y[0] < 124) {
|
||||||
|
printf("Next photo ...\r\n");
|
||||||
|
Photo_L++;
|
||||||
|
if(Photo_L > 9)
|
||||||
|
Photo_L=1;
|
||||||
|
ReFlag = 2;
|
||||||
|
}
|
||||||
|
else if(ICNT86_Dev_Now.X[0] > 135 && ICNT86_Dev_Now.X[0] < 160 && ICNT86_Dev_Now.Y[0] > 101 && ICNT86_Dev_Now.Y[0] < 124) {
|
||||||
|
printf("Home ...\r\n");
|
||||||
|
Page = 0;
|
||||||
|
GUI_ReadBmp(PagePath_2in9[Page], 0, 0);
|
||||||
|
ReFlag = 1;
|
||||||
|
}
|
||||||
|
else if(ICNT86_Dev_Now.X[0] > 71 && ICNT86_Dev_Now.X[0] < 92 && ICNT86_Dev_Now.Y[0] > 101 && ICNT86_Dev_Now.Y[0] < 124) {
|
||||||
|
printf("Last page ...\r\n");
|
||||||
|
if(Photo_L == 1)
|
||||||
|
printf("Top photo ...\r\n");
|
||||||
|
else {
|
||||||
|
Photo_L--;
|
||||||
|
ReFlag = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(ICNT86_Dev_Now.X[0] > 5 && ICNT86_Dev_Now.X[0] < 27 && ICNT86_Dev_Now.Y[0] > 101 && ICNT86_Dev_Now.Y[0] < 124) {
|
||||||
|
printf("Refresh photo ...\r\n");
|
||||||
|
SelfFlag = 1;
|
||||||
|
ReFlag = 1;
|
||||||
|
}
|
||||||
|
if(ReFlag == 2) { // Refresh large photo
|
||||||
|
ReFlag = 1;
|
||||||
|
Show_Photo_Large_2in9(Photo_L);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
#ifndef _MAIN_H_
|
||||||
|
#define _MAIN_H_
|
||||||
|
|
||||||
|
#include <stdlib.h> //exit()
|
||||||
|
#include <signal.h> //signal()
|
||||||
|
#include <pthread.h> //pthread_create()
|
||||||
|
#include "GUI_Paint.h"
|
||||||
|
#include "GUI_BMPfile.h"
|
||||||
|
|
||||||
|
int TestCode_2in13(void);
|
||||||
|
int TestCode_2in13_V3(void);
|
||||||
|
int TestCode_2in13_V4(void);
|
||||||
|
int TestCode_2in9(void);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
#include "Test.h"
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
// TestCode_2in13();
|
||||||
|
// TestCode_2in13_V3();
|
||||||
|
// TestCode_2in13_V4();
|
||||||
|
TestCode_2in9();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,342 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : DEV_Config.c
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : Hardware underlying interface
|
||||||
|
* | Info :
|
||||||
|
*----------------
|
||||||
|
* | This version: V2.0
|
||||||
|
* | Date : 2020-06-17
|
||||||
|
* | Info : Basic version
|
||||||
|
*
|
||||||
|
******************************************************************************/
|
||||||
|
#include "DEV_Config.h"
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
#if USE_LGPIO_LIB
|
||||||
|
int GPIO_Handle;
|
||||||
|
int SPI_Handle;
|
||||||
|
int IIC_Handle;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GPIO
|
||||||
|
**/
|
||||||
|
int EPD_RST_PIN;
|
||||||
|
int EPD_DC_PIN;
|
||||||
|
int EPD_CS_PIN;
|
||||||
|
int EPD_BUSY_PIN;
|
||||||
|
int IIC_Address;
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t fd;
|
||||||
|
/*****************************************
|
||||||
|
GPIO
|
||||||
|
*****************************************/
|
||||||
|
void DEV_Digital_Write(UWORD Pin, UBYTE Value)
|
||||||
|
{
|
||||||
|
#ifdef USE_BCM2835_LIB
|
||||||
|
bcm2835_gpio_write(Pin, Value);
|
||||||
|
#elif USE_WIRINGPI_LIB
|
||||||
|
digitalWrite(Pin, Value);
|
||||||
|
#elif USE_LGPIO_LIB
|
||||||
|
lgGpioWrite(GPIO_Handle, Pin, Value);
|
||||||
|
#elif USE_GPIOD_LIB
|
||||||
|
GPIOD_Write(Pin, Value);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
UBYTE DEV_Digital_Read(UWORD Pin)
|
||||||
|
{
|
||||||
|
UBYTE Read_value = 0;
|
||||||
|
#ifdef USE_BCM2835_LIB
|
||||||
|
Read_value = bcm2835_gpio_lev(Pin);
|
||||||
|
#elif USE_WIRINGPI_LIB
|
||||||
|
Read_value = digitalRead(Pin);
|
||||||
|
#elif USE_LGPIO_LIB
|
||||||
|
Read_value = lgGpioRead(GPIO_Handle,Pin);
|
||||||
|
#elif USE_GPIOD_LIB
|
||||||
|
Read_value = GPIOD_Read(Pin);
|
||||||
|
#endif
|
||||||
|
return Read_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DEV_GPIO_Mode(UWORD Pin, UWORD Mode)
|
||||||
|
{
|
||||||
|
#ifdef USE_BCM2835_LIB
|
||||||
|
if(Mode == 0 || Mode == BCM2835_GPIO_FSEL_INPT){
|
||||||
|
bcm2835_gpio_fsel(Pin, BCM2835_GPIO_FSEL_INPT);
|
||||||
|
}else {
|
||||||
|
bcm2835_gpio_fsel(Pin, BCM2835_GPIO_FSEL_OUTP);
|
||||||
|
}
|
||||||
|
#elif USE_WIRINGPI_LIB
|
||||||
|
if(Mode == 0 || Mode == INPUT) {
|
||||||
|
pinMode(Pin, INPUT);
|
||||||
|
pullUpDnControl(Pin, PUD_UP);
|
||||||
|
} else {
|
||||||
|
pinMode(Pin, OUTPUT);
|
||||||
|
// Debug (" %d OUT \r\n",Pin);
|
||||||
|
}
|
||||||
|
#elif USE_LGPIO_LIB
|
||||||
|
if(Mode == 0 || Mode == LG_SET_INPUT){
|
||||||
|
lgGpioClaimInput(GPIO_Handle,LFLAGS,Pin);
|
||||||
|
// Debug("IN Pin = %d\r\n",Pin);
|
||||||
|
}else{
|
||||||
|
lgGpioClaimOutput(GPIO_Handle, LFLAGS, Pin, LG_LOW);
|
||||||
|
// Debug("OUT Pin = %d\r\n",Pin);
|
||||||
|
}
|
||||||
|
#elif USE_GPIOD_LIB
|
||||||
|
if(Mode == 0 || Mode == GPIOD_IN){
|
||||||
|
GPIOD_Direction(Pin, GPIOD_IN);
|
||||||
|
// Debug("IN Pin = %d\r\n",Pin);
|
||||||
|
}else{
|
||||||
|
GPIOD_Direction(Pin, GPIOD_OUT);
|
||||||
|
// Debug("OUT Pin = %d\r\n",Pin);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* delay x ms
|
||||||
|
**/
|
||||||
|
void DEV_Delay_ms(UDOUBLE xms)
|
||||||
|
{
|
||||||
|
#ifdef USE_BCM2835_LIB
|
||||||
|
bcm2835_delay(xms);
|
||||||
|
#elif USE_WIRINGPI_LIB
|
||||||
|
delay(xms);
|
||||||
|
#elif USE_LGPIO_LIB
|
||||||
|
lguSleep(xms/1000.0);
|
||||||
|
#elif USE_GPIOD_LIB
|
||||||
|
UDOUBLE i;
|
||||||
|
for(i=0; i < xms; i++){
|
||||||
|
usleep(1000);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static void DEV_GPIO_Init(void)
|
||||||
|
{
|
||||||
|
EPD_RST_PIN = 17;
|
||||||
|
EPD_DC_PIN = 25;
|
||||||
|
EPD_CS_PIN = 8;
|
||||||
|
EPD_BUSY_PIN = 24;
|
||||||
|
|
||||||
|
DEV_GPIO_Mode(EPD_RST_PIN, 1);
|
||||||
|
DEV_GPIO_Mode(EPD_DC_PIN, 1);
|
||||||
|
DEV_GPIO_Mode(EPD_CS_PIN, 1);
|
||||||
|
DEV_GPIO_Mode(EPD_BUSY_PIN, 0);
|
||||||
|
|
||||||
|
DEV_Digital_Write(EPD_CS_PIN, 1);
|
||||||
|
|
||||||
|
DEV_GPIO_Mode(TRST, 1);
|
||||||
|
DEV_GPIO_Mode(INT, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function: Module Initialize, the library and initialize the pins, SPI protocol
|
||||||
|
parameter:
|
||||||
|
Info:
|
||||||
|
******************************************************************************/
|
||||||
|
UBYTE DEV_ModuleInit(void)
|
||||||
|
{
|
||||||
|
#ifdef USE_BCM2835_LIB
|
||||||
|
if(!bcm2835_init()) {
|
||||||
|
printf("bcm2835 init failed !!! \r\n");
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
printf("bcm2835 init success !!! \r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
DEV_GPIO_Init();
|
||||||
|
|
||||||
|
bcm2835_i2c_begin();
|
||||||
|
bcm2835_i2c_setSlaveAddress(IIC_Address);
|
||||||
|
// bcm2835_i2c_setClockDivider(BCM2835_I2C_CLOCK_DIVIDER_2500);
|
||||||
|
|
||||||
|
bcm2835_spi_begin(); //Start spi interface, set spi pin for the reuse function
|
||||||
|
bcm2835_spi_setBitOrder(BCM2835_SPI_BIT_ORDER_MSBFIRST); //High first transmission
|
||||||
|
bcm2835_spi_setDataMode(BCM2835_SPI_MODE0); //spi mode 0
|
||||||
|
bcm2835_spi_setClockDivider(BCM2835_SPI_CLOCK_DIVIDER_32); //Frequency
|
||||||
|
bcm2835_spi_chipSelect(BCM2835_SPI_CS0); //set CE0
|
||||||
|
bcm2835_spi_setChipSelectPolarity(BCM2835_SPI_CS0, LOW); //enable cs0
|
||||||
|
#elif USE_WIRINGPI_LIB
|
||||||
|
// if(wiringPiSetup() < 0) {//use wiringpi Pin number table
|
||||||
|
if(wiringPiSetupGpio() < 0) { //use BCM2835 Pin number table
|
||||||
|
printf("set wiringPi lib failed !!! \r\n");
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
printf("set wiringPi lib success !!! \r\n");
|
||||||
|
}
|
||||||
|
// GPIO Config
|
||||||
|
DEV_GPIO_Init();
|
||||||
|
|
||||||
|
// wiringPiSPISetup(0,10000000);
|
||||||
|
wiringPiSPISetupMode(0, 10000000, 0);
|
||||||
|
fd = wiringPiI2CSetup(IIC_Address);
|
||||||
|
|
||||||
|
DEV_HARDWARE_I2C_begin("/dev/i2c-1");
|
||||||
|
DEV_HARDWARE_I2C_setSlaveAddress(IIC_Address);
|
||||||
|
#elif USE_LGPIO_LIB
|
||||||
|
char buffer[NUM_MAXBUF];
|
||||||
|
FILE *fp;
|
||||||
|
|
||||||
|
fp = popen("cat /proc/cpuinfo | grep 'Raspberry Pi 5'", "r");
|
||||||
|
if (fp == NULL) {
|
||||||
|
Debug("It is not possible to determine the model of the Raspberry PI\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(fgets(buffer, sizeof(buffer), fp) != NULL)
|
||||||
|
{
|
||||||
|
GPIO_Handle = lgGpiochipOpen(4);
|
||||||
|
if (GPIO_Handle < 0)
|
||||||
|
{
|
||||||
|
Debug( "gpiochip4 Export Failed\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GPIO_Handle = lgGpiochipOpen(0);
|
||||||
|
if (GPIO_Handle < 0)
|
||||||
|
{
|
||||||
|
Debug( "gpiochip0 Export Failed\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SPI_Handle = lgSpiOpen(0, 0, 10000000, 0);
|
||||||
|
IIC_Handle = lgI2cOpen(1,IIC_Address,0);
|
||||||
|
DEV_GPIO_Init();
|
||||||
|
#elif USE_GPIOD_LIB
|
||||||
|
GPIOD_Export();
|
||||||
|
DEV_GPIO_Init();
|
||||||
|
|
||||||
|
DEV_HARDWARE_I2C_begin("/dev/i2c-1");
|
||||||
|
DEV_HARDWARE_I2C_setSlaveAddress(IIC_Address);
|
||||||
|
|
||||||
|
DEV_HARDWARE_SPI_begin("/dev/spidev0.0");
|
||||||
|
DEV_HARDWARE_SPI_setSpeed(10000000);
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SPI
|
||||||
|
**/
|
||||||
|
void DEV_SPI_WriteByte(uint8_t Value)
|
||||||
|
{
|
||||||
|
#ifdef USE_BCM2835_LIB
|
||||||
|
bcm2835_spi_transfer(Value);
|
||||||
|
#elif USE_WIRINGPI_LIB
|
||||||
|
wiringPiSPIDataRW(0, &Value, 1);
|
||||||
|
#elif USE_LGPIO_LIB
|
||||||
|
lgSpiWrite(SPI_Handle,(char*)&Value, 1);
|
||||||
|
#elif USE_GPIOD_LIB
|
||||||
|
DEV_HARDWARE_SPI_TransferByte(Value);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void DEV_SPI_Write_nByte(uint8_t *pData, uint32_t Len)
|
||||||
|
{
|
||||||
|
#ifdef USE_BCM2835_LIB
|
||||||
|
char rData[Len];
|
||||||
|
bcm2835_spi_transfernb(pData, rData, Len);
|
||||||
|
#elif USE_WIRINGPI_LIB
|
||||||
|
wiringPiSPIDataRW(0, pData, Len);
|
||||||
|
#elif USE_LGPIO_LIB
|
||||||
|
lgSpiWrite(SPI_Handle,(char*)pData, Len);
|
||||||
|
#elif USE_GPIOD_LIB
|
||||||
|
DEV_HARDWARE_SPI_Transfer(pData, Len);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
UBYTE I2C_Write_Byte(UWORD Reg, char *Data, UBYTE len)
|
||||||
|
{
|
||||||
|
char wbuf[50]={(Reg>>8)&0xff, Reg&0xff};
|
||||||
|
for(UBYTE i=0; i<len; i++) {
|
||||||
|
wbuf[i+2] = Data[i];
|
||||||
|
}
|
||||||
|
#ifdef USE_BCM2835_LIB
|
||||||
|
if(bcm2835_i2c_write(wbuf, len+2) != BCM2835_I2C_REASON_OK) {
|
||||||
|
printf("WRITE ERROR \r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
#elif USE_WIRINGPI_LIB
|
||||||
|
if(len > 1)
|
||||||
|
printf("wiringPi I2C WARING \r\n");
|
||||||
|
wiringPiI2CWriteReg16(fd, wbuf[0], wbuf[1] | (wbuf[2]<<8));
|
||||||
|
#elif USE_LGPIO_LIB
|
||||||
|
lgI2cWriteDevice(IIC_Handle, wbuf, len+2);
|
||||||
|
#elif USE_GPIOD_LIB
|
||||||
|
DEV_HARDWARE_I2C_write(wbuf, len+2);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef USE_WIRINGPI_LIB
|
||||||
|
static I2C_Write_WiringPi(UWORD Reg)
|
||||||
|
{
|
||||||
|
wiringPiI2CWriteReg8(fd, (Reg>>8) & 0xff, Reg & 0xff);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
UBYTE I2C_Read_Byte(UWORD Reg, char *Data, UBYTE len)
|
||||||
|
{
|
||||||
|
char *rbuf = Data;
|
||||||
|
|
||||||
|
#ifdef USE_BCM2835_LIB
|
||||||
|
I2C_Write_Byte(Reg, 0, 0);
|
||||||
|
if(bcm2835_i2c_read(rbuf, len) != BCM2835_I2C_REASON_OK) {
|
||||||
|
printf("READ ERROR \r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
#elif USE_WIRINGPI_LIB
|
||||||
|
I2C_Write_WiringPi(Reg);
|
||||||
|
for(UBYTE i=0; i<len; i++) {
|
||||||
|
rbuf[i] = wiringPiI2CRead(fd);
|
||||||
|
}
|
||||||
|
#elif USE_LGPIO_LIB
|
||||||
|
I2C_Write_Byte(Reg, 0, 0);
|
||||||
|
lgI2cReadDevice(IIC_Handle, rbuf, len);
|
||||||
|
#elif USE_GPIOD_LIB
|
||||||
|
I2C_Write_Byte(Reg, 0, 0);
|
||||||
|
DEV_HARDWARE_I2C_read(rbuf, len);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function: Module exits, closes SPI and BCM2835 library
|
||||||
|
parameter:
|
||||||
|
Info:
|
||||||
|
******************************************************************************/
|
||||||
|
void DEV_ModuleExit(void)
|
||||||
|
{
|
||||||
|
TRST_0;
|
||||||
|
DEV_Digital_Write(EPD_CS_PIN, 0);
|
||||||
|
DEV_Digital_Write(EPD_DC_PIN, 0);
|
||||||
|
DEV_Digital_Write(EPD_RST_PIN, 0);
|
||||||
|
#ifdef USE_BCM2835_LIB
|
||||||
|
bcm2835_i2c_end();
|
||||||
|
bcm2835_spi_end();
|
||||||
|
bcm2835_close();
|
||||||
|
#elif USE_WIRINGPI_LIB
|
||||||
|
|
||||||
|
#elif USE_LGPIO_LIB
|
||||||
|
lgI2cClose(IIC_Handle);
|
||||||
|
lgSpiClose(SPI_Handle);
|
||||||
|
lgGpiochipClose(GPIO_Handle);
|
||||||
|
#elif USE_GPIOD_LIB
|
||||||
|
DEV_HARDWARE_I2C_end();
|
||||||
|
DEV_HARDWARE_SPI_end();
|
||||||
|
GPIOD_Unexport(EPD_CS_PIN);
|
||||||
|
GPIOD_Unexport(EPD_DC_PIN);
|
||||||
|
GPIOD_Unexport(EPD_RST_PIN);
|
||||||
|
GPIOD_Unexport(EPD_BUSY_PIN);
|
||||||
|
GPIOD_Unexport_GPIO();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
#ifndef _DEV_CONFIG_H_
|
||||||
|
#define _DEV_CONFIG_H_
|
||||||
|
/***********************************************************************************************************************
|
||||||
|
------------------------------------------------------------------------
|
||||||
|
|\\\ ///|
|
||||||
|
|\\\ Hardware interface ///|
|
||||||
|
------------------------------------------------------------------------
|
||||||
|
***********************************************************************************************************************/
|
||||||
|
#ifdef USE_BCM2835_LIB
|
||||||
|
#include <bcm2835.h>
|
||||||
|
#elif USE_WIRINGPI_LIB
|
||||||
|
#include <wiringPi.h>
|
||||||
|
#include <wiringPiSPI.h>
|
||||||
|
#include <wiringPiI2C.h>
|
||||||
|
#include "dev_hardware_i2c.h"
|
||||||
|
#elif USE_LGPIO_LIB
|
||||||
|
#include <lgpio.h>
|
||||||
|
#define LFLAGS 0
|
||||||
|
#define NUM_MAXBUF 4
|
||||||
|
#elif USE_GPIOD_LIB
|
||||||
|
#include "RPI_gpiod.h"
|
||||||
|
#include "dev_hardware_i2c.h"
|
||||||
|
#include "dev_hardware_SPI.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include "Debug.h"
|
||||||
|
|
||||||
|
// #define IIC_Address 0x14
|
||||||
|
// #define IIC_Address_Read 0x29
|
||||||
|
// #define IIC_Address_Write 0x28
|
||||||
|
|
||||||
|
/**
|
||||||
|
* data
|
||||||
|
**/
|
||||||
|
#define UBYTE uint8_t
|
||||||
|
#define UWORD uint16_t
|
||||||
|
#define UDOUBLE uint32_t
|
||||||
|
|
||||||
|
//TP Define
|
||||||
|
#define TRST 22
|
||||||
|
#define INT 27
|
||||||
|
|
||||||
|
#define TRST_0 DEV_Digital_Write(TRST, 0)
|
||||||
|
#define TRST_1 DEV_Digital_Write(TRST, 1)
|
||||||
|
|
||||||
|
#define INT_0 DEV_Digital_Write(INT, 0)
|
||||||
|
#define INT_1 DEV_Digital_Write(INT, 1)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GPIOI config
|
||||||
|
**/
|
||||||
|
extern int EPD_RST_PIN;
|
||||||
|
extern int EPD_DC_PIN;
|
||||||
|
extern int EPD_CS_PIN;
|
||||||
|
extern int EPD_BUSY_PIN;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
UBYTE DEV_ModuleInit(void);
|
||||||
|
void DEV_ModuleExit(void);
|
||||||
|
|
||||||
|
void DEV_GPIO_Mode(UWORD Pin, UWORD Mode);
|
||||||
|
void DEV_Delay_ms(UDOUBLE xms);
|
||||||
|
|
||||||
|
void DEV_Digital_Write(UWORD Pin, UBYTE Value);
|
||||||
|
UBYTE DEV_Digital_Read(UWORD Pin);
|
||||||
|
|
||||||
|
void DEV_SPI_WriteByte(UBYTE Value);
|
||||||
|
void DEV_SPI_Write_nByte(uint8_t *pData, uint32_t Len);
|
||||||
|
|
||||||
|
UBYTE I2C_Write_Byte(UWORD Reg, char *Data, UBYTE len);
|
||||||
|
UBYTE I2C_Read_Byte(UWORD Reg, char *Data, UBYTE len);
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : Debug.h
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : debug with printf
|
||||||
|
* | Info :
|
||||||
|
* Image scanning
|
||||||
|
* Please use progressive scanning to generate images or fonts
|
||||||
|
*----------------
|
||||||
|
* | This version: V2.0
|
||||||
|
* | Date : 2020-06-17
|
||||||
|
* | Info :
|
||||||
|
* 1.USE_DEBUG -> DEBUG, If you need to see the debug information,
|
||||||
|
* clear the execution: make DEBUG=-DDEBUG
|
||||||
|
#
|
||||||
|
# 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 __DEBUG_H
|
||||||
|
#define __DEBUG_H
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
#define Debug(__info,...) printf("Debug: " __info,##__VA_ARGS__)
|
||||||
|
#else
|
||||||
|
#define Debug(__info,...)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
@@ -0,0 +1,170 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : RPI_GPIOD.c
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : Drive GPIO
|
||||||
|
* | Info : Read and write gpio
|
||||||
|
*----------------
|
||||||
|
* | This version: V1.0
|
||||||
|
* | Date : 2023-11-15
|
||||||
|
* | Info : Basic version
|
||||||
|
*
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documnetation files (the "Software"), to deal
|
||||||
|
# GPIOD_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 folGPIOD_LOWing conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included GPIOD_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. GPIOD_IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY WHETHER GPIOD_IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# GPIOD_OUT OF OR GPIOD_IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS GPIOD_IN
|
||||||
|
# THE SOFTWARE.
|
||||||
|
#
|
||||||
|
******************************************************************************/
|
||||||
|
#include "RPI_gpiod.h"
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <gpiod.h>
|
||||||
|
|
||||||
|
struct gpiod_chip *gpiochip;
|
||||||
|
struct gpiod_line *gpioline;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
int GPIOD_Export()
|
||||||
|
{
|
||||||
|
char buffer[NUM_MAXBUF];
|
||||||
|
FILE *fp;
|
||||||
|
|
||||||
|
fp = popen("cat /proc/cpuinfo | grep 'Raspberry Pi 5'", "r");
|
||||||
|
if (fp == NULL) {
|
||||||
|
GPIOD_Debug("It is not possible to determine the model of the Raspberry PI\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(fgets(buffer, sizeof(buffer), fp) != NULL)
|
||||||
|
{
|
||||||
|
gpiochip = gpiod_chip_open("/dev/gpiochip4");
|
||||||
|
if (gpiochip == NULL)
|
||||||
|
{
|
||||||
|
GPIOD_Debug( "gpiochip4 Export Failed\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gpiochip = gpiod_chip_open("/dev/gpiochip0");
|
||||||
|
if (gpiochip == NULL)
|
||||||
|
{
|
||||||
|
GPIOD_Debug( "gpiochip0 Export Failed\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int GPIOD_Unexport(int Pin)
|
||||||
|
{
|
||||||
|
gpioline = gpiod_chip_get_line(gpiochip, Pin);
|
||||||
|
if (gpioline == NULL)
|
||||||
|
{
|
||||||
|
GPIOD_Debug( "Export Failed: Pin%d\n", Pin);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
gpiod_line_release(gpioline);
|
||||||
|
|
||||||
|
GPIOD_Debug( "Unexport: Pin%d\r\n", Pin);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int GPIOD_Unexport_GPIO(void)
|
||||||
|
{
|
||||||
|
gpiod_line_release(gpioline);
|
||||||
|
gpiod_chip_close(gpiochip);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int GPIOD_Direction(int Pin, int Dir)
|
||||||
|
{
|
||||||
|
gpioline = gpiod_chip_get_line(gpiochip, Pin);
|
||||||
|
if (gpioline == NULL)
|
||||||
|
{
|
||||||
|
GPIOD_Debug( "Export Failed: Pin%d\n", Pin);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Dir == GPIOD_IN)
|
||||||
|
{
|
||||||
|
ret = gpiod_line_request_input(gpioline, "gpio");
|
||||||
|
if (ret != 0)
|
||||||
|
{
|
||||||
|
GPIOD_Debug( "Export Failed: Pin%d\n", Pin);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
GPIOD_Debug("Pin%d:intput\r\n", Pin);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ret = gpiod_line_request_output(gpioline, "gpio", 0);
|
||||||
|
if (ret != 0)
|
||||||
|
{
|
||||||
|
GPIOD_Debug( "Export Failed: Pin%d\n", Pin);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
GPIOD_Debug("Pin%d:Output\r\n", Pin);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int GPIOD_Read(int Pin)
|
||||||
|
{
|
||||||
|
gpioline = gpiod_chip_get_line(gpiochip, Pin);
|
||||||
|
if (gpioline == NULL)
|
||||||
|
{
|
||||||
|
GPIOD_Debug( "Export Failed: Pin%d\n", Pin);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = gpiod_line_get_value(gpioline);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
GPIOD_Debug( "failed to read value!\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return(ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
int GPIOD_Write(int Pin, int value)
|
||||||
|
{
|
||||||
|
gpioline = gpiod_chip_get_line(gpiochip, Pin);
|
||||||
|
if (gpioline == NULL)
|
||||||
|
{
|
||||||
|
GPIOD_Debug( "Export Failed: Pin%d\n", Pin);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = gpiod_line_set_value(gpioline, value);
|
||||||
|
if (ret != 0)
|
||||||
|
{
|
||||||
|
GPIOD_Debug( "failed to write value! : Pin%d\n", Pin);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : gpiod.h
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : Drive GPIO
|
||||||
|
* | Info : Read and write gpio
|
||||||
|
*----------------
|
||||||
|
* | This version: V1.0
|
||||||
|
* | Date : 2023-11-15
|
||||||
|
* | Info : Basic version
|
||||||
|
*d
|
||||||
|
#
|
||||||
|
# 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:
|
||||||
|
#D
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
************************D******************************************************/
|
||||||
|
#ifndef __GPIOD_
|
||||||
|
#define __GPIOD_
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <gpiod.h>
|
||||||
|
|
||||||
|
#define GPIOD_IN 0
|
||||||
|
#define GPIOD_OUT 1
|
||||||
|
|
||||||
|
#define GPIOD_LOW 0
|
||||||
|
#define GPIOD_HIGH 1
|
||||||
|
|
||||||
|
#define NUM_MAXBUF 4
|
||||||
|
#define DIR_MAXSIZ 60
|
||||||
|
|
||||||
|
#define GPIOD_DEBUG 0
|
||||||
|
#if GPIOD_DEBUG
|
||||||
|
#define GPIOD_Debug(__info,...) printf("Debug: " __info,##__VA_ARGS__)
|
||||||
|
#else
|
||||||
|
#define GPIOD_Debug(__info,...)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// BCM GPIO for Jetson nano
|
||||||
|
#define GPIO4 4 // 7, 4
|
||||||
|
#define GPIO17 7 // 11, 17
|
||||||
|
#define GPIO18 18 // 12, 18
|
||||||
|
#define GPIO27 27 // 13, 27
|
||||||
|
#define GPIO22 22 // 15, 22
|
||||||
|
#define GPIO23 23 // 16, 23
|
||||||
|
#define GPIO24 24 // 18, 24
|
||||||
|
#define SPI0_MOSI 10 // 19, 10
|
||||||
|
#define SPI0_MISO 9 // 21, 9
|
||||||
|
#define GPIO25 28 // 22, 25
|
||||||
|
#define SPI0_SCK 11 // 23, 11
|
||||||
|
#define SPI0_CS0 8 // 24, 8
|
||||||
|
#define SPI0_CS1 7 // 26, 7
|
||||||
|
#define GPIO5 5 // 29, 5
|
||||||
|
#define GPIO6 6 // 31, 6
|
||||||
|
#define GPIO12 12 // 32, 12
|
||||||
|
#define GPIO13 13 // 33, 13
|
||||||
|
#define GPIO19 19 // 35, 19
|
||||||
|
#define GPIO16 16 // 36, 16
|
||||||
|
#define GPIO26 26 // 37, 26
|
||||||
|
#define GPIO20 20 // 38, 20
|
||||||
|
#define GPIO21 21 // 40, 21
|
||||||
|
|
||||||
|
extern struct gpiod_chip *gpiochip;
|
||||||
|
extern struct gpiod_line *gpioline;
|
||||||
|
extern int ret;
|
||||||
|
|
||||||
|
int GPIOD_Export();
|
||||||
|
int GPIOD_Unexport(int Pin);
|
||||||
|
int GPIOD_Unexport_GPIO(void);
|
||||||
|
int GPIOD_Direction(int Pin, int Dir);
|
||||||
|
int GPIOD_Read(int Pin);
|
||||||
|
int GPIOD_Write(int Pin, int value);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,363 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : dev_hardware_SPI.c
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : Read and write /dev/SPI, hardware SPI
|
||||||
|
* | Info :
|
||||||
|
*----------------
|
||||||
|
* | This version: V1.0
|
||||||
|
* | Date : 2019-06-26
|
||||||
|
* | Info : Basic version
|
||||||
|
*
|
||||||
|
#
|
||||||
|
# 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 "dev_hardware_SPI.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <getopt.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <linux/types.h>
|
||||||
|
#include <linux/spi/spidev.h>
|
||||||
|
|
||||||
|
HARDWARE_SPI hardware_SPI;
|
||||||
|
|
||||||
|
static uint8_t bits = 8;
|
||||||
|
|
||||||
|
#define SPI_CS_HIGH 0x04 //Chip select high
|
||||||
|
#define SPI_LSB_FIRST 0x08 //LSB
|
||||||
|
#define SPI_3WIRE 0x10 //3-wire mode SI and SO same line
|
||||||
|
#define SPI_LOOP 0x20 //Loopback mode
|
||||||
|
#define SPI_NO_CS 0x40 //A single device occupies one SPI bus, so there is no chip select
|
||||||
|
#define SPI_READY 0x80 //Slave pull low to stop data transmission
|
||||||
|
|
||||||
|
struct spi_ioc_transfer tr;
|
||||||
|
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function: SPI port initialization
|
||||||
|
parameter:
|
||||||
|
SPI_device : Device name
|
||||||
|
Info:
|
||||||
|
/dev/spidev0.0
|
||||||
|
/dev/spidev0.1
|
||||||
|
******************************************************************************/
|
||||||
|
void DEV_HARDWARE_SPI_begin(char *SPI_device)
|
||||||
|
{
|
||||||
|
//device
|
||||||
|
int ret = 0;
|
||||||
|
if((hardware_SPI.fd = open(SPI_device, O_RDWR )) < 0) {
|
||||||
|
perror("Failed to open SPI device.\n");
|
||||||
|
DEV_HARDWARE_SPI_Debug("Failed to open SPI device\r\n");
|
||||||
|
exit(1);
|
||||||
|
} else {
|
||||||
|
DEV_HARDWARE_SPI_Debug("open : %s\r\n", SPI_device);
|
||||||
|
}
|
||||||
|
hardware_SPI.mode = 0;
|
||||||
|
|
||||||
|
ret = ioctl(hardware_SPI.fd, SPI_IOC_WR_BITS_PER_WORD, &bits);
|
||||||
|
if (ret == -1) {
|
||||||
|
DEV_HARDWARE_SPI_Debug("can't set bits per word\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = ioctl(hardware_SPI.fd, SPI_IOC_RD_BITS_PER_WORD, &bits);
|
||||||
|
if (ret == -1) {
|
||||||
|
DEV_HARDWARE_SPI_Debug("can't get bits per word\r\n");
|
||||||
|
}
|
||||||
|
tr.bits_per_word = bits;
|
||||||
|
|
||||||
|
DEV_HARDWARE_SPI_Mode(SPI_MODE_0);
|
||||||
|
DEV_HARDWARE_SPI_ChipSelect(SPI_CS_Mode_LOW);
|
||||||
|
DEV_HARDWARE_SPI_SetBitOrder(SPI_BIT_ORDER_LSBFIRST);
|
||||||
|
DEV_HARDWARE_SPI_setSpeed(20000000);
|
||||||
|
DEV_HARDWARE_SPI_SetDataInterval(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DEV_HARDWARE_SPI_beginSet(char *SPI_device, SPIMode mode, uint32_t speed)
|
||||||
|
{
|
||||||
|
//device
|
||||||
|
int ret = 0;
|
||||||
|
hardware_SPI.mode = 0;
|
||||||
|
if((hardware_SPI.fd = open(SPI_device, O_RDWR )) < 0) {
|
||||||
|
perror("Failed to open SPI device.\n");
|
||||||
|
exit(1);
|
||||||
|
} else {
|
||||||
|
DEV_HARDWARE_SPI_Debug("open : %s\r\n", SPI_device);
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = ioctl(hardware_SPI.fd, SPI_IOC_WR_BITS_PER_WORD, &bits);
|
||||||
|
if (ret == -1)
|
||||||
|
DEV_HARDWARE_SPI_Debug("can't set bits per word\r\n");
|
||||||
|
|
||||||
|
ret = ioctl(hardware_SPI.fd, SPI_IOC_RD_BITS_PER_WORD, &bits);
|
||||||
|
if (ret == -1)
|
||||||
|
DEV_HARDWARE_SPI_Debug("can't get bits per word\r\n");
|
||||||
|
|
||||||
|
DEV_HARDWARE_SPI_Mode(mode);
|
||||||
|
DEV_HARDWARE_SPI_ChipSelect(SPI_CS_Mode_LOW);
|
||||||
|
DEV_HARDWARE_SPI_setSpeed(speed);
|
||||||
|
DEV_HARDWARE_SPI_SetDataInterval(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function: SPI device End
|
||||||
|
parameter:
|
||||||
|
Info:
|
||||||
|
******************************************************************************/
|
||||||
|
void DEV_HARDWARE_SPI_end(void)
|
||||||
|
{
|
||||||
|
hardware_SPI.mode = 0;
|
||||||
|
if (close(hardware_SPI.fd) != 0){
|
||||||
|
DEV_HARDWARE_SPI_Debug("Failed to close SPI device\r\n");
|
||||||
|
perror("Failed to close SPI device.\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function: Set SPI speed
|
||||||
|
parameter:
|
||||||
|
Info: Return 1 success
|
||||||
|
Return -1 failed
|
||||||
|
******************************************************************************/
|
||||||
|
int DEV_HARDWARE_SPI_setSpeed(uint32_t speed)
|
||||||
|
{
|
||||||
|
uint32_t speed1 = hardware_SPI.speed;
|
||||||
|
|
||||||
|
hardware_SPI.speed = speed;
|
||||||
|
|
||||||
|
//Write speed
|
||||||
|
if (ioctl(hardware_SPI.fd, SPI_IOC_WR_MAX_SPEED_HZ, &speed) == -1) {
|
||||||
|
DEV_HARDWARE_SPI_Debug("can't set max speed hz\r\n");
|
||||||
|
hardware_SPI.speed = speed1;//Setting failure rate unchanged
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Read the speed of just writing
|
||||||
|
if (ioctl(hardware_SPI.fd, SPI_IOC_RD_MAX_SPEED_HZ, &speed) == -1) {
|
||||||
|
DEV_HARDWARE_SPI_Debug("can't get max speed hz\r\n");
|
||||||
|
hardware_SPI.speed = speed1;//Setting failure rate unchanged
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
hardware_SPI.speed = speed;
|
||||||
|
tr.speed_hz = hardware_SPI.speed;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function: Set SPI Mode
|
||||||
|
parameter:
|
||||||
|
Info:
|
||||||
|
SPIMode:
|
||||||
|
SPI_MODE0
|
||||||
|
SPI_MODE1
|
||||||
|
SPI_MODE2
|
||||||
|
SPI_MODE3
|
||||||
|
Return :
|
||||||
|
Return 1 success
|
||||||
|
Return -1 failed
|
||||||
|
******************************************************************************/
|
||||||
|
int DEV_HARDWARE_SPI_Mode(SPIMode mode)
|
||||||
|
{
|
||||||
|
hardware_SPI.mode &= 0xfC;//Clear low 2 digits
|
||||||
|
hardware_SPI.mode |= mode;//Setting mode
|
||||||
|
|
||||||
|
//Write device
|
||||||
|
if (ioctl(hardware_SPI.fd, SPI_IOC_WR_MODE, &hardware_SPI.mode) == -1) {
|
||||||
|
DEV_HARDWARE_SPI_Debug("can't set spi mode\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function: Set SPI CS Enable
|
||||||
|
parameter:
|
||||||
|
Info:
|
||||||
|
EN:
|
||||||
|
DISABLE
|
||||||
|
ENABLE
|
||||||
|
Return :
|
||||||
|
Return 1 success
|
||||||
|
Return -1 failed
|
||||||
|
******************************************************************************/
|
||||||
|
int DEV_HARDWARE_SPI_CSEN(SPICSEN EN)
|
||||||
|
{
|
||||||
|
if(EN == ENABLE){
|
||||||
|
hardware_SPI.mode |= SPI_NO_CS;
|
||||||
|
}else {
|
||||||
|
hardware_SPI.mode &= ~SPI_NO_CS;
|
||||||
|
}
|
||||||
|
//Write device
|
||||||
|
if (ioctl(hardware_SPI.fd, SPI_IOC_WR_MODE, &hardware_SPI.mode) == -1) {
|
||||||
|
DEV_HARDWARE_SPI_Debug("can't set spi CS EN\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function: Chip Select
|
||||||
|
parameter:
|
||||||
|
Info:
|
||||||
|
CS_Mode:
|
||||||
|
SPI_CS_Mode_LOW
|
||||||
|
SPI_CS_Mode_HIGH
|
||||||
|
SPI_CS_Mode_NONE
|
||||||
|
Return :
|
||||||
|
Return 1 success
|
||||||
|
Return -1 failed
|
||||||
|
******************************************************************************/
|
||||||
|
int DEV_HARDWARE_SPI_ChipSelect(SPIChipSelect CS_Mode)
|
||||||
|
{
|
||||||
|
if(CS_Mode == SPI_CS_Mode_HIGH){
|
||||||
|
hardware_SPI.mode |= SPI_CS_HIGH;
|
||||||
|
hardware_SPI.mode &= ~SPI_NO_CS;
|
||||||
|
DEV_HARDWARE_SPI_Debug("CS HIGH \r\n");
|
||||||
|
}else if(CS_Mode == SPI_CS_Mode_LOW){
|
||||||
|
hardware_SPI.mode &= ~SPI_CS_HIGH;
|
||||||
|
hardware_SPI.mode &= ~SPI_NO_CS;
|
||||||
|
}else if(CS_Mode == SPI_CS_Mode_NONE){
|
||||||
|
hardware_SPI.mode |= SPI_NO_CS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ioctl(hardware_SPI.fd, SPI_IOC_WR_MODE, &hardware_SPI.mode) == -1) {
|
||||||
|
DEV_HARDWARE_SPI_Debug("can't set spi mode\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function: Sets the SPI bit order
|
||||||
|
parameter:
|
||||||
|
Info:
|
||||||
|
Order:
|
||||||
|
SPI_BIT_ORDER_LSBFIRST
|
||||||
|
SPI_BIT_ORDER_MSBFIRST
|
||||||
|
Return :
|
||||||
|
Return 1 success
|
||||||
|
Return -1 failed
|
||||||
|
******************************************************************************/
|
||||||
|
int DEV_HARDWARE_SPI_SetBitOrder(SPIBitOrder Order)
|
||||||
|
{
|
||||||
|
if(Order == SPI_BIT_ORDER_LSBFIRST){
|
||||||
|
hardware_SPI.mode |= SPI_LSB_FIRST;
|
||||||
|
DEV_HARDWARE_SPI_Debug("SPI_LSB_FIRST\r\n");
|
||||||
|
}else if(Order == SPI_BIT_ORDER_MSBFIRST){
|
||||||
|
hardware_SPI.mode &= ~SPI_LSB_FIRST;
|
||||||
|
DEV_HARDWARE_SPI_Debug("SPI_MSB_FIRST\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// DEV_HARDWARE_SPI_Debug("hardware_SPI.mode = 0x%02x\r\n", hardware_SPI.mode);
|
||||||
|
int fd = ioctl(hardware_SPI.fd, SPI_IOC_WR_MODE, &hardware_SPI.mode);
|
||||||
|
DEV_HARDWARE_SPI_Debug("fd = %d\r\n",fd);
|
||||||
|
if (fd == -1) {
|
||||||
|
DEV_HARDWARE_SPI_Debug("can't set spi SPI_LSB_FIRST\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function: Sets the SPI Bus Mode
|
||||||
|
parameter:
|
||||||
|
Info:
|
||||||
|
Order:
|
||||||
|
SPI_3WIRE_Mode
|
||||||
|
SPI_4WIRE_Mode
|
||||||
|
Return :
|
||||||
|
Return 1 success
|
||||||
|
Return -1 failed
|
||||||
|
******************************************************************************/
|
||||||
|
int DEV_HARDWARE_SPI_SetBusMode(BusMode mode)
|
||||||
|
{
|
||||||
|
if(mode == SPI_3WIRE_Mode){
|
||||||
|
hardware_SPI.mode |= SPI_3WIRE;
|
||||||
|
}else if(mode == SPI_4WIRE_Mode){
|
||||||
|
hardware_SPI.mode &= ~SPI_3WIRE;
|
||||||
|
}
|
||||||
|
if (ioctl(hardware_SPI.fd, SPI_IOC_WR_MODE, &hardware_SPI.mode) == -1) {
|
||||||
|
DEV_HARDWARE_SPI_Debug("can't set spi mode\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function:
|
||||||
|
Time interval after transmission of one byte during continuous transmission
|
||||||
|
parameter:
|
||||||
|
us : Interval time (us)
|
||||||
|
Info:
|
||||||
|
******************************************************************************/
|
||||||
|
void DEV_HARDWARE_SPI_SetDataInterval(uint16_t us)
|
||||||
|
{
|
||||||
|
hardware_SPI.delay = us;
|
||||||
|
tr.delay_usecs = hardware_SPI.delay;
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function: SPI port sends one byte of data
|
||||||
|
parameter:
|
||||||
|
buf : Sent data
|
||||||
|
Info:
|
||||||
|
******************************************************************************/
|
||||||
|
uint8_t DEV_HARDWARE_SPI_TransferByte(uint8_t buf)
|
||||||
|
{
|
||||||
|
uint8_t rbuf[1];
|
||||||
|
tr.len = 1;
|
||||||
|
tr.tx_buf = (unsigned long)&buf;
|
||||||
|
tr.rx_buf = (unsigned long)rbuf;
|
||||||
|
|
||||||
|
//ioctl Operation, transmission of data
|
||||||
|
if ( ioctl(hardware_SPI.fd, SPI_IOC_MESSAGE(1), &tr) < 1 )
|
||||||
|
DEV_HARDWARE_SPI_Debug("can't send spi message\r\n");
|
||||||
|
return rbuf[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function: The SPI port reads a byte
|
||||||
|
parameter:
|
||||||
|
Info: Return read data
|
||||||
|
******************************************************************************/
|
||||||
|
int DEV_HARDWARE_SPI_Transfer(uint8_t *buf, uint32_t len)
|
||||||
|
{
|
||||||
|
uint8_t rbuf[len];
|
||||||
|
tr.len = len;
|
||||||
|
tr.tx_buf = (unsigned long)buf;
|
||||||
|
tr.rx_buf = (unsigned long)rbuf;
|
||||||
|
|
||||||
|
//ioctl Operation, transmission of data
|
||||||
|
if (ioctl(hardware_SPI.fd, SPI_IOC_MESSAGE(1), &tr) < 1 ){
|
||||||
|
DEV_HARDWARE_SPI_Debug("can't send spi message\r\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,120 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : dev_hardware_SPI.h
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : Read and write /dev/SPI, hardware SPI
|
||||||
|
* | Info :
|
||||||
|
*----------------
|
||||||
|
* | This version: V1.0
|
||||||
|
* | Date : 2019-06-26
|
||||||
|
* | Info : Basic version
|
||||||
|
*
|
||||||
|
#
|
||||||
|
# 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 __DEV_HARDWARE_SPI_
|
||||||
|
#define __DEV_HARDWARE_SPI_
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#define DEV_HARDWARE_SPI_DEBUG 0
|
||||||
|
#if DEV_HARDWARE_SPI_DEBUG
|
||||||
|
#define DEV_HARDWARE_SPI_Debug(__info,...) printf("Debug: " __info,##__VA_ARGS__)
|
||||||
|
#else
|
||||||
|
#define DEV_HARDWARE_SPI_Debug(__info,...)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define SPI_CPHA 0x01
|
||||||
|
#define SPI_CPOL 0x02
|
||||||
|
#define SPI_MODE_0 (0|0)
|
||||||
|
#define SPI_MODE_1 (0|SPI_CPHA)
|
||||||
|
#define SPI_MODE_2 (SPI_CPOL|0)
|
||||||
|
#define SPI_MODE_3 (SPI_CPOL|SPI_CPHA)
|
||||||
|
|
||||||
|
typedef enum{
|
||||||
|
SPI_MODE0 = SPI_MODE_0, /*!< CPOL = 0, CPHA = 0 */
|
||||||
|
SPI_MODE1 = SPI_MODE_1, /*!< CPOL = 0, CPHA = 1 */
|
||||||
|
SPI_MODE2 = SPI_MODE_2, /*!< CPOL = 1, CPHA = 0 */
|
||||||
|
SPI_MODE3 = SPI_MODE_3 /*!< CPOL = 1, CPHA = 1 */
|
||||||
|
}SPIMode;
|
||||||
|
|
||||||
|
typedef enum{
|
||||||
|
DISABLE = 0,
|
||||||
|
ENABLE = 1
|
||||||
|
}SPICSEN;
|
||||||
|
|
||||||
|
typedef enum{
|
||||||
|
SPI_CS_Mode_LOW = 0, /*!< Chip Select 0 */
|
||||||
|
SPI_CS_Mode_HIGH = 1, /*!< Chip Select 1 */
|
||||||
|
SPI_CS_Mode_NONE = 3 /*!< No CS, control it yourself */
|
||||||
|
}SPIChipSelect;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
SPI_BIT_ORDER_LSBFIRST = 0, /*!< LSB First */
|
||||||
|
SPI_BIT_ORDER_MSBFIRST = 1 /*!< MSB First */
|
||||||
|
}SPIBitOrder;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
SPI_3WIRE_Mode = 0,
|
||||||
|
SPI_4WIRE_Mode = 1
|
||||||
|
}BusMode;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define SPI attribute
|
||||||
|
**/
|
||||||
|
typedef struct SPIStruct {
|
||||||
|
//GPIO
|
||||||
|
uint16_t SCLK_PIN;
|
||||||
|
uint16_t MOSI_PIN;
|
||||||
|
uint16_t MISO_PIN;
|
||||||
|
|
||||||
|
uint16_t CS0_PIN;
|
||||||
|
uint16_t CS1_PIN;
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t speed;
|
||||||
|
uint16_t mode;
|
||||||
|
uint16_t delay;
|
||||||
|
int fd; //
|
||||||
|
} HARDWARE_SPI;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void DEV_HARDWARE_SPI_begin(char *SPI_device);
|
||||||
|
void DEV_HARDWARE_SPI_beginSet(char *SPI_device, SPIMode mode, uint32_t speed);
|
||||||
|
void DEV_HARDWARE_SPI_end(void);
|
||||||
|
|
||||||
|
int DEV_HARDWARE_SPI_setSpeed(uint32_t speed);
|
||||||
|
|
||||||
|
uint8_t DEV_HARDWARE_SPI_TransferByte(uint8_t buf);
|
||||||
|
int DEV_HARDWARE_SPI_Transfer(uint8_t *buf, uint32_t len);
|
||||||
|
|
||||||
|
void DEV_HARDWARE_SPI_SetDataInterval(uint16_t us);
|
||||||
|
int DEV_HARDWARE_SPI_SetBusMode(BusMode mode);
|
||||||
|
int DEV_HARDWARE_SPI_SetBitOrder(SPIBitOrder Order);
|
||||||
|
int DEV_HARDWARE_SPI_ChipSelect(SPIChipSelect CS_Mode);
|
||||||
|
int DEV_HARDWARE_SPI_CSEN(SPICSEN EN);
|
||||||
|
int DEV_HARDWARE_SPI_Mode(SPIMode mode);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,112 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : dev_hardware_i2c.c
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : Read and write /dev/i2C, hardware I2C
|
||||||
|
* | Info :
|
||||||
|
*----------------
|
||||||
|
* | This version: V1.0
|
||||||
|
* | Date : 2019-06-26
|
||||||
|
* | Info : Basic version
|
||||||
|
*
|
||||||
|
#
|
||||||
|
# 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 "dev_hardware_i2c.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h> //exit()
|
||||||
|
#include <fcntl.h> //define O_RDWR
|
||||||
|
#include <linux/i2c-dev.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
|
||||||
|
HARDWARE_I2C hardware_i2c;
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function: I2C device initialization
|
||||||
|
parameter:
|
||||||
|
i2c_device : Device name
|
||||||
|
Info: /dev/i2c-*
|
||||||
|
******************************************************************************/
|
||||||
|
void DEV_HARDWARE_I2C_begin(char *i2c_device)
|
||||||
|
{
|
||||||
|
//device
|
||||||
|
if((hardware_i2c.fd = open(i2c_device, O_RDWR)) < 0) { //open I2C
|
||||||
|
perror("Failed to open i2c device.\n");
|
||||||
|
printf("Failed to open i2c device\r\n");
|
||||||
|
exit(1);
|
||||||
|
} else {
|
||||||
|
DEV_HARDWARE_I2C_Debug("open : %s\r\n", i2c_device);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function: I2C device End
|
||||||
|
parameter:
|
||||||
|
Info:
|
||||||
|
******************************************************************************/
|
||||||
|
void DEV_HARDWARE_I2C_end(void)
|
||||||
|
{
|
||||||
|
if (close(hardware_i2c.fd) != 0){
|
||||||
|
perror("Failed to close i2c device.\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function: Set the device address for I2C access
|
||||||
|
parameter:
|
||||||
|
addr : Device address accessed by I2C
|
||||||
|
Info:
|
||||||
|
******************************************************************************/
|
||||||
|
void DEV_HARDWARE_I2C_setSlaveAddress(uint8_t addr)
|
||||||
|
{
|
||||||
|
if(ioctl(hardware_i2c.fd, I2C_SLAVE, addr) < 0) {
|
||||||
|
printf("Failed to access bus.\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function: I2C Send data
|
||||||
|
parameter:
|
||||||
|
buf : Send data buffer address
|
||||||
|
len : Send data length
|
||||||
|
Info:
|
||||||
|
******************************************************************************/
|
||||||
|
uint8_t DEV_HARDWARE_I2C_write(const char * buf, uint32_t len)
|
||||||
|
{
|
||||||
|
write(hardware_i2c.fd, buf, len);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function: I2C read data
|
||||||
|
parameter:
|
||||||
|
buf : Sead data buffer address
|
||||||
|
len : Sead data length
|
||||||
|
Info:
|
||||||
|
******************************************************************************/
|
||||||
|
uint8_t DEV_HARDWARE_I2C_read(char* buf, uint32_t len)
|
||||||
|
{
|
||||||
|
read(hardware_i2c.fd, buf, len);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : dev_hardware_i2c.h
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : Read and write /dev/i2C, hardware I2C
|
||||||
|
* | Info :
|
||||||
|
*----------------
|
||||||
|
* | This version: V1.0
|
||||||
|
* | Date : 2019-06-26
|
||||||
|
* | Info : Basic version
|
||||||
|
*
|
||||||
|
#
|
||||||
|
# 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 __DEV_HARDWARE_I2C_
|
||||||
|
#define __DEV_HARDWARE_I2C_
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
|
||||||
|
#define DEV_HARDWARE_I2C_DEBUG 0
|
||||||
|
#if DEV_HARDWARE_I2C_DEBUG
|
||||||
|
#define DEV_HARDWARE_I2C_Debug(__info,...) printf("Debug: " __info,##__VA_ARGS__)
|
||||||
|
#else
|
||||||
|
#define DEV_HARDWARE_I2C_Debug(__info,...)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define I2C attribute
|
||||||
|
**/
|
||||||
|
typedef struct I2CStruct {
|
||||||
|
//GPIO
|
||||||
|
uint16_t SCL_PIN;
|
||||||
|
uint16_t SDA_PIN;
|
||||||
|
|
||||||
|
int fd; //I2C device file descriptor
|
||||||
|
uint16_t addr; //I2C device address
|
||||||
|
} HARDWARE_I2C;
|
||||||
|
|
||||||
|
void DEV_HARDWARE_I2C_begin(char *i2c_device);
|
||||||
|
void DEV_HARDWARE_I2C_end(void);
|
||||||
|
void DEV_HARDWARE_I2C_setSlaveAddress(uint8_t addr);
|
||||||
|
uint8_t DEV_HARDWARE_I2C_write(const char * buf, uint32_t len);
|
||||||
|
uint8_t DEV_HARDWARE_I2C_read(char* buf, uint32_t len);
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,121 @@
|
|||||||
|
#include "GT1151.h"
|
||||||
|
|
||||||
|
GT1151_Dev Dev_Now, Dev_Old;
|
||||||
|
UBYTE GT_Gesture_Mode = 0;
|
||||||
|
|
||||||
|
void GT_Reset(void)
|
||||||
|
{
|
||||||
|
TRST_1;
|
||||||
|
DEV_Delay_ms(100);
|
||||||
|
TRST_0;
|
||||||
|
DEV_Delay_ms(100);
|
||||||
|
TRST_1;
|
||||||
|
DEV_Delay_ms(100);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GT_Write(UWORD Reg, char *Data, UBYTE len)
|
||||||
|
{
|
||||||
|
I2C_Write_Byte(Reg, Data, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GT_Read(UWORD Reg, char *Data, UBYTE len)
|
||||||
|
{
|
||||||
|
I2C_Read_Byte(Reg, Data, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GT_ReadVersion(void)
|
||||||
|
{
|
||||||
|
char buf[4];
|
||||||
|
GT_Read(0x8140, buf, 4);
|
||||||
|
printf("Product ID is %c %c %c %c \r\n", buf[0], buf[1], buf[2] ,buf[3]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GT_Init(void)
|
||||||
|
{
|
||||||
|
GT_Reset();
|
||||||
|
GT_ReadVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GT_Gesture(void)
|
||||||
|
{
|
||||||
|
char buf[3] ={0x08, 0x00, 0xf8};
|
||||||
|
GT_Write(0x8040, &buf[0], 1);
|
||||||
|
GT_Write(0x8041, &buf[1], 1);
|
||||||
|
GT_Write(0x8042, &buf[2], 1);
|
||||||
|
GT_Gesture_Mode = 1;
|
||||||
|
printf("into gesture mode \r\n");
|
||||||
|
DEV_Delay_ms(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GT_Gesture_Scan(void)
|
||||||
|
{
|
||||||
|
char buf;
|
||||||
|
GT_Read(0x814c, &buf, 1);
|
||||||
|
if(buf == 0xcc)
|
||||||
|
{
|
||||||
|
printf("gesture mode exiting \r\n");
|
||||||
|
GT_Gesture_Mode = 0;
|
||||||
|
GT_Reset();
|
||||||
|
Dev_Old.X[0] = Dev_Now.X[0];
|
||||||
|
Dev_Old.Y[0] = Dev_Now.Y[0];
|
||||||
|
Dev_Old.S[0] = Dev_Now.S[0];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
buf = 0x00;
|
||||||
|
GT_Write(0x814c, &buf, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
UBYTE GT_Scan(void)
|
||||||
|
{
|
||||||
|
char buf[100];
|
||||||
|
char mask[1] = {0x00};
|
||||||
|
|
||||||
|
if (Dev_Now.Touch == 1) {
|
||||||
|
// Dev_Now.Touch = 0;
|
||||||
|
if(GT_Gesture_Mode == 1)
|
||||||
|
{
|
||||||
|
GT_Gesture_Scan();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GT_Read(0x814E, buf, 1);
|
||||||
|
if ((buf[0]&0x80) == 0x00) { //No new touch
|
||||||
|
GT_Write(0x814E, mask, 1);
|
||||||
|
DEV_Delay_ms(1);
|
||||||
|
// printf("buffers status is 0 \r\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Dev_Now.TouchpointFlag = buf[0]&0x80;
|
||||||
|
Dev_Now.TouchCount = buf[0]&0x0f;
|
||||||
|
if (Dev_Now.TouchCount > 5 || Dev_Now.TouchCount < 1) {
|
||||||
|
GT_Write(0x814E, mask, 1);
|
||||||
|
// printf("TouchCount number is wrong \r\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
GT_Read(0x814F, &buf[1], Dev_Now.TouchCount*8);
|
||||||
|
GT_Write(0x814E, mask, 1);
|
||||||
|
|
||||||
|
Dev_Old.X[0] = Dev_Now.X[0];
|
||||||
|
Dev_Old.Y[0] = Dev_Now.Y[0];
|
||||||
|
Dev_Old.S[0] = Dev_Now.S[0];
|
||||||
|
|
||||||
|
for(UBYTE i=0; i<Dev_Now.TouchCount; i++) {
|
||||||
|
Dev_Now.Touchkeytrackid[i] = buf[1 + 8*i];
|
||||||
|
Dev_Now.X[i] = ((UWORD)buf[3+8*i] << 8) + buf[2+8*i];
|
||||||
|
Dev_Now.Y[i] = ((UWORD)buf[5+8*i] << 8) + buf[4+8*i];
|
||||||
|
Dev_Now.S[i] = ((UWORD)buf[7+8*i] << 8) + buf[6+8*i];
|
||||||
|
}
|
||||||
|
|
||||||
|
for(UBYTE i=0; i<Dev_Now.TouchCount; i++)
|
||||||
|
printf("Point %d: X is %d, Y is %d, Size is %d \r\n", i+1, Dev_Now.X[i], Dev_Now.Y[i], Dev_Now.S[i]);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
#include "DEV_Config.h"
|
||||||
|
|
||||||
|
#ifndef __GT1151_H
|
||||||
|
#define __GT1151_H
|
||||||
|
|
||||||
|
#define CT_MAX_TOUCH 5
|
||||||
|
|
||||||
|
typedef struct{
|
||||||
|
UBYTE Touch;
|
||||||
|
UBYTE TouchpointFlag;
|
||||||
|
UBYTE TouchCount;
|
||||||
|
|
||||||
|
UBYTE Touchkeytrackid[CT_MAX_TOUCH];
|
||||||
|
UWORD X[CT_MAX_TOUCH];
|
||||||
|
UWORD Y[CT_MAX_TOUCH];
|
||||||
|
UWORD S[CT_MAX_TOUCH];
|
||||||
|
}GT1151_Dev;
|
||||||
|
|
||||||
|
void GT_Reset(void);
|
||||||
|
void GT_Write(UWORD Reg, char *Data, UBYTE len);
|
||||||
|
void GT_Read(UWORD Reg, char *Data, UBYTE len);
|
||||||
|
void GT_ReadVersion(void);
|
||||||
|
UBYTE GT_Scan(void);
|
||||||
|
void GT_Init(void);
|
||||||
|
void GT_Gesture(void);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
#include "ICNT86X.h"
|
||||||
|
|
||||||
|
ICNT86_Dev ICNT86_Dev_Now, ICNT86_Dev_Old;
|
||||||
|
|
||||||
|
void ICNT_Reset(void)
|
||||||
|
{
|
||||||
|
TRST_1;
|
||||||
|
DEV_Delay_ms(100);
|
||||||
|
TRST_0;
|
||||||
|
DEV_Delay_ms(100);
|
||||||
|
TRST_1;
|
||||||
|
DEV_Delay_ms(100);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ICNT_Write(UWORD Reg, char *Data, UBYTE len)
|
||||||
|
{
|
||||||
|
I2C_Write_Byte(Reg, Data, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ICNT_Read(UWORD Reg, char *Data, UBYTE len)
|
||||||
|
{
|
||||||
|
I2C_Read_Byte(Reg, Data, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ICNT_ReadVersion(void)
|
||||||
|
{
|
||||||
|
char buf[4];
|
||||||
|
ICNT_Read(0x000a, buf, 4);
|
||||||
|
printf("IC Version is %x %x \r\n", buf[0], buf[1]);
|
||||||
|
printf("FW Version is %x %x \r\n", buf[2], buf[3]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ICNT_Init(void)
|
||||||
|
{
|
||||||
|
ICNT_Reset();
|
||||||
|
ICNT_ReadVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
UBYTE ICNT_Scan(void)
|
||||||
|
{
|
||||||
|
char buf[100];
|
||||||
|
char mask[1] = {0x00};
|
||||||
|
if (ICNT86_Dev_Now.Touch == 1) {
|
||||||
|
// ICNT86_Dev_Now.Touch = 0;
|
||||||
|
ICNT_Read(0x1001, buf, 1);
|
||||||
|
if (buf[0] == 0x00) { //No new touch
|
||||||
|
ICNT_Write(0x1001, mask, 1);
|
||||||
|
DEV_Delay_ms(1);
|
||||||
|
// printf("buffers status is 0 \r\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ICNT86_Dev_Now.TouchCount = buf[0];
|
||||||
|
if (ICNT86_Dev_Now.TouchCount > 5 || ICNT86_Dev_Now.TouchCount < 1) {
|
||||||
|
ICNT_Write(0x1001, mask, 1);
|
||||||
|
ICNT86_Dev_Now.TouchCount = 0;
|
||||||
|
// printf("TouchCount number is wrong \r\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
ICNT_Read(0x1002, buf, ICNT86_Dev_Now.TouchCount*7);
|
||||||
|
ICNT_Write(0x1001, mask, 1);
|
||||||
|
|
||||||
|
ICNT86_Dev_Old.X[0] = ICNT86_Dev_Now.X[0];
|
||||||
|
ICNT86_Dev_Old.Y[0] = ICNT86_Dev_Now.Y[0];
|
||||||
|
ICNT86_Dev_Old.P[0] = ICNT86_Dev_Now.P[0];
|
||||||
|
|
||||||
|
for(UBYTE i=0; i<ICNT86_Dev_Now.TouchCount; i++) {
|
||||||
|
ICNT86_Dev_Now.X[i] = ((UWORD)buf[2+7*i] << 8) + buf[1+7*i];
|
||||||
|
ICNT86_Dev_Now.Y[i] = ((UWORD)buf[4+7*i] << 8) + buf[3+7*i];
|
||||||
|
ICNT86_Dev_Now.P[i] = buf[5+7*i];
|
||||||
|
ICNT86_Dev_Now.TouchEvenid[i] = buf[6 + 7*i];
|
||||||
|
}
|
||||||
|
|
||||||
|
for(UBYTE i=0; i<ICNT86_Dev_Now.TouchCount; i++)
|
||||||
|
printf("Point %d: X is %d, Y is %d, Pressure is %d \r\n", i+1, ICNT86_Dev_Now.X[i], ICNT86_Dev_Now.Y[i], ICNT86_Dev_Now.P[i]);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
#include "DEV_Config.h"
|
||||||
|
|
||||||
|
#ifndef __ICNT86X_H
|
||||||
|
#define __ICNT86X_H
|
||||||
|
|
||||||
|
#define ICNT_MAX_TOUCH 5
|
||||||
|
|
||||||
|
typedef struct{
|
||||||
|
UBYTE Touch;
|
||||||
|
UBYTE TouchCount;
|
||||||
|
UBYTE TouchGestureid;
|
||||||
|
|
||||||
|
UBYTE TouchEvenid[ICNT_MAX_TOUCH];
|
||||||
|
UWORD X[ICNT_MAX_TOUCH];
|
||||||
|
UWORD Y[ICNT_MAX_TOUCH];
|
||||||
|
UBYTE P[ICNT_MAX_TOUCH];
|
||||||
|
}ICNT86_Dev;
|
||||||
|
|
||||||
|
void ICNT_Reset(void);
|
||||||
|
void ICNT_Write(UWORD Reg, char *Data, UBYTE len);
|
||||||
|
void ICNT_Read(UWORD Reg, char *Data, UBYTE len);
|
||||||
|
void ICNT_ReadVersion(void);
|
||||||
|
UBYTE ICNT_Scan(void);
|
||||||
|
void ICNT_Init(void);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,398 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : EPD_2in13_V2.c
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : 2.13inch e-paper V2
|
||||||
|
* | Info :
|
||||||
|
*----------------
|
||||||
|
* | This version: V3.0
|
||||||
|
* | Date : 2019-06-13
|
||||||
|
* | Info :
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
* V3.0(2019-06-13):
|
||||||
|
* 1.Change name:
|
||||||
|
* EPD_Reset() => EPD_2IN13_V2_Reset()
|
||||||
|
* EPD_SendCommand() => EPD_2IN13_V2_SendCommand()
|
||||||
|
* EPD_SendData() => EPD_2IN13_V2_SendData()
|
||||||
|
* EPD_WaitUntilIdle() => EPD_2IN13_V2_ReadBusy()
|
||||||
|
* EPD_Init() => EPD_2IN13_V2_Init()
|
||||||
|
* EPD_Clear() => EPD_2IN13_V2_Clear()
|
||||||
|
* EPD_Display() => EPD_2IN13_V2_Display()
|
||||||
|
* EPD_Sleep() => EPD_2IN13_V2_Sleep()
|
||||||
|
* 2.add:
|
||||||
|
* EPD_2IN13_V2_DisplayPartBaseImage()
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
* V2.0(2018-11-14):
|
||||||
|
* 1.Remove:ImageBuff[EPD_HEIGHT * EPD_WIDTH / 8]
|
||||||
|
* 2.Change:EPD_2IN13_V2_Display(UBYTE *Image)
|
||||||
|
* Need to pass parameters: pointer to cached data
|
||||||
|
* 3.Change:
|
||||||
|
* EPD_RST -> EPD_RST_PIN
|
||||||
|
* EPD_DC -> EPD_DC_PIN
|
||||||
|
* EPD_CS -> EPD_CS_PIN
|
||||||
|
* EPD_BUSY -> EPD_BUSY_PIN
|
||||||
|
#
|
||||||
|
# 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_2in13_V2.h"
|
||||||
|
#include "Debug.h"
|
||||||
|
|
||||||
|
const unsigned char EPD_2IN13_V2_lut_full_update[]= {
|
||||||
|
0x80,0x60,0x40,0x00,0x00,0x00,0x00, //LUT0: BB: VS 0 ~7
|
||||||
|
0x10,0x60,0x20,0x00,0x00,0x00,0x00, //LUT1: BW: VS 0 ~7
|
||||||
|
0x80,0x60,0x40,0x00,0x00,0x00,0x00, //LUT2: WB: VS 0 ~7
|
||||||
|
0x10,0x60,0x20,0x00,0x00,0x00,0x00, //LUT3: WW: VS 0 ~7
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00, //LUT4: VCOM: VS 0 ~7
|
||||||
|
|
||||||
|
0x03,0x03,0x00,0x00,0x02, // TP0 A~D RP0
|
||||||
|
0x09,0x09,0x00,0x00,0x02, // TP1 A~D RP1
|
||||||
|
0x03,0x03,0x00,0x00,0x02, // TP2 A~D RP2
|
||||||
|
0x00,0x00,0x00,0x00,0x00, // TP3 A~D RP3
|
||||||
|
0x00,0x00,0x00,0x00,0x00, // TP4 A~D RP4
|
||||||
|
0x00,0x00,0x00,0x00,0x00, // TP5 A~D RP5
|
||||||
|
0x00,0x00,0x00,0x00,0x00, // TP6 A~D RP6
|
||||||
|
|
||||||
|
0x15,0x41,0xA8,0x32,0x30,0x0A,
|
||||||
|
};
|
||||||
|
|
||||||
|
const unsigned char EPD_2IN13_V2_lut_partial_update[]= { //20 bytes
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00, //LUT0: BB: VS 0 ~7
|
||||||
|
0x80,0x00,0x00,0x00,0x00,0x00,0x00, //LUT1: BW: VS 0 ~7
|
||||||
|
0x40,0x00,0x00,0x00,0x00,0x00,0x00, //LUT2: WB: VS 0 ~7
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00, //LUT3: WW: VS 0 ~7
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00, //LUT4: VCOM: VS 0 ~7
|
||||||
|
|
||||||
|
0x0A,0x00,0x00,0x00,0x00, // TP0 A~D RP0
|
||||||
|
0x00,0x00,0x00,0x00,0x00, // TP1 A~D RP1
|
||||||
|
0x00,0x00,0x00,0x00,0x00, // TP2 A~D RP2
|
||||||
|
0x00,0x00,0x00,0x00,0x00, // TP3 A~D RP3
|
||||||
|
0x00,0x00,0x00,0x00,0x00, // TP4 A~D RP4
|
||||||
|
0x00,0x00,0x00,0x00,0x00, // TP5 A~D RP5
|
||||||
|
0x00,0x00,0x00,0x00,0x00, // TP6 A~D RP6
|
||||||
|
|
||||||
|
0x15,0x41,0xA8,0x32,0x30,0x0A,
|
||||||
|
};
|
||||||
|
/******************************************************************************
|
||||||
|
function : Software reset
|
||||||
|
parameter:
|
||||||
|
******************************************************************************/
|
||||||
|
static void EPD_2IN13_V2_Reset(void)
|
||||||
|
{
|
||||||
|
DEV_Digital_Write(EPD_RST_PIN, 1);
|
||||||
|
DEV_Delay_ms(200);
|
||||||
|
DEV_Digital_Write(EPD_RST_PIN, 0);
|
||||||
|
DEV_Delay_ms(2);
|
||||||
|
DEV_Digital_Write(EPD_RST_PIN, 1);
|
||||||
|
DEV_Delay_ms(200);
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : send command
|
||||||
|
parameter:
|
||||||
|
Reg : Command register
|
||||||
|
******************************************************************************/
|
||||||
|
static void EPD_2IN13_V2_SendCommand(UBYTE Reg)
|
||||||
|
{
|
||||||
|
DEV_Digital_Write(EPD_DC_PIN, 0);
|
||||||
|
DEV_Digital_Write(EPD_CS_PIN, 0);
|
||||||
|
DEV_SPI_WriteByte(Reg);
|
||||||
|
DEV_Digital_Write(EPD_CS_PIN, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : send data
|
||||||
|
parameter:
|
||||||
|
Data : Write data
|
||||||
|
******************************************************************************/
|
||||||
|
static void EPD_2IN13_V2_SendData(UBYTE Data)
|
||||||
|
{
|
||||||
|
DEV_Digital_Write(EPD_DC_PIN, 1);
|
||||||
|
DEV_Digital_Write(EPD_CS_PIN, 0);
|
||||||
|
DEV_SPI_WriteByte(Data);
|
||||||
|
DEV_Digital_Write(EPD_CS_PIN, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void EPD_2IN13_V2_SendData2(UBYTE *Data, UDOUBLE len)
|
||||||
|
{
|
||||||
|
DEV_Digital_Write(EPD_DC_PIN, 1);
|
||||||
|
DEV_Digital_Write(EPD_CS_PIN, 0);
|
||||||
|
DEV_SPI_Write_nByte(Data, len);
|
||||||
|
DEV_Digital_Write(EPD_CS_PIN, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : Wait until the busy_pin goes LOW
|
||||||
|
parameter:
|
||||||
|
******************************************************************************/
|
||||||
|
void EPD_2IN13_V2_ReadBusy(void)
|
||||||
|
{
|
||||||
|
Debug("e-Paper busy\r\n");
|
||||||
|
do { //LOW: idle, HIGH: busy
|
||||||
|
DEV_Delay_ms(1);
|
||||||
|
}while(DEV_Digital_Read(EPD_BUSY_PIN) == 1);
|
||||||
|
Debug("e-Paper busy release\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : Turn On Display
|
||||||
|
parameter:
|
||||||
|
******************************************************************************/
|
||||||
|
static void EPD_2IN13_V2_TurnOnDisplay(void)
|
||||||
|
{
|
||||||
|
EPD_2IN13_V2_SendCommand(0x22);
|
||||||
|
EPD_2IN13_V2_SendData(0xC7);
|
||||||
|
EPD_2IN13_V2_SendCommand(0x20);
|
||||||
|
EPD_2IN13_V2_ReadBusy();
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : Turn On Display
|
||||||
|
parameter:
|
||||||
|
******************************************************************************/
|
||||||
|
static void EPD_2IN13_V2_TurnOnDisplayPart(void)
|
||||||
|
{
|
||||||
|
EPD_2IN13_V2_SendCommand(0x22);
|
||||||
|
EPD_2IN13_V2_SendData(0x0C);
|
||||||
|
EPD_2IN13_V2_SendCommand(0x20);
|
||||||
|
// EPD_2IN13_V2_ReadBusy();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void EPD_2IN13_V2_TurnOnDisplayPart_Wait(void)
|
||||||
|
{
|
||||||
|
EPD_2IN13_V2_SendCommand(0x22);
|
||||||
|
EPD_2IN13_V2_SendData(0x0C);
|
||||||
|
EPD_2IN13_V2_SendCommand(0x20);
|
||||||
|
EPD_2IN13_V2_ReadBusy();
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : Initialize the e-Paper register
|
||||||
|
parameter:
|
||||||
|
******************************************************************************/
|
||||||
|
void EPD_2IN13_V2_Init(UBYTE Mode)
|
||||||
|
{
|
||||||
|
|
||||||
|
UBYTE count;
|
||||||
|
EPD_2IN13_V2_Reset();
|
||||||
|
|
||||||
|
if(Mode == EPD_2IN13_V2_FULL) {
|
||||||
|
EPD_2IN13_V2_ReadBusy();
|
||||||
|
EPD_2IN13_V2_SendCommand(0x12); // soft reset
|
||||||
|
EPD_2IN13_V2_ReadBusy();
|
||||||
|
|
||||||
|
EPD_2IN13_V2_SendCommand(0x74); //set analog block control
|
||||||
|
EPD_2IN13_V2_SendData(0x54);
|
||||||
|
EPD_2IN13_V2_SendCommand(0x7E); //set digital block control
|
||||||
|
EPD_2IN13_V2_SendData(0x3B);
|
||||||
|
|
||||||
|
EPD_2IN13_V2_SendCommand(0x01); //Driver output control
|
||||||
|
EPD_2IN13_V2_SendData(0xF9);
|
||||||
|
EPD_2IN13_V2_SendData(0x00);
|
||||||
|
EPD_2IN13_V2_SendData(0x00);
|
||||||
|
|
||||||
|
EPD_2IN13_V2_SendCommand(0x11); //data entry mode
|
||||||
|
EPD_2IN13_V2_SendData(0x01);
|
||||||
|
|
||||||
|
EPD_2IN13_V2_SendCommand(0x44); //set Ram-X address start/end position
|
||||||
|
EPD_2IN13_V2_SendData(0x00);
|
||||||
|
EPD_2IN13_V2_SendData(0x0F); //0x0C-->(15+1)*8=128
|
||||||
|
|
||||||
|
EPD_2IN13_V2_SendCommand(0x45); //set Ram-Y address start/end position
|
||||||
|
EPD_2IN13_V2_SendData(0xF9); //0xF9-->(249+1)=250
|
||||||
|
EPD_2IN13_V2_SendData(0x00);
|
||||||
|
EPD_2IN13_V2_SendData(0x00);
|
||||||
|
EPD_2IN13_V2_SendData(0x00);
|
||||||
|
|
||||||
|
EPD_2IN13_V2_SendCommand(0x3C); //BorderWavefrom
|
||||||
|
EPD_2IN13_V2_SendData(0x03);
|
||||||
|
|
||||||
|
EPD_2IN13_V2_SendCommand(0x2C); //VCOM Voltage
|
||||||
|
EPD_2IN13_V2_SendData(0x55); //
|
||||||
|
|
||||||
|
EPD_2IN13_V2_SendCommand(0x03);
|
||||||
|
EPD_2IN13_V2_SendData(EPD_2IN13_V2_lut_full_update[70]);
|
||||||
|
|
||||||
|
EPD_2IN13_V2_SendCommand(0x04); //
|
||||||
|
EPD_2IN13_V2_SendData(EPD_2IN13_V2_lut_full_update[71]);
|
||||||
|
EPD_2IN13_V2_SendData(EPD_2IN13_V2_lut_full_update[72]);
|
||||||
|
EPD_2IN13_V2_SendData(EPD_2IN13_V2_lut_full_update[73]);
|
||||||
|
|
||||||
|
EPD_2IN13_V2_SendCommand(0x3A); //Dummy Line
|
||||||
|
EPD_2IN13_V2_SendData(EPD_2IN13_V2_lut_full_update[74]);
|
||||||
|
EPD_2IN13_V2_SendCommand(0x3B); //Gate time
|
||||||
|
EPD_2IN13_V2_SendData(EPD_2IN13_V2_lut_full_update[75]);
|
||||||
|
|
||||||
|
EPD_2IN13_V2_SendCommand(0x32);
|
||||||
|
for(count = 0; count < 70; count++) {
|
||||||
|
EPD_2IN13_V2_SendData(EPD_2IN13_V2_lut_full_update[count]);
|
||||||
|
}
|
||||||
|
|
||||||
|
EPD_2IN13_V2_SendCommand(0x4E); // set RAM x address count to 0;
|
||||||
|
EPD_2IN13_V2_SendData(0x00);
|
||||||
|
EPD_2IN13_V2_SendCommand(0x4F); // set RAM y address count to 0X127;
|
||||||
|
EPD_2IN13_V2_SendData(0xF9);
|
||||||
|
EPD_2IN13_V2_SendData(0x00);
|
||||||
|
EPD_2IN13_V2_ReadBusy();
|
||||||
|
} else if(Mode == EPD_2IN13_V2_PART) {
|
||||||
|
EPD_2IN13_V2_SendCommand(0x2C); //VCOM Voltage
|
||||||
|
EPD_2IN13_V2_SendData(0x26);
|
||||||
|
|
||||||
|
EPD_2IN13_V2_ReadBusy();
|
||||||
|
|
||||||
|
EPD_2IN13_V2_SendCommand(0x32);
|
||||||
|
for(count = 0; count < 70; count++) {
|
||||||
|
EPD_2IN13_V2_SendData(EPD_2IN13_V2_lut_partial_update[count]);
|
||||||
|
}
|
||||||
|
|
||||||
|
EPD_2IN13_V2_SendCommand(0x37);
|
||||||
|
EPD_2IN13_V2_SendData(0x00);
|
||||||
|
EPD_2IN13_V2_SendData(0x00);
|
||||||
|
EPD_2IN13_V2_SendData(0x00);
|
||||||
|
EPD_2IN13_V2_SendData(0x00);
|
||||||
|
EPD_2IN13_V2_SendData(0x40);
|
||||||
|
EPD_2IN13_V2_SendData(0x00);
|
||||||
|
EPD_2IN13_V2_SendData(0x00);
|
||||||
|
|
||||||
|
EPD_2IN13_V2_SendCommand(0x22);
|
||||||
|
EPD_2IN13_V2_SendData(0xC0);
|
||||||
|
|
||||||
|
EPD_2IN13_V2_SendCommand(0x20);
|
||||||
|
EPD_2IN13_V2_ReadBusy();
|
||||||
|
|
||||||
|
EPD_2IN13_V2_SendCommand(0x3C); //BorderWavefrom
|
||||||
|
EPD_2IN13_V2_SendData(0x01);
|
||||||
|
} else {
|
||||||
|
Debug("error, the Mode is EPD_2IN13_FULL or EPD_2IN13_PART");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : Clear screen
|
||||||
|
parameter:
|
||||||
|
******************************************************************************/
|
||||||
|
void EPD_2IN13_V2_Clear(void)
|
||||||
|
{
|
||||||
|
UWORD Width, Height;
|
||||||
|
Width = (EPD_2IN13_V2_WIDTH % 8 == 0)? (EPD_2IN13_V2_WIDTH / 8 ): (EPD_2IN13_V2_WIDTH / 8 + 1);
|
||||||
|
Height = EPD_2IN13_V2_HEIGHT;
|
||||||
|
|
||||||
|
EPD_2IN13_V2_SendCommand(0x24);
|
||||||
|
for (UWORD j = 0; j < Height; j++) {
|
||||||
|
for (UWORD i = 0; i < Width; i++) {
|
||||||
|
EPD_2IN13_V2_SendData(0XFF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EPD_2IN13_V2_TurnOnDisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : Sends the image buffer in RAM to e-Paper and displays
|
||||||
|
parameter:
|
||||||
|
******************************************************************************/
|
||||||
|
void EPD_2IN13_V2_Display(UBYTE *Image)
|
||||||
|
{
|
||||||
|
UWORD Width, Height;
|
||||||
|
Width = (EPD_2IN13_V2_WIDTH % 8 == 0)? (EPD_2IN13_V2_WIDTH / 8 ): (EPD_2IN13_V2_WIDTH / 8 + 1);
|
||||||
|
Height = EPD_2IN13_V2_HEIGHT;
|
||||||
|
|
||||||
|
EPD_2IN13_V2_SendCommand(0x24);
|
||||||
|
for (UWORD j = 0; j < Height; j++) {
|
||||||
|
for (UWORD i = 0; i < Width; i++) {
|
||||||
|
EPD_2IN13_V2_SendData(Image[i + j * Width]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EPD_2IN13_V2_TurnOnDisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : The image of the previous frame must be uploaded, otherwise the
|
||||||
|
first few seconds will display an exception.
|
||||||
|
parameter:
|
||||||
|
******************************************************************************/
|
||||||
|
void EPD_2IN13_V2_DisplayPartBaseImage(UBYTE *Image)
|
||||||
|
{
|
||||||
|
UWORD Width, Height;
|
||||||
|
Width = (EPD_2IN13_V2_WIDTH % 8 == 0)? (EPD_2IN13_V2_WIDTH / 8 ): (EPD_2IN13_V2_WIDTH / 8 + 1);
|
||||||
|
Height = EPD_2IN13_V2_HEIGHT;
|
||||||
|
|
||||||
|
// UDOUBLE Addr = 0;
|
||||||
|
EPD_2IN13_V2_SendCommand(0x24);
|
||||||
|
// for (UWORD j = 0; j < Height; j++) {
|
||||||
|
// for (UWORD i = 0; i < Width; i++) {
|
||||||
|
// Addr = i + j * Width;
|
||||||
|
// EPD_2IN13_V2_SendData(Image[Addr]);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
EPD_2IN13_V2_SendData2(Image, Height*Width);
|
||||||
|
EPD_2IN13_V2_SendCommand(0x26);
|
||||||
|
// for (UWORD j = 0; j < Height; j++) {
|
||||||
|
// for (UWORD i = 0; i < Width; i++) {
|
||||||
|
// Addr = i + j * Width;
|
||||||
|
// EPD_2IN13_V2_SendData(Image[Addr]);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
EPD_2IN13_V2_SendData2(Image, Height*Width);
|
||||||
|
EPD_2IN13_V2_TurnOnDisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
void EPD_2IN13_V2_DisplayPart_Wait(UBYTE *Image)
|
||||||
|
{
|
||||||
|
UWORD Width, Height;
|
||||||
|
Width = (EPD_2IN13_V2_WIDTH % 8 == 0)? (EPD_2IN13_V2_WIDTH / 8 ): (EPD_2IN13_V2_WIDTH / 8 + 1);
|
||||||
|
Height = EPD_2IN13_V2_HEIGHT;
|
||||||
|
EPD_2IN13_V2_SendCommand(0x24);
|
||||||
|
// for (UWORD j = 0; j < Height; j++) {
|
||||||
|
// for (UWORD i = 0; i < Width; i++) {
|
||||||
|
// EPD_2IN13_V2_SendData(Image[i + j * Width]);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
EPD_2IN13_V2_SendData2(Image, Height*Width);
|
||||||
|
EPD_2IN13_V2_TurnOnDisplayPart_Wait();
|
||||||
|
}
|
||||||
|
|
||||||
|
void EPD_2IN13_V2_DisplayPart(UBYTE *Image)
|
||||||
|
{
|
||||||
|
UWORD Width, Height;
|
||||||
|
Width = (EPD_2IN13_V2_WIDTH % 8 == 0)? (EPD_2IN13_V2_WIDTH / 8 ): (EPD_2IN13_V2_WIDTH / 8 + 1);
|
||||||
|
Height = EPD_2IN13_V2_HEIGHT;
|
||||||
|
EPD_2IN13_V2_SendCommand(0x24);
|
||||||
|
// for (UWORD j = 0; j < Height; j++) {
|
||||||
|
// for (UWORD i = 0; i < Width; i++) {
|
||||||
|
// EPD_2IN13_V2_SendData(Image[i + j * Width]);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
EPD_2IN13_V2_SendData2(Image, Height*Width);
|
||||||
|
EPD_2IN13_V2_TurnOnDisplayPart();
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : Enter sleep mode
|
||||||
|
parameter:
|
||||||
|
******************************************************************************/
|
||||||
|
void EPD_2IN13_V2_Sleep(void)
|
||||||
|
{
|
||||||
|
EPD_2IN13_V2_SendCommand(0x22); //POWER OFF
|
||||||
|
EPD_2IN13_V2_SendData(0xC3);
|
||||||
|
EPD_2IN13_V2_SendCommand(0x20);
|
||||||
|
|
||||||
|
EPD_2IN13_V2_SendCommand(0x10); //enter deep sleep
|
||||||
|
EPD_2IN13_V2_SendData(0x01);
|
||||||
|
DEV_Delay_ms(100);
|
||||||
|
}
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : EPD_2in13_V2.h
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : 2.13inch e-paper V2
|
||||||
|
* | Info :
|
||||||
|
*----------------
|
||||||
|
* | This version: V3.0
|
||||||
|
* | Date : 2019-06-13
|
||||||
|
* | Info :
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
* V3.0(2019-06-13):
|
||||||
|
* 1.Change name:
|
||||||
|
* EPD_Reset() => EPD_2IN13_V2_Reset()
|
||||||
|
* EPD_SendCommand() => EPD_2IN13_V2_SendCommand()
|
||||||
|
* EPD_SendData() => EPD_2IN13_V2_SendData()
|
||||||
|
* EPD_WaitUntilIdle() => EPD_2IN13_V2_ReadBusy()
|
||||||
|
* EPD_Init() => EPD_2IN13_V2_Init()
|
||||||
|
* EPD_Clear() => EPD_2IN13_V2_Clear()
|
||||||
|
* EPD_Display() => EPD_2IN13_V2_Display()
|
||||||
|
* EPD_Sleep() => EPD_2IN13_V2_Sleep()
|
||||||
|
* 2.add:
|
||||||
|
* EPD_2IN13_V2_DisplayPartBaseImage()
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
* V2.0(2018-11-14):
|
||||||
|
* 1.Remove:ImageBuff[EPD_HEIGHT * EPD_WIDTH / 8]
|
||||||
|
* 2.Change:EPD_2IN13_V2_Display(UBYTE *Image)
|
||||||
|
* Need to pass parameters: pointer to cached data
|
||||||
|
* 3.Change:
|
||||||
|
* EPD_RST -> EPD_RST_PIN
|
||||||
|
* EPD_DC -> EPD_DC_PIN
|
||||||
|
* EPD_CS -> EPD_CS_PIN
|
||||||
|
* EPD_BUSY -> EPD_BUSY_PIN
|
||||||
|
#
|
||||||
|
# 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_2IN13_V2_H_
|
||||||
|
#define _EPD_2IN13_V2_H_
|
||||||
|
|
||||||
|
#include "DEV_Config.h"
|
||||||
|
|
||||||
|
// Display resolution
|
||||||
|
#define EPD_2IN13_V2_WIDTH 122
|
||||||
|
#define EPD_2IN13_V2_HEIGHT 250
|
||||||
|
|
||||||
|
#define EPD_2IN13_V2_FULL 0
|
||||||
|
#define EPD_2IN13_V2_PART 1
|
||||||
|
|
||||||
|
void EPD_2IN13_V2_Init(UBYTE Mode);
|
||||||
|
void EPD_2IN13_V2_Clear(void);
|
||||||
|
void EPD_2IN13_V2_Display(UBYTE *Image);
|
||||||
|
void EPD_2IN13_V2_DisplayPart(UBYTE *Image);
|
||||||
|
void EPD_2IN13_V2_DisplayPartBaseImage(UBYTE *Image);
|
||||||
|
void EPD_2IN13_V2_Sleep(void);
|
||||||
|
|
||||||
|
void EPD_2IN13_V2_DisplayPart_Wait(UBYTE *Image);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,473 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : EPD_2in13_V3.c
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : 2.13inch e-paper V3
|
||||||
|
* | Info :
|
||||||
|
*----------------
|
||||||
|
* | This version: V1.1
|
||||||
|
* | Date : 2021-10-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_2in13_V3.h"
|
||||||
|
#include "Debug.h"
|
||||||
|
|
||||||
|
UBYTE WF_PARTIAL_2IN13_V3[159] =
|
||||||
|
{
|
||||||
|
0x0,0x40,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||||
|
0x80,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||||
|
0x40,0x40,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||||
|
0x0,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||||
|
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||||
|
0x10,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||||
|
0x1,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||||
|
0x1,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||||
|
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||||
|
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||||
|
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||||
|
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||||
|
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||||
|
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||||
|
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||||
|
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||||
|
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||||
|
0x22,0x22,0x22,0x22,0x22,0x22,0x0,0x0,0x0,
|
||||||
|
0x22,0x17,0x41,0x00,0x32,0x36,
|
||||||
|
};
|
||||||
|
|
||||||
|
UBYTE WS_20_30_2IN13_V3[159] =
|
||||||
|
{
|
||||||
|
0x80, 0x4A, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||||
|
0x40, 0x4A, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||||
|
0x80, 0x4A, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||||
|
0x40, 0x4A, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||||
|
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||||
|
0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||||
|
0xF, 0x0, 0x0, 0xF, 0x0, 0x0, 0x2,
|
||||||
|
0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||||
|
0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||||
|
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||||
|
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||||
|
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||||
|
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||||
|
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||||
|
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||||
|
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||||
|
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||||
|
0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x0, 0x0, 0x0,
|
||||||
|
0x22, 0x17, 0x41, 0x0, 0x32, 0x36
|
||||||
|
};
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : Software reset
|
||||||
|
parameter:
|
||||||
|
******************************************************************************/
|
||||||
|
static void EPD_2in13_V3_Reset(void)
|
||||||
|
{
|
||||||
|
DEV_Digital_Write(EPD_RST_PIN, 1);
|
||||||
|
DEV_Delay_ms(20);
|
||||||
|
DEV_Digital_Write(EPD_RST_PIN, 0);
|
||||||
|
DEV_Delay_ms(2);
|
||||||
|
DEV_Digital_Write(EPD_RST_PIN, 1);
|
||||||
|
DEV_Delay_ms(20);
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : send command
|
||||||
|
parameter:
|
||||||
|
Reg : Command register
|
||||||
|
******************************************************************************/
|
||||||
|
static void EPD_2in13_V3_SendCommand(UBYTE Reg)
|
||||||
|
{
|
||||||
|
DEV_Digital_Write(EPD_DC_PIN, 0);
|
||||||
|
DEV_Digital_Write(EPD_CS_PIN, 0);
|
||||||
|
DEV_SPI_WriteByte(Reg);
|
||||||
|
DEV_Digital_Write(EPD_CS_PIN, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : send data
|
||||||
|
parameter:
|
||||||
|
Data : Write data
|
||||||
|
******************************************************************************/
|
||||||
|
static void EPD_2in13_V3_SendData(UBYTE Data)
|
||||||
|
{
|
||||||
|
DEV_Digital_Write(EPD_DC_PIN, 1);
|
||||||
|
DEV_Digital_Write(EPD_CS_PIN, 0);
|
||||||
|
DEV_SPI_WriteByte(Data);
|
||||||
|
DEV_Digital_Write(EPD_CS_PIN, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void EPD_2IN13_V3_SendData2(UBYTE *Data, UDOUBLE len)
|
||||||
|
{
|
||||||
|
DEV_Digital_Write(EPD_DC_PIN, 1);
|
||||||
|
DEV_Digital_Write(EPD_CS_PIN, 0);
|
||||||
|
DEV_SPI_Write_nByte(Data, len);
|
||||||
|
DEV_Digital_Write(EPD_CS_PIN, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : Wait until the busy_pin goes LOW
|
||||||
|
parameter:
|
||||||
|
******************************************************************************/
|
||||||
|
void EPD_2in13_V3_ReadBusy(void)
|
||||||
|
{
|
||||||
|
Debug("e-Paper busy\r\n");
|
||||||
|
while(1)
|
||||||
|
{ //=1 BUSY
|
||||||
|
if(DEV_Digital_Read(EPD_BUSY_PIN)==0)
|
||||||
|
break;
|
||||||
|
DEV_Delay_ms(10);
|
||||||
|
}
|
||||||
|
DEV_Delay_ms(10);
|
||||||
|
Debug("e-Paper busy release\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : Turn On Display
|
||||||
|
parameter:
|
||||||
|
******************************************************************************/
|
||||||
|
static void EPD_2in13_V3_TurnOnDisplay(void)
|
||||||
|
{
|
||||||
|
EPD_2in13_V3_SendCommand(0x22); // Display Update Control
|
||||||
|
EPD_2in13_V3_SendData(0xc7);
|
||||||
|
EPD_2in13_V3_SendCommand(0x20); // Activate Display Update Sequence
|
||||||
|
EPD_2in13_V3_ReadBusy();
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : Turn On Display
|
||||||
|
parameter:
|
||||||
|
******************************************************************************/
|
||||||
|
static void EPD_2in13_V3_TurnOnDisplay_Partial(void)
|
||||||
|
{
|
||||||
|
EPD_2in13_V3_SendCommand(0x22); // Display Update Control
|
||||||
|
EPD_2in13_V3_SendData(0x0C); // fast:0x0c, quality:0x0f, 0xcf
|
||||||
|
EPD_2in13_V3_SendCommand(0x20); // Activate Display Update Sequence
|
||||||
|
// EPD_2in13_V3_ReadBusy();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void EPD_2in13_V3_TurnOnDisplay_Partial_Wait(void)
|
||||||
|
{
|
||||||
|
EPD_2in13_V3_SendCommand(0x22); // Display Update Control
|
||||||
|
EPD_2in13_V3_SendData(0x0C); // fast:0x0c, quality:0x0f, 0xcf
|
||||||
|
EPD_2in13_V3_SendCommand(0x20); // Activate Display Update Sequence
|
||||||
|
EPD_2in13_V3_ReadBusy();
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : Set lut
|
||||||
|
parameter:
|
||||||
|
lut : lut data
|
||||||
|
******************************************************************************/
|
||||||
|
static void EPD_2IN13_V3_LUT(UBYTE *lut)
|
||||||
|
{
|
||||||
|
UBYTE count;
|
||||||
|
EPD_2in13_V3_SendCommand(0x32);
|
||||||
|
for(count=0; count<153; count++)
|
||||||
|
EPD_2in13_V3_SendData(lut[count]);
|
||||||
|
EPD_2in13_V3_ReadBusy();
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : Send lut data and configuration
|
||||||
|
parameter:
|
||||||
|
lut : lut data
|
||||||
|
******************************************************************************/
|
||||||
|
static void EPD_2IN13_V2_LUT_by_host(UBYTE *lut)
|
||||||
|
{
|
||||||
|
EPD_2IN13_V3_LUT((UBYTE *)lut); //lut
|
||||||
|
EPD_2in13_V3_SendCommand(0x3f);
|
||||||
|
EPD_2in13_V3_SendData(*(lut+153));
|
||||||
|
EPD_2in13_V3_SendCommand(0x03); // gate voltage
|
||||||
|
EPD_2in13_V3_SendData(*(lut+154));
|
||||||
|
EPD_2in13_V3_SendCommand(0x04); // source voltage
|
||||||
|
EPD_2in13_V3_SendData(*(lut+155)); // VSH
|
||||||
|
EPD_2in13_V3_SendData(*(lut+156)); // VSH2
|
||||||
|
EPD_2in13_V3_SendData(*(lut+157)); // VSL
|
||||||
|
EPD_2in13_V3_SendCommand(0x2c); // VCOM
|
||||||
|
EPD_2in13_V3_SendData(*(lut+158));
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : Setting the display window
|
||||||
|
parameter:
|
||||||
|
Xstart : X-axis starting position
|
||||||
|
Ystart : Y-axis starting position
|
||||||
|
Xend : End position of X-axis
|
||||||
|
Yend : End position of Y-axis
|
||||||
|
******************************************************************************/
|
||||||
|
static void EPD_2in13_V3_SetWindows(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend)
|
||||||
|
{
|
||||||
|
EPD_2in13_V3_SendCommand(0x44); // SET_RAM_X_ADDRESS_START_END_POSITION
|
||||||
|
EPD_2in13_V3_SendData((Xstart>>3) & 0xFF);
|
||||||
|
EPD_2in13_V3_SendData((Xend>>3) & 0xFF);
|
||||||
|
|
||||||
|
EPD_2in13_V3_SendCommand(0x45); // SET_RAM_Y_ADDRESS_START_END_POSITION
|
||||||
|
EPD_2in13_V3_SendData(Ystart & 0xFF);
|
||||||
|
EPD_2in13_V3_SendData((Ystart >> 8) & 0xFF);
|
||||||
|
EPD_2in13_V3_SendData(Yend & 0xFF);
|
||||||
|
EPD_2in13_V3_SendData((Yend >> 8) & 0xFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : Set Cursor
|
||||||
|
parameter:
|
||||||
|
Xstart : X-axis starting position
|
||||||
|
Ystart : Y-axis starting position
|
||||||
|
******************************************************************************/
|
||||||
|
static void EPD_2in13_V3_SetCursor(UWORD Xstart, UWORD Ystart)
|
||||||
|
{
|
||||||
|
EPD_2in13_V3_SendCommand(0x4E); // SET_RAM_X_ADDRESS_COUNTER
|
||||||
|
EPD_2in13_V3_SendData(Xstart & 0xFF);
|
||||||
|
|
||||||
|
EPD_2in13_V3_SendCommand(0x4F); // SET_RAM_Y_ADDRESS_COUNTER
|
||||||
|
EPD_2in13_V3_SendData(Ystart & 0xFF);
|
||||||
|
EPD_2in13_V3_SendData((Ystart >> 8) & 0xFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : Initialize the e-Paper register
|
||||||
|
parameter:
|
||||||
|
******************************************************************************/
|
||||||
|
void EPD_2in13_V3_Init(UBYTE Mode)
|
||||||
|
{
|
||||||
|
if(Mode == EPD_2IN13_V3_FULL)
|
||||||
|
{
|
||||||
|
EPD_2in13_V3_Reset();
|
||||||
|
DEV_Delay_ms(100);
|
||||||
|
|
||||||
|
EPD_2in13_V3_ReadBusy();
|
||||||
|
EPD_2in13_V3_SendCommand(0x12); //SWRESET
|
||||||
|
EPD_2in13_V3_ReadBusy();
|
||||||
|
|
||||||
|
EPD_2in13_V3_SendCommand(0x01); //Driver output control
|
||||||
|
EPD_2in13_V3_SendData(0xf9);
|
||||||
|
EPD_2in13_V3_SendData(0x00);
|
||||||
|
EPD_2in13_V3_SendData(0x00);
|
||||||
|
|
||||||
|
EPD_2in13_V3_SendCommand(0x11); //data entry mode
|
||||||
|
EPD_2in13_V3_SendData(0x03);
|
||||||
|
|
||||||
|
EPD_2in13_V3_SetWindows(0, 0, EPD_2in13_V3_WIDTH-1, EPD_2in13_V3_HEIGHT-1);
|
||||||
|
EPD_2in13_V3_SetCursor(0, 0);
|
||||||
|
|
||||||
|
EPD_2in13_V3_SendCommand(0x3C); //BorderWavefrom
|
||||||
|
EPD_2in13_V3_SendData(0x05);
|
||||||
|
|
||||||
|
EPD_2in13_V3_SendCommand(0x21); // Display update control
|
||||||
|
EPD_2in13_V3_SendData(0x00);
|
||||||
|
EPD_2in13_V3_SendData(0x80);
|
||||||
|
|
||||||
|
EPD_2in13_V3_SendCommand(0x18); //Read built-in temperature sensor
|
||||||
|
EPD_2in13_V3_SendData(0x80);
|
||||||
|
|
||||||
|
EPD_2in13_V3_ReadBusy();
|
||||||
|
EPD_2IN13_V2_LUT_by_host(WS_20_30_2IN13_V3);
|
||||||
|
}
|
||||||
|
else if(Mode == EPD_2IN13_V3_PART)
|
||||||
|
{
|
||||||
|
//Reset
|
||||||
|
DEV_Digital_Write(EPD_RST_PIN, 0);
|
||||||
|
DEV_Delay_ms(1);
|
||||||
|
DEV_Digital_Write(EPD_RST_PIN, 1);
|
||||||
|
|
||||||
|
EPD_2IN13_V2_LUT_by_host(WF_PARTIAL_2IN13_V3);
|
||||||
|
|
||||||
|
EPD_2in13_V3_SendCommand(0x37);
|
||||||
|
EPD_2in13_V3_SendData(0x00);
|
||||||
|
EPD_2in13_V3_SendData(0x00);
|
||||||
|
EPD_2in13_V3_SendData(0x00);
|
||||||
|
EPD_2in13_V3_SendData(0x00);
|
||||||
|
EPD_2in13_V3_SendData(0x00);
|
||||||
|
EPD_2in13_V3_SendData(0x40); ///RAM Ping-Pong enable
|
||||||
|
EPD_2in13_V3_SendData(0x00);
|
||||||
|
EPD_2in13_V3_SendData(0x00);
|
||||||
|
EPD_2in13_V3_SendData(0x00);
|
||||||
|
EPD_2in13_V3_SendData(0x00);
|
||||||
|
|
||||||
|
EPD_2in13_V3_SendCommand(0x3C); //BorderWavefrom
|
||||||
|
EPD_2in13_V3_SendData(0xC0);
|
||||||
|
|
||||||
|
EPD_2in13_V3_SendCommand(0x22); //Display Update Sequence Option
|
||||||
|
EPD_2in13_V3_SendData(0xC0); // Enable clock and Enable analog
|
||||||
|
EPD_2in13_V3_SendCommand(0x20); //Activate Display Update Sequence
|
||||||
|
EPD_2in13_V3_ReadBusy();
|
||||||
|
|
||||||
|
EPD_2in13_V3_SetWindows(0, 0, EPD_2in13_V3_WIDTH-1, EPD_2in13_V3_HEIGHT-1);
|
||||||
|
EPD_2in13_V3_SetCursor(0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : Clear screen
|
||||||
|
parameter:
|
||||||
|
******************************************************************************/
|
||||||
|
void EPD_2in13_V3_Clear(void)
|
||||||
|
{
|
||||||
|
UWORD Width, Height;
|
||||||
|
Width = (EPD_2in13_V3_WIDTH % 8 == 0)? (EPD_2in13_V3_WIDTH / 8 ): (EPD_2in13_V3_WIDTH / 8 + 1);
|
||||||
|
Height = EPD_2in13_V3_HEIGHT;
|
||||||
|
|
||||||
|
EPD_2in13_V3_SendCommand(0x24);
|
||||||
|
for (UWORD j = 0; j < Height; j++) {
|
||||||
|
for (UWORD i = 0; i < Width; i++) {
|
||||||
|
EPD_2in13_V3_SendData(0XFF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EPD_2in13_V3_TurnOnDisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : Sends the image buffer in RAM to e-Paper and displays
|
||||||
|
parameter:
|
||||||
|
Image : Image data
|
||||||
|
******************************************************************************/
|
||||||
|
void EPD_2in13_V3_Display(UBYTE *Image)
|
||||||
|
{
|
||||||
|
UWORD Width, Height;
|
||||||
|
Width = (EPD_2in13_V3_WIDTH % 8 == 0)? (EPD_2in13_V3_WIDTH / 8 ): (EPD_2in13_V3_WIDTH / 8 + 1);
|
||||||
|
Height = EPD_2in13_V3_HEIGHT;
|
||||||
|
|
||||||
|
EPD_2in13_V3_SendCommand(0x24);
|
||||||
|
for (UWORD j = 0; j < Height; j++) {
|
||||||
|
for (UWORD i = 0; i < Width; i++) {
|
||||||
|
EPD_2in13_V3_SendData(Image[i + j * Width]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EPD_2in13_V3_TurnOnDisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : Refresh a base image
|
||||||
|
parameter:
|
||||||
|
Image : Image data
|
||||||
|
******************************************************************************/
|
||||||
|
void EPD_2in13_V3_Display_Base(UBYTE *Image)
|
||||||
|
{
|
||||||
|
UWORD Width, Height;
|
||||||
|
Width = (EPD_2in13_V3_WIDTH % 8 == 0)? (EPD_2in13_V3_WIDTH / 8 ): (EPD_2in13_V3_WIDTH / 8 + 1);
|
||||||
|
Height = EPD_2in13_V3_HEIGHT;
|
||||||
|
|
||||||
|
EPD_2in13_V3_SendCommand(0x24); //Write Black and White image to RAM
|
||||||
|
// for (UWORD j = 0; j < Height; j++) {
|
||||||
|
// for (UWORD i = 0; i < Width; i++) {
|
||||||
|
// EPD_2in13_V3_SendData(Image[i + j * Width]);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
EPD_2IN13_V3_SendData2(Image, Height*Width);
|
||||||
|
EPD_2in13_V3_SendCommand(0x26); //Write Black and White image to RAM
|
||||||
|
// for (UWORD j = 0; j < Height; j++) {
|
||||||
|
// for (UWORD i = 0; i < Width; i++) {
|
||||||
|
// EPD_2in13_V3_SendData(Image[i + j * Width]);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
EPD_2IN13_V3_SendData2(Image, Height*Width);
|
||||||
|
EPD_2in13_V3_TurnOnDisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : Sends the image buffer in RAM to e-Paper and partial refresh
|
||||||
|
parameter:
|
||||||
|
Image : Image data
|
||||||
|
******************************************************************************/
|
||||||
|
void EPD_2in13_V3_Display_Partial(UBYTE *Image)
|
||||||
|
{
|
||||||
|
UWORD Width, Height;
|
||||||
|
Width = (EPD_2in13_V3_WIDTH % 8 == 0)? (EPD_2in13_V3_WIDTH / 8 ): (EPD_2in13_V3_WIDTH / 8 + 1);
|
||||||
|
Height = EPD_2in13_V3_HEIGHT;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
EPD_2in13_V3_SendCommand(0x24); //Write Black and White image to RAM
|
||||||
|
// for (UWORD j = 0; j < Height; j++) {
|
||||||
|
// for (UWORD i = 0; i < Width; i++) {
|
||||||
|
// EPD_2in13_V3_SendData(Image[i + j * Width]);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
EPD_2IN13_V3_SendData2(Image, Height*Width);
|
||||||
|
EPD_2in13_V3_TurnOnDisplay_Partial();
|
||||||
|
}
|
||||||
|
|
||||||
|
void EPD_2in13_V3_Display_Partial_Wait(UBYTE *Image)
|
||||||
|
{
|
||||||
|
UWORD Width, Height;
|
||||||
|
Width = (EPD_2in13_V3_WIDTH % 8 == 0)? (EPD_2in13_V3_WIDTH / 8 ): (EPD_2in13_V3_WIDTH / 8 + 1);
|
||||||
|
Height = EPD_2in13_V3_HEIGHT;
|
||||||
|
|
||||||
|
// //Reset
|
||||||
|
// DEV_Digital_Write(EPD_RST_PIN, 0);
|
||||||
|
// DEV_Delay_ms(1);
|
||||||
|
// DEV_Digital_Write(EPD_RST_PIN, 1);
|
||||||
|
|
||||||
|
// EPD_2IN13_V2_LUT_by_host(WF_PARTIAL_2IN13_V3);
|
||||||
|
|
||||||
|
// EPD_2in13_V3_SendCommand(0x37);
|
||||||
|
// EPD_2in13_V3_SendData(0x00);
|
||||||
|
// EPD_2in13_V3_SendData(0x00);
|
||||||
|
// EPD_2in13_V3_SendData(0x00);
|
||||||
|
// EPD_2in13_V3_SendData(0x00);
|
||||||
|
// EPD_2in13_V3_SendData(0x00);
|
||||||
|
// EPD_2in13_V3_SendData(0x40); ///RAM Ping-Pong enable
|
||||||
|
// EPD_2in13_V3_SendData(0x00);
|
||||||
|
// EPD_2in13_V3_SendData(0x00);
|
||||||
|
// EPD_2in13_V3_SendData(0x00);
|
||||||
|
// EPD_2in13_V3_SendData(0x00);
|
||||||
|
|
||||||
|
// EPD_2in13_V3_SendCommand(0x3C); //BorderWavefrom
|
||||||
|
// EPD_2in13_V3_SendData(0x80);
|
||||||
|
|
||||||
|
// EPD_2in13_V3_SendCommand(0x22); //Display Update Sequence Option
|
||||||
|
// EPD_2in13_V3_SendData(0xC0); // Enable clock and Enable analog
|
||||||
|
// EPD_2in13_V3_SendCommand(0x20); //Activate Display Update Sequence
|
||||||
|
// EPD_2in13_V3_ReadBusy();
|
||||||
|
|
||||||
|
// EPD_2in13_V3_SetWindows(0, 0, EPD_2in13_V3_WIDTH-1, EPD_2in13_V3_HEIGHT-1);
|
||||||
|
// EPD_2in13_V3_SetCursor(0, 0);
|
||||||
|
|
||||||
|
EPD_2in13_V3_SendCommand(0x24); //Write Black and White image to RAM
|
||||||
|
// for (UWORD j = 0; j < Height; j++) {
|
||||||
|
// for (UWORD i = 0; i < Width; i++) {
|
||||||
|
// EPD_2in13_V3_SendData(Image[i + j * Width]);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
EPD_2IN13_V3_SendData2(Image, Height*Width);
|
||||||
|
EPD_2in13_V3_TurnOnDisplay_Partial_Wait();
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : Enter sleep mode
|
||||||
|
parameter:
|
||||||
|
******************************************************************************/
|
||||||
|
void EPD_2in13_V3_Sleep(void)
|
||||||
|
{
|
||||||
|
EPD_2in13_V3_SendCommand(0x10); //enter deep sleep
|
||||||
|
EPD_2in13_V3_SendData(0x01);
|
||||||
|
DEV_Delay_ms(100);
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : EPD_2Iin13_V3.h
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : 2.13inch e-paper V3
|
||||||
|
* | Info :
|
||||||
|
*----------------
|
||||||
|
* | This version: V1.1
|
||||||
|
* | Date : 2021-10-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.
|
||||||
|
#
|
||||||
|
******************************************************************************/
|
||||||
|
#ifndef __EPD_2in13_V3_H_
|
||||||
|
#define __EPD_2in13_V3_H_
|
||||||
|
|
||||||
|
#include "DEV_Config.h"
|
||||||
|
|
||||||
|
// Display resolution
|
||||||
|
#define EPD_2in13_V3_WIDTH 122
|
||||||
|
#define EPD_2in13_V3_HEIGHT 250
|
||||||
|
|
||||||
|
#define EPD_2IN13_V3_FULL 0
|
||||||
|
#define EPD_2IN13_V3_PART 1
|
||||||
|
|
||||||
|
void EPD_2in13_V3_Init(UBYTE Mode);
|
||||||
|
void EPD_2in13_V3_Clear(void);
|
||||||
|
void EPD_2in13_V3_Display(UBYTE *Image);
|
||||||
|
void EPD_2in13_V3_Display_Base(UBYTE *Image);
|
||||||
|
void EPD_2in13_V3_Display_Partial(UBYTE *Image);
|
||||||
|
void EPD_2in13_V3_Display_Partial_Wait(UBYTE *Image);
|
||||||
|
void EPD_2in13_V3_Sleep(void);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,433 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : EPD_2in13_V4.c
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : 2.13inch e-paper V4
|
||||||
|
* | 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_2in13_V4.h"
|
||||||
|
#include "Debug.h"
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : Software reset
|
||||||
|
parameter:
|
||||||
|
******************************************************************************/
|
||||||
|
static void EPD_2in13_V4_Reset(void)
|
||||||
|
{
|
||||||
|
DEV_Digital_Write(EPD_RST_PIN, 1);
|
||||||
|
DEV_Delay_ms(20);
|
||||||
|
DEV_Digital_Write(EPD_RST_PIN, 0);
|
||||||
|
DEV_Delay_ms(2);
|
||||||
|
DEV_Digital_Write(EPD_RST_PIN, 1);
|
||||||
|
DEV_Delay_ms(20);
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : send command
|
||||||
|
parameter:
|
||||||
|
Reg : Command register
|
||||||
|
******************************************************************************/
|
||||||
|
static void EPD_2in13_V4_SendCommand(UBYTE Reg)
|
||||||
|
{
|
||||||
|
DEV_Digital_Write(EPD_DC_PIN, 0);
|
||||||
|
DEV_Digital_Write(EPD_CS_PIN, 0);
|
||||||
|
DEV_SPI_WriteByte(Reg);
|
||||||
|
DEV_Digital_Write(EPD_CS_PIN, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : send data
|
||||||
|
parameter:
|
||||||
|
Data : Write data
|
||||||
|
******************************************************************************/
|
||||||
|
static void EPD_2in13_V4_SendData(UBYTE Data)
|
||||||
|
{
|
||||||
|
DEV_Digital_Write(EPD_DC_PIN, 1);
|
||||||
|
DEV_Digital_Write(EPD_CS_PIN, 0);
|
||||||
|
DEV_SPI_WriteByte(Data);
|
||||||
|
DEV_Digital_Write(EPD_CS_PIN, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void EPD_2IN13_V4_SendData2(UBYTE *Data, UDOUBLE len)
|
||||||
|
{
|
||||||
|
DEV_Digital_Write(EPD_DC_PIN, 1);
|
||||||
|
DEV_Digital_Write(EPD_CS_PIN, 0);
|
||||||
|
DEV_SPI_Write_nByte(Data, len);
|
||||||
|
DEV_Digital_Write(EPD_CS_PIN, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : Wait until the busy_pin goes LOW
|
||||||
|
parameter:
|
||||||
|
******************************************************************************/
|
||||||
|
void EPD_2in13_V4_ReadBusy(void)
|
||||||
|
{
|
||||||
|
Debug("e-Paper busy\r\n");
|
||||||
|
while(1)
|
||||||
|
{ //=1 BUSY
|
||||||
|
if(DEV_Digital_Read(EPD_BUSY_PIN)==0)
|
||||||
|
break;
|
||||||
|
DEV_Delay_ms(10);
|
||||||
|
}
|
||||||
|
DEV_Delay_ms(10);
|
||||||
|
Debug("e-Paper busy release\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : Setting the display window
|
||||||
|
parameter:
|
||||||
|
Xstart : X-axis starting position
|
||||||
|
Ystart : Y-axis starting position
|
||||||
|
Xend : End position of X-axis
|
||||||
|
Yend : End position of Y-axis
|
||||||
|
******************************************************************************/
|
||||||
|
static void EPD_2in13_V4_SetWindows(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend)
|
||||||
|
{
|
||||||
|
EPD_2in13_V4_SendCommand(0x44); // SET_RAM_X_ADDRESS_START_END_POSITION
|
||||||
|
EPD_2in13_V4_SendData((Xstart>>3) & 0xFF);
|
||||||
|
EPD_2in13_V4_SendData((Xend>>3) & 0xFF);
|
||||||
|
|
||||||
|
EPD_2in13_V4_SendCommand(0x45); // SET_RAM_Y_ADDRESS_START_END_POSITION
|
||||||
|
EPD_2in13_V4_SendData(Ystart & 0xFF);
|
||||||
|
EPD_2in13_V4_SendData((Ystart >> 8) & 0xFF);
|
||||||
|
EPD_2in13_V4_SendData(Yend & 0xFF);
|
||||||
|
EPD_2in13_V4_SendData((Yend >> 8) & 0xFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : Set Cursor
|
||||||
|
parameter:
|
||||||
|
Xstart : X-axis starting position
|
||||||
|
Ystart : Y-axis starting position
|
||||||
|
******************************************************************************/
|
||||||
|
static void EPD_2in13_V4_SetCursor(UWORD Xstart, UWORD Ystart)
|
||||||
|
{
|
||||||
|
EPD_2in13_V4_SendCommand(0x4E); // SET_RAM_X_ADDRESS_COUNTER
|
||||||
|
EPD_2in13_V4_SendData(Xstart & 0xFF);
|
||||||
|
|
||||||
|
EPD_2in13_V4_SendCommand(0x4F); // SET_RAM_Y_ADDRESS_COUNTER
|
||||||
|
EPD_2in13_V4_SendData(Ystart & 0xFF);
|
||||||
|
EPD_2in13_V4_SendData((Ystart >> 8) & 0xFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : Turn On Display
|
||||||
|
parameter:
|
||||||
|
******************************************************************************/
|
||||||
|
static void EPD_2in13_V4_TurnOnDisplay(void)
|
||||||
|
{
|
||||||
|
EPD_2in13_V4_SendCommand(0x22); // Display Update Control
|
||||||
|
EPD_2in13_V4_SendData(0xf7);
|
||||||
|
EPD_2in13_V4_SendCommand(0x20); // Activate Display Update Sequence
|
||||||
|
EPD_2in13_V4_ReadBusy();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void EPD_2in13_V4_TurnOnDisplay_Fast(void)
|
||||||
|
{
|
||||||
|
EPD_2in13_V4_SendCommand(0x22); // Display Update Control
|
||||||
|
EPD_2in13_V4_SendData(0xc7); // fast:0x0c, quality:0x0f, 0xcf
|
||||||
|
EPD_2in13_V4_SendCommand(0x20); // Activate Display Update Sequence
|
||||||
|
EPD_2in13_V4_ReadBusy();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void EPD_2in13_V4_TurnOnDisplay_Partial(void)
|
||||||
|
{
|
||||||
|
EPD_2in13_V4_SendCommand(0x22); // Display Update Control
|
||||||
|
EPD_2in13_V4_SendData(0xff); // fast:0x0c, quality:0x0f, 0xcf
|
||||||
|
EPD_2in13_V4_SendCommand(0x20); // Activate Display Update Sequence
|
||||||
|
// EPD_2in13_V4_ReadBusy();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void EPD_2in13_V4_TurnOnDisplay_Partial_Wait(void)
|
||||||
|
{
|
||||||
|
EPD_2in13_V4_SendCommand(0x22); // Display Update Control
|
||||||
|
EPD_2in13_V4_SendData(0xff); // fast:0x0c, quality:0x0f, 0xcf
|
||||||
|
EPD_2in13_V4_SendCommand(0x20); // Activate Display Update Sequence
|
||||||
|
EPD_2in13_V4_ReadBusy();
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : Initialize the e-Paper register
|
||||||
|
parameter:
|
||||||
|
******************************************************************************/
|
||||||
|
void EPD_2in13_V4_Init(UBYTE Mode)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
if(Mode == EPD_2IN13_V4_FULL)
|
||||||
|
{
|
||||||
|
EPD_2in13_V4_Reset();
|
||||||
|
EPD_2in13_V4_ReadBusy();
|
||||||
|
EPD_2in13_V4_SendCommand(0x12); //SWRESET
|
||||||
|
EPD_2in13_V4_ReadBusy();
|
||||||
|
|
||||||
|
EPD_2in13_V4_SendCommand(0x01); //Driver output control
|
||||||
|
EPD_2in13_V4_SendData(0xF9);
|
||||||
|
EPD_2in13_V4_SendData(0x00);
|
||||||
|
EPD_2in13_V4_SendData(0x00);
|
||||||
|
|
||||||
|
EPD_2in13_V4_SendCommand(0x11); //data entry mode
|
||||||
|
EPD_2in13_V4_SendData(0x03);
|
||||||
|
|
||||||
|
EPD_2in13_V4_SetWindows(0, 0, EPD_2in13_V4_WIDTH-1, EPD_2in13_V4_HEIGHT-1);
|
||||||
|
EPD_2in13_V4_SetCursor(0, 0);
|
||||||
|
|
||||||
|
EPD_2in13_V4_SendCommand(0x3C); //BorderWavefrom
|
||||||
|
EPD_2in13_V4_SendData(0x05);
|
||||||
|
|
||||||
|
EPD_2in13_V4_SendCommand(0x21); // Display update control
|
||||||
|
EPD_2in13_V4_SendData(0x00);
|
||||||
|
EPD_2in13_V4_SendData(0x80);
|
||||||
|
|
||||||
|
EPD_2in13_V4_SendCommand(0x18); //Read built-in temperature sensor
|
||||||
|
EPD_2in13_V4_SendData(0x80);
|
||||||
|
EPD_2in13_V4_ReadBusy();
|
||||||
|
}
|
||||||
|
else if(Mode == EPD_2IN13_V4_PART)
|
||||||
|
{
|
||||||
|
//Reset
|
||||||
|
DEV_Digital_Write(EPD_RST_PIN, 0);
|
||||||
|
DEV_Delay_ms(1);
|
||||||
|
DEV_Digital_Write(EPD_RST_PIN, 1);
|
||||||
|
|
||||||
|
EPD_2in13_V4_SendCommand(0x3C); //BorderWavefrom
|
||||||
|
EPD_2in13_V4_SendData(0x80);
|
||||||
|
|
||||||
|
EPD_2in13_V4_SendCommand(0x01); //Driver output control
|
||||||
|
EPD_2in13_V4_SendData(0xF9);
|
||||||
|
EPD_2in13_V4_SendData(0x00);
|
||||||
|
EPD_2in13_V4_SendData(0x00);
|
||||||
|
|
||||||
|
EPD_2in13_V4_SendCommand(0x11); //data entry mode
|
||||||
|
EPD_2in13_V4_SendData(0x03);
|
||||||
|
|
||||||
|
EPD_2in13_V4_SetWindows(0, 0, EPD_2in13_V4_WIDTH-1, EPD_2in13_V4_HEIGHT-1);
|
||||||
|
EPD_2in13_V4_SetCursor(0, 0);
|
||||||
|
}
|
||||||
|
else if(Mode == EPD_2IN13_V4_Fast)
|
||||||
|
{
|
||||||
|
EPD_2in13_V4_Reset();
|
||||||
|
EPD_2in13_V4_ReadBusy();
|
||||||
|
EPD_2in13_V4_SendCommand(0x12); //SWRESET
|
||||||
|
EPD_2in13_V4_ReadBusy();
|
||||||
|
|
||||||
|
EPD_2in13_V4_SendCommand(0x18); //Read built-in temperature sensor
|
||||||
|
EPD_2in13_V4_SendData(0x80);
|
||||||
|
|
||||||
|
EPD_2in13_V4_SendCommand(0x11); //data entry mode
|
||||||
|
EPD_2in13_V4_SendData(0x03);
|
||||||
|
|
||||||
|
EPD_2in13_V4_SetWindows(0, 0, EPD_2in13_V4_WIDTH-1, EPD_2in13_V4_HEIGHT-1);
|
||||||
|
EPD_2in13_V4_SetCursor(0, 0);
|
||||||
|
|
||||||
|
EPD_2in13_V4_SendCommand(0x22); // Load temperature value
|
||||||
|
EPD_2in13_V4_SendData(0xB1);
|
||||||
|
EPD_2in13_V4_SendCommand(0x20);
|
||||||
|
EPD_2in13_V4_ReadBusy();
|
||||||
|
|
||||||
|
EPD_2in13_V4_SendCommand(0x1A); // Write to temperature register
|
||||||
|
EPD_2in13_V4_SendData(0x64);
|
||||||
|
EPD_2in13_V4_SendData(0x00);
|
||||||
|
|
||||||
|
EPD_2in13_V4_SendCommand(0x22); // Load temperature value
|
||||||
|
EPD_2in13_V4_SendData(0x91);
|
||||||
|
EPD_2in13_V4_SendCommand(0x20);
|
||||||
|
EPD_2in13_V4_ReadBusy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : Clear screen
|
||||||
|
parameter:
|
||||||
|
******************************************************************************/
|
||||||
|
void EPD_2in13_V4_Clear(void)
|
||||||
|
{
|
||||||
|
UWORD Width, Height;
|
||||||
|
Width = (EPD_2in13_V4_WIDTH % 8 == 0)? (EPD_2in13_V4_WIDTH / 8 ): (EPD_2in13_V4_WIDTH / 8 + 1);
|
||||||
|
Height = EPD_2in13_V4_HEIGHT;
|
||||||
|
|
||||||
|
EPD_2in13_V4_SendCommand(0x24);
|
||||||
|
for (UWORD j = 0; j < Height; j++) {
|
||||||
|
for (UWORD i = 0; i < Width; i++) {
|
||||||
|
EPD_2in13_V4_SendData(0XFF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EPD_2in13_V4_TurnOnDisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
void EPD_2in13_V4_Clear_Black(void)
|
||||||
|
{
|
||||||
|
UWORD Width, Height;
|
||||||
|
Width = (EPD_2in13_V4_WIDTH % 8 == 0)? (EPD_2in13_V4_WIDTH / 8 ): (EPD_2in13_V4_WIDTH / 8 + 1);
|
||||||
|
Height = EPD_2in13_V4_HEIGHT;
|
||||||
|
|
||||||
|
EPD_2in13_V4_SendCommand(0x24);
|
||||||
|
for (UWORD j = 0; j < Height; j++) {
|
||||||
|
for (UWORD i = 0; i < Width; i++) {
|
||||||
|
EPD_2in13_V4_SendData(0X00);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EPD_2in13_V4_TurnOnDisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : Sends the image buffer in RAM to e-Paper and displays
|
||||||
|
parameter:
|
||||||
|
Image : Image data
|
||||||
|
******************************************************************************/
|
||||||
|
void EPD_2in13_V4_Display(UBYTE *Image)
|
||||||
|
{
|
||||||
|
UWORD Width, Height;
|
||||||
|
Width = (EPD_2in13_V4_WIDTH % 8 == 0)? (EPD_2in13_V4_WIDTH / 8 ): (EPD_2in13_V4_WIDTH / 8 + 1);
|
||||||
|
Height = EPD_2in13_V4_HEIGHT;
|
||||||
|
|
||||||
|
EPD_2in13_V4_SendCommand(0x24);
|
||||||
|
for (UWORD j = 0; j < Height; j++) {
|
||||||
|
for (UWORD i = 0; i < Width; i++) {
|
||||||
|
EPD_2in13_V4_SendData(Image[i + j * Width]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EPD_2in13_V4_TurnOnDisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
void EPD_2in13_V4_Display_Fast(UBYTE *Image)
|
||||||
|
{
|
||||||
|
UWORD Width, Height;
|
||||||
|
Width = (EPD_2in13_V4_WIDTH % 8 == 0)? (EPD_2in13_V4_WIDTH / 8 ): (EPD_2in13_V4_WIDTH / 8 + 1);
|
||||||
|
Height = EPD_2in13_V4_HEIGHT;
|
||||||
|
|
||||||
|
EPD_2in13_V4_SendCommand(0x24);
|
||||||
|
for (UWORD j = 0; j < Height; j++) {
|
||||||
|
for (UWORD i = 0; i < Width; i++) {
|
||||||
|
EPD_2in13_V4_SendData(Image[i + j * Width]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EPD_2in13_V4_TurnOnDisplay_Fast();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : Refresh a base image
|
||||||
|
parameter:
|
||||||
|
Image : Image data
|
||||||
|
******************************************************************************/
|
||||||
|
void EPD_2in13_V4_Display_Base(UBYTE *Image)
|
||||||
|
{
|
||||||
|
UWORD Width, Height;
|
||||||
|
Width = (EPD_2in13_V4_WIDTH % 8 == 0)? (EPD_2in13_V4_WIDTH / 8 ): (EPD_2in13_V4_WIDTH / 8 + 1);
|
||||||
|
Height = EPD_2in13_V4_HEIGHT;
|
||||||
|
|
||||||
|
EPD_2in13_V4_SendCommand(0x24); //Write Black and White image to RAM
|
||||||
|
EPD_2IN13_V4_SendData2(Image, Width*Height);
|
||||||
|
|
||||||
|
EPD_2in13_V4_SendCommand(0x26); //Write Black and White image to RAM
|
||||||
|
EPD_2IN13_V4_SendData2(Image, Width*Height);
|
||||||
|
EPD_2in13_V4_TurnOnDisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : Sends the image buffer in RAM to e-Paper and partial refresh
|
||||||
|
parameter:
|
||||||
|
Image : Image data
|
||||||
|
******************************************************************************/
|
||||||
|
void EPD_2in13_V4_Display_Partial(UBYTE *Image)
|
||||||
|
{
|
||||||
|
UWORD Width, Height;
|
||||||
|
Width = (EPD_2in13_V4_WIDTH % 8 == 0)? (EPD_2in13_V4_WIDTH / 8 ): (EPD_2in13_V4_WIDTH / 8 + 1);
|
||||||
|
Height = EPD_2in13_V4_HEIGHT;
|
||||||
|
|
||||||
|
printf("1111/r/n");
|
||||||
|
|
||||||
|
//Reset
|
||||||
|
DEV_Digital_Write(EPD_RST_PIN, 0);
|
||||||
|
DEV_Delay_ms(1);
|
||||||
|
DEV_Digital_Write(EPD_RST_PIN, 1);
|
||||||
|
|
||||||
|
EPD_2in13_V4_SendCommand(0x3C); //BorderWavefrom
|
||||||
|
EPD_2in13_V4_SendData(0x80);
|
||||||
|
|
||||||
|
EPD_2in13_V4_SendCommand(0x01); //Driver output control
|
||||||
|
EPD_2in13_V4_SendData(0xF9);
|
||||||
|
EPD_2in13_V4_SendData(0x00);
|
||||||
|
EPD_2in13_V4_SendData(0x00);
|
||||||
|
|
||||||
|
EPD_2in13_V4_SendCommand(0x11); //data entry mode
|
||||||
|
EPD_2in13_V4_SendData(0x03);
|
||||||
|
|
||||||
|
EPD_2in13_V4_SetWindows(0, 0, EPD_2in13_V4_WIDTH-1, EPD_2in13_V4_HEIGHT-1);
|
||||||
|
EPD_2in13_V4_SetCursor(0, 0);
|
||||||
|
|
||||||
|
EPD_2in13_V4_SendCommand(0x24); //Write Black and White image to RAM
|
||||||
|
EPD_2IN13_V4_SendData2(Image, Width*Height);
|
||||||
|
EPD_2in13_V4_TurnOnDisplay_Partial();
|
||||||
|
}
|
||||||
|
|
||||||
|
void EPD_2in13_V4_Display_Partial_Wait(UBYTE *Image)
|
||||||
|
{
|
||||||
|
UWORD Width, Height;
|
||||||
|
Width = (EPD_2in13_V4_WIDTH % 8 == 0)? (EPD_2in13_V4_WIDTH / 8 ): (EPD_2in13_V4_WIDTH / 8 + 1);
|
||||||
|
Height = EPD_2in13_V4_HEIGHT;
|
||||||
|
|
||||||
|
EPD_2in13_V4_ReadBusy();
|
||||||
|
|
||||||
|
//Reset
|
||||||
|
DEV_Digital_Write(EPD_RST_PIN, 0);
|
||||||
|
DEV_Delay_ms(1);
|
||||||
|
DEV_Digital_Write(EPD_RST_PIN, 1);
|
||||||
|
|
||||||
|
EPD_2in13_V4_SendCommand(0x3C); //BorderWavefrom
|
||||||
|
EPD_2in13_V4_SendData(0x80);
|
||||||
|
|
||||||
|
EPD_2in13_V4_SendCommand(0x01); //Driver output control
|
||||||
|
EPD_2in13_V4_SendData(0xF9);
|
||||||
|
EPD_2in13_V4_SendData(0x00);
|
||||||
|
EPD_2in13_V4_SendData(0x00);
|
||||||
|
|
||||||
|
EPD_2in13_V4_SendCommand(0x11); //data entry mode
|
||||||
|
EPD_2in13_V4_SendData(0x03);
|
||||||
|
|
||||||
|
EPD_2in13_V4_SetWindows(0, 0, EPD_2in13_V4_WIDTH-1, EPD_2in13_V4_HEIGHT-1);
|
||||||
|
EPD_2in13_V4_SetCursor(0, 0);
|
||||||
|
|
||||||
|
EPD_2in13_V4_SendCommand(0x24); //Write Black and White image to RAM
|
||||||
|
EPD_2IN13_V4_SendData2(Image, Width*Height);
|
||||||
|
EPD_2in13_V4_TurnOnDisplay_Partial_Wait();
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : Enter sleep mode
|
||||||
|
parameter:
|
||||||
|
******************************************************************************/
|
||||||
|
void EPD_2in13_V4_Sleep(void)
|
||||||
|
{
|
||||||
|
EPD_2in13_V4_SendCommand(0x10); //enter deep sleep
|
||||||
|
EPD_2in13_V4_SendData(0x01);
|
||||||
|
DEV_Delay_ms(100);
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : EPD_2Iin13_V4.h
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : 2.13inch e-paper V4
|
||||||
|
* | 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.
|
||||||
|
#
|
||||||
|
******************************************************************************/
|
||||||
|
#ifndef __EPD_2in13_V4_H_
|
||||||
|
#define __EPD_2in13_V4_H_
|
||||||
|
|
||||||
|
#include "DEV_Config.h"
|
||||||
|
|
||||||
|
|
||||||
|
// Display resolution
|
||||||
|
#define EPD_2in13_V4_WIDTH 122
|
||||||
|
#define EPD_2in13_V4_HEIGHT 250
|
||||||
|
|
||||||
|
#define EPD_2IN13_V4_FULL 0
|
||||||
|
#define EPD_2IN13_V4_PART 1
|
||||||
|
#define EPD_2IN13_V4_Fast 2
|
||||||
|
|
||||||
|
void EPD_2in13_V4_Init(UBYTE Mode);
|
||||||
|
void EPD_2in13_V4_Clear(void);
|
||||||
|
void EPD_2in13_V4_Clear_Black(void);
|
||||||
|
void EPD_2in13_V4_Display(UBYTE *Image);
|
||||||
|
void EPD_2in13_V4_Display_Fast(UBYTE *Image);
|
||||||
|
void EPD_2in13_V4_Display_Base(UBYTE *Image);
|
||||||
|
void EPD_2in13_V4_Display_Partial(UBYTE *Image);
|
||||||
|
void EPD_2in13_V4_Display_Partial_Wait(UBYTE *Image);
|
||||||
|
void EPD_2in13_V4_Sleep(void);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,615 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : EPD_2in9_V2.c
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : 2.9inch e-paper V2
|
||||||
|
* | 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_2in9_V2.h"
|
||||||
|
#include "Debug.h"
|
||||||
|
|
||||||
|
UBYTE _WF_PARTIAL_2IN9[159] =
|
||||||
|
{
|
||||||
|
0x0,0x40,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||||
|
0x80,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||||
|
0x40,0x40,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||||
|
0x0,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||||
|
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||||
|
0x0A,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||||
|
0x1,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||||
|
0x1,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||||
|
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||||
|
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||||
|
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||||
|
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||||
|
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||||
|
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||||
|
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||||
|
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||||
|
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||||
|
0x22,0x22,0x22,0x22,0x22,0x22,0x0,0x0,0x0,
|
||||||
|
0x22,0x17,0x41,0xB0,0x32,0x36,
|
||||||
|
};
|
||||||
|
|
||||||
|
UBYTE _WF_PARTIAL_2IN9_Wait[159] =
|
||||||
|
{
|
||||||
|
0x0,0x40,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||||
|
0x80,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||||
|
0x40,0x40,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||||
|
0x0,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||||
|
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||||
|
0x0A,0x0,0x0,0x0,0x0,0x0,0x2,
|
||||||
|
0x1,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||||
|
0x1,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||||
|
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||||
|
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||||
|
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||||
|
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||||
|
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||||
|
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||||
|
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||||
|
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||||
|
0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||||
|
0x22,0x22,0x22,0x22,0x22,0x22,0x0,0x0,0x0,
|
||||||
|
0x22,0x17,0x41,0xB0,0x32,0x36,
|
||||||
|
};
|
||||||
|
|
||||||
|
unsigned char Gray4[159] =
|
||||||
|
{
|
||||||
|
0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //VS L0 //2.28s
|
||||||
|
0x20, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //VS L1
|
||||||
|
0x28, 0x60, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //VS L2
|
||||||
|
0x2A, 0x60, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //VS L3
|
||||||
|
0x00, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //VS L4
|
||||||
|
0x00, 0x02, 0x00, 0x05, 0x14, 0x00, 0x00, //TP, SR, RP of Group0
|
||||||
|
0x1E, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x01, //TP, SR, RP of Group1
|
||||||
|
0x00, 0x02, 0x00, 0x05, 0x14, 0x00, 0x00, //TP, SR, RP of Group2
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //TP, SR, RP of Group3
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //TP, SR, RP of Group4
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //TP, SR, RP of Group5
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //TP, SR, RP of Group6
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //TP, SR, RP of Group7
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //TP, SR, RP of Group8
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //TP, SR, RP of Group9
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //TP, SR, RP of Group10
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //TP, SR, RP of Group11
|
||||||
|
0x24, 0x22, 0x22, 0x22, 0x23, 0x32, 0x00, 0x00, 0x00, //FR, XON
|
||||||
|
0x22, 0x17, 0x41, 0xAE, 0x32, 0x28, //EOPT VGH VSH1 VSH2 VSL VCOM
|
||||||
|
};
|
||||||
|
|
||||||
|
unsigned char WF_FULL[159] =
|
||||||
|
{
|
||||||
|
0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //VS L0 1.00S
|
||||||
|
0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //VS L1
|
||||||
|
0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //VS L2
|
||||||
|
0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //VS L3
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //VS L4
|
||||||
|
0x19, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, //TP, SR, RP of Group0
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //TP, SR, RP of Group1
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //TP, SR, RP of Group2
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //TP, SR, RP of Group3
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //TP, SR, RP of Group4
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //TP, SR, RP of Group5
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //TP, SR, RP of Group6
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //TP, SR, RP of Group7
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //TP, SR, RP of Group8
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //TP, SR, RP of Group9
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //TP, SR, RP of Group10
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //TP, SR, RP of Group11
|
||||||
|
0x24, 0x42, 0x22, 0x22, 0x23, 0x32, 0x00, 0x00, 0x00, //FR, XON
|
||||||
|
0x22, 0x17, 0x41, 0xAE, 0x32, 0x38, //EOPT VGH VSH1 VSH2 VSL VCOM
|
||||||
|
};
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : Software reset
|
||||||
|
parameter:
|
||||||
|
******************************************************************************/
|
||||||
|
static void EPD_2IN9_V2_Reset(void)
|
||||||
|
{
|
||||||
|
DEV_Digital_Write(EPD_RST_PIN, 1);
|
||||||
|
DEV_Delay_ms(20);
|
||||||
|
DEV_Digital_Write(EPD_RST_PIN, 0);
|
||||||
|
DEV_Delay_ms(2);
|
||||||
|
DEV_Digital_Write(EPD_RST_PIN, 1);
|
||||||
|
DEV_Delay_ms(20);
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : send command
|
||||||
|
parameter:
|
||||||
|
Reg : Command register
|
||||||
|
******************************************************************************/
|
||||||
|
static void EPD_2IN9_V2_SendCommand(UBYTE Reg)
|
||||||
|
{
|
||||||
|
DEV_Digital_Write(EPD_DC_PIN, 0);
|
||||||
|
DEV_Digital_Write(EPD_CS_PIN, 0);
|
||||||
|
DEV_SPI_WriteByte(Reg);
|
||||||
|
DEV_Digital_Write(EPD_CS_PIN, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : send data
|
||||||
|
parameter:
|
||||||
|
Data : Write data
|
||||||
|
******************************************************************************/
|
||||||
|
static void EPD_2IN9_V2_SendData(UBYTE Data)
|
||||||
|
{
|
||||||
|
DEV_Digital_Write(EPD_DC_PIN, 1);
|
||||||
|
DEV_Digital_Write(EPD_CS_PIN, 0);
|
||||||
|
DEV_SPI_WriteByte(Data);
|
||||||
|
DEV_Digital_Write(EPD_CS_PIN, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void EPD_2IN9_V2_SendData2(UBYTE *Data, UDOUBLE len)
|
||||||
|
{
|
||||||
|
DEV_Digital_Write(EPD_DC_PIN, 1);
|
||||||
|
DEV_Digital_Write(EPD_CS_PIN, 0);
|
||||||
|
DEV_SPI_Write_nByte(Data, len);
|
||||||
|
DEV_Digital_Write(EPD_CS_PIN, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : Wait until the busy_pin goes LOW
|
||||||
|
parameter:
|
||||||
|
******************************************************************************/
|
||||||
|
void EPD_2IN9_V2_ReadBusy(void)
|
||||||
|
{
|
||||||
|
// Debug("e-Paper busy\r\n");
|
||||||
|
while(1)
|
||||||
|
{ //=1 BUSY
|
||||||
|
if(DEV_Digital_Read(EPD_BUSY_PIN)==0)
|
||||||
|
break;
|
||||||
|
DEV_Delay_ms(0.01);
|
||||||
|
}
|
||||||
|
// DEV_Delay_ms(10);
|
||||||
|
// Debug("e-Paper busy release\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void EPD_2IN9_V2_LUT(UBYTE LUT)
|
||||||
|
{
|
||||||
|
EPD_2IN9_V2_SendCommand(0x32);
|
||||||
|
if(LUT)
|
||||||
|
EPD_2IN9_V2_SendData2(_WF_PARTIAL_2IN9, 159);
|
||||||
|
else
|
||||||
|
EPD_2IN9_V2_SendData2(_WF_PARTIAL_2IN9_Wait, 159);
|
||||||
|
EPD_2IN9_V2_ReadBusy();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void EPD_2IN9_V2_LUT_by_host(UBYTE *lut)
|
||||||
|
{
|
||||||
|
UBYTE count;
|
||||||
|
EPD_2IN9_V2_SendCommand(0x32);
|
||||||
|
for(count=0; count<153; count++)
|
||||||
|
EPD_2IN9_V2_SendData(*lut++);
|
||||||
|
EPD_2IN9_V2_ReadBusy();
|
||||||
|
|
||||||
|
EPD_2IN9_V2_SendCommand(0x3f);
|
||||||
|
EPD_2IN9_V2_SendData(*lut++);
|
||||||
|
EPD_2IN9_V2_SendCommand(0x03); // gate voltage
|
||||||
|
EPD_2IN9_V2_SendData(*lut++);
|
||||||
|
EPD_2IN9_V2_SendCommand(0x04); // source voltage
|
||||||
|
EPD_2IN9_V2_SendData(*lut++); // VSH
|
||||||
|
EPD_2IN9_V2_SendData(*lut++); // VSH2
|
||||||
|
EPD_2IN9_V2_SendData(*lut++); // VSL
|
||||||
|
EPD_2IN9_V2_SendCommand(0x2c); // VCOM
|
||||||
|
EPD_2IN9_V2_SendData(*lut++);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : Turn On Display
|
||||||
|
parameter:
|
||||||
|
******************************************************************************/
|
||||||
|
static void EPD_2IN9_V2_TurnOnDisplay(void)
|
||||||
|
{
|
||||||
|
EPD_2IN9_V2_SendCommand(0x22); //Display Update Control
|
||||||
|
EPD_2IN9_V2_SendData(0xF7);
|
||||||
|
EPD_2IN9_V2_SendCommand(0x20); //Activate Display Update Sequence
|
||||||
|
EPD_2IN9_V2_ReadBusy();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void EPD_2IN9_V2_TurnOnDisplay_Partial(void)
|
||||||
|
{
|
||||||
|
EPD_2IN9_V2_SendCommand(0x22); //Display Update Control
|
||||||
|
EPD_2IN9_V2_SendData(0x0F);
|
||||||
|
EPD_2IN9_V2_SendCommand(0x20); //Activate Display Update Sequence
|
||||||
|
// EPD_2IN9_V2_ReadBusy();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void EPD_2IN9_V2_TurnOnDisplay_Partial_Wait(void)
|
||||||
|
{
|
||||||
|
EPD_2IN9_V2_SendCommand(0x22); //Display Update Control
|
||||||
|
EPD_2IN9_V2_SendData(0x0F);
|
||||||
|
EPD_2IN9_V2_SendCommand(0x20); //Activate Display Update Sequence
|
||||||
|
EPD_2IN9_V2_ReadBusy();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void EPD_2IN9_V2_TurnOnDisplay_Gray4(void)
|
||||||
|
{
|
||||||
|
EPD_2IN9_V2_SendCommand(0x22); //Display Update Control
|
||||||
|
EPD_2IN9_V2_SendData(0xC7);
|
||||||
|
EPD_2IN9_V2_SendCommand(0x20); //Activate Display Update Sequence
|
||||||
|
EPD_2IN9_V2_ReadBusy();
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : Setting the display window
|
||||||
|
parameter:
|
||||||
|
******************************************************************************/
|
||||||
|
static void EPD_2IN9_V2_SetWindows(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend)
|
||||||
|
{
|
||||||
|
EPD_2IN9_V2_SendCommand(0x44); // SET_RAM_X_ADDRESS_START_END_POSITION
|
||||||
|
EPD_2IN9_V2_SendData((Xstart>>3) & 0xFF);
|
||||||
|
EPD_2IN9_V2_SendData((Xend>>3) & 0xFF);
|
||||||
|
|
||||||
|
EPD_2IN9_V2_SendCommand(0x45); // SET_RAM_Y_ADDRESS_START_END_POSITION
|
||||||
|
EPD_2IN9_V2_SendData(Ystart & 0xFF);
|
||||||
|
EPD_2IN9_V2_SendData((Ystart >> 8) & 0xFF);
|
||||||
|
EPD_2IN9_V2_SendData(Yend & 0xFF);
|
||||||
|
EPD_2IN9_V2_SendData((Yend >> 8) & 0xFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : Set Cursor
|
||||||
|
parameter:
|
||||||
|
******************************************************************************/
|
||||||
|
static void EPD_2IN9_V2_SetCursor(UWORD Xstart, UWORD Ystart)
|
||||||
|
{
|
||||||
|
EPD_2IN9_V2_SendCommand(0x4E); // SET_RAM_X_ADDRESS_COUNTER
|
||||||
|
EPD_2IN9_V2_SendData(Xstart & 0xFF);
|
||||||
|
|
||||||
|
EPD_2IN9_V2_SendCommand(0x4F); // SET_RAM_Y_ADDRESS_COUNTER
|
||||||
|
EPD_2IN9_V2_SendData(Ystart & 0xFF);
|
||||||
|
EPD_2IN9_V2_SendData((Ystart >> 8) & 0xFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : Initialize the e-Paper register
|
||||||
|
parameter:
|
||||||
|
******************************************************************************/
|
||||||
|
void EPD_2IN9_V2_Init(void)
|
||||||
|
{
|
||||||
|
EPD_2IN9_V2_Reset();
|
||||||
|
DEV_Delay_ms(100);
|
||||||
|
|
||||||
|
EPD_2IN9_V2_ReadBusy();
|
||||||
|
EPD_2IN9_V2_SendCommand(0x12); // soft reset
|
||||||
|
EPD_2IN9_V2_ReadBusy();
|
||||||
|
|
||||||
|
EPD_2IN9_V2_SendCommand(0x01); //Driver output control
|
||||||
|
EPD_2IN9_V2_SendData(0x27);
|
||||||
|
EPD_2IN9_V2_SendData(0x01);
|
||||||
|
EPD_2IN9_V2_SendData(0x00);
|
||||||
|
|
||||||
|
EPD_2IN9_V2_SendCommand(0x11); //data entry mode
|
||||||
|
EPD_2IN9_V2_SendData(0x03);
|
||||||
|
|
||||||
|
EPD_2IN9_V2_SetWindows(0, 0, EPD_2IN9_V2_WIDTH-1, EPD_2IN9_V2_HEIGHT-1);
|
||||||
|
|
||||||
|
EPD_2IN9_V2_SendCommand(0x21); // Display update control
|
||||||
|
EPD_2IN9_V2_SendData(0x00);
|
||||||
|
EPD_2IN9_V2_SendData(0x80);
|
||||||
|
|
||||||
|
EPD_2IN9_V2_SetCursor(0, 0);
|
||||||
|
EPD_2IN9_V2_ReadBusy();
|
||||||
|
}
|
||||||
|
|
||||||
|
void EPD_2IN9_V2_Init_Fast(void)
|
||||||
|
{
|
||||||
|
EPD_2IN9_V2_Reset();
|
||||||
|
DEV_Delay_ms(100);
|
||||||
|
|
||||||
|
EPD_2IN9_V2_ReadBusy();
|
||||||
|
EPD_2IN9_V2_SendCommand(0x12); // soft reset
|
||||||
|
EPD_2IN9_V2_ReadBusy();
|
||||||
|
|
||||||
|
EPD_2IN9_V2_SendCommand(0x01); //Driver output control
|
||||||
|
EPD_2IN9_V2_SendData(0x27);
|
||||||
|
EPD_2IN9_V2_SendData(0x01);
|
||||||
|
EPD_2IN9_V2_SendData(0x00);
|
||||||
|
|
||||||
|
EPD_2IN9_V2_SendCommand(0x11); //data entry mode
|
||||||
|
EPD_2IN9_V2_SendData(0x03);
|
||||||
|
|
||||||
|
EPD_2IN9_V2_SetWindows(0, 0, EPD_2IN9_V2_WIDTH-1, EPD_2IN9_V2_HEIGHT-1);
|
||||||
|
|
||||||
|
EPD_2IN9_V2_SendCommand(0x3C);
|
||||||
|
EPD_2IN9_V2_SendData(0x05);
|
||||||
|
|
||||||
|
EPD_2IN9_V2_SendCommand(0x21); // Display update control
|
||||||
|
EPD_2IN9_V2_SendData(0x00);
|
||||||
|
EPD_2IN9_V2_SendData(0x80);
|
||||||
|
|
||||||
|
EPD_2IN9_V2_SetCursor(0, 0);
|
||||||
|
EPD_2IN9_V2_ReadBusy();
|
||||||
|
|
||||||
|
EPD_2IN9_V2_LUT_by_host(WF_FULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EPD_2IN9_V2_Gray4_Init(void)
|
||||||
|
{
|
||||||
|
EPD_2IN9_V2_Reset();
|
||||||
|
DEV_Delay_ms(100);
|
||||||
|
|
||||||
|
EPD_2IN9_V2_ReadBusy();
|
||||||
|
EPD_2IN9_V2_SendCommand(0x12); // soft reset
|
||||||
|
EPD_2IN9_V2_ReadBusy();
|
||||||
|
|
||||||
|
EPD_2IN9_V2_SendCommand(0x74); //set analog block control
|
||||||
|
EPD_2IN9_V2_SendData(0x54);
|
||||||
|
EPD_2IN9_V2_SendCommand(0x7E); //set digital block control
|
||||||
|
EPD_2IN9_V2_SendData(0x3B);
|
||||||
|
|
||||||
|
EPD_2IN9_V2_SendCommand(0x01); //Driver output control
|
||||||
|
EPD_2IN9_V2_SendData(0x27);
|
||||||
|
EPD_2IN9_V2_SendData(0x01);
|
||||||
|
EPD_2IN9_V2_SendData(0x00);
|
||||||
|
|
||||||
|
EPD_2IN9_V2_SendCommand(0x11); //data entry mode
|
||||||
|
EPD_2IN9_V2_SendData(0x03);
|
||||||
|
|
||||||
|
EPD_2IN9_V2_SetWindows(0, 0, EPD_2IN9_V2_WIDTH-1, EPD_2IN9_V2_HEIGHT-1);
|
||||||
|
|
||||||
|
EPD_2IN9_V2_SendCommand(0x3C);
|
||||||
|
EPD_2IN9_V2_SendData(0x00);
|
||||||
|
|
||||||
|
EPD_2IN9_V2_SendCommand(0x21); // Display update control
|
||||||
|
EPD_2IN9_V2_SendData(0x00);
|
||||||
|
EPD_2IN9_V2_SendData(0x80);
|
||||||
|
|
||||||
|
EPD_2IN9_V2_SetCursor(0, 0);
|
||||||
|
EPD_2IN9_V2_ReadBusy();
|
||||||
|
|
||||||
|
EPD_2IN9_V2_LUT_by_host(Gray4);
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : Clear screen
|
||||||
|
parameter:
|
||||||
|
******************************************************************************/
|
||||||
|
void EPD_2IN9_V2_Clear(void)
|
||||||
|
{
|
||||||
|
UWORD i;
|
||||||
|
EPD_2IN9_V2_SendCommand(0x24); //write RAM for black(0)/white (1)
|
||||||
|
for(i=0;i<4736;i++)
|
||||||
|
{
|
||||||
|
EPD_2IN9_V2_SendData(0xff);
|
||||||
|
}
|
||||||
|
EPD_2IN9_V2_TurnOnDisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : Sends the image buffer in RAM to e-Paper and displays
|
||||||
|
parameter:
|
||||||
|
******************************************************************************/
|
||||||
|
void EPD_2IN9_V2_Display(UBYTE *Image)
|
||||||
|
{
|
||||||
|
UWORD i;
|
||||||
|
EPD_2IN9_V2_SendCommand(0x24); //write RAM for black(0)/white (1)
|
||||||
|
for(i=0;i<4736;i++)
|
||||||
|
{
|
||||||
|
EPD_2IN9_V2_SendData(Image[i]);
|
||||||
|
}
|
||||||
|
// EPD_2IN9_V2_SendData2(Image, 4736);
|
||||||
|
EPD_2IN9_V2_TurnOnDisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
void EPD_2IN9_V2_Display_Base(UBYTE *Image)
|
||||||
|
{
|
||||||
|
UWORD i;
|
||||||
|
|
||||||
|
EPD_2IN9_V2_SendCommand(0x24); //Write Black and White image to RAM
|
||||||
|
for(i=0;i<4736;i++)
|
||||||
|
{
|
||||||
|
EPD_2IN9_V2_SendData(Image[i]);
|
||||||
|
}
|
||||||
|
// EPD_2IN9_V2_SendData2(Image, 4736);
|
||||||
|
EPD_2IN9_V2_SendCommand(0x26); //Write Black and White image to RAM
|
||||||
|
for(i=0;i<4736;i++)
|
||||||
|
{
|
||||||
|
EPD_2IN9_V2_SendData(Image[i]);
|
||||||
|
}
|
||||||
|
// EPD_2IN9_V2_SendData2(Image, 4736);
|
||||||
|
EPD_2IN9_V2_TurnOnDisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
void EPD_2IN9_V2_Display_Partial_Wait(UBYTE *Image)
|
||||||
|
{
|
||||||
|
// UWORD i;
|
||||||
|
|
||||||
|
//Reset
|
||||||
|
DEV_Digital_Write(EPD_RST_PIN, 0);
|
||||||
|
DEV_Delay_ms(0.2);
|
||||||
|
DEV_Digital_Write(EPD_RST_PIN, 1);
|
||||||
|
// DEV_Delay_ms(1);
|
||||||
|
|
||||||
|
EPD_2IN9_V2_LUT(0);
|
||||||
|
EPD_2IN9_V2_SendCommand(0x37);
|
||||||
|
EPD_2IN9_V2_SendData(0x00);
|
||||||
|
EPD_2IN9_V2_SendData(0x00);
|
||||||
|
EPD_2IN9_V2_SendData(0x00);
|
||||||
|
EPD_2IN9_V2_SendData(0x00);
|
||||||
|
EPD_2IN9_V2_SendData(0x00);
|
||||||
|
EPD_2IN9_V2_SendData(0x40);
|
||||||
|
EPD_2IN9_V2_SendData(0x00);
|
||||||
|
EPD_2IN9_V2_SendData(0x00);
|
||||||
|
EPD_2IN9_V2_SendData(0x00);
|
||||||
|
EPD_2IN9_V2_SendData(0x00);
|
||||||
|
|
||||||
|
EPD_2IN9_V2_SendCommand(0x3C); //BorderWavefrom
|
||||||
|
EPD_2IN9_V2_SendData(0x80);
|
||||||
|
|
||||||
|
EPD_2IN9_V2_SendCommand(0x22);
|
||||||
|
EPD_2IN9_V2_SendData(0xC0);
|
||||||
|
EPD_2IN9_V2_SendCommand(0x20);
|
||||||
|
EPD_2IN9_V2_ReadBusy();
|
||||||
|
|
||||||
|
EPD_2IN9_V2_SetWindows(0, 0, EPD_2IN9_V2_WIDTH-1, EPD_2IN9_V2_HEIGHT-1);
|
||||||
|
EPD_2IN9_V2_SetCursor(0, 0);
|
||||||
|
|
||||||
|
EPD_2IN9_V2_SendCommand(0x24); //Write Black and White image to RAM
|
||||||
|
// for(i=0;i<4736;i++)
|
||||||
|
// {
|
||||||
|
// EPD_2IN9_V2_SendData(Image[i]);
|
||||||
|
// }
|
||||||
|
EPD_2IN9_V2_SendData2(Image, 2500);
|
||||||
|
EPD_2IN9_V2_SendData2(Image+2500, 2236);
|
||||||
|
EPD_2IN9_V2_TurnOnDisplay_Partial_Wait();
|
||||||
|
}
|
||||||
|
|
||||||
|
void EPD_2IN9_V2_Display_Partial(UBYTE *Image)
|
||||||
|
{
|
||||||
|
// UWORD i;
|
||||||
|
|
||||||
|
//Reset
|
||||||
|
// DEV_Digital_Write(EPD_RST_PIN, 0);
|
||||||
|
// DEV_Delay_ms(5);
|
||||||
|
// DEV_Digital_Write(EPD_RST_PIN, 1);
|
||||||
|
// DEV_Delay_ms(10);
|
||||||
|
|
||||||
|
EPD_2IN9_V2_LUT(1);
|
||||||
|
EPD_2IN9_V2_SendCommand(0x37);
|
||||||
|
EPD_2IN9_V2_SendData(0x00);
|
||||||
|
EPD_2IN9_V2_SendData(0x00);
|
||||||
|
EPD_2IN9_V2_SendData(0x00);
|
||||||
|
EPD_2IN9_V2_SendData(0x00);
|
||||||
|
EPD_2IN9_V2_SendData(0x00);
|
||||||
|
EPD_2IN9_V2_SendData(0x40);
|
||||||
|
EPD_2IN9_V2_SendData(0x00);
|
||||||
|
EPD_2IN9_V2_SendData(0x00);
|
||||||
|
EPD_2IN9_V2_SendData(0x00);
|
||||||
|
EPD_2IN9_V2_SendData(0x00);
|
||||||
|
|
||||||
|
EPD_2IN9_V2_SendCommand(0x3C); //BorderWavefrom
|
||||||
|
EPD_2IN9_V2_SendData(0x80);
|
||||||
|
|
||||||
|
EPD_2IN9_V2_SendCommand(0x22);
|
||||||
|
EPD_2IN9_V2_SendData(0xC0);
|
||||||
|
EPD_2IN9_V2_SendCommand(0x20);
|
||||||
|
EPD_2IN9_V2_ReadBusy();
|
||||||
|
|
||||||
|
EPD_2IN9_V2_SetWindows(0, 0, EPD_2IN9_V2_WIDTH-1, EPD_2IN9_V2_HEIGHT-1);
|
||||||
|
EPD_2IN9_V2_SetCursor(0, 0);
|
||||||
|
|
||||||
|
EPD_2IN9_V2_SendCommand(0x24); //Write Black and White image to RAM
|
||||||
|
EPD_2IN9_V2_SendData2(Image, 2500);
|
||||||
|
EPD_2IN9_V2_SendData2(Image+2500, 2236);
|
||||||
|
EPD_2IN9_V2_TurnOnDisplay_Partial();
|
||||||
|
}
|
||||||
|
|
||||||
|
void EPD_2IN9_V2_4GrayDisplay(UBYTE *Image)
|
||||||
|
{
|
||||||
|
UDOUBLE i,j,k;
|
||||||
|
UBYTE temp1,temp2,temp3;
|
||||||
|
|
||||||
|
// old data
|
||||||
|
EPD_2IN9_V2_SendCommand(0x24);
|
||||||
|
for(i=0; i<4736; i++) {
|
||||||
|
temp3=0;
|
||||||
|
for(j=0; j<2; j++) {
|
||||||
|
temp1 = Image[i*2+j];
|
||||||
|
for(k=0; k<2; k++) {
|
||||||
|
temp2 = temp1&0xC0;
|
||||||
|
if(temp2 == 0xC0)
|
||||||
|
temp3 |= 0x00;
|
||||||
|
else if(temp2 == 0x00)
|
||||||
|
temp3 |= 0x01;
|
||||||
|
else if(temp2 == 0x80)
|
||||||
|
temp3 |= 0x01;
|
||||||
|
else //0x40
|
||||||
|
temp3 |= 0x00;
|
||||||
|
temp3 <<= 1;
|
||||||
|
|
||||||
|
temp1 <<= 2;
|
||||||
|
temp2 = temp1&0xC0 ;
|
||||||
|
if(temp2 == 0xC0)
|
||||||
|
temp3 |= 0x00;
|
||||||
|
else if(temp2 == 0x00)
|
||||||
|
temp3 |= 0x01;
|
||||||
|
else if(temp2 == 0x80)
|
||||||
|
temp3 |= 0x01;
|
||||||
|
else //0x40
|
||||||
|
temp3 |= 0x00;
|
||||||
|
if(j!=1 || k!=1)
|
||||||
|
temp3 <<= 1;
|
||||||
|
|
||||||
|
temp1 <<= 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EPD_2IN9_V2_SendData(temp3);
|
||||||
|
// printf("%x ",temp3);
|
||||||
|
}
|
||||||
|
|
||||||
|
EPD_2IN9_V2_SendCommand(0x26); //write RAM for black(0)/white (1)
|
||||||
|
for(i=0; i<4736; i++) {
|
||||||
|
temp3=0;
|
||||||
|
for(j=0; j<2; j++) {
|
||||||
|
temp1 = Image[i*2+j];
|
||||||
|
for(k=0; k<2; k++) {
|
||||||
|
temp2 = temp1&0xC0 ;
|
||||||
|
if(temp2 == 0xC0)
|
||||||
|
temp3 |= 0x00;//white
|
||||||
|
else if(temp2 == 0x00)
|
||||||
|
temp3 |= 0x01; //black
|
||||||
|
else if(temp2 == 0x80)
|
||||||
|
temp3 |= 0x00; //gray1
|
||||||
|
else //0x40
|
||||||
|
temp3 |= 0x01; //gray2
|
||||||
|
temp3 <<= 1;
|
||||||
|
|
||||||
|
temp1 <<= 2;
|
||||||
|
temp2 = temp1&0xC0 ;
|
||||||
|
if(temp2 == 0xC0) //white
|
||||||
|
temp3 |= 0x00;
|
||||||
|
else if(temp2 == 0x00) //black
|
||||||
|
temp3 |= 0x01;
|
||||||
|
else if(temp2 == 0x80)
|
||||||
|
temp3 |= 0x00; //gray1
|
||||||
|
else //0x40
|
||||||
|
temp3 |= 0x01; //gray2
|
||||||
|
if(j!=1 || k!=1)
|
||||||
|
temp3 <<= 1;
|
||||||
|
|
||||||
|
temp1 <<= 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EPD_2IN9_V2_SendData(temp3);
|
||||||
|
// printf("%x ",temp3);
|
||||||
|
}
|
||||||
|
|
||||||
|
EPD_2IN9_V2_TurnOnDisplay_Gray4();
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function : Enter sleep mode
|
||||||
|
parameter:
|
||||||
|
******************************************************************************/
|
||||||
|
void EPD_2IN9_V2_Sleep(void)
|
||||||
|
{
|
||||||
|
EPD_2IN9_V2_SendCommand(0x10); //enter deep sleep
|
||||||
|
EPD_2IN9_V2_SendData(0x01);
|
||||||
|
DEV_Delay_ms(100);
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : EPD_2in9_V2.h
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : 2.9inch e-paper V2
|
||||||
|
* | 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.
|
||||||
|
#
|
||||||
|
******************************************************************************/
|
||||||
|
#ifndef __EPD_2IN9_V2_H_
|
||||||
|
#define __EPD_2IN9_V2_H_
|
||||||
|
|
||||||
|
#include "DEV_Config.h"
|
||||||
|
|
||||||
|
// Display resolution
|
||||||
|
#define EPD_2IN9_V2_WIDTH 128
|
||||||
|
#define EPD_2IN9_V2_HEIGHT 296
|
||||||
|
|
||||||
|
void EPD_2IN9_V2_Init(void);
|
||||||
|
void EPD_2IN9_V2_Clear(void);
|
||||||
|
void EPD_2IN9_V2_Display(UBYTE *Image);
|
||||||
|
void EPD_2IN9_V2_Display_Base(UBYTE *Image);
|
||||||
|
void EPD_2IN9_V2_Display_Partial(UBYTE *Image);
|
||||||
|
void EPD_2IN9_V2_Sleep(void);
|
||||||
|
|
||||||
|
void EPD_2IN9_V2_Display_Partial_Wait(UBYTE *Image);
|
||||||
|
|
||||||
|
void EPD_2IN9_V2_Init_Fast(void);
|
||||||
|
void EPD_2IN9_V2_Gray4_Init(void);
|
||||||
|
void EPD_2IN9_V2_4GrayDisplay(UBYTE *Image);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,120 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file Font12.c
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @version V1.0.0
|
||||||
|
* @date 18-February-2014
|
||||||
|
* @brief This file provides text Font12 for STM32xx-EVAL's LCD driver.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "fonts.h"
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Font data for Courier New 12pt
|
||||||
|
//
|
||||||
|
|
||||||
|
const CH_CN Font12CN_Table[] =
|
||||||
|
{
|
||||||
|
/*-- 文字: 你 --*/
|
||||||
|
/*-- 微软雅黑12; 此字体下对应的点阵为:宽x高=16x21 --*/
|
||||||
|
{{"你"},{
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1D,0xC0,0x1D,0x80,0x3B,0xFF,0x3B,0x07,
|
||||||
|
0x3F,0x77,0x7E,0x76,0xF8,0x70,0xFB,0xFE,0xFB,0xFE,0x3F,0x77,0x3F,0x77,0x3E,0x73,
|
||||||
|
0x38,0x70,0x38,0x70,0x3B,0xE0,0x00,0x00,0x00,0x00}},
|
||||||
|
|
||||||
|
/*-- 文字: 好 --*/
|
||||||
|
/*-- 微软雅黑12; 此字体下对应的点阵为:宽x高=16x21 --*/
|
||||||
|
{{"好"},{
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x73,0xFF,0x70,0x0F,0xFE,0x1E,
|
||||||
|
0x7E,0x3C,0x6E,0x38,0xEE,0x30,0xEF,0xFF,0xFC,0x30,0x7C,0x30,0x38,0x30,0x3E,0x30,
|
||||||
|
0x7E,0x30,0xE0,0x30,0xC1,0xF0,0x00,0x00,0x00,0x00}},
|
||||||
|
|
||||||
|
/*-- 文字: 树 --*/
|
||||||
|
/*-- 微软雅黑12; 此字体下对应的点阵为:宽x高=16x21 --*/
|
||||||
|
{{"树"},{
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x0E,0x30,0x0E,0x3F,0xEE,0x30,0xEE,
|
||||||
|
0xFC,0xFF,0x76,0xCE,0x77,0xFE,0x7B,0xFE,0xFF,0xFE,0xF3,0xDE,0xF3,0xCE,0x37,0xEE,
|
||||||
|
0x3E,0x6E,0x3C,0x0E,0x30,0x3E,0x00,0x00,0x00,0x00}},
|
||||||
|
|
||||||
|
/*-- 文字: 莓 --*/
|
||||||
|
/*-- 微软雅黑12; 此字体下对应的点阵为:宽x高=16x21 --*/
|
||||||
|
{{"莓"},{
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x70,0xFF,0xFF,0x3E,0x70,0x38,0x00,
|
||||||
|
0x7F,0xFF,0xE0,0x00,0xFF,0xFC,0x3B,0x8C,0x39,0xCC,0xFF,0xFF,0x73,0x9C,0x71,0xDC,
|
||||||
|
0x7F,0xFF,0x00,0x1C,0x01,0xF8,0x00,0x00,0x00,0x00}},
|
||||||
|
|
||||||
|
/*-- 文字: 派 --*/
|
||||||
|
/*-- 微软雅黑12; 此字体下对应的点阵为:宽x高=16x21 --*/
|
||||||
|
{{"派"},{
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x1F,0xFF,0xF0,0x3E,0x00,0x0E,0x1F,
|
||||||
|
0xCF,0xFB,0xFF,0xF8,0x3F,0xFF,0x0F,0xFF,0x7F,0xD8,0x7F,0xDC,0x6F,0xCE,0xED,0xFF,
|
||||||
|
0xFD,0xF7,0xF9,0xC0,0x00,0x00,0x00,0x00,0x00,0x00}},
|
||||||
|
|
||||||
|
/*-- 文字: a --*/
|
||||||
|
/*-- 微软雅黑12; 此字体下对应的点阵为:宽x高=16x21 --*/
|
||||||
|
{{"a"},{
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x3E,0x00,0x67,0x00,0x07,0x80,0x0F,0x80,0x7F,0x80,0xE3,0x80,0xE7,0x80,0xE7,0x80,
|
||||||
|
0x7F,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},
|
||||||
|
|
||||||
|
/*-- 文字: b --*/
|
||||||
|
/*-- 微软雅黑12; 此字体下对应的点阵为:宽x高=16x21 --*/
|
||||||
|
{{"b"},{
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x70,0x00,
|
||||||
|
0x7F,0x00,0x7B,0x80,0x71,0xC0,0x71,0xC0,0x71,0xC0,0x71,0xC0,0x71,0xC0,0x7B,0x80,
|
||||||
|
0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},
|
||||||
|
|
||||||
|
/*-- 文字: c --*/
|
||||||
|
/*-- 微软雅黑12; 此字体下对应的点阵为:宽x高=16x21 --*/
|
||||||
|
{{"c"},{
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x3F,0x00,0x73,0x00,0xF0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xF0,0x00,0x73,0x00,
|
||||||
|
0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},
|
||||||
|
|
||||||
|
/*-- 文字: A --*/
|
||||||
|
/*-- 微软雅黑12; 此字体下对应的点阵为:宽x高=16x21 --*/
|
||||||
|
{{"A"},{
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0E,0x00,0x1F,0x00,0x1F,0x00,
|
||||||
|
0x1F,0x00,0x3B,0x80,0x3B,0x80,0x71,0x80,0x7F,0xC0,0x71,0xC0,0xE0,0xE0,0xE0,0xE0,
|
||||||
|
0xE0,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},
|
||||||
|
};
|
||||||
|
|
||||||
|
cFONT Font12CN = {
|
||||||
|
Font12CN_Table,
|
||||||
|
sizeof(Font12CN_Table)/sizeof(CH_CN), /*size of table*/
|
||||||
|
11, /* ASCII Width */
|
||||||
|
16, /* Width */
|
||||||
|
21, /* Height */
|
||||||
|
};
|
||||||
|
|
||||||
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||||
@@ -0,0 +1,465 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file Font12.c
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @version V1.0.0
|
||||||
|
* @date 18-February-2014
|
||||||
|
* @brief This file provides text Font12 for STM32xx-EVAL's LCD driver.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "fonts.h"
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Font data for Courier New 12pt
|
||||||
|
//
|
||||||
|
|
||||||
|
const CH_CN Font24CN_Table[] =
|
||||||
|
{
|
||||||
|
/*-- 文字: 你 --*/
|
||||||
|
/*-- 微软雅黑24; 此字体下对应的点阵为:宽x高=32x41 --*/
|
||||||
|
{{"你"},{
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xC1,0xC0,0x00,
|
||||||
|
0x01,0xE3,0xE0,0x00,0x03,0xE3,0xC0,0x00,0x03,0xC7,0x80,0x00,0x03,0xC7,0xFF,0xFF,
|
||||||
|
0x07,0x8F,0xFF,0xFF,0x07,0x8F,0x00,0x0F,0x0F,0x1E,0x00,0x1E,0x0F,0x3C,0x1E,0x1E,
|
||||||
|
0x1F,0x3C,0x1E,0x3E,0x1F,0x18,0x1E,0x3C,0x3F,0x00,0x1E,0x1C,0x7F,0x00,0x1E,0x00,
|
||||||
|
0x7F,0x07,0x9E,0x70,0xFF,0x07,0x9E,0xF0,0xEF,0x0F,0x9E,0x78,0x6F,0x0F,0x1E,0x78,
|
||||||
|
0x0F,0x0F,0x1E,0x3C,0x0F,0x1E,0x1E,0x3C,0x0F,0x1E,0x1E,0x1E,0x0F,0x3C,0x1E,0x1E,
|
||||||
|
0x0F,0x3C,0x1E,0x1F,0x0F,0x7C,0x1E,0x0F,0x0F,0x78,0x1E,0x0E,0x0F,0x00,0x1E,0x00,
|
||||||
|
0x0F,0x00,0x1E,0x00,0x0F,0x00,0x3C,0x00,0x0F,0x07,0xFC,0x00,0x0F,0x07,0xF8,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00}},
|
||||||
|
|
||||||
|
/*-- 文字: 好 --*/
|
||||||
|
/*-- 微软雅黑24; 此字体下对应的点阵为:宽x高=32x41 --*/
|
||||||
|
{{"好"},{
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x00,0x00,0x00,0x0F,0x00,0x00,0x00,
|
||||||
|
0x0F,0x07,0xFF,0xFE,0x0F,0x07,0xFF,0xFE,0x0F,0x00,0x00,0x3E,0x1E,0x00,0x00,0xFC,
|
||||||
|
0xFF,0xF8,0x01,0xF0,0xFF,0xF8,0x03,0xE0,0x1E,0x78,0x07,0xC0,0x1E,0x78,0x0F,0x80,
|
||||||
|
0x3C,0x78,0x0F,0x00,0x3C,0x78,0x0F,0x00,0x3C,0x78,0x0F,0x00,0x3C,0x78,0x0F,0x00,
|
||||||
|
0x3C,0x7F,0xFF,0xFF,0x78,0xFF,0xFF,0xFF,0x78,0xF0,0x0F,0x00,0x78,0xF0,0x0F,0x00,
|
||||||
|
0x3D,0xE0,0x0F,0x00,0x1F,0xE0,0x0F,0x00,0x0F,0xE0,0x0F,0x00,0x07,0xC0,0x0F,0x00,
|
||||||
|
0x07,0xE0,0x0F,0x00,0x07,0xF0,0x0F,0x00,0x0F,0xF8,0x0F,0x00,0x1E,0x7C,0x0F,0x00,
|
||||||
|
0x3C,0x38,0x0F,0x00,0x78,0x00,0x0F,0x00,0xF0,0x03,0xFF,0x00,0x60,0x01,0xFE,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00}},
|
||||||
|
|
||||||
|
/*-- 文字: 微 --*/
|
||||||
|
/*-- 微软雅黑24; 此字体下对应的点阵为:宽x高=32x41 --*/
|
||||||
|
{{"微"},{
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x07,0x01,0xE0,0x07,0x87,0x01,0xE0,
|
||||||
|
0x07,0x07,0x01,0xC0,0x0F,0xF7,0x79,0xC0,0x1E,0xF7,0x7B,0xC0,0x1E,0xF7,0x7B,0x80,
|
||||||
|
0x3C,0xF7,0x7B,0xFF,0x78,0xF7,0x7B,0xFF,0xF8,0xF7,0x7F,0x9E,0xF7,0xFF,0xFF,0x9E,
|
||||||
|
0x67,0xFF,0xFF,0x9E,0x07,0x00,0x7F,0x9C,0x0F,0x00,0x0F,0x9C,0x1E,0x00,0x1F,0x9C,
|
||||||
|
0x1E,0x7F,0xFF,0xBC,0x3E,0x7F,0xF3,0xFC,0x3E,0x00,0x03,0xFC,0x7E,0x00,0x01,0xF8,
|
||||||
|
0xFE,0x00,0x01,0xF8,0xFE,0x7F,0xE1,0xF8,0xDE,0x7F,0xE1,0xF8,0x1E,0x78,0xE0,0xF0,
|
||||||
|
0x1E,0x78,0xEE,0xF0,0x1E,0x78,0xFF,0xF0,0x1E,0x78,0xFD,0xF8,0x1E,0x79,0xFB,0xFC,
|
||||||
|
0x1E,0xF1,0xF7,0xBC,0x1E,0xF0,0xEF,0x9E,0x1F,0xE0,0x0F,0x0F,0x1E,0xC0,0x1E,0x0F,
|
||||||
|
0x1E,0x00,0x0C,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00}},
|
||||||
|
|
||||||
|
/*-- 文字: 软 --*/
|
||||||
|
/*-- 微软雅黑24; 此字体下对应的点阵为:宽x高=32x41 --*/
|
||||||
|
{{"软"},{
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x03,0xC0,0x78,0x00,0x07,0x80,0x78,0x00,0x07,0x80,0x78,0x00,
|
||||||
|
0x07,0x80,0xF0,0x00,0x0F,0x00,0xF0,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
|
||||||
|
0x1E,0x03,0xC0,0x1F,0x1E,0x03,0xC0,0x1E,0x1F,0xE7,0x8F,0x3E,0x3D,0xE7,0x8F,0x3C,
|
||||||
|
0x3D,0xEF,0x0F,0x7C,0x3D,0xE7,0x0F,0x78,0x79,0xE0,0x0F,0x00,0x79,0xE0,0x0E,0x00,
|
||||||
|
0x7F,0xFE,0x0E,0x00,0x7F,0xFE,0x1F,0x00,0x01,0xE0,0x1F,0x00,0x01,0xE0,0x1F,0x00,
|
||||||
|
0x01,0xE0,0x1F,0x80,0x01,0xE0,0x1F,0x80,0x01,0xE0,0x3F,0x80,0x01,0xFF,0x3F,0xC0,
|
||||||
|
0x0F,0xFF,0x7B,0xC0,0xFF,0xF0,0x79,0xE0,0xF9,0xE0,0xF1,0xF0,0x01,0xE1,0xF0,0xF0,
|
||||||
|
0x01,0xE3,0xE0,0xF8,0x01,0xE7,0xC0,0x7C,0x01,0xFF,0x80,0x3F,0x01,0xFF,0x00,0x1F,
|
||||||
|
0x01,0xEC,0x00,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00}},
|
||||||
|
|
||||||
|
/*-- 文字: 雅 --*/
|
||||||
|
/*-- 微软雅黑24; 此字体下对应的点阵为:宽x高=32x41 --*/
|
||||||
|
{{"雅"},{
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x77,0x00,0x00,0x00,0xFF,0x00,
|
||||||
|
0x7F,0xFC,0xF7,0x80,0x7F,0xFD,0xE3,0xC0,0x01,0xC1,0xE3,0xC0,0x01,0xC3,0xC1,0x80,
|
||||||
|
0x3D,0xC7,0xFF,0xFF,0x39,0xC7,0xFF,0xFF,0x39,0xCF,0x83,0x80,0x79,0xDF,0x83,0x80,
|
||||||
|
0x79,0xFF,0x83,0x80,0x79,0xDF,0x83,0x80,0x71,0xC3,0x83,0x80,0x7F,0xFF,0xFF,0xFE,
|
||||||
|
0x7F,0xFF,0xFF,0xFE,0x03,0xC3,0x83,0x80,0x07,0xC3,0x83,0x80,0x07,0xC3,0x83,0x80,
|
||||||
|
0x0F,0xC3,0x83,0x80,0x0F,0xC3,0x83,0x80,0x1F,0xC3,0xFF,0xFE,0x1D,0xC3,0xFF,0xFE,
|
||||||
|
0x3D,0xC3,0x83,0x80,0x79,0xC3,0x83,0x80,0xF1,0xC3,0x83,0x80,0xF1,0xC3,0x83,0x80,
|
||||||
|
0x61,0xC3,0x83,0x80,0x01,0xC3,0xFF,0xFF,0x03,0xC3,0xFF,0xFF,0x1F,0xC3,0x80,0x00,
|
||||||
|
0x1F,0x83,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00}},
|
||||||
|
|
||||||
|
/*-- 文字: 黑 --*/
|
||||||
|
/*-- 微软雅黑24; 此字体下对应的点阵为:宽x高=32x41 --*/
|
||||||
|
{{"黑"},{
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x1F,0xFF,0xFF,0xFC,0x1F,0xFF,0xFF,0xFC,0x1E,0x03,0xC0,0x3C,0x1E,0xC3,0xC7,0x3C,
|
||||||
|
0x1F,0xE3,0xC7,0xBC,0x1E,0xF3,0xCF,0x3C,0x1E,0xFB,0xDF,0x3C,0x1E,0x7B,0xDE,0x3C,
|
||||||
|
0x1E,0x33,0xDC,0x3C,0x1E,0x03,0xC0,0x3C,0x1F,0xFF,0xFF,0xFC,0x1F,0xFF,0xFF,0xFC,
|
||||||
|
0x1E,0x03,0xC0,0x3C,0x00,0x03,0xC0,0x00,0x00,0x03,0xC0,0x00,0x3F,0xFF,0xFF,0xFC,
|
||||||
|
0x3F,0xFF,0xFF,0xFC,0x00,0x03,0xC0,0x00,0x00,0x03,0xC0,0x00,0x00,0x03,0xC0,0x00,
|
||||||
|
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x1C,0x38,0x70,0x70,
|
||||||
|
0x3E,0x78,0xF8,0xF8,0x3C,0x7C,0x78,0x7C,0x7C,0x3C,0x3C,0x3E,0xF8,0x3E,0x3C,0x1F,
|
||||||
|
0xF0,0x1C,0x18,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00}},
|
||||||
|
|
||||||
|
/*-- 文字: 此 --*/
|
||||||
|
/*-- 微软雅黑24; 此字体下对应的点阵为:宽x高=32x41 --*/
|
||||||
|
{{"此"},{
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x3C,0x00,
|
||||||
|
0x00,0x78,0x3C,0x00,0x00,0x78,0x3C,0x00,0x00,0x78,0x3C,0x00,0x00,0x78,0x3C,0x00,
|
||||||
|
0x00,0x78,0x3C,0x0C,0x3C,0x78,0x3C,0x1E,0x3C,0x78,0x3C,0x3F,0x3C,0x78,0x3C,0xF8,
|
||||||
|
0x3C,0x7F,0xFD,0xF0,0x3C,0x7F,0xFF,0xE0,0x3C,0x78,0x3F,0x80,0x3C,0x78,0x3E,0x00,
|
||||||
|
0x3C,0x78,0x3C,0x00,0x3C,0x78,0x3C,0x00,0x3C,0x78,0x3C,0x00,0x3C,0x78,0x3C,0x00,
|
||||||
|
0x3C,0x78,0x3C,0x00,0x3C,0x78,0x3C,0x00,0x3C,0x78,0x3C,0x0E,0x3C,0x78,0x3C,0x0F,
|
||||||
|
0x3C,0x78,0x3C,0x0F,0x3C,0x79,0xFC,0x0F,0x3C,0x7F,0xFC,0x0F,0x3F,0xFF,0x3C,0x0F,
|
||||||
|
0x3F,0xF0,0x3E,0x1E,0xFF,0x00,0x1F,0xFE,0xF0,0x00,0x0F,0xFC,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00}},
|
||||||
|
|
||||||
|
/*-- 文字: 字 --*/
|
||||||
|
/*-- 微软雅黑24; 此字体下对应的点阵为:宽x高=32x41 --*/
|
||||||
|
{{"字"},{
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x03,0x80,0x00,0x00,0x07,0x80,0x00,0x00,0x03,0xC0,0x00,
|
||||||
|
0x00,0x03,0xE0,0x00,0x00,0x01,0xE0,0x00,0x7F,0xFF,0xFF,0xFE,0x7F,0xFF,0xFF,0xFE,
|
||||||
|
0x78,0x00,0x00,0x1E,0x78,0x00,0x00,0x1E,0x78,0x00,0x00,0x1E,0x78,0x00,0x00,0x1E,
|
||||||
|
0x7B,0xFF,0xFF,0xDE,0x03,0xFF,0xFF,0xC0,0x00,0x00,0x0F,0xC0,0x00,0x00,0x3F,0x00,
|
||||||
|
0x00,0x00,0x7E,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xE0,0x00,0x00,0x01,0xE0,0x00,
|
||||||
|
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x01,0xE0,0x00,0x00,0x01,0xE0,0x00,
|
||||||
|
0x00,0x01,0xE0,0x00,0x00,0x01,0xE0,0x00,0x00,0x01,0xE0,0x00,0x00,0x01,0xE0,0x00,
|
||||||
|
0x00,0x03,0xE0,0x00,0x00,0x03,0xC0,0x00,0x00,0xFF,0xC0,0x00,0x00,0xFF,0x80,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00}},
|
||||||
|
|
||||||
|
/*-- 文字: 体 --*/
|
||||||
|
/*-- 微软雅黑24; 此字体下对应的点阵为:宽x高=32x41 --*/
|
||||||
|
{{"体"},{
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xC0,0x3C,0x00,
|
||||||
|
0x03,0xC0,0x3C,0x00,0x03,0xC0,0x3C,0x00,0x07,0x80,0x3C,0x00,0x07,0x80,0x3C,0x00,
|
||||||
|
0x07,0x80,0x3C,0x00,0x0F,0xFF,0xFF,0xFF,0x0F,0xFF,0xFF,0xFF,0x1F,0x01,0xFE,0x00,
|
||||||
|
0x1F,0x01,0xFF,0x00,0x3F,0x01,0xFF,0x00,0x3F,0x03,0xFF,0x00,0x7F,0x03,0xFF,0x80,
|
||||||
|
0x7F,0x07,0xBF,0x80,0xFF,0x07,0xBF,0xC0,0xEF,0x0F,0x3D,0xC0,0xCF,0x0F,0x3D,0xE0,
|
||||||
|
0x0F,0x1E,0x3D,0xE0,0x0F,0x1E,0x3C,0xF0,0x0F,0x3C,0x3C,0x78,0x0F,0x7C,0x3C,0x7C,
|
||||||
|
0x0F,0xF8,0x3C,0x3E,0x0F,0xF7,0xFF,0xDF,0x0F,0xE7,0xFF,0xCF,0x0F,0xC0,0x3C,0x06,
|
||||||
|
0x0F,0x00,0x3C,0x00,0x0F,0x00,0x3C,0x00,0x0F,0x00,0x3C,0x00,0x0F,0x00,0x3C,0x00,
|
||||||
|
0x0F,0x00,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00}},
|
||||||
|
|
||||||
|
/*-- 文字: 下 --*/
|
||||||
|
/*-- 微软雅黑24; 此字体下对应的点阵为:宽x高=32x41 --*/
|
||||||
|
{{"下"},{
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x0F,0x80,0x00,0x00,0x0F,0x80,0x00,
|
||||||
|
0x00,0x0F,0x80,0x00,0x00,0x0F,0x80,0x00,0x00,0x0F,0x80,0x00,0x00,0x0F,0x80,0x00,
|
||||||
|
0x00,0x0F,0xE0,0x00,0x00,0x0F,0xF8,0x00,0x00,0x0F,0xFC,0x00,0x00,0x0F,0xBF,0x00,
|
||||||
|
0x00,0x0F,0x9F,0x80,0x00,0x0F,0x87,0xE0,0x00,0x0F,0x83,0xF0,0x00,0x0F,0x80,0xF8,
|
||||||
|
0x00,0x0F,0x80,0x7C,0x00,0x0F,0x80,0x38,0x00,0x0F,0x80,0x00,0x00,0x0F,0x80,0x00,
|
||||||
|
0x00,0x0F,0x80,0x00,0x00,0x0F,0x80,0x00,0x00,0x0F,0x80,0x00,0x00,0x0F,0x80,0x00,
|
||||||
|
0x00,0x0F,0x80,0x00,0x00,0x0F,0x80,0x00,0x00,0x0F,0x80,0x00,0x00,0x0F,0x80,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00}},
|
||||||
|
|
||||||
|
/*-- 文字: 对 --*/
|
||||||
|
/*-- 微软雅黑24; 此字体下对应的点阵为:宽x高=32x41 --*/
|
||||||
|
{{"对"},{
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,
|
||||||
|
0x00,0x00,0x00,0x78,0x00,0x00,0x00,0x78,0x7F,0xFC,0x00,0x78,0x7F,0xFC,0x00,0x78,
|
||||||
|
0x00,0x3C,0x00,0x78,0x00,0x3F,0xFF,0xFF,0x30,0x3F,0xFF,0xFF,0x78,0x3C,0x00,0x78,
|
||||||
|
0x3C,0x38,0x00,0x78,0x3E,0x78,0x00,0x78,0x1E,0x78,0xC0,0x78,0x0F,0x79,0xE0,0x78,
|
||||||
|
0x0F,0xF0,0xF0,0x78,0x07,0xF0,0xF8,0x78,0x03,0xF0,0x78,0x78,0x01,0xE0,0x3C,0x78,
|
||||||
|
0x03,0xF0,0x3E,0x78,0x03,0xF0,0x18,0x78,0x07,0xF8,0x00,0x78,0x07,0xFC,0x00,0x78,
|
||||||
|
0x0F,0x3E,0x00,0x78,0x1F,0x1E,0x00,0x78,0x3E,0x1F,0x00,0x78,0x7C,0x0E,0x00,0xF8,
|
||||||
|
0xF8,0x00,0x00,0xF0,0xF0,0x00,0x3F,0xF0,0x60,0x00,0x3F,0xE0,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00}},
|
||||||
|
|
||||||
|
/*-- 文字: 应 --*/
|
||||||
|
/*-- 微软雅黑24; 此字体下对应的点阵为:宽x高=32x41 --*/
|
||||||
|
{{"应"},{
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x01,0xC0,0x00,0x00,0x03,0xE0,0x00,0x00,0x01,0xE0,0x00,
|
||||||
|
0x00,0x01,0xF0,0x00,0x00,0x00,0xF0,0x00,0x1F,0xFF,0xFF,0xFF,0x1F,0xFF,0xFF,0xFF,
|
||||||
|
0x1E,0x00,0x00,0x00,0x1E,0x00,0x00,0x00,0x1E,0x01,0xE0,0x78,0x1E,0x01,0xE0,0x78,
|
||||||
|
0x1E,0xE1,0xE0,0x78,0x1F,0xF1,0xF0,0xF8,0x1E,0xF0,0xF0,0xF0,0x1E,0xF0,0xF0,0xF0,
|
||||||
|
0x1E,0xF8,0xF0,0xF0,0x1E,0x78,0xF1,0xF0,0x1E,0x78,0xF9,0xE0,0x1E,0x78,0x79,0xE0,
|
||||||
|
0x1E,0x7C,0x7B,0xE0,0x1E,0x3C,0x7B,0xC0,0x1E,0x3C,0x7B,0xC0,0x1E,0x3C,0x7B,0xC0,
|
||||||
|
0x3C,0x3E,0x07,0x80,0x3C,0x1C,0x07,0x80,0x3C,0x00,0x07,0x80,0x3C,0x00,0x0F,0x00,
|
||||||
|
0x78,0x00,0x0F,0x00,0x7B,0xFF,0xFF,0xFF,0xF3,0xFF,0xFF,0xFF,0xF0,0x00,0x00,0x00,
|
||||||
|
0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00}},
|
||||||
|
|
||||||
|
/*-- 文字: 的 --*/
|
||||||
|
/*-- 微软雅黑24; 此字体下对应的点阵为:宽x高=32x41 --*/
|
||||||
|
{{"的"},{
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x80,0x3C,0x00,0x07,0xC0,0x3E,0x00,
|
||||||
|
0x07,0x80,0x3C,0x00,0x07,0x80,0x7C,0x00,0x0F,0x00,0x78,0x00,0x7F,0xFE,0x7F,0xFE,
|
||||||
|
0x7F,0xFE,0xFF,0xFE,0x78,0x1E,0xF0,0x1E,0x78,0x1F,0xE0,0x1E,0x78,0x1F,0xE0,0x1E,
|
||||||
|
0x78,0x1F,0xC0,0x1E,0x78,0x1F,0xC0,0x1E,0x78,0x1F,0xF0,0x1E,0x78,0x1E,0xF8,0x1E,
|
||||||
|
0x78,0x1E,0x7C,0x1E,0x7F,0xFE,0x3C,0x1E,0x7F,0xFE,0x1E,0x1E,0x78,0x1E,0x1F,0x1E,
|
||||||
|
0x78,0x1E,0x0F,0x9E,0x78,0x1E,0x07,0x9E,0x78,0x1E,0x07,0x1E,0x78,0x1E,0x00,0x1E,
|
||||||
|
0x78,0x1E,0x00,0x1E,0x78,0x1E,0x00,0x3E,0x78,0x1E,0x00,0x3C,0x78,0x1E,0x00,0x3C,
|
||||||
|
0x7F,0xFE,0x00,0x3C,0x7F,0xFE,0x00,0x7C,0x78,0x1E,0x3F,0xF8,0x78,0x1E,0x3F,0xF0,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00}},
|
||||||
|
|
||||||
|
/*-- 文字: 点 --*/
|
||||||
|
/*-- 微软雅黑24; 此字体下对应的点阵为:宽x高=32x41 --*/
|
||||||
|
{{"点"},{
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xC0,0x00,0x00,0x03,0xC0,0x00,
|
||||||
|
0x00,0x03,0xC0,0x00,0x00,0x03,0xC0,0x00,0x00,0x03,0xFF,0xFF,0x00,0x03,0xFF,0xFF,
|
||||||
|
0x00,0x03,0xC0,0x00,0x00,0x03,0xC0,0x00,0x00,0x03,0xC0,0x00,0x00,0x03,0xC0,0x00,
|
||||||
|
0x0F,0xFF,0xFF,0xF8,0x0F,0xFF,0xFF,0xF8,0x0F,0x00,0x00,0x78,0x0F,0x00,0x00,0x78,
|
||||||
|
0x0F,0x00,0x00,0x78,0x0F,0x00,0x00,0x78,0x0F,0x00,0x00,0x78,0x0F,0x00,0x00,0x78,
|
||||||
|
0x0F,0xFF,0xFF,0xF8,0x0F,0xFF,0xFF,0xF8,0x0F,0x00,0x00,0x78,0x00,0x00,0x00,0x00,
|
||||||
|
0x0C,0x38,0x38,0x30,0x1E,0x7C,0x78,0x78,0x3E,0x3C,0x78,0x78,0x3C,0x3C,0x3C,0x3C,
|
||||||
|
0x7C,0x3E,0x3C,0x3E,0xF8,0x1E,0x3C,0x1E,0xF0,0x1E,0x1E,0x1F,0x70,0x1E,0x1C,0x0E,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00}},
|
||||||
|
|
||||||
|
/*-- 文字: 阵 --*/
|
||||||
|
/*-- 微软雅黑24; 此字体下对应的点阵为:宽x高=32x41 --*/
|
||||||
|
{{"阵"},{
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x00,0x00,0x00,0x78,0x00,
|
||||||
|
0x7F,0xF0,0x78,0x00,0x7F,0xF0,0x78,0x00,0x79,0xFF,0xFF,0xFF,0x79,0xFF,0xFF,0xFF,
|
||||||
|
0x79,0xE1,0xE0,0x00,0x79,0xE1,0xE0,0x00,0x7B,0xC1,0xEF,0x80,0x7B,0xC3,0xCF,0x80,
|
||||||
|
0x7B,0xC3,0xCF,0x80,0x7F,0x87,0xCF,0x80,0x7F,0x87,0x8F,0x80,0x7F,0x87,0x8F,0x80,
|
||||||
|
0x7B,0xCF,0x0F,0x80,0x7B,0xCF,0xFF,0xFE,0x79,0xEF,0xFF,0xFE,0x79,0xE0,0x0F,0x80,
|
||||||
|
0x78,0xE0,0x0F,0x80,0x78,0xF0,0x0F,0x80,0x78,0xF0,0x0F,0x80,0x78,0xF0,0x0F,0x80,
|
||||||
|
0x78,0xFF,0xFF,0xFF,0x79,0xFF,0xFF,0xFF,0x7F,0xE0,0x0F,0x80,0x7F,0xC0,0x0F,0x80,
|
||||||
|
0x78,0x00,0x0F,0x80,0x78,0x00,0x0F,0x80,0x78,0x00,0x0F,0x80,0x78,0x00,0x0F,0x80,
|
||||||
|
0x78,0x00,0x0F,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00}},
|
||||||
|
|
||||||
|
/*-- 文字: 为 --*/
|
||||||
|
/*-- 微软雅黑24; 此字体下对应的点阵为:宽x高=32x41 --*/
|
||||||
|
{{"为"},{
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x80,0x00,
|
||||||
|
0x0E,0x07,0x80,0x00,0x1F,0x07,0x80,0x00,0x0F,0x87,0x80,0x00,0x07,0xC7,0x80,0x00,
|
||||||
|
0x01,0xE7,0x80,0x00,0x00,0xC7,0x80,0x00,0x00,0x07,0x80,0x00,0x7F,0xFF,0xFF,0xFC,
|
||||||
|
0x7F,0xFF,0xFF,0xFC,0x00,0x07,0x80,0x3C,0x00,0x0F,0x80,0x3C,0x00,0x0F,0x00,0x3C,
|
||||||
|
0x00,0x0F,0x00,0x3C,0x00,0x0F,0x60,0x3C,0x00,0x1F,0xF0,0x3C,0x00,0x1E,0x78,0x3C,
|
||||||
|
0x00,0x3E,0x3C,0x3C,0x00,0x3C,0x3E,0x3C,0x00,0x7C,0x1F,0x3C,0x00,0x78,0x0F,0x3C,
|
||||||
|
0x00,0xF8,0x06,0x3C,0x01,0xF0,0x00,0x3C,0x03,0xE0,0x00,0x7C,0x07,0xC0,0x00,0x7C,
|
||||||
|
0x0F,0x80,0x00,0x78,0x1F,0x00,0x00,0xF8,0x3E,0x00,0xFF,0xF0,0x7C,0x00,0xFF,0xE0,
|
||||||
|
0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00}},
|
||||||
|
|
||||||
|
/*-- 文字: 树 --*/
|
||||||
|
/*-- 微软雅黑24; 此字体下对应的点阵为:宽x高=32x41 --*/
|
||||||
|
{{"树"},{
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x00,0x00,0x38,
|
||||||
|
0x0F,0x00,0x00,0x38,0x0F,0x00,0x00,0x38,0x0F,0x3F,0xF8,0x38,0x0F,0x3F,0xF8,0x38,
|
||||||
|
0x0F,0x00,0x78,0x38,0xFF,0xE0,0x7F,0xFF,0xFF,0xE0,0x7F,0xFF,0x0F,0x00,0x70,0x38,
|
||||||
|
0x0F,0x18,0xF0,0x38,0x1F,0x3C,0xF0,0x38,0x1F,0x1C,0xFE,0x38,0x1F,0xDE,0xFE,0x38,
|
||||||
|
0x3F,0xEF,0xEF,0x38,0x3F,0xFF,0xEF,0x38,0x3F,0xF7,0xE7,0xB8,0x7F,0x67,0xC7,0xB8,
|
||||||
|
0x7F,0x03,0xC3,0xB8,0xFF,0x07,0xE0,0x38,0xEF,0x07,0xE0,0x38,0xEF,0x0F,0xF0,0x38,
|
||||||
|
0xCF,0x1F,0xF0,0x38,0x0F,0x1E,0x78,0x38,0x0F,0x3C,0x7C,0x38,0x0F,0x78,0x3C,0x38,
|
||||||
|
0x0F,0xF8,0x38,0x38,0x0F,0x60,0x00,0x78,0x0F,0x00,0x0F,0xF8,0x0F,0x00,0x07,0xF0,
|
||||||
|
0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00}},
|
||||||
|
|
||||||
|
/*-- 文字: 莓 --*/
|
||||||
|
/*-- 微软雅黑24; 此字体下对应的点阵为:宽x高=32x41 --*/
|
||||||
|
{{"莓"},{
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x1E,0x00,0x00,0x3C,0x1E,0x00,
|
||||||
|
0x00,0x3C,0x1E,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x3C,0x1E,0x00,
|
||||||
|
0x07,0xBC,0x1E,0x00,0x07,0x80,0x00,0x00,0x0F,0xFF,0xFF,0xFC,0x0F,0xFF,0xFF,0xFC,
|
||||||
|
0x1E,0x00,0x00,0x00,0x3C,0x00,0x00,0x00,0x3C,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xF0,
|
||||||
|
0xF7,0xFF,0xFF,0xF0,0x37,0x83,0x80,0xF0,0x07,0x87,0xC0,0xF0,0x07,0x83,0xF0,0xF0,
|
||||||
|
0x07,0x00,0xE0,0xF0,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x0F,0x0F,0x00,0xE0,
|
||||||
|
0x0F,0x0F,0x81,0xE0,0x0E,0x03,0xE1,0xE0,0x1E,0x01,0xC1,0xE0,0x1F,0xFF,0xFF,0xFE,
|
||||||
|
0x1F,0xFF,0xFF,0xFE,0x00,0x00,0x01,0xE0,0x00,0x00,0x03,0xC0,0x00,0x00,0xFF,0xC0,
|
||||||
|
0x00,0x00,0xFF,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00}},
|
||||||
|
|
||||||
|
/*-- 文字: 派 --*/
|
||||||
|
/*-- 微软雅黑24; 此字体下对应的点阵为:宽x高=32x41 --*/
|
||||||
|
{{"派"},{
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x3E,
|
||||||
|
0x7C,0x00,0x3F,0xFE,0x3F,0x3F,0xFF,0xF0,0x1F,0xBF,0xE0,0x00,0x07,0xBC,0x00,0x00,
|
||||||
|
0x03,0x3C,0x00,0x00,0x00,0x3C,0x00,0x3C,0x00,0x3C,0x0F,0xFE,0x70,0x3D,0xFF,0xF8,
|
||||||
|
0xF8,0x3D,0xFF,0x00,0x7C,0x3D,0xE7,0x80,0x3F,0x3D,0xE7,0x80,0x1F,0x3D,0xE7,0x8E,
|
||||||
|
0x0E,0x3D,0xE7,0x9F,0x00,0x3D,0xE7,0xFE,0x00,0x39,0xE7,0xF8,0x00,0x39,0xE3,0xF0,
|
||||||
|
0x1C,0x39,0xE3,0xC0,0x1E,0x79,0xE3,0xC0,0x1E,0x79,0xE1,0xE0,0x1E,0x79,0xE1,0xE0,
|
||||||
|
0x3C,0x79,0xE0,0xF0,0x3C,0x79,0xE0,0xF8,0x3C,0xF1,0xE0,0x7C,0x3C,0xF1,0xE3,0x7C,
|
||||||
|
0x7D,0xF1,0xEF,0x3F,0x79,0xE1,0xFE,0x1F,0x7B,0xE1,0xF8,0x0E,0x7B,0xC3,0xE0,0x00,
|
||||||
|
0x79,0x81,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00}},
|
||||||
|
|
||||||
|
/*-- 文字: A --*/
|
||||||
|
/*-- 微软雅黑24; 此字体下对应的点阵为:宽x高=32x41 --*/
|
||||||
|
{{
|
||||||
|
"A"},{
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x7C,0x00,0x00,0x00,0xFC,0x00,0x00,0x00,0xFE,0x00,0x00,0x00,0xFE,0x00,0x00,
|
||||||
|
0x01,0xFF,0x00,0x00,0x01,0xFF,0x00,0x00,0x01,0xEF,0x00,0x00,0x03,0xEF,0x80,0x00,
|
||||||
|
0x03,0xCF,0x80,0x00,0x07,0xC7,0x80,0x00,0x07,0xC7,0xC0,0x00,0x07,0x87,0xC0,0x00,
|
||||||
|
0x0F,0x83,0xE0,0x00,0x0F,0x83,0xE0,0x00,0x0F,0x01,0xE0,0x00,0x1F,0xFF,0xF0,0x00,
|
||||||
|
0x1F,0xFF,0xF0,0x00,0x3F,0xFF,0xF8,0x00,0x3E,0x00,0xF8,0x00,0x3C,0x00,0xF8,0x00,
|
||||||
|
0x7C,0x00,0x7C,0x00,0x7C,0x00,0x7C,0x00,0x78,0x00,0x3C,0x00,0xF8,0x00,0x3E,0x00,
|
||||||
|
0xF8,0x00,0x3E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00}},
|
||||||
|
|
||||||
|
/*-- 文字: a --*/
|
||||||
|
/*-- 微软雅黑24; 此字体下对应的点阵为:宽x高=32x41 --*/
|
||||||
|
{{"a"},{
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xF8,0x00,0x00,
|
||||||
|
0x1F,0xFE,0x00,0x00,0x3F,0xFE,0x00,0x00,0x3E,0x3F,0x00,0x00,0x38,0x1F,0x00,0x00,
|
||||||
|
0x00,0x0F,0x00,0x00,0x00,0x0F,0x00,0x00,0x03,0xFF,0x00,0x00,0x1F,0xFF,0x00,0x00,
|
||||||
|
0x3F,0x8F,0x00,0x00,0x7C,0x0F,0x00,0x00,0x7C,0x0F,0x00,0x00,0x78,0x1F,0x00,0x00,
|
||||||
|
0x7C,0x1F,0x00,0x00,0x7E,0x7F,0x00,0x00,0x7F,0xFF,0x00,0x00,0x3F,0xFF,0x00,0x00,
|
||||||
|
0x0F,0xCF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00}},
|
||||||
|
|
||||||
|
/*-- 文字: b --*/
|
||||||
|
/*-- 微软雅黑24; 此字体下对应的点阵为:宽x高=32x41 --*/
|
||||||
|
{{"b"},{
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x00,0x00,0x00,
|
||||||
|
0x3C,0x00,0x00,0x00,0x3C,0x00,0x00,0x00,0x3C,0x00,0x00,0x00,0x3C,0x00,0x00,0x00,
|
||||||
|
0x3C,0x00,0x00,0x00,0x3C,0x00,0x00,0x00,0x3C,0x00,0x00,0x00,0x3C,0xFE,0x00,0x00,
|
||||||
|
0x3D,0xFF,0x80,0x00,0x3F,0xFF,0xC0,0x00,0x3F,0x8F,0xC0,0x00,0x3F,0x07,0xE0,0x00,
|
||||||
|
0x3E,0x03,0xE0,0x00,0x3E,0x03,0xE0,0x00,0x3C,0x01,0xE0,0x00,0x3C,0x01,0xE0,0x00,
|
||||||
|
0x3C,0x01,0xE0,0x00,0x3C,0x03,0xE0,0x00,0x3E,0x03,0xE0,0x00,0x3E,0x03,0xE0,0x00,
|
||||||
|
0x3F,0x07,0xC0,0x00,0x3F,0x8F,0xC0,0x00,0x3F,0xFF,0x80,0x00,0x3F,0xFF,0x00,0x00,
|
||||||
|
0x3C,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00}},
|
||||||
|
|
||||||
|
/*-- 文字: c --*/
|
||||||
|
/*-- 微软雅黑24; 此字体下对应的点阵为:宽x高=32x41 --*/
|
||||||
|
{{"c"},{
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xFC,0x00,0x00,
|
||||||
|
0x07,0xFE,0x00,0x00,0x1F,0xFE,0x00,0x00,0x3F,0x86,0x00,0x00,0x3E,0x00,0x00,0x00,
|
||||||
|
0x7C,0x00,0x00,0x00,0x7C,0x00,0x00,0x00,0x7C,0x00,0x00,0x00,0x78,0x00,0x00,0x00,
|
||||||
|
0x78,0x00,0x00,0x00,0x7C,0x00,0x00,0x00,0x7C,0x00,0x00,0x00,0x7C,0x00,0x00,0x00,
|
||||||
|
0x3E,0x00,0x00,0x00,0x3F,0x86,0x00,0x00,0x1F,0xFE,0x00,0x00,0x0F,0xFE,0x00,0x00,
|
||||||
|
0x03,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00}},
|
||||||
|
|
||||||
|
/*-- 文字: 微 --*/
|
||||||
|
/*-- 微软雅黑24; 此字体下对应的点阵为:宽x高=32x41 --*/
|
||||||
|
{{"微"},{
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x07,0x01,0xE0,0x07,0x87,0x01,0xE0,
|
||||||
|
0x07,0x07,0x01,0xC0,0x0F,0xF7,0x79,0xC0,0x1E,0xF7,0x7B,0xC0,0x1E,0xF7,0x7B,0x80,
|
||||||
|
0x3C,0xF7,0x7B,0xFF,0x78,0xF7,0x7B,0xFF,0xF8,0xF7,0x7F,0x9E,0xF7,0xFF,0xFF,0x9E,
|
||||||
|
0x67,0xFF,0xFF,0x9E,0x07,0x00,0x7F,0x9C,0x0F,0x00,0x0F,0x9C,0x1E,0x00,0x1F,0x9C,
|
||||||
|
0x1E,0x7F,0xFF,0xBC,0x3E,0x7F,0xF3,0xFC,0x3E,0x00,0x03,0xFC,0x7E,0x00,0x01,0xF8,
|
||||||
|
0xFE,0x00,0x01,0xF8,0xFE,0x7F,0xE1,0xF8,0xDE,0x7F,0xE1,0xF8,0x1E,0x78,0xE0,0xF0,
|
||||||
|
0x1E,0x78,0xEE,0xF0,0x1E,0x78,0xFF,0xF0,0x1E,0x78,0xFD,0xF8,0x1E,0x79,0xFB,0xFC,
|
||||||
|
0x1E,0xF1,0xF7,0xBC,0x1E,0xF0,0xEF,0x9E,0x1F,0xE0,0x0F,0x0F,0x1E,0xC0,0x1E,0x0F,
|
||||||
|
0x1E,0x00,0x0C,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00}},
|
||||||
|
|
||||||
|
/*-- 文字: 雪 --*/
|
||||||
|
/*-- 微软雅黑24; 此字体下对应的点阵为:宽x高=32x41 --*/
|
||||||
|
{{"雪"},{
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x1F,0xFF,0xFF,0xF8,0x1F,0xFF,0xFF,0xF8,0x00,0x03,0xC0,0x00,0x00,0x03,0xC0,0x00,
|
||||||
|
0x7F,0xFF,0xFF,0xFE,0x7F,0xFF,0xFF,0xFE,0x78,0x03,0xC0,0x1E,0x78,0x03,0xC0,0x1E,
|
||||||
|
0x7F,0xFF,0xFF,0xFE,0x7F,0xFF,0xFF,0xFE,0x00,0x03,0xC0,0x00,0x00,0x03,0xC0,0x00,
|
||||||
|
0x07,0xFF,0xFF,0xE0,0x07,0xFF,0xFF,0xE0,0x00,0x03,0xC0,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x1F,0xFF,0xFF,0xF8,0x1F,0xFF,0xFF,0xF8,0x00,0x00,0x00,0x78,0x00,0x00,0x00,0x78,
|
||||||
|
0x1F,0xFF,0xFF,0xF8,0x1F,0xFF,0xFF,0xF8,0x00,0x00,0x00,0x78,0x00,0x00,0x00,0x78,
|
||||||
|
0x00,0x00,0x00,0x78,0x3F,0xFF,0xFF,0xF8,0x3F,0xFF,0xFF,0xF8,0x00,0x00,0x00,0x78,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00}},
|
||||||
|
|
||||||
|
/*-- 文字: 电 --*/
|
||||||
|
/*-- 微软雅黑24; 此字体下对应的点阵为:宽x高=32x41 --*/
|
||||||
|
{{"电"},{
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x80,0x00,0x00,0x07,0x80,0x00,
|
||||||
|
0x00,0x07,0x80,0x00,0x00,0x07,0x80,0x00,0x7F,0xFF,0xFF,0xF8,0x7F,0xFF,0xFF,0xF8,
|
||||||
|
0x78,0x07,0x80,0xF8,0x78,0x07,0x80,0xF8,0x78,0x07,0x80,0xF8,0x78,0x07,0x80,0xF8,
|
||||||
|
0x78,0x07,0x80,0xF8,0x78,0x07,0x80,0xF8,0x7F,0xFF,0xFF,0xF8,0x7F,0xFF,0xFF,0xF8,
|
||||||
|
0x78,0x07,0x80,0xF8,0x78,0x07,0x80,0xF8,0x78,0x07,0x80,0xF8,0x78,0x07,0x80,0xF8,
|
||||||
|
0x78,0x07,0x80,0xF8,0x78,0x07,0x80,0xF8,0x7F,0xFF,0xFF,0xF8,0x7F,0xFF,0xFF,0xF8,
|
||||||
|
0x78,0x07,0x80,0x0E,0x78,0x07,0x80,0x0F,0x00,0x07,0x80,0x0F,0x00,0x07,0x80,0x0F,
|
||||||
|
0x00,0x07,0x80,0x1F,0x00,0x07,0x80,0x1E,0x00,0x03,0xFF,0xFE,0x00,0x01,0xFF,0xFC,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00}},
|
||||||
|
|
||||||
|
/*-- 文字: 子 --*/
|
||||||
|
/*-- 微软雅黑24; 此字体下对应的点阵为:宽x高=32x41 --*/
|
||||||
|
{{"子"},{
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x1F,0xFF,0xFF,0xF8,0x1F,0xFF,0xFF,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x07,0xE0,
|
||||||
|
0x00,0x00,0x0F,0xC0,0x00,0x00,0x1F,0x80,0x00,0x00,0x3E,0x00,0x00,0x00,0xFC,0x00,
|
||||||
|
0x00,0x01,0xF8,0x00,0x00,0x03,0xE0,0x00,0x00,0x03,0xE0,0x00,0x00,0x03,0xE0,0x00,
|
||||||
|
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x03,0xE0,0x00,0x00,0x03,0xE0,0x00,
|
||||||
|
0x00,0x03,0xE0,0x00,0x00,0x03,0xE0,0x00,0x00,0x03,0xE0,0x00,0x00,0x03,0xE0,0x00,
|
||||||
|
0x00,0x03,0xE0,0x00,0x00,0x03,0xE0,0x00,0x00,0x03,0xE0,0x00,0x00,0x03,0xE0,0x00,
|
||||||
|
0x00,0x03,0xE0,0x00,0x00,0x03,0xC0,0x00,0x01,0xFF,0xC0,0x00,0x00,0xFF,0x80,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00}},
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
cFONT Font24CN = {
|
||||||
|
Font24CN_Table,
|
||||||
|
sizeof(Font24CN_Table)/sizeof(CH_CN), /*size of table*/
|
||||||
|
24, /* ASCII Width */
|
||||||
|
32, /* Width */
|
||||||
|
41, /* Height */
|
||||||
|
};
|
||||||
|
|
||||||
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file fonts.h
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @version V1.0.0
|
||||||
|
* @date 18-February-2014
|
||||||
|
* @brief Header for fonts.c file
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef __FONTS_H
|
||||||
|
#define __FONTS_H
|
||||||
|
|
||||||
|
/*最大字体微软雅黑24 (32x41) */
|
||||||
|
#define MAX_HEIGHT_FONT 41
|
||||||
|
#define MAX_WIDTH_FONT 32
|
||||||
|
#define OFFSET_BITMAP
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
//ASCII
|
||||||
|
typedef struct _tFont
|
||||||
|
{
|
||||||
|
const uint8_t *table;
|
||||||
|
uint16_t Width;
|
||||||
|
uint16_t Height;
|
||||||
|
|
||||||
|
} sFONT;
|
||||||
|
|
||||||
|
|
||||||
|
//GB2312
|
||||||
|
typedef struct // 汉字字模数据结构
|
||||||
|
{
|
||||||
|
const char index[2]; // 汉字内码索引
|
||||||
|
const char matrix[MAX_HEIGHT_FONT*MAX_WIDTH_FONT/8+2]; // 点阵码数据
|
||||||
|
}CH_CN;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
const CH_CN *table;
|
||||||
|
uint16_t size;
|
||||||
|
uint16_t ASCII_Width;
|
||||||
|
uint16_t Width;
|
||||||
|
uint16_t Height;
|
||||||
|
|
||||||
|
}cFONT;
|
||||||
|
|
||||||
|
extern sFONT Font24;
|
||||||
|
extern sFONT Font20;
|
||||||
|
extern sFONT Font16;
|
||||||
|
extern sFONT Font12;
|
||||||
|
extern sFONT Font8;
|
||||||
|
|
||||||
|
extern cFONT Font12CN;
|
||||||
|
extern cFONT Font24CN;
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __FONTS_H */
|
||||||
|
|
||||||
|
|
||||||
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||||
@@ -0,0 +1,286 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : GUI_BMPfile.h
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : Hardware underlying interface
|
||||||
|
* | Info :
|
||||||
|
* Used to shield the underlying layers of each master
|
||||||
|
* and enhance portability
|
||||||
|
*----------------
|
||||||
|
* | This version: V2.2
|
||||||
|
* | Date : 2020-07-08
|
||||||
|
* | Info :
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
* V2.2(2020-07-08):
|
||||||
|
* 1.Add GUI_ReadBmp_RGB_7Color()
|
||||||
|
* V2.1(2019-10-10):
|
||||||
|
* 1.Add GUI_ReadBmp_4Gray()
|
||||||
|
* V2.0(2018-11-12):
|
||||||
|
* 1.Change file name: GUI_BMP.h -> GUI_BMPfile.h
|
||||||
|
* 2.fix: GUI_ReadBmp()
|
||||||
|
* Now Xstart and Xstart can control the position of the picture normally,
|
||||||
|
* and support the display of images of any size. If it is larger than
|
||||||
|
* the actual display range, it will not be displayed.
|
||||||
|
#
|
||||||
|
# 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 "GUI_BMPfile.h"
|
||||||
|
#include "GUI_Paint.h"
|
||||||
|
#include "Debug.h"
|
||||||
|
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h> //exit()
|
||||||
|
#include <string.h> //memset()
|
||||||
|
#include <math.h> //memset()
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
UBYTE GUI_ReadBmp(const char *path, UWORD Xstart, UWORD Ystart)
|
||||||
|
{
|
||||||
|
FILE *fp; //Define a file pointer
|
||||||
|
BMPFILEHEADER bmpFileHeader; //Define a bmp file header structure
|
||||||
|
BMPINFOHEADER bmpInfoHeader; //Define a bmp info header structure
|
||||||
|
|
||||||
|
|
||||||
|
// Binary file open
|
||||||
|
if((fp = fopen(path, "rb")) == NULL) {
|
||||||
|
Debug("Cann't open the file!\n");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the file pointer from the beginning
|
||||||
|
fseek(fp, 0, SEEK_SET);
|
||||||
|
fread(&bmpFileHeader, sizeof(BMPFILEHEADER), 1, fp); //sizeof(BMPFILEHEADER) must be 14
|
||||||
|
fread(&bmpInfoHeader, sizeof(BMPINFOHEADER), 1, fp); //sizeof(BMPFILEHEADER) must be 50
|
||||||
|
printf("pixel = %d * %d\r\n", bmpInfoHeader.biWidth, bmpInfoHeader.biHeight);
|
||||||
|
|
||||||
|
UWORD Image_Width_Byte = (bmpInfoHeader.biWidth % 8 == 0)? (bmpInfoHeader.biWidth / 8): (bmpInfoHeader.biWidth / 8 + 1);
|
||||||
|
UWORD Bmp_Width_Byte = (Image_Width_Byte % 4 == 0) ? Image_Width_Byte: ((Image_Width_Byte / 4 + 1) * 4);
|
||||||
|
UBYTE Image[Image_Width_Byte * bmpInfoHeader.biHeight];
|
||||||
|
memset(Image, 0xFF, Image_Width_Byte * bmpInfoHeader.biHeight);
|
||||||
|
|
||||||
|
// Determine if it is a monochrome bitmap
|
||||||
|
int readbyte = bmpInfoHeader.biBitCount;
|
||||||
|
if(readbyte != 1) {
|
||||||
|
Debug("the bmp Image is not a monochrome bitmap!\n");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Determine black and white based on the palette
|
||||||
|
UWORD i;
|
||||||
|
UWORD Bcolor, Wcolor;
|
||||||
|
UWORD bmprgbquadsize = pow(2, bmpInfoHeader.biBitCount);// 2^1 = 2
|
||||||
|
BMPRGBQUAD bmprgbquad[bmprgbquadsize]; //palette
|
||||||
|
// BMPRGBQUAD bmprgbquad[2]; //palette
|
||||||
|
|
||||||
|
for(i = 0; i < bmprgbquadsize; i++){
|
||||||
|
// for(i = 0; i < 2; i++) {
|
||||||
|
fread(&bmprgbquad[i], sizeof(BMPRGBQUAD), 1, fp);
|
||||||
|
}
|
||||||
|
if(bmprgbquad[0].rgbBlue == 0xff && bmprgbquad[0].rgbGreen == 0xff && bmprgbquad[0].rgbRed == 0xff) {
|
||||||
|
Bcolor = BLACK;
|
||||||
|
Wcolor = WHITE;
|
||||||
|
} else {
|
||||||
|
Bcolor = WHITE;
|
||||||
|
Wcolor = BLACK;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read image data into the cache
|
||||||
|
UWORD x, y;
|
||||||
|
UBYTE Rdata;
|
||||||
|
fseek(fp, bmpFileHeader.bOffset, SEEK_SET);
|
||||||
|
for(y = 0; y < bmpInfoHeader.biHeight; y++) {//Total display column
|
||||||
|
for(x = 0; x < Bmp_Width_Byte; x++) {//Show a line in the line
|
||||||
|
if(fread((char *)&Rdata, 1, readbyte, fp) != readbyte) {
|
||||||
|
perror("get bmpdata:\r\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(x < Image_Width_Byte) { //bmp
|
||||||
|
Image[x + (bmpInfoHeader.biHeight - y - 1) * Image_Width_Byte] = Rdata;
|
||||||
|
// printf("rdata = %d\r\n", Rdata);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose(fp);
|
||||||
|
|
||||||
|
// Refresh the image to the display buffer based on the displayed orientation
|
||||||
|
UBYTE color, temp;
|
||||||
|
for(y = 0; y < bmpInfoHeader.biHeight; y++) {
|
||||||
|
for(x = 0; x < bmpInfoHeader.biWidth; x++) {
|
||||||
|
if(x > Paint.Width || y > Paint.Height) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
temp = Image[(x / 8) + (y * Image_Width_Byte)];
|
||||||
|
color = (((temp << (x%8)) & 0x80) == 0x80) ?Bcolor:Wcolor;
|
||||||
|
Paint_SetPixel(Xstart + x, Ystart + y, color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/*************************************************************************
|
||||||
|
|
||||||
|
*************************************************************************/
|
||||||
|
UBYTE GUI_ReadBmp_4Gray(const char *path, UWORD Xstart, UWORD Ystart)
|
||||||
|
{
|
||||||
|
FILE *fp; //Define a file pointer
|
||||||
|
BMPFILEHEADER bmpFileHeader; //Define a bmp file header structure
|
||||||
|
BMPINFOHEADER bmpInfoHeader; //Define a bmp info header structure
|
||||||
|
|
||||||
|
// Binary file open
|
||||||
|
if((fp = fopen(path, "rb")) == NULL) {
|
||||||
|
Debug("Cann't open the file!\n");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the file pointer from the beginning
|
||||||
|
fseek(fp, 0, SEEK_SET);
|
||||||
|
fread(&bmpFileHeader, sizeof(BMPFILEHEADER), 1, fp); //sizeof(BMPFILEHEADER) must be 14
|
||||||
|
fread(&bmpInfoHeader, sizeof(BMPINFOHEADER), 1, fp); //sizeof(BMPFILEHEADER) must be 50
|
||||||
|
printf("pixel = %d * %d\r\n", bmpInfoHeader.biWidth, bmpInfoHeader.biHeight);
|
||||||
|
|
||||||
|
UWORD Image_Width_Byte = (bmpInfoHeader.biWidth % 4 == 0)? (bmpInfoHeader.biWidth / 4): (bmpInfoHeader.biWidth / 4 + 1);
|
||||||
|
UWORD Bmp_Width_Byte = (bmpInfoHeader.biWidth % 2 == 0)? (bmpInfoHeader.biWidth / 2): (bmpInfoHeader.biWidth / 2 + 1);
|
||||||
|
UBYTE Image[Image_Width_Byte * bmpInfoHeader.biHeight * 2];
|
||||||
|
memset(Image, 0xFF, Image_Width_Byte * bmpInfoHeader.biHeight * 2);
|
||||||
|
|
||||||
|
// Determine if it is a monochrome bitmap
|
||||||
|
int readbyte = bmpInfoHeader.biBitCount;
|
||||||
|
printf("biBitCount = %d\r\n",readbyte);
|
||||||
|
if(readbyte != 4){
|
||||||
|
Debug("Bmp image is not a 4-color bitmap!\n");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
// Read image data into the cache
|
||||||
|
UWORD x, y;
|
||||||
|
UBYTE Rdata;
|
||||||
|
fseek(fp, bmpFileHeader.bOffset, SEEK_SET);
|
||||||
|
|
||||||
|
for(y = 0; y < bmpInfoHeader.biHeight; y++) {//Total display column
|
||||||
|
for(x = 0; x < Bmp_Width_Byte; x++) {//Show a line in the line
|
||||||
|
if(fread((char *)&Rdata, 1, 1, fp) != 1) {
|
||||||
|
perror("get bmpdata:\r\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(x < Image_Width_Byte*2) { //bmp
|
||||||
|
Image[x + (bmpInfoHeader.biHeight - y - 1) * Image_Width_Byte*2] = Rdata;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose(fp);
|
||||||
|
|
||||||
|
// Refresh the image to the display buffer based on the displayed orientation
|
||||||
|
UBYTE color, temp;
|
||||||
|
printf("bmpInfoHeader.biWidth = %d\r\n",bmpInfoHeader.biWidth);
|
||||||
|
printf("bmpInfoHeader.biHeight = %d\r\n",bmpInfoHeader.biHeight);
|
||||||
|
for(y = 0; y < bmpInfoHeader.biHeight; y++) {
|
||||||
|
for(x = 0; x < bmpInfoHeader.biWidth; x++) {
|
||||||
|
if(x > Paint.Width || y > Paint.Height) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
temp = Image[x/2 + y * bmpInfoHeader.biWidth/2] >> ((x%2)? 0:4);//0xf 0x8 0x7 0x0
|
||||||
|
color = temp>>2; //11 10 01 00
|
||||||
|
Paint_SetPixel(Xstart + x, Ystart + y, color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
UBYTE GUI_ReadBmp_RGB_7Color(const char *path, UWORD Xstart, UWORD Ystart)
|
||||||
|
{
|
||||||
|
FILE *fp; //Define a file pointer
|
||||||
|
BMPFILEHEADER bmpFileHeader; //Define a bmp file header structure
|
||||||
|
BMPINFOHEADER bmpInfoHeader; //Define a bmp info header structure
|
||||||
|
|
||||||
|
// Binary file open
|
||||||
|
if((fp = fopen(path, "rb")) == NULL) {
|
||||||
|
Debug("Cann't open the file!\n");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the file pointer from the beginning
|
||||||
|
fseek(fp, 0, SEEK_SET);
|
||||||
|
fread(&bmpFileHeader, sizeof(BMPFILEHEADER), 1, fp); //sizeof(BMPFILEHEADER) must be 14
|
||||||
|
fread(&bmpInfoHeader, sizeof(BMPINFOHEADER), 1, fp); //sizeof(BMPFILEHEADER) must be 50
|
||||||
|
printf("pixel = %d * %d\r\n", bmpInfoHeader.biWidth, bmpInfoHeader.biHeight);
|
||||||
|
|
||||||
|
UDOUBLE Image_Byte = bmpInfoHeader.biWidth * bmpInfoHeader.biHeight * 3;
|
||||||
|
UBYTE Image[Image_Byte];
|
||||||
|
memset(Image, 0xFF, Image_Byte);
|
||||||
|
|
||||||
|
// Determine if it is a monochrome bitmap
|
||||||
|
int readbyte = bmpInfoHeader.biBitCount;
|
||||||
|
if(readbyte != 24){
|
||||||
|
Debug("Bmp image is not 24 bitmap!\n");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
// Read image data into the cache
|
||||||
|
UWORD x, y;
|
||||||
|
UBYTE Rdata[3];
|
||||||
|
fseek(fp, bmpFileHeader.bOffset, SEEK_SET);
|
||||||
|
|
||||||
|
for(y = 0; y < bmpInfoHeader.biHeight; y++) {//Total display column
|
||||||
|
for(x = 0; x < bmpInfoHeader.biWidth ; x++) {//Show a line in the line
|
||||||
|
if(fread((char *)Rdata, 1, 1, fp) != 1) {
|
||||||
|
perror("get bmpdata:\r\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(fread((char *)Rdata+1, 1, 1, fp) != 1) {
|
||||||
|
perror("get bmpdata:\r\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(fread((char *)Rdata+2, 1, 1, fp) != 1) {
|
||||||
|
perror("get bmpdata:\r\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Rdata[0] == 0 && Rdata[1] == 0 && Rdata[2] == 0){
|
||||||
|
Image[x+(y* bmpInfoHeader.biWidth )] = 0;//Black
|
||||||
|
}else if(Rdata[0] == 255 && Rdata[1] == 255 && Rdata[2] == 255){
|
||||||
|
Image[x+(y* bmpInfoHeader.biWidth )] = 1;//White
|
||||||
|
}else if(Rdata[0] == 0 && Rdata[1] == 255 && Rdata[2] == 0){
|
||||||
|
Image[x+(y* bmpInfoHeader.biWidth )] = 2;//Green
|
||||||
|
}else if(Rdata[0] == 255 && Rdata[1] == 0 && Rdata[2] == 0){
|
||||||
|
Image[x+(y* bmpInfoHeader.biWidth )] = 3;//Blue
|
||||||
|
}else if(Rdata[0] == 0 && Rdata[1] == 0 && Rdata[2] == 255){
|
||||||
|
Image[x+(y* bmpInfoHeader.biWidth )] = 4;//Red
|
||||||
|
}else if(Rdata[0] == 0 && Rdata[1] == 255 && Rdata[2] == 255){
|
||||||
|
Image[x+(y* bmpInfoHeader.biWidth )] = 5;//Yellow
|
||||||
|
}else if(Rdata[0] == 0 && Rdata[1] == 128 && Rdata[2] == 255){
|
||||||
|
Image[x+(y* bmpInfoHeader.biWidth )] = 6;//Orange
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose(fp);
|
||||||
|
|
||||||
|
// Refresh the image to the display buffer based on the displayed orientation
|
||||||
|
for(y = 0; y < bmpInfoHeader.biHeight; y++) {
|
||||||
|
for(x = 0; x < bmpInfoHeader.biWidth; x++) {
|
||||||
|
if(x > Paint.Width || y > Paint.Height) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Paint_SetPixel(Xstart + x, Ystart + y, Image[bmpInfoHeader.biHeight * bmpInfoHeader.biWidth - 1 -(bmpInfoHeader.biWidth-x-1+(y* bmpInfoHeader.biWidth))]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* | File : GUI_BMPfile.h
|
||||||
|
* | Author : Waveshare team
|
||||||
|
* | Function : Hardware underlying interface
|
||||||
|
* | Info :
|
||||||
|
* Used to shield the underlying layers of each master
|
||||||
|
* and enhance portability
|
||||||
|
*----------------
|
||||||
|
* | This version: V2.2
|
||||||
|
* | Date : 2020-07-08
|
||||||
|
* | Info :
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
* V2.2(2020-07-08):
|
||||||
|
* 1.Add GUI_ReadBmp_RGB_7Color()
|
||||||
|
* V2.1(2019-10-10):
|
||||||
|
* 1.Add GUI_ReadBmp_4Gray()
|
||||||
|
* V2.0(2018-11-12):
|
||||||
|
* 1.Change file name: GUI_BMP.h -> GUI_BMPfile.h
|
||||||
|
* 2.fix: GUI_ReadBmp()
|
||||||
|
* Now Xstart and Xstart can control the position of the picture normally,
|
||||||
|
* and support the display of images of any size. If it is larger than
|
||||||
|
* the actual display range, it will not be displayed.
|
||||||
|
#
|
||||||
|
# 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 __GUI_BMPFILE_H
|
||||||
|
#define __GUI_BMPFILE_H
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "DEV_Config.h"
|
||||||
|
|
||||||
|
/*Bitmap file header 14bit*/
|
||||||
|
typedef struct BMP_FILE_HEADER {
|
||||||
|
UWORD bType; //File identifier
|
||||||
|
UDOUBLE bSize; //The size of the file
|
||||||
|
UWORD bReserved1; //Reserved value, must be set to 0
|
||||||
|
UWORD bReserved2; //Reserved value, must be set to 0
|
||||||
|
UDOUBLE bOffset; //The offset from the beginning of the file header to the beginning of the image data bit
|
||||||
|
} __attribute__ ((packed)) BMPFILEHEADER; // 14bit
|
||||||
|
|
||||||
|
/*Bitmap information header 40bit*/
|
||||||
|
typedef struct BMP_INFO {
|
||||||
|
UDOUBLE biInfoSize; //The size of the header
|
||||||
|
UDOUBLE biWidth; //The width of the image
|
||||||
|
UDOUBLE biHeight; //The height of the image
|
||||||
|
UWORD biPlanes; //The number of planes in the image
|
||||||
|
UWORD biBitCount; //The number of bits per pixel
|
||||||
|
UDOUBLE biCompression; //Compression type
|
||||||
|
UDOUBLE bimpImageSize; //The size of the image, in bytes
|
||||||
|
UDOUBLE biXPelsPerMeter; //Horizontal resolution
|
||||||
|
UDOUBLE biYPelsPerMeter; //Vertical resolution
|
||||||
|
UDOUBLE biClrUsed; //The number of colors used
|
||||||
|
UDOUBLE biClrImportant; //The number of important colors
|
||||||
|
} __attribute__ ((packed)) BMPINFOHEADER;
|
||||||
|
|
||||||
|
/*Color table: palette */
|
||||||
|
typedef struct RGB_QUAD {
|
||||||
|
UBYTE rgbBlue; //Blue intensity
|
||||||
|
UBYTE rgbGreen; //Green strength
|
||||||
|
UBYTE rgbRed; //Red intensity
|
||||||
|
UBYTE rgbReversed; //Reserved value
|
||||||
|
} __attribute__ ((packed)) BMPRGBQUAD;
|
||||||
|
/**************************************** end ***********************************************/
|
||||||
|
|
||||||
|
UBYTE GUI_ReadBmp(const char *path, UWORD Xstart, UWORD Ystart);
|
||||||
|
UBYTE GUI_ReadBmp_4Gray(const char *path, UWORD Xstart, UWORD Ystart);
|
||||||
|
UBYTE GUI_ReadBmp_RGB_7Color(const char *path, UWORD Xstart, UWORD Ystart);
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,798 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* | File : GUI_Paint.c
|
||||||
|
* | Author : Waveshare electronics
|
||||||
|
* | Function : Achieve drawing: draw points, lines, boxes, circles and
|
||||||
|
* their size, solid dotted line, solid rectangle hollow
|
||||||
|
* rectangle, solid circle hollow circle.
|
||||||
|
* | Info :
|
||||||
|
* Achieve display characters: Display a single character, string, number
|
||||||
|
* Achieve time display: adaptive size display time minutes and seconds
|
||||||
|
*----------------
|
||||||
|
* | This version: V3.2
|
||||||
|
* | Date : 2020-07-10
|
||||||
|
* | Info :
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
* V3.2(2020-07-10):
|
||||||
|
* 1.Change: Paint_SetScale(UBYTE scale)
|
||||||
|
* Add scale 7 for 5.65f e-Parper
|
||||||
|
* 2.Change: Paint_SetPixel(UWORD Xpoint, UWORD Ypoint, UWORD Color)
|
||||||
|
* Add the branch for scale 7
|
||||||
|
* 3.Change: Paint_Clear(UWORD Color)
|
||||||
|
* Add the branch for scale 7
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
* V3.1(2019-10-10):
|
||||||
|
* 1. Add gray level
|
||||||
|
* PAINT Add Scale
|
||||||
|
* 2. Add void Paint_SetScale(UBYTE scale);
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
* V3.0(2019-04-18):
|
||||||
|
* 1.Change:
|
||||||
|
* Paint_DrawPoint(..., DOT_STYLE DOT_STYLE)
|
||||||
|
* => Paint_DrawPoint(..., DOT_STYLE Dot_Style)
|
||||||
|
* Paint_DrawLine(..., LINE_STYLE Line_Style, DOT_PIXEL Dot_Pixel)
|
||||||
|
* => Paint_DrawLine(..., DOT_PIXEL Line_width, LINE_STYLE Line_Style)
|
||||||
|
* Paint_DrawRectangle(..., DRAW_FILL Filled, DOT_PIXEL Dot_Pixel)
|
||||||
|
* => Paint_DrawRectangle(..., DOT_PIXEL Line_width, DRAW_FILL Draw_Fill)
|
||||||
|
* Paint_DrawCircle(..., DRAW_FILL Draw_Fill, DOT_PIXEL Dot_Pixel)
|
||||||
|
* => Paint_DrawCircle(..., DOT_PIXEL Line_width, DRAW_FILL Draw_Filll)
|
||||||
|
*
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
* V2.0(2018-11-15):
|
||||||
|
* 1.add: Paint_NewImage()
|
||||||
|
* Create an image's properties
|
||||||
|
* 2.add: Paint_SelectImage()
|
||||||
|
* Select the picture to be drawn
|
||||||
|
* 3.add: Paint_SetRotate()
|
||||||
|
* Set the direction of the cache
|
||||||
|
* 4.add: Paint_RotateImage()
|
||||||
|
* Can flip the picture, Support 0-360 degrees,
|
||||||
|
* but only 90.180.270 rotation is better
|
||||||
|
* 4.add: Paint_SetMirroring()
|
||||||
|
* Can Mirroring the picture, horizontal, vertical, origin
|
||||||
|
* 5.add: Paint_DrawString_CN()
|
||||||
|
* Can display Chinese(GB1312)
|
||||||
|
*
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
* V1.0(2018-07-17):
|
||||||
|
* Create library
|
||||||
|
*
|
||||||
|
* 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 "GUI_Paint.h"
|
||||||
|
#include "DEV_Config.h"
|
||||||
|
#include "Debug.h"
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h> //memset()
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
PAINT Paint;
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function: Create Image
|
||||||
|
parameter:
|
||||||
|
image : Pointer to the image cache
|
||||||
|
width : The width of the picture
|
||||||
|
Height : The height of the picture
|
||||||
|
Color : Whether the picture is inverted
|
||||||
|
******************************************************************************/
|
||||||
|
void Paint_NewImage(UBYTE *image, UWORD Width, UWORD Height, UWORD Rotate, UWORD Color)
|
||||||
|
{
|
||||||
|
Paint.Image = NULL;
|
||||||
|
Paint.Image = image;
|
||||||
|
|
||||||
|
Paint.WidthMemory = Width;
|
||||||
|
Paint.HeightMemory = Height;
|
||||||
|
Paint.Color = Color;
|
||||||
|
Paint.Scale = 2;
|
||||||
|
Paint.WidthByte = (Width % 8 == 0)? (Width / 8 ): (Width / 8 + 1);
|
||||||
|
Paint.HeightByte = Height;
|
||||||
|
// printf("WidthByte = %d, HeightByte = %d\r\n", Paint.WidthByte, Paint.HeightByte);
|
||||||
|
// printf(" EPD_WIDTH / 8 = %d\r\n", 122 / 8);
|
||||||
|
|
||||||
|
Paint.Rotate = Rotate;
|
||||||
|
Paint.Mirror = MIRROR_NONE;
|
||||||
|
|
||||||
|
if(Rotate == ROTATE_0 || Rotate == ROTATE_180) {
|
||||||
|
Paint.Width = Width;
|
||||||
|
Paint.Height = Height;
|
||||||
|
} else {
|
||||||
|
Paint.Width = Height;
|
||||||
|
Paint.Height = Width;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function: Select Image
|
||||||
|
parameter:
|
||||||
|
image : Pointer to the image cache
|
||||||
|
******************************************************************************/
|
||||||
|
void Paint_SelectImage(UBYTE *image)
|
||||||
|
{
|
||||||
|
Paint.Image = image;
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function: Select Image Rotate
|
||||||
|
parameter:
|
||||||
|
Rotate : 0,90,180,270
|
||||||
|
******************************************************************************/
|
||||||
|
void Paint_SetRotate(UWORD Rotate)
|
||||||
|
{
|
||||||
|
if(Rotate == ROTATE_0 || Rotate == ROTATE_90 || Rotate == ROTATE_180 || Rotate == ROTATE_270) {
|
||||||
|
Debug("Set image Rotate %d\r\n", Rotate);
|
||||||
|
Paint.Rotate = Rotate;
|
||||||
|
} else {
|
||||||
|
Debug("rotate = 0, 90, 180, 270\r\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function: Select Image mirror
|
||||||
|
parameter:
|
||||||
|
mirror :Not mirror,Horizontal mirror,Vertical mirror,Origin mirror
|
||||||
|
******************************************************************************/
|
||||||
|
void Paint_SetMirroring(UBYTE mirror)
|
||||||
|
{
|
||||||
|
if(mirror == MIRROR_NONE || mirror == MIRROR_HORIZONTAL ||
|
||||||
|
mirror == MIRROR_VERTICAL || mirror == MIRROR_ORIGIN) {
|
||||||
|
Debug("mirror image x:%s, y:%s\r\n",(mirror & 0x01)? "mirror":"none", ((mirror >> 1) & 0x01)? "mirror":"none");
|
||||||
|
Paint.Mirror = mirror;
|
||||||
|
} else {
|
||||||
|
Debug("mirror should be MIRROR_NONE, MIRROR_HORIZONTAL, \
|
||||||
|
MIRROR_VERTICAL or MIRROR_ORIGIN\r\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Paint_SetScale(UBYTE scale)
|
||||||
|
{
|
||||||
|
if(scale == 2){
|
||||||
|
Paint.Scale = scale;
|
||||||
|
Paint.WidthByte = (Paint.WidthMemory % 8 == 0)? (Paint.WidthMemory / 8 ): (Paint.WidthMemory / 8 + 1);
|
||||||
|
}else if(scale == 4){
|
||||||
|
Paint.Scale = scale;
|
||||||
|
Paint.WidthByte = (Paint.WidthMemory % 4 == 0)? (Paint.WidthMemory / 4 ): (Paint.WidthMemory / 4 + 1);
|
||||||
|
}else if(scale == 7){//Only applicable with 5in65 e-Paper
|
||||||
|
Paint.Scale = scale;
|
||||||
|
Paint.WidthByte = (Paint.WidthMemory % 2 == 0)? (Paint.WidthMemory / 2 ): (Paint.WidthMemory / 2 + 1);;
|
||||||
|
}else{
|
||||||
|
Debug("Set Scale Input parameter error\r\n");
|
||||||
|
Debug("Scale Only support: 2 4 7\r\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/******************************************************************************
|
||||||
|
function: Draw Pixels
|
||||||
|
parameter:
|
||||||
|
Xpoint : At point X
|
||||||
|
Ypoint : At point Y
|
||||||
|
Color : Painted colors
|
||||||
|
******************************************************************************/
|
||||||
|
void Paint_SetPixel(UWORD Xpoint, UWORD Ypoint, UWORD Color)
|
||||||
|
{
|
||||||
|
if(Xpoint > Paint.Width || Ypoint > Paint.Height){
|
||||||
|
Debug("Exceeding display boundaries\r\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
UWORD X, Y;
|
||||||
|
switch(Paint.Rotate) {
|
||||||
|
case 0:
|
||||||
|
X = Xpoint;
|
||||||
|
Y = Ypoint;
|
||||||
|
break;
|
||||||
|
case 90:
|
||||||
|
X = Paint.WidthMemory - Ypoint - 1;
|
||||||
|
Y = Xpoint;
|
||||||
|
break;
|
||||||
|
case 180:
|
||||||
|
X = Paint.WidthMemory - Xpoint - 1;
|
||||||
|
Y = Paint.HeightMemory - Ypoint - 1;
|
||||||
|
break;
|
||||||
|
case 270:
|
||||||
|
X = Ypoint;
|
||||||
|
Y = Paint.HeightMemory - Xpoint - 1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(Paint.Mirror) {
|
||||||
|
case MIRROR_NONE:
|
||||||
|
break;
|
||||||
|
case MIRROR_HORIZONTAL:
|
||||||
|
X = Paint.WidthMemory - X - 1;
|
||||||
|
break;
|
||||||
|
case MIRROR_VERTICAL:
|
||||||
|
Y = Paint.HeightMemory - Y - 1;
|
||||||
|
break;
|
||||||
|
case MIRROR_ORIGIN:
|
||||||
|
X = Paint.WidthMemory - X - 1;
|
||||||
|
Y = Paint.HeightMemory - Y - 1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(X > Paint.WidthMemory || Y > Paint.HeightMemory){
|
||||||
|
Debug("Exceeding display boundaries\r\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Paint.Scale == 2){
|
||||||
|
UDOUBLE Addr = X / 8 + Y * Paint.WidthByte;
|
||||||
|
UBYTE Rdata = Paint.Image[Addr];
|
||||||
|
if(Color == BLACK)
|
||||||
|
Paint.Image[Addr] = Rdata & ~(0x80 >> (X % 8));
|
||||||
|
else
|
||||||
|
Paint.Image[Addr] = Rdata | (0x80 >> (X % 8));
|
||||||
|
}else if(Paint.Scale == 4){
|
||||||
|
UDOUBLE Addr = X / 4 + Y * Paint.WidthByte;
|
||||||
|
Color = Color % 4;//Guaranteed color scale is 4 --- 0~3
|
||||||
|
UBYTE Rdata = Paint.Image[Addr];
|
||||||
|
|
||||||
|
Rdata = Rdata & (~(0xC0 >> ((X % 4)*2)));//Clear first, then set value
|
||||||
|
Paint.Image[Addr] = Rdata | ((Color << 6) >> ((X % 4)*2));
|
||||||
|
}else if(Paint.Scale == 7){
|
||||||
|
UDOUBLE Addr = X / 2 + Y * Paint.WidthByte;
|
||||||
|
UBYTE Rdata = Paint.Image[Addr];
|
||||||
|
Rdata = Rdata & (~(0xF0 >> ((X % 2)*4)));//Clear first, then set value
|
||||||
|
Paint.Image[Addr] = Rdata | ((Color << 4) >> ((X % 2)*4));
|
||||||
|
// printf("Add = %d ,data = %d\r\n",Addr,Rdata);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function: Clear the color of the picture
|
||||||
|
parameter:
|
||||||
|
Color : Painted colors
|
||||||
|
******************************************************************************/
|
||||||
|
void Paint_Clear(UWORD Color)
|
||||||
|
{
|
||||||
|
if(Paint.Scale == 2 || Paint.Scale == 4){
|
||||||
|
for (UWORD Y = 0; Y < Paint.HeightByte; Y++) {
|
||||||
|
for (UWORD X = 0; X < Paint.WidthByte; X++ ) {//8 pixel = 1 byte
|
||||||
|
UDOUBLE Addr = X + Y*Paint.WidthByte;
|
||||||
|
Paint.Image[Addr] = Color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else if(Paint.Scale == 7){
|
||||||
|
for (UWORD Y = 0; Y < Paint.HeightByte; Y++) {
|
||||||
|
for (UWORD X = 0; X < Paint.WidthByte; X++ ) {
|
||||||
|
UDOUBLE Addr = X + Y*Paint.WidthByte;
|
||||||
|
Paint.Image[Addr] = (Color<<4)|Color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function: Clear the color of a window
|
||||||
|
parameter:
|
||||||
|
Xstart : x starting point
|
||||||
|
Ystart : Y starting point
|
||||||
|
Xend : x end point
|
||||||
|
Yend : y end point
|
||||||
|
Color : Painted colors
|
||||||
|
******************************************************************************/
|
||||||
|
void Paint_ClearWindows(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, UWORD Color)
|
||||||
|
{
|
||||||
|
UWORD X, Y;
|
||||||
|
for (Y = Ystart; Y < Yend; Y++) {
|
||||||
|
for (X = Xstart; X < Xend; X++) {//8 pixel = 1 byte
|
||||||
|
Paint_SetPixel(X, Y, Color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function: Draw Point(Xpoint, Ypoint) Fill the color
|
||||||
|
parameter:
|
||||||
|
Xpoint : The Xpoint coordinate of the point
|
||||||
|
Ypoint : The Ypoint coordinate of the point
|
||||||
|
Color : Painted color
|
||||||
|
Dot_Pixel : point size
|
||||||
|
Dot_Style : point Style
|
||||||
|
******************************************************************************/
|
||||||
|
void Paint_DrawPoint(UWORD Xpoint, UWORD Ypoint, UWORD Color,
|
||||||
|
DOT_PIXEL Dot_Pixel, DOT_STYLE Dot_Style)
|
||||||
|
{
|
||||||
|
if (Xpoint > Paint.Width || Ypoint > Paint.Height) {
|
||||||
|
Debug("Paint_DrawPoint Input exceeds the normal display range\r\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int16_t XDir_Num , YDir_Num;
|
||||||
|
if (Dot_Style == DOT_FILL_AROUND) {
|
||||||
|
for (XDir_Num = 0; XDir_Num < 2 * Dot_Pixel - 1; XDir_Num++) {
|
||||||
|
for (YDir_Num = 0; YDir_Num < 2 * Dot_Pixel - 1; YDir_Num++) {
|
||||||
|
if(Xpoint + XDir_Num - Dot_Pixel < 0 || Ypoint + YDir_Num - Dot_Pixel < 0)
|
||||||
|
break;
|
||||||
|
// printf("x = %d, y = %d\r\n", Xpoint + XDir_Num - Dot_Pixel, Ypoint + YDir_Num - Dot_Pixel);
|
||||||
|
Paint_SetPixel(Xpoint + XDir_Num - Dot_Pixel, Ypoint + YDir_Num - Dot_Pixel, Color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (XDir_Num = 0; XDir_Num < Dot_Pixel; XDir_Num++) {
|
||||||
|
for (YDir_Num = 0; YDir_Num < Dot_Pixel; YDir_Num++) {
|
||||||
|
Paint_SetPixel(Xpoint + XDir_Num - 1, Ypoint + YDir_Num - 1, Color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function: Draw a line of arbitrary slope
|
||||||
|
parameter:
|
||||||
|
Xstart :Starting Xpoint point coordinates
|
||||||
|
Ystart :Starting Xpoint point coordinates
|
||||||
|
Xend :End point Xpoint coordinate
|
||||||
|
Yend :End point Ypoint coordinate
|
||||||
|
Color :The color of the line segment
|
||||||
|
Line_width : Line width
|
||||||
|
Line_Style: Solid and dotted lines
|
||||||
|
******************************************************************************/
|
||||||
|
void Paint_DrawLine(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend,
|
||||||
|
UWORD Color, DOT_PIXEL Line_width, LINE_STYLE Line_Style)
|
||||||
|
{
|
||||||
|
if (Xstart > Paint.Width || Ystart > Paint.Height ||
|
||||||
|
Xend > Paint.Width || Yend > Paint.Height) {
|
||||||
|
Debug("Paint_DrawLine Input exceeds the normal display range\r\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
UWORD Xpoint = Xstart;
|
||||||
|
UWORD Ypoint = Ystart;
|
||||||
|
int dx = (int)Xend - (int)Xstart >= 0 ? Xend - Xstart : Xstart - Xend;
|
||||||
|
int dy = (int)Yend - (int)Ystart <= 0 ? Yend - Ystart : Ystart - Yend;
|
||||||
|
|
||||||
|
// Increment direction, 1 is positive, -1 is counter;
|
||||||
|
int XAddway = Xstart < Xend ? 1 : -1;
|
||||||
|
int YAddway = Ystart < Yend ? 1 : -1;
|
||||||
|
|
||||||
|
//Cumulative error
|
||||||
|
int Esp = dx + dy;
|
||||||
|
char Dotted_Len = 0;
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
Dotted_Len++;
|
||||||
|
//Painted dotted line, 2 point is really virtual
|
||||||
|
if (Line_Style == LINE_STYLE_DOTTED && Dotted_Len % 3 == 0) {
|
||||||
|
//Debug("LINE_DOTTED\r\n");
|
||||||
|
Paint_DrawPoint(Xpoint, Ypoint, IMAGE_BACKGROUND, Line_width, DOT_STYLE_DFT);
|
||||||
|
Dotted_Len = 0;
|
||||||
|
} else {
|
||||||
|
Paint_DrawPoint(Xpoint, Ypoint, Color, Line_width, DOT_STYLE_DFT);
|
||||||
|
}
|
||||||
|
if (2 * Esp >= dy) {
|
||||||
|
if (Xpoint == Xend)
|
||||||
|
break;
|
||||||
|
Esp += dy;
|
||||||
|
Xpoint += XAddway;
|
||||||
|
}
|
||||||
|
if (2 * Esp <= dx) {
|
||||||
|
if (Ypoint == Yend)
|
||||||
|
break;
|
||||||
|
Esp += dx;
|
||||||
|
Ypoint += YAddway;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function: Draw a rectangle
|
||||||
|
parameter:
|
||||||
|
Xstart :Rectangular Starting Xpoint point coordinates
|
||||||
|
Ystart :Rectangular Starting Xpoint point coordinates
|
||||||
|
Xend :Rectangular End point Xpoint coordinate
|
||||||
|
Yend :Rectangular End point Ypoint coordinate
|
||||||
|
Color :The color of the Rectangular segment
|
||||||
|
Line_width: Line width
|
||||||
|
Draw_Fill : Whether to fill the inside of the rectangle
|
||||||
|
******************************************************************************/
|
||||||
|
void Paint_DrawRectangle(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend,
|
||||||
|
UWORD Color, DOT_PIXEL Line_width, DRAW_FILL Draw_Fill)
|
||||||
|
{
|
||||||
|
if (Xstart > Paint.Width || Ystart > Paint.Height ||
|
||||||
|
Xend > Paint.Width || Yend > Paint.Height) {
|
||||||
|
Debug("Input exceeds the normal display range\r\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Draw_Fill) {
|
||||||
|
UWORD Ypoint;
|
||||||
|
for(Ypoint = Ystart; Ypoint < Yend; Ypoint++) {
|
||||||
|
Paint_DrawLine(Xstart, Ypoint, Xend, Ypoint, Color , Line_width, LINE_STYLE_SOLID);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Paint_DrawLine(Xstart, Ystart, Xend, Ystart, Color, Line_width, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(Xstart, Ystart, Xstart, Yend, Color, Line_width, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(Xend, Yend, Xend, Ystart, Color, Line_width, LINE_STYLE_SOLID);
|
||||||
|
Paint_DrawLine(Xend, Yend, Xstart, Yend, Color, Line_width, LINE_STYLE_SOLID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function: Use the 8-point method to draw a circle of the
|
||||||
|
specified size at the specified position->
|
||||||
|
parameter:
|
||||||
|
X_Center :Center X coordinate
|
||||||
|
Y_Center :Center Y coordinate
|
||||||
|
Radius :circle Radius
|
||||||
|
Color :The color of the :circle segment
|
||||||
|
Line_width: Line width
|
||||||
|
Draw_Fill : Whether to fill the inside of the Circle
|
||||||
|
******************************************************************************/
|
||||||
|
void Paint_DrawCircle(UWORD X_Center, UWORD Y_Center, UWORD Radius,
|
||||||
|
UWORD Color, DOT_PIXEL Line_width, DRAW_FILL Draw_Fill)
|
||||||
|
{
|
||||||
|
if (X_Center > Paint.Width || Y_Center >= Paint.Height) {
|
||||||
|
Debug("Paint_DrawCircle Input exceeds the normal display range\r\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Draw a circle from(0, R) as a starting point
|
||||||
|
int16_t XCurrent, YCurrent;
|
||||||
|
XCurrent = 0;
|
||||||
|
YCurrent = Radius;
|
||||||
|
|
||||||
|
//Cumulative error,judge the next point of the logo
|
||||||
|
int16_t Esp = 3 - (Radius << 1 );
|
||||||
|
|
||||||
|
int16_t sCountY;
|
||||||
|
if (Draw_Fill == DRAW_FILL_FULL) {
|
||||||
|
while (XCurrent <= YCurrent ) { //Realistic circles
|
||||||
|
for (sCountY = XCurrent; sCountY <= YCurrent; sCountY ++ ) {
|
||||||
|
Paint_DrawPoint(X_Center + XCurrent, Y_Center + sCountY, Color, DOT_PIXEL_DFT, DOT_STYLE_DFT);//1
|
||||||
|
Paint_DrawPoint(X_Center - XCurrent, Y_Center + sCountY, Color, DOT_PIXEL_DFT, DOT_STYLE_DFT);//2
|
||||||
|
Paint_DrawPoint(X_Center - sCountY, Y_Center + XCurrent, Color, DOT_PIXEL_DFT, DOT_STYLE_DFT);//3
|
||||||
|
Paint_DrawPoint(X_Center - sCountY, Y_Center - XCurrent, Color, DOT_PIXEL_DFT, DOT_STYLE_DFT);//4
|
||||||
|
Paint_DrawPoint(X_Center - XCurrent, Y_Center - sCountY, Color, DOT_PIXEL_DFT, DOT_STYLE_DFT);//5
|
||||||
|
Paint_DrawPoint(X_Center + XCurrent, Y_Center - sCountY, Color, DOT_PIXEL_DFT, DOT_STYLE_DFT);//6
|
||||||
|
Paint_DrawPoint(X_Center + sCountY, Y_Center - XCurrent, Color, DOT_PIXEL_DFT, DOT_STYLE_DFT);//7
|
||||||
|
Paint_DrawPoint(X_Center + sCountY, Y_Center + XCurrent, Color, DOT_PIXEL_DFT, DOT_STYLE_DFT);
|
||||||
|
}
|
||||||
|
if (Esp < 0 )
|
||||||
|
Esp += 4 * XCurrent + 6;
|
||||||
|
else {
|
||||||
|
Esp += 10 + 4 * (XCurrent - YCurrent );
|
||||||
|
YCurrent --;
|
||||||
|
}
|
||||||
|
XCurrent ++;
|
||||||
|
}
|
||||||
|
} else { //Draw a hollow circle
|
||||||
|
while (XCurrent <= YCurrent ) {
|
||||||
|
Paint_DrawPoint(X_Center + XCurrent, Y_Center + YCurrent, Color, Line_width, DOT_STYLE_DFT);//1
|
||||||
|
Paint_DrawPoint(X_Center - XCurrent, Y_Center + YCurrent, Color, Line_width, DOT_STYLE_DFT);//2
|
||||||
|
Paint_DrawPoint(X_Center - YCurrent, Y_Center + XCurrent, Color, Line_width, DOT_STYLE_DFT);//3
|
||||||
|
Paint_DrawPoint(X_Center - YCurrent, Y_Center - XCurrent, Color, Line_width, DOT_STYLE_DFT);//4
|
||||||
|
Paint_DrawPoint(X_Center - XCurrent, Y_Center - YCurrent, Color, Line_width, DOT_STYLE_DFT);//5
|
||||||
|
Paint_DrawPoint(X_Center + XCurrent, Y_Center - YCurrent, Color, Line_width, DOT_STYLE_DFT);//6
|
||||||
|
Paint_DrawPoint(X_Center + YCurrent, Y_Center - XCurrent, Color, Line_width, DOT_STYLE_DFT);//7
|
||||||
|
Paint_DrawPoint(X_Center + YCurrent, Y_Center + XCurrent, Color, Line_width, DOT_STYLE_DFT);//0
|
||||||
|
|
||||||
|
if (Esp < 0 )
|
||||||
|
Esp += 4 * XCurrent + 6;
|
||||||
|
else {
|
||||||
|
Esp += 10 + 4 * (XCurrent - YCurrent );
|
||||||
|
YCurrent --;
|
||||||
|
}
|
||||||
|
XCurrent ++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function: Show English characters
|
||||||
|
parameter:
|
||||||
|
Xpoint :X coordinate
|
||||||
|
Ypoint :Y coordinate
|
||||||
|
Acsii_Char :To display the English characters
|
||||||
|
Font :A structure pointer that displays a character size
|
||||||
|
Color_Foreground : Select the foreground color
|
||||||
|
Color_Background : Select the background color
|
||||||
|
******************************************************************************/
|
||||||
|
void Paint_DrawChar(UWORD Xpoint, UWORD Ypoint, const char Acsii_Char,
|
||||||
|
sFONT* Font, UWORD Color_Foreground, UWORD Color_Background)
|
||||||
|
{
|
||||||
|
UWORD Page, Column;
|
||||||
|
|
||||||
|
if (Xpoint > Paint.Width || Ypoint > Paint.Height) {
|
||||||
|
Debug("Paint_DrawChar Input exceeds the normal display range\r\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t Char_Offset = (Acsii_Char - ' ') * Font->Height * (Font->Width / 8 + (Font->Width % 8 ? 1 : 0));
|
||||||
|
const unsigned char *ptr = &Font->table[Char_Offset];
|
||||||
|
|
||||||
|
for (Page = 0; Page < Font->Height; Page ++ ) {
|
||||||
|
for (Column = 0; Column < Font->Width; Column ++ ) {
|
||||||
|
|
||||||
|
//To determine whether the font background color and screen background color is consistent
|
||||||
|
if (FONT_BACKGROUND == Color_Background) { //this process is to speed up the scan
|
||||||
|
if (*ptr & (0x80 >> (Column % 8)))
|
||||||
|
Paint_SetPixel(Xpoint + Column, Ypoint + Page, Color_Foreground);
|
||||||
|
// Paint_DrawPoint(Xpoint + Column, Ypoint + Page, Color_Foreground, DOT_PIXEL_DFT, DOT_STYLE_DFT);
|
||||||
|
} else {
|
||||||
|
if (*ptr & (0x80 >> (Column % 8))) {
|
||||||
|
Paint_SetPixel(Xpoint + Column, Ypoint + Page, Color_Foreground);
|
||||||
|
// Paint_DrawPoint(Xpoint + Column, Ypoint + Page, Color_Foreground, DOT_PIXEL_DFT, DOT_STYLE_DFT);
|
||||||
|
} else {
|
||||||
|
Paint_SetPixel(Xpoint + Column, Ypoint + Page, Color_Background);
|
||||||
|
// Paint_DrawPoint(Xpoint + Column, Ypoint + Page, Color_Background, DOT_PIXEL_DFT, DOT_STYLE_DFT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//One pixel is 8 bits
|
||||||
|
if (Column % 8 == 7)
|
||||||
|
ptr++;
|
||||||
|
}// Write a line
|
||||||
|
if (Font->Width % 8 != 0)
|
||||||
|
ptr++;
|
||||||
|
}// Write all
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function: Display the string
|
||||||
|
parameter:
|
||||||
|
Xstart :X coordinate
|
||||||
|
Ystart :Y coordinate
|
||||||
|
pString :The first address of the English string to be displayed
|
||||||
|
Font :A structure pointer that displays a character size
|
||||||
|
Color_Foreground : Select the foreground color
|
||||||
|
Color_Background : Select the background color
|
||||||
|
******************************************************************************/
|
||||||
|
void Paint_DrawString_EN(UWORD Xstart, UWORD Ystart, const char * pString,
|
||||||
|
sFONT* Font, UWORD Color_Foreground, UWORD Color_Background)
|
||||||
|
{
|
||||||
|
UWORD Xpoint = Xstart;
|
||||||
|
UWORD Ypoint = Ystart;
|
||||||
|
|
||||||
|
if (Xstart > Paint.Width || Ystart > Paint.Height) {
|
||||||
|
Debug("Paint_DrawString_EN Input exceeds the normal display range\r\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (* pString != '\0') {
|
||||||
|
//if X direction filled , reposition to(Xstart,Ypoint),Ypoint is Y direction plus the Height of the character
|
||||||
|
if ((Xpoint + Font->Width ) > Paint.Width ) {
|
||||||
|
Xpoint = Xstart;
|
||||||
|
Ypoint += Font->Height;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the Y direction is full, reposition to(Xstart, Ystart)
|
||||||
|
if ((Ypoint + Font->Height ) > Paint.Height ) {
|
||||||
|
Xpoint = Xstart;
|
||||||
|
Ypoint = Ystart;
|
||||||
|
}
|
||||||
|
Paint_DrawChar(Xpoint, Ypoint, * pString, Font, Color_Background, Color_Foreground);
|
||||||
|
|
||||||
|
//The next character of the address
|
||||||
|
pString ++;
|
||||||
|
|
||||||
|
//The next word of the abscissa increases the font of the broadband
|
||||||
|
Xpoint += Font->Width;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function: Display the string
|
||||||
|
parameter:
|
||||||
|
Xstart :X coordinate
|
||||||
|
Ystart :Y coordinate
|
||||||
|
pString :The first address of the Chinese string and English
|
||||||
|
string to be displayed
|
||||||
|
Font :A structure pointer that displays a character size
|
||||||
|
Color_Foreground : Select the foreground color
|
||||||
|
Color_Background : Select the background color
|
||||||
|
******************************************************************************/
|
||||||
|
void Paint_DrawString_CN(UWORD Xstart, UWORD Ystart, const char * pString, cFONT* font,
|
||||||
|
UWORD Color_Foreground, UWORD Color_Background)
|
||||||
|
{
|
||||||
|
const char* p_text = pString;
|
||||||
|
int x = Xstart, y = Ystart;
|
||||||
|
int i, j,Num;
|
||||||
|
|
||||||
|
/* Send the string character by character on EPD */
|
||||||
|
while (*p_text != 0) {
|
||||||
|
if(*p_text <= 0x7F) { //ASCII < 126
|
||||||
|
for(Num = 0; Num < font->size; Num++) {
|
||||||
|
if(*p_text== font->table[Num].index[0]) {
|
||||||
|
const char* ptr = &font->table[Num].matrix[0];
|
||||||
|
|
||||||
|
for (j = 0; j < font->Height; j++) {
|
||||||
|
for (i = 0; i < font->Width; i++) {
|
||||||
|
if (FONT_BACKGROUND == Color_Background) { //this process is to speed up the scan
|
||||||
|
if (*ptr & (0x80 >> (i % 8))) {
|
||||||
|
Paint_SetPixel(x + i, y + j, Color_Foreground);
|
||||||
|
// Paint_DrawPoint(x + i, y + j, Color_Foreground, DOT_PIXEL_DFT, DOT_STYLE_DFT);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (*ptr & (0x80 >> (i % 8))) {
|
||||||
|
Paint_SetPixel(x + i, y + j, Color_Foreground);
|
||||||
|
// Paint_DrawPoint(x + i, y + j, Color_Foreground, DOT_PIXEL_DFT, DOT_STYLE_DFT);
|
||||||
|
} else {
|
||||||
|
Paint_SetPixel(x + i, y + j, Color_Background);
|
||||||
|
// Paint_DrawPoint(x + i, y + j, Color_Background, DOT_PIXEL_DFT, DOT_STYLE_DFT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (i % 8 == 7) {
|
||||||
|
ptr++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (font->Width % 8 != 0) {
|
||||||
|
ptr++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* Point on the next character */
|
||||||
|
p_text += 1;
|
||||||
|
/* Decrement the column position by 16 */
|
||||||
|
x += font->ASCII_Width;
|
||||||
|
} else { //Chinese
|
||||||
|
for(Num = 0; Num < font->size; Num++) {
|
||||||
|
if((*p_text== font->table[Num].index[0]) && (*(p_text+1) == font->table[Num].index[1])) {
|
||||||
|
const char* ptr = &font->table[Num].matrix[0];
|
||||||
|
|
||||||
|
for (j = 0; j < font->Height; j++) {
|
||||||
|
for (i = 0; i < font->Width; i++) {
|
||||||
|
if (FONT_BACKGROUND == Color_Background) { //this process is to speed up the scan
|
||||||
|
if (*ptr & (0x80 >> (i % 8))) {
|
||||||
|
Paint_SetPixel(x + i, y + j, Color_Foreground);
|
||||||
|
// Paint_DrawPoint(x + i, y + j, Color_Foreground, DOT_PIXEL_DFT, DOT_STYLE_DFT);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (*ptr & (0x80 >> (i % 8))) {
|
||||||
|
Paint_SetPixel(x + i, y + j, Color_Foreground);
|
||||||
|
// Paint_DrawPoint(x + i, y + j, Color_Foreground, DOT_PIXEL_DFT, DOT_STYLE_DFT);
|
||||||
|
} else {
|
||||||
|
Paint_SetPixel(x + i, y + j, Color_Background);
|
||||||
|
// Paint_DrawPoint(x + i, y + j, Color_Background, DOT_PIXEL_DFT, DOT_STYLE_DFT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (i % 8 == 7) {
|
||||||
|
ptr++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (font->Width % 8 != 0) {
|
||||||
|
ptr++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* Point on the next character */
|
||||||
|
p_text += 2;
|
||||||
|
/* Decrement the column position by 16 */
|
||||||
|
x += font->Width;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function: Display nummber
|
||||||
|
parameter:
|
||||||
|
Xstart :X coordinate
|
||||||
|
Ystart : Y coordinate
|
||||||
|
Nummber : The number displayed
|
||||||
|
Font :A structure pointer that displays a character size
|
||||||
|
Color_Foreground : Select the foreground color
|
||||||
|
Color_Background : Select the background color
|
||||||
|
******************************************************************************/
|
||||||
|
#define ARRAY_LEN 255
|
||||||
|
void Paint_DrawNum(UWORD Xpoint, UWORD Ypoint, int32_t Nummber,
|
||||||
|
sFONT* Font, UWORD Color_Foreground, UWORD Color_Background)
|
||||||
|
{
|
||||||
|
|
||||||
|
int16_t Num_Bit = 0, Str_Bit = 0;
|
||||||
|
uint8_t Str_Array[ARRAY_LEN] = {0}, Num_Array[ARRAY_LEN] = {0};
|
||||||
|
uint8_t *pStr = Str_Array;
|
||||||
|
|
||||||
|
if (Xpoint > Paint.Width || Ypoint > Paint.Height) {
|
||||||
|
Debug("Paint_DisNum Input exceeds the normal display range\r\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Converts a number to a string
|
||||||
|
while (Nummber) {
|
||||||
|
Num_Array[Num_Bit] = Nummber % 10 + '0';
|
||||||
|
Num_Bit++;
|
||||||
|
Nummber /= 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
//The string is inverted
|
||||||
|
while (Num_Bit > 0) {
|
||||||
|
Str_Array[Str_Bit] = Num_Array[Num_Bit - 1];
|
||||||
|
Str_Bit ++;
|
||||||
|
Num_Bit --;
|
||||||
|
}
|
||||||
|
|
||||||
|
//show
|
||||||
|
Paint_DrawString_EN(Xpoint, Ypoint, (const char*)pStr, Font, Color_Background, Color_Foreground);
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function: Display time
|
||||||
|
parameter:
|
||||||
|
Xstart :X coordinate
|
||||||
|
Ystart : Y coordinate
|
||||||
|
pTime : Time-related structures
|
||||||
|
Font :A structure pointer that displays a character size
|
||||||
|
Color_Foreground : Select the foreground color
|
||||||
|
Color_Background : Select the background color
|
||||||
|
******************************************************************************/
|
||||||
|
void Paint_DrawTime(UWORD Xstart, UWORD Ystart, PAINT_TIME *pTime, sFONT* Font,
|
||||||
|
UWORD Color_Foreground, UWORD Color_Background)
|
||||||
|
{
|
||||||
|
uint8_t value[10] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
|
||||||
|
|
||||||
|
UWORD Dx = Font->Width;
|
||||||
|
|
||||||
|
//Write data into the cache
|
||||||
|
Paint_DrawChar(Xstart , Ystart, value[pTime->Hour / 10], Font, Color_Background, Color_Foreground);
|
||||||
|
Paint_DrawChar(Xstart + Dx , Ystart, value[pTime->Hour % 10], Font, Color_Background, Color_Foreground);
|
||||||
|
Paint_DrawChar(Xstart + Dx + Dx / 4 + Dx / 2 , Ystart, ':' , Font, Color_Background, Color_Foreground);
|
||||||
|
Paint_DrawChar(Xstart + Dx * 2 + Dx / 2 , Ystart, value[pTime->Min / 10] , Font, Color_Background, Color_Foreground);
|
||||||
|
Paint_DrawChar(Xstart + Dx * 3 + Dx / 2 , Ystart, value[pTime->Min % 10] , Font, Color_Background, Color_Foreground);
|
||||||
|
// Paint_DrawChar(Xstart + Dx * 4 + Dx / 2 - Dx / 4, Ystart, ':' , Font, Color_Background, Color_Foreground);
|
||||||
|
// Paint_DrawChar(Xstart + Dx * 5 , Ystart, value[pTime->Sec / 10] , Font, Color_Background, Color_Foreground);
|
||||||
|
// Paint_DrawChar(Xstart + Dx * 6 , Ystart, value[pTime->Sec % 10] , Font, Color_Background, Color_Foreground);
|
||||||
|
}
|
||||||
|
void Paint_DrawDate(UWORD Xstart, UWORD Ystart, PAINT_TIME *pTime, sFONT* Font,
|
||||||
|
UWORD Color_Foreground, UWORD Color_Background)
|
||||||
|
{
|
||||||
|
uint8_t value[10] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
|
||||||
|
|
||||||
|
UWORD Dx = Font->Width;
|
||||||
|
|
||||||
|
//Write data into the cache
|
||||||
|
Paint_DrawChar(Xstart , Ystart, value[pTime->Year / 1000] , Font, Color_Background, Color_Foreground);
|
||||||
|
Paint_DrawChar(Xstart + Dx , Ystart, value[pTime->Year / 100 % 10] , Font, Color_Background, Color_Foreground);
|
||||||
|
Paint_DrawChar(Xstart + Dx * 2 , Ystart, value[pTime->Year / 10 %100] , Font, Color_Background, Color_Foreground);
|
||||||
|
Paint_DrawChar(Xstart + Dx * 3 , Ystart, value[pTime->Year % 1000 % 100 % 10] , Font, Color_Background, Color_Foreground);
|
||||||
|
Paint_DrawChar(Xstart + Dx * 4 , Ystart, '-' , Font, Color_Background, Color_Foreground);
|
||||||
|
Paint_DrawChar(Xstart + Dx * 5 , Ystart, value[pTime->Month / 10] , Font, Color_Background, Color_Foreground);
|
||||||
|
Paint_DrawChar(Xstart + Dx * 6 , Ystart, value[pTime->Month % 10] , Font, Color_Background, Color_Foreground);
|
||||||
|
Paint_DrawChar(Xstart + Dx * 7 , Ystart, '-' , Font, Color_Background, Color_Foreground);
|
||||||
|
Paint_DrawChar(Xstart + Dx * 8 , Ystart, value[pTime->Day / 10] , Font, Color_Background, Color_Foreground);
|
||||||
|
Paint_DrawChar(Xstart + Dx * 9 , Ystart, value[pTime->Day % 10] , Font, Color_Background, Color_Foreground);
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
function: Display monochrome bitmap
|
||||||
|
parameter:
|
||||||
|
image_buffer :A picture data converted to a bitmap
|
||||||
|
info:
|
||||||
|
Use a computer to convert the image into a corresponding array,
|
||||||
|
and then embed the array directly into Imagedata.cpp as a .c file.
|
||||||
|
******************************************************************************/
|
||||||
|
void Paint_DrawBitMap(const unsigned char* image_buffer)
|
||||||
|
{
|
||||||
|
UWORD x, y;
|
||||||
|
UDOUBLE Addr = 0;
|
||||||
|
|
||||||
|
for (y = 0; y < Paint.HeightByte; y++) {
|
||||||
|
for (x = 0; x < Paint.WidthByte; x++) {//8 pixel = 1 byte
|
||||||
|
Addr = x + y * Paint.WidthByte;
|
||||||
|
Paint.Image[Addr] = (unsigned char)image_buffer[Addr];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,215 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* | File : GUI_Paint.h
|
||||||
|
* | Author : Waveshare electronics
|
||||||
|
* | Function : Achieve drawing: draw points, lines, boxes, circles and
|
||||||
|
* their size, solid dotted line, solid rectangle hollow
|
||||||
|
* rectangle, solid circle hollow circle.
|
||||||
|
* | Info :
|
||||||
|
* Achieve display characters: Display a single character, string, number
|
||||||
|
* Achieve time display: adaptive size display time minutes and seconds
|
||||||
|
*----------------
|
||||||
|
* | This version: V3.1
|
||||||
|
* | Date : 2019-10-10
|
||||||
|
* | Info :
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
* V3.1(2019-10-10):
|
||||||
|
* 1. Add gray level
|
||||||
|
* PAINT Add Scale
|
||||||
|
* 2. Add void Paint_SetScale(UBYTE scale);
|
||||||
|
*
|
||||||
|
* V3.0(2019-04-18):
|
||||||
|
* 1.Change:
|
||||||
|
* Paint_DrawPoint(..., DOT_STYLE DOT_STYLE)
|
||||||
|
* => Paint_DrawPoint(..., DOT_STYLE Dot_Style)
|
||||||
|
* Paint_DrawLine(..., LINE_STYLE Line_Style, DOT_PIXEL Dot_Pixel)
|
||||||
|
* => Paint_DrawLine(..., DOT_PIXEL Line_width, LINE_STYLE Line_Style)
|
||||||
|
* Paint_DrawRectangle(..., DRAW_FILL Filled, DOT_PIXEL Dot_Pixel)
|
||||||
|
* => Paint_DrawRectangle(..., DOT_PIXEL Line_width, DRAW_FILL Draw_Fill)
|
||||||
|
* Paint_DrawCircle(..., DRAW_FILL Draw_Fill, DOT_PIXEL Dot_Pixel)
|
||||||
|
* => Paint_DrawCircle(..., DOT_PIXEL Line_width, DRAW_FILL Draw_Filll)
|
||||||
|
*
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
* V2.0(2018-11-15):
|
||||||
|
* 1.add: Paint_NewImage()
|
||||||
|
* Create an image's properties
|
||||||
|
* 2.add: Paint_SelectImage()
|
||||||
|
* Select the picture to be drawn
|
||||||
|
* 3.add: Paint_SetRotate()
|
||||||
|
* Set the direction of the cache
|
||||||
|
* 4.add: Paint_RotateImage()
|
||||||
|
* Can flip the picture, Support 0-360 degrees,
|
||||||
|
* but only 90.180.270 rotation is better
|
||||||
|
* 4.add: Paint_SetMirroring()
|
||||||
|
* Can Mirroring the picture, horizontal, vertical, origin
|
||||||
|
* 5.add: Paint_DrawString_CN()
|
||||||
|
* Can display Chinese(GB1312)
|
||||||
|
*
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
* V1.0(2018-07-17):
|
||||||
|
* Create library
|
||||||
|
*
|
||||||
|
* 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 __GUI_PAINT_H
|
||||||
|
#define __GUI_PAINT_H
|
||||||
|
|
||||||
|
#include "DEV_Config.h"
|
||||||
|
#include "../Fonts/fonts.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Image attributes
|
||||||
|
**/
|
||||||
|
typedef struct {
|
||||||
|
UBYTE *Image;
|
||||||
|
UWORD Width;
|
||||||
|
UWORD Height;
|
||||||
|
UWORD WidthMemory;
|
||||||
|
UWORD HeightMemory;
|
||||||
|
UWORD Color;
|
||||||
|
UWORD Rotate;
|
||||||
|
UWORD Mirror;
|
||||||
|
UWORD WidthByte;
|
||||||
|
UWORD HeightByte;
|
||||||
|
UWORD Scale;
|
||||||
|
} PAINT;
|
||||||
|
extern PAINT Paint;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display rotate
|
||||||
|
**/
|
||||||
|
#define ROTATE_0 0
|
||||||
|
#define ROTATE_90 90
|
||||||
|
#define ROTATE_180 180
|
||||||
|
#define ROTATE_270 270
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display Flip
|
||||||
|
**/
|
||||||
|
typedef enum {
|
||||||
|
MIRROR_NONE = 0x00,
|
||||||
|
MIRROR_HORIZONTAL = 0x01,
|
||||||
|
MIRROR_VERTICAL = 0x02,
|
||||||
|
MIRROR_ORIGIN = 0x03,
|
||||||
|
} MIRROR_IMAGE;
|
||||||
|
#define MIRROR_IMAGE_DFT MIRROR_NONE
|
||||||
|
|
||||||
|
/**
|
||||||
|
* image color
|
||||||
|
**/
|
||||||
|
#define WHITE 0xFF
|
||||||
|
#define BLACK 0x00
|
||||||
|
#define RED BLACK
|
||||||
|
|
||||||
|
#define IMAGE_BACKGROUND WHITE
|
||||||
|
#define FONT_FOREGROUND BLACK
|
||||||
|
#define FONT_BACKGROUND WHITE
|
||||||
|
|
||||||
|
//4 Gray level
|
||||||
|
#define GRAY1 0x03 //Blackest
|
||||||
|
#define GRAY2 0x02
|
||||||
|
#define GRAY3 0x01 //gray
|
||||||
|
#define GRAY4 0x00 //white
|
||||||
|
/**
|
||||||
|
* The size of the point
|
||||||
|
**/
|
||||||
|
typedef enum {
|
||||||
|
DOT_PIXEL_1X1 = 1, // 1 x 1
|
||||||
|
DOT_PIXEL_2X2 , // 2 X 2
|
||||||
|
DOT_PIXEL_3X3 , // 3 X 3
|
||||||
|
DOT_PIXEL_4X4 , // 4 X 4
|
||||||
|
DOT_PIXEL_5X5 , // 5 X 5
|
||||||
|
DOT_PIXEL_6X6 , // 6 X 6
|
||||||
|
DOT_PIXEL_7X7 , // 7 X 7
|
||||||
|
DOT_PIXEL_8X8 , // 8 X 8
|
||||||
|
} DOT_PIXEL;
|
||||||
|
#define DOT_PIXEL_DFT DOT_PIXEL_1X1 //Default dot pilex
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Point size fill style
|
||||||
|
**/
|
||||||
|
typedef enum {
|
||||||
|
DOT_FILL_AROUND = 1, // dot pixel 1 x 1
|
||||||
|
DOT_FILL_RIGHTUP , // dot pixel 2 X 2
|
||||||
|
} DOT_STYLE;
|
||||||
|
#define DOT_STYLE_DFT DOT_FILL_AROUND //Default dot pilex
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Line style, solid or dashed
|
||||||
|
**/
|
||||||
|
typedef enum {
|
||||||
|
LINE_STYLE_SOLID = 0,
|
||||||
|
LINE_STYLE_DOTTED,
|
||||||
|
} LINE_STYLE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the graphic is filled
|
||||||
|
**/
|
||||||
|
typedef enum {
|
||||||
|
DRAW_FILL_EMPTY = 0,
|
||||||
|
DRAW_FILL_FULL,
|
||||||
|
} DRAW_FILL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom structure of a time attribute
|
||||||
|
**/
|
||||||
|
typedef struct {
|
||||||
|
UWORD Year; //0000
|
||||||
|
UBYTE Month; //1 - 12
|
||||||
|
UBYTE Day; //1 - 30
|
||||||
|
UBYTE Hour; //0 - 23
|
||||||
|
UBYTE Min; //0 - 59
|
||||||
|
UBYTE Sec; //0 - 59
|
||||||
|
} PAINT_TIME;
|
||||||
|
extern PAINT_TIME sPaint_time;
|
||||||
|
|
||||||
|
//init and Clear
|
||||||
|
void Paint_NewImage(UBYTE *image, UWORD Width, UWORD Height, UWORD Rotate, UWORD Color);
|
||||||
|
void Paint_SelectImage(UBYTE *image);
|
||||||
|
void Paint_SetRotate(UWORD Rotate);
|
||||||
|
void Paint_SetMirroring(UBYTE mirror);
|
||||||
|
void Paint_SetPixel(UWORD Xpoint, UWORD Ypoint, UWORD Color);
|
||||||
|
void Paint_SetScale(UBYTE scale);
|
||||||
|
|
||||||
|
void Paint_Clear(UWORD Color);
|
||||||
|
void Paint_ClearWindows(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, UWORD Color);
|
||||||
|
|
||||||
|
//Drawing
|
||||||
|
void Paint_DrawPoint(UWORD Xpoint, UWORD Ypoint, UWORD Color, DOT_PIXEL Dot_Pixel, DOT_STYLE Dot_FillWay);
|
||||||
|
void Paint_DrawLine(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, UWORD Color, DOT_PIXEL Line_width, LINE_STYLE Line_Style);
|
||||||
|
void Paint_DrawRectangle(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, UWORD Color, DOT_PIXEL Line_width, DRAW_FILL Draw_Fill);
|
||||||
|
void Paint_DrawCircle(UWORD X_Center, UWORD Y_Center, UWORD Radius, UWORD Color, DOT_PIXEL Line_width, DRAW_FILL Draw_Fill);
|
||||||
|
|
||||||
|
//Display string
|
||||||
|
void Paint_DrawChar(UWORD Xstart, UWORD Ystart, const char Acsii_Char, sFONT* Font, UWORD Color_Foreground, UWORD Color_Background);
|
||||||
|
void Paint_DrawString_EN(UWORD Xstart, UWORD Ystart, const char * pString, sFONT* Font, UWORD Color_Foreground, UWORD Color_Background);
|
||||||
|
void Paint_DrawString_CN(UWORD Xstart, UWORD Ystart, const char * pString, cFONT* font, UWORD Color_Foreground, UWORD Color_Background);
|
||||||
|
void Paint_DrawNum(UWORD Xpoint, UWORD Ypoint, int32_t Nummber, sFONT* Font, UWORD Color_Foreground, UWORD Color_Background);
|
||||||
|
void Paint_DrawTime(UWORD Xstart, UWORD Ystart, PAINT_TIME *pTime, sFONT* Font, UWORD Color_Foreground, UWORD Color_Background);
|
||||||
|
void Paint_DrawDate(UWORD Xstart, UWORD Ystart, PAINT_TIME *pTime, sFONT* Font, UWORD Color_Foreground, UWORD Color_Background);
|
||||||
|
//pic
|
||||||
|
void Paint_DrawBitMap(const unsigned char* image_buffer);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
After Width: | Height: | Size: 4.0 KiB |
|
After Width: | Height: | Size: 4.0 KiB |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 4.0 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 4.0 KiB |
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 614 B |
|
After Width: | Height: | Size: 614 B |
|
After Width: | Height: | Size: 614 B |
|
After Width: | Height: | Size: 614 B |
|
After Width: | Height: | Size: 614 B |
|
After Width: | Height: | Size: 614 B |
|
After Width: | Height: | Size: 614 B |
|
After Width: | Height: | Size: 614 B |
|
After Width: | Height: | Size: 614 B |
|
After Width: | Height: | Size: 614 B |