KulibinOrsk писал(а): ↑11.12.2019{, 12:02}
- вывести и текст и фигуры различных цветов и в любое место программы
Во первых, не в любое, а на ТЕКУЩУЮ страницу.
KulibinOrsk писал(а): ↑11.12.2019{, 14:13}
support, полагаю что во всех версиях (я проверил на 5.3.0) не работает вывод текста в панель NEXTION в частности NX3224T028-011.
Пытаюсь использовать панель просто как цветной дисплей (очень удобно кстати) и вот с flprog не выводит текст, при этом круги, квадраты разными цветами все отрабатывает.
Вот объясните мне, как чистая панель может вывести текст если в ней нет ШРИФТОВ. Даже в том параметре где Вы указали, отправка текста НА ТЕКУЩУЮ СТРАНИЦУ!
нужно указать ID шрифта, а он заливается ТОЛЬКО из Nextion Editor.
Отправлено спустя 13 минут 35 секунд:
KulibinOrsk писал(а): ↑11.12.2019{, 13:18}
Brand2, Вам что пример из 2-х строчек с флпрог нужен ? Или хотите фот-видео с панелей ?
Ценю Ваш юмор про 2 строчки. Отправка текста HELLO на дисплей, на текущую страницу.
Может Вы 2 блока имели ввиду?
struct _nextionLissenStruct{
char code;
String result;
long number;
};
_nextionLissenStruct _nextionTempLissen;
bool _nextionPaintTXT1_OldStae = 0;
bool _trgrt1 = 0;
bool _trgrt1I = 0;
void setup()
{
Serial2.begin(9600, SERIAL_8N1);
nextionSendCommand("", 2);
nextionSendCommand("page 0", 2);
}
void loop()
{
String _tempVariable_String;
//Плата:1
if (!(0)) { if (_trgrt1I) { _trgrt1 = 0;} else {_trgrt1 = 1; _trgrt1I = 1;} } else {_trgrt1 = 0; _trgrt1I = 0;};
if ( _trgrt1) { if ( ! _nextionPaintTXT1_OldStae) {_nextionPaintTXT1_OldStae = 1 ; _tempVariable_String = String ("xstr ") + String ("0") + String (",") + String ("0") + String (",") + String ("0") + String (",") + String ("0") + String (",") + String ("0") + String (",") + String ("0") + String (",") + String ("0") + String (",") + String ("1") + String (",") + String ("1") + String (",") + String ("1") + String (",\"") + String (" HELLO") + String ("\"");
nextionSendCommand(_tempVariable_String.c_str(), 2);}} else { _nextionPaintTXT1_OldStae = 0; }
}
bool _isTimer(unsigned long startTime, unsigned long period )
{
unsigned long currentTime;
currentTime = millis();
if (currentTime>= startTime) {return (currentTime>=(startTime + period));} else {return (currentTime >=(4294967295-startTime+period));}
}
struct _nextionLissenStruct nextionSendCommand(const char* cmd, byte port )
{
while (Serial2.available()){Serial2.read(); }
Serial2.print(cmd);
Serial2.write(0xFF);
Serial2.write(0xFF);
Serial2.write(0xFF);
return nextionListen(port);
}
struct _nextionLissenStruct nextionListen( byte port )
{
byte _bite;
byte _end = 0xff;
byte cmd[100];
int index = 0;
_nextionLissenStruct temp;
temp.result = "";
temp.code = 'z';
temp.number = 0;
int countEnd = 0;
delay(50);
long startTime = millis();
while(! (countEnd==3)) {
while(Serial2.available()>0){
if(Serial2.available()>0){
_bite = Serial2.read();
cmd[index] = _bite;
index++;
if(_bite == _end){countEnd++;}
if(countEnd == 3){break;}
}}
if(_isTimer(startTime, 100)) {return temp;}
}
switch (cmd[0]) {
case 0x66:
temp.code = 'f';
temp.result = String(cmd[1], DEC);
return temp;
break;
case 0x70:
temp.code = 'p';
for (int i = 1; i < index - 3; i++) {
temp.result += char(cmd);}
return temp;
break;
case 0x71:
temp.code = 'q';
temp.number = uint32_t(cmd[4]) << 24 | uint32_t(cmd[3]) << 16 | uint32_t(cmd[2]) << 8 | uint32_t(cmd[1]);
return temp;
break;
default:
return temp;
break;
}
return temp;
}
int nextionAskPageNamper(byte port)
{
int result;
_nextionLissenStruct temp;
temp = nextionSendCommand("sendme",port);
if((temp.code == 'f')&&(temp.result != "")){result = temp.result.toInt();} else {result = -1;}
return result;
}