Giter VIP home page Giter VIP logo

Comments (1)

VasilKalchev avatar VasilKalchev commented on June 8, 2024

Sorry for the huge delay.

The problem comes from the difference between the constructor of the original LiquidCrystal library and the constructor of the LiquidCrystal_I2C library.

The LiquidCrystal library calls it's public method begin() (used again later in setup()) from the constructor which allows method calls on the object.
The LiquidCrystal_I2C library doesn't call it, and for some reason calling the object's methods before begin() breaks the object.

So when using LiquidCrystal_I2C, my LiquidMenu constructor calls LiquidCrystal_I2C::createChar(int, int[]) before LiquidCrystal_I2C::begin() is called, which breaks the not fully initialized LiquidCrystal_I2C object.

I tried calling the begin() method from the LiquidCrystal_I2C constructor, but that broke the object too. I also tried modifying the code in the LiquidCrystal_I2C::begin() method, but I couldn't make it to work.

The way to make it work without breaking the LiquidMenu API is to move the 3 calls:

// LiquidMenu/src/LiquidMenu.cpp
    ...
    _p_liquidCrystal->createChar(15, symbol::rightFocus);
    _p_liquidCrystal->createChar(14, symbol::leftFocus);
    _p_liquidCrystal->createChar(13, symbol::customFocus);
    ...

and the "focus" variables:

// LiquidMenu/src/symbols.h
    namespace symbol {
    uint8_t rightFocus[8] = {
      0b00000 ,0b00100, 0b01000, 0b11111, 0b01000, 0b00100, 0b00000, 0b00000
    };
    uint8_t leftFocus[8] = {
      0b00000, 0b00100, 0b00010, 0b11111, 0b00010, 0b00100, 0b00000,0b00000
    };
    uint8_t customFocus[8] = {
      0b00000, 0b00000, 0b01110, 0b01110, 0b01110, 0b00000, 0b00000, 0b00000
    };
    } //namespace symbol

to the end of the LiquidCrystal_I2C::begin() method:

// LiquidCrystal_I2C/LiquidCrystal_I2C.cpp
    ...
    // set the entry mode
    command(LCD_ENTRYMODESET | _displaymode);

    home();

    createChar(15, symbol::rightFocus);
    createChar(14, symbol::leftFocus);
    createChar(13, symbol::customFocus);
  }
  ...

and the variables in the same file before the constructor. Other solution will be to use a different I2C library if there is available.

from liquidmenu.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.