whitecatboard / Lua-RTOS-ESP32

Lua RTOS for ESP32
Other
1.19k stars 221 forks source link

added gdisplay.qrcode #234

Closed the0ne closed 5 years ago

the0ne commented 5 years ago

changed mixed-spacing in gdisplay.c lua module to tab-only spacing changed shadowed-variables in gdisplay.c to static_-named variables to avoid possibly dangerous shadowing

usage example: gdisplay.qrcode(x,y,"text-to-encode"[,gdisplay.ECC_HIGH[, 1]]) gdisplay.qrcode({x,y},"text-to-encode"[,gdisplay.ECC_LOW[, 2]])

... where the last optional parameter is a multi-size factor, hence 2 will double height and width of the qr-code to make it scan-able better on small displays or from large distance

also supports qr code segmentation which can save a lot of qr-space and so make the qr-code smaller: https://www.nayuki.io/page/optimal-text-segmentation-for-qr-codes

gdisplay.qrcode(0,0,{{mode=gdisplay.MODE_ALPHANUM,val="WIFI:S:MY-EXTRA-LONG-NAME"},{mode=gdisplay.MODE_BYTE,val=";T:WPA;P:87654321;;"}})

jolivepetrus commented 5 years ago

@the0ne,

Just starting testing this PR. It's amazing!.

One question, I'm using a 1.8" TFT display, and running this:

gdisplay.attach(gdisplay.ST7735G_18, gdisplay.LANDSCAPE_FLIP, false)
gdisplay.clear(gdisplay.BLACK)
gdisplay.qrcode(0,0,"whitecatboard.org",gdisplay.ECC_HIGH)

The resulting image is:

image

Maybe is too small. Is there any way to set the width to use in generating the QR?.

Also, do you have the wiki for this new feature to merge it in master?

the0ne commented 5 years ago

Is there any way to set the width to use in generating the QR?.

absolutely - that's what the parameter after the ECC type is for. try a value greater than 1 to double (2) or triple (3) the size, etc.

the0ne commented 5 years ago

Also, do you have the wiki for this new feature to merge it in master?

Not yet finished. I plan to provide a wiki update for all of the new PRs together here so you can update the master wiki from there as you wish.

the0ne commented 5 years ago

Is there any way to set the width to use in generating the QR?.

absolutely - that's what the parameter after the ECC type is for. try a value greater than 1 to double (2) or triple (3) the size, etc.

@jolivepetrus did you succeed?

I once noticed that the refresh rates of the display vs. the camera may lead to scanning issues. So I ordered some e-paper display for more tests (still being on its way from china).

jolivepetrus commented 5 years ago

@the0ne,

I will check later.

the0ne commented 5 years ago

Also, do you have the wiki for this new feature to merge it in master?

Not yet finished. I plan to provide a wiki update for all of the new PRs together here so you can update the master wiki from there as you wish.

@jolivepetrus i've added it at the bottom of https://github.com/the0ne/Lua-RTOS-ESP32/wiki/GDISPLAY-module

jolivepetrus commented 5 years ago

@the0ne,

About the wiki, this part is not explained, and maybe it's the most important:

{{mode=gdisplay.MODE_ALPHANUM,val="WIFI:S:MY-EXTRA-LONG-NAME"},{mode=gdisplay.MODE_BYTE,val=";T:WPA;P:87654321;;"}}

the0ne commented 5 years ago

Hmm. I've put there:

This function supports qr code segmentation which can save a lot of qr-space and so make the qr-code smaller: https://www.nayuki.io/page/optimal-text-segmentation-for-qr-codes

gdisplay.qrcode(0,0,{{mode=gdisplay.MODE_ALPHANUM,val="WIFI:S:MY-EXTRA-LONG-NAME"},{mode=gdisplay.MODE_BYTE,val=";T:WPA;P:87654321;;"}})

Well, I guess I could add a description of the supported modes and now to build up the list. Is that what you are missing?