'Wire1' was not declared in this scope

Hi,

I have a sketch using U8g2lib.h to control a display using a 2nd SPI port on a Teensy LC.
This sketch runs fine on IDE 1.8.19.

Now using IDE 2.2.1 the sketch comes up with the error:

U8x8lib.cpp:1387:7: error: 'Wire1' was not declared in this scope

In both IDE versions a test on declaring Wire1.h in a #define results in a "no such file or directory error".

Both IDE use the same library.

What could be wrong?

Gr,
Ron

Please post the code, using code tags, and a link to the exactly library in question.

@Petjepet
What's connection between 2nd SPI port and "Wire1" declaration? "Wire" - is standard name for I2c bus, not SPI

It is in declaring the display:

// Initialize LCD 12864 display: ST7920  
U8G2_ST7920_128X64_1_SW_SPI u8g(U8G2_R2, E_PIN, RW_PIN, RS_PIN, U8X8_PIN_NONE);

then the error is in the U8G2lib:

extern "C" uint8_t u8x8_byte_arduino_2nd_hw_i2c(U8X8_UNUSED u8x8_t *u8x8, U8X8_UNUSED uint8_t msg, U8X8_UNUSED uint8_t arg_int, U8X8_UNUSED void *arg_ptr)
{
#ifdef U8X8_HAVE_2ND_HW_I2C
  switch(msg)
  {
    case U8X8_MSG_BYTE_SEND:
      Wire1.write((uint8_t *)arg_ptr, (int)arg_int);       <<<<<<  ERROR  <<<<<<<<<<<
      break;
    case U8X8_MSG_BYTE_INIT:
      if ( u8x8->bus_clock == 0 ) 	/* issue 769 */
	u8x8->bus_clock = u8x8->display_info->i2c_bus_clock_100kHz * 100000UL;
      Wire1.begin();
      break;
    case U8X8_MSG_BYTE_SET_DC:
      break;
    case U8X8_MSG_BYTE_START_TRANSFER:
#if ARDUINO >= 10600
      /* not sure when the setClock function was introduced, but it is there since 1.6.0 */
      /* if there is any error with Wire.setClock() just remove this function call by */
      /* defining U8X8_DO_NOT_SET_WIRE_CLOCK */
#ifndef U8X8_DO_NOT_SET_WIRE_CLOCK
      Wire1.setClock(u8x8->bus_clock); 
#endif
#endif

I marked the line with "<<<<<< ERROR <<<<<<<<<<<".

I think I have it working.
In the hardware folder and Teensy folder the Wire library has a file "WireKinetis.h".
In there:

// Teensy LC
#if defined(__MKL26Z64__)
#define WIRE_IMPLEMENT_WIRE
//Wire1 consumes precious memory on Teensy LC
//#define WIRE_IMPLEMENT_WIRE1
#define WIRE_HAS_STOP_INTERRUPT

I uncommented the #define WIRE_IMPLEMENT_WIRE1 constant and it worked.

The strange thing is that in the same library on the hardware section on IDE 1.8.19 this still is commented and compiling works there with no issue.

How can this be?

IDE 2.2.0 must have some different implementations.

This could be if the macro U8X8_HAVE_2ND_HW_I2C give another value when evaluated in 1.8.19

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.