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.
Diff: LCD_ST7735/Bitmap1bpp.cpp
- Revision:
- 0:d85c449aca6d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/LCD_ST7735/Bitmap1bpp.cpp Wed Jan 28 03:26:07 2015 +0000
@@ -0,0 +1,35 @@
+#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;
+}