Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QR code type 10 or higher not scanable #32

Open
vdneut opened this issue Nov 26, 2021 · 2 comments
Open

QR code type 10 or higher not scanable #32

vdneut opened this issue Nov 26, 2021 · 2 comments

Comments

@vdneut
Copy link

vdneut commented Nov 26, 2021

The qr codes generated and displayed on a 320x480 TFT / Arduino MEGA can be scanned using an average qr-code scanner app, up to type 9. Using type 10 or higher, the app does not scan the code.

qrcode_initText retruns 0 (zero). Seems to be ok.

See code below, including the output: type 9 is working and type 10 is not working

Not sure if it is something I did wrong, or any other reason.
Help is greatly appreciated!

Kind regards

#include "qrcode.h"
#define LCD_CS A3 // Chip Select goes to Analog 3
#define LCD_CD A2 // Command/Data goes to Analog 2
#define LCD_WR A1 // LCD Write goes to Analog 1
#define LCD_RD A0 // LCD Read goes to Analog 0
#define LCD_RESET A4 // Can alternately just connect to Arduino's reset pin
#include <SPI.h>          // f.k. for Arduino-1.5.2
#include "Adafruit_GFX.h"// Hardware-specific library
#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;
#define BLACK   0x0000
#define WHITE   0xFFFF

void setup() {
    int qr_return;
    // Create the QR code
    QRCode qrcode;
    uint8_t qrcodeData9[qrcode_getBufferSize(9)]; 
    
    qrcode_initText(&qrcode, qrcodeData9, 9, 0, "https://a.nl?b=HelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHel0123456789");
    
    uint16_t ID = tft.readID(); //
    tft.begin(ID);
    tft.fillScreen(WHITE);

    uint8_t qr_size = 5;
    uint8_t qr_top = 20;
    uint8_t qr_left = (320 / 2) - int((qrcode.size * qr_size) / 2);  // Center

    // Each line of modules
    for (uint8_t y = 0; y < qrcode.size; y++) {
        // Each horizontal module
        for (uint8_t x = 0; x < qrcode.size; x++) {
          if (qrcode_getModule(&qrcode, x, y)) {
            
            tft.fillRect(qr_left + (qr_size * x), qr_top + (qr_size * y), qr_size, qr_size, BLACK);
          }
        }
    }
   
    uint8_t qrcodeData10[qrcode_getBufferSize(10)]; 
    qrcode_initText(&qrcode, qrcodeData10, 10, 0, "https://a.nl?b=HelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHelloworldHel0123456789");

    qr_left = (320 / 2) - int((qrcode.size * qr_size) / 2);  // Center
    tft.fillScreen(WHITE);
    // Each line of modules
    for (uint8_t y = 0; y < qrcode.size; y++) {
        // Each horizontal module
        for (uint8_t x = 0; x < qrcode.size; x++) {
          if (qrcode_getModule(&qrcode, x, y)) {
            
            tft.fillRect(qr_left + (qr_size * x), qr_top + (qr_size * y), qr_size, qr_size, BLACK);
          }
        }
    }
}

void loop() {

}

Type 9 is working
typ9-works

Type 10 is not working
type10-not-working

@vdneut
Copy link
Author

vdneut commented Dec 14, 2021

Status: not solved

And did some digging and found that LOCK_VERSION could be set to 10 and create smaller arrays (it might be a memory problem?). But no effect.

Has anyone tested this with type 10 or higher?

To be complete, I include the arrays for type 10:

`#elif LOCK_VERSION == 10

static const int16_t NUM_ERROR_CORRECTION_CODEWORDS[4] = {
130, 72, 224, 192
};

static const int8_t NUM_ERROR_CORRECTION_BLOCKS[4] = {
5, 4, 8, 8
};

static const uint16_t NUM_RAW_DATA_MODULES = 2768;
`

@vdneut
Copy link
Author

vdneut commented Dec 14, 2021

Status: Solved
Within function getModeBits() in qrcode.c
Change
unsigned int modeInfo = 0x7bbb80a;
Into
unsigned long modeInfo = 0x7bbb80a;
To avoid truncation of 0x7bbb80a.
To reproduce: use the int and compile with warning level high or 'all'.
@ricmoo or @per1234 could you please solve this bug in the library?
Regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant