Beijer Electronics (formerly QSI Corporation)

Manufacturer of Mobile Data and Human Machine Interface Terminals.
It is currently Sun Nov 19, 2017 3:17 am

All times are UTC - 7 hours




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: Spinner
PostPosted: Thu May 04, 2006 12:55 pm 
Offline

Joined: Mon May 01, 2006 3:27 pm
Posts: 60
I am using 3 spinners to make changes to 3 values which I store is an Array. I have 15 buttons that are use target the arrays position and store the spinner value. The spinner value gets changes in two ways. 1) by mannualy touching the spinner and by loading a value from a variabl.



The problems is I want to only run the transmit code withing the function ony when the value has changed by screen touch. I tried a boolean equaation but no luck. Note when I change the spinner value in software I set TxReady1=False





func valueChanged()





Blue[Fixture]=spinner_b.value





if TxReady1 then





toTx[0]= 255

toTx[1]= Group

toTx[2]= Fixture

toTx[3]= RED[Fixture]

toTx[4]= GREEN[Fixture]

toTx[5]= BLUE[Fixture]



endif



endfunc


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 04, 2006 1:12 pm 
Offline
QSI Support
QSI Support
User avatar

Joined: Wed Mar 08, 2006 12:25 pm
Posts: 881
Location: Salt Lake City, Utah
You might consider handling the HandleRelease() event instead of ValueChanged(). This will only be called when the slider is touch released.



It may also exhibit better performance because ValueChanged() is called continually while a user is moving the slider which could result in far more transmissions than you intended



I tend to use HandleRelease() whenever I need to finalize a value set by a slider. I use ValueChanged() for realtime status updates, for example if I have a label that displays the slider's value in a numeric format, I would update the label in the ValueChanged event.



If you really really need to do your code in the ValueChanged event, you should declare a global boolean value:

Code:
dim SliderIsTouched as boolean




Then handle all the events as follows

Code:

func HandlePress()

   sliderIsTouched := true

endfunc



func ValueChanged()

    if sliderIsTouched then

        'Code to transmit

    endif

endfunc



func HandleRelease()

    sliderIsTouched := false

endfunc

_________________
Jeremy
http://www.beijerinc.com


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 04, 2006 2:48 pm 
Offline

Joined: Mon May 01, 2006 3:27 pm
Posts: 60
I am using Spinner which only has Inc, Dec ,Valuechanged and released. I do need continuious updates.



Any Idea ?


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 04, 2006 3:00 pm 
Offline
QSI Support
QSI Support
User avatar

Joined: Wed Mar 08, 2006 12:25 pm
Posts: 881
Location: Salt Lake City, Utah
Sorry, I read your post (and your previous one) as though you were using a SliderV2, not a SpinnerV2.



In this case your code becomes a bit easier, if a little odd seeming at first. Ignore the code from the previous example.



Code:

func Increment()

   'Do your code to transmit the value you want

endfunc



func Decrement()

    Increment() ' Calls the Increment event.

endfunc





The Increment and Decrement events are only called when the spinner is touched, never when a value is set programmatically. It may seem odd to call Increment() in the Decrement() event handler, but remember that Increment() is an event handler, NOT a command to the spinner to increment its value. If you don't like to do that, you could create a global function or you could duplicate copy and past the code from Increment to Decrement (although that creates a maintance headache).

_________________
Jeremy
http://www.beijerinc.com


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 04, 2006 4:27 pm 
Offline

Joined: Mon May 01, 2006 3:27 pm
Posts: 60
I tried the Inc and dec. but when I do a spinner_R.value=RED[Fixture] in a button click it does run



Any Idea ?







func decrement()



RED[Fixture]=spinner_r.value

SendTx()



endfunc



func increment()

RED[Fixture]=spinner_r.value

SendTx()



endfunc





func click()



spinner_R.value=RED[Fixture]



endfunc


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 05, 2006 6:42 am 
Offline
QSI Support
QSI Support
User avatar

Joined: Wed Mar 08, 2006 12:25 pm
Posts: 881
Location: Salt Lake City, Utah
Wow, I did not know that the spinner behaved that way. You are right.



Well that makes this a bit more of a challenge, but not impossible.



Code:

'Global code:

Dim suppressTxOnSpinnerValueChange as boolean

init suppressTxOnSpinnerValueChange  := false



func SetSpinner (spinner as objref SpinnerV2, newValue as float)

    suppressTxOnSpinnerValueChange = true

    spinner.value = newValue

    suppressTxOnSpinnerValueChange = false

endfunc



'Spinner code:

func ValueChanged()

    RED[Fixture]=spinner_r.value

    if not suppressTxOnSpinnerValueChange then

        SendTx()

    endif

endfunc



'Button code

func Click()

    SetSpinner (spinner_R, RED[Fixture])

endfunc





The other possibility would be to create a new type of spinner that does not call its event functions when the value is set programmatically. This is not too difficult, but a bit more complex to explain that what I just did.



I hope this works for you. Good luck.

_________________
Jeremy
http://www.beijerinc.com


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 05, 2006 6:56 am 
Thanks for the code.



I just used a boolean in the button and tested the boolean in the transmit code which work fine but may creat problems as I get more into the code.



I also noticed that the serial data is only sent every 100ms and each update from the spinner is not sent. Is there a way around this to get fater updats ?



func click()



SliderIsTouched := false



spinner_R.value=RED[Fixture]

spinner_G.value=Green[Fixture]

spinner_B.value=Blue[Fixture]



SliderIsTouched := true



endfunc


Top
  
 
 Post subject:
PostPosted: Fri May 05, 2006 7:04 am 
Offline
QSI Support
QSI Support
User avatar

Joined: Wed Mar 08, 2006 12:25 pm
Posts: 881
Location: Salt Lake City, Utah
Well, I am not sure about the "missing updates". I would run this in simulation mode in Qlarity Foundry and review the Communciations Window to verify that updates are all being transmitted.



As far as the updates every 100ms, if you look at your spinners, you will notice that the defult "repeatRate" is 100ms -- so if you are transmitting every 100 ms, that is dead on for the spinner. You can, if you want, increase the rate of the spinner (40 ms is the maximum). However, much faster than 100 and the spinner becomes difficult to use as you usually overshoot the value you want.

_________________
Jeremy
http://www.beijerinc.com


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 05, 2006 1:17 pm 
That did it 40 works goog. This is for a light dimmer so the user would use the bulb instensity as visual refrence.



Again thanks for the quick replys.


Top
  
 
 Post subject:
PostPosted: Fri May 05, 2006 1:39 pm 
Offline
QSI Support
QSI Support
User avatar

Joined: Wed Mar 08, 2006 12:25 pm
Posts: 881
Location: Salt Lake City, Utah
I am glad to hear it. I don't mean to question your design, but it seems to me that a Slider would be a more natural object to model light dimming -- as the user is in total control of the speed of dimming and can quickly slide to the max/min brightness.



If you are only using the spinner for the numerical readout, it is possible to use a slider in conjunction with a label to get the same effect.



The main situation where I see a spinner as superior to a slider would be if you want the dimming to occur at a consistent speed -- which is difficult to obtain with a slider.



If you have a ton of screen space, you can do something like this www.qsicorp.com/engfiles/Sliders.qly

_________________
Jeremy
http://www.beijerinc.com


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC - 7 hours


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 post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group