olikraus / u8g2

U8glib library for monochrome displays, version 2
Other
4.91k stars 1.03k forks source link

'SDA1' undeclared #2400

Closed o7-machinehum closed 3 months ago

o7-machinehum commented 3 months ago

I'm having an issues with compilation, for some reason U8x8lib.cpp is including Wire1.

pio run -e target
Processing target (platform: atmelavr; board: ATmega1284P; framework: arduino)
----------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/ATmega1284P.html
PLATFORM: Atmel AVR (5.0.0) > ATmega1284P
HARDWARE: ATMEGA1284P 16MHz, 16KB RAM, 128KB Flash
DEBUG: Current (simavr) External (simavr)
PACKAGES: 
 - framework-arduino-avr-mightycore @ 3.0.0 
 - toolchain-atmelavr @ 1.70300.191015 (7.3.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 20 compatible libraries
Scanning dependencies...
Dependency Graph
|-- EthernetENC @ 2.0.4
|-- U8g2 @ 2.35.9
|-- SPI @ 1.0
|-- Wire @ 1.1
|-- ArduinoJson @ 7.0.4
|-- Watchdog @ 3.0.2
|-- EEPROM @ 2.0
|-- CRC32 @ 2.0.0
|-- ArduinoModbus @ 1.0.9
|-- se-lib-cpp
|-- ArduinoRS485 @ 1.0.5
Building in release mode
Archiving .pio/build/target/lib3a1/libEthernetENC.a
Archiving .pio/build/target/lib458/libWire.a
Compiling .pio/build/target/lib89b/Wire1/Wire1.cpp.o
Compiling .pio/build/target/lib89b/Wire1/utility/twi1.c.o
Compiling .pio/build/target/libd46/U8g2/clib/mui_u8g2.c.o
Compiling .pio/build/target/libd46/U8g2/clib/u8g2_arc.c.o
Compiling .pio/build/target/libd46/U8g2/clib/u8g2_bitmap.c.o
Indexing .pio/build/target/lib3a1/libEthernetENC.a
Indexing .pio/build/target/lib458/libWire.a
Compiling .pio/build/target/libd46/U8g2/clib/u8g2_box.c.o
Compiling .pio/build/target/libd46/U8g2/clib/u8g2_buffer.c.o
Compiling .pio/build/target/libd46/U8g2/clib/u8g2_button.c.o
Compiling .pio/build/target/libd46/U8g2/clib/u8g2_circle.c.o
Compiling .pio/build/target/libd46/U8g2/clib/u8g2_cleardisplay.c.o
Compiling .pio/build/target/libd46/U8g2/clib/u8g2_d_memory.c.o
Compiling .pio/build/target/libd46/U8g2/clib/u8g2_d_setup.c.o
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c: In function 'twi_init1':
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:89:16: error: 'SDA1' undeclared (first use in this function); did you mean 'SDA'?
   digitalWrite(SDA1, 1);
                ^~~~
                SDA
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:89:16: note: each undeclared identifier is reported only once for each function it appears in
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:90:16: error: 'SCL1' undeclared (first use in this function); did you mean 'SCL'?
   digitalWrite(SCL1, 1);
                ^~~~
                SCL
In file included from /Users/machinehum/.platformio/packages/toolchain-atmelavr/avr/include/avr/io.h:99:0,
                 from /Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:26:
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:93:7: error: 'TWSR1' undeclared (first use in this function); did you mean 'TWSR'?
   cbi(TWSR1, TWPS0);
       ^
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:93:3: note: in expansion of macro 'cbi'
   cbi(TWSR1, TWPS0);
   ^~~
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:95:9: error: lvalue required as left operand of assignment
   TWBR1 = ((F_CPU / TWI_FREQ) - 16) / 2;
         ^
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:103:3: error: 'TWCR1' undeclared (first use in this function); did you mean 'TWSR1'?
   TWCR1 = _BV(TWEN) | _BV(TWIE) | _BV(TWEA);
   ^~~~~
   TWSR1
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c: In function 'twi_disable1':
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:115:3: error: 'TWCR1' undeclared (first use in this function); did you mean 'TWCR'?
   TWCR1 &= ~(_BV(TWEN) | _BV(TWIE) | _BV(TWEA));
   ^~~~~
   TWCR
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:118:16: error: 'SDA1' undeclared (first use in this function); did you mean 'SDA'?
   digitalWrite(SDA1, 0);
                ^~~~
                SDA
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:119:16: error: 'SCL1' undeclared (first use in this function); did you mean 'SCL'?
   digitalWrite(SCL1, 0);
                ^~~~
                SCL
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c: In function 'twi_setAddress1':
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:131:3: error: 'TWAR1' undeclared (first use in this function); did you mean 'TWA1'?
   TWAR1 = address << 1;
   ^~~~~
   TWA1
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c: In function 'twi_setFrequency1':
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:142:9: error: lvalue required as left operand of assignment
   TWBR1 = ((F_CPU / frequency) - 16) / 2;
         ^
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c: In function 'twi_readFrom1':
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:219:9: error: 'TWDR1' undeclared (first use in this function); did you mean 'TWD1'?
         TWDR1 = twi_slarw;
         ^~~~~
         TWD1
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:220:15: error: 'TWCR1' undeclared (first use in this function); did you mean 'TWDR1'?
       } while(TWCR1 & _BV(TWWC));
               ^~~~~
               TWDR1
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c: In function 'twi_writeTo1':
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:322:9: error: 'TWDR1' undeclared (first use in this function); did you mean 'TWD1'?
         TWDR1 = twi_slarw;
         ^~~~~
         TWD1
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:323:15: error: 'TWCR1' undeclared (first use in this function); did you mean 'TWDR1'?
       } while(TWCR1 & _BV(TWWC));
               ^~~~~
               TWDR1
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c: In function 'twi_reply1':
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:421:5: error: 'TWCR1' undeclared (first use in this function); did you mean 'TWCR'?
     TWCR1 = _BV(TWEN) | _BV(TWIE) | _BV(TWINT) | _BV(TWEA);
     ^~~~~
     TWCR
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c: In function 'twi_stop1':
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:436:3: error: 'TWCR1' undeclared (first use in this function); did you mean 'TWCR'?
   TWCR1 = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTO);
   ^~~~~
   TWCR
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c: In function 'twi_releaseBus1':
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:474:3: error: 'TWCR1' undeclared (first use in this function); did you mean 'TWCR'?
   TWCR1 = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT);
   ^~~~~
   TWCR
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c: In function 'twi_handleTimeout1':
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:506:29: error: 'TWAR1' undeclared (first use in this function); did you mean 'TWA1'?
     uint8_t previous_TWAR = TWAR1;
                             ^~~~~
                             TWA1
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:514:11: error: lvalue required as left operand of assignment
     TWBR1 = previous_TWBR;
           ^
