View previous topic :: View next topic |
Author |
Message |
rwlee
Joined: 04 Aug 2008 Posts: 35 Location: La Porte, Texas

|
Posted: Sun Aug 21, 2022 4:24 pm Post subject: |
|
|
Paulvk,
Thanks for your help, so presum that I use the get #1 command to retrieve the answer from the nextion, at some point need to clear the buffer ?
Thanks, Wayne |
|
Back to top |
|
 |
rwlee
Joined: 04 Aug 2008 Posts: 35 Location: La Porte, Texas

|
Posted: Sun Aug 21, 2022 9:35 pm Post subject: |
|
|
I get a compile error
Error : 44 Line : 30 2 variables expected , in File : D:\MCS\Programs\Nextion-Test\Read RTC-2.bas
print #2 , num_test.val=10
Num_test.val is the objname in Nextion it's a number Box
I tried to separate the and assign to variables, I don't get any errors but there is nothing coming back from Nextion.
dim _Num as string * 12
_num = "Num_test.val="
call nextion
Sub Nextion
Printbin #2 , &HFF ; &HFF ; &HFF
Waitms 100
End Sub |
|
Back to top |
|
 |
albertsm
Joined: 09 Apr 2004 Posts: 5838 Location: Holland

|
Posted: Mon Aug 22, 2022 8:15 am Post subject: |
|
|
sending , num_test.val=10 is not ok.
i think you need to send the ID (a number).
you can use inputbin to read the input. _________________ Mark |
|
Back to top |
|
 |
Paulvk
Joined: 28 Jul 2006 Posts: 1255 Location: SYDNEY

|
Posted: Mon Aug 22, 2022 12:08 pm Post subject: |
|
|
Ok have arrived somewhat unpacked.
Its best to start with a simple screen the button , text box and number box.
Then just write simple code to talk to the nextion.
Or do what I did first and use a terminal program , I used realterm with a rs232 to TTL adaptor on my PC
to send and receive commands its very suited to this as it has two send boxes
so you can keep the 0XFF 0XFF 0XFF in one and send it as a number while using
the other to send text commands .
Now there is really no advantage in "I tried to separate the and assign to variables"
if you do not want to write something many times in bascom you just assign it to a constant.
With the nextion if you create a button and under the touch press event you put prints "text001",0
the nextion should send text001 when you press the button you can then confirm if you have it
hooked up correctly I have a couple of rs232 to TTL units that had TX & RX marked the wrong way around
spent some minutes trying to work out why it was not working.
So best to confirm its working before trying to write a lot of code in bascom.
Regards Paul |
|
Back to top |
|
 |
Duval JP
Joined: 22 Jun 2004 Posts: 1147 Location: France

|
Posted: Thu Aug 25, 2022 10:30 am Post subject: my contribution |
|
|
Hi
i just give you a small example
and I add a zip file with
- program
- tuto in PDF and powerpoint
- picture files
- HMI file
the video :https://youtu.be/7T40DF3LYvw
i you need help ,I'm back from vacation I'm rested!
JP _________________ pleasure to learn, to teach, to create |
|
Back to top |
|
 |
rwlee
Joined: 04 Aug 2008 Posts: 35 Location: La Porte, Texas

|
Posted: Fri Aug 26, 2022 2:19 pm Post subject: |
|
|
Thanks Duval JP,
I've been using Realterm and 2 MAX232CSE Modules to debug with , I noticed than in the send window from Nextion on the real term I was getting a CR and LF which was causing Nextion to not respond, after research I found that adding ; at the end of every print statement all started working, I think I'm on my way now I'm communicating with the Nextion very well now
Thanks, Wayne |
|
Back to top |
|
 |
Duval JP
Joined: 22 Jun 2004 Posts: 1147 Location: France

|
Posted: Fri Aug 26, 2022 4:18 pm Post subject: time to give the way to see the time |
|
|
Hi rwlee,
I add the time, (the date will come from monday
I do step by step because a lot of people come crazy with nextion, me too !
I use slicer because is funny, you can use button or what you want
So As yesterday I add
- program
- tuto in PDF and powerpoint
- picture files
- HMI file
no video, i'have no time, but sure it works !
I must say RTC of Nextion is not so good as DS3231 , and it is an efemism
Again you mus dim your var as long not byte  _________________ pleasure to learn, to teach, to create |
|
Back to top |
|
 |
Duval JP
Joined: 22 Jun 2004 Posts: 1147 Location: France

|
Posted: Wed Aug 31, 2022 4:49 pm Post subject: Continuation and end |
|
|
Hi
I add the date today, again with nextion not so easy to read back the dates but the sub works well now
I hope it can help you
I clean the include "sub_macro_nextion_base.inc" , if you use it and found some mistake let me know
the video :
https://youtu.be/Lt85sGaZNOg
jp  _________________ pleasure to learn, to teach, to create |
|
Back to top |
|
 |
rwlee
Joined: 04 Aug 2008 Posts: 35 Location: La Porte, Texas

|
Posted: Thu Sep 01, 2022 4:08 am Post subject: Re: my contribution |
|
|
[quote="Duval JP"]Hi
i just give you a small example
Thanks again for the Info
Wayne |
|
Back to top |
|
 |
rwlee
Joined: 04 Aug 2008 Posts: 35 Location: La Porte, Texas

|
Posted: Mon Nov 20, 2023 10:15 pm Post subject: ATMEGA 328p Dosen't repond to Nextion NX3224K024 |
|
|
So I tested the output of the Display, and it works directly with the PC Terminal Emulator, to Print "Hello World" on the comport. But when I connected to the MCU I cant capture the input!
I even tried spliting the Serial output of the so the output of the Nextion display goes directly into the 328p But I get Nothing!
Code: |
$regfile = "m328pdef.dat"
$crystal = 16000000
$baud = 19200
$hwstack = 64
$swstack = 64
$framesize = 64
Config Submode = New
Debug On
Config Com1 = 19200 , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
Echo Off
Config Serialin0 = Buffered , Size = 30 'RX from Terminal
Open "COM1:" For Binary As #1
Const Nex_ = 1
Dim Buf_ as Byte
Dim Loop_Cnt as Byte
Print #Nex_ , "Starting"
Do
Wait 1
Buf_ = Ischarwaiting(#Nex_)
If Buf_ = 1 then
Loop_Cnt = Inkey(#Nex_)
Print #Nex_ , "Loop_Cnt " ; Loop_Cnt
Else
Print #Nex_ , "Nothing "
End If
Loop
End |
 |
|
Back to top |
|
 |
EDC
Joined: 26 Mar 2014 Posts: 937

|
Posted: Mon Nov 20, 2023 10:40 pm Post subject: |
|
|
It is a "classic mistake"
For buffered Serialin you can`t forget to "Enable Interrupts"!
I know because, years ago, I take that lesson too ahahahahaha _________________ Check B-Flash - MCS bootloader app for Android |
|
Back to top |
|
 |
rwlee
Joined: 04 Aug 2008 Posts: 35 Location: La Porte, Texas

|
Posted: Mon Nov 20, 2023 11:08 pm Post subject: ATMEGA 328p Dosen't repond to Nextion NX3224K024 |
|
|
Thanks, EDC
That did it, but I can't find any examples of how toput together as string extracted from each byte, Is there anyway to grab the entire string at once? |
|
Back to top |
|
 |
EDC
Joined: 26 Mar 2014 Posts: 937

|
Posted: Mon Nov 20, 2023 11:18 pm Post subject: |
|
|
You can try like that.. there is plenty of solutions.
Code: | Dim Resultstring As String * 30
If 0 < Ischarwaiting(#Nex_) Then
Dim Char As Byte
Do
Char = Inkey(#Nex_)
Select Case Char
Case 13 : 'CarriageReturn ->swallow
Case 10 : 'NewLine ->got string ->processing
Print Resultstring
Resultstring = "" 'clear the string for new message
Case Else
If Char > 31 Then
Resultstring = Resultstring + Chr(char)
End If
End Select
Loop Until Ischarwaiting(#Nex_) = 0
End If |
Sometimes you must take care about length of the string (to not exeed *30 here).
Sometimes is good to introduce some timeout for entire string. _________________ Check B-Flash - MCS bootloader app for Android |
|
Back to top |
|
 |
rwlee
Joined: 04 Aug 2008 Posts: 35 Location: La Porte, Texas

|
|
Back to top |
|
 |
EDC
Joined: 26 Mar 2014 Posts: 937

|
|
Back to top |
|
 |
|