mirror of
https://github.com/joBr99/nspanel-lovelace-ui.git
synced 2025-12-19 22:24:15 +01:00
added nextion flash 1.2 as FlashNextionFast command
This commit is contained in:
@@ -17,9 +17,15 @@ Send's normal Custom Commands to the Screen in the following format:
|
|||||||
|
|
||||||
- `FlashNextion URL`
|
- `FlashNextion URL`
|
||||||
|
|
||||||
|
Start's flashing a tft file to the nextion screen via Nextion Upload Protocol 1.1
|
||||||
|
Might be required to send the command twice (known issue, didn't investigate yet)
|
||||||
|
|
||||||
|
- `FlashNextionFast URL`
|
||||||
|
|
||||||
Start's flashing a tft file to the nextion screen via Nextion Upload Protocol 1.2
|
Start's flashing a tft file to the nextion screen via Nextion Upload Protocol 1.2
|
||||||
Might be required to send the command twice (known issue, didn't investigate yet)
|
Might be required to send the command twice (known issue, didn't investigate yet)
|
||||||
|
|
||||||
|
|
||||||
Webserver must be reachable via HTTP and support Range Header
|
Webserver must be reachable via HTTP and support Range Header
|
||||||
|
|
||||||
Example: `FlashNextion http://192.168.75.30:8123/local/nspanel.tft`
|
Example: `FlashNextion http://192.168.75.30:8123/local/nspanel.tft`
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ class TftDownloader
|
|||||||
var current_chunk_start
|
var current_chunk_start
|
||||||
var download_range
|
var download_range
|
||||||
|
|
||||||
|
|
||||||
def init(host, port, file, download_range)
|
def init(host, port, file, download_range)
|
||||||
self.tft_file_size = 0
|
self.tft_file_size = 0
|
||||||
|
|
||||||
@@ -118,6 +119,7 @@ class Nextion : Driver
|
|||||||
var ser
|
var ser
|
||||||
var flash_size
|
var flash_size
|
||||||
var flash_mode
|
var flash_mode
|
||||||
|
var flash_version
|
||||||
var flash_skip
|
var flash_skip
|
||||||
var flash_current_byte
|
var flash_current_byte
|
||||||
var tftd
|
var tftd
|
||||||
@@ -128,6 +130,7 @@ class Nextion : Driver
|
|||||||
log("NSP: Initializing Driver")
|
log("NSP: Initializing Driver")
|
||||||
self.ser = serial(17, 16, 115200, serial.SERIAL_8N1)
|
self.ser = serial(17, 16, 115200, serial.SERIAL_8N1)
|
||||||
self.flash_mode = 0
|
self.flash_mode = 0
|
||||||
|
self.flash_version = 1
|
||||||
self.flash_skip = false
|
self.flash_skip = false
|
||||||
tasmota.add_driver(self)
|
tasmota.add_driver(self)
|
||||||
end
|
end
|
||||||
@@ -200,7 +203,6 @@ class Nextion : Driver
|
|||||||
end
|
end
|
||||||
|
|
||||||
def start_flash(url)
|
def start_flash(url)
|
||||||
|
|
||||||
import string
|
import string
|
||||||
var host
|
var host
|
||||||
var port
|
var port
|
||||||
@@ -224,7 +226,6 @@ class Nextion : Driver
|
|||||||
#print(host,port,file)
|
#print(host,port,file)
|
||||||
|
|
||||||
self.tftd = TftDownloader(host, port, file, 32768)
|
self.tftd = TftDownloader(host, port, file, 32768)
|
||||||
#self.tftd = TftDownloader("192.168.75.30", 8123, "/local/test.tft", 32768)
|
|
||||||
|
|
||||||
# get size of tft file
|
# get size of tft file
|
||||||
self.flash_size = self.tftd.get_file_size()
|
self.flash_size = self.tftd.get_file_size()
|
||||||
@@ -270,13 +271,18 @@ class Nextion : Driver
|
|||||||
var msg = self.ser.read()
|
var msg = self.ser.read()
|
||||||
if size(msg) > 0
|
if size(msg) > 0
|
||||||
print("NSP: Received Raw =", msg)
|
print("NSP: Received Raw =", msg)
|
||||||
if (self.flash_mode==1)
|
if self.flash_mode==1
|
||||||
var str = msg[0..-4].asstring()
|
var str = msg[0..-4].asstring()
|
||||||
log(str, 3)
|
log(str, 3)
|
||||||
# TODO: add check for firmware versions < 126 and send proto 1.1 command for thoose
|
# TODO: add check for firmware versions < 126 and send proto 1.1 command for thoose
|
||||||
if (string.find(str,"comok 2")==0)
|
if (string.find(str,"comok 2")==0)
|
||||||
|
if self.flash_version==1
|
||||||
|
log("NSP: Flashing 1.1")
|
||||||
self.sendnx(string.format("whmi-wri %d,115200,1",self.flash_size)) # Nextion Upload Protocol 1.1
|
self.sendnx(string.format("whmi-wri %d,115200,1",self.flash_size)) # Nextion Upload Protocol 1.1
|
||||||
#self.sendnx(string.format("whmi-wris %d,115200,1",self.flash_size)) # Nextion Upload Protocol 1.2
|
else
|
||||||
|
log("NSP: Flashing 1.2")
|
||||||
|
self.sendnx(string.format("whmi-wris %d,115200,1",self.flash_size)) # Nextion Upload Protocol 1.2
|
||||||
|
end
|
||||||
|
|
||||||
# skip to byte (upload protocol 1.2)
|
# skip to byte (upload protocol 1.2)
|
||||||
elif (size(msg)==1 && msg[0]==0x08)
|
elif (size(msg)==1 && msg[0]==0x08)
|
||||||
@@ -325,6 +331,7 @@ var nextion = Nextion()
|
|||||||
|
|
||||||
def flash_nextion(cmd, idx, payload, payload_json)
|
def flash_nextion(cmd, idx, payload, payload_json)
|
||||||
def task()
|
def task()
|
||||||
|
nextion.flash_version = 1
|
||||||
nextion.start_flash(payload)
|
nextion.start_flash(payload)
|
||||||
end
|
end
|
||||||
tasmota.set_timer(0,task)
|
tasmota.set_timer(0,task)
|
||||||
@@ -333,6 +340,17 @@ end
|
|||||||
|
|
||||||
tasmota.add_cmd('FlashNextion', flash_nextion)
|
tasmota.add_cmd('FlashNextion', flash_nextion)
|
||||||
|
|
||||||
|
def flash_nextion_1_2(cmd, idx, payload, payload_json)
|
||||||
|
def task()
|
||||||
|
nextion.flash_version = 2
|
||||||
|
nextion.start_flash(payload)
|
||||||
|
end
|
||||||
|
tasmota.set_timer(0,task)
|
||||||
|
tasmota.resp_cmnd_done()
|
||||||
|
end
|
||||||
|
|
||||||
|
tasmota.add_cmd('FlashNextionFast', flash_nextion_1_2)
|
||||||
|
|
||||||
def send_cmd(cmd, idx, payload, payload_json)
|
def send_cmd(cmd, idx, payload, payload_json)
|
||||||
nextion.sendnx(payload)
|
nextion.sendnx(payload)
|
||||||
tasmota.resp_cmnd_done()
|
tasmota.resp_cmnd_done()
|
||||||
|
|||||||
Reference in New Issue
Block a user