-->
Page 1 of 3

compiler error trying OLED library on swap(x, y)

PostPosted: Wed Dec 09, 2015 3:10 pm
by canedje
Hello everybody.

I try to get an OLED SSD1306 running
I did download an example programm and the ESP_Adafruit_SSD1306 librarie.

I do receive an compiler error on swap function in the library part of the programm:

    :/Documenten/Arduino/libraries/ESP_Adafruit_SSD1306-master/ESP_Adafruit_SSD1306.cpp: In member function 'virtual void Adafruit_SSD1306::drawPixel(int16_t, int16_t, uint16_t)':
    D:/Documenten/Arduino/libraries/ESP_Adafruit_SSD1306-master/ESP_Adafruit_SSD1306.cpp:109:14: error: 'swap' was not declared in this scope
    swap(x, y);

The library is using severall times the command: swap(x, y)
I don't know why this error occurs.
Is a part of the library missing?
Or is swap a kind of standard function?
How to solve this compiler error?

Thanks
Is swap a standard function?

Re: compiler error trying OLED library on swap(x, y)

PostPosted: Wed Dec 09, 2015 3:52 pm
by reaper7
yes, swap is a core function
so...try my fixed mod:
https://github.com/reaper7/ESP_SSD1306

Re: compiler error trying OLED library on swap(x, y)

PostPosted: Wed Dec 09, 2015 4:11 pm
by canedje
reaper7 wrote:yes, swap is a core function
so...try my fixed mod:
https://github.com/reaper7/ESP_SSD1306



Thanks for the answer.

I tried your example: basic_oled_i2c
Including your librarie.
I still do recieve a compiler error in the file in the library: ESP_SSD1306.cpp

The compile error is:

    D:/Documenten/Arduino/libraries/ESP_SSD1306-master/ESP_SSD1306.cpp:130:17: error: 'swapint' was not declared in this scope
    swapint(x, y);
    ^
    D:/Documenten/Arduino/libraries/ESP_SSD1306-master/ESP_SSD1306.cpp: In member function 'virtual void ESP_SSD1306::drawFastHLine(int16_t, int16_t, int16_t, uint16_t)':
    D:/Documenten/Arduino/libraries/ESP_SSD1306-master/ESP_SSD1306.cpp:592:19: error: 'swapint' was not declared in this scope
    swapint(x, y);
    ^
    D:/Documenten/Arduino/libraries/ESP_SSD1306-master/ESP_SSD1306.cpp: In member function 'virtual void ESP_SSD1306::drawFastVLine(int16_t, int16_t, int16_t, uint16_t)':
    D:/Documenten/Arduino/libraries/ESP_SSD1306-master/ESP_SSD1306.cpp:660:19: error: 'swapint' was not declared in this scope
    swapint(x, y);
    ^
    Libraries/ESP_SSD1306-master/subdir.mk:18: recipe for target 'Libraries/ESP_SSD1306-master/ESP_SSD1306.cpp.o' failed
    make: *** [Libraries/ESP_SSD1306-master/ESP_SSD1306.cpp.o] Error 1


Do I need to include an kind of standard lib like math.h where swap will be declared?

If swap is a core function why is my compiler not recognize it?

Re: compiler error trying OLED library on swap(x, y)

PostPosted: Wed Dec 09, 2015 5:33 pm
by reaper7
swap (or new swapint) is placed inside Adafruit_GFX library (file Adafruit_GFX.h)

download this lib and change:
from
Code: Select all#define swap(a, b) { int16_t t = a; a = b; b = t; }

to
Code: Select all#define swapint(a, b) { int16_t t = a; a = b; b = t; }