Code-changeable touchpanel icons?
vegastech
Posts: 369
What is the best approach to take for icons that will change based on button selection? I've gotten to the point in my weather parsing where I want to make the icons change based on the conditions found in the webpage. I have copied the necessary icons into TPD4 and I am assuming that I should load them into the touchpanel file for quick access. Should I create popup pages the size of each icon, and then just do a page flip based on my find_string command? What other ways are there to make this happen, and are these other ways more efficient or reliable? thanks.
0
Comments
Jeff
P.S.
I'm sure there are other ways as well
I worked what you asked last night and here is what I'm doing. I've got all of DirecTV's logos loaded in each panel (include R4s), and simply send the ^BMP command. The command is about as simple as the ^TXT.
^BMP-<variable text address>,<state>,<image name>
I've heard of people loading them onto their master and using dynamic imaging - an idea I will entertain this Monday to check on how quick they load.
Of course send level has some advantages since the master tracks levels and won't resend the command if it already has while the ^BMP- command can't really be tracked automatically by the master so depending on your feedback structure you may repeat the command, sending it to the panels 100's or 1,000's of times and subsequently bogging down the system.
The module I wrote a few years back used the ^BMP- method and at that time my feedback methodology was much different than it is today so I would track everything sent in a duplicate structure or array for comparison & verification.
Ex.
You can swee here that I'm sending directly to an array of panels which I wouldn't do today and since I now tend to send feedback only when it changes or a tp comes "on page" I wouldn't use the duplicate "sent" structure or array either.
That works - although if it's a multi-state button you would need to use the ^ani command; send_level for a multi-state bargraph button type.
Like maybe...once the icon is created, it can be imported into additional panels easily, or something like that?
Bingo - copy and paste a single button aot a button and a "resources" page. With specific regards to the weather thing, the Yahoo api provides a unique integer value for each condition so if your button states are in the same order the code is pretty easy too.
If you create a constant array of icon names and the just put a for loop in your function that does a find string or == string for each index postion until a match is found and then just return the index number. If no match return 0 and send the N/A.png or similar.
It's really a matter of preference as to which method you use and each method has advantages and disadvantages depending on how you work your code. With the look up table/send level method you can forget a long select active in lieu of a constant array which you can put into it's own define constant section so that it stays neatly folded out of the way. Then your working code appears shorter and easier to navigate up & down.
It compiles fine. I currently have the local variables commented out so that I can verify their operability in the debugger, and so far, the nCondCode variable is populating with a value of 34, which is "fair". However, my button never leaves the first state. I believe what I have added for the button animation is for it to start at its current state (the zero), and change to the state referenced by the variable.
FYI, in the code you posted you need ITOA(nCondCode) in the string for it to work.