code

General discussion on Visual GLCD Software.
Post Reply
Author
Message
antonadc
Posts: 277
Joined: 14 Dec 2012 10:15
Location: Pretoria South Africa

code

#1 Post by antonadc » 05 Jan 2016 17:15

Hi guys

I have a small problem and don't know what to do. I have written a small program with a few screens. When you click on the main menu button you are taken to a screen which displays time.
I have made a loop in the screen to read the time from a pcf8583 and display the time on the screen. Now there is no way back to the main screen. If I try and put a button on the screen nothing happens as the pic does not get to the button software as its busy reading and displaying time. If I try and put the button software in the loop the compiler will not accept it. Any ideas how I can get back to the main screen.

As you can see I have made ButtonRound5 as the button which calls screen4 where the time code is.

Code: Select all

sub procedure ButtonRound5OnClick()
DrawScreen(@Screen4)
loop:
  I2C1_Start()           ' issue I2C start signal
  I2C1_Wr(0xA0)          ' send byte via I2C (device address + W)
  I2C1_WR(0)
  I2C1_Repeated_Start()           ' issue I2C signal repeated start
  I2C1_Wr(0xA1)          ' send byte (device address + R)
  dummy   = I2C1_rd(1)
  dummy   = I2C1_rd(1)
  seconds = I2C1_Rd(1)    ' Read seconds byte
  minutes = I2C1_Rd(1)    ' Read minutes byte
  hours   = I2C1_Rd(1)      ' Read hours byte
  day    = I2C1_Rd(1)       ' Read year/day byte
  month  = I2C1_Rd(0)     ' Read weekday/month byte}
  I2C1_Stop()

  month=month << 3
  month=month >> 3

  Drawbox(@Box1)
  dummy=BCD2DEC(seconds)
  inttostr(dummy,hold_str)
  if dummy<10 then
  hold_str[3]="0"
  end if
  strcpy(Label6_Caption,hold_str)
  DrawLabel(@label6)

  Drawbox(@Box2)
  dummy=BCD2DEC(minutes)
  inttostr(dummy,hold_str)
  if dummy<10 then
  hold_str[3]="0"
  end if
  strcpy(Label9_Caption,hold_str)
  DrawLabel(@label9)

  Drawbox(@Box3)
  dummy=BCD2DEC(hours)
  inttostr(dummy,hold_str)
  if dummy<10 then
  hold_str[3]="0"
  end if
  strcpy(Label10_Caption,hold_str)
  DrawLabel(@label10)

 goto loop
end sub

Thanks in advance.

Anton

User avatar
biljana.nedeljkovic
mikroElektronika team
Posts: 1043
Joined: 30 Jun 2015 15:15

Re: code

#2 Post by biljana.nedeljkovic » 06 Jan 2016 14:55

Hello,

Can you attach the whole project?

Also, have you used example code provided in the Visual GLCD to see how to move to the previous and next screen?
You have lots of projects available in the Examples folder.

Kind regards,
Biljana

antonadc
Posts: 277
Joined: 14 Dec 2012 10:15
Location: Pretoria South Africa

Re: code

#3 Post by antonadc » 07 Jan 2016 01:05

attached code. There is nothing in the examples that can help. Thanks.

Anton
Attachments
6963small.rar
(234.55 KiB) Downloaded 199 times

antonadc
Posts: 277
Joined: 14 Dec 2012 10:15
Location: Pretoria South Africa

Re: code

#4 Post by antonadc » 12 Jan 2016 09:38

Please ME team can you help me here.

Thanks

Anton

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: code

#5 Post by filip » 13 Jan 2016 13:36

Hi,

Have you tried using break statement to get out of the loop ?

Regards,
Filip.

antonadc
Posts: 277
Joined: 14 Dec 2012 10:15
Location: Pretoria South Africa

Re: code

#6 Post by antonadc » 14 Jan 2016 10:06

how would I write the code as the compiler rejects the break code

Post Reply

Return to “Visual GLCD General”