Skip to content
Snippets Groups Projects
Commit 1b1952ef authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

framebuffer: battery: show charging indicator

parent 392aec88
No related branches found
No related tags found
No related merge requests found
......@@ -23,7 +23,7 @@ class Framebuffer : public OutputStream
void scroll();
void fillBox(unsigned int x, unsigned int y, unsigned int w, unsigned int h);
void drawAt(unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned char *image);
void drawBattery(unsigned int x, unsigned int y, unsigned char percent);
void drawBattery(unsigned int x, unsigned int y, unsigned char percent, bool charging = false);
void setFont(const glyph_t *font) { this->font = font; }
void setPos(unsigned int newX, unsigned int newY) { fontX = newX; fontY = newY; }
virtual void put(char c) override;
......
......@@ -71,15 +71,24 @@ void Framebuffer::drawAt(unsigned int x, unsigned int y, unsigned int w, unsigne
}
}
void Framebuffer::drawBattery(unsigned int x, unsigned int y, unsigned char percent)
void Framebuffer::drawBattery(unsigned int x, unsigned int y, unsigned char percent, bool charging)
{
for (unsigned char i = 0; i < 13; i++) {
data[(x+i) * (height/8) + y] = 0x81 | (0xff * (percent >= (i*8)));
data[(x+i) * (height/8) + y] = 0x81 | (0xff * (percent*2 >= i*15));
}
data[(x+11) * (height/8) + y/8] |= 0xe7;
data[(x+12) * (height/8) + y/8] &= ~0x81;
data[(x+12) * (height/8) + y/8] |= 0x24;
data[(x+13) * (height/8) + y/8] = 0x3c;
if (charging) {
data[(x+2) * (height/8) + y/8] ^= 0x7e;
data[(x+3) * (height/8) + y/8] ^= 0x3c;
data[(x+4) * (height/8) + y/8] ^= 0x18;
data[(x+7) * (height/8) + y/8] ^= 0x7e;
data[(x+8) * (height/8) + y/8] ^= 0x3c;
data[(x+9) * (height/8) + y/8] ^= 0x18;
}
}
void Framebuffer::scroll()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment