View previous topic :: View next topic |
Author |
Message |
rwlee
Joined: 04 Aug 2008 Posts: 36 Location: La Porte, Texas
|
Posted: Wed Aug 17, 2022 6:31 pm Post subject: Nextion reading a number or string from a object |
|
|
I've read the documentation from Nextion's website but I'm looking for a simple way to read a number n0.val, text t0.txt, variable v0.val etc. |
|
Back to top |
|
|
Paulvk
Joined: 28 Jul 2006 Posts: 1257 Location: SYDNEY
|
Posted: Thu Aug 18, 2022 12:14 am Post subject: |
|
|
Probably better in another section maybe mark will move..
Some basics with nextion
Its not like other displays and does not need a library these complicate the process and increase the
amount of code on the external micro controller needlessly.
It has a reparse mode where you control the serial data.
It can be programmed like a micro computer.
Now what are you trying to do with the display description please and then I can tell you the best way to
proceeded and display you are using.
Note I have a 7 inch intelligent display in front of me now controlling my solar power inverters communicating directly with them
via RS232 that sends commands and receives data no micro controller in between.
Regards Paul |
|
Back to top |
|
|
rwlee
Joined: 04 Aug 2008 Posts: 36 Location: La Porte, Texas
|
Posted: Thu Aug 18, 2022 2:56 am Post subject: |
|
|
Thanks for your supply
I just purchased Bascom AVR (again) I used it years ago and really liked the Bit banging abilities.
I'm have 2 displays a 2.8 and a 7 inch, from what I have found is that they both pretty much have the same formats, I'm using the onboard time clock to send the time rtc3, rtc4 and rtc5, I need read the clock values, Seconds, minutes and hours and send the pulses to aCD4017 Decade counter in series. I have all of that working I have nixie clock style numbers that are edge lit so each clock pulse displays a number, I have the nixie LED's working. I just need to run the Nextion part I'm trying to understand, I have the clock running with no problem in 2.8 Nextion display, I don't have any trouble with the c language in the Nextion editor. |
|
Back to top |
|
|
Paulvk
Joined: 28 Jul 2006 Posts: 1257 Location: SYDNEY
|
Posted: Thu Aug 18, 2022 8:10 am Post subject: |
|
|
so how are you driving the CD4017 with an avr or directly with the nextion? |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Thu Aug 18, 2022 8:33 am Post subject: |
|
|
the nextion can be used on its own. and that is indeed a topic not suited for this forum. so when it goes that direction, i move this topic.
But when a user ask something on a BASCOM forum you can assume that he want to use bascom. So it makes sense to help with the question.
Like asking 'how to drive with a drive stick' and tell them the auto pilot will do it without. sure it can help but it is not what was asked for.
JP shared code on how to use the nextion with Bascom :
https://www.mcselec.com/index2.php?option=com_forum&Itemid=59&page=viewtopic&t=14537&highlight=nextion
and you best can start there. _________________ Mark |
|
Back to top |
|
|
Duval JP
Joined: 22 Jun 2004 Posts: 1161 Location: France
|
Posted: Thu Aug 18, 2022 11:19 am Post subject: |
|
|
Hi,
I'm sorry to let you for some times, I not in my home until 23th of august. I did some include file for time and date with nextion i will answers to all your requests.
JP _________________ pleasure to learn, to teach, to create |
|
Back to top |
|
|
sq2eer
Joined: 16 Aug 2011 Posts: 7 Location: Pelplin
|
|
Back to top |
|
|
rwlee
Joined: 04 Aug 2008 Posts: 36 Location: La Porte, Texas
|
Posted: Fri Aug 19, 2022 1:21 am Post subject: |
|
|
Paulvk wrote: | so how are you driving the CD4017 with an avr or directly with the nextion? |
Im driving the CD4017 with Bascom AVR, not just the 4017 but a stepper motor driver, Mechanical eye, and a Lightning tube. |
|
Back to top |
|
|
Paulvk
Joined: 28 Jul 2006 Posts: 1257 Location: SYDNEY
|
Posted: Fri Aug 19, 2022 2:30 am Post subject: |
|
|
So you just want to send values from the nextion to to AVR.
This is fairly simple you just the nextion command prints "Send raw formatted data over Serial to MCU"
With this you can send all the values to the AVR for example if I wanted to send the time to a clock every second
I would use a timer set to 1000 ms with this code
prints second.val
prints min.val
prints hour.val
printh 0D //send character 13
In bascom I would use ISCHARWAITING looking for any data coming from the nextion
Code: |
If Ischarwaiting() = 1 Then
times = Inkey() 'get a character from the buffer which is a hexadecimal value
n = HEXVAL( times ) 'convert the hex value to decimal
if n=13 then ' end of block of data
call updateclock 'sub to update clock
else
Uart_command = Uart_command + times 'add the character to the uart_command buffer
end if
End If
|
I have not time as now packing for trip but will later expand code
regards Paul |
|
Back to top |
|
|
rwlee
Joined: 04 Aug 2008 Posts: 36 Location: La Porte, Texas
|
Posted: Fri Aug 19, 2022 3:12 am Post subject: |
|
|
Paulvk wrote: | So you just want to send values from the nextion to to AVR.
This is fairly simple you just the nextion command prints "Send raw formatted data over Serial to MCU"
With this you can send all the values to the AVR for example if I wanted to send the time to a clock every second
I would use a timer set to 1000 ms with this code
prints second.val
prints min.val
prints hour.val
printh 0D //send character 13
In bascom I would use ISCHARWAITING looking for any data coming from the nextion
Code: |
If Ischarwaiting() = 1 Then
times = Inkey() 'get a character from the buffer which is a hexadecimal value
n = HEXVAL( times ) 'convert the hex value to decimal
if n=13 then ' end of block of data
call updateclock 'sub to update clock
else
Uart_command = Uart_command + times 'add the character to the uart_command buffer
end if
End If
|
I have not time as now packing for trip but will later expand code
regards Paul |
Thanks Paul,
I'm trying to figure this out, I kinda get it but still a little vague, would it be easier to ask the Nextion for a value rather than wait for a change in time? |
|
Back to top |
|
|
rwlee
Joined: 04 Aug 2008 Posts: 36 Location: La Porte, Texas
|
Posted: Fri Aug 19, 2022 4:05 am Post subject: |
|
|
albertsm wrote: | the nextion can be used on its own. and that is indeed a topic not suited for this forum. so when it goes that direction, i move this topic.
But when a user ask something on a BASCOM forum you can assume that he want to use bascom. So it makes sense to help with the question.
Like asking 'how to drive with a drive stick' and tell them the auto pilot will do it without. sure it can help but it is not what was asked for.
JP shared code on how to use the nextion with Bascom :
https://www.mcselec.com/index2.php?option=com_forum&Itemid=59&page=viewtopic&t=14537&highlight=nextion
and you best can start there. |
Thanks Albertsm,
Trying to read through all of the functions. |
|
Back to top |
|
|
Paulvk
Joined: 28 Jul 2006 Posts: 1257 Location: SYDNEY
|
Posted: Fri Aug 19, 2022 4:05 am Post subject: |
|
|
"would it be easier to ask the Nextion for a value rather than wait for a change in time?"
I will elaborate later on on how to ask for values and how to do it with reparse mode which is more efficient.
Still packing Regards Paul |
|
Back to top |
|
|
EDC
Joined: 26 Mar 2014 Posts: 971
|
Posted: Fri Aug 19, 2022 12:01 pm Post subject: |
|
|
I think that "search" option of the Forum is sometimes underestimated.
There is plenty of topics when you search "nextion" and i swear there is the answear how ta ask Nextion for variable value. Simply dont invent wheel again. |
|
Back to top |
|
|
rwlee
Joined: 04 Aug 2008 Posts: 36 Location: La Porte, Texas
|
Posted: Sat Aug 20, 2022 3:05 am Post subject: |
|
|
"I think that "search" option of the Forum is sometimes underestimated.
There is plenty of topics when you search "nextion" and i swear there is the answer how ta ask Nextion for variable value. Simply don't invent wheel again."
That was the first thing I did, but after trying to go through hundreds of lines of code I can't find a simple solution, lots of stuff in Arduino as well, I find it very tedious to try and just find a solution with going through so many INC files, and not finding what I'm looking for. as for reinventing the wheel thats why im sure someone know the answer. I appreciate any help from this forum. |
|
Back to top |
|
|
Paulvk
Joined: 28 Jul 2006 Posts: 1257 Location: SYDNEY
|
Posted: Sun Aug 21, 2022 1:43 pm Post subject: |
|
|
Sorry for delay I had to travel 250km
To get the value of an object from nextion with bascom
First the slow object by object way.
On the nextion there is a text box t0 and a number box n0 and a button
we need to send commands to the nextion via the serial port
all commands must end with hex FF FF FF
the nextion will end the returned value with FF FF FF
First we set the values then ask for them back
note this code is for a mega 644p change to suit used micro
Code: |
$regfile = "m644pdef.dat" ' specify the used micro
$crystal = 8000000 ' used crystal frequency
$baud = 9600 ' use baud rate 9600 normal rate of nextion
$hwstack = 40
$swstack = 40
$framesize = 40
Declare Sub Nextion 'this prints HEX FF FF FF
Print "t0.txt="text Zero "" 'put Text zero in text box
call nextion 'send FF FF FF
Print "B0.txt = "button 0 "" ' put button 0 on the button
Call Nextion 'send FF FF FF
Print "n0.val=123456" 'puts 123456 into number box zero
call nextion 'send FF FF FF
print "get t0.txt" 'ask display for the text of t0 text box zero
call nextion 'send FF FF FF
print "get b0.txt" 'ask display for the text of b0 button zero
call nextion 'send FF FF FF
print "get n0.val" 'ask display for the value (number) of n0 number box zero
call nextion 'send FF FF FF
end
Sub Nextion
Printbin &HFF ; &HFF ; &HFF
Waitms 200
End Sub
|
Last edited by Paulvk on Mon Aug 22, 2022 12:13 am; edited 1 time in total |
|
Back to top |
|
|
|