Skip to content

Commit 20df89c

Browse files
committed
Rename class (LCDPBMFrame->PBMFrame) and others members.
1 parent e2c3e6c commit 20df89c

File tree

2 files changed

+47
-39
lines changed

2 files changed

+47
-39
lines changed

src/bin/daemon/LCDPlugins/LCDPlugin.cpp

Lines changed: 38 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,16 @@ using namespace NSGKUtils;
3232

3333
/* -- -- -- */
3434

35-
const bool LCDPBMFrame::switchToNextFrame(const uint16_t currentFrameCounter)
35+
PBMFrame::PBMFrame(const uint16_t num)
36+
: _numFrames(num)
3637
{
37-
return (currentFrameCounter >= _frameCounter);
38+
/* initialize PBM frame container */
39+
_PBMData.resize( (PBM_WIDTH / 8) * PBM_HEIGHT, 0 );
40+
}
41+
42+
const bool PBMFrame::switchToNextFrame(const uint16_t currentFrameCounter)
43+
{
44+
return (currentFrameCounter >= _numFrames);
3845
}
3946

4047
/* -- -- -- */
@@ -43,8 +50,8 @@ LCDPlugin::LCDPlugin()
4350
: _pluginTempo(LCDPluginTempo::TEMPO_DEFAULT),
4451
_initialized(false),
4552
_everLocked(false),
46-
_frameCounter(0),
47-
_frameIndex(0)
53+
_PBMFrameCounter(0),
54+
_PBMFrameIndex(0)
4855
{
4956
}
5057

@@ -72,7 +79,7 @@ const bool LCDPlugin::isInitialized(void) const
7279

7380
void LCDPlugin::resetPBMFrameIndex(void)
7481
{
75-
_itCurrentFrame = _PBMFrames.end();
82+
_itCurrentPBMFrame = _PBMFrames.end();
7683
this->checkPBMFrameIndex(); /* may throw */
7784
}
7885

@@ -106,14 +113,17 @@ void LCDPlugin::prepareNextPBMFrame(void)
106113
{
107114
/* update internal frame counter and iterator to allow the plugin
108115
* to have multiples PBM loaded and simulate animation */
109-
if( (*_itCurrentFrame).switchToNextFrame(_frameCounter) ) {
110-
_itCurrentFrame++;
116+
if( (*_itCurrentPBMFrame).switchToNextFrame(_PBMFrameCounter) ) {
117+
_itCurrentPBMFrame++;
111118
this->checkPBMFrameIndex(); /* may throw */
112-
_frameIndex = (_itCurrentFrame - _PBMFrames.begin());
113-
_frameCounter = 0;
119+
_PBMFrameIndex = (_itCurrentPBMFrame - _PBMFrames.begin());
120+
_PBMFrameCounter = 0;
114121
}
115122

116-
_frameCounter++; /* for next call */
123+
_PBMFrameCounter++; /* for next call */
124+
#if DEBUGGING_ON && DEBUG_LCD_PLUGINS
125+
LOG(DEBUG2) << this->getPluginName() << " - frameCount #" << _PBMFrameCounter;
126+
#endif
117127
}
118128

119129
void LCDPlugin::init(FontsManager* const pFonts, const std::string & product)
@@ -172,22 +182,23 @@ void LCDPlugin::addPBMClearedFrame(
172182
_PBMFrames.emplace_back(num);
173183
}
174184
catch (const std::exception & e) {
175-
LOG(ERROR) << "LCDPBMFrame constructor vector resize exception ?";
185+
LOG(ERROR) << "PBMFrame constructor vector resize exception ?";
176186
throw GLogiKExcept("initializing PBM frame failure");
177187
}
178188
}
179189

180190
const uint16_t LCDPlugin::getNextPBMFrameID(void) const
181191
{
182-
return _frameIndex;
192+
return _PBMFrameIndex;
183193
}
184194

185195
PBMDataArray & LCDPlugin::getCurrentPBMFrame(void)
186196
{
187197
#if DEBUGGING_ON && DEBUG_LCD_PLUGINS
188-
LOG(DEBUG3) << this->getPluginName() << " PBM # " << _frameIndex;
198+
LOG(DEBUG2) << this->getPluginName()
199+
<< " - PBMFrameindex: " << _PBMFrameIndex;
189200
#endif
190-
return (*_itCurrentFrame)._PBMData;
201+
return (*_itCurrentPBMFrame)._PBMData;
191202
}
192203

