hanyazou / BMI160-Arduino

76 stars 35 forks source link

public member BMI160.getMotionDetectionThreshold() fails compile with 'is private within this context' #17

Open awardblvr opened 1 year ago

awardblvr commented 1 year ago

Using getMotionDetectionThreshold() thusly:

    BMI160.begin(BMI160GenClass::I2C_MODE, I2C_ADDR_ACCEL_BMI160, ACCEL_INT_1_PIN);
   ...
    Serial.print(", MotionDetectionThreshold:");
    Serial.print(BMI160.getMotionDetectionThreshold());
   ...
    Serial.println();

I get

Compiling sketch...
/Users/myself/Library/Arduino15/packages/esp32/tools/xtensa-esp32s2-elf-gcc/gcc8_4_0-esp-2021r2-patch3/bin/xtensa-esp32s2-elf-g++ -DHAVE_CONFIG_H "-DMBEDTLS_CONFIG_FILE=\"mbedtls/esp_config.h\"" -DUNITY_INCLUDE_CONFIG_H -DWITH_POSIX -D_GNU_SOURCE "-DIDF_VER=\"v4.4.2\"" -DESP_PLATFORM -D_POSIX_READER_WRITER_LOCKS -I/Users/myself/Library/Arduino15/packages/esp32/hardware/esp32/2.0.5/tools/sdk/esp32s2/include/newlib/platform_include ... intermediates removed ...
/var/folders/hm/p5fl5cc15l581lpldm56101m0000gn/T/arduino_build_157280/sketch/project_xxy.ino.cpp -o /var/folders/hm/p5fl5cc15l581lpldm56101m0000gn/T/arduino_build_157280/sketch/project_xxy.ino.cpp.o
/Users/myself/Documents/ESP32/project_xxy/project_xxy.ino: In function 'void setup()':
project_xxy:535:53: error: 'float CurieIMUClass::getMotionDetectionThreshold()' is private within this context
     Serial.print(BMI160.getMotionDetectionThreshold());
                                                     ^
In file included from /Users/myself/Documents/Arduino/libraries/BMI160-Arduino/BMI160Gen.h:5,
                 from /Users/myself/Documents/ESP32/project_xxy/project_xxy.ino:29:
/Users/myself/Documents/Arduino/libraries/BMI160-Arduino/CurieIMU.h:217:15: note: declared private here
         float getMotionDetectionThreshold();
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~

I found by editing the copyrighted file .../Arduino/libraries/BMI160-Arduino/CurieIMU.h and moving those function declarations from the private: section to the public: section, resolves the issue... (But, they are already public in BMI160.h! ) So.. Not sure how the inheritance thing is working on this.. But it NEEDS to be fixed. (please)