@@ -32,9 +32,16 @@ using namespace NSGKUtils;
32
32
33
33
/* -- -- -- */
34
34
35
- const bool LCDPBMFrame::switchToNextFrame (const uint16_t currentFrameCounter)
35
+ PBMFrame::PBMFrame (const uint16_t num)
36
+ : _numFrames(num)
36
37
{
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);
38
45
}
39
46
40
47
/* -- -- -- */
@@ -43,8 +50,8 @@ LCDPlugin::LCDPlugin()
43
50
: _pluginTempo(LCDPluginTempo::TEMPO_DEFAULT),
44
51
_initialized (false ),
45
52
_everLocked(false ),
46
- _frameCounter (0 ),
47
- _frameIndex (0 )
53
+ _PBMFrameCounter (0 ),
54
+ _PBMFrameIndex (0 )
48
55
{
49
56
}
50
57
@@ -72,7 +79,7 @@ const bool LCDPlugin::isInitialized(void) const
72
79
73
80
void LCDPlugin::resetPBMFrameIndex (void )
74
81
{
75
- _itCurrentFrame = _PBMFrames.end ();
82
+ _itCurrentPBMFrame = _PBMFrames.end ();
76
83
this ->checkPBMFrameIndex (); /* may throw */
77
84
}
78
85
@@ -106,14 +113,17 @@ void LCDPlugin::prepareNextPBMFrame(void)
106
113
{
107
114
/* update internal frame counter and iterator to allow the plugin
108
115
* to have multiples PBM loaded and simulate animation */
109
- if ( (*_itCurrentFrame ).switchToNextFrame (_frameCounter ) ) {
110
- _itCurrentFrame ++;
116
+ if ( (*_itCurrentPBMFrame ).switchToNextFrame (_PBMFrameCounter ) ) {
117
+ _itCurrentPBMFrame ++;
111
118
this ->checkPBMFrameIndex (); /* may throw */
112
- _frameIndex = (_itCurrentFrame - _PBMFrames.begin ());
113
- _frameCounter = 0 ;
119
+ _PBMFrameIndex = (_itCurrentPBMFrame - _PBMFrames.begin ());
120
+ _PBMFrameCounter = 0 ;
114
121
}
115
122
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
117
127
}
118
128
119
129
void LCDPlugin::init (FontsManager* const pFonts, const std::string & product)
@@ -172,22 +182,23 @@ void LCDPlugin::addPBMClearedFrame(
172
182
_PBMFrames.emplace_back (num);
173
183
}
174
184
catch (const std::exception & e) {
175
- LOG (ERROR) << " LCDPBMFrame constructor vector resize exception ?" ;
185
+ LOG (ERROR) << " PBMFrame constructor vector resize exception ?" ;
176
186
throw GLogiKExcept (" initializing PBM frame failure" );
177
187
}
178
188
}
179
189
180
190
const uint16_t LCDPlugin::getNextPBMFrameID (void ) const
181
191
{
182
- return _frameIndex ;
192
+ return _PBMFrameIndex ;
183
193
}
184
194
185
195
PBMDataArray & LCDPlugin::getCurrentPBMFrame (void )
186
196
{
187
197
#if DEBUGGING_ON && DEBUG_LCD_PLUGINS
188
- LOG (DEBUG3) << this ->getPluginName () << " PBM # " << _frameIndex;
198
+ LOG (DEBUG2) << this ->getPluginName ()
199
+ << " - PBMFrameindex: " << _PBMFrameIndex;
189
200
#endif
190
- return (*_itCurrentFrame )._PBMData ;
201
+ return (*_itCurrentPBMFrame )._PBMData ;
191
202
}
192
203
193
204
void LCDPlugin::writeStringOnFrame (
@@ -199,7 +210,9 @@ void LCDPlugin::writeStringOnFrame(
199
210
{
200
211
try {
201
212
#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;
203
216
#endif
204
217
uint16_t XPos, YPos = 0 ;
205
218
@@ -213,7 +226,7 @@ void LCDPlugin::writeStringOnFrame(
213
226
214
227
for (const char & c : string) {
215
228
const std::string character (1 , c);
216
- pFonts->printCharacterOnFrame ( fontID, (*_itCurrentFrame )._PBMData , character, XPos, YPos );
229
+ pFonts->printCharacterOnFrame ( fontID, (*_itCurrentPBMFrame )._PBMData , character, XPos, YPos );
217
230
} /* for each character in the string */
218
231
}
219
232
catch (const GLogiKExcept & e) {
@@ -231,8 +244,8 @@ void LCDPlugin::writeStringOnLastFrame(
231
244
try {
232
245
if ( _PBMFrames.empty () )
233
246
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 ());
236
249
237
250
this ->writeStringOnFrame (pFonts, fontID, string, PBMXPos, PBMYPos);
238
251
}
@@ -257,7 +270,7 @@ void LCDPlugin::drawProgressBarOnFrame(
257
270
}
258
271
259
272
try {
260
- PBMDataArray & frame = (*_itCurrentFrame )._PBMData ;
273
+ PBMDataArray & frame = (*_itCurrentPBMFrame )._PBMData ;
261
274
262
275
auto drawHorizontalLine = [&frame] (const uint16_t index) -> void
263
276
{
@@ -354,7 +367,7 @@ void LCDPlugin::drawPadlockOnFrame(
354
367
const uint16_t xByte = PBMXPos / 8 ;
355
368
const uint16_t index = (PBM_WIDTH_IN_BYTES * PBMYPos) + xByte;
356
369
357
- PBMDataArray & frame = (*_itCurrentFrame )._PBMData ;
370
+ PBMDataArray & frame = (*_itCurrentPBMFrame )._PBMData ;
358
371
359
372
if ( lockedPlugin ) {
360
373
_everLocked = true ;
@@ -402,14 +415,14 @@ void LCDPlugin::resetEverLocked(void)
402
415
403
416
void LCDPlugin::checkPBMFrameIndex (void )
404
417
{
405
- if ( _itCurrentFrame == _PBMFrames.end () ) {
406
- _itCurrentFrame = _PBMFrames.begin ();
418
+ if ( _itCurrentPBMFrame == _PBMFrames.end () ) {
419
+ _itCurrentPBMFrame = _PBMFrames.begin ();
407
420
408
- if ( _itCurrentFrame == _PBMFrames.end () )
421
+ if ( _itCurrentPBMFrame == _PBMFrames.end () )
409
422
throw GLogiKExcept (" plugin frame iterator exception" );
410
423
411
- _frameCounter = 0 ;
412
- _frameIndex = 0 ;
424
+ _PBMFrameCounter = 0 ;
425
+ _PBMFrameIndex = 0 ;
413
426
}
414
427
}
415
428
0 commit comments