Fixed som bugs in scrolling ...

This commit is contained in:
Jens Noack 2020-10-18 15:10:20 +02:00
parent 4536b09801
commit 0a3cbdb00e
3 changed files with 60 additions and 15 deletions

View file

@ -98,6 +98,7 @@ private:
// matrix variables
uint16_t text_curr_nr;
uint32_t text_set_starttime;
bool text_no_activ_legal_sets;
int text_pos;
unsigned int text_pass;

View file

@ -78,29 +78,68 @@ void LedDisplayController::disp_init()
last_display_show_ms = 0;
default_display_show_wait_ms = 200;
display_show_wait_ms = 100;
text_no_activ_legal_sets = true;
}
void LedDisplayController::disp_start_set()
{
if ((0 == text_set_starttime) ||
(text_sets.sets[text_curr_nr].text == '\0') ||
text_sets.sets[text_curr_nr].active == false ||
((text_sets.sets[text_curr_nr].scroll == false) && (text_sets.sets[text_curr_nr].runtime > 0) && ((millis() - text_set_starttime) >= text_sets.sets[text_curr_nr].runtime)) ||
((text_sets.sets[text_curr_nr].scroll == true) && (text_sets.sets[text_curr_nr].scrollCount > 0) && (text_pass >= text_sets.sets[text_curr_nr].scrollCount)) ||
(((text_sets.sets[text_curr_nr].scrollCount == 0) || text_sets.sets[text_curr_nr].scroll == false) && (text_sets.sets[text_curr_nr].runtime == 0) && ((millis() - text_set_starttime) >= 10000)))
{
bool legal_entry_setting =
(0 == text_set_starttime) ||
// current entry is not scrolling: maximum of runtime is defined and runtime is over
((text_sets.sets[text_curr_nr].scroll == false) && ((text_sets.sets[text_curr_nr].runtime > 0) && ((millis() - text_set_starttime) >= text_sets.sets[text_curr_nr].runtime))) ||
// current entry is scrolling: but maximum number of scrolls is defined and reached
((text_sets.sets[text_curr_nr].scroll == true) && ((text_sets.sets[text_curr_nr].scrollCount > 0) && (text_pass >= text_sets.sets[text_curr_nr].scrollCount)))
;
bool illegal_entry_settings =
// current entry is not active
(text_sets.sets[text_curr_nr].active == false) ||
// current entry has no text defined
(text_sets.sets[text_curr_nr].text == '\0') ||
// current entry is not scrolling: but no runtime is defined
((text_sets.sets[text_curr_nr].scroll == false) && (text_sets.sets[text_curr_nr].runtime == 0)) ||
// current entry is scrolling: but no scrollnumber defined
((text_sets.sets[text_curr_nr].scroll == true) && (text_sets.sets[text_curr_nr].scrollCount == 0))
;
if (legal_entry_setting || illegal_entry_settings
//(((text_sets.sets[text_curr_nr].scrollCount == 0) || text_sets.sets[text_curr_nr].scroll == false) && (text_sets.sets[text_curr_nr].runtime == 0) ) //&& ((millis() - text_set_starttime) >= 10000))
)
{
//Serial.printf("[%lu] Meet start set condition. Curr set is %d. \n", millis(), text_curr_nr);
if (0 < text_set_starttime || text_sets.sets[text_curr_nr].text == '\0' || text_sets.sets[text_curr_nr].active == false)
if (0 < text_set_starttime ) //|| text_sets.sets[text_curr_nr].text == '\0' || text_sets.sets[text_curr_nr].active == false)
text_curr_nr++;
if (text_curr_nr == maximumTextSets)
text_curr_nr = 0;
text_pass = 0;
if (text_sets.sets[text_curr_nr].text != '\0' && text_sets.sets[text_curr_nr].active == true)
{
text_curr_nr = 0;
if(false == text_no_activ_legal_sets )
{
this->matrix->fillScreen(0);
this->matrix->Show();
}
text_no_activ_legal_sets = false;
}
text_pass = 0;
if (text_sets.sets[text_curr_nr].active &&
(
((text_sets.sets[text_curr_nr].scroll == false) && (text_sets.sets[text_curr_nr].runtime > 0))
|| ((text_sets.sets[text_curr_nr].scroll == true) && (text_sets.sets[text_curr_nr].scrollCount > 0))
)
)
{
text_no_activ_legal_sets = true;
//Serial.printf("[%lu] Set %d. Runtime %d. Text:'%s'\n", millis(), text_curr_nr, text_sets.sets[text_curr_nr].runtime, text_sets.sets[text_curr_nr].text);
this->matrix->fillScreen(0);
textpixel = 6 * strlen(text_sets.sets[text_curr_nr].text);
// scrolling text has always left or right allignment - depending on direction of scroll
if(true == text_sets.sets[text_curr_nr].scroll)
text_sets.sets[text_curr_nr].alignment = AlignRight;
switch (text_sets.sets[text_curr_nr].alignment)
{
case AlignLeft:
@ -133,7 +172,7 @@ void LedDisplayController::disp_scroll_text()
last_display_show_ms = millis();
display_show_wait_ms = ((2*default_display_show_wait_ms)/text_sets.sets[text_curr_nr].scrollSpeed);
Serial.printf("speed %d, waittime: %d' \n", text_sets.sets[text_curr_nr].scrollSpeed, display_show_wait_ms);
//Serial.printf("speed %d, waittime: %d' \n", text_sets.sets[text_curr_nr].scrollSpeed, display_show_wait_ms);
this->matrix->fillScreen(0);
show_matrix(text_sets.sets[text_curr_nr].text, text_pos, text_sets.sets[text_curr_nr].color);
(int)text_pos--;
@ -221,9 +260,10 @@ LedDisplayController::GetSetTextSetParameterExitCode LedDisplayController::getSe
case RuntimeParameter:
if (set)
currentTextSet->runtime = value->toInt();
currentTextSet->runtime = value->toInt()*1000;
else
returnValue = String(currentTextSet->runtime);
returnValue = String(round(currentTextSet->runtime/1000));
//Serial.printf("Runtim is: %d \n", currentTextSet->runtime);
break;
case ColorParameter:
@ -326,7 +366,7 @@ bool LedDisplayController::loadTextSets()
if (strcmp(buf.valid, "OK") == 0)
{
memcpy(&text_sets, &buf, sizeof(sets_t));
Serial.printf("OK: '%s\n", text_sets.sets[0].text);
//Serial.printf("OK: '%s\n", text_sets.sets[0].text);
return true;
}
else

View file

@ -11,6 +11,9 @@
OmobiLedDisplay *display;
///----- Setup of display driver and topology: -------------------------------------------------------------------------
// For detailed information on NeoPixel and NeoTiles etc. - all around display topology setup please see here:
// https://github.com/Makuna/NeoPixelBus/wiki/Matrix-Panels-Support
NeoPixelBrightnessBusGfx<NeoGrbFeature, Neo800KbpsMethod> *displayMatrix = new NeoPixelBrightnessBusGfx<NeoGrbFeature, Neo800KbpsMethod>(MATRIX_PIXEL_WIDTH, MATRIX_PIXEL_HEIGHT, MATRIX_PIN);
NeoTiles <RowMajorLayout, RowMajorLayout> tiles(TILE_PIXEL_COLS, TILE_PIXEL_ROWS, MATRIX_TILES_COL,MATRIX_TILES_ROW);
// use a remap function to remap based on the topology, tile or mosaik
@ -18,6 +21,7 @@ NeoTiles <RowMajorLayout, RowMajorLayout> tiles(TILE_PIXEL_COLS, TILE_PIXEL_ROWS
uint16_t remap(uint16_t x, uint16_t y) {
return tiles.Map(x, y);
}
///--------------------------------------------------------------------------------------------------------------------
void setup()
{