mirror of
https://github.com/jam422470459/EPD-nRF52-hema213.git
synced 2025-12-06 16:42:49 +08:00
remove UBYTE/UWORD/UDOUBLE
This commit is contained in:
@@ -15,6 +15,8 @@
|
||||
#include "nrf_drv_spi.h"
|
||||
#include "EPD_driver.h"
|
||||
|
||||
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
|
||||
|
||||
uint32_t EPD_MOSI_PIN = 5;
|
||||
uint32_t EPD_SCLK_PIN = 8;
|
||||
uint32_t EPD_CS_PIN = 9;
|
||||
@@ -72,7 +74,7 @@ function: Initialize Arduino, Initialize Pins, and SPI
|
||||
parameter:
|
||||
Info:
|
||||
******************************************************************************/
|
||||
UBYTE DEV_Module_Init(void)
|
||||
uint8_t DEV_Module_Init(void)
|
||||
{
|
||||
nrf_gpio_cfg_output(EPD_CS_PIN);
|
||||
nrf_gpio_cfg_output(EPD_DC_PIN);
|
||||
@@ -117,24 +119,17 @@ note:
|
||||
SPI4W_Write_Byte(value) :
|
||||
Register hardware SPI
|
||||
*********************************************/
|
||||
void DEV_SPI_WriteByte(UBYTE value)
|
||||
void DEV_SPI_WriteByte(uint8_t value)
|
||||
{
|
||||
nrf_drv_spi_transfer(&spi, &value, 1, NULL, 0);
|
||||
}
|
||||
|
||||
void DEV_SPI_WriteBytes(UBYTE *value, UBYTE len)
|
||||
void DEV_SPI_WriteBytes(uint8_t *value, uint8_t len)
|
||||
{
|
||||
nrf_drv_spi_transfer(&spi, value, len, NULL, 0);
|
||||
}
|
||||
|
||||
UBYTE DEV_SPI_ReadByte(void)
|
||||
{
|
||||
UBYTE value;
|
||||
nrf_drv_spi_transfer(&spi, NULL, 0, &value, 1);
|
||||
return value;
|
||||
}
|
||||
|
||||
void EPD_WriteCommand(UBYTE Reg)
|
||||
void EPD_WriteCommand(uint8_t Reg)
|
||||
{
|
||||
DEV_Digital_Write(EPD_DC_PIN, 0);
|
||||
DEV_Digital_Write(EPD_CS_PIN, 0);
|
||||
@@ -142,7 +137,7 @@ void EPD_WriteCommand(UBYTE Reg)
|
||||
DEV_Digital_Write(EPD_CS_PIN, 1);
|
||||
}
|
||||
|
||||
void EPD_WriteByte(UBYTE Data)
|
||||
void EPD_WriteByte(uint8_t Data)
|
||||
{
|
||||
DEV_Digital_Write(EPD_DC_PIN, 1);
|
||||
DEV_Digital_Write(EPD_CS_PIN, 0);
|
||||
@@ -150,7 +145,7 @@ void EPD_WriteByte(UBYTE Data)
|
||||
DEV_Digital_Write(EPD_CS_PIN, 1);
|
||||
}
|
||||
|
||||
void EPD_WriteData(UBYTE *Data, UBYTE Len)
|
||||
void EPD_WriteData(uint8_t *Data, uint8_t Len)
|
||||
{
|
||||
DEV_Digital_Write(EPD_DC_PIN, 1);
|
||||
DEV_Digital_Write(EPD_CS_PIN, 0);
|
||||
|
||||
@@ -20,17 +20,6 @@
|
||||
#include "nrf_delay.h"
|
||||
#include "nrf_gpio.h"
|
||||
|
||||
#ifndef ARRAY_SIZE
|
||||
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
|
||||
#endif
|
||||
|
||||
/**
|
||||
* data
|
||||
**/
|
||||
#define UBYTE uint8_t
|
||||
#define UWORD uint16_t
|
||||
#define UDOUBLE uint32_t
|
||||
|
||||
/**< EPD driver IDs. */
|
||||
enum EPD_DRIVER_IDS
|
||||
{
|
||||
@@ -49,10 +38,10 @@ typedef struct
|
||||
uint16_t height;
|
||||
void (*init)(void); /**< Initialize the e-Paper register */
|
||||
void (*clear)(void); /**< Clear screen */
|
||||
void (*send_command)(UBYTE Reg); /**< send command */
|
||||
void (*send_byte)(UBYTE Reg); /**< send byte */
|
||||
void (*send_data)(UBYTE *Data, UBYTE Len); /**< send data */
|
||||
void (*write_image)(UBYTE *black, UBYTE *color, UWORD x, UWORD y, UWORD w, UWORD h); /**< write image */
|
||||
void (*send_command)(uint8_t Reg); /**< send command */
|
||||
void (*send_byte)(uint8_t Reg); /**< send byte */
|
||||
void (*send_data)(uint8_t *Data, uint8_t Len); /**< send data */
|
||||
void (*write_image)(uint8_t *black, uint8_t *color, uint16_t x, uint16_t y, uint16_t w, uint16_t h); /**< write image */
|
||||
void (*refresh)(void); /**< Sends the image buffer in RAM to e-Paper and displays */
|
||||
void (*sleep)(void); /**< Enter sleep mode */
|
||||
} epd_driver_t;
|
||||
@@ -77,15 +66,15 @@ extern uint32_t EPD_BS_PIN;
|
||||
#define DEV_Delay_ms(__xms) nrf_delay_ms(__xms);
|
||||
#define DEV_Delay_us(__xus) nrf_delay_us(__xus);
|
||||
|
||||
UBYTE DEV_Module_Init(void);
|
||||
uint8_t DEV_Module_Init(void);
|
||||
void DEV_Module_Exit(void);
|
||||
|
||||
void DEV_SPI_WriteByte(UBYTE value);
|
||||
void DEV_SPI_WriteBytes(UBYTE *value, UBYTE len);
|
||||
void DEV_SPI_WriteByte(uint8_t value);
|
||||
void DEV_SPI_WriteBytes(uint8_t *value, uint8_t len);
|
||||
|
||||
void EPD_WriteCommand(UBYTE Reg);
|
||||
void EPD_WriteByte(UBYTE Data);
|
||||
void EPD_WriteData(UBYTE *Data, UBYTE Len);
|
||||
void EPD_WriteCommand(uint8_t Reg);
|
||||
void EPD_WriteByte(uint8_t Data);
|
||||
void EPD_WriteData(uint8_t *Data, uint8_t Len);
|
||||
|
||||
epd_driver_t *epd_driver_get(void);
|
||||
epd_driver_t *epd_driver_by_id(uint8_t id);
|
||||
|
||||
62
EPD/UC8176.c
62
EPD/UC8176.c
@@ -41,7 +41,7 @@ static void EPD_4IN2_Reset(void)
|
||||
{
|
||||
DEV_Digital_Write(EPD_RST_PIN, 1);
|
||||
DEV_Delay_ms(10);
|
||||
for (UBYTE i = 0; i < 3; i++)
|
||||
for (uint8_t i = 0; i < 3; i++)
|
||||
{
|
||||
DEV_Digital_Write(EPD_RST_PIN, 0);
|
||||
DEV_Delay_ms(10);
|
||||
@@ -115,20 +115,20 @@ parameter:
|
||||
******************************************************************************/
|
||||
void EPD_4IN2_Clear(void)
|
||||
{
|
||||
UWORD Width, Height;
|
||||
uint16_t Width, Height;
|
||||
Width = (EPD_4IN2_WIDTH % 8 == 0)? (EPD_4IN2_WIDTH / 8 ): (EPD_4IN2_WIDTH / 8 + 1);
|
||||
Height = EPD_4IN2_HEIGHT;
|
||||
|
||||
EPD_WriteCommand(0x10);
|
||||
for (UWORD j = 0; j < Height; j++) {
|
||||
for (UWORD i = 0; i < Width; i++) {
|
||||
for (uint16_t j = 0; j < Height; j++) {
|
||||
for (uint16_t i = 0; i < Width; i++) {
|
||||
EPD_WriteByte(0xFF);
|
||||
}
|
||||
}
|
||||
|
||||
EPD_WriteCommand(0x13);
|
||||
for (UWORD j = 0; j < Height; j++) {
|
||||
for (UWORD i = 0; i < Width; i++) {
|
||||
for (uint16_t j = 0; j < Height; j++) {
|
||||
for (uint16_t i = 0; i < Width; i++) {
|
||||
EPD_WriteByte(0xFF);
|
||||
}
|
||||
}
|
||||
@@ -136,58 +136,58 @@ void EPD_4IN2_Clear(void)
|
||||
EPD_4IN2_Refresh();
|
||||
}
|
||||
|
||||
static void _setPartialRamArea(UWORD x, UWORD y, UWORD w, UWORD h)
|
||||
static void _setPartialRamArea(uint16_t x, uint16_t y, uint16_t w, uint16_t h)
|
||||
{
|
||||
uint16_t xe = (x + w - 1) | 0x0007; // byte boundary inclusive (last byte)
|
||||
uint16_t ye = y + h - 1;
|
||||
x &= 0xFFF8; // byte boundary
|
||||
xe |= 0x0007; // byte boundary
|
||||
EPD_WriteCommand(0x90); // partial window
|
||||
EPD_WriteByte(x / 256);
|
||||
EPD_WriteByte(x % 256);
|
||||
EPD_WriteByte(xe / 256);
|
||||
EPD_WriteByte(xe % 256);
|
||||
EPD_WriteByte(y / 256);
|
||||
EPD_WriteByte(y % 256);
|
||||
EPD_WriteByte(ye / 256);
|
||||
EPD_WriteByte(ye % 256);
|
||||
EPD_WriteByte(0x01);
|
||||
uint16_t xe = (x + w - 1) | 0x0007; // byte boundary inclusive (last byte)
|
||||
uint16_t ye = y + h - 1;
|
||||
x &= 0xFFF8; // byte boundary
|
||||
xe |= 0x0007; // byte boundary
|
||||
EPD_WriteCommand(0x90); // partial window
|
||||
EPD_WriteByte(x / 256);
|
||||
EPD_WriteByte(x % 256);
|
||||
EPD_WriteByte(xe / 256);
|
||||
EPD_WriteByte(xe % 256);
|
||||
EPD_WriteByte(y / 256);
|
||||
EPD_WriteByte(y % 256);
|
||||
EPD_WriteByte(ye / 256);
|
||||
EPD_WriteByte(ye % 256);
|
||||
EPD_WriteByte(0x01);
|
||||
}
|
||||
|
||||
void EPD_4IN2_Write_Image(UBYTE *black, UBYTE *color, UWORD x, UWORD y, UWORD w, UWORD h)
|
||||
void EPD_4IN2_Write_Image(uint8_t *black, uint8_t *color, uint16_t x, uint16_t y, uint16_t w, uint16_t h)
|
||||
{
|
||||
UWORD wb = (w + 7) / 8; // width bytes, bitmaps are padded
|
||||
uint16_t wb = (w + 7) / 8; // width bytes, bitmaps are padded
|
||||
x -= x % 8; // byte boundary
|
||||
w = wb * 8; // byte boundary
|
||||
if (x + w > EPD_4IN2_WIDTH || y + h > EPD_4IN2_HEIGHT) return;
|
||||
EPD_WriteCommand(0x91); // partial in
|
||||
_setPartialRamArea(x, y, w, h);
|
||||
EPD_WriteCommand(0x13);
|
||||
for (UWORD i = 0; i < h; i++) {
|
||||
for (UWORD j = 0; j < w / 8; j++) {
|
||||
for (uint16_t i = 0; i < h; i++) {
|
||||
for (uint16_t j = 0; j < w / 8; j++) {
|
||||
EPD_WriteByte(black[j + i * wb]);
|
||||
}
|
||||
}
|
||||
EPD_WriteCommand(0x92); // partial out
|
||||
}
|
||||
|
||||
void EPD_4IN2B_V2_Write_Image(UBYTE *black, UBYTE *color, UWORD x, UWORD y, UWORD w, UWORD h)
|
||||
void EPD_4IN2B_V2_Write_Image(uint8_t *black, uint8_t *color, uint16_t x, uint16_t y, uint16_t w, uint16_t h)
|
||||
{
|
||||
UWORD wb = (w + 7) / 8; // width bytes, bitmaps are padded
|
||||
uint16_t wb = (w + 7) / 8; // width bytes, bitmaps are padded
|
||||
x -= x % 8; // byte boundary
|
||||
w = wb * 8; // byte boundary
|
||||
if (x + w > EPD_4IN2_WIDTH || y + h > EPD_4IN2_HEIGHT) return;
|
||||
EPD_WriteCommand(0x91); // partial in
|
||||
_setPartialRamArea(x, y, w, h);
|
||||
EPD_WriteCommand(0x10);
|
||||
for (UWORD i = 0; i < h; i++) {
|
||||
for (UWORD j = 0; j < w / 8; j++) {
|
||||
for (uint16_t i = 0; i < h; i++) {
|
||||
for (uint16_t j = 0; j < w / 8; j++) {
|
||||
EPD_WriteByte(black ? black[j + i * wb] : 0xFF);
|
||||
}
|
||||
}
|
||||
EPD_WriteCommand(0x13);
|
||||
for (UWORD i = 0; i < h; i++) {
|
||||
for (UWORD j = 0; j < w / 8; j++) {
|
||||
for (uint16_t i = 0; i < h; i++) {
|
||||
for (uint16_t j = 0; j < w / 8; j++) {
|
||||
EPD_WriteByte(color ? color[j + i * wb] : 0xFF);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user