Start a new topic

How to send special characters with .setText()

 Hello all,


i realy like the Nextion Displays and found a lot informations/tips here.


But there is still one big point i did not get.


How do i send from i.e. Arduino special characters to the Nextion to show the text?


Lets say i want to Send a percent sign "%".

t0.setText("%"); does not work

The same for characters like ä,ö,ü


Standard text works perfect but please help me to find the solution to send the special characters.

The Device can show it, in debug it works but not over serial.


Thank you very much.


Nextion is used with many many programming languages.

Checking your compiler (in your case Arduino.cc) will sure hold your answer

Thanks, not the help i was looking for.

I thought the library is made for Arduino so it should be standard compiler with Arduino IDE.
Thats why i asked here.
Sorry that my hope was to find help here.

 


this is the Nextion forum, sorry ...


in general


Nextion Questions - Nextion Forum ...

Arduino Questions - Arduino Forum ...

Ok but is it not a Nextion question when i ask for help with the "Nextion Library" to send special characters with "Nextion Function" .setText() to "Nextion Device"?

I know that you can't help all the noobs as i am one, but i am sure when i go to the Arduino Forum and ask for help with the Nextion Library and Device they will say, go to Nextion Forum because it is their Library :)


does the code run on Nextions STM or on your Arduino? Only because it remotes a Nextion won't make it Nextion code, sorry ...

therefore questions about this code are Arduino related, because that's the target you run it ...

even the library is provided for Nextions, it is still Arduino code, not?



 

Ahhh so you don't know how to form your question at Arduino.

So you look in your NexText.h file

 - check the .setText function's parameter - it is of type char


Should now be easy to ask at Arduino

 How do I send special characters (ie: % ä,ö,ü) as type char.


And here is the reason you should ask over there.

- knowing where to look is the path to your fastest answers.

- knowing what you are looking for even helps you search


If you have a plumbing issue

 - it makes sense to .... ask at a plumbing or hardware store

Does it make sense to ask at a Grocery Store

  only because their store also has a toilet using water?


You Question isn't a Nextion Question per se

 - it is more specific to language and compiler - Arduino C++

If you were forced to write it in mikroC

  - they may handle it differently, so mikroe forums.


At a plumbing and hardware store, 72% may know your answer but plumbers

don't normally visit grocers just to see if patrons have a plumbing question.


The ItealLib Arduino Nextion Library not only came with source code

 - but it had a folder full of examples, and if your answer is not in there

well, now you see why I suggested - (Arduino.cc) your compiler's forum.


I don't know arduino, but on the off chance that behind the arduino code is something like printf, in which a % within quotes has special meaning, have you tried "escaping" the character with a backslash?


t0.setText("\%");

maybe, but as far as I know .. maybe wrong, but

I think \r and \" is all that Nextion catches currently with escape sequences

0x23 Return Codes for invalid escapes ...


Best the user checks the Arduino site for

@Itsmeagain


There could be an issue with your Nextion font, in which case the problem is Nextion!


Other than that, run this very simple sketch on your Arduino and note the output in the Serial Monitor

note the baud is 115200. Then go figure.....


  

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  Serial.println();

  Serial.println("\x25\x2c\xe4\x2c\xeb\x2c\xfc\x2e");
     Serial.println("\x54\x68\x65\x20\x71\x75\x69\x63\x6b\x20\x62\x72\x6f\x77\x6e\x20\x66\x6f\x78\x20\x6a\x75\x6d\x70\x73\x20\x6f\x76\x65\x72\x20\x74\x68\x65\x20\x6c\x61\x7a\x79\x20\x64\x6f\x67");

uint8_t tabCount = 0;

  for (int i = 32; i < 256; i++) {
    Serial.print("  |  ");
    Serial.write(i);
    tabCount++;
    if (tabCount == 4) {
      Serial.println();
      tabCount = 0;
    }
    delay(20);
  }
}

void loop() {
  // put your main code here, to run repeatedly:

}

  


1 person likes this

I can't classify a font issue for such as a Nextion problem.


Perhaps user doesn't understand their selected iso-8859-X

but this is well documented should a user search for what iso-8859 is


Nextion Font generator will generate the font according to select iso-8859 the HMI is encoded for.  As such if we say the normal user uses the default iso-8859-1, Generator will encode for iso-8859-1.  The user would have had to actively make a change for.  As such, I am not sure if it is deemed a Nextion "problem"


 if there is something wrong or missing in the font, that's a font issue and not a Nextion issue.


    - ZI fonts are generated by the user

    - ZI fonts are based on the choosed Windows TTF font

    - TTF Fonts per se can have some missing or different characters inside ...


not every installed TTF font is complete or contains all characters at the right code position it should ...


everything wrong in the TFT is surely same wrong inside the generated ZI



If it works in debug, as OP says, it should not be a font problem.


In debug, t0.txt="%" works. So does t0.txt="ä,ö,ü". The font I'm using is arial 8x16, iso-8859-1 (I don't know if that's enough to sufficiently characterize it for others, or if that's the font the OP is using).


If those commands don't work in debug for the OP, then it's likely a font issue. If they do work, then it's probably an arduino library issue. I'd try escaping the "%" with a backslash just to see. I don't know why that would be needed with "ä,ö,ü". (but as I said, I know nothing practical about arduino).


@indev2

Thank you very much.
That's it.
I try to change the function "setText()" which is for Arduino and other MCUs to replace such special characters with the serial chars to send it correctly.
Login or Signup to post a comment