mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-25 20:26:41 +00:00
qrcode default version increased
This commit is contained in:
parent
053f1f91c8
commit
3f4e79a195
@ -119,6 +119,8 @@ lv_res_t lv_qrcode_update(lv_obj_t* qrcode, const void* data, uint32_t data_len)
|
|||||||
lv_canvas_fill_bg(qrcode, c, 0);
|
lv_canvas_fill_bg(qrcode, c, 0);
|
||||||
// lv_canvas_zoom();
|
// lv_canvas_zoom();
|
||||||
|
|
||||||
|
LV_LOG_INFO("Update QR-code text with length : %d", data_len);
|
||||||
|
|
||||||
if(data_len > qrcodegen_BUFFER_LEN_MAX) return LV_RES_INV;
|
if(data_len > qrcodegen_BUFFER_LEN_MAX) return LV_RES_INV;
|
||||||
|
|
||||||
uint8_t qr0[qrcodegen_BUFFER_LEN_MAX];
|
uint8_t qr0[qrcodegen_BUFFER_LEN_MAX];
|
||||||
@ -128,7 +130,10 @@ lv_res_t lv_qrcode_update(lv_obj_t* qrcode, const void* data, uint32_t data_len)
|
|||||||
bool ok = qrcodegen_encodeBinary(data_tmp, data_len, qr0, qrcodegen_Ecc_MEDIUM, qrcodegen_VERSION_MIN,
|
bool ok = qrcodegen_encodeBinary(data_tmp, data_len, qr0, qrcodegen_Ecc_MEDIUM, qrcodegen_VERSION_MIN,
|
||||||
qrcodegen_VERSION_MAX, qrcodegen_Mask_AUTO, true);
|
qrcodegen_VERSION_MAX, qrcodegen_Mask_AUTO, true);
|
||||||
|
|
||||||
if(!ok) return LV_RES_INV;
|
if(!ok) {
|
||||||
|
LV_LOG_WARN("QR-code encoding error");
|
||||||
|
return LV_RES_INV;
|
||||||
|
}
|
||||||
|
|
||||||
lv_coord_t obj_w = lv_obj_get_width(qrcode);
|
lv_coord_t obj_w = lv_obj_get_width(qrcode);
|
||||||
int qr_size = qrcodegen_getSize(qr0); // Number of vertical QR blocks
|
int qr_size = qrcodegen_getSize(qr0); // Number of vertical QR blocks
|
||||||
@ -136,6 +141,8 @@ lv_res_t lv_qrcode_update(lv_obj_t* qrcode, const void* data, uint32_t data_len)
|
|||||||
int scaled = qr_size * scale;
|
int scaled = qr_size * scale;
|
||||||
int margin = (obj_w - scaled) / 2;
|
int margin = (obj_w - scaled) / 2;
|
||||||
|
|
||||||
|
LV_LOG_INFO("Update QR-code data : obj_w[%d] QR moduls[%d] scale factor[%d]", obj_w, qr_size, scale);
|
||||||
|
|
||||||
/*Expand the qr encodet binary to canvas size*/
|
/*Expand the qr encodet binary to canvas size*/
|
||||||
for(int y = 0; y < scaled; y++) {
|
for(int y = 0; y < scaled; y++) {
|
||||||
for(int x = 0; x < scaled; x++) {
|
for(int x = 0; x < scaled; x++) {
|
||||||
|
@ -122,8 +122,22 @@ struct qrcodegen_Segment
|
|||||||
|
|
||||||
/*---- Macro constants and functions ----*/
|
/*---- Macro constants and functions ----*/
|
||||||
|
|
||||||
#define qrcodegen_VERSION_MIN 1 // The minimum version number supported in the QR Code Model 2 standard
|
/* Version number supported in the QR Code Model 2 standard
|
||||||
#define qrcodegen_VERSION_MAX 3 // The maximum version number supported in the QR Code Model 2 standard
|
* higher version numbers can process longer texts but require more memory and computing time.
|
||||||
|
*
|
||||||
|
* VERSION_MAX = 3 : max text length to encode 42 alphanumeric characters
|
||||||
|
* VERSION_MAX = 5 : max text length to encode 85 alphanumeric characters
|
||||||
|
* VERSION_MAX = 7 : max text length to encode 122 alphanumeric characters
|
||||||
|
* VERSION_MAX = 9 : max text length to encode 180 alphanumeric characters
|
||||||
|
* VERSION_MAX = 11 : max text length to encode 251 alphanumeric characters
|
||||||
|
* VERSION_MAX = 15 : max text length to encode 412 alphanumeric characters
|
||||||
|
* and so on
|
||||||
|
* VERSION_MAX = 25 : openHASP restarts on qrcode update
|
||||||
|
*/
|
||||||
|
#define qrcodegen_VERSION_MIN 1 // The minimum version number
|
||||||
|
#ifndef qrcodegen_VERSION_MAX
|
||||||
|
#define qrcodegen_VERSION_MAX 7 // The maximum version number
|
||||||
|
#endif
|
||||||
|
|
||||||
// Calculates the number of bytes needed to store any QR Code up to and including the given version number,
|
// Calculates the number of bytes needed to store any QR Code up to and including the given version number,
|
||||||
// as a compile-time constant. For example, 'uint8_t buffer[qrcodegen_BUFFER_LEN_FOR_VERSION(25)];'
|
// as a compile-time constant. For example, 'uint8_t buffer[qrcodegen_BUFFER_LEN_FOR_VERSION(25)];'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user