Page 1 of 1

Problem with Adafruit_AMG88xx.h library

Posted: 05 Apr 2020 22:46
by Miklux
Hi all,
I'm trying to compile a little sketch with my ZUno device.
I want to use the Adafruit_AMG88xx.h library but it gives me an error.

The sketch is this one:

Code: Select all

#include <Adafruit_AMG88xx.h>
#include <Wire.h>

#define MAP_TO_ZEROCHANNEL 0x80
ZUNO_SETUP_PRODUCT_ID(0xAB, 0xCD);
ZUNO_ENABLE(WITH_CC_SENSOR_MULTILEVEL);
ZUNO_DYNAMIC_CHANNELS(3);

byte nIngressi;
byte nUscite;
byte nPresenze;


void setup() {
  Serial.begin(115200);
  nIngressi = 0;
  nUscite = 0;
  nPresenze = 0;
  ZUNO_START_CONFIG();
  ZUNO_SET_ZWCHANNEL(1| MAP_TO_ZEROCHANNEL); // <- this channel will be provided via 1 & 0 channels
  ZUNO_ADD_CHANNEL(ZUNO_SENSOR_MULTILEVEL_CHANNEL_NUMBER, ZUNO_SENSOR_MULTILEVEL_TYPE_GENERAL_PURPOSE_VALUE, SENSOR_MULTILEVEL_PROPERTIES_COMBINER( SENSOR_MULTILEVEL_SCALE_LOCAL, SENSOR_MULTILEVEL_SIZE_ONE_BYTE, SENSOR_MULTILEVEL_PRECISION_ZERO_DECIMALS));
  ZUNO_SET_ZWCHANNEL(2);
  ZUNO_ADD_CHANNEL(ZUNO_SENSOR_MULTILEVEL_CHANNEL_NUMBER, ZUNO_SENSOR_MULTILEVEL_TYPE_GENERAL_PURPOSE_VALUE, SENSOR_MULTILEVEL_PROPERTIES_COMBINER( SENSOR_MULTILEVEL_SCALE_LOCAL, SENSOR_MULTILEVEL_SIZE_ONE_BYTE, SENSOR_MULTILEVEL_PRECISION_ZERO_DECIMALS));
  ZUNO_SET_ZWCHANNEL(3);
  ZUNO_ADD_CHANNEL(ZUNO_SENSOR_MULTILEVEL_CHANNEL_NUMBER, ZUNO_SENSOR_MULTILEVEL_TYPE_GENERAL_PURPOSE_VALUE, SENSOR_MULTILEVEL_PROPERTIES_COMBINER( SENSOR_MULTILEVEL_SCALE_LOCAL, SENSOR_MULTILEVEL_SIZE_ONE_BYTE, SENSOR_MULTILEVEL_PRECISION_ZERO_DECIMALS));
  ZUNO_COMMIT_CONFIG();
}

void loop() {
  byte selection=0;
  if (Serial.available() > 0) {
    // read the incoming byte:
    selection = Serial.read();
    switch(selection) {
    case '0':
      nIngressi++;
      g_channels_data[0].bParam = nIngressi;
      break;
    case '1':
      nUscite++;
      g_channels_data[1].bParam = nUscite;
      break;
    default:
      break;   
    }
    nPresenze=nIngressi-nUscite;
    if(nPresenze<0) nPresenze=0;
    g_channels_data[2].bParam = nPresenze;
    Serial.println(nPresenze);
  }
  //delay(30000); 
}
All is ok if I compile without the Adafruit_AMG88xx library , but with it i receive this:

Code: Select all

Arduino:1.8.12 (Windows 10), Scheda:"Z-Wave>ME Z-Uno, Europe, Disabled, Disabled, Disabled, Disabled"

