This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/TMS320F28069M: How to input an array in GUI Composer?

Part Number: TMS320F28069M


Tool/software: Code Composer Studio

Hi,

Is there a way to change an array's elements in GUI Composer? I have an int array in my C code and in my GUI, I would like to change the array elements while it's running. I've noticed that an array can be outputted in a text box, but there is no way to input an array.

Thank You,

Raisaat Rashid

  • Hi Raisaat,

    Binding to an array for write operating is something that we didn't have good support at the moment. However, you can use javascript to write the value.

    i.e gc.databind.registry.getBinding('myarray').setValue([1, 2, 3])

    Regards,
    Paterick

  • Hello Patrick,

    I need be able to change the array values while the GUI is running. So I'm afraid hard-coding the array values in JavaScript would not help. I have two more questions:

    1. Is there a way to input a string in a text box? I wrote some C code in CCS that works with a space-separated string of numbers like "1 2 3" and does some manipulation on it. I have a char *str pointer in my C code that is assigned that string, and I would like to tie that char pointer to a text box widget's value property. So when the GUI is running, I will input a string like "1 2 3" in that text box. I tried tying the char pointer to a text box widget's value property, but it doesn't work. I also tried tying evaluate['*str'] to the value property as described in http://processors.wiki.ti.com/index.php/GUI_Composer/Bind_Expressions but that is not working either.

    2. Is there a way I can get the value of a toggle button widget's checked property in JavaScript? I want my JavaScript code to do something if the toggle button is enabled.

    Any help would be highly appreciated.

    Thank You,

    Raisaat Rashid

  • I am not suggesting you to hardcoded the value when setting the array, I was just showing you a snippet of code to set the array in JavaScript.

    Here is the longer version of the snippet to set the array value:

    templateObj.$.ti_widget_textbox.addEventListener('changed', e => {
        let value = e.detail.newValue;
        gc.databind.registry.getBinding('my_model.myarray').setValue(value.split(','));
    });

    Create a new javascript file using File | New | JavaScript File and paste the above code to after the line console.log("Application template has been stamped.");

    Re 1: You can use the same approach as the integer array, but with the additional conversion from character to integer

    templateObj.$.ti_widget_textbox2.addEventListener('changed', e => {
        let value = e.detail.newValue;
        gc.databind.registry.getBinding('my_model.mychararray').setValue(value.split('').map(c => c.charCodeAt(0)));
    });

    For the string, mychararray variable is an array, you can create another text box and bind the value to an array pointer to see the change.

    Re 2: 

    templateObj.$.ti_widget_toggle_button.addEventListener('checked-changed', e => {
        console.log(e);
    });

    Regards,
    Patrick

  • I also filed a JIRA to track the array writing issue (GC-1783). Once it is fixed, you don't need the workaround to set the value using JavaScript.

    Regards,
    Patrick
  • Hi Patrick,

    Thanks a lot for your help! Your suggestions worked!

    Thank You,

    Raisaat Rashid