In file included from /Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:27:0:
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c: In function 'TWI1_vect':
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:533:5: warning: 'TWI1_vect' appears to be a misspelled 'signal' handler, missing '__vector' prefix [-Wmisspelled-isr]
 ISR(TWI1_vect)
     ^
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:536:10: error: 'TWSR1' undeclared (first use in this function); did you mean 'TWSR'?
   switch(TWSR1 & TW_STATUS_MASK){
          ^~~~~
          TWSR
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:541:7: error: 'TWDR1' undeclared (first use in this function); did you mean 'TWSR1'?
       TWDR1 = twi_slarw;
       ^~~~~
       TWSR1
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:561:5: error: 'TWCR1' undeclared (first use in this function); did you mean 'TWDR1'?
     TWCR1 = _BV(TWINT) | _BV(TWSTA)| _BV(TWEN) ;
     ^~~~~
     TWDR1
*** [.pio/build/target/lib89b/Wire1/utility/twi1.c.o] Error 1
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/Wire1.cpp: In lambda function:
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/Wire1.cpp:24:56: error: 'static void TwoWire::onReceiveService(uint8_t*, int)' is private within this context
                         [](uint8_t* v, int len){ Wire1.onReceiveService(v, len); },
                                                        ^~~~~~~~~~~~~~~~
In file included from /Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/Wire1.h:4:0,
                 from /Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/Wire1.cpp:5:
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire/src/Wire.h:52:17: note: declared private here
     static void onReceiveService(uint8_t*, int);
                 ^~~~~~~~~~~~~~~~
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/Wire1.cpp:24:79: error: 'static void TwoWire::onReceiveService(uint8_t*, int)' is private within this context
                         [](uint8_t* v, int len){ Wire1.onReceiveService(v, len); },
                                                                               ^
In file included from /Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/Wire1.h:4:0,
                 from /Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/Wire1.cpp:5:
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire/src/Wire.h:52:17: note: declared private here
     static void onReceiveService(uint8_t*, int);
                 ^~~~~~~~~~~~~~~~
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/Wire1.cpp: In lambda function:
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/Wire1.cpp:26:37: error: 'static void TwoWire::onRequestService()' is private within this context
                         [](){ Wire1.onRequestService(); });
                                     ^~~~~~~~~~~~~~~~
