earthlcd / ezLCD-5x

Public Repository for ezLCD-5035-RT release files system, firmware and issue reporting
https://earthlcd.com/products/ezlcd-5x?_pos=1&_sid=0927d2260&_ss=r
0 stars 1 forks source link

ez.I2CWrite(Address, Register, Data [, regSize [, timeout]]) attempt to call a nil value #61

Closed JacobChrist closed 1 year ago

JacobChrist commented 1 year ago

Describe the bug Attempting to use: ez.I2CWrite(Address, Register, Data [, regSize [, timeout]])

Called like this:

  result = ez.I2CWrite(42, 0, 0)

The following error is in LuaError.log [string "ezCmdLua"]:824: attempt to call a nil value (field 'I2CWrite')

Going to attempt to stuff value in to a lstringData.

JacobChrist commented 1 year ago

Same result when trying to stuff into a lstring:

function NAU7802_setRegister(registerAddress, value)
    data = string.char(value)
    result = ez.I2CWrite(_deviceAddress, registerAddress, data, string.len(data))
    return result
end
JacobChrist commented 1 year ago

This is a documentation error, I don't have permissions to update the labels. The W in Write should not be capitalized in the lua manual.

ez.I2CWrite(Address, Register, Data [, regSize [, timeout]]) ez.I2CWrite(Address, Register, lstringData, dataSize [, regSize [, timeout]]) should be:

ez.I2Cwrite(Address, Register, Data [, regSize [, timeout]]) ez.I2Cwrite(Address, Register, lstringData, dataSize [, regSize [, timeout]])

Tested both with Data and lstringData, both seem to work (but I will not know for sure until I get the rest of the code working).

microlan commented 1 year ago

Yes, Lua is case-sensitive. I confirmed in the source code that the "W" should be lower-case. Fixed in the manual. I'll push the update to Git as part of a few other minor docs changes.