eb1992 / ShiftLcd

An Arduino library that provides an easy-to-use interface for controlling an LCD display with a shift register.
MIT License
2 stars 0 forks source link

[Enhancement] Support for CH55x Arduino Platform #1

Closed tobychui closed 3 months ago

tobychui commented 4 months ago

Hi eb1992, thanks for the great work!

I was trying to use ShiftLcd with CH552G using the ch55xdruino board definitions. However, I am getting this error message

sdcpp.exe: fatal error: when writing output to : Broken pipe
D:\Projects\Lab-bench power supply\lcd\lcd-test\lcd\ShiftLcd.h:11: error 1: Syntax error, declaration ignored at 'class'
D:\Projects\Lab-bench power supply\lcd\lcd-test\lcd\ShiftLcd.h:11: syntax error: token -> 'ShiftLcd' ; column 14
D:\Projects\Lab-bench power supply\lcd\lcd-test\lcd\ShiftLcd.h:22: syntax error: token -> '=' ; column 40
cp:: No such file or directory
exit status 1
Error compiling for board CH552 Board.

And it is the compilation result from an empty sketch with only the library imported (and the .cpp and .h files are under the lcd folder)

#include "lcd/ShiftLcd.h"

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

I have read your code in the src folder, seems this implementation didn't depends on Wire.h or other CH55x not supported library. Might I have some clues on how I can fix this by changing the source code of the .cpp or the .h file? Thanks in advance!

eb1992 commented 3 months ago

Hi!

After some googling it seems that your board CH552G and ch55xdruino does not use C++ libraries, but C libraries instead. This explains the error messages from your build. Classes does not exist in C: error 1: Syntax error, declaration ignored at 'class'. Neither does default parameter values: D:\Projects\Lab-bench power supply\lcd\lcd-test\lcd\ShiftLcd.h:22: syntax error: token -> '=' ; column 40

I'm sure that this library could be rewritten in C just by looking at the existing logic, but since I don't have hardware to test on I will not try to do that.

Feel free to try it yourself and let me know if it works out!