This would need to be done at the LiBCM level... and yes, it's technically possible**, but almost certainly will never happen. A much simpler option is to just have the user press a button to dim the display.Hi Natalya, any chance this could eventually be configured/wired to autodim when headlights are turned on?
The screen itself also has GPIO and could be wired up to the radio harness... as well as another option that would not involve LiBCM itself. You would just have to program the screen to read the GPIO and have an apropriate resistor divider so the 12V doesn't blow up the 3.3v/5V IO.This would need to be done at the LiBCM level... and yes, it's technically possible**, but almost certainly will never happen. A much simpler option is to just have the user press a button to dim the display.
**One concept: Connect a voltage-translated wire from the 12V headlight circuit to a 5V LiBCM GPIO.
Yeah I've never changed it from the UART either... and all the guides say do it from the TFT.38400 Baud achieved. (was 9600) No matter what I tried I could not get LiBCM to change the Nextion's baud rate, so instead I set it in the .tft file for the Nextion. I don't have these uploaded yet; I'll let y'all know when it's all on github.
Future Pegasus integration would let you query the cluster backlight brightness, and you could automatically set the display brightness using thatThis would need to be done at the LiBCM level... and yes, it's technically possible**, but almost certainly will never happen. A much simpler option is to just have the user press a button to dim the display.
**One concept: Connect a voltage-translated wire from the 12V headlight circuit to a 5V LiBCM GPIO.
if (cmd = Serial1.available()) {
Serial.print(F("\nSerial1 cmd_str: "));
Serial.write(cmd);
Serial.print('|');
Serial.print(cmd);
Serial.print('|');
Serial.print(cmd,HEX);
Serial.print(' ');
buffer = Serial1.read();
Serial.write(buffer);
Serial.print('|');
Serial.print(buffer);
Serial.print('|');
Serial.print(buffer,HEX);
Serial.print(' ');
buffer = Serial1.read();
Serial.write(buffer);
Serial.print('|');
Serial.print(buffer);
Serial.print('|');
Serial.print(buffer,HEX);
Serial.print(' ');
buffer = Serial1.read();
Serial.write(buffer);
Serial.print('|');
Serial.print(buffer);
Serial.print('|');
Serial.print(buffer,HEX);
Serial.print(' ');
buffer = Serial1.read();
Serial.write(buffer);
Serial.print('|');
Serial.print(buffer);
Serial.print('|');
Serial.print(buffer,HEX);
Serial.print(' ');
buffer = Serial1.read();
Serial.write(buffer);
Serial.print('|');
Serial.print(buffer);
Serial.print('|');
Serial.print(buffer,HEX);
Serial.print(' ');
buffer = Serial1.read();
Serial.write(buffer);
Serial.print('|');
Serial.print(buffer);
Serial.print('|');
Serial.print(buffer,HEX);
buffer = 0;
}
printh 30 30
Serial1 cmd_str: 0|30|0 0|30|0 �|255|FF �|255|FF �|255|FF �|255|FF �|255|FF
Serial1 cmd_str: |1|1 �|254|FE �|255|FF �|255|FF �|255|FF �|255|FF �|255|FF
if (LiDisplayWaitingForCommand > 0) {
LiDisplayWaitingForCommand -= 1;
}
if (LiDisplayWaitingForCommand == 1) {
LiDisplayWaitingForCommand -= 1;
Serial.print(Serial1.read());
Serial.print(' ');
Serial.print(Serial1.read());
Serial.print(' ');
Serial.print(Serial1.read());
Serial.print(' ');
Serial.print(Serial1.read());
Serial.print(' ');
Serial.print(Serial1.read());
Serial.print(' ');
Serial.print(Serial1.read());
Serial.print(' ');
buffer = 0;
}
if (Serial1.available() && (LiDisplayWaitingForCommand == 0)) {
Serial.print(F("\nSerial1 Available: "));
LiDisplayWaitingForCommand = 100;
}
printh 30 30
Serial1 Available: 0 0 -1 -1 -1 -1
Serial1 Available: 254 -1 -1 -1 -1 -1
You could try putting one of these on each end of the connection. Since you are only going one way, you can tie the enable pins high on one end and low on the other.I cannot get communication from the Nextion to the Arduino to work reliably. I can't tell if the data is being sent wrong from the Nextion, or received wrong by the Arduino. I can't reliably send even two bytes.
Example Arduino code:
Example Nextion code from page p0 button b0 touch release event:Code:if (cmd = Serial1.available()) { Serial.print(F("\nSerial1 cmd_str: ")); Serial.write(cmd); Serial.print('|'); Serial.print(cmd); Serial.print('|'); Serial.print(cmd,HEX); Serial.print(' '); buffer = Serial1.read(); Serial.write(buffer); Serial.print('|'); Serial.print(buffer); Serial.print('|'); Serial.print(buffer,HEX); Serial.print(' '); buffer = Serial1.read(); Serial.write(buffer); Serial.print('|'); Serial.print(buffer); Serial.print('|'); Serial.print(buffer,HEX); Serial.print(' '); buffer = Serial1.read(); Serial.write(buffer); Serial.print('|'); Serial.print(buffer); Serial.print('|'); Serial.print(buffer,HEX); Serial.print(' '); buffer = Serial1.read(); Serial.write(buffer); Serial.print('|'); Serial.print(buffer); Serial.print('|'); Serial.print(buffer,HEX); Serial.print(' '); buffer = Serial1.read(); Serial.write(buffer); Serial.print('|'); Serial.print(buffer); Serial.print('|'); Serial.print(buffer,HEX); Serial.print(' '); buffer = Serial1.read(); Serial.write(buffer); Serial.print('|'); Serial.print(buffer); Serial.print('|'); Serial.print(buffer,HEX); buffer = 0; }
Expected Output:Code:printh 30 30
Actual Output:Code:Serial1 cmd_str: 0|30|0 0|30|0 �|255|FF �|255|FF �|255|FF �|255|FF �|255|FF
I've tried all kinds of permutations, with longer printh chains, but I could only ever get a maximum of 3 bytes back (sometimes) and the rest FF (meaning nothing to read) so I tried a really short one and it still doesn't work.Code:Serial1 cmd_str: |1|1 �|254|FE �|255|FF �|255|FF �|255|FF �|255|FF �|255|FF
I don't know what to try next. But until I can send info from LiDisplay to LiBCM we can't use any buttons on LiDisplay.
The "-1" is what Serial.read() returns if there is no data available. Serial.read() does not wait until data is available.Tried adding a 100ms delay...
Nextion Code:Code:if (LiDisplayWaitingForCommand > 0) { LiDisplayWaitingForCommand -= 1; } if (LiDisplayWaitingForCommand == 1) { LiDisplayWaitingForCommand -= 1; Serial.print(Serial1.read()); Serial.print(' '); Serial.print(Serial1.read()); Serial.print(' '); Serial.print(Serial1.read()); Serial.print(' '); Serial.print(Serial1.read()); Serial.print(' '); Serial.print(Serial1.read()); Serial.print(' '); Serial.print(Serial1.read()); Serial.print(' '); buffer = 0; } if (Serial1.available() && (LiDisplayWaitingForCommand == 0)) { Serial.print(F("\nSerial1 Available: ")); LiDisplayWaitingForCommand = 100; }
Expected Output:Code:printh 30 30
Actual Output:Code:Serial1 Available: 0 0 -1 -1 -1 -1
I'm pretty sure the message is being sent fast enough. It just doesn't show up correctly.Code:Serial1 Available: 254 -1 -1 -1 -1 -1
I thought that's what I was doing here. Are you saying there's a more direct way than to use Serial.print(Serial1.read()) ?You should add code to LiBCM to output the serial data it receives from Nextion via the USB serial port... that'll let you know what LiBCM 'sees'.