eink - ink screen operation library#

Adapted Air780E/Air700E Air780EP Air601 Air101/Air103 Air105 ESP32C3 ESP32S3

Note

This page document is automatically generated by this file. If there is any error, please submit issue or help modify pr, thank you!

Tip

This library has its own demo,click this link to view eink’s demo example

Constant#

constant

type

explanation

eink.MODEL_1in02d

number

1.02 Inch d

eink.MODEL_1in54

number

1.54 Inch

eink.MODEL_1in54_V2

number

1.54 Inch _V2

eink.MODEL_1in54b

number

1.54 Inch b

eink.MODEL_1in54b_V2

number

1.54 Inch b_V2

eink.MODEL_1in54_V3

number

1.54 Inch _V3

eink.MODEL_1in54c

number

1.54 Inch c

eink.MODEL_1in54r

number

1.54 Inch three-color screen 152*152

eink.MODEL_2in13

number

2.13 Inch

eink.MODEL_2in13bc

number

2.13 Inch bc

eink.MODEL_2in13d

number

2.13 Inch d

eink.MODEL_2in13_V2

number

2.13 Inch V2

eink.MODEL_2in54b_V3

number

2.13 Inch b_V3

eink.MODEL_2in66

number

2.66 Inch

eink.MODEL_2in66b

number

2.66 Inch b

eink.MODEL_2in7

number

2.7 Inch

eink.MODEL_2in7b

number

2.7 Inch b

eink.MODEL_2in9

number

2.9 Inch

eink.MODEL_2in9_V2

number

2.9 Inch _V2

eink.MODEL_2in9bc

number

2.9 Inch bc

eink.MODEL_2in9b_V3

number

2.9 Inch b_V3

eink.MODEL_2in9d

number

2.9 Inch d

eink.MODEL_3in52

number

3.52 Inch

eink.MODEL_3in7

number

3.7 Inch

eink.MODEL_3in7_U

number

3.7 Inch

eink.MODEL_4in2

number

4.2 Inch

eink.MODEL_4in2V2

number

4.2 Inch V2(ssd1683)

eink.MODEL_4in2bc

number

4.2 Inch b

eink.MODEL_4in2b_V2

number

4.2 Inch V2

eink.MODEL_5in65f

number

5.65 Inch f

eink.MODEL_5in83

number

5.83 Inch

eink.MODEL_5in83bc

number

5.83 Inch bc

eink.MODEL_5in83_V2

number

5.83 Inch V2

eink.MODEL_5in83b_V2

number

5.83 Inch bV2

eink.MODEL_7in5

number

7.5 Inch

eink.MODEL_7in5_HD

number

7.5 Inch HD

eink.MODEL_7in5_V2

number

7.5 Inch V2

eink.MODEL_7in5bc

number

7.5 Inch bc

eink.MODEL_7in5b_HD

number

7.5 Inch b_HD

eink.MODEL_7in5b_V2

number

7.5 Inch b_V2

eink.font_opposansm12

font

12 Font

eink.font_unifont_t_symbols

font

Symbol Font

eink.font_open_iconic_weather_6x_t

font

Weather Font

eink.font_opposansm16

font

16 Font

eink.font_opposansm18

font

18 Font

eink.font_opposansm20

font

20 Font

eink.font_opposansm22

font

22 Font

eink.font_opposansm24

font

24 Font

eink.font_opposansm32

font

32 Font

eink.font_opposansm12_chinese

font

12 Chinese font

eink.font_opposansm14_chinese

font

14 Chinese font

eink.font_opposansm16_chinese

font

16 Chinese font

eink.font_opposansm18_chinese

font

18 Chinese font

eink.font_opposansm20_chinese

font

20 Chinese font

eink.font_opposansm22_chinese

font

22 Chinese font

eink.font_opposansm24_chinese

font

24 Chinese font

eink.font_opposansm32_chinese

font

32 Chinese font

eink.init(tp, args,spi_device)#

eink Display initialization

Parameters

Incoming Value Type

Explanation

number

eink types, currently supported:https://wiki.luatos.org/api/eink.html#id1

table

Additional parameters, related to specific devices:
pin_busy(busy)
port:spi port, such as 0,1,2… if it is device mode, it is “device”
pin_dc:eink data/command selection pin
pin_rst:eink reset pin

