Skip to content

Commit bda8191

Browse files
committed
feat(qrcode): Add user_data for qrcode
1 parent 7a06152 commit bda8191

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

qrcode/esp_qrcode_main.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ static const char *lt[] = {
3232
/* 15 */ "\u2588\u2588",
3333
};
3434

35-
void esp_qrcode_print_console(esp_qrcode_handle_t qrcode)
35+
void esp_qrcode_print_console(esp_qrcode_handle_t qrcode, void *user_data)
3636
{
37+
(void)user_data;
3738
int size = qrcodegen_getSize(qrcode);
3839
int border = 2;
3940
unsigned char num = 0;
@@ -103,7 +104,7 @@ esp_err_t esp_qrcode_generate(esp_qrcode_config_t *cfg, const char *text)
103104
qrcodegen_VERSION_MIN, cfg->max_qrcode_version,
104105
qrcodegen_Mask_AUTO, true);
105106
if (ok && cfg->display_func) {
106-
cfg->display_func((esp_qrcode_handle_t)qrcode);
107+
cfg->display_func((esp_qrcode_handle_t)qrcode, cfg->user_data);
107108
err = ESP_OK;
108109
}
109110

qrcode/idf_component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
version: "0.1.0~2"
1+
version: "0.2.0"
22
description: QR Code generator
33
url: https://github.com/espressif/idf-extra-components/tree/master/qrcode

qrcode/include/qrcode.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ typedef const uint8_t *esp_qrcode_handle_t;
2121
* @brief QR Code configuration options
2222
*/
2323
typedef struct {
24-
void (*display_func)(esp_qrcode_handle_t qrcode); /**< Function called for displaying the QR Code after encoding is complete */
24+
void (*display_func)(esp_qrcode_handle_t qrcode, void *user_data); /**< Function called for displaying the QR Code after encoding is complete */
2525
int max_qrcode_version; /**< Max QR Code Version to be used. Range: 2 - 40 */
2626
int qrcode_ecc_level; /**< Error Correction Level for QR Code */
27+
void *user_data; /**< User data */
2728
} esp_qrcode_config_t;
2829

2930
/**
@@ -57,7 +58,7 @@ esp_err_t esp_qrcode_generate(esp_qrcode_config_t *cfg, const char *text);
5758
*
5859
* @param qrcode QR Code handle used by the display function.
5960
*/
60-
void esp_qrcode_print_console(esp_qrcode_handle_t qrcode);
61+
void esp_qrcode_print_console(esp_qrcode_handle_t qrcode, void *user_data);
6162

6263
/**
6364
* @brief Returns the side length of the given QR Code
@@ -90,6 +91,7 @@ bool esp_qrcode_get_module(esp_qrcode_handle_t qrcode, int x, int y);
9091
.display_func = esp_qrcode_print_console, \
9192
.max_qrcode_version = 10, \
9293
.qrcode_ecc_level = ESP_QRCODE_ECC_LOW, \
94+
.user_data = NULL, \
9395
}
9496

9597
#ifdef __cplusplus

0 commit comments

Comments
 (0)