Compilation sans erreur, test réel à faire
This commit is contained in:
@@ -1,5 +1,23 @@
|
||||
#include "lib_epaper_2in9.h"
|
||||
|
||||
|
||||
// Constants
|
||||
const uint8_t lut_full_update[] = {
|
||||
0x50, 0xAA, 0x55, 0xAA, 0x11, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0xFF, 0xFF, 0x1F, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
const uint8_t lut_partial_update[] = {
|
||||
0x10, 0x18, 0x18, 0x08, 0x18, 0x18,
|
||||
0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x13, 0x14, 0x44, 0x12,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
// Basic functions
|
||||
void _epaper_spiinit()
|
||||
{
|
||||
@@ -48,7 +66,7 @@ uint8_t _epaper_digitalread(uint8_t pin)
|
||||
return LPC_GPIO_PORT->B0[pin];
|
||||
}
|
||||
|
||||
uint8_t _epaper_digitalwrite(uint8_t pin, uint8_t value)
|
||||
void _epaper_digitalwrite(uint8_t pin, uint8_t value)
|
||||
{
|
||||
LPC_GPIO_PORT->B0[pin] = value;
|
||||
}
|
||||
@@ -58,24 +76,24 @@ void _epaper_setlut(const uint8_t* lut)
|
||||
epaper_sendcommand(WRITE_LUT_REGISTER);
|
||||
/* the length of look-up table is 30 bytes */
|
||||
for (int i = 0; i < 30; i++) {
|
||||
SendData(lut[i]);
|
||||
epaper_senddata(lut[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void _epaper_setmemoryarea(uint8_t x_start, uint8_t y_start, uint8_t x_stop, uint8_t y_stop)
|
||||
void _epaper_setmemoryarea(uint16_t x_start, uint16_t y_start, uint16_t x_stop, uint16_t y_stop)
|
||||
{
|
||||
epaper_sendcommand(SET_RAM_X_ADDRESS_START_END_POSITION);
|
||||
/* x point must be the multiple of 8 or the last 3 bits will be ignored */
|
||||
epaper_senddata((x_start >> 3) & 0xFF);
|
||||
epaper_senddata((x_end >> 3) & 0xFF);
|
||||
epaper_senddata((x_stop >> 3) & 0xFF);
|
||||
epaper_sendcommand(SET_RAM_Y_ADDRESS_START_END_POSITION);
|
||||
epaper_senddata(y_start & 0xFF);
|
||||
epaper_senddata((y_start >> 8) & 0xFF);
|
||||
epaper_senddata(y_end & 0xFF);
|
||||
epaper_senddata((y_end >> 8) & 0xFF);
|
||||
epaper_senddata(y_stop & 0xFF);
|
||||
epaper_senddata((y_stop >> 8) & 0xFF);
|
||||
}
|
||||
|
||||
void _epaper_setmemorypointer(uint8_t x, uint8_t y)
|
||||
void _epaper_setmemorypointer(uint16_t x, uint16_t y)
|
||||
{
|
||||
epaper_sendcommand(SET_RAM_X_ADDRESS_COUNTER);
|
||||
/* x point must be the multiple of 8 or the last 3 bits will be ignored */
|
||||
@@ -129,7 +147,7 @@ void epaper_sendcommand(uint8_t command)
|
||||
void epaper_senddata(uint8_t data)
|
||||
{
|
||||
_epaper_digitalwrite(DC_PIN, 1);
|
||||
_epaper_spitransfer(command);
|
||||
_epaper_spitransfer(data);
|
||||
}
|
||||
|
||||
void epaper_reset()
|
||||
@@ -140,30 +158,25 @@ void epaper_reset()
|
||||
for(uint32_t i = 0; i<10000; i++);
|
||||
}
|
||||
|
||||
void epaper_setframe(uint8_t* image_buffer, uint8_t x, uint8_t y, uint8_t w, uint8_t h)
|
||||
void epaper_setframe(uint8_t* image_buffer, uint16_t x, uint16_t y, uint16_t w, uint16_t h)
|
||||
{
|
||||
int x_end;
|
||||
int y_end;
|
||||
|
||||
if (
|
||||
image_buffer == NULL ||
|
||||
x < 0 || image_width < 0 ||
|
||||
y < 0 || image_height < 0
|
||||
) {
|
||||
return;
|
||||
}
|
||||
if (image_buffer == 0 || x < 0 || w < 0 || y < 0 || h < 0) return;
|
||||
|
||||
/* x point must be the multiple of 8 or the last 3 bits will be ignored */
|
||||
x &= 0xF8;
|
||||
image_width &= 0xF8;
|
||||
if (x + image_width >= this->width) {
|
||||
x_end = this->width - 1;
|
||||
w &= 0xF8;
|
||||
if (x + w >= EPD_WIDTH) {
|
||||
x_end = EPD_WIDTH - 1;
|
||||
} else {
|
||||
x_end = x + image_width - 1;
|
||||
x_end = x + EPD_WIDTH - 1;
|
||||
}
|
||||
if (y + image_height >= this->height) {
|
||||
y_end = this->height - 1;
|
||||
if (y + h >= EPD_HEIGHT) {
|
||||
y_end = EPD_HEIGHT - 1;
|
||||
} else {
|
||||
y_end = y + image_height - 1;
|
||||
y_end = y + EPD_HEIGHT - 1;
|
||||
}
|
||||
_epaper_setmemoryarea(x, y, x_end, y_end);
|
||||
_epaper_setmemorypointer(x, y);
|
||||
@@ -171,7 +184,7 @@ void epaper_setframe(uint8_t* image_buffer, uint8_t x, uint8_t y, uint8_t w, uin
|
||||
/* send the image data */
|
||||
for (int j = 0; j < y_end - y + 1; j++) {
|
||||
for (int i = 0; i < (x_end - x + 1) / 8; i++) {
|
||||
SendData(image_buffer[i + j * (image_width / 8)]);
|
||||
epaper_senddata(image_buffer[i + j * (w / 8)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -182,7 +195,7 @@ void epaper_clearframe(uint8_t color)
|
||||
_epaper_setmemorypointer(0, 0);
|
||||
epaper_sendcommand(WRITE_RAM);
|
||||
/* send the color data */
|
||||
for (int i = 0; i < this->width / 8 * this->height; i++) {
|
||||
for (int i = 0; i < EPD_WIDTH / 8 * EPD_HEIGHT; i++) {
|
||||
epaper_senddata(color);
|
||||
}
|
||||
}
|
||||
@@ -202,19 +215,3 @@ void epaper_sleep()
|
||||
epaper_sendcommand(DEEP_SLEEP_MODE);
|
||||
epaper_senddata(0x01);
|
||||
}
|
||||
|
||||
const uint8_t lut_full_update[] = {
|
||||
0x50, 0xAA, 0x55, 0xAA, 0x11, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0xFF, 0xFF, 0x1F, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
const uint8_t lut_partial_update[] = {
|
||||
0x10, 0x18, 0x18, 0x08, 0x18, 0x18,
|
||||
0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x13, 0x14, 0x44, 0x12,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
11
src/main.c
11
src/main.c
@@ -8,10 +8,6 @@
|
||||
#include "lib_ENS_II1_lcd.h"
|
||||
#include "lib_epaper_2in9.h"
|
||||
|
||||
|
||||
#define SCK_PIN P0_19
|
||||
|
||||
|
||||
//
|
||||
// Main routine
|
||||
//
|
||||
@@ -24,10 +20,13 @@ int main(void) {
|
||||
init_lcd();
|
||||
lcd_puts("Test e-paper");
|
||||
lcd_position(1, 0);
|
||||
lcd_puts("Init ok");
|
||||
lcd_puts("Initialisation ok");
|
||||
|
||||
while(1) {
|
||||
|
||||
for(int i = 100000; i>0; i--);
|
||||
epaper_clearframe(0xFF);
|
||||
for(int i = 100000; i>0; i--);
|
||||
epaper_clearframe(0x88);
|
||||
};
|
||||
|
||||
} // end of main
|
||||
|
||||
Reference in New Issue
Block a user