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:
|
case CLEAR_ALL:
|
||||||
DeleteLines();
|
DeleteLines();
|
||||||
case RESET_ALL:
|
case RESET_ALL:
|
||||||
_act_setting = _setting;
|
_act_setting.font = _setting.font;
|
||||||
break;
|
break;
|
||||||
case BOLD:
|
case BOLD:
|
||||||
_act_setting.bold = true;
|
_act_setting.font.bold = true;
|
||||||
break;
|
break;
|
||||||
case UNDERLINE:
|
case UNDERLINE:
|
||||||
_act_setting.underline = true;
|
_act_setting.font.underline = true;
|
||||||
break;
|
break;
|
||||||
case REVERSED:
|
case REVERSED:
|
||||||
_act_setting.reversed = true;
|
_act_setting.font.reversed = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -103,18 +103,18 @@ bool Scroller::decodeEscape2Setting(String es)
|
|||||||
sscanf(es.c_str(),e->code,¶m);
|
sscanf(es.c_str(),e->code,¶m);
|
||||||
switch (e->control) {
|
switch (e->control) {
|
||||||
case SPEED:
|
case SPEED:
|
||||||
_act_setting.speed = param;
|
_act_setting.control.speed = param;
|
||||||
break;
|
break;
|
||||||
case TIMEOUT:
|
case TIMEOUT:
|
||||||
_act_setting.timeout = param;
|
_act_setting.control.timeout = param;
|
||||||
break;
|
break;
|
||||||
case LOOPS:
|
case LOOPS:
|
||||||
_act_setting.loops = param;
|
_act_setting.control.loops = param;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (e->tt == eDict_t::COLOR) _act_setting.color = e->color;
|
if (e->tt == eDict_t::COLOR) _act_setting.font.color = e->color;
|
||||||
if (e->tt == eDict_t::BCOLOR) _act_setting.bcolor = e->color;
|
if (e->tt == eDict_t::BCOLOR) _act_setting.font.bcolor = e->color;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
DumpSetting(_act_setting);
|
DumpSetting(_act_setting);
|
||||||
#endif
|
#endif
|
||||||
@@ -123,7 +123,7 @@ bool Scroller::decodeEscape2Setting(String es)
|
|||||||
|
|
||||||
void Scroller::DumpSetting(Setting & s)
|
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)
|
void Scroller::SetMatrix(FastLED_NeoMatrix *matrix)
|
||||||
@@ -178,8 +178,8 @@ void Scroller::Show(int _x,int _y,String line)
|
|||||||
l = ee;
|
l = ee;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
_matrix->setTextColor(Framebuffer_GFX::Color24to16(_act_setting.color));
|
_matrix->setTextColor(Framebuffer_GFX::Color24to16(_act_setting.font.color));
|
||||||
_matrix->setBrightness(_act_setting.brightness);
|
_matrix->setBrightness(_act_setting.font.brightness);
|
||||||
if (l != line.length()) {
|
if (l != line.length()) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
Serial.print(line.charAt(l));
|
Serial.print(line.charAt(l));
|
||||||
@@ -225,21 +225,21 @@ int Scroller::Scroll()
|
|||||||
{
|
{
|
||||||
Show(-_x,_y,line);
|
Show(-_x,_y,line);
|
||||||
if (_x++ == 0) {
|
if (_x++ == 0) {
|
||||||
return _act_setting.timeout/SCROLLER_TICK_TIME;
|
return _act_setting.control.timeout/SCROLLER_TICK_TIME;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return _act_setting.speed/SCROLLER_TICK_TIME;
|
return _act_setting.control.speed/SCROLLER_TICK_TIME;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_lp++;
|
_lp++;
|
||||||
_x = 0;
|
_x = 0;
|
||||||
return _act_setting.timeout/SCROLLER_TICK_TIME;
|
return _act_setting.control.timeout/SCROLLER_TICK_TIME;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Show(_x,_y,line);
|
Show(_x,_y,line);
|
||||||
_lp++;
|
_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;
|
_delayTicks = 50;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TimesScrolled() == _act_setting.loops) {
|
if (TimesScrolled() == _act_setting.control.loops) {
|
||||||
Serial.println("MAX LOOP");
|
Serial.println("MAX LOOP");
|
||||||
TurnOff();
|
TurnOff();
|
||||||
return;
|
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)
|
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.font.color = color;
|
||||||
_act_setting.brightness = brightness;
|
_act_setting.font.brightness = brightness;
|
||||||
_act_setting.timeout = timeout_on;
|
_act_setting.control.timeout = timeout_on;
|
||||||
_act_setting.timeout = timeout_off;
|
_act_setting.control.timeout = timeout_off;
|
||||||
_act_setting.speed = speed;
|
_act_setting.control.speed = speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
Scroller::~Scroller()
|
Scroller::~Scroller()
|
||||||
|
|||||||
@@ -24,15 +24,19 @@ enum {RESET_ALL,CLEAR_ALL, BOLD, UNDERLINE=4,REVERSED=7, SPEED, TIMEOUT, LOOPS};
|
|||||||
|
|
||||||
struct Setting
|
struct Setting
|
||||||
{
|
{
|
||||||
uint8_t loops;
|
struct {
|
||||||
uint32_t color;
|
uint32_t color;
|
||||||
uint32_t bcolor;
|
uint32_t bcolor;
|
||||||
uint8_t brightness;
|
uint8_t brightness;
|
||||||
int timeout;
|
bool underline;
|
||||||
int speed;
|
|
||||||
bool reversed;
|
bool reversed;
|
||||||
bool bold;
|
bool bold;
|
||||||
bool underline;
|
} font;
|
||||||
|
struct {
|
||||||
|
uint8_t loops;
|
||||||
|
int timeout;
|
||||||
|
int speed;
|
||||||
|
} control;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Scroller
|
class Scroller
|
||||||
@@ -41,7 +45,7 @@ private:
|
|||||||
/* data */
|
/* data */
|
||||||
const static int MAX_LINES = 100;
|
const static int MAX_LINES = 100;
|
||||||
String _Lines[MAX_LINES];
|
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
|
Setting _act_setting; // actual setting
|
||||||
int _nlines = 0;
|
int _nlines = 0;
|
||||||
int _lp = 0;
|
int _lp = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user