scroll speed added

This commit is contained in:
Jens Noack 2020-10-18 00:18:50 +02:00
parent dbbe037f06
commit 4536b09801
2 changed files with 29 additions and 18 deletions

View file

@ -27,16 +27,12 @@ public:
this->matrix = matrix; this->matrix = matrix;
this->matrix->Begin(); this->matrix->Begin();
//this->matrix->setRemapFunction(&remap);
this->matrix->setTextWrap(false); this->matrix->setTextWrap(false);
this->matrix->SetBrightness(40);
text_curr_nr = 0; text_curr_nr = 0;
text_set_starttime = 0; text_set_starttime = 0;
text_pass = 0; text_pass = 0;
textpixel = 0; textpixel = 0;
disp_brightness = 5;
disp_show = false; disp_show = false;
this->disp_init(); this->disp_init();
@ -106,8 +102,10 @@ private:
int text_pos; int text_pos;
unsigned int text_pass; unsigned int text_pass;
unsigned int textpixel; unsigned int textpixel;
int disp_brightness;
bool disp_show; bool disp_show;
long last_display_show_ms;
uint8_t default_display_show_wait_ms;
uint8_t display_show_wait_ms;
// matrix control // matrix control
//uint16_t remap(uint16_t x, uint16_t y); //uint16_t remap(uint16_t x, uint16_t y);
@ -133,11 +131,12 @@ private:
typedef struct sets_t typedef struct sets_t
{ {
text_set_t sets[maximumTextSets]; text_set_t sets[maximumTextSets];
int disp_brightness;
char valid[3]; char valid[3];
} sets_t; } sets_t;
// storage variables // storage variables
const text_set_t defaultTextSet {"Hallo", true, 1000, "", AlignCenter, false, 0, 0}; const text_set_t defaultTextSet {"", false, 0, "", AlignCenter, false, 0, 0};
sets_t text_sets; sets_t text_sets;
// storage control // storage control

View file

@ -53,14 +53,14 @@ LedDisplayController::GetSetTextSetParameterExitCode LedDisplayController::setTe
int LedDisplayController::getBrightness() int LedDisplayController::getBrightness()
{ {
return this->disp_brightness; return this->text_sets.disp_brightness;
} }
bool LedDisplayController::setBrightness(int brightness) bool LedDisplayController::setBrightness(int brightness)
{ {
if (brightness < 0 || brightness > 10) if (brightness < 0 || brightness > 255)
return false; return false;
this->disp_brightness = brightness; this->text_sets.disp_brightness = brightness;
return true; return true;
} }
@ -75,6 +75,9 @@ void LedDisplayController::disp_init()
text_pass = 0; text_pass = 0;
text_pos = this->matrix->width(); text_pos = this->matrix->width();
disp_show = true; disp_show = true;
last_display_show_ms = 0;
default_display_show_wait_ms = 200;
display_show_wait_ms = 100;
} }
void LedDisplayController::disp_start_set() void LedDisplayController::disp_start_set()
@ -124,21 +127,29 @@ void LedDisplayController::disp_start_set()
void LedDisplayController::disp_scroll_text() void LedDisplayController::disp_scroll_text()
{ {
this->matrix->fillScreen(0);
show_matrix(text_sets.sets[text_curr_nr].text, text_pos, text_sets.sets[text_curr_nr].color); if(millis() - last_display_show_ms > display_show_wait_ms)
(int)text_pos--;
if (int(text_pos + textpixel) < 0)
{ {
text_pos = this->matrix->width();
text_pass++; last_display_show_ms = millis();
//Serial.printf("Pass[%d] - set nr %d, Text: '%s' \n", text_pass, text_curr_nr, text_sets.sets[text_curr_nr].text); 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);
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--;
if (int(text_pos + textpixel) < 0)
{
text_pos = this->matrix->width();
text_pass++;
//Serial.printf("Pass[%d] - set nr %d, Text: '%s' \n", text_pass, text_curr_nr, text_sets.sets[text_curr_nr].text);
}
} }
delay(100);
} }
void LedDisplayController::show_matrix(const char *text, int pos, const char *color) void LedDisplayController::show_matrix(const char *text, int pos, const char *color)
{ {
//Serial.printf("TEXT: %s (pos=%d, color=%d)\n", text, pos, this->colorFromHex(String(color))); //Serial.printf("TEXT: %s (pos=%d, color=%d)\n", text, pos, this->colorFromHex(String(color)));
this->matrix->SetBrightness(this->text_sets.disp_brightness);
this->matrix->setTextColor(this->colorFromHex(String(color))); this->matrix->setTextColor(this->colorFromHex(String(color)));
this->matrix->setCursor(pos, 0); this->matrix->setCursor(pos, 0);
this->matrix->print(text); this->matrix->print(text);
@ -330,6 +341,7 @@ bool LedDisplayController::loadTextSets()
} }
memcpy(&text_sets, &defaultTextSets, sizeof(sets_t)); memcpy(&text_sets, &defaultTextSets, sizeof(sets_t));
text_sets.disp_brightness = 100;
return this->storeTextSets(); return this->storeTextSets();
} }
} }