userdata

spi Device, valid when port = “device”

Return Value

None

Examples

-- Initialize spi0 eink.MODEL_4 in2bc) Note: eink needs to be initialized before initialization spi
spi_eink = spi.deviceSetup(0,20,0,0,8,20000000,spi.MSB,1,1)
log.info("eink.init",
eink.init(eink.MODEL_4in2bc,{port = "device",pin_dc = 17, pin_pwr = 7,pin_rst = 19,direction = 2,w = 160,h = 80,xoffset = 1,yoffset = 26},spi_eink))

eink.setup(full, spiid, pin_busy, pin_reset, pin_dc, pin_cs)#

Initialization eink

Parameters

Incoming Value Type

Explanation

int

Full screen refresh 0, partial refresh 1, default is full screen refresh

int

The spi of the location. The default value is 0

int

Busy Busy signal pin

int

Reset Reset Pin

int

DC Data Command Select Pin

int

CS enable pin

Return Value

return value type

explanation

boolean

Returns true on success, otherwise false

Examples

None


eink.sleep()#

Enter sleep mode, need to re-initialize when using again

Parameters

None

Return Value

None

Examples

None


eink.clear(color, force)#

Clear the drawing buffer, the default is not immediately flushed to the device

Parameters

Incoming Value Type

Explanation

number

color Optional, default 1. Screen color

bool

force Optional, default false. If true, clear the screen immediately

Return Value

return value type

explanation

nil

No return value

Examples

None


eink.setWin(width, height, rotate)#

Settings window

Parameters

Incoming Value Type

Explanation

int

width Width

int

height Height

int

rotate Display direction, 0/1/2/3, equivalent to rotation of 0 degrees/90 degrees/180 degrees/270 degrees

Return Value

return value type

explanation

nil

No return value

Examples

None


eink.getWin()#

Get window information

Parameters

None

Return Value

return value type

explanation

int

width Wide

int

height High

int

rotate Rotation direction

Examples

None


eink.setFont(font)#

Set Font

Parameters

Incoming Value Type

Explanation

userdata

Font

Return Value

None

Examples

-- Set to font, valid for print after
eink.setFont(eink.font_opposansm12_chinese)

eink.print(x, y, str, colored)#

Draw String

Parameters

Incoming Value Type

Explanation

int

x Coordinates

int

y Coordinates

string

String

int

Color, can be 0 or 1, the default is 0

Return Value

return value type

explanation

nil

No return value

Examples

-- Set the font first, then write
-- Available fonts depend on the specific firmware. If you don't have the size you want, you can compile a custom firmware in the cloud.
-- font_opposansm8_chinese
-- font_opposansm10_chinese
-- font_opposansm12_chinese
-- font_opposansm14_chinese
-- font_opposansm16_chinese
eink.setFont(eink.font_opposansm12_chinese)
eink.print(10, 20, "LuatOS")

eink.show(x, y, noClear)#

Output the buffer image to the screen

Parameters

Incoming Value Type

Explanation

int

x x-coordinate of the output, default 0

int

y y-coordinate of the output, default 0

bool

Optional, default false. If it is true, the screen is not cleared and new content is directly brushed on.

Return Value

return value type

explanation

nil

No return value

Examples

None


eink.draw(buff, buff2, noclear)#

Output data directly to the screen, support two-color data

Parameters

Incoming Value Type

Explanation

userdata

zbuff Pointer

userdata

zbuff Pointer

bool

Optional, default false. If it is true, the screen is not cleared and new content is directly brushed on.

Return Value

return value type

explanation

nil

No return value

Examples

None


eink.line(x, y, x2, y2, colored)#

Buffer Draw Line

Parameters

Incoming Value Type

Explanation

int

x coordinate of starting point

int

starting point y coordinate

int

End point x coordinate

int

End y coordinate

Return Value

return value type

explanation

nil

No return value

Examples

eink.line(0, 0, 10, 20, 0)

eink.rect(x, y, x2, y2, colored, fill)#

Buffer Draw Rectangle

Parameters

Incoming Value Type

Explanation

int

x-coordinate of top left vertex

int

y-coordinate of top left vertex