C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\Michele\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\Michele\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Michele\Documents\Arduino\libraries -fqbn=Z-Uno:zw8051:zuno:Frequency=Eu,Security=Off,MuliCommand=Off,LogOutput=Off,NVMClean=Off -ide-version=10812 -build-path C:\Users\Michele\AppData\Local\Temp\arduino_build_539636 -warnings=none -build-cache C:\Users\Michele\AppData\Local\Temp\arduino_cache_77333 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.zuno_toolchain.path=C:\Users\Michele\AppData\Local\Arduino15\packages\Z-Uno\tools\zuno_toolchain\00.08.80 -prefs=runtime.tools.zuno_toolchain-00.08.80.path=C:\Users\Michele\AppData\Local\Arduino15\packages\Z-Uno\tools\zuno_toolchain\00.08.80 -verbose C:\Users\Michele\Documents\Arduino\zWave_SD_IR_ARRAY_COUNTER_NO_STRING_280519\zWave_SD_IR_ARRAY_COUNTER_NO_STRING_280519\zWave_SD_IR_ARRAY_COUNTER_NO_STRING_280519.ino
C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\Michele\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\Michele\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Michele\Documents\Arduino\libraries -fqbn=Z-Uno:zw8051:zuno:Frequency=Eu,Security=Off,MuliCommand=Off,LogOutput=Off,NVMClean=Off -ide-version=10812 -build-path C:\Users\Michele\AppData\Local\Temp\arduino_build_539636 -warnings=none -build-cache C:\Users\Michele\AppData\Local\Temp\arduino_cache_77333 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.zuno_toolchain.path=C:\Users\Michele\AppData\Local\Arduino15\packages\Z-Uno\tools\zuno_toolchain\00.08.80 -prefs=runtime.tools.zuno_toolchain-00.08.80.path=C:\Users\Michele\AppData\Local\Arduino15\packages\Z-Uno\tools\zuno_toolchain\00.08.80 -verbose C:\Users\Michele\Documents\Arduino\zWave_SD_IR_ARRAY_COUNTER_NO_STRING_280519\zWave_SD_IR_ARRAY_COUNTER_NO_STRING_280519\zWave_SD_IR_ARRAY_COUNTER_NO_STRING_280519.ino
Using board 'zuno' from platform in folder: C:\Users\Michele\AppData\Local\Arduino15\packages\Z-Uno\hardware\zw8051\2.1.5
Using core 'zuno' from platform in folder: C:\Users\Michele\AppData\Local\Arduino15\packages\Z-Uno\hardware\zw8051\2.1.5
Detecting libraries used...
"C:\\Users\\Michele\\AppData\\Local\\Arduino15\\packages\\Z-Uno\\tools\\zuno_toolchain\\00.08.80/zuno_toolchain/compiler" arduino_preproc "C:\\Users\\Michele\\AppData\\Local\\Temp\\arduino_build_539636\\sketch\\zWave_SD_IR_ARRAY_COUNTER_NO_STRING_280519.ino.cpp" -r "C:\\Users\\Michele\\AppData\\Local\\Arduino15\\packages\\Z-Uno\\hardware\\zw8051\\2.1.5"
C:\Users\Michele\AppData\Local\Temp\arduino_build_539636

Found 1.8.x project structure (File:zWave_SD_IR_ARRAY_COUNTER_NO_STRING_280519.ino.cpp). Converting it...

           

Generating function prototypes...
"C:\\Users\\Michele\\AppData\\Local\\Arduino15\\packages\\Z-Uno\\tools\\zuno_toolchain\\00.08.80/zuno_toolchain/compiler" arduino_preproc "C:\\Users\\Michele\\AppData\\Local\\Temp\\arduino_build_539636\\sketch\\zWave_SD_IR_ARRAY_COUNTER_NO_STRING_280519.ino.cpp" -r "C:\\Users\\Michele\\AppData\\Local\\Arduino15\\packages\\Z-Uno\\hardware\\zw8051\\2.1.5"
C:\Users\Michele\AppData\Local\Temp\arduino_build_539636

Found 1.8.x project structure (File:zWave_SD_IR_ARRAY_COUNTER_NO_STRING_280519.ino.cpp). Converting it...         

