Do not reset all settings with esc reset_all
This commit is contained in:
@@ -84,16 +84,16 @@ bool Scroller::decodeEscape2Setting(String es)
|
||||
case CLEAR_ALL:
|
||||
DeleteLines();
|
||||
case RESET_ALL:
|
||||
_act_setting = _setting;
|
||||
_act_setting.font = _setting.font;
|
||||
break;
|
||||
case BOLD:
|
||||
_act_setting.bold = true;
|
||||
_act_setting.font.bold = true;
|
||||
break;
|
||||
case UNDERLINE:
|
||||
_act_setting.underline = true;
|
||||
_act_setting.font.underline = true;
|
||||
break;
|
||||
case REVERSED:
|
||||
_act_setting.reversed = true;
|
||||
_act_setting.font.reversed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -103,18 +103,18 @@ bool Scroller::decodeEscape2Setting(String es)
|
||||
sscanf(es.c_str(),e->code,¶m);
|
||||
switch (e->control) {
|
||||
case SPEED:
|
||||
_act_setting.speed = param;
|
||||
_act_setting.control.speed = param;
|
||||
break;
|
||||
case TIMEOUT:
|
||||
_act_setting.timeout = param;
|
||||
_act_setting.control.timeout = param;
|
||||
break;
|
||||
case LOOPS:
|
||||
_act_setting.loops = param;
|
||||
_act_setting.control.loops = param;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (e->tt == eDict_t::COLOR) _act_setting.color = e->color;
|
||||
if (e->tt == eDict_t::BCOLOR) _act_setting.bcolor = e->color;
|
||||
if (e->tt == eDict_t::COLOR) _act_setting.font.color = e->color;
|
||||
if (e->tt == eDict_t::BCOLOR) _act_setting.font.bcolor = e->color;
|
||||
#ifdef DEBUG
|
||||
DumpSetting(_act_setting);
|
||||
#endif
|
||||
@@ -123,7 +123,7 @@ bool Scroller::decodeEscape2Setting(String es)
|
||||
|
||||
void Scroller::DumpSetting(Setting & s)
|
||||
{
|
||||
Serial.printf("[COLOR=%x Brightness=%d Speed=%d Timeout=%d]\n",s.color,s.brightness,s.speed,s.timeout);
|
||||
Serial.printf("[COLOR=%x Brightness=%d Speed=%d Timeout=%d]\n",s.font.color,s.font.brightness,s.control.speed,s.control.timeout);
|
||||
}
|
||||
|
||||
void Scroller::SetMatrix(FastLED_NeoMatrix *matrix)
|
||||
@@ -178,8 +178,8 @@ void Scroller::Show(int _x,int _y,String line)
|
||||
l = ee;
|
||||
continue;
|
||||
}
|
||||
_matrix->setTextColor(Framebuffer_GFX::Color24to16(_act_setting.color));
|
||||
_matrix->setBrightness(_act_setting.brightness);
|
||||
_matrix->setTextColor(Framebuffer_GFX::Color24to16(_act_setting.font.color));
|
||||
_matrix->setBrightness(_act_setting.font.brightness);
|
||||
if (l != line.length()) {
|
||||
#ifdef DEBUG
|
||||
Serial.print(line.charAt(l));
|
||||
@@ -225,21 +225,21 @@ int Scroller::Scroll()
|
||||
{
|
||||
Show(-_x,_y,line);
|
||||
if (_x++ == 0) {
|
||||
return _act_setting.timeout/SCROLLER_TICK_TIME;
|
||||
return _act_setting.control.timeout/SCROLLER_TICK_TIME;
|
||||
}
|
||||
else {
|
||||
return _act_setting.speed/SCROLLER_TICK_TIME;
|
||||
return _act_setting.control.speed/SCROLLER_TICK_TIME;
|
||||
}
|
||||
}
|
||||
_lp++;
|
||||
_x = 0;
|
||||
return _act_setting.timeout/SCROLLER_TICK_TIME;
|
||||
return _act_setting.control.timeout/SCROLLER_TICK_TIME;
|
||||
}
|
||||
else
|
||||
{
|
||||
Show(_x,_y,line);
|
||||
_lp++;
|
||||
return _act_setting.timeout/SCROLLER_TICK_TIME;
|
||||
return _act_setting.control.timeout/SCROLLER_TICK_TIME;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -291,7 +291,7 @@ void Scroller::loop(ulong tick)
|
||||
_delayTicks = 50;
|
||||
}
|
||||
|
||||
if (TimesScrolled() == _act_setting.loops) {
|
||||
if (TimesScrolled() == _act_setting.control.loops) {
|
||||
Serial.println("MAX LOOP");
|
||||
TurnOff();
|
||||
return;
|
||||
@@ -313,11 +313,11 @@ int Scroller::TimesScrolled()
|
||||
|
||||
void Scroller::SetParameters(int line,uint8_t color,uint8_t brightness,int timeout_off,int timeout_on,int speed)
|
||||
{
|
||||
_act_setting.color = color;
|
||||
_act_setting.brightness = brightness;
|
||||
_act_setting.timeout = timeout_on;
|
||||
_act_setting.timeout = timeout_off;
|
||||
_act_setting.speed = speed;
|
||||
_act_setting.font.color = color;
|
||||
_act_setting.font.brightness = brightness;
|
||||
_act_setting.control.timeout = timeout_on;
|
||||
_act_setting.control.timeout = timeout_off;
|
||||
_act_setting.control.speed = speed;
|
||||
}
|
||||
|
||||
Scroller::~Scroller()
|
||||
|
||||
@@ -24,15 +24,19 @@ enum {RESET_ALL,CLEAR_ALL, BOLD, UNDERLINE=4,REVERSED=7, SPEED, TIMEOUT, LOOPS};
|
||||
|
||||
struct Setting
|
||||
{
|
||||
uint8_t loops;
|
||||
uint32_t color;
|
||||
uint32_t bcolor;
|
||||
uint8_t brightness;
|
||||
int timeout;
|
||||
int speed;
|
||||
bool reversed;
|
||||
bool bold;
|
||||
bool underline;
|
||||
struct {
|
||||
uint32_t color;
|
||||
uint32_t bcolor;
|
||||
uint8_t brightness;
|
||||
bool underline;
|
||||
bool reversed;
|
||||
bool bold;
|
||||
} font;
|
||||
struct {
|
||||
uint8_t loops;
|
||||
int timeout;
|
||||
int speed;
|
||||
} control;
|
||||
};
|
||||
|
||||
class Scroller
|
||||
@@ -41,7 +45,7 @@ private:
|
||||
/* data */
|
||||
const static int MAX_LINES = 100;
|
||||
String _Lines[MAX_LINES];
|
||||
Setting _setting = {1, CRGB::Red, CRGB::Black, 10, 3000, 100, false, false, false}; // default setting
|
||||
Setting _setting = { {CRGB::Red, CRGB::Black, 10, false, false, false}, {1,3000,100} }; // default setting
|
||||
Setting _act_setting; // actual setting
|
||||
int _nlines = 0;
|
||||
int _lp = 0;
|
||||
|
||||
Reference in New Issue
Block a user