Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Change an Image on the Nextion

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
rwlee

Bascom Member



Joined: 04 Aug 2008
Posts: 36
Location: La Porte, Texas

usa.gif
PostPosted: Wed Jan 17, 2024 3:58 am    Post subject: Change an Image on the Nextion Reply with quote

So I look at he documentation on the Nextion

Duval JP has great deal of work on almost all the the Nextion's abilities, I've gotten man ofhis code to work

I needto do a simple task (so it would seem) to change 3 pictures on a 2 second time loop

All of the 3 pictures one after the other "p0.pic="

This is my code:

Code:

$regfile = "m328pdef.dat"
$crystal = 16000000
$baud = 19200
$hwstack = 64
$swstack = 64
$framesize = 64

Config Com1 = 115200 , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0       '19200 modif pour ecran intelligent
Open "COM1:" For Binary As #1
Const Nex = 1
Config Serialin0 = Buffered , Size = 50

Open "comd.7:115200,8,n,1" For Output As #2
Const Usb_ = 2

Declare Sub Nex_image(Byval Xval As Byte , Byval Yval As Byte , Byval Picval As Byte)

Const Xval = 221
Const Yval = 30
Dim Idx_ as Byte
Dim Picval as Byte

Do
  For Idx_ = 1 to 3
      Picval = Idx_
      Call Nex_image(Xval , Yval , Picval)
      wait 2
  Next
Loop
End

Sub Nex_image(byval Xval As Word , Yval As Word , Picval As Byte)
   Local Gtext As String * 22
   Gtext = "p0.pic=" + Str(xval) + "," + Str(yval) + "," + Str(picval)
   Print# Nex , Gtext ;
   Print #Usb_ , Gtext ;
   Printbin #Nex , &HFF ; &HFF ; &HFF
   Printbin #Usb_ , &HFF ; &HFF ; &HFF
End Sub

 


But the Pictures wont Change, I have 3 differernt Pictures 1, 2, 3 That m trying to change.
But nothing changes. I can Change the Text, And the color of the text, form BASCOM but the pictures wont change





What am I missing?

(BASCOM-AVR version : 2.0.8.6 )
Back to top
View user's profile
Duval JP

Bascom Member



Joined: 22 Jun 2004
Posts: 1161
Location: France

france.gif
PostPosted: Wed Jan 17, 2024 11:29 am    Post subject: Reply with quote

Nextion is capricious, I've had similar problems with images and I've circumvented the problem by using text zones.
text zones without text but with images and it worked fine

follow the text zone t10 (moon)


and the sub
Code:
'*******************************************************************************
  Sub Nex_textpic(byval Text_id As String , Byval Picture As Byte )
   Local Gtext As String * 20

   Gtext = Text_id + ".pic="                                'change the picture
   Print#nex , Gtext ; Picture ;
   Nexend
  '  Debug #usb , " sub nex_tex_pic"

End Sub
 '*******************************************************************************


used here
Code:
   Txtlune = "t5"
   Tmoon = "t10"
      Call Nex_text(txtlune , " " , Black , Cyan , 0)
   If Icol > 0 Then

   Select Case Dummy                                      
      Case 0 To 1
           Picture = 23                                    
          Call Nex_textpic(tmoon , Picture )
         Call Nex_text(txtlune , "Nouvelle lune" , Black , Cyan , 0)      
      Case 2 To 5
           Picture = 24                                  
          Call Nex_textpic(tmoon , Picture )
           Call Nex_text(txtlune , " " , Black , Cyan , 0)
      Case 6 To 29
           Picture = 25                                  
          Call Nex_textpic(tmoon , Picture )
           Call Nex_text(txtlune , " " , Black , Cyan , 0)
      Case 30 To 54


I hope It can help you
JP Wink

_________________
pleasure to learn, to teach, to create
Back to top
View user's profile Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
Page 1 of 1

 
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