parent
9e461c2884
commit
b1e63f6faa
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,6 @@
|
||||
info.ini
|
||||
ctrl.ini
|
||||
tg.ini
|
||||
prefixA.ini
|
||||
prefixB.ini
|
||||
prefixC.ini
|
||||
@ -0,0 +1,7 @@
|
||||
EA5SW
|
||||
1
|
||||
99998
|
||||
99999
|
||||
99997
|
||||
99996
|
||||
99995
|
||||
@ -0,0 +1,4 @@
|
||||
EA5SW
|
||||
Valencia-IM99TK
|
||||
439.9625
|
||||
BrandMeister
|
||||
@ -0,0 +1,10 @@
|
||||
EA0
|
||||
EA1
|
||||
EA2
|
||||
EA3
|
||||
EA4
|
||||
EA5
|
||||
EA6
|
||||
EA7
|
||||
EA8
|
||||
EA9
|
||||
@ -0,0 +1,10 @@
|
||||
EB0
|
||||
EB1
|
||||
EB2
|
||||
EB3
|
||||
EB4
|
||||
EB5
|
||||
EB6
|
||||
EB7
|
||||
EB8
|
||||
EB9
|
||||
@ -0,0 +1,10 @@
|
||||
EC0
|
||||
EC1
|
||||
EC2
|
||||
EC3
|
||||
EC4
|
||||
EC5
|
||||
EC6
|
||||
EC7
|
||||
EC8
|
||||
EC9
|
||||
@ -0,0 +1,131 @@
|
||||
214
|
||||
2141
|
||||
2142
|
||||
2143
|
||||
2144
|
||||
2145
|
||||
2146
|
||||
2147
|
||||
2148
|
||||
2149
|
||||
214112
|
||||
21401
|
||||
21402
|
||||
21403
|
||||
21404
|
||||
21405
|
||||
21406
|
||||
21407
|
||||
21408
|
||||
21409
|
||||
21410
|
||||
21411
|
||||
21412
|
||||
21413
|
||||
21414
|
||||
21415
|
||||
21416
|
||||
21417
|
||||
21418
|
||||
21419
|
||||
21420
|
||||
21421
|
||||
21422
|
||||
21423
|
||||
21424
|
||||
21425
|
||||
21426
|
||||
21427
|
||||
21428
|
||||
21429
|
||||
21430
|
||||
21431
|
||||
21432
|
||||
21433
|
||||
21434
|
||||
21435
|
||||
21436
|
||||
21437
|
||||
21438
|
||||
21439
|
||||
21440
|
||||
21441
|
||||
21442
|
||||
21443
|
||||
21444
|
||||
21445
|
||||
21446
|
||||
21447
|
||||
21448
|
||||
21449
|
||||
21450
|
||||
21451
|
||||
21452
|
||||
91
|
||||
92
|
||||
914
|
||||
202
|
||||
204
|
||||
206
|
||||
208
|
||||
213
|
||||
216
|
||||
219
|
||||
220
|
||||
222
|
||||
226
|
||||
228
|
||||
230
|
||||
231
|
||||
232
|
||||
234
|
||||
240
|
||||
242
|
||||
244
|
||||
250
|
||||
254
|
||||
255
|
||||
260
|
||||
262
|
||||
268
|
||||
272
|
||||
294
|
||||
297
|
||||
302
|
||||
310
|
||||
330
|
||||
334
|
||||
425
|
||||
441
|
||||
450
|
||||
460
|
||||
466
|
||||
502
|
||||
505
|
||||
515
|
||||
530
|
||||
655
|
||||
712
|
||||
714
|
||||
724
|
||||
730
|
||||
732
|
||||
734
|
||||
748
|
||||
2701
|
||||
4540
|
||||
5351
|
||||
5371
|
||||
005
|
||||
005
|
||||
005
|
||||
TGP121=005
|
||||
TGP122=005
|
||||
TGP123=005
|
||||
TGP124=005
|
||||
TGP125=005
|
||||
TGP126=005
|
||||
TGP127=005
|
||||
TGP128=005
|
||||
TGP129=005
|
||||
TGP130=005
|
||||
@ -0,0 +1,6 @@
|
||||
EA5SW_24.HMI source file for Layout Nextion 2.4
|
||||
EA5SW_24.tft compiled file for Layout Nextion 2.4
|
||||
EA5SW_32.HMI source file for Layout Nextion 3.2
|
||||
EA5SW_32.tft compiled file for Layout Nextion 3.2
|
||||
EA5SW_35.HMI source file for Layout Nextion 3.5
|
||||
EA5SW_35.tft compiled file for Layout Nextion 3.5
|
||||
@ -0,0 +1,66 @@
|
||||
# Update Nextion Displays from the Command Line
|
||||
|
||||
This directory contains a simple python script which you can use to update the
|
||||
Nextion displays. All you need is a compiled .tft file which is written to the
|
||||
display's flash memory. The precompiled .tft files with the MMDVMHost default
|
||||
layout are to be found in this directory as well.
|
||||
|
||||
To update the Nextion display you just need to know the serial port the display
|
||||
is connected to. It could be /dev/ttyUSBx for USB<->Serial adapters or
|
||||
/dev/ttyAMA0 for the UART on the Raspberry Pi for example.
|
||||
|
||||
# Prerequisites
|
||||
|
||||
You need to have python installed as well as the python-serial package. That can
|
||||
normally be found in your distro's package manager.
|
||||
|
||||
# File Naming Convention
|
||||
|
||||
There are compiled .tft files in the repo for basic and enhanced Nextion
|
||||
displays of sizes 2.4", 2.8", 3.2" and 3.5". Please choose depending on the
|
||||
model number printed on the back of the display.
|
||||
|
||||
The basic displays are denoted by a "T" as 7th character in the filename and
|
||||
model number whereas enhanced displays have a "K" in that position. The actual
|
||||
display size can be derived from the last two digits. The four digits in between
|
||||
the characters refert to the diplay's resolution.
|
||||
|
||||
For example: A model number NX4832T035 represents a display with:
|
||||
|
||||
- a resolution of 320x480 pixels
|
||||
- basic command set
|
||||
- a screen size of 3.5"
|
||||
|
||||
# Updating the Display
|
||||
|
||||
Now comes the easy part. Just execute:
|
||||
|
||||
```
|
||||
$ python nextion.py NX4832T035.tft /dev/ttyUSB0
|
||||
```
|
||||
|
||||
And the output should be as follows:
|
||||
|
||||
```
|
||||
Trying with baudrate: 2400...
|
||||
Trying with baudrate: 4800...
|
||||
Trying with baudrate: 9600...
|
||||
Connected with baudrate: 9600...
|
||||
Status: comok
|
||||
Touchscreen: yes
|
||||
Model: NX4832T035_011R
|
||||
Firmware version: 68
|
||||
MCU code: 61488
|
||||
Serial: D2658880C35D2124
|
||||
Flash size: 16777216
|
||||
Downloading, 100%...
|
||||
File transferred successfully
|
||||
```
|
||||
|
||||
# Known errors
|
||||
|
||||
Especially when using USB<->Serial adapters there are cases in which the scripts
|
||||
stops at different times. This is known and due to the very simple update
|
||||
protocol. In this case you have to fix the display by using a SD-Card to update
|
||||
the display. The /dev/ttyAMAx ports do not seems to suffer from this issue.
|
||||
|
||||
@ -0,0 +1,136 @@
|
||||
'''
|
||||
* Copyright (C) 2016 Alex Koren
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
'''
|
||||
|
||||
import serial
|
||||
import time
|
||||
import sys
|
||||
import os
|
||||
import re
|
||||
|
||||
e = "\xff\xff\xff"
|
||||
|
||||
def getBaudrate(ser, fSize=None, checkModel=None):
|
||||
for baudrate in (2400, 4800, 9600, 19200, 38400, 57600, 115200):
|
||||
ser.baudrate = baudrate
|
||||
ser.timeout = 3000 / baudrate + .2
|
||||
print 'Trying with baudrate: ' + str(baudrate) + '...'
|
||||
ser.write("\xff\xff\xff")
|
||||
ser.write('connect')
|
||||
ser.write("\xff\xff\xff")
|
||||
r = ser.read(128)
|
||||
if 'comok' in r:
|
||||
print 'Connected with baudrate: ' + str(baudrate) + '...'
|
||||
noConnect = False
|
||||
status, unknown1, model, fwversion, mcucode, serial, flashSize = r.strip("\xff\x00").split(',')
|
||||
print 'Status: ' + status.split(' ')[0]
|
||||
if status.split(' ')[1] == "1":
|
||||
print 'Touchscreen: yes'
|
||||
else:
|
||||
print 'Touchscreen: no'
|
||||
print 'Model: ' + model
|
||||
print 'Firmware version: ' + fwversion
|
||||
print 'MCU code: ' + mcucode
|
||||
print 'Serial: ' + serial
|
||||
print 'Flash size: ' + flashSize
|
||||
if fSize and fSize > flashSize:
|
||||
print 'File too big!'
|
||||
return False
|
||||
if checkModel and not checkModel in model:
|
||||
print 'Wrong Display!'
|
||||
return False
|
||||
return True
|
||||
return False
|
||||
|
||||
def setDownloadBaudrate(ser, fSize, baudrate):
|
||||
ser.write("")
|
||||
ser.write("whmi-wri " + str(fSize) + "," + str(baudrate) + ",0" + e)
|
||||
time.sleep(.05)
|
||||
ser.baudrate = baudrate
|
||||
ser.timeout = .5
|
||||
r = ser.read(1)
|
||||
if "\x05" in r:
|
||||
return True
|
||||
return False
|
||||
|
||||
def transferFile(ser, filename, fSize):
|
||||
with open(filename, 'rb') as hmif:
|
||||
dcount = 0
|
||||
while True:
|
||||
data = hmif.read(4096)
|
||||
if len(data) == 0:
|
||||
break
|
||||
dcount += len(data)
|
||||
ser.timeout = 5
|
||||
ser.write(data)
|
||||
sys.stdout.write('\rDownloading, %3.1f%%...'% (dcount / float(fSize) * 100.0))
|
||||
sys.stdout.flush()
|
||||
ser.timeout = .5
|
||||
time.sleep(.5)
|
||||
r = ser.read(1)
|
||||
if "\x05" in r:
|
||||
continue
|
||||
else:
|
||||
print
|
||||
return False
|
||||
break
|
||||
print
|
||||
return True
|
||||
|
||||
def upload(ser, filename, checkModel=None):
|
||||
if not getBaudrate(ser, os.path.getsize(filename), checkModel):
|
||||
print 'Could not find baudrate'
|
||||
exit(1)
|
||||
|
||||
if not setDownloadBaudrate(ser, os.path.getsize(filename), 115200):
|
||||
print 'Could not set download baudrate'
|
||||
exit(1)
|
||||
|
||||
if not transferFile(ser, filename, os.path.getsize(filename)):
|
||||
print 'Could not transfer file'
|
||||
exit(1)
|
||||
|
||||
print 'File transferred successfully'
|
||||
exit(0)
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) != 4 and len(sys.argv) != 3:
|
||||
print 'usage:\npython nextion.py file_to_upload.tft /path/to/dev/ttyDevice [nextion_model_name]\
|
||||
\nexample: nextion.py newUI.tft /dev/ttyUSB0 NX3224T024\
|
||||
\nnote: model name is optional'
|
||||
exit(1)
|
||||
|
||||
try:
|
||||
ser = serial.Serial(sys.argv[2], 9600, timeout=5)
|
||||
except serial.serialutil.SerialException:
|
||||
print 'could not open serial device ' + sys.argv[2]
|
||||
exit(1)
|
||||
if serial.VERSION <= "3.0":
|
||||
if not ser.isOpen():
|
||||
ser.open()
|
||||
else:
|
||||
if not ser.is_open:
|
||||
ser.open()
|
||||
|
||||
checkModel = None
|
||||
if len(sys.argv) == 4:
|
||||
checkModel = sys.argv[3]
|
||||
pattern = re.compile("^NX\d{4}[TK]\d{3}$")
|
||||
if not pattern.match(checkModel):
|
||||
print 'Invalid model name. Please give a correct one (e.g. NX3224T024)'
|
||||
exit(1)
|
||||
upload(ser, sys.argv[1], checkModel)
|
||||
Loading…
Reference in new issue