felias-fogg / SoftI2CMaster

Software I2C Arduino library
GNU General Public License v3.0
368 stars 100 forks source link

Digispark ATTINY85 conflicting return type? #33

Closed quantifiable closed 2 years ago

quantifiable commented 6 years ago

just calling SoftWire in this simple Digispark Echo code:

#include <DigiUSB.h>
#define SCL_PIN 2
#define SCL_PORT PORTB
#define SDA_PIN 0
#define SDA_PORT PORTB
//#define I2C_HARDWARE 1
#include <SoftI2CMaster.h>
#include <SoftWire.h>
SoftWire Wire = SoftWire();

void setup() {
  DigiUSB.begin();
  Wire.begin();
}

void get_input() {
  int lastRead;
  // when there are no characters to read, or the character isn't a newline
  while (true) { // loop forever
    if (DigiUSB.available()) {
      // something to read
      lastRead = DigiUSB.read();
      DigiUSB.write(lastRead);

      if (lastRead == '\n') {
        break; // when we get a newline, break out of loop
      }
    }

    // refresh the usb port for 10 milliseconds
    DigiUSB.delay(10);
  }
}

void loop() {
  // print output
  DigiUSB.println("Waiting for input...");
  // get input
  get_input();
}

I get "conflicting return type", abborting the compilation.

In file included from C:\Users\xyz\AppData\Local\Temp\arduino_modified_sketch_192160\Echo.ino:8:0:

C:\Users\xyz\Documents\Arduino\libraries\SoftI2CMaster-master/SoftWire.h:101:10: error: conflicting return type specified for 'virtual size_t SoftWire::write(const uint8_t*, size_t)'

   size_t write(const uint8_t *data, size_t quantity) {

          ^

In file included from C:\Users\xyz\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\cores\tiny/Stream.h:24:0,

                 from C:\Users\xyz\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\cores\tiny/TinyDebugSerial.h:31,

                 from C:\Users\xyz\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\cores\tiny/WProgram.h:18,

                 from C:\Users\xyz\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\cores\tiny/Arduino.h:4,

                 from sketch\Echo.ino.cpp:1:

C:\Users\xyz\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\cores\tiny/Print.h:75:18: error:   overriding 'virtual void Print::write(const uint8_t*, size_t)'

     virtual void write(const uint8_t *buffer, size_t size);

                  ^

exit status 1

How can this be fixed?

fragsalat commented 5 years ago

I'm having the same issue.

I've adopted the write functions to match those if the Print.h. So the write with single param has size_t as return and the other with 2 params is void.

ArminJo commented 2 years ago

Use the new digispark core https://github.com/ArminJo/DigistumpArduino