Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Nextion and Bascom
Goto page Previous  1, 2, 3, 4
 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM Project Blog
View previous topic :: View next topic  
Author Message
Kasch

Bascom Member



Joined: 18 Jun 2005
Posts: 47

PostPosted: Mon Oct 26, 2020 5:25 pm    Post subject: Reply with quote

how can I send it to you?
Back to top
View user's profile
Duval JP

Bascom Member



Joined: 22 Jun 2004
Posts: 990
Location: France

france.gif
PostPosted: Mon Oct 26, 2020 6:41 pm    Post subject: Reply with quote

do a zip file to jp030405 at yahoo.fr
_________________
pleasure to learn, to teach, to create
Back to top
View user's profile Visit poster's website
Kasch

Bascom Member



Joined: 18 Jun 2005
Posts: 47

PostPosted: Mon Nov 09, 2020 11:40 am    Post subject: Reply with quote

sorry for late answere, i have sent it
Back to top
View user's profile
Paulvk

Bascom Member



Joined: 28 Jul 2006
Posts: 1209
Location: SYDNEY

australia.gif
PostPosted: Mon Dec 14, 2020 6:30 am    Post subject: Get ASCII Reply with quote

I have been working to make sending to the nextion faster.
So to do this you need to just send the data to the display
and then process on the display to put in the boxes
but we need error checking nextion does modbus crc16
but I wanted xmodem crc16 and nextion has no command
to give the ascii value of a character so I have written
it myself and here is a demo page
it loads characters 32 to 126 int nextion eeprom
then you can search the eeprom and get the ascii value of a character you enter.
Next I will post the xmodem crc16
and then put it all together to send packets of data to the nextion from the avr with
both types of crc16
Regards Paul
Back to top
View user's profile
Paulvk

Bascom Member



Joined: 28 Jul 2006
Posts: 1209
Location: SYDNEY

australia.gif
PostPosted: Mon Mar 22, 2021 7:05 am    Post subject: CRC16 generator Reply with quote

Here is code that generates CRC16 for a string you first have to run the
previous program once to put the characters ! to ~ in the eeprom
(Note if you use other characters you will need to add them)
to enable it to look up and calculate the character ASCII number
This enables CRC checking of bytes sent to the nextion from the AVR
and those sent to the AVR
Regards paul

Code:

//calculate crc16 of string
//put in button code to demo
//Variables needed
//text variables >TXT1,TXT2
//Number variables >char,crc,count,i,j,k,l
//t0 holds the string n0 shows result
strlen t0.txt,count.val //get length of string
NUM1.val=0 //start a first character
crc.val=0
k.val=count.val
n1.val=count.val
count.val=0
while(k.val>0)
{
  //substr <src>,<dest>,<start>,<count>
  char.val=0
  substr t0.txt,TXT1.txt,count.val,1
   NUM1.val=1
  l.val=0
   while(NUM1.val<96)
   {
      repo TXT2.txt,l.val //get character from eeprom
      l.val+=4
      NUM1.val+=1
      if(TXT1.txt==TXT2.txt)//match in eeprom
      {
        char.val=NUM1.val
        char.val+=30
        NUM1.val=99
     }
    }
            char.val=char.val<<8
            crc.val=crc.val^char.val
            i.val=8
           while(i.val>0)
          {
             j.val=crc.val&0x8000
             if(j.val==0x8000)
            {
              crc.val=crc.val<<1
              crc.val=crc.val^0x1021//this can be changed for other

                                    //crc polynomials
              //print "one"
                }else
               {
                crc.val=crc.val<<1 //left crc shift 1
                }
               crc.val=crc.val&0xFFFF
               i.val-=1
          }
          count.val+=1
         NUM1.val+=1 //increment by 1
         k.val-=1 // decrement by 1
 }
   //n2.val=count.val
   n0.val=crc.val
  // printh crc.val
 
Back to top
View user's profile
Paulvk

Bascom Member



Joined: 28 Jul 2006
Posts: 1209
Location: SYDNEY

australia.gif
PostPosted: Fri May 21, 2021 5:35 am    Post subject: Reply with quote

Now since I have had some more time to get back to the Nextion
and learn more of its code I have improved the CRC generator
it no longer uses EEprom here is updated code and a hmi file
that has the Nextion generate the crc , display it in hex and
send the whole thing with crc over the serial.
So what use is this nextion , it will enable you to type in
what a device may return to the AVR after being requested
to send back some info with crc testing your bascom program
without using a live device.
Attached is the Nextion hmi file so you can modify , use and run it on the Nextion simulator.
Regards Paul

Code:


strlen t0.txt,count.val //get length of string
NUM1.val=0 //start a first character
crc.val=0
k.val=count.val
n1.val=count.val
count.val=0
while(k.val>0)
{
  //substr <src>,<dest>,<start>,<count>
  char.val=0
  substr t0.txt,TXT1.txt,count.val,1
  NUM1.val=1
  l.val=0
  //spstr <src>,<dest>,<key>,<index>
  spstr ASCII.txt,SPLIT.txt,TXT1.txt,0
  strlen SPLIT.txt,num1.val
  char.val=num1.val
  char.val+=32
  n4.val=char.val //character number
  char.val=char.val<<8
  crc.val=crc.val^char.val
  i.val=8
  while(i.val>0)
  {
    j.val=crc.val&0x8000
    if(j.val==0x8000)
    {
      crc.val=crc.val<<1
      crc.val=crc.val^0x1021
    }else
    {
      crc.val=crc.val<<1 //left crc shift 1
    }
    crc.val=crc.val&0xFFFF
    i.val-=1
  }
  count.val+=1
  NUM1.val+=1 //increment by 1
  k.val-=1 // decrement by 1
}
covx num1.val,tex10.txt,0,0
n0.val=crc.val
covx num1.val,t1.txt,2,0
num1.val=crc.val
print t0.txt
crc.val=crc.val>>8
prints crc.val,1
prints num1.val,1
printh 0D
//covx h0.val,t0.txt,4,2 // convert value of h0 into t0.txt in 2 bytes of hex digits
covx num1.val,t2.txt,4,2
 
Back to top
View user's profile
Paulvk

Bascom Member



Joined: 28 Jul 2006
Posts: 1209
Location: SYDNEY

australia.gif
PostPosted: Sun Jun 27, 2021 5:31 am    Post subject: Reply with quote

I have written a document to try and make it easier to understand how the reparse mode works
and how to use the timers as sub programs. It also has a lot of comments and instructions on how
to use the nextion language using the inverter code as the example.
Attached is a 6 page document in microsoft word format

An animation file for nextion is also attached

Regards Paul
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM Project Blog All times are GMT + 1 Hour
Goto page Previous  1, 2, 3, 4
Page 4 of 4

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum