Skip to content

Nextion Display

Wotever edited this page Mar 22, 2018 · 40 revisions

WARNING !

Unfair sellers sells a chenese version of the nextion, these are branded TJCxxxxx, they are not supported by the nextion editor and would be useless with SimHub, make sure to buy a real nextion (model starting with NXxxxx)

Wiring nextion display

Parts needed :

  • Nextion display
  • Wires
  • Usb TTL

Connect USB TTL following these wirings

GND => GND
5V => 5V
RX => TX
TX => RX

Warning ! Trap inside ! Take care, TX goes to RX

Always make sure Simhub is closed before uploading.

Wiring nextion through an Arduino Micro

MICRO => Nextion
GND   =>   GND
VCC   =>   5V
RX1   =>   TX
TX0   =>   RX

Upload the sketch found in C:\Program Files (x86)\SimHub\_Addons\NextionMicroBridge It offers the structure to add gamepad support, please not that it's just a sample with a single button and you must add your own logic.

Upload to nextion will not work using the Itead nextion editor but Simhub offers an alternative uploader.

  • Build your template using the editor using the "compile" button :

  • Open build folder :

  • double click on your template file :

  • Choose your arduino serial port and click on upload, you're ready !

Template structure

Nextion template is made of three parts :

  • Nextion template (.hmi file) which is made with Nextion editor and uploaded to Nextion display
  • Nextion structure (.hmistruct file) which describe Nextion display components and used by SimHub
  • Mapping file (.ini file) which is a "mapping" file to describe how SimHub must use the nextion display

The files must be place inside NextionTemplate folder

A complete sample for 2.8" display is provided with SimHub

Custom Nextion Editor

SimHub is bundled with a custom nextion editor, which can be found in SimHubNextionEditor folder inside archive

Nextion editor documentation is available here : http://wiki.iteadstudio.com/Nextion_HMI_Solution

Connect SimHub to Nextion Emulator

To connect SimHub to Nextion Editor Emulator you need to bridge two com ports on the same computer. Always check debug option of nextion plugin when trying to connect to emulator.

Bridge Serial port : Software way (15 days trial)

http://www.eltima.com/fr/products/vspdxp/

Bridge Serial port : Hardware way

Connect two USB TTL (RX => TX, TX => RX)

Update Nextion Structure File

After each nextion display modification you have to update Nextion structure file.

In nextion editor click on Create mapping file in main toolbar

Structure file will be created alongside HMI file

Add a new page

In nextion editor All pages must have in Preinitialize event the sendme instruction

Pages roles

You can set the role of each page by adding the pagesroles section

  • skip means that simhub won't cycle on it (when using cycling actions)
  • ingame means that simhub will cycle on the page when in game
  • idle means that simhub will cycle on the page when idle

Syntax :

[pagesroles]
{pagename}={role1}[,{role2}]

Exemple

[pagesroles]
idle=idle
printer=idle
system=idle,skip 
homealt=ingame
laphistory=ingame
telemetry=ingame

Create virtual pages

You can create virtual pages based on a real Nextion page allowing you to display easily varoius data using the same nextion spage.

Add to the page virtualpages section

Syntax :

[virtualpages]
{virtualpagename}={realpagename}

Exemple :

[virtualpages]
gamevolumechanged=virtmessage
rpmalerttriggerchanged=virtmessage
sessionstarted=virtmessage
newlap=virtmessage

Add a new dynamic component

In nextion editor

Always set vscope to global, components and pages names must be in lower case

Only the green properties can be mapped inside SimHub

Map a component to simhub

You can update properties in simhub using mapping file, all the values except when specified are Ncalc functions ( NCalc-scripting)

Syntax :

[{pagename}.{componenentname}]
{propertyname}={ncalc expression}

Exemples :

[laphistory.l1]
txt=format([PersistantTrackerPlugin.PreviousLap_00],'m\\:ss\\:fff')

Force nextion component refresh after property update

Add forcerefresh=1 to the mapping section

Exemple :

[{pagename}.{componenentname}]
....
forcerefresh={ncalc expression}
[home.rpmbar]
val=min(100,max(0,isnull([serialdashplugin.computedrpmpercent],0)))
ppic=if(blink('rpm',200,[serialdashplugin.computedrpmpercent]>[serialdashplugin.blinktriggerratio]),8,7)
bpic=if(blink('rpm2',250,isnull([DataCorePlugin.GameRawData.Graphics.isInPitLane],false)),8,6)
FORCEREFRESH=1

Set component visibility

Set vis property :

Syntax:

[{pagename}.{componenentname}]
vis={ncalc expression}

Exemple :

[sessionstarted.icon]
pic=13
vis=1

Update all the components with the same name on all pages

Use global as page name in mapping section

Exemple :

[global.rpm]
txt=format(max(0,isnull([datacoreplugin.gamedata.newdata.rpms],0)),'0')
Clone this wiki locally