int

x-coordinate of bottom right vertex

int

bottom right vertex y coordinate

int

The default is 0

int

Whether to fill, the default is 0, do not fill

Return Value

return value type

explanation

nil

No return value

Examples

eink.rect(0, 0, 10, 20)
eink.rect(0, 0, 10, 20,0, 1) -- Filled

eink.circle(x, y, radius, colored, fill)#

Buffer Draw Circle

Parameters

Incoming Value Type

Explanation

int

center x coordinate

int

center y coordinate

int

Radius

int

The default is 0

int

Whether to fill, the default is 0, do not fill

Return Value

return value type

explanation

nil

No return value

Examples

eink.circle(0, 0, 10)
eink.circle(0, 0, 10, 1, 1) -- Filled

eink.qrcode(x, y, str, size)#

Buffer Drawing QRCode

Parameters

Incoming Value Type

Explanation

int

x Coordinates

int

y Coordinates

string

The content of the two-dimensional code

int

Display size (note: the generated size of the two-dimensional code is related to the content to be displayed and the error correction level. the generated version is an indefinite size of 1-40 (corresponding to 21x21-177x177). if the size is different from the set size, the two-dimensional code will be automatically displayed in the middle of the specified area. if the two-dimensional code is not displayed, please check the log prompt.)

Return Value

return value type

explanation

nil

No return value

Examples

None


eink.bat(x, y, bat)#

Buffer Draw Battery

Parameters

Incoming Value Type

Explanation

int

x Coordinates

int

y Coordinates

int

Battery voltage in millivolts

Return Value

return value type

explanation

nil

No return value

Examples

None


eink.weather_icon(x, y, code)#

Buffer Draw Weather Icon

Parameters

Incoming Value Type

Explanation

int

x Coordinates

int

y Coordinates

int

Weather Code

Return Value

return value type

explanation

nil

No return value

Examples

None


eink.model(m)#

Set ink screen driver model

Parameters

Incoming Value Type

Explanation

int

Model name, for example eink.model(eink.MODEL_1in54_V2)

Return Value

return value type

explanation

nil

No return value

Examples

None


eink.drawXbm(x, y, w, h, data)#

Draw Bitmap

Parameters

Incoming Value Type

Explanation

int

X Coordinates

int

y Coordinates

int

bitmap width

int

Bitmap Height

int

Bitmap data, each bit representing a pixel

Return Value

None

Examples

-- The mold can be taken using PCtoLCD2002 software.
-- In (0,0) for the upper left corner, draw a 16x 16 "today" bitmap
eink.drawXbm(0, 0, 16,16, string.char(
    0x80,0x00,0x80,0x00,0x40,0x01,0x20,0x02,0x10,0x04,0x48,0x08,0x84,0x10,0x83,0x60,
    0x00,0x00,0xF8,0x0F,0x00,0x08,0x00,0x04,0x00,0x04,0x00,0x02,0x00,0x01,0x80,0x00
))

eink.setCtx(index)#

Switch color drawing board, suitable for multi-color ink screen

Parameters

Incoming Value Type

Explanation

int

Color index, 0 for black and 0 for red 1

Return Value

None

Examples

-- Only suitable for multi-color ink screen, invalid for monochrome ink screen (only black and white)
eink.setCtx(1)
-- After switching, all drawXXX will operate on the artboard of the specified color

eink.async(index)#

Asynchronous mode. To use this mode, you need to require(“sysplus”) first and then eink.clear().wait() eink.show().wait()

Parameters

Incoming Value Type

Explanation

int

1 Using Asynchronous

Return Value

None

Examples

    eink.async(1)
    spi_eink = spi.deviceSetup(spi_id,pin_cs,0,0,8,20*1000*1000,spi.MSB,1,1)
    eink.init(eink.MODEL_1in54,
            {port = "device",pin_dc = pin_dc, pin_busy = pin_busy,pin_rst = pin_reset},
            spi_eink)
    eink.setWin(200, 200, 0)
    sys.wait(100)
    log.info("e-paper 1.54", "Testing Go")
    eink.print(30, 20, "LuatOS-AIR780E",0x00)
    eink.show().wait()
    log.info("e-paper 1.54", "Testing End")