#include <Arduboy2.h>
Arduboy2Base arduboy;
void setup() {
arduboy.boot();
arduboy.audio.begin();
//arduboy.setFrameRate(FPS);
//Start serial
Serial.begin(115200);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial.println("Entering setup");
Serial.println("Exiting setup");
}
void loop() {
Serial.println("Entering loop");
// put your main code here, to run repeatedly:
arduboy.clear();
arduboy.fillRect(0, 0, WIDTH-1, HEIGHT-1);
arduboy.display();
Serial.println("Exiting setup");
}
My problem is fillrect is hanging.
with this output on serial:
Entering setup
Exiting setup
Entering loop
If I switch the arduboy class declaration to be Arduboy2 it works. Also if I roll back the Arduboy2 library to 3.1.1 it works. I’m currently trying to use 4.0.0.
I’m confused because the Arduboy2 library hasn’t been updated Since Apr 26 and I wasn’t having any trouble before this evening.
Am I missing something? I feel like I’m loosing my mind.
I double checked, there is an Arduboy2Base, it’s in the same file as Arduboy2 for some reason. Didn’t realise Arduboy2 has a 3-stage inheritance chain.
fillRect is definitely on Arduboy2Base so disregard my earlier statement.
I’ve narrowed the problem down.
It seems that it’s fine creating rectangles up to 8x8, but any larger than that and it locks up for some reason.
The biggest difference between the versions (3.1.1 and 4.0.0) is that 4.0.0 is now using some assembly, so it could be something to do with register clobbers. Seems odd that Arduboy2 doesn’t have the problem but Arduboy2Base does.
Sorry about that. It’s a problem with the library drawPixel() function.
For the v4.0.0 release, @Dreamer3 provided a modified version of drawPixel() which uses some assembler to reduce code size and improve speed. There’s a problem with this new code which causes it to sometimes hang.
Until the problem is sorted out, you could revert back to Arduboy2 library v3.1.1 using the Library Manager
Sketch > Include Library > Manage Libraries...
Enter arduboy2 in the Filter your search… field.
Click somewhere in the Arduboy2 entry.
Choose Version 3.1.1 in the Select version pull-down.
Click on Install
If your sketch uses something unique to v4.0.0, preventing you from using v3.1.1, you can replace the Arduboy2Base::drawPixel() function in file Arduboy2.cpp with the previous version:
void Arduboy2Base::drawPixel(int16_t x, int16_t y, uint8_t color)
{
#ifdef PIXEL_SAFE_MODE
if (x < 0 || x > (WIDTH-1) || y < 0 || y > (HEIGHT-1))
{
return;
}
#endif
uint8_t row = (uint8_t)y / 8;
if (color)
{
sBuffer[(row*WIDTH) + (uint8_t)x] |= _BV((uint8_t)y % 8);
}
else
{
sBuffer[(row*WIDTH) + (uint8_t)x] &= ~ _BV((uint8_t)y % 8);
}
}
Excellent, I have temporarily rolled back. I was mostly confused because it went from working to not rather suddenly. Like 4.0.0 just got added to the Arduino library repo.
I only spotted it because I spent ages looking at the code before I increased the zombie spawn rate otherwise I would have probably sailed through never knowing it existed