i have code legacy hardware lcd display. code in main sketch , comes before setup(). looks this:
unfortunately, need support 2 different i2c lcd modules use different values pins.
i store variant device has in eeprom, think won't have access information until setup(). if instantiate in setup() isn't global.
i know use #ifdef, #else,#endif, i'd rather not way
looking @ liquidcrystal code, when object instantiated, sets bunch of private attributes using private method config(). think make work if changed liquidcrystal .config() protected , created own object inherited liquidcrystal_i2c . i'd rather not have special version of library. there better way?
code: [select]
static const uint8_t en_pin = 4;
static const uint8_t rw_pin = 5;
static const uint8_t rs_pin = 6;
static const uint8_t d4_pin = 0;
static const uint8_t d5_pin = 1;
static const uint8_t d6_pin = 2;
static const uint8_t d7_pin = 3;
liquidcrystal_i2c lcd(i2c_addr_lcd,en_pin,rw_pin,rs_pin,d4_pin,d5_pin,d6_pin,d7_pin);
unfortunately, need support 2 different i2c lcd modules use different values pins.
i store variant device has in eeprom, think won't have access information until setup(). if instantiate in setup() isn't global.
i know use #ifdef, #else,#endif, i'd rather not way
looking @ liquidcrystal code, when object instantiated, sets bunch of private attributes using private method config(). think make work if changed liquidcrystal .config() protected , created own object inherited liquidcrystal_i2c . i'd rather not have special version of library. there better way?
i don't see better way. if instantiate object in setup, it's going go out of scope when setup ends , leave unable use @ all.
Arduino Forum > Using Arduino > Programming Questions > Initializing global object (LCD) from setup().
arduino
Comments
Post a Comment