diff --git a/README.md b/README.md index 312614a..c134285 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/LcdProgressBarDouble.cpp b/src/LcdProgressBarDouble.cpp index f2e4935..1ad9a14 100644 --- a/src/LcdProgressBarDouble.cpp +++ b/src/LcdProgressBarDouble.cpp @@ -27,7 +27,7 @@ const byte LcdProgressBarDouble::bars[] PROGMEM = { // 0 - B11000, + B00000, B11000, B11000, B00000, @@ -47,7 +47,7 @@ B00000 , // 2 - B11000, + B00000, B11000, B11000, B00000, @@ -57,7 +57,7 @@ B00000 , // 3 - B11111, + B00000, B11111, B11111, B00000, @@ -77,7 +77,7 @@ B00000 , // 5 - B11111, + B00000, B11111, B11111, B00000, @@ -87,7 +87,7 @@ B00000 , // 6 - B11000, + B00000, B11000, B11000, B00000, @@ -97,7 +97,7 @@ B00000 , // 7 - B11111, + B00000, B11111, B11111, B00000, @@ -110,7 +110,7 @@ byte LcdProgressBarDouble::bars[8][8] = { { // 0 - B11000, + B00000, B11000, B11000, B00000, @@ -130,7 +130,7 @@ B00000 }, { // 2 - B11000, + B00000, B11000, B11000, B00000, @@ -140,7 +140,7 @@ B00000 }, { // 3 - B11111, + B00000, B11111, B11111, B00000, @@ -160,7 +160,7 @@ B00000 }, { // 5 - B11111, + B00000, B11111, B11111, B00000, @@ -170,7 +170,7 @@ B00000 }, { // 6 - B11000, + B00000, B11000, B11000, B00000, @@ -180,7 +180,7 @@ B00000 }, { // 7 - B11111, + B00000, B11111, B11111, B00000, @@ -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 @@ -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 { diff --git a/src/LcdProgressBarDouble.h b/src/LcdProgressBarDouble.h index 2f8d047..0bbdc25 100644 --- a/src/LcdProgressBarDouble.h +++ b/src/LcdProgressBarDouble.h @@ -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); /** @@ -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};