193204
void LCDPlugin::writeStringOnFrame(
@@ -199,7 +210,9 @@ void LCDPlugin::writeStringOnFrame(
199210
{
200211
try {
201212
#if DEBUGGING_ON && DEBUG_LCD_PLUGINS
202-
LOG(DEBUG2) << this->getPluginName() << " PBM # " << _frameIndex << " - writing string : " << string;
213+
LOG(DEBUG2) << this->getPluginName()
214+
<< " - PBMFrameindex: " << _PBMFrameIndex
215+
<< " - writing string : " << string;
203216
#endif
204217
uint16_t XPos, YPos = 0;
205218

@@ -213,7 +226,7 @@ void LCDPlugin::writeStringOnFrame(
213226

214227
for(const char & c : string) {
215228
const std::string character(1, c);
216-
pFonts->printCharacterOnFrame( fontID, (*_itCurrentFrame)._PBMData, character, XPos, YPos );
229+
pFonts->printCharacterOnFrame( fontID, (*_itCurrentPBMFrame)._PBMData, character, XPos, YPos );
217230
} /* for each character in the string */
218231
}
219232
catch (const GLogiKExcept & e) {
@@ -231,8 +244,8 @@ void LCDPlugin::writeStringOnLastFrame(
231244
try {
232245
if( _PBMFrames.empty() )
233246
throw GLogiKExcept("accessing last element on empty container");
234-
_itCurrentFrame = --(_PBMFrames.end());
235-
_frameIndex = (_itCurrentFrame - _PBMFrames.begin());
247+
_itCurrentPBMFrame = --(_PBMFrames.end());
248+
_PBMFrameIndex = (_itCurrentPBMFrame - _PBMFrames.begin());
236249

237250
this->writeStringOnFrame(pFonts, fontID, string, PBMXPos, PBMYPos);
238251
}
@@ -257,7 +270,7 @@ void LCDPlugin::drawProgressBarOnFrame(
257270
}
258271

259272
try {
260-
PBMDataArray & frame = (*_itCurrentFrame)._PBMData;
273+
PBMDataArray & frame = (*_itCurrentPBMFrame)._PBMData;
261274

262275
auto drawHorizontalLine = [&frame] (const uint16_t index) -> void
263276
{
@@ -354,7 +367,7 @@ void LCDPlugin::drawPadlockOnFrame(
354367
const uint16_t xByte = PBMXPos / 8;
355368
const uint16_t index = (PBM_WIDTH_IN_BYTES * PBMYPos) + xByte;
356369

357-
PBMDataArray & frame = (*_itCurrentFrame)._PBMData;
370+
PBMDataArray & frame = (*_itCurrentPBMFrame)._PBMData;
358371

359372
if( lockedPlugin ) {
360373
_everLocked = true;
@@ -402,14 +415,14 @@ void LCDPlugin::resetEverLocked(void)
402415

403416
void LCDPlugin::checkPBMFrameIndex(void)
404417
{
405-
if( _itCurrentFrame == _PBMFrames.end() ) {
406-
_itCurrentFrame = _PBMFrames.begin();
418+
if( _itCurrentPBMFrame == _PBMFrames.end() ) {
419+
_itCurrentPBMFrame = _PBMFrames.begin();
407420

408-
if( _itCurrentFrame == _PBMFrames.end() )
421+
if( _itCurrentPBMFrame == _PBMFrames.end() )
409422
throw GLogiKExcept("plugin frame iterator exception");
410423

411-
_frameCounter = 0;
412-
_frameIndex = 0;
424+
_PBMFrameCounter = 0;
425+
_PBMFrameIndex = 0;
413426
}
414427
}
415428

src/bin/daemon/LCDPlugins/LCDPlugin.hpp

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,12 @@ enum class LCDPluginTempo : uint8_t
4848
TEMPO_400_15,
4949
};
5050

51-
class LCDPBMFrame
51+
class PBMFrame
5252
{
5353
public:
54-
LCDPBMFrame(const uint16_t i)
55-
: _frameCounter(i)
56-
{
57-
/* initialize LCD PBM container */
58-
_PBMData.resize( (PBM_WIDTH / 8) * PBM_HEIGHT, 0 );
59-
}
60-
LCDPBMFrame(void) = delete;
61-
~LCDPBMFrame() = default;
54+
PBMFrame(const uint16_t num);
55+
PBMFrame(void) = delete;
56+
~PBMFrame() = default;
6257

6358
PBMDataArray _PBMData;
6459

@@ -67,7 +62,7 @@ class LCDPBMFrame
6762
protected:
6863

6964
private:
70-
const uint16_t _frameCounter;
65+
const uint16_t _numFrames;
7166

7267
};
7368

@@ -148,10 +143,10 @@ class LCDPlugin
148143
private:
149144
bool _initialized;
150145
bool _everLocked;
151-
uint16_t _frameCounter; /* frame counter */
152-
uint16_t _frameIndex; /* frame index in the container */
153-
std::vector<LCDPBMFrame> _PBMFrames;
154-
std::vector<LCDPBMFrame>::iterator _itCurrentFrame;
146+
uint16_t _PBMFrameCounter; /* frame counter */
147+
uint16_t _PBMFrameIndex; /* frame index in the container */
148+
std::vector<PBMFrame> _PBMFrames;
149+
std::vector<PBMFrame>::iterator _itCurrentPBMFrame;
155150

156151
void checkPBMFrameIndex(void);
157152
static std::tuple<uint16_t, uint16_t> getTempo(const LCDPluginTempo tempo);

0 commit comments

Comments
 (0)