Problems with adapting library for Z-Uno

Discussion about Z-Uno product. Visit http://z-uno.z-wave.me for more details.
Post Reply
cls02
Posts: 3
Joined: 14 Mar 2017 09:49

Problems with adapting library for Z-Uno

Post by cls02 »

Hi,

I am trying to adapt the Adafruit_RGBLCDShield library to work with the Z-Uno, using the ZUNO_MCP23017 library (which seems to be based on the Adafruit one). However, I get the following error when compiling:

Compiling file "/var/folders/vw/4dbt13s178163k4kvrch0lt40000gn/T/build509803355726088525.tmp/
ZUNO_RGBLCDShieldNoButtons_ucxx.c" by means of SDCC...
/var/folders/vw/4dbt13s178163k4kvrch0lt40000gn/T/build509803355726088525.tmp/
ZUNO_RGBLCDShieldNoButtons_ucxx.c:320: error 200: field '_i2c' has incomplete type

The related code snippets are are:

ZUNO_RGBLCDShieldNoButtons.h

Code: Select all

ZUNO_MCP23017 _i2c;
And in ZUNO_RGBLCDShieldNoButtons_ucxx.c

Code: Select all

//class ZUNO_MCP23017 DECLARATION
//--------------------------------------------------------------------------------
typedef struct cxx__class__ZUNO_MCP23017_s
{
     unsigned char i2caddr;

}cxx__class__ZUNO_MCP23017;

//--------------------------------------------------------------------------------


//class ZUNO_RGBLCDShieldNoButtons DECLARATION
//--------------------------------------------------------------------------------
typedef struct cxx__class__ZUNO_RGBLCDShieldNoButtons_s
{
     void ** __cxx__vmethod__table;
     int write_error;
     unsigned char _rs_pin;
     unsigned char _rw_pin;
     unsigned char _enable_pin;
     unsigned char _data_pins[8];
     unsigned char _displayfunction;
     unsigned char _displaycontrol;
     unsigned char _displaymode;
     unsigned char _initialized;
     unsigned char _numlines;
     unsigned char _currline;
     unsigned char _i2cAddr;
     struct cxx__class__ZUNO_MCP23017 _i2c;

}cxx__class__ZUNO_RGBLCDShieldNoButtons;
The error message refers to the last line above. (Using Z-Uno 2.0.8 on Mac OS X 10.12.3). The library compiles just fine for other HW.

What am I missing here?

Thanks in advance,
Casper
p0lyg0n1
Posts: 242
Joined: 04 Aug 2016 07:14

Re: Problems with adapting library for Z-Uno

Post by p0lyg0n1 »

Compiler doesn't support aggregated objects.
So you have to use pointer instead of a copy of an object.
So, you have to use

Code: Select all

ZUNO_MCP23017 * _i2c;
and refactor some code inside the class RGBLCDShieldNoButtons:
1. access to method of _i2c object:

Code: Select all

_i2c->method(...)
instead of

Code: Select all

_i2c.method(...)
2. Initialize it inside constructor with pointer to your object (something like this):

Code: Select all

RGBLCDShieldNoButtons(ZUNO_MCP23017 * i2c_mcp, <another parameters>): _i2c(i2c_mcp)
{
  // some other code ...
}
cls02
Posts: 3
Joined: 14 Mar 2017 09:49

Re: Problems with adapting library for Z-Uno

Post by cls02 »

Thanks - works perfectly. Casper
cls02
Posts: 3
Joined: 14 Mar 2017 09:49

Re: Problems with adapting library for Z-Uno

Post by cls02 »

Got the RGBLCDShield working ok, but having problems with migrating the Keypad_MC17 library, which is used to interface Keypads via the MCP23017.

I get the strange message "Unknown error":
Preprocessing file: /var/folders/vw/4dbt13s178163k4kvrch0lt40000gn/T/build1926746325090264338.tmp/ZUNO_Keypad_MC17.cpp with SDCPP...
Compiling /var/folders/vw/4dbt13s178163k4kvrch0lt40000gn/T/build1926746325090264338.tmp/ZUNO_Keypad_MC17_sdcpp_.cpp ...Unknown error:'class ZUNO_Keypad' uCxx returned error code:-1

Any idea what error code -1 means, and what could be wrong? I can send/attach the code if needed.

Thanks again,
Casper
p0lyg0n1
Posts: 242
Joined: 04 Aug 2016 07:14

Re: Problems with adapting library for Z-Uno

Post by p0lyg0n1 »

Please add the full output and ZUNO_Keypad_MC17* files. Looks like uCxx internal error.
Post Reply