"C:\\Program Files (x86)\\Arduino\\tools-builder\\ctags\\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\\Users\\Michele\\AppData\\Local\\Temp\\arduino_build_539636\\preproc\\ctags_target_for_gcc_minus_e.cpp"
Sto compilando lo sketch...
"C:\\Users\\Michele\\AppData\\Local\\Arduino15\\packages\\Z-Uno\\tools\\zuno_toolchain\\00.08.80/zuno_toolchain/compiler" build "C:\\Users\\Michele\\AppData\\Local\\Temp\\arduino_build_539636/zWave_SD_IR_ARRAY_COUNTER_NO_STRING_280519.ino" -r "C:\\Users\\Michele\\AppData\\Local\\Arduino15\\packages\\Z-Uno\\hardware\\zw8051\\2.1.5" -i1_8 -idv 10812


	************* Building Arduino Sketch *************

	C:\Users\Michele\AppData\Local\Temp\arduino_build_539636/zWave_SD_IR_ARRAY_COUNTER_NO_STRING_280519.ino

	***************************************************



	 --- USING a list of libraries from:

		C:\Users\Michele\AppData\Local\Arduino15\packages\Z-Uno\hardware\zw8051\2.1.5\libraries

		C:\Users\Michele\Documents\Arduino\libraries

	*** Collecting prototypes...

Preprocessing file: C:\Users\Michele\AppData\Local\Temp\arduino_build_539636\Custom.c with SDCPP... 

Preprocessing file: C:\Users\Michele\AppData\Local\Temp\arduino_build_539636\Print.cpp with SDCPP... 

Compiling C:\Users\Michele\AppData\Local\Temp\arduino_build_539636\Print_sdcpp_.cpp ...

Preprocessing file: C:\Users\Michele\AppData\Local\Temp\arduino_build_539636\Stream.cpp with SDCPP... 

Compiling C:\Users\Michele\AppData\Local\Temp\arduino_build_539636\Stream_sdcpp_.cpp ...

Preprocessing file: C:\Users\Michele\AppData\Local\Temp\arduino_build_539636\HardwareSerial.cpp with SDCPP... 

Compiling C:\Users\Michele\AppData\Local\Temp\arduino_build_539636\HardwareSerial_sdcpp_.cpp ...

Preprocessing file: C:\Users\Michele\AppData\Local\Temp\arduino_build_539636\HLCore.cpp with SDCPP... 

Compiling C:\Users\Michele\AppData\Local\Temp\arduino_build_539636\HLCore_sdcpp_.cpp ...

Preprocessing file: C:\Users\Michele\AppData\Local\Temp\arduino_build_539636\Wire.cpp with SDCPP... 

Compiling C:\Users\Michele\AppData\Local\Temp\arduino_build_539636\Wire_sdcpp_.cpp ...

Preprocessing file: C:\Users\Michele\AppData\Local\Temp\arduino_build_539636\Adafruit_AMG88xx.cpp with SDCPP... 

In file included from C:\Users\Michele\AppData\Local\Temp\arduino_build_539636\Adafruit_AMG88xx.cpp:1:

C:\Users\Michele\AppData\Local\Temp\arduino_build_539636\/Adafruit_AMG88xx.h:7:23: fatal error: WProgram.h: No such file or directory

compilation terminated.

Preprocessor failed!uCxx returned error code:1

exit status 1
Errore durante la compilazione per la scheda Z-Wave>ME Z-Uno.

Please, can you help me?
Thanks in aadvance
Mik

Re: Problem with Adafruit_AMG88xx.h library

Posted: 08 Apr 2020 15:26
by p0lyg0n1
Hi,
The main problem is that Adafruit library was written for AVR microprocessors. Z-Uno uses power efficient, but very old factory standard i8051 core. To get library to work with Z-Uno you have to port library according to Z-Uno limitations in stack and inner compiler limitations. Z-Uno has only 120-140 bytes of stack, its compiler couldn't use references, big local variables, C++ templates & etc.
To port library you have to understand the main principles of device (AMG88), you have to understand all the the Adafruit code. It's not just place it to your folder & recompile. Sometimes it's easier to rewrite library yourself than port it. You can compare some already ported libraries to understand main techniques of stack usage reduction: see our GitHub: https://github.com/Z-Wave-Me/Z-Uno-Core ... /libraries
Good luck!
Yours,
Alex.

Re: Problem with Adafruit_AMG88xx.h library

Posted: 20 Apr 2020 14:51
by Miklux
Sorry for the late answer,

thank you, I resolved creating my own library. :mrgreen:

Re: Problem with Adafruit_AMG88xx.h library

Posted: 27 Apr 2020 03:37
by PoltoS
Great job!