Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# LcdProgressBarDouble
LcdProgressBarDouble is an Arduino library for displaying a 2 progress bars in a single row in LCD display.
updated to make bars symmetrical and start from custom column
29 changes: 15 additions & 14 deletions src/LcdProgressBarDouble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
const byte LcdProgressBarDouble::bars[] PROGMEM =
{
// 0
B11000,
B00000,
B11000,
B11000,
B00000,
Expand All @@ -47,7 +47,7 @@
B00000
,
// 2
B11000,
B00000,
B11000,
B11000,
B00000,
Expand All @@ -57,7 +57,7 @@
B00000
,
// 3
B11111,
B00000,
B11111,
B11111,
B00000,
Expand All @@ -77,7 +77,7 @@
B00000
,
// 5
B11111,
B00000,
B11111,
B11111,
B00000,
Expand All @@ -87,7 +87,7 @@
B00000
,
// 6
B11000,
B00000,
B11000,
B11000,
B00000,
Expand All @@ -97,7 +97,7 @@
B00000
,
// 7
B11111,
B00000,
B11111,
B11111,
B00000,
Expand All @@ -110,7 +110,7 @@
byte LcdProgressBarDouble::bars[8][8] =
{
{ // 0
B11000,
B00000,
B11000,
B11000,
B00000,
Expand All @@ -130,7 +130,7 @@
B00000
},
{ // 2
B11000,
B00000,
B11000,
B11000,
B00000,
Expand All @@ -140,7 +140,7 @@
B00000
},
{ // 3
B11111,
B00000,
B11111,
B11111,
B00000,
Expand All @@ -160,7 +160,7 @@
B00000
},
{ // 5
B11111,
B00000,
B11111,
B11111,
B00000,
Expand All @@ -170,7 +170,7 @@
B00000
},
{ // 6
B11000,
B00000,
B11000,
B11000,
B00000,
Expand All @@ -180,7 +180,7 @@
B00000
},
{ // 7
B11111,
B00000,
B11111,
B11111,
B00000,
Expand Down Expand Up @@ -233,11 +233,12 @@
};
#endif

LcdProgressBarDouble::LcdProgressBarDouble(LiquidCrystal* lcd, int row, int numCols)
LcdProgressBarDouble::LcdProgressBarDouble(LiquidCrystal* lcd, int row, int numCols, int col)
{
_lcd = lcd;
_numCols = numCols;
_computedNumCols = numCols * 2;
_col = col;
_row = row;

#ifdef LCDPROGRESSBAR_USE_PROGMEM
Expand Down Expand Up @@ -433,7 +434,7 @@ void LcdProgressBarDouble::draw(signed long value1, signed long value2)
Serial.print("#"); Serial.print(i); Serial.print("# Mask:"); Serial.print(mask); Serial.print(", "); Serial.println(m);
#endif

_lcd->setCursor(i / 2, _row);
_lcd->setCursor((i / 2) + _col, _row);
if (mask == 0) {
_lcd->print(' ');
} else {
Expand Down
4 changes: 3 additions & 1 deletion src/LcdProgressBarDouble.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class LcdProgressBarDouble
* @param row Which row to display. 0 is the 1st row, 1 is the second, ...
* @param numCols Number of columns your LCD has (16, 8, ...)
*/
LcdProgressBarDouble(LiquidCrystal* lcd, int row = 0, int numCols = 16);
LcdProgressBarDouble(LiquidCrystal* lcd, int row = 0, int numCols = 16, int col = 0);


/**
Expand Down Expand Up @@ -148,6 +148,8 @@ class LcdProgressBarDouble
int _computedNumCols = 0;
//-- Which row to display. 0 is the 1st row, 1 is the second, ...
int _row = 0;
//-- Which column to display. 0 is the 1st column, 1 is the second, ...
int _col = 0;
//-- Which position is the progress bar: optimization purpose only; refresh LCD only on change
byte _previousProgressPos[2] = {0xFF, 0xFF};

Expand Down