Trying to learn getPixel


I am currently trying to figure out how the getPixel function works.
Maybe someone can take a look at my function and tell me why it doesent work.

void invertPixel(byte x, byte y) {
  if (getPixel(x, y) == WHITE) {
    arduboy.drawPixel(x, y, BLACK);
  } else {
    arduboy.drawPixel(x, y, WHITE);

Also when i type the function in it doesent get highlighted like the other functions which is weird because its in the arduboy 2 documentation.

Does it compile or not? It looks correct.

As far as the highlighting goes, it appears that getPixel did not make it into the keywords.txt file. The colouring is cosmetic only and does not affect compilation. You could put in an ‘Issue’ against @MLXXXp’s repository and he may fix it in a future release.

1 Like

It says getPixel was not declared in this scope.

It actually works just forgot that i had to write arduboy.getPixel(); -,-


getPixel() is a member function of the arduboy class. So you have to call it from an/the instance of arduboy2 like arduboy.getPixel(...).

1 Like

Hah … I didn’t notice that either! Glad you got it working.


Huh? A seal??  

@filmote that’s the akward seal meme. Because i posted his mistake probably at the same time when he did. :wink:

Right … I had heard of that before!

getPixel has been added to keywords.txt for the next release. (Sorry for missing it.)