In file included from /Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/Wire1.h:4:0,
                 from /Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/Wire1.cpp:5:
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire/src/Wire.h:51:17: note: declared private here
     static void onRequestService(void);
                 ^~~~~~~~~~~~~~~~
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/Wire1.cpp:26:54: error: 'static void TwoWire::onRequestService()' is private within this context
                         [](){ Wire1.onRequestService(); });
                                                      ^
In file included from /Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/Wire1.h:4:0,
                 from /Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/Wire1.cpp:5:
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire/src/Wire.h:51:17: note: declared private here
     static void onRequestService(void);
                 ^~~~~~~~~~~~~~~~
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/Wire1.cpp: At global scope:
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/Wire1.cpp:26:58: error: no matching function for call to 'TwoWire::TwoWire(int, void (&)(), void (&)(), void (&)(uint8_t), void (&)(uint32_t), uint8_t (&)(uint8_t, uint8_t*, uint8_t, uint8_t), uint8_t (&)(uint8_t, uint8_t*, uint8_t, uint8_t, uint8_t), uint8_t (&)(const uint8_t*, uint8_t), void (&)(uint8_t), void (&)(), void (&)(), void (&)(void (*)(uint8_t*, int)), <lambda(uint8_t*, int)>, void (&)(void (*)()), <lambda()>)'
                         [](){ Wire1.onRequestService(); });
                                                          ^
In file included from /Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/Wire1.h:4:0,
                 from /Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/Wire1.cpp:5:
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire/src/Wire.h:54:5: note: candidate: TwoWire::TwoWire()
     TwoWire();
     ^~~~~~~
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire/src/Wire.h:54:5: note:   candidate expects 0 arguments, 15 provided
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire/src/Wire.h:36:7: note: candidate: constexpr TwoWire::TwoWire(const TwoWire&)
 class TwoWire : public Stream
       ^~~~~~~
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire/src/Wire.h:36:7: note:   candidate expects 1 argument, 15 provided
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire/src/Wire.h:36:7: note: candidate: constexpr TwoWire::TwoWire(TwoWire&&)
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire/src/Wire.h:36:7: note:   candidate expects 1 argument, 15 provided
*** [.pio/build/target/lib89b/Wire1/Wire1.cpp.o] Error 1
=============================================================== [FAILED] Took 1.16 seconds ===============================================================

Environment    Status    Duration
-------------  --------  ------------
target         FAILED    00:00:01.158
========================================================= 1 failed, 0 succeeded in 00:00:01.158 =========================================================
make: *** [all] Error 1

If I make this change to .pio/libdeps/target/U8g2/src/U8x8lib.cpp, things compile.

#ifdef U8X8_HAVE_HW_I2C
#  ifdef U8X8_HAVE_HW_I2C_TEENSY3
#    include <i2c_t3.h>
#  else
#    include <Wire.h>
#    ifdef U8X8_HAVE_2ND_HW_I2C
#      if defined(MINICORE) && defined(__AVR_ATmega328PB__)
// #        include <Wire1.h>
#      endif
#    endif
#  endif
#endif /* U8X8_HAVE_HW_I2C */

