mirror of
https://github.com/usetrmnl/bb_epaper.git
synced 2026-04-29 13:43:26 -07:00
Updated to build as an esp-idf component and in c++
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
idf_component_register(
|
||||
SRCS "src/bb_epaper.cpp"
|
||||
"src/bb_ep.inl"
|
||||
"src/Group5.cpp"
|
||||
"src/bb_ep_gfx.inl"
|
||||
"src/g5dec.inl"
|
||||
INCLUDE_DIRS "src"
|
||||
REQUIRES driver esp_timer
|
||||
)
|
||||
+11
-3
@@ -6,6 +6,8 @@
|
||||
#ifndef __ESP_IDF_IO__
|
||||
#define __ESP_IDF_IO__
|
||||
|
||||
#include "esp_timer.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "driver/spi_master.h"
|
||||
|
||||
#define INPUT 0
|
||||
@@ -41,13 +43,13 @@ void pinMode(int iPin, int iMode)
|
||||
{
|
||||
gpio_config_t io_conf = {};
|
||||
|
||||
gpio_reset_pin(iPin);
|
||||
gpio_reset_pin((gpio_num_t)iPin);
|
||||
if (iMode == DISABLED) return;
|
||||
io_conf.intr_type = GPIO_INTR_DISABLE; //disable interrupt
|
||||
//bit mask of the pins that you want to set,e.g.GPIO18/19
|
||||
io_conf.pin_bit_mask = (1ULL << iPin);
|
||||
io_conf.pull_down_en = 0; //disable pull-down mode
|
||||
io_conf.pull_up_en = (iMode == INPUT_PULLUP); // pull-up mode
|
||||
io_conf.pull_down_en = GPIO_PULLDOWN_DISABLE;
|
||||
io_conf.pull_up_en = (iMode == INPUT_PULLUP) ? GPIO_PULLUP_ENABLE : GPIO_PULLUP_DISABLE; // pull-up mode
|
||||
if (iMode == INPUT || iMode == INPUT_PULLUP) {
|
||||
io_conf.mode = GPIO_MODE_INPUT;
|
||||
} else { // must be output
|
||||
@@ -59,6 +61,12 @@ int digitalRead(int iPin)
|
||||
{
|
||||
return (int)gpio_get_level((gpio_num_t)iPin);
|
||||
} /* digitalRead() */
|
||||
|
||||
long millis(void)
|
||||
{
|
||||
return (long)(esp_timer_get_time() / 1000L);
|
||||
} /* millis() */
|
||||
|
||||
void delayMicroseconds(long l)
|
||||
{
|
||||
l *= 40;
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
# For more information about build system see
|
||||
# https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html
|
||||
# The following five lines of boilerplate have to be in your project's
|
||||
# CMakeLists in this exact order for cmake to work correctly
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
set(EXTRA_COMPONENT_DIRS "../../")
|
||||
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
project(hello_world_cpp)
|
||||
@@ -0,0 +1,2 @@
|
||||
idf_component_register(SRCS "hello_world_cpp.cpp"
|
||||
INCLUDE_DIRS ".")
|
||||
@@ -0,0 +1,25 @@
|
||||
#include <stdio.h>
|
||||
#include <bb_epaper.h>
|
||||
BBEPAPER bbep(EP102_80x128);
|
||||
|
||||
// Pinout for the LilyGo mini-epaper S3
|
||||
#define PIN_BUSY 10
|
||||
#define PIN_RST 11
|
||||
#define PIN_DC 12
|
||||
#define PIN_CS 13
|
||||
#define PIN_SCK 14
|
||||
#define PIN_MOSI 15
|
||||
|
||||
extern "C" void app_main(void)
|
||||
{
|
||||
bbep.initIO(PIN_DC, PIN_RST, PIN_BUSY, PIN_CS, PIN_MOSI, PIN_SCK, 4000000);
|
||||
bbep.allocBuffer();
|
||||
bbep.fillScreen(BBEP_WHITE);
|
||||
bbep.setTextColor(BBEP_BLACK, BBEP_WHITE);
|
||||
bbep.setFont(FONT_12x16);
|
||||
bbep.println("Hello");
|
||||
bbep.println("C++!");
|
||||
bbep.writePlane();
|
||||
bbep.refresh(REFRESH_FULL);
|
||||
bbep.sleep(1);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -9,7 +9,7 @@
|
||||
#include <bb_epaper.h>
|
||||
#include "bart_80x128.h" // a pre-compressed image made with the Linux CLI tool in this repo
|
||||
|
||||
BBEPAPER bbep(EPD102_80x128);
|
||||
BBEPAPER bbep(EP102_80x128);
|
||||
G5DECODER g5dec;
|
||||
#define IMAGE_WIDTH 80
|
||||
#define IMAGE_HEIGHT 128
|
||||
|
||||
+2
-2
@@ -1489,7 +1489,7 @@ uint8_t u8Cache[512];
|
||||
// ** ONLY ADD NEW PANELS TO THE END OF THE LIST **
|
||||
//
|
||||
const EPD_PANEL panelDefs[] PROGMEM = {
|
||||
{0}, // undefined panel
|
||||
{0,0,0,NULL,NULL,NULL,0,0,NULL}, // undefined panel
|
||||
{400, 300, 0, epd42_init_sequence_full, NULL, epd42_init_sequence_part, 0, BBEP_CHIP_UC81xx, u8Colors_2clr}, // EP42_400x300
|
||||
{400, 300, 0, epd42b_init_sequence_full, epd42b_init_sequence_fast, epd42b_init_sequence_part, 0, BBEP_CHIP_SSD16xx, u8Colors_2clr}, // EP42B_400x300
|
||||
{122, 250, 0, epd213_122x250_init_sequence_full, NULL, epd213_122x250_init_sequence_part, 0, BBEP_CHIP_SSD16xx, u8Colors_2clr}, // EP213_122x250 WaveShare
|
||||
@@ -1527,7 +1527,7 @@ const EPD_PANEL panelDefs[] PROGMEM = {
|
||||
{480, 800, 0, epd426_init_full, epd426_init_fast, epd426_init_part, 0, BBEP_CHIP_SSD16xx, u8Colors_2clr},
|
||||
{128, 296, 0, epd29r2_init_sequence_full, NULL, NULL, BBEP_RED_SWAPPED | BBEP_3COLOR, BBEP_CHIP_UC81xx, u8Colors_3clr}, // EP29R2_128x296 Adafruit 2.9" 128x296 Tricolor FeatherWing
|
||||
{640, 400, 0, epd41_init_sequence_full, NULL, NULL, BBEP_4BPP_DATA, BBEP_CHIP_UC81xx, u8Colors_2clr}, // EP41_640x400 Eink ED040TC1
|
||||
{1024, 576, 0, epd81c_init_full, NULL, NULL, BBEP_SPLIT_BUFFER | BBEP_7COLOR, BBEP_CHIP_UC81xx, u8Colors_spectra}, // 8.1" 1024x576 dual cable Spectra 6 EP81_SPECTRA_1024x576
|
||||
{1024, 576, 0, epd81c_init_full, NULL, NULL, BBEP_SPLIT_BUFFER | BBEP_7COLOR, BBEP_CHIP_UC81xx, u8Colors_spectra} // 8.1" 1024x576 dual cable Spectra 6 EP81_SPECTRA_1024x576
|
||||
};
|
||||
//
|
||||
// Set the e-paper panel type
|
||||
|
||||
+10
-6
@@ -35,8 +35,12 @@ void delay(int);
|
||||
#ifdef _LINUX_
|
||||
#include "rpi_io.inl"
|
||||
#else
|
||||
#ifdef ARDUINO
|
||||
#include "arduino_io.inl" // I/O (non-portable) code is in here
|
||||
#endif
|
||||
#else
|
||||
#include "../esp_idf/esp_generic.inl" // ESP-IDF specific
|
||||
#endif // ARDUINO
|
||||
#endif // _LINUX_
|
||||
#include "bb_ep.inl" // All of the display interface code is in here
|
||||
#include "bb_ep_gfx.inl" // drawing code
|
||||
|
||||
@@ -71,7 +75,7 @@ void BBEPAPER::setCS2(uint8_t cs)
|
||||
bbepSetCS2(&_bbep, cs);
|
||||
}
|
||||
|
||||
#ifdef ARDUINO
|
||||
#ifndef _LINUX_
|
||||
void BBEPAPER::initIO(int iDC, int iReset, int iBusy, int iCS, int iMOSI, int iSCLK, uint32_t u32Speed)
|
||||
{
|
||||
bbepInitIO(&_bbep, iDC, iReset, iBusy, iCS, iMOSI, iSCLK, u32Speed);
|
||||
@@ -260,7 +264,7 @@ void BBEPAPER::drawLine(int x1, int y1, int x2, int y2, int iColor)
|
||||
bbepDrawLine(&_bbep, x1, y1, x2, y2, iColor);
|
||||
} /* drawLine() */
|
||||
|
||||
#ifdef _LINUX_
|
||||
#ifndef ARDUINO
|
||||
void BBEPAPER::print(const string &str)
|
||||
{
|
||||
print(str.c_str());
|
||||
@@ -357,11 +361,11 @@ char ucTemp[4];
|
||||
print((const char *)ucTemp);
|
||||
} /* println() */
|
||||
|
||||
#endif // _LINUX_
|
||||
#endif // !ARDUINO_
|
||||
//
|
||||
// write (Arduino Print friend class)
|
||||
//
|
||||
#ifndef __AVR__
|
||||
#if !defined( __AVR__ )
|
||||
size_t BBEPAPER::write(uint8_t c) {
|
||||
char szTemp[2]; // used to draw 1 character at a time to the C methods
|
||||
int w=8, h=8;
|
||||
@@ -409,7 +413,7 @@ int w=8, h=8;
|
||||
}
|
||||
return 1;
|
||||
} /* write() */
|
||||
#endif // !__AVR__
|
||||
#endif // ARDUINO && !__AVR__
|
||||
|
||||
void BBEPAPER::drawPixel(int16_t x, int16_t y, uint8_t color)
|
||||
{
|
||||
|
||||
+8
-4
@@ -396,7 +396,7 @@ BB_SET_PIXEL_FAST *pfnSetPixelFast;
|
||||
} BBEPDISP;
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if defined( _LINUX_ )
|
||||
#ifndef ARDUINO
|
||||
#include <string>
|
||||
using namespace std;
|
||||
class BBEPAPER
|
||||
@@ -416,9 +416,13 @@ class BBEPAPER
|
||||
void setCS2(uint8_t cs);
|
||||
bool hasFastRefresh();
|
||||
bool hasPartialRefresh();
|
||||
#ifndef _LINUX_
|
||||
#ifdef ARDUINO
|
||||
void initIO(int iDC, int iReset, int iBusy, int iCS = SS, int iMOSI = MOSI, int iSCLK = SCK, uint32_t u32Speed = 8000000);
|
||||
#else
|
||||
#else // esp-idf?
|
||||
void initIO(int iDC, int iReset, int iBusy, int iCS, int iMOSI, int iSCLK, uint32_t u32Speed);
|
||||
#endif // ARDUINO
|
||||
#else // _LINUX_
|
||||
void initIO(int iDC, int iReset, int iBusy, int iCS, int iSPIChannel, uint32_t u32Speed = 8000000);
|
||||
#endif
|
||||
int writePlane(int iPlane = PLANE_DUPLICATE);
|
||||
@@ -475,7 +479,7 @@ class BBEPAPER
|
||||
int getPlane(void);
|
||||
int getChip(void);
|
||||
void drawSprite(const uint8_t *pSprite, int cx, int cy, int iPitch, int x, int y, uint8_t iColor);
|
||||
#if defined (_LINUX_)
|
||||
#if !defined (ARDUINO)
|
||||
void print(const char *pString);
|
||||
void println(const char *pString);
|
||||
void print(int, int);
|
||||
@@ -489,7 +493,7 @@ class BBEPAPER
|
||||
using Print::write;
|
||||
virtual size_t write(uint8_t);
|
||||
#endif // __AVR__
|
||||
#endif // _LINUX_
|
||||
#endif // !ARDUINO
|
||||
|
||||
private:
|
||||
BBEPDISP _bbep;
|
||||
|
||||
Reference in New Issue
Block a user