Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,17 @@
"@epaperjs/rpi-4in2": "workspace:^",
"@epaperjs/rpi-7in5-v2": "workspace:^",
"@epaperjs/rpi-2in7": "workspace:^",
"@epaperjs/rpi-3in7": "workspace:^"
"@epaperjs/rpi-3in7": "workspace:^",
"@epaperjs/rpi-13in3": "workspace:^"
},
"peerDependencies": {
"@epaperjs/rpi-2in13-bc": "workspace:^",
"@epaperjs/rpi-2in13-v2": "workspace:^",
"@epaperjs/rpi-4in2": "workspace:^",
"@epaperjs/rpi-7in5-v2": "workspace:^",
"@epaperjs/rpi-2in7": "workspace:^",
"@epaperjs/rpi-3in7": "workspace:^"
"@epaperjs/rpi-3in7": "workspace:^",
"@epaperjs/rpi-13in3": "workspace:^"
},
"peerDependenciesMeta": {
"@epaperjs/rpi-2in13-bc": {
Expand All @@ -62,6 +64,9 @@
},
"@epaperjs/rpi-3in7": {
"optional": true
},
"@epaperjs/rpi-13in3": {
"optional": true
}
}
}
}
10 changes: 10 additions & 0 deletions packages/cli/src/deviceFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const deviceMap = new Map<string, (orientation?: Orientation, colorMode?: ColorM
['rpi-7in5-v2', getRpi7in5V2],
['rpi-2in7', getRpi2In7],
['rpi-3in7', getRpi3In7],
['rpi-13in3', getRpi13In3],
]);

async function getRpi2in13V2(orientation?: Orientation, colorMode?: ColorMode): Promise<DisplayDevice> {
Expand Down Expand Up @@ -74,3 +75,12 @@ async function getRpi3In7(orientation?: Orientation, colorMode?: ColorMode): Pro
throw new Error('Failed to import @epaperjs/rpi-3in7, make sure it is installed');
}
}

async function getRpi13In3(orientation?: Orientation, colorMode?: ColorMode): Promise<DisplayDevice> {
try {
const { Rpi13In3 } = await import('@epaperjs/rpi-13in3');
return new Rpi13In3(orientation, colorMode);
} catch (e) {
throw new Error('Failed to import @epaperjs/rpi-13in3, make sure it is installed');
}
}
10 changes: 8 additions & 2 deletions packages/cli/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
"sourceMap": false,
"declarationMap": false
},
"include": ["src/**/*.ts", "src/**/*.js"],
"include": [
"src/**/*.ts",
"src/**/*.js"
],
"references": [
{
"path": "../core"
Expand All @@ -28,6 +31,9 @@
},
{
"path": "../rpi-3in7"
},
{
"path": "../rpi-13in3"
}
]
}
}
17 changes: 17 additions & 0 deletions packages/rpi-13in3/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# @epaperjs/rpi-13in3

Node bindings for [Waveshare 13.3"](https://www.waveshare.com/13.3inch-e-paper-hat.htm)

## Supported Color Modes

`Black / White`

## Installation

```
npm i -g @epaperjs/rpi-13in3
```

## License

MIT
30 changes: 30 additions & 0 deletions packages/rpi-13in3/binding.gyp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"targets": [
{
"target_name": "waveshare13in3",
"cflags!": [
"-fno-exceptions",
"-Wextra"
],
"cflags_cc!": [ "-fno-exceptions" ],
"sources": [
"./src/c/EPD_IT8951_node.cc",
"./src/c/DEV_Config.c",
"./src/c/EPD_IT8951.c",
"./src/c/dev_hardware_SPI.c",
"./src/c/RPI_sysfs_gpio.c"
],
"defines": [
"RPI",
"USE_DEV_LIB"
],
"include_dirs": [
"<!@(node -p \"require('node-addon-api').include\")"
],
"libraries": [
"-lm",
"-lbcm2835"
]
}
]
}
37 changes: 37 additions & 0 deletions packages/rpi-13in3/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"name": "@epaperjs/rpi-13in3",
"version": "2.0.2",
"private": false,
"description": "ePaper.js support for Waveshare 13.3",
"author": "samsonmking <[email protected]>",
"homepage": "https://github.com/samsonmking/epaper.js#readme",
"bugs": {
"url": "https://github.com/samsonmking/epaper.js/issues"
},
"license": "MIT",
"main": "lib/rpi13In3.js",
"files": [
"lib",
"src/c",
"binding.gyp"
],
"repository": {
"type": "git",
"url": "git+https://github.com/samsonmking/epaper.js.git"
},
"scripts": {
"build": "node-gyp rebuild",
"clean": "node-gyp clean",
"build:clean": "pnpm clean && pnpm build"
},
"dependencies": {
"@epaperjs/core": "workspace:^",
"bindings": "^1.5.0",
"node-addon-api": "^4.2.0",
"node-gyp": "^8.4.1"
},
"gypfile": true,
"devDependencies": {
"@types/bindings": "^1.5.1"
}
}
176 changes: 176 additions & 0 deletions packages/rpi-13in3/src/c/DEV_Config.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
/*****************************************************************************
* | File : DEV_Config.c
* | Author : Waveshare team
* | Function : Hardware underlying interface
* | Info :
*----------------
* | This version: V3.0
* | Date : 2019-09-17
* | 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 theex 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_Config.h"
#include <fcntl.h>


/******************************************************************************
function: GPIO Write
parameter:
Info:
******************************************************************************/
void DEV_Digital_Write(UWORD Pin, UBYTE Value)
{
bcm2835_gpio_write(Pin, Value);
}

