After paqque's discovery, I decided to try to implement the first iteration of my backlight control. Whilst some of my backlight questions may be irrelevant if you choose not to keep the functionality in, I also have a question about the behaviour of incrementing variables in button commands.
I currently use the following code:
if,var,var15,,<,4
imagebutton,203,0,up_arrow_small.png,t,6,13,var15_1
button,203,0,8,8,-1,40,%var15%,
else
endif
image,188,0,Backlight.png,t
button,188,0,13,16,-1,0,%backlight,
if,var,var15,,>,0
imagebutton,203,8,down_arrow_small.png,t,6,13,var15_-1
button,203,8,8,8,-1,40,%var15%,
else
endif
The intent here is to only display the up/down arrows if the current value of var15 is within the range 0..4, ie the valid range for backlight settings. The imagebutton is intended to increment/decrement the variable, whilst the button is intended to call action 40 with this new value.
What I think I am seeing is that the button command is being called with the old value in var15 each time, but var15 is being incremented/decremented appropriately. So, the button command lags 1 value behind where I think it should be. If you paste the code into your skin you will see some odd, but explicable, behaviour at the limit conditions.
Is there some guidance you can give me on how this is actually working, and perhaps how I can implement the above better?
as the skin is processed the "%varx%" are replaced by the data they contain.
so when this is encountered (with var15 being 2):
imagebutton,203,0,up_arrow_small.png,t,6,13,var15_1
button,203,0,8,8,-1,40,%var15%,
the actual buttons are
imagebutton,203,0,up_arrow_small.png,t,6,13,var15_1
button,203,0,8,8,-1,40,2,
so when the button is pressed, var15 will be incremented by 1, and the brightness will be set to the old value.
it seems to me that if you change the two if statements to be <5 and >-1 it may work better.
Thanks for the clarification on variable substitution - makes it much easier to understand.
Quote from: srsit seems to me that if you change the two if statements to be <5 and >-1 it may work better.
Yes, it does sort of work that way, but it means that if I increment it as far as it goes then var15 is set to 5, then if I hit the decrement button it calls action 40 with the parameter of 5 (because the decrement doesn't take effect til next time). It so happens this has no negative effect, except to make the first click apparently ineffectual.
It would be great if I could use the following, instead:
if,var,var15,,<,4
imagebutton,203,0,up_arrow_small.png,t,6,13,var15_1
button,203,0,8,8,-1,40,%var15%+1,
else
endif
image,188,0,Backlight.png,t
button,188,0,13,16,-1,0,%backlight,
if,var,var15,,>,0
imagebutton,203,8,down_arrow_small.png,t,6,13,var15_-1
button,203,8,8,8,-1,40,%var15%-1,
else
endifThis would obviously require the simple arithmetic to be parsed at variable substitution time. In terms of parsing, it might be even easier to use this instead:
button,203,8,8,8,-1,40,%var15-1%,I'm not sure whether this should be in the feature requests section - if you think so, let me know.
I think this should work
imagebutton,203,0,up_arrow_small.png,t,6,13,var15_1
addvar,var15,1
button,203,0,8,8,-1,40,%var15%,
addvar,var15,-1
I have iPAQ 2215 and I am not sure if other ipaqs have same backlight controls or not but here is the issue I am facing.
In 2215, the backlight slider has 60 steps and with TodayPlus 0.10.0, I can switch between 0 and 4 using the action 40 but not beyond that value 4.
So effectively the backlight is staying at very low values. I think either the scaling of the values or allowing it to set between 0 and 59 would be better.
And yes, I was not using the above code exactly so it was not that I was looping between 0 and 4, its just that action 40 was not responding to any value greater than 4.