#endif /* ARDUINO */ 

That being said, I have no idea where U8X8_HAVE_2ND_HW_I2C, __AVR_ATmega328PB__ or MINICORE are being set. I'm at a bit of a loss with that.

[env:target]
platform = atmelavr
board = ATmega1284P
board_build.f_cpu =  16000000L
board_build.variant = standard
monitor_speed = 9600
board_upload.speed = 115200
; platform_packages = platformio/framework-arduino-avr-mightycore@^2.2.2
build_flags = -Wall -DUIP_CONNECT_TIMEOUT=1 -DUIP_WRITE_TIMEOUT=500 -DUIPETHERNET_DEBUG_CLIENT=1

framework = arduino
build_type = release 
check_tool = cppcheck, clangtidy
test_ignore = test_app, test_service
lib_deps = 
    jandrassy/EthernetENC@^2.0.4
    olikraus/U8g2@^2.35.9
    SPI
    Wire
    ArduinoJson
    janelia-arduino/Watchdog@^3.0.0
    EEPROM
    CRC32
    ArduinoModbus
o7-machinehum commented 3 months ago

Here is an very basic broken project

machinehum@Walkers-MBP test % pio run
Processing ATmega1284P (platform: atmelavr; board: ATmega1284P; framework: arduino)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/ATmega1284P.html
PLATFORM: Atmel AVR (5.0.0) > ATmega1284P
HARDWARE: ATMEGA1284P 16MHz, 16KB RAM, 128KB Flash
DEBUG: Current (simavr) External (simavr)
PACKAGES: 
 - framework-arduino-avr-mightycore @ 3.0.0 
 - toolchain-atmelavr @ 1.70300.191015 (7.3.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 12 compatible libraries
Scanning dependencies...
Dependency Graph
|-- U8g2 @ 2.35.9
|-- Wire @ 1.1
Building in release mode
Archiving .pio/build/ATmega1284P/lib2e6/libSPI.a
Archiving .pio/build/ATmega1284P/lib458/libWire.a
Compiling .pio/build/ATmega1284P/lib89b/Wire1/Wire1.cpp.o
Compiling .pio/build/ATmega1284P/lib89b/Wire1/utility/twi1.c.o
Compiling .pio/build/ATmega1284P/lib1c5/U8g2/clib/u8g2_box.c.o
Indexing .pio/build/ATmega1284P/lib2e6/libSPI.a
Indexing .pio/build/ATmega1284P/lib458/libWire.a
Compiling .pio/build/ATmega1284P/lib1c5/U8g2/clib/u8g2_buffer.c.o
Compiling .pio/build/ATmega1284P/lib1c5/U8g2/clib/u8g2_button.c.o
Compiling .pio/build/ATmega1284P/lib1c5/U8g2/clib/u8g2_circle.c.o
Compiling .pio/build/ATmega1284P/lib1c5/U8g2/clib/u8g2_cleardisplay.c.o
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/Wire1.cpp: In lambda function:
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/Wire1.cpp:24:56: error: 'static void TwoWire::onReceiveService(uint8_t*, int)' is private within this context
                         [](uint8_t* v, int len){ Wire1.onReceiveService(v, len); },
                                                        ^~~~~~~~~~~~~~~~
In file included from /Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/Wire1.h:4:0,
                 from /Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/Wire1.cpp:5:
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire/src/Wire.h:52:17: note: declared private here
     static void onReceiveService(uint8_t*, int);
                 ^~~~~~~~~~~~~~~~
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/Wire1.cpp:24:79: error: 'static void TwoWire::onReceiveService(uint8_t*, int)' is private within this context
                         [](uint8_t* v, int len){ Wire1.onReceiveService(v, len); },
                                                                               ^
In file included from /Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/Wire1.h:4:0,
                 from /Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/Wire1.cpp:5:
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire/src/Wire.h:52:17: note: declared private here
     static void onReceiveService(uint8_t*, int);
                 ^~~~~~~~~~~~~~~~
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/Wire1.cpp: In lambda function:
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/Wire1.cpp:26:37: error: 'static void TwoWire::onRequestService()' is private within this context
                         [](){ Wire1.onRequestService(); });
                                     ^~~~~~~~~~~~~~~~
In file included from /Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/Wire1.h:4:0,
Compiling .pio/build/ATmega1284P/lib1c5/U8g2/clib/u8g2_d_memory.c.o
                 from /Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/Wire1.cpp:5:
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire/src/Wire.h:51:17: note: declared private here
     static void onRequestService(void);
                 ^~~~~~~~~~~~~~~~
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/Wire1.cpp:26:54: error: 'static void TwoWire::onRequestService()' is private within this context
                         [](){ Wire1.onRequestService(); });
                                                      ^
In file included from /Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/Wire1.h:4:0,
                 from /Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/Wire1.cpp:5:
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire/src/Wire.h:51:17: note: declared private here
     static void onRequestService(void);
                 ^~~~~~~~~~~~~~~~
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/Wire1.cpp: At global scope:
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/Wire1.cpp:26:58: error: no matching function for call to 'TwoWire::TwoWire(int, void (&)(), void (&)(), void (&)(uint8_t), void (&)(uint32_t), uint8_t (&)(uint8_t, uint8_t*, uint8_t, uint8_t), uint8_t (&)(uint8_t, uint8_t*, uint8_t, uint8_t, uint8_t), uint8_t (&)(const uint8_t*, uint8_t), void (&)(uint8_t), void (&)(), void (&)(), void (&)(void (*)(uint8_t*, int)), <lambda(uint8_t*, int)>, void (&)(void (*)()), <lambda()>)'
                         [](){ Wire1.onRequestService(); });
                                                          ^
In file included from /Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/Wire1.h:4:0,
                 from /Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/Wire1.cpp:5:
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire/src/Wire.h:54:5: note: candidate: TwoWire::TwoWire()
     TwoWire();
     ^~~~~~~
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire/src/Wire.h:54:5: note:   candidate expects 0 arguments, 15 provided
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire/src/Wire.h:36:7: note: candidate: constexpr TwoWire::TwoWire(const TwoWire&)
 class TwoWire : public Stream
       ^~~~~~~
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire/src/Wire.h:36:7: note:   candidate expects 1 argument, 15 provided
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire/src/Wire.h:36:7: note: candidate: constexpr TwoWire::TwoWire(TwoWire&&)
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire/src/Wire.h:36:7: note:   candidate expects 1 argument, 15 provided
Compiling .pio/build/ATmega1284P/lib1c5/U8g2/clib/u8g2_d_setup.c.o
*** [.pio/build/ATmega1284P/lib89b/Wire1/Wire1.cpp.o] Error 1
Compiling .pio/build/ATmega1284P/lib1c5/U8g2/clib/u8g2_font.c.o
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c: In function 'twi_init1':
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:89:16: error: 'SDA1' undeclared (first use in this function); did you mean 'SDA'?
   digitalWrite(SDA1, 1);
                ^~~~
                SDA
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:89:16: note: each undeclared identifier is reported only once for each function it appears in
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:90:16: error: 'SCL1' undeclared (first use in this function); did you mean 'SCL'?
   digitalWrite(SCL1, 1);
                ^~~~
                SCL
In file included from /Users/machinehum/.platformio/packages/toolchain-atmelavr/avr/include/avr/io.h:99:0,
                 from /Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:26:
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:93:7: error: 'TWSR1' undeclared (first use in this function); did you mean 'TWSR'?
   cbi(TWSR1, TWPS0);
       ^
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:93:3: note: in expansion of macro 'cbi'
   cbi(TWSR1, TWPS0);
   ^~~
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:95:9: error: lvalue required as left operand of assignment
   TWBR1 = ((F_CPU / TWI_FREQ) - 16) / 2;
         ^
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:103:3: error: 'TWCR1' undeclared (first use in this function); did you mean 'TWSR1'?
   TWCR1 = _BV(TWEN) | _BV(TWIE) | _BV(TWEA);
   ^~~~~
   TWSR1
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c: In function 'twi_disable1':
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:115:3: error: 'TWCR1' undeclared (first use in this function); did you mean 'TWCR'?
   TWCR1 &= ~(_BV(TWEN) | _BV(TWIE) | _BV(TWEA));
   ^~~~~
   TWCR
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:118:16: error: 'SDA1' undeclared (first use in this function); did you mean 'SDA'?
   digitalWrite(SDA1, 0);
                ^~~~
                SDA
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:119:16: error: 'SCL1' undeclared (first use in this function); did you mean 'SCL'?
   digitalWrite(SCL1, 0);
                ^~~~
                SCL
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c: In function 'twi_setAddress1':
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:131:3: error: 'TWAR1' undeclared (first use in this function); did you mean 'TWA1'?
   TWAR1 = address << 1;
   ^~~~~
   TWA1
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c: In function 'twi_setFrequency1':
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:142:9: error: lvalue required as left operand of assignment
   TWBR1 = ((F_CPU / frequency) - 16) / 2;
         ^
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c: In function 'twi_readFrom1':
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:219:9: error: 'TWDR1' undeclared (first use in this function); did you mean 'TWD1'?
         TWDR1 = twi_slarw;
         ^~~~~
         TWD1
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:220:15: error: 'TWCR1' undeclared (first use in this function); did you mean 'TWDR1'?
       } while(TWCR1 & _BV(TWWC));
               ^~~~~
               TWDR1
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c: In function 'twi_writeTo1':
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:322:9: error: 'TWDR1' undeclared (first use in this function); did you mean 'TWD1'?
         TWDR1 = twi_slarw;
         ^~~~~
         TWD1
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:323:15: error: 'TWCR1' undeclared (first use in this function); did you mean 'TWDR1'?
       } while(TWCR1 & _BV(TWWC));
               ^~~~~
               TWDR1
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c: In function 'twi_reply1':
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:421:5: error: 'TWCR1' undeclared (first use in this function); did you mean 'TWCR'?
     TWCR1 = _BV(TWEN) | _BV(TWIE) | _BV(TWINT) | _BV(TWEA);
     ^~~~~
     TWCR
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c: In function 'twi_stop1':
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:436:3: error: 'TWCR1' undeclared (first use in this function); did you mean 'TWCR'?
   TWCR1 = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTO);
   ^~~~~
   TWCR
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c: In function 'twi_releaseBus1':
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:474:3: error: 'TWCR1' undeclared (first use in this function); did you mean 'TWCR'?
   TWCR1 = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT);
   ^~~~~
   TWCR
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c: In function 'twi_handleTimeout1':
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:506:29: error: 'TWAR1' undeclared (first use in this function); did you mean 'TWA1'?
     uint8_t previous_TWAR = TWAR1;
                             ^~~~~
                             TWA1
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:514:11: error: lvalue required as left operand of assignment
     TWBR1 = previous_TWBR;
           ^
In file included from /Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:27:0:
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c: In function 'TWI1_vect':
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:533:5: warning: 'TWI1_vect' appears to be a misspelled 'signal' handler, missing '__vector' prefix [-Wmisspelled-isr]
 ISR(TWI1_vect)
     ^
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:536:10: error: 'TWSR1' undeclared (first use in this function); did you mean 'TWSR'?
   switch(TWSR1 & TW_STATUS_MASK){
          ^~~~~
          TWSR
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:541:7: error: 'TWDR1' undeclared (first use in this function); did you mean 'TWSR1'?
       TWDR1 = twi_slarw;
       ^~~~~
       TWSR1
/Users/machinehum/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src/utility/twi1.c:561:5: error: 'TWCR1' undeclared (first use in this function); did you mean 'TWDR1'?
     TWCR1 = _BV(TWINT) | _BV(TWSTA)| _BV(TWEN) ;
     ^~~~~
     TWDR1
*** [.pio/build/ATmega1284P/lib89b/Wire1/utility/twi1.c.o] Error 1
===================================================================== [FAILED] Took 0.83 seconds =====================================================================
machinehum@Walkers-MBP test % 
o7-machinehum commented 3 months ago

FYI https://github.com/olikraus/u8g2/issues/2207

MCUdude commented 3 months ago

@olikraus The last version that works out of the box with MightyCore through PlatformIO is 2.34.5, the next version available in the PlatformIO registry is 2.34.18, and this version does not work, and has the same error as @o7-machinehum reported.

o7-machinehum commented 3 months ago

@olikraus The last version that works out of the box with MightyCore through PlatformIO is 2.34.5, the next version available in the PlatformIO registry is 2.34.18, and this version does not work, and has the same error as @o7-machinehum reported.

Yes that works thanks! I want to bisect up to where things stop working. Would you happen to know how versions are actually managed? There is only one tag in github.

MCUdude commented 3 months ago

I want to bisect up to where things stop working

I would like to know as well. But the Github tags/releases are not consistent, so keeping track of where or when the breaking change happended can be very time consuming. So our best option would be if @olikraus could look into it.

MCUdude commented 3 months ago

@o7-machinehum have a look at this:

https://github.com/olikraus/U8g2_Arduino/blob/ca1caf364434809734e82e7d7cf66947d4e77bdf/src/U8x8lib.cpp#L54-L56

If I uncomment these lines, the code compiles just fine. The question is; how can #if defined(MINICORE) && defined(__AVR_ATmega328PB__) possibly be true? The code is compiled for an ATmega1284P, and for MightyCore, not MiniCore.

MCUdude commented 3 months ago

Now this is really weird, and maybe related to PlatformIO itself.

The followig code does not compile, hence this issue:

#ifdef U8X8_HAVE_HW_I2C
#  ifdef U8X8_HAVE_HW_I2C_TEENSY3
#    include <i2c_t3.h>
#  else
#    include <Wire.h>
#    ifdef U8X8_HAVE_2ND_HW_I2C
#      if defined(MINICORE) && defined(__AVR_ATmega328PB__)
#        include <Wire1.h>
#      endif
#    endif
#  endif
#endif /* U8X8_HAVE_HW_I2C */

However, this does!

#ifdef U8X8_HAVE_HW_I2C
#  ifdef U8X8_HAVE_HW_I2C_TEENSY3
#    include <i2c_t3.h>
#  else
#    include <Wire.h>
#    ifdef U8X8_HAVE_2ND_HW_I2C
#      if defined(MINICORE) && defined(__AVR_ATmega328PB__)
#        include <blablabla_not_present.h>
#      endif
#    endif
#  endif
#endif /* U8X8_HAVE_HW_I2C */

@valeros how is this even possible!

o7-machinehum commented 3 months ago

Now this is really weird, and maybe related to PlatformIO itself.

The followig code does not compile, hence this issue:

#ifdef U8X8_HAVE_HW_I2C
#  ifdef U8X8_HAVE_HW_I2C_TEENSY3
#    include <i2c_t3.h>
#  else
#    include <Wire.h>
#    ifdef U8X8_HAVE_2ND_HW_I2C
#      if defined(MINICORE) && defined(__AVR_ATmega328PB__)
#        include <Wire1.h>
#      endif
#    endif
#  endif
#endif /* U8X8_HAVE_HW_I2C */

However, this does!

#ifdef U8X8_HAVE_HW_I2C
#  ifdef U8X8_HAVE_HW_I2C_TEENSY3
#    include <i2c_t3.h>
#  else
#    include <Wire.h>
#    ifdef U8X8_HAVE_2ND_HW_I2C
#      if defined(MINICORE) && defined(__AVR_ATmega328PB__)
#        include <blablabla_not_present.h>
#      endif
#    endif
#  endif
#endif /* U8X8_HAVE_HW_I2C */

@valeros how is this even possible!

Hey, yeah thanks for validating me on this one. I'm seeing the exact same thing and it was driving me insane.

FYI the break is in between 2.34.5 and 2.34.18, exactly where this offending code above was introduced.

MCUdude commented 3 months ago

@valeros Even this code snippet includes Wire1.h, and causes the compiler to fail. I have no idea how this can even happen.

#if 0
#include <Wire1.h>
#endif

EDIT: and this:

#define MYVAL 1
#if MYVAL==2
#include <Wire1.h>
#endif
o7-machinehum commented 3 months ago

@valeros Even this code snippet includes Wire1.h, and causes the compiler to fail. I have no idea how this can even happen.

#if 0
#include <Wire1.h>
#endif

I wonder if platformIO is doing something insane, like grepping for headers in source and compiling the corresponding .c/cpp files based on that.

valeros commented 3 months ago

Hi there, I've reproduced the problem, though I'm not sure how it worked before. Anyway, a PR that fixes the issue has been filed here https://github.com/olikraus/U8g2_Arduino/pull/12. It would be great if the maintainer could take a look.

In the meantime, as a workaround, just add lib_ldf_mode = chain+ to your platformio.ini.

MCUdude commented 3 months ago

@valeros may I ask how this:

#if 0
#include <Wire1.h>
#endif

... possibly can be included when building using PlatformIO, and why lib_ldf_mode = chain+ fixes it?

o7-machinehum commented 3 months ago

lib_ldf_mode

https://docs.platformio.org/en/stable/librarymanager/ldf.html

Being completely uneducated, I think the chain+ should be the default. But I'm sure there's a good reason for it not being.

valeros commented 3 months ago

and why lib_ldf_mode = chain+ fixes it

For backward compatibility reasons, the default mode of the dependency finder doesn't evaluate preprocessor directives.

olikraus commented 3 months ago

Hi there, I've reproduced the problem, though I'm not sure how it worked before. Anyway, a PR that fixes the issue has been filed here olikraus/U8g2_Arduino#12. It would be great if the maintainer could take a look.

In the meantime, as a workaround, just add lib_ldf_mode = chain+ to your platformio.ini.

I have merged the PR

olikraus commented 3 months ago

It this code causes the problem: https://github.com/olikraus/U8g2_Arduino/blob/ca1caf364434809734e82e7d7cf66947d4e77bdf/src/U8x8lib.cpp#L54-L56

then... I don't remember where it came from. Maybe a PR from someone else.

Please let me know how to support here further.

valeros commented 3 months ago

Hi @olikraus, thanks for the answer. I noticed you bumped version to 2.35.10 yesterday. Could you please also update the version in PlatformIO manifest file here https://github.com/olikraus/U8g2_Arduino/blob/master/library.json#L10, so that the latest version can be uploaded to the PlatformIO Registry. Thanks!

olikraus commented 3 months ago

Whouldn't it be better to keep the latest stable release in that json file? Currently latest stable release for u8g2 is 2.34.x

valeros commented 3 months ago

@olikraus

Whouldn't it be better to keep the latest stable release in that json file? Currently latest stable release for u8g2 is 2.34.x

Isn't 2.35.10 the latest? There is a discrepancy between library.json and library.properties files, so it would be great to have these files in sync.

olikraus commented 3 months ago

The latest official release is 2.34.22: https://github.com/olikraus/U8g2_Arduino/releases/tag/2.34.22 This release will be used by Arduino IDE. In fact Arduino IDE will use library.properties file from the release itself and not from the repository "head".

2.35.10 (currently 2.35.14) are unstable beta releases.

ivankravets commented 3 months ago

You must keep the version field the same for both manifests if you want PlatformIO to pick your updates automatically.

Otherwise, you can copy the source code of the upcoming release into the temporary folder, remove library.properties and publish to the PlatformIO Registry manually using pio pkg publish command.

olikraus commented 3 months ago

hmm... I have no idea about PlatformIO and I also don't have time to figure out how to support PlatformIO. All the platformIO related code had been contributed via PR.

My goal is to support Arduino IDE. This seems to work and will be tested by this project.

I would be happy to support PlatformIO, but I can't do this. So I see two options: Either I remove the platformIO related code or someone is able to fix this.

ivankravets commented 2 months ago

You need to synchronize the "version" among the all manifest:

Finally, the latest release is 2.34.22 https://github.com/olikraus/U8g2_Arduino/releases

The easiest way to fix the issue is to set "version" the same in both manifests and create a new tag/release with that version.