Skip to content

Commit

Permalink
Merge pull request #6 from mtribiere/Dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
mtribiere authored Mar 7, 2021
2 parents b57ff13 + 94e50f7 commit 23e30a0
Show file tree
Hide file tree
Showing 20 changed files with 87 additions and 336 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
cmake_minimum_required(VERSION 3.5)

include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(spi_epaper)
project(spi_epaper_example)
5 changes: 5 additions & 0 deletions components/Epaper/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
set(COMPONENT_ADD_INCLUDEDIRS include)
set(COMPONENT_SRCS "src/EPD.c")
set(COMPONENT_SRCS "src/painterEPD.c")

register_component()
12 changes: 12 additions & 0 deletions components/Epaper/component.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#
# Main component makefile.
#
# This Makefile can be left empty. By default, it will take the sources in the
# src/ directory, compile them and link them into lib(subdirectory_name).a
# in the build directory. This behaviour is entirely configurable,
# please read the ESP-IDF documents if you need to do this.
#

COMPONENT_SRCDIRS := src
COMPONENT_ADD_INCLUDEDIRS := include

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
#define FONT_12_HEIGHT 12

// Font data for Courier New 12pt
uint8_t Font_12_table[] =
uint8_t Font_12_table[] PROGMEM =
{
// @0 ' ' (7 pixels wide)
0x00, //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#define FONT_16_HEIGHT 16


uint8_t Font_16_table[] =
uint8_t Font_16_table[] PROGMEM =
{
// @0 ' ' (11 pixels wide)
0x00, 0x00, //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#define FONT_20_HEIGHT 20

// Character bitmaps for Courier New 15pt
uint8_t Font_20_table[] =
uint8_t Font_20_table[] PROGMEM =
{
// @0 ' ' (14 pixels wide)
0x00, 0x00, //
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions main/painterEPD.h → components/Epaper/include/painterEPD.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
#define BLACK 0
#define WHITE 1

//Define section to put in flash
#define PROGMEM ICACHE_RODATA_ATTR
#define ICACHE_RODATA_ATTR __attribute__((section(".irom.text")))

//Define font struct
typedef struct{
uint16_t fontW; //Using 16 bits int to help memory management
Expand Down
File renamed without changes.
60 changes: 45 additions & 15 deletions main/painterEPD.c → components/Epaper/src/painterEPD.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,25 +48,55 @@ esp_err_t epaper_draw_square(uint8_t x, uint8_t y,uint8_t size){

esp_err_t epaper_draw_line(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1) {

/* Bresenham line algorithm */
int dx = x1 - x0 >= 0 ? x1 - x0 : x0 - x1;
int sx = x0 < x1 ? 1 : -1;
int dy = y1 - y0 <= 0 ? y1 - y0 : y0 - y1;
int sy = y0 < y1 ? 1 : -1;
int err = dx + dy;

while((x0 != x1) && (y0 != y1)) {
epaper_draw_pixel(x0, y0 , BLACK);
if (2 * err >= dy) {
err += dy;
x0 += sx;
//If straight vertical line
if(x0 == x1){

while(y0 != y1){
epaper_draw_pixel(x0, y0 , BLACK);
if(y0<y1)
y0++;
else
y0--;
}
if (2 * err <= dx) {
err += dx;
y0 += sy;


}else{

//If straight horizontal line
if(y0 == y1){

while(x0 != x1){
epaper_draw_pixel(x0,y0,BLACK);
if(x0<x1)
x0++;
else
x0--;
}

}else{

/* Bresenham line algorithm */
int dx = x1 - x0 >= 0 ? x1 - x0 : x0 - x1;
int sx = x0 < x1 ? 1 : -1;
int dy = y1 - y0 <= 0 ? y1 - y0 : y0 - y1;
int sy = y0 < y1 ? 1 : -1;
int err = dx + dy;

while((x0 != x1) && (y0 != y1)) {
epaper_draw_pixel(x0, y0 , BLACK);
if (2 * err >= dy) {
err += dy;
x0 += sx;
}
if (2 * err <= dx) {
err += dx;
y0 += sy;
}
}
}
}


return ESP_OK;
}

Expand Down
4 changes: 4 additions & 0 deletions components/SPI/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
set(COMPONENT_ADD_INCLUDEDIRS include)
set(COMPONENT_SRCS "src/spiEPD.c")

register_component()
11 changes: 11 additions & 0 deletions components/SPI/component.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#
# Main component makefile.
#
# This Makefile can be left empty. By default, it will take the sources in the
# src/ directory, compile them and link them into lib(subdirectory_name).a
# in the build directory. This behaviour is entirely configurable,
# please read the ESP-IDF documents if you need to do this.
#

COMPONENT_SRCDIRS := src
COMPONENT_ADD_INCLUDEDIRS := include
File renamed without changes.
File renamed without changes.
6 changes: 2 additions & 4 deletions main/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
set(COMPONENT_SRCS "spi_epaper.c")
set(COMPONENT_SRCS "EPD.c")
set(COMPONENT_SRCS "spiEPD.c")
set(COMPONENT_SRCS "painterEPD.c")
set(COMPONENT_SRCS "spi_epaper_example.c")


register_component()
313 changes: 0 additions & 313 deletions main/img.h

This file was deleted.

File renamed without changes.

0 comments on commit 23e30a0

Please sign in to comment.