B4R Question Help adding a function to an existing wrapper

Discussion in 'B4R Questions' started by Kevin, Jun 28, 2018.

  1. Kevin

    Kevin Well-Known Member Licensed User

    I use the rLiquidCrystal_I2C library and wanted to add a function to it to directly support creating a custom character. I think I am close but I end up with the following error when attempting to compile the project:

    Here is the relevant code:

    B4R (I think this would be right if I can work out the compilation problem:
    Code:
    Dim CharMap() As Byte = Array As Byte (0x08,0x14,0x08,0x07,0x04,0x07,0x04,0x04)
    lcd.CreateChar (
    1, CharMap)
    rLiquidCrystal_I2C_Cust.xml:
    Code:
    <method>
                <name DesignerName=
    "CreateChar">CreateChar</name>
                <comment>Creates a custom character 
    to be displayed.</comment>
                <returntype>B4R::void</returntype>
                <parameter>
                    <name>Index</name>
                    <
    type>Byte</type>
                </parameter>
                <parameter>
                    <name>CharMap</name>
                    <
    type>Byte[]</type>
                </parameter>
            </method>
    rLiquidCrystal_I2C_Cust.cpp:
    Code:
    void B4RLiquidCrystal_I2C::CreateChar(Byte Slot, ArrayByte* CharMap) {
            lcd->createChar(Slot, CharMap);
        
    }
    rLiquidCrystal_I2C_Cust.h:
    Code:
    void CreateChar(Byte Slot, ArrayByte* CharMap);
    LiquidCrystal_I2C_Cust.cpp:
    Code:
    // Allows us to fill the first 8 CGRAM locations
    // with custom characters
    void LiquidCrystal_I2C::createChar(uint8_t 
    location, uint8_t charmap[]) {
        
    location &= 0x7; // we only have 8 locations 0-7
        command(LCD_SETCGRAMADDR | (
    location << 3));
        
    for (int i=0; i<8; i++) {
            write(charmap[i]);
        
    }
    }

    LiquidCrystal_I2C_Cust.h:
    • Code:
      void createChar(uint8_t, uint8_t[]);
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Kevin likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice