Merge branch 'Truck_complains_about_formatting'

This commit is contained in:
Lewis Jackson 2023-05-29 22:13:52 +03:00
commit 854dea2dc2
2 changed files with 107 additions and 94 deletions

View file

@ -1,11 +1,24 @@
#include "SevenSegment.h"
SevenSegment::SevenSegment(uint16_t digitWidth, uint16_t digitHeight, uint16_t digitGap, uint16_t segmentThickness, uint16_t segmentGap)
: m_digitWidth(digitWidth), m_digitHeight(digitHeight), m_digitGap(digitGap), m_segmentThickness(segmentThickness), m_segmentGap(segmentGap)
SevenSegment::SevenSegment(uint16_t digitWidth,
uint16_t digitHeight,
uint16_t digitGap,
uint16_t segmentThickness,
uint16_t segmentGap)
: m_digitWidth(digitWidth),
m_digitHeight(digitHeight),
m_digitGap(digitGap),
m_segmentThickness(segmentThickness),
m_segmentGap(segmentGap)
{
}
void SevenSegment::DrawDigit(GxEPD2_BW<WatchyDisplayBase, WatchyDisplayBase::HEIGHT> & display, uint8_t digit, uint16_t x, uint16_t y, uint8_t color)
void SevenSegment::DrawDigit(GxEPD2_BW<WatchyDisplayBase,
WatchyDisplayBase::HEIGHT> & display,
uint8_t digit,
uint16_t x,
uint16_t y,
uint8_t color)
{
if (digit > 9) {
return;
@ -13,6 +26,8 @@ void SevenSegment::DrawDigit(GxEPD2_BW<WatchyDisplayBase, WatchyDisplayBase::HEI
uint16_t digitX = x;
uint16_t digitY = y;
uint8_t drawcolors[] = { (uint8_t) (color ^ 0xFF) ,
(uint8_t) color };
// top top-right bottom-right bottom bottom-left top-left middle
@ -32,51 +47,49 @@ void SevenSegment::DrawDigit(GxEPD2_BW<WatchyDisplayBase, WatchyDisplayBase::HEI
const bool * segments = drawSegments[digit];
// Top
if (segments[0]) {
display.fillRect(digitX + m_segmentThickness, digitY, m_digitWidth - 2 * m_segmentThickness, m_segmentThickness, color);
} else {
display.fillRect(digitX + m_segmentThickness, digitY, m_digitWidth - 2 * m_segmentThickness, m_segmentThickness, color ^ 0xFF);
}
display.fillRect(digitX + m_segmentThickness,
digitY,
m_digitWidth - 2 * m_segmentThickness,
m_segmentThickness,
drawcolors[segments[0]]);
// Top-right
if (segments[1]) {
display.fillRect(digitX + m_digitWidth - m_segmentThickness, digitY + m_segmentThickness, m_segmentThickness, m_digitHeight / 2 - m_segmentThickness * 2, color);
} else {
display.fillRect(digitX + m_digitWidth - m_segmentThickness, digitY + m_segmentThickness, m_segmentThickness, m_digitHeight / 2 - m_segmentThickness * 2, color ^ 0xFF);
}
display.fillRect(digitX + m_digitWidth - m_segmentThickness,
digitY + m_segmentThickness,
m_segmentThickness,
m_digitHeight / 2 - m_segmentThickness * 2,
drawcolors[segments[1]]);
// Bottom-right
if (segments[2]) {
display.fillRect(digitX + m_digitWidth - m_segmentThickness, digitY + m_digitHeight / 2, m_segmentThickness, m_digitHeight / 2 - m_segmentThickness * 2, color);
} else {
display.fillRect(digitX + m_digitWidth - m_segmentThickness, digitY + m_digitHeight / 2, m_segmentThickness, m_digitHeight / 2 - m_segmentThickness * 2, color ^ 0xFF);
}
display.fillRect(digitX + m_digitWidth - m_segmentThickness,
digitY + m_digitHeight / 2, m_segmentThickness,
m_digitHeight / 2 - m_segmentThickness * 2,
drawcolors[segments[2]]);
// Bottom
if (segments[3]) {
display.fillRect(digitX + m_segmentThickness, digitY + m_digitHeight - m_segmentThickness * 2, m_digitWidth - 2 * m_segmentThickness, m_segmentThickness, color);
} else {
display.fillRect(digitX + m_segmentThickness, digitY + m_digitHeight - m_segmentThickness * 2, m_digitWidth - 2 * m_segmentThickness, m_segmentThickness, color ^ 0xFF);
}
display.fillRect(digitX + m_segmentThickness,
digitY + m_digitHeight - m_segmentThickness * 2,
m_digitWidth - 2 * m_segmentThickness,
m_segmentThickness,
drawcolors[segments[3]]);
// Bottom-left
if (segments[4]) {
display.fillRect(digitX, digitY + m_digitHeight / 2, m_segmentThickness, m_digitHeight / 2 - m_segmentThickness * 2, color);
} else {
display.fillRect(digitX, digitY + m_digitHeight / 2, m_segmentThickness, m_digitHeight / 2 - m_segmentThickness * 2, color ^ 0xFF);
}
display.fillRect(digitX,
digitY + m_digitHeight / 2,
m_segmentThickness, m_digitHeight / 2 - m_segmentThickness * 2,
drawcolors[segments[4]]);
// Top-left
if (segments[5]) {
display.fillRect(digitX, digitY + m_segmentThickness, m_segmentThickness, m_digitHeight / 2 - m_segmentThickness * 2, color);
} else {
display.fillRect(digitX, digitY + m_segmentThickness, m_segmentThickness, m_digitHeight / 2 - m_segmentThickness * 2, color ^ 0xFF);
}
display.fillRect(digitX,
digitY + m_segmentThickness,
m_segmentThickness,
m_digitHeight / 2 - m_segmentThickness * 2,
drawcolors[segments[5]]);
// Middle
if (segments[6]) {
display.fillRect(digitX + m_segmentThickness, digitY + m_digitHeight / 2 - m_segmentThickness, m_digitWidth - 2 * m_segmentThickness, m_segmentThickness, color);
} else {
display.fillRect(digitX + m_segmentThickness, digitY + m_digitHeight / 2 - m_segmentThickness, m_digitWidth - 2 * m_segmentThickness, m_segmentThickness, color ^ 0xFF);
}
display.fillRect(digitX + m_segmentThickness,
digitY + m_digitHeight / 2 - m_segmentThickness,
m_digitWidth - 2 * m_segmentThickness,
m_segmentThickness,
drawcolors[segments[6]]);
}