Go Down

Topic: M2TKLIB Hello World with LiquidCrystal_I2C (Read 4 times) previous topic - next topic

digimate

I am trying to use M2TKLIB with my I2C 20x4 LCD panel.   I tried modifying the hello world program to use the different library...

Code: [Select]

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include "M2tk.h"
#include "utility/m2ghlc.h"

LiquidCrystal_I2C lcd(0x3F,20,4);

M2_LABEL(hello_world_label, NULL, "Hello World!");
M2tk m2(&hello_world_label, NULL, NULL, m2_gh_lc);

void setup() {
 m2_SetLiquidCrystal(&lcd, 16, 2);
}

void loop() {
 m2.draw();
 delay(500);
}



But I get the following errors

Quote
In file included from HelloWorld.cpp:29:0:
/home/myhome/sketchbook/libraries/M2tklib/utility/m2ghlc.h:27:27: fatal error: LiquidCrystal.h: No such file or directory
compilation terminated.


So I tried a simple change to m2ghlc.h

Code: [Select]
//#include <LiquidCrystal.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>


But more errors appear...

Quote
In file included from HelloWorld_for_m2tklib.cpp:29:0:
/home/myhome/sketchbook/libraries/M2tklib/utility/m2ghlc.h:31:26: error: variable or field 'm2_SetLiquidCrystal' declared void
/home/myhome/sketchbook/libraries/M2tklib/utility/m2ghlc.h:31:26: error: 'LiquidCrystal' was not declared in this scope
/home/myhome/sketchbook/libraries/M2tklib/utility/m2ghlc.h:31:41: error: 'lc_ptr' was not declared in this scope
/home/myhome/sketchbook/libraries/M2tklib/utility/m2ghlc.h:31:57: error: expected primary-expression before 'cols'
/home/myhome/sketchbook/libraries/M2tklib/utility/m2ghlc.h:31:71: error: expected primary-expression before 'rows'
HelloWorld_for_m2tklib.cpp: In function 'void setup()':
HelloWorld_for_m2tklib.cpp:40:34: error: 'm2_SetLiquidCrystal' was not declared in this scope


So I thought I had better ask before making matters worse :)


olikraus

The simple answer is, M2tklib does not support LiquidCrystal_I2C.

If you want to support LiquidCrystal_I2C, you need to locate "m2ghlc.cpp"
Replace LiquidCrystal with LiquidCrystal_I2C, but also replace all member function calls with the equivalent one from LiquidCrystal_I2C.
For example you will find:
Code: [Select]
    case M2_GFX_MSG_START:
      m2_gh_lc_cursor_y = 255;
      m2_lc_ptr->noCursor();
      m2_lc_ptr->noBlink();
      m2_lc_ptr->clear();

So, for noCursor() you need to find the corresponding function name to switch the cursor off.

Once this is done all your errors should go away.

Oliver



digimate

I was starting to come to that conclusion myself.   It seems that nearly all LCD libraries seem to target the non-I2C devices, so although I really like how the I2C display interfaces with only a couple of pins, it makes more work whenever I want to use a library like M2TKLIB.

Thanks for the help.

olikraus

Can you provide a link to the I2C lib? I will check if i can do the porting.

Oliver

digimate


Go Up