Exemplo n.º 1
0
void
xpcc::GraphicDisplay::drawVerticalLine(glcd::Point start, uint16_t length)
{
	for (int_fast16_t i = start.getY(); i < static_cast<int16_t>(start.getY() + length); ++i) {
		(this->*draw)(start.getX(), i);
	}
}
Exemplo n.º 2
0
void
xpcc::GraphicDisplay::drawImageRaw(glcd::Point upperLeft,
		uint16_t width, uint16_t height,
		xpcc::accessor::Flash<uint8_t> data)
{
	uint16_t rows = (height + 7) / 8;
	for (uint16_t i = 0; i < width; i++)
	{
		for (uint16_t k = 0; k < rows; k++)
		{
			uint16_t byte = data[i + k * width];
			uint16_t rowHeight = height - k * 8;
			if (rowHeight > 8) {
				rowHeight = 8;
			}
			for (uint16_t j = 0; j < rowHeight; j++)
			{
				if (byte & 0x01) {
					this->setPixel(upperLeft.getX() + i, upperLeft.getY() + k * 8 + j);
				}
				else {
					this->clearPixel(upperLeft.getX() + i, upperLeft.getY() + k * 8 + j);
				}
				byte >>= 1;
			}
		}
	}
}
Exemplo n.º 3
0
void
xpcc::GraphicDisplay::drawVerticalLine(glcd::Point start, uint8_t length)
{
    for (uint8_t i = start.getY(); i < start.getY() + length; ++i) {
        (this->*draw)(start.getX(), i);
    }
}
Exemplo n.º 4
0
void
xpcc::GraphicDisplay::drawRectangle(glcd::Point upperLeft,
		uint16_t width, uint16_t height)
{
	uint16_t x2 = upperLeft.getX() + width  - 1;
	uint16_t y2 = upperLeft.getY() + height - 1;
	
	this->drawHorizontalLine(upperLeft,  width);
	this->drawHorizontalLine(glcd::Point(upperLeft.getX(), y2), width);
	this->drawVerticalLine(upperLeft, height);
	this->drawVerticalLine(glcd::Point(x2, upperLeft.getY()), height);
}
Exemplo n.º 5
0
void
xpcc::GraphicDisplay::drawHorizontalLine(glcd::Point start, uint8_t length)
{
    for (uint8_t i = start.getX(); i < start.getX() + length; ++i) {
        (this->*draw)(i, start.getY());
    }
}
Exemplo n.º 6
0
void
xpcc::GraphicDisplay::drawCircle4(glcd::Point center, int16_t x, int16_t y)
{
	const int16_t cx = center.getX();
	const int16_t cy = center.getY();
	
	(this->*draw)(cx + x, cy + y);
	(this->*draw)(cx - x, cy - y);
	if (x != 0) {
		(this->*draw)(cx - x, cy + y);
	}
	if (y != 0) {
		(this->*draw)(cx + x, cy - y);
	}
}
Exemplo n.º 7
0
void
xpcc::GraphicDisplay::drawRoundedRectangle(glcd::Point upperLeft,
		uint16_t width, uint16_t height, uint16_t radius)
{
	if (radius == 0) {
		this->drawRectangle(upperLeft, width, height);
	}
	
	const int16_t x = upperLeft.getX();
	const int16_t y = upperLeft.getY();
	
	int16_t x1 = 0;
	int16_t y1 = radius;
  	int16_t f = 3 - 2 * radius;
	
	while (x1 <= y1)
	{
		(this->*draw)(x + radius - x1, y + radius - y1);
		(this->*draw)(x + radius - x1, y + height - radius + y1);
		(this->*draw)(x + radius - y1, y + radius - x1);
		(this->*draw)(x + radius - y1, y + height - radius + x1);
		
		(this->*draw)(x + width - radius + x1, y + radius - y1);
		(this->*draw)(x + width - radius + x1, y + height - radius + y1);
		(this->*draw)(x + width - radius + y1, y + radius - x1);
		(this->*draw)(x + width - radius + y1, y + height - radius + x1);
		
		if (f < 0) {
			f += (4 * x1 + 6);
		}
		else {
			f += (4 * (x1 - y1) + 10);
			y1--;
		}
		x1++;
	}
	
	this->drawHorizontalLine(glcd::Point(x + radius, y), width - (2 * radius));
	this->drawHorizontalLine(glcd::Point(x + radius, y + height), width - (2 * radius));
	this->drawVerticalLine(glcd::Point(x, y + radius), height - (2 * radius));
	this->drawVerticalLine(glcd::Point(x + width, y + radius), height - (2 * radius));
}