/******************************************************************************
function: GPIO Read
parameter:
Info:
******************************************************************************/
UBYTE DEV_Digital_Read(UWORD Pin)
{
UBYTE Read_Value = 0;
Read_Value = bcm2835_gpio_lev(Pin);
return Read_Value;
}

/******************************************************************************
function: SPI Write
parameter:
Info:
******************************************************************************/
void DEV_SPI_WriteByte(UBYTE Value)
{
bcm2835_spi_transfer(Value);
}

/******************************************************************************
function: SPI Read
parameter:
Info:
******************************************************************************/
UBYTE DEV_SPI_ReadByte()
{
UBYTE Read_Value = 0x00;
Read_Value = bcm2835_spi_transfer(0x00);
return Read_Value;
}

/******************************************************************************
function: Time delay for ms
parameter:
Info:
******************************************************************************/
void DEV_Delay_ms(UDOUBLE xms)
{
bcm2835_delay(xms);
}


/******************************************************************************
function: Time delay for us
parameter:
Info:
******************************************************************************/
void DEV_Delay_us(UDOUBLE xus)
{
bcm2835_delayMicroseconds(xus);
}






/**
* GPIO Mode
**/
static void DEV_GPIO_Mode(UWORD Pin, UWORD Mode)
{
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);
}
}


/**
* GPIO Init
**/
static void DEV_GPIO_Init(void)
{
DEV_GPIO_Mode(EPD_RST_PIN, BCM2835_GPIO_FSEL_OUTP);
DEV_GPIO_Mode(EPD_CS_PIN, BCM2835_GPIO_FSEL_OUTP);
DEV_GPIO_Mode(EPD_BUSY_PIN, BCM2835_GPIO_FSEL_INPT);

DEV_Digital_Write(EPD_CS_PIN, HIGH);
}



/******************************************************************************
function: Module Initialize, the library and initialize the pins, SPI protocol
parameter:
Info:
******************************************************************************/
UBYTE DEV_Module_Init(void)
{
Debug("/***********************************/ \r\n");

if(!bcm2835_init()) {
Debug("bcm2835 init failed !!! \r\n");
return 1;
} else {
Debug("bcm2835 init success !!! \r\n");
}

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_16); //For RPi3/3B/3B+
bcm2835_spi_setClockDivider(BCM2835_SPI_CLOCK_DIVIDER_32); //For RPi 4
/* SPI clock reference link:*/
/*http://www.airspayce.com/mikem/bcm2835/group__constants.html#gaf2e0ca069b8caef24602a02e8a00884e*/

//GPIO Config
DEV_GPIO_Init();

Debug("/***********************************/ \r\n");
return 0;
}



/******************************************************************************
function: Module exits, closes SPI and BCM2835 library
parameter:
Info:
******************************************************************************/
void DEV_Module_Exit(void)
{
DEV_Digital_Write(EPD_CS_PIN, LOW);
DEV_Digital_Write(EPD_RST_PIN, LOW);

bcm2835_spi_end();
bcm2835_close();
}
Loading