Skip to content

Commit 0f95029

Browse files
committed
LCDDataArray is now a vector.
1 parent d450363 commit 0f95029

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

src/bin/daemon/LCDPlugins/LCDPlugin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ PBMFrame::PBMFrame(const uint16_t num)
3636
: _numFrames(num)
3737
{
3838
/* initialize PBM frame container */
39-
_PBMData.resize( (DEFAULT_PBM_WIDTH / 8) * DEFAULT_PBM_HEIGHT, 0 );
39+
_PBMData.resize( DEFAULT_PBM_DATA_IN_BYTES, 0 );
4040
}
4141

4242
const bool PBMFrame::switchToNextFrame(const uint16_t currentFrameCounter)

src/bin/daemon/LCDPlugins/PBM.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
#ifndef SRC_BIN_DAEMON_LCDPLUGINS_PBM_HPP_
2323
#define SRC_BIN_DAEMON_LCDPLUGINS_PBM_HPP_
2424

25-
#include <array>
2625
#include <vector>
2726

27+
/* LCD screen real sizes in pixels */
2828
#define LCD_SCREEN_HEIGHT 43
2929
#define LCD_SCREEN_WIDTH 160
3030

@@ -33,10 +33,10 @@
3333
#define DEFAULT_PBM_HEIGHT_IN_BYTES (DEFAULT_PBM_HEIGHT/8)
3434
#define DEFAULT_PBM_WIDTH_IN_BYTES (DEFAULT_PBM_WIDTH/8)
3535

36-
#define PBM_DATA_IN_BYTES (DEFAULT_PBM_WIDTH_IN_BYTES * DEFAULT_PBM_HEIGHT)
36+
#define DEFAULT_PBM_DATA_IN_BYTES (DEFAULT_PBM_WIDTH_IN_BYTES * DEFAULT_PBM_HEIGHT)
3737

3838
/* LCD header length */
39-
#define LCD_BUFFER_OFFSET 32
39+
#define LCD_DATA_HEADER_OFFSET 32
4040

4141
// formula when PBM_HEIGHT not multiple of 8
4242
// TODO do we need it ?
@@ -46,7 +46,7 @@ namespace GLogiK
4646
{
4747

4848
typedef std::vector<unsigned char> PBMDataArray;
49-
typedef std::array<unsigned char, PBM_DATA_IN_BYTES+LCD_BUFFER_OFFSET> LCDDataArray;
49+
typedef std::vector<unsigned char> LCDDataArray;
5050

5151
} // namespace GLogiK
5252

src/bin/daemon/LCDScreenPluginsManager.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
*
2020
*/
2121

22+
#include <algorithm>
2223
#include <new>
2324

2425
#include "lib/utils/utils.hpp"
@@ -87,7 +88,9 @@ LCDScreenPluginsManager::LCDScreenPluginsManager(const std::string & product)
8788
GKSysLog(LOG_WARNING, WARNING, "no LCD screen plugin initialized");
8889
_noPlugins = true;
8990
}
90-
_LCDBuffer.fill(0x0);
91+
92+
/* initialize LCD frame container */
93+
_LCDBuffer.resize( DEFAULT_PBM_DATA_IN_BYTES + LCD_DATA_HEADER_OFFSET, 0 );
9194
}
9295

9396
LCDScreenPluginsManager::~LCDScreenPluginsManager() {
@@ -224,15 +227,17 @@ LCDDataArray & LCDScreenPluginsManager::getNextLCDScreenBuffer(
224227
(*_itCurrentPlugin)->getNextPBMFrame(_pFonts, LCDKey, _currentPluginLocked)
225228
);
226229
}
227-
else /* else blank screen */
228-
_LCDBuffer.fill(0x0);
230+
else {
231+
/* blank screen */
232+
std::fill(_LCDBuffer.begin(), _LCDBuffer.end(), 0x0);
233+
}
229234
}
230235
catch (const GLogiKExcept & e) {
231236
LOG(ERROR) << e.what();
232-
_LCDBuffer.fill(0x0);
237+
std::fill(_LCDBuffer.begin(), _LCDBuffer.end(), 0x0);
233238
}
234239

235-
std::fill_n(_LCDBuffer.begin(), LCD_BUFFER_OFFSET, 0);
240+
std::fill_n(_LCDBuffer.begin(), LCD_DATA_HEADER_OFFSET, 0x0);
236241
}
237242

238243
/* the keyboard needs this magic byte */
@@ -323,7 +328,7 @@ void LCDScreenPluginsManager::dumpPBMDataIntoLCDBuffer(LCDDataArray & LCDBuffer,
323328
<< " bit: " << bit << "\n";
324329
#endif
325330

326-
LCDBuffer[LCD_BUFFER_OFFSET + LCDCol + indexOffset] =
331+
LCDBuffer[LCD_DATA_HEADER_OFFSET + LCDCol + indexOffset] =
327332
(((PBMData[PBMByte + (DEFAULT_PBM_WIDTH_IN_BYTES * 0) + indexOffset] >> bit) & 1) << 0 ) |
328333
(((PBMData[PBMByte + (DEFAULT_PBM_WIDTH_IN_BYTES * 1) + indexOffset] >> bit) & 1) << 1 ) |
329334
(((PBMData[PBMByte + (DEFAULT_PBM_WIDTH_IN_BYTES * 2) + indexOffset] >> bit) & 1) << 2 ) |

0 commit comments

Comments
 (0)