scroll speed added
This commit is contained in:
parent
dbbe037f06
commit
4536b09801
2 changed files with 29 additions and 18 deletions
|
@ -27,16 +27,12 @@ public:
|
|||
|
||||
this->matrix = matrix;
|
||||
this->matrix->Begin();
|
||||
|
||||
//this->matrix->setRemapFunction(&remap);
|
||||
this->matrix->setTextWrap(false);
|
||||
this->matrix->SetBrightness(40);
|
||||
|
||||
|
||||
text_curr_nr = 0;
|
||||
text_set_starttime = 0;
|
||||
text_pass = 0;
|
||||
textpixel = 0;
|
||||
disp_brightness = 5;
|
||||
disp_show = false;
|
||||
|
||||
this->disp_init();
|
||||
|
@ -106,8 +102,10 @@ private:
|
|||
int text_pos;
|
||||
unsigned int text_pass;
|
||||
unsigned int textpixel;
|
||||
int disp_brightness;
|
||||
bool disp_show;
|
||||
long last_display_show_ms;
|
||||
uint8_t default_display_show_wait_ms;
|
||||
uint8_t display_show_wait_ms;
|
||||
|
||||
// matrix control
|
||||
//uint16_t remap(uint16_t x, uint16_t y);
|
||||
|
@ -133,11 +131,12 @@ private:
|
|||
typedef struct sets_t
|
||||
{
|
||||
text_set_t sets[maximumTextSets];
|
||||
int disp_brightness;
|
||||
char valid[3];
|
||||
} sets_t;
|
||||
|
||||
// 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;
|
||||
|
||||
// storage control
|
||||
|
|
|
@ -53,14 +53,14 @@ LedDisplayController::GetSetTextSetParameterExitCode LedDisplayController::setTe
|
|||
|
||||
int LedDisplayController::getBrightness()
|
||||
{
|
||||
return this->disp_brightness;
|
||||
return this->text_sets.disp_brightness;
|
||||
}
|
||||
|
||||
bool LedDisplayController::setBrightness(int brightness)
|
||||
{
|
||||
if (brightness < 0 || brightness > 10)
|
||||
if (brightness < 0 || brightness > 255)
|
||||
return false;
|
||||
this->disp_brightness = brightness;
|
||||
this->text_sets.disp_brightness = brightness;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -75,6 +75,9 @@ void LedDisplayController::disp_init()
|
|||
text_pass = 0;
|
||||
text_pos = this->matrix->width();
|
||||
disp_show = true;
|
||||
last_display_show_ms = 0;
|
||||
default_display_show_wait_ms = 200;
|
||||
display_show_wait_ms = 100;
|
||||
}
|
||||
|
||||
void LedDisplayController::disp_start_set()
|
||||
|
@ -124,21 +127,29 @@ void LedDisplayController::disp_start_set()
|
|||
|
||||
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);
|
||||
(int)text_pos--;
|
||||
if (int(text_pos + textpixel) < 0)
|
||||
|
||||
if(millis() - last_display_show_ms > display_show_wait_ms)
|
||||
{
|
||||
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);
|
||||
|
||||
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);
|
||||
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)
|
||||
{
|
||||
//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->setCursor(pos, 0);
|
||||
this->matrix->print(text);
|
||||
|
@ -330,6 +341,7 @@ bool LedDisplayController::loadTextSets()
|
|||
}
|
||||
|
||||
memcpy(&text_sets, &defaultTextSets, sizeof(sets_t));
|
||||
text_sets.disp_brightness = 100;
|
||||
return this->storeTextSets();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue