Announcement

Collapse
No announcement yet.

Keyboard Object Question

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Eran
    replied
    Hi Tim,

    1) I’ve made a sample code on how to Read LED object’s value. Hope it helps.
    2) Have you tried the “PostGenie Init” MagicCode Tim? If you haven’t yet, you can try either of these codes to a “PostGenie Init” MagicCode:
    A)
    gfx_Contrast(14);
    WriteObject(tGSlider, 0, peekW(CONTRAST));

    B)
    var CON;
    CON := 8;
    gfx_Contrast(CON);
    WriteObject(tGSlider, 0, CON);

    *The two codes are actually the same, but in actual coding, you’ll probably use the second one (only with the declaration on the “Constant/Global/Data” Magiccode) for you’re going to change the value of CON in the main loop.

    PrintStrings() function is used in Magic instead of WriteObject() to print strings. This is documented in the Visi-Genie Reference Manual under Section 6. You can also read the said manual to know how to use this function.

    This thread may also help you to understand more about using strings in Magic:
    https://forum.4dsystems.com.au/forum...-string-widget
    *I have attached sample codes for both setting up a start-up contrast and printing strings.

    Hope this helps and best regards,
    Eran
    Attached Files

    Leave a comment:


  • Bigtim
    replied
    Eran sorry to be a pain

    I am having a brain fart when it comes to using strings.

    I have successfully updated the text within a string object from my Arduino in an earlier version of the project.

    What I am trying to do now is dynamically control what the string displays using my magic code.

    for example

    WriteObject(tStrings,0, "Hello World");

    Should that work?

    I can't use a pre-determined message list (as I have seen in some of the examples) because the text I want to display will be dynamic and edited by the user.

    Leave a comment:


  • Bigtim
    replied
    Hi Eran

    The list box I hacked together based on the example you gave me is working really nicely. It is not as sophisticated as the one you sent me in that it doesn't scroll smoothly (still getting my head around how to do that but ) but at this stage of the development I'm happy with where I am at.

    In terms of the other two questions: (btw you are correct that at the moment all my functions and work is 'display side.' I want to do as much clever stuff in the display before moving on to the communication with the Arduino. )

    1) Essentially I am doing what you describe in option B. The only reason I asked the question is that I reuse the code to write to four LED objects. So before I call up the routine that edits the value to be displayed I need to retrieve the correct value in my 'mirror variable' which is fine and as you say not a huge overhead.

    I was just wondering if it were possible to READ the stored value in the LED object then all I would need to do would be to pass the function the index to the LED object I wanted to edit.

    2) I have a slider that is set up to adjust the contrast which is working fine. The slightly annoying thing is that on power up, the display 'resumes' using the last set contrast value. At the moment my slider has no way of knowing what this values is. So the first time I use the slider it is set at 0 when the contrast is maybe at 5. Once I use the slider then everything is ok and in sync as you say. What I'd really like to do on power up is READ the display's contrast setting, write this to my slider object such that the first time my 'set up' screen is displayed, the slider is showing the current value.

    Is there a memory location I can peek the contrast value from? EDIT HAVE I GOT THIS WRONG? DOES THE DISPLAY REMEMBER THE CONTRAST VALUE OR DOES IT START UP WITH A SPECIFIC VALUE EACH TIME?

    when I use the code:

    WriteObject(tGSlider,0, peekW(CONTRAST));

    on startup it always seems to return 0?

    Last edited by Bigtim; 28th April 2018, 08:05 PM.

    Leave a comment:


  • Eran
    replied

    That’s good to hear Tim!

    Program-wise, using String objects is simpler; but GUI-wise, the list box is better. If you want an opinion on which one to use, the string object is the one that I will recommend. To make it GUI-wise, utilizing the other features of Workshop4 is the KEY.

    Here are my inputs with regards to your other two questions, although I'm not entirely sure if I understood the questions correctly. Feel free to correct me.

    1. Well, using the Arduino host to read the led values is very possible; but I think using an additional one variable per leddigit is simpler. Consider the following options:
    A. When you are reading a leddgit, you will be needing first a Read function and save it to another variable then use it as you prefer. This will make you code two or three routines with more than five lines of codes.
    B. When you write a value to a leddigit, why not just store that value to another variable? This will only take a single routine and a single line of code. Perhaps this is what you’re referring to as “mirror type”?
    Example:
    WriteObject(tLeddigits, 0, value); //Where “value” is your variable. You can simply copy that variable to a new one so no further reading is to be done; thus
    newValue := value;
    *Taking into consideration that you have mentioned the “time-critical” factor in your previous post.


    2. You want to control the contrast value using the slider object and set a default contrast value other than zero, is this right?
    You can simply insert a magic code “Post Genie init” and set your slider value together with your contrast value there. About reading the contrast value, you can use the peekW(CONTRAST) function; but I don’t think you still need to read its contrast again for you’re already using a variable to set the contrast.


    I’m just assuming that all these routines are on the display side and I’m not sure if my assumptions about your algorithm are right Tim, but if not, maybe you can clarify more about your questions so I can help you?

    Best Regards,
    Eran

    Leave a comment:


  • Bigtim
    replied
    Eran

    With your fantastic help my project has really moved forward the last couple of days. Thank you so much.

    Two questions (again!) sorry.

    1)

    Is it possible to READ the value that has been set in an Leddiggits object?

    My code is working fine but because I'm not sure how to read these values, I am having to support additional variables to 'mirror' the values held in my LED objects. It would remove some code if I could read these objects from other code segments. Is that possible?

    2)

    Is it possible to read the displays current contrast value?

    One of my set up menu items lets the user change the contrast. First time I use it the slider is set to 0. It would be nice if I could initialise the slider with the contrast value when I power up.

    Leave a comment:


  • Bigtim
    replied
    Thanks Eran, I'll take a good look at the code you referenced.

    The reason I need to rely on information from the Arduino is that I am using the display to programme a programmable midi controller. So the display allows the user to define and edit a list of midi messages which are passed back to the Arduino such that when a given button is pressed the appropriate list of midi actions are sent out to the network. So its a) a bit time critical and b) very dynamic.

    Ultimately we plan to make the Arduino code open source so I am trying to make the display as flexible as possible and avoid 'hard coding' lists into the display or any widgets.

    Hmmmm the reason I went for the 'invisible buttons idea' was to try and keep all my touch code in the magic touch module. (with some help I modified the code you kindly helped me with for the led displays to do this.) I hadn't actually planned to put an object underneath as such (just print some data from the list in a 'known position' Do you think I would be better off using a string object that I can simply detect using magic touch?

    Leave a comment:


  • Eran
    replied
    Tim,

    If you really need a listbox with dynamic listnames, this can help you: https://forum.4dsystems.com.au/forum...tbox#post45814
    NOTE: This example is in designer environment, you can copy the code and paste it into a Magic code in Visi-Genie.

    About using transparent buttons. The setup is fine, just make sure that every time a button is pressed, the widget under it will be updated right after the button’s touch event. This is because every time you press on a transparent button, what’s under it (static text for example) would be cleared ‘visually’. Remember that whatever is updated the latest comes on the topmost layer and is the one displayed.

    Another way of implementing this is making multiple list boxes using smart widgets and show the list box containing the name that you have sent form the Arduino; but if you really need to write the list names from the Arduino dynamically, you can use the code above or the one that you’re trying to implement.

    Best Regards,

    Eran

    Leave a comment:


  • Bigtim
    replied
    Eran, quick question if I may

    Given that my list box needs dynamic data would I be right in assuming that smart widgets are not the way to go?

    I am thinking of building a list box from 'basic' elements eg

    Have a panel to frame the list box
    Lay four or five buttons on top to detect which option is pressed
    Write the indexed contents of my array 'underneath' these buttons
    Use a slider / buttons to modify the index to change which elements are displayed

    Does that sound like the right path would you say?

    Leave a comment:


  • Bigtim
    replied
    Hi Eran

    I think the issue with the manuals was me looking at the wrong documents, what a dope!

    The list box I need to try and create need to be able to take its list from data I will ultimately get from my host Arduino. (there are several points in my project where I will want to select data from one of several lists and I hope to be able to use one form to service this by dynamically setting up the list) In the first instance I am hoping to simulate setting up the list box by populating it in the display (once I've proved I can do that I'll have a look at comms with the Arduino.)

    Tim

    Leave a comment:


  • Eran
    replied
    Tim,

    By that, do you mean that you have opened the Diablo16 Processor Internal Functions Reference Manual? There are actually two manuals that can be opened in the Visi-Genie Magic environment. First is the Diablo 16 Internal Functions Reference Manual that can be opened when a Magic code editor box is open and your cursor is in it. Callable Functions for ViSi-Genie Magic are listed in the second manual (Visi-Genie Reference Manual) that can be accessed when you have selected any object in any form (just click on a widget to select).

    If this is not the case and your Reference Manual's version is of an older one, you can update your manual by going to File > Options > Updates and click the box Automatically Download Updates then press OK.

    If the list box contains a list of fixed "names", then you can do that using the Smart widget. The following videos contain list box examples that you may use as reference.
    1. https://www.youtube.com/watch?v=HQdGWwzr7Bw (00:50 to 1:00)
    2. https://www.youtube.com/watch?v=hSvNnPwSxnE (00:43 - 00:56)

    Hope it helps and regards,

    Eran

    Leave a comment:


  • Bigtim
    replied
    Eran

    Thanks amazing thank you so much. The reference manual tip is invaluable LOL I was using an old version that didn't have reference to the magic stuff!

    Do you know if there is an example available anywhere that shows how to set up a list box? The only other tricky thing in my project will be to receive some data from my Arduino, populate a list box and allow a user to select one of the options (and store that option in a variable).

    Thanks again for the help!

    Tim

    Leave a comment:


  • Eran
    replied
    Tim,

    Glad to hear that you're enjoying the pro version of Workshop4.

    The value of leddigits object can be simply updated using the function WriteObject. There is actually a number of callable functions for Visi-Genie Magic. The list can be found in the Section 6 of Workshop4 IDE VISI–GENIE REFERENCE MANUAL (Opened when F1 is pressed while an object is selected).

    *Attached is an example of what you’re trying to implement. I have also included the first feature of your project about touching one of the LED objects. You can always change the GUI and code of this example.

    Hope it helps and regards,
    Eran
    Attached Files

    Leave a comment:


  • Bigtim
    replied
    Originally posted by Eran View Post
    Tim,

    1. Yes Tim, the basic Visi-Genie features are still available in the pro version.The pro version just adds features like magic codes and smart widgets. You can also minimize the routines that you want the Arduino to run and let the display handle some of it (particularly display-related ones).
    2. The pro version will work for a single PC Tim. More information about the License can be found here: https://www.4dsystems.com.au/product/4D_Workshop_4_IDE/ under the BUY NOW section.
    3. Yes, list box can be implemented using the smart widgets. This might interest you: https://www.youtube.com/watch?v=HQdGWwzr7Bw . This might help you as well : https://www.youtube.com/watch?v=w1PCTq9H3Dw A lot of things can actually be done in the pro version of Workshop4.

    Regards,

    Eran
    Hi again Eran,

    Today I took your advice and went pro

    Made a good start to the project and have been playing with the basic password example in the IDE that make use of the magic keyboard event code which is exactly what I need.

    One thing I notice in most of the examples is that the input from the keyboard seems to be simply printed (putch) and erased from a set position on the screen. What I had hoped to do was direct my keyboard values (via a variable) to some led digit object but I'm struggling to find reference to a function to 'set' the value of an led digit object?

    Is such a function available / could you point me in the right direction to finding reference to it?

    Thank for all your help

    Tim

    Leave a comment:


  • Bigtim
    replied
    Eran

    That's fantastic, thank you again for your help

    Tim

    Leave a comment:


  • Eran
    replied
    Tim,

    1. Yes Tim, the basic Visi-Genie features are still available in the pro version.The pro version just adds features like magic codes and smart widgets. You can also minimize the routines that you want the Arduino to run and let the display handle some of it (particularly display-related ones).
    2. The pro version will work for a single PC Tim. More information about the License can be found here: https://www.4dsystems.com.au/product/4D_Workshop_4_IDE/ under the BUY NOW section.
    3. Yes, list box can be implemented using the smart widgets. This might interest you: https://www.youtube.com/watch?v=HQdGWwzr7Bw . This might help you as well : https://www.youtube.com/watch?v=w1PCTq9H3Dw A lot of things can actually be done in the pro version of Workshop4.

    Regards,

    Eran

    Leave a comment:

Working...
X