Add C++ equivalent code for drawPixel()

This commit is contained in:
Scott Allen 2018-11-13 11:51:55 -05:00
parent 2941ed100f
commit 195d3e5cde
1 changed files with 22 additions and 1 deletions

View File

@ -364,6 +364,27 @@ void Arduboy2Base::drawPixel(int16_t x, int16_t y, uint8_t color)
if (!(color & _BV(0))) data ^= bit;
sBuffer[row_offset] = data;
}
#if 0
// For reference, this is the C++ equivalent
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
uint16_t row_offset;
uint8_t bit;
bit = 1 << (y & 7);
row_offset = (y & 0xF8) * WIDTH / 8 + x;
uint8_t data = sBuffer[row_offset] | bit;
if (!color) data ^= bit;
sBuffer[row_offset] = data;
}
#endif
uint8_t Arduboy2Base::getPixel(uint8_t x, uint8_t y)
{