wonho-maker / Adafruit_SH1106

Adafruit graphic library for SH1106 dirver lcds.
Other
162 stars 93 forks source link

swap() function not defined -> cannot compile #2

Open Bzzz opened 8 years ago

Bzzz commented 8 years ago

This library misses the swap function from the main SSD1306 library. The example sketch produces:

/libraries/SH1106/Adafruit_SH1106.cpp: In member function 'virtual void Adafruit_SH1106::drawFastVLine(int16_t, int16_t, int16_t, uint16_t)': /libraries/SH1106/Adafruit_SH1106.cpp:742:23: error: 'swap' was not declared in this scope swap(x, y);

SSD1306 library has such a function defined, SH1106 doesn't, maybe carved out by mistake. I propose adding

define sh1106_swap(a, b) { int16_t t = a; a = b; b = t; }

to the cpp file and replacing every swap() command with sh1106_swap() to stay in line with the main lib.

CarbonChili commented 7 years ago

I also get this error when compiling to do with swap

Adafruit_SH1106-master\Adafruit_SH1106.cpp:123:14: error: 'swap' was not declared in this scope swap(x, y); Adafruit_SH1106-master\Adafruit_SH1106.cpp:673:16: error: 'swap' was not declared in this scope swap(x, y); Adafruit_SH1106-master\Adafruit_SH1106.cpp:741:16: error: 'swap' was not declared in this scope swap(x, y);

I have made the changes suggested by Bzzz and it works without fault

ricxcer commented 7 years ago

How do I do? Can you send me the changed .cpp file? Thank you!

ricxcer commented 7 years ago

Now it worked! Thanks!

wonho-maker commented 7 years ago

Hi It is long time ;; Maybe default swap function deprecate or remove in header lib So i fix it but i can't real test because i don't have arduino now

Thank you for everyting

yo1995 commented 7 years ago

thank you for your modification. really helped!

golec-arkadiusz commented 3 years ago

Edit file Adafruit_SH1106.cpp from librarry

add function swap(x,y);

//** int swap(int x, int y) { int tmp; tmp = x; x = y; y = tmp; return x,y; } //**

OR

define swap(x, y) { int16_t tmp = x; x = y; y = tmp; }