Go Down

Topic: How hard will it be to adapt epaper library that works with UNO for zero? (Read 915 times) previous topic - next topic

futurebirdagain

I've been trying to use an eink display for a long time and at last I found one that works. It's this model and it has a library and example sketches that display text, which is what I want.




I was able to get the library to work with my UNO as in the tutorial. But, when I load it I get an ominous message:

Global variables use 1914 bytes (93%) of dynamic memory, leaving 134 bytes for local variables. Maximum is 2048 bytes.
Low memory available, stability problems may occur.


This won't do. I need to set up a sensor and add other elements to the code and the sketch is already unstable when it's just displaying a few lines of text.

I bought a "Neutrino" board, and Arduino clone a few years back and it claims to be more powerful.



Decided to load the sketch on that board.

The sketch isn't compatible and will not even upload to the zero-clone. I get these errors:

"error: 'PORTD' was not declared in this scope"
"error: 'DDRD' was not declared in this scope"
"note: suggested alternative: 'PORTC'"
"note: in expansion of macro 'Eink_CS1_HIGH'"
"note: in expansion of macro 'Eink_DC_LOW'"

etc.

The "note: suggested alternative: 'PORTC'" makes me wonder if I can fix this by changing some of the dependent libraries. Looking at this post it seems that not every board can use PORTC. Is the zero like NodeMCU in this respect?

I do not want to re-write a whole library. I'd rather just get another board that would work with the library that I have that has more memory. I have ordered a MEGA and maybe that will work?

I have tested that:
-the zero clone will load blink and other sketches just fine. It's only the epaper library that fails.
-the epaper library works fine on the Arduino uno, though the memory issue is troubling.
-the developer has not made a library just for zero.


I don't know much about zero and I'm taking some time to read up on it. I hoped it would just be "a more powerful arduino" but I clearly do not understand the use case. Suspect I'll save this board for another project.



Here is the most of the error code.

Code: [Select]
Arduino: 1.8.13 (Mac OS X), Board: "Arduino Zero (Native USB Port)"

CUT TO FIT POST LIMIT


Compiling sketch...
/Users/myUserName/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/bin/arm-none-eabi-g++ -mcpu=cortex-m0plus -mthumb -c -g -Os -Wall -Wextra -Wno-expansion-to-defined -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD -DF_CPU=48000000L -DARDUINO=10813 -DARDUINO_SAMD_ZERO -DARDUINO_ARCH_SAMD -D__SAMD21G18A__ -DUSB_VID=0x2341 -DUSB_PID=0x804d -DUSBCON "-DUSB_MANUFACTURER=\"Arduino LLC\"" "-DUSB_PRODUCT=\"Arduino Zero\"" -I/Users/myUserName/Library/Arduino15/packages/arduino/tools/CMSIS/4.5.0/CMSIS/Include/ -I/Users/myUserName/Library/Arduino15/packages/arduino/tools/CMSIS-Atmel/1.2.0/CMSIS/Device/ATMEL/ -I/Users/myUserName/Library/Arduino15/packages/arduino/hardware/samd/1.8.6/cores/arduino -I/Users/myUserName/Library/Arduino15/packages/arduino/hardware/samd/1.8.6/variants/arduino_zero -I/Users/myUserName/Documents/Arduino/libraries/SmartEink_Arduino_Library -I/Users/myUserName/Library/Arduino15/packages/arduino/hardware/samd/1.8.6/libraries/SPI /var/folders/vp/7hc1s72n3tg7w21wmk28d7hc0000gn/T/arduino_build_915750/sketch/ShowStringDemo.ino.cpp -o /var/folders/vp/7hc1s72n3tg7w21wmk28d7hc0000gn/T/arduino_build_915750/sketch/ShowStringDemo.ino.cpp.o
/Users/myUserName/Documents/Arduino/libraries/SmartEink_Arduino_Library/examples/ShowStringDemo/ShowStringDemo.ino: In function 'void setup()':
/Users/myUserName/Documents/Arduino/libraries/SmartEink_Arduino_Library/examples/ShowStringDemo/ShowStringDemo.ino:49:38: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
 Eink.EinkP8x16Str(14,8,"NOA-Labs.com");
                                      ^
/Users/myUserName/Documents/Arduino/libraries/SmartEink_Arduino_Library/examples/ShowStringDemo/ShowStringDemo.ino:50:47: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
 Eink.EinkP8x16Str(10,8,"smart-prototyping.com");
                                               ^
/Users/myUserName/Documents/Arduino/libraries/SmartEink_Arduino_Library/examples/ShowStringDemo/ShowStringDemo.ino:51:35: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
 Eink.EinkP8x16Str(6,8,"0123456789");
                                   ^
/Users/myUserName/Documents/Arduino/libraries/SmartEink_Arduino_Library/examples/ShowStringDemo/ShowStringDemo.ino:52:40: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
 Eink.EinkP8x16Str(2,8,"ABCDEFG abcdefg");
                                        ^
Compiling libraries...
Compiling library "SmartEink_Arduino_Library"
/Users/myUserName/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/bin/arm-none-eabi-g++ -mcpu=cortex-m0plus -mthumb -c -g -Os -Wall -Wextra -Wno-expansion-to-defined -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD -DF_CPU=48000000L -DARDUINO=10813 -DARDUINO_SAMD_ZERO -DARDUINO_ARCH_SAMD -D__SAMD21G18A__ -DUSB_VID=0x2341 -DUSB_PID=0x804d -DUSBCON "-DUSB_MANUFACTURER=\"Arduino LLC\"" "-DUSB_PRODUCT=\"Arduino Zero\"" -I/Users/myUserName/Library/Arduino15/packages/arduino/tools/CMSIS/4.5.0/CMSIS/Include/ -I/Users/myUserName/Library/Arduino15/packages/arduino/tools/CMSIS-Atmel/1.2.0/CMSIS/Device/ATMEL/ -I/Users/myUserName/Library/Arduino15/packages/arduino/hardware/samd/1.8.6/cores/arduino -I/Users/myUserName/Library/Arduino15/packages/arduino/hardware/samd/1.8.6/variants/arduino_zero -I/Users/myUserName/Documents/Arduino/libraries/SmartEink_Arduino_Library -I/Users/myUserName/Library/Arduino15/packages/arduino/hardware/samd/1.8.6/libraries/SPI /Users/myUserName/Documents/Arduino/libraries/SmartEink_Arduino_Library/SmartEink.cpp -o /var/folders/vp/7hc1s72n3tg7w21wmk28d7hc0000gn/T/arduino_build_915750/libraries/SmartEink_Arduino_Library/SmartEink.cpp.o
In file included from /Users/myUserName/Documents/Arduino/libraries/SmartEink_Arduino_Library/SmartEink.cpp:23:0:
/Users/myUserName/Documents/Arduino/libraries/SmartEink_Arduino_Library/SmartEink.cpp: In member function 'void E_ink::WriteComm(unsigned char)':
/Users/myUserName/Documents/Arduino/libraries/SmartEink_Arduino_Library/SmartEink.h:52:24: error: 'DDRD' was not declared in this scope
 #define Eink_CS1_HIGH {DDRD |= 0x40;PORTD |=  0x40;}
                        ^
/Users/myUserName/Documents/Arduino/libraries/SmartEink_Arduino_Library/SmartEink.cpp:322:3: note: in expansion of macro 'Eink_CS1_HIGH'
   Eink_CS1_HIGH;
   ^~~~~~~~~~~~~
/Users/myUserName/Documents/Arduino/libraries/SmartEink_Arduino_Library/SmartEink.h:52:37: error: 'PORTD' was not declared in this scope
 #define Eink_CS1_HIGH {DDRD |= 0x40;PORTD |=  0x40;}
                                     ^
/Users/myUserName/Documents/Arduino/libraries/SmartEink_Arduino_Library/SmartEink.cpp:322:3: note: in expansion of macro 'Eink_CS1_HIGH'
   Eink_CS1_HIGH;
   ^~~~~~~~~~~~~
/Users/myUserName/Documents/Arduino/libraries/SmartEink_Arduino_Library/SmartEink.h:52:37: note: suggested alternative: 'PORTC'
 #define Eink_CS1_HIGH {DDRD |= 0x40;PORTD |=  0x40;}
                                     ^
/Users/myUserName/Documents/Arduino/libraries/SmartEink_Arduino_Library/SmartEink.cpp:322:3: note: in expansion of macro 'Eink_CS1_HIGH'
   Eink_CS1_HIGH;
   ^~~~~~~~~~~~~


REPEATS WITH MINOR VARIATIONS


/Users/myUserName/Documents/Arduino/libraries/SmartEink_Arduino_Library/SmartEink.cpp: In member function 'void E_ink::ConverCharMatrixData()':
/Users/myUserName/Documents/Arduino/libraries/SmartEink_Arduino_Library/SmartEink.cpp:397:11: warning: unused variable 'j' [-Wunused-variable]
   INT8U i,j,m;


Using library SmartEink_Arduino_Library in folder: /Users/myUserName/Documents/Arduino/libraries/SmartEink_Arduino_Library (legacy)
Using library SPI at version 1.0 in folder: /Users/myUserName/Library/Arduino15/packages/arduino/hardware/samd/1.8.6/libraries/SPI
exit status 1
Error compiling for board Arduino Zero (Native USB Port).

westfw

I suggest you try it using normal digitalWrite and pinmode calls for the cs pins.

david_prentice

Edit the H file to provide suitable conditional macros  for CS1 and DC

Connect SDA, SCL pins to the MOSI, SCK on the 3x2 SPI header.


I am a little wary of the wiring in the manual.   BS1, RES are not handled by the library.   BS1 seems to be handled in the sketch.   But nothing for RESET

If you are prepared to test the code,  we could show you what to do.
As westw has suggested,  just use pinMode() and digitalWrite()


David.

westfw

It's a crappy library.  It should run fine on an Uno and leave plenty of memory free, except that it has a large font table that it doesn't use PROGMEM for (and a less obvious 200 byte private array that looks like it could be shorter.)

And, it's pretty easy to move to SAMD.

Try the attached version.
  • Add PROGMEM for font and initialization data.
  • add SAMD support with digitalWrite() for CS and DC.
  • initializes pinMode in initEink instead of every time a byte is written.

futurebirdagain

Thank you so much westfw. Are these changes that I need to make to the lib that you posted? or are they additional changes that could make it even better?

Go Up