Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
LCD_ST7735/Bitmap1bpp.cpp
- Committer:
- taylorza
- Date:
- 2015-01-28
- Revision:
- 0:d85c449aca6d
File content as of revision 0:d85c449aca6d:
#include "mbed.h"
#include "Bitmap1bpp.h"
Bitmap1bpp::Bitmap1bpp(uint16_t width, uint16_t height):
_width(width),
_height(height),
_stride((width >> 3) + ((width & 0x07) ? 1 : 0)),
_pBitmapData(new uint8_t[_stride * height])
{
}
Bitmap1bpp::~Bitmap1bpp()
{
if (_pBitmapData != NULL)
{
delete []_pBitmapData;
_pBitmapData = NULL;
}
}
void Bitmap1bpp::clear()
{
memset(_pBitmapData, 0, _stride * _height);
}
void Bitmap1bpp::setPixel(int16_t x, int16_t y, uint16_t color)
{
if (x < 0 || x >= _width || y < 0 || y >= _height) return;
uint8_t mask = 1 << (7 - (x % 8));
uint8_t *p = _pBitmapData + ((y * _stride) + (x / 8));
if (color) *p |= mask; else *p &= ~mask;
}