Hi there,
I'm trying to write a Simulink block to use with Arduino an LCD 1602 driven through the I2C port. What I would like to obtain is to be able to display some text on the LCD display connected to my Arduino Uno:
I have already written a custom block to drive with Arduino the internal LED, and it works fine (see internal_led_custom_block.zip).
I wanted to use the same approach to write a driver for the LCD 1602 display, but I am struggling to let the coder to compile my .cpp program. In particular I get the following error (and may others...) which is generated by the file:
In file included from /home/scorretti/Documents/MATLAB/SupportPackages/R2023a/3P.instrset/arduinoide.instrset/arduino-1.8.19/hardware/arduino/avr/cores/arduino/Print.h:27:0,
from /home/scorretti/Documents/MATLAB/programs/Arduino/lcd_1602_i2c/libraries/LiquidCrystal_I2C.h:6,
from /home/scorretti/Documents/MATLAB/programs/Arduino/lcd_1602_i2c/include/lcd1602.h:6,
from /home/scorretti/Documents/MATLAB/programs/Arduino/lcd_1602_i2c/demo_lcd_1602_ert_rtw/demo_lcd_1602.h:27,
from /home/scorretti/Documents/MATLAB/programs/Arduino/lcd_1602_i2c/demo_lcd_1602_ert_rtw/demo_lcd_1602_data.c:20:
/home/scorretti/Documents/MATLAB/SupportPackages/R2023a/3P.instrset/arduinoide.instrset/arduino-1.8.19/hardware/arduino/avr/cores/arduino/Printable.h:25:1: error: unknown type name 'class'; did you mean 'labs'?
class Print;
^~~~~
Up to my understanding, the problem is that the compiler is trying to compile the file Print.h like if it were written in C instead of C++, and I cannot figure out why and how to fix this.
It is not possible to configure the project so as to use C++
My C++ code (lcd1602.cpp) is basically a copy/paste from an Arduino sketch (Sketch_1_1_Display_the_string_on_LCD1602.ino) which uses the same library, but compiles and runs fine.
Similar topics / examples may be:
The last question seems really close to the problem I'm facing, but I could not solve it as well.
Any help is appreciated.
R.S.