B4R Question Help adding a function to an existing wrapper

Kevin

Well-Known Member
Licensed User
Longtime 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:

no known conversion for argument 2 from 'B4R::ArrayByte* {aka B4R::Array*}' to 'uint8_t* {aka unsigned char*}'
exit status 1

Here is the relevant code:

B4R (I think this would be right if I can work out the compilation problem:
B4X:
Dim CharMap() As Byte = Array As Byte (0x08,0x14,0x08,0x07,0x04,0x07,0x04,0x04)
lcd.CreateChar (1, CharMap)

rLiquidCrystal_I2C_Cust.xml:
B4X:
<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:
B4X:
void B4RLiquidCrystal_I2C::CreateChar(Byte Slot, ArrayByte* CharMap) {
        lcd->createChar(Slot, CharMap);
    }

rLiquidCrystal_I2C_Cust.h:
B4X:
void CreateChar(Byte Slot, ArrayByte* CharMap);

LiquidCrystal_I2C_Cust.cpp:
B4X:
// 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:
  • B4X:
    void createChar(uint8_t, uint8_t[]);
 
Top