yoprogramo / QRcode_eSPI

Subclasses of QRcodeDisplay to be able to use TFT displays using TFT_eSPI library.
7 stars 2 forks source link

How to select a different QR version ? #5

Closed andersondeoliveiramachado closed 1 year ago

andersondeoliveiramachado commented 1 year ago

In the library documentation: https://github.com/yoprogramo/QRcodeDisplay#how-to-select-a-different-qr-version, it states that it is necessary to define QRCODEVERSION, how can this be done?

// REFERENCIA .: https://raw.githubusercontent.com/yoprogramo/QRcode_eSPI/master/examples/simple.ino
// IDE ........: Arduino 1.8.16
// BIBLIOTECAS : QRcodeDisplay 2.1.10 , QRcode_eSPI 2.0.0 , TFT_eSPI
// DATA/HORA ..: 16/09/2023

#include <SPI.h>
#include <TFT_eSPI.h>

#define QRCODEVERSION 8 /////////// Putting the definition here didn't work.
#include <qrcode_espi.h>

TFT_eSPI display = TFT_eSPI();
QRcode_eSPI qrcode (&display);

void setup() {

    Serial.begin(115200);
    Serial.println("");
    Serial.println("Starting the system ...");

    display.init();

    qrcode.init();

    // PROBLEM CREATING TEXT WITH MORE THAN 154 CHARACTERS, I WAS CUTTING IT, CHANGING TO VERSION 8, IT STARTED READING ALL THE CHARACTERS

    // 163 characters, reading only up to 15 4 in version 7, WITH VERSION 8 YOU CAN ALREADY READ ALL THE CHARACTERS
    //                      10        20        30        40        50        60        70        80        90        100       110       120       130       140       150 | 
    //             1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123

    /*

      Remove from C:\Users\my_user\Documents\Arduino\libraries\QRcodeDisplay\src\frame-v7.c

      #ifndef QRCODEVERSION
      #define QRCODEVERSION 7
      #endif

     Put on C:\Users\my_user\Documents\Arduino\libraries\QRcodeDisplay\src\frame-v8.c

      #ifndef QRCODEVERSION
      #define QRCODEVERSION 8
      #endif

    */

    // Create QRCODE
    qrcode.create("1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123");

}

void loop() {

}
yoprogramo commented 1 year ago

Hello, I'm using Platformio and I can define this variable on the platformio.ini file as

build_flags = 
    -DQRCODEVERSION=8

If you are using arduino ide unfortunatelly there are not such option for individual sketches but you can define at board level, see this:

https://forum.arduino.cc/t/how-to-specify-unique-compiling-options-for-multiple-sketches/679370

Hope it helps

andersondeoliveiramachado commented 1 year ago

Hello, I'm using Platformio and I can define this variable on the platformio.ini file as

build_flags = 
  -DQRCODEVERSION=8

If you are using arduino ide unfortunatelly there are not such option for individual sketches but you can define at board level, see this:

https://forum.arduino.cc/t/how-to-specify-unique-compiling-options-for-multiple-sketches/679370

Hope it helps

Many thanks for the reply, Your project is fantastic. I'm a beginner in this esp32/arduino world.

For now I'm going to use it by changing the file \libraries\QRcodeDisplay\src\frame-v8.c since it's working this way.

juniorradu commented 5 months ago

Hello, I'm using Platformio and I can define this variable on the platformio.ini file as

build_flags = 
  -DQRCODEVERSION=8

If you are using arduino ide unfortunatelly there are not such option for individual sketches but you can define at board level, see this:

https://forum.arduino.cc/t/how-to-specify-unique-compiling-options-for-multiple-sketches/679370

Hope it helps

This worked for me, thanks.