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.

TMS320F28379D: Revisiting TMS320F28379D: GUI Composer: Simple example for setting value on target with button

Part Number: TMS320F28379D

Tool/software:

Hello,

I tried implementing the javascript for using a button-click to set a value on the target, following the previous suggestion in this thread:

https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1250817/tms320f28379d-gui-composer-simple-example-for-setting-value-on-target-with-button

I have implemented in index.js:

const init = () => {

GcWidget.querySelector('#myButton').then(widget => {
widget.addEventListener('click', async () => {
const binding = bindingRegistry.getBinding('pm.sampledata');
const value = binding.getValue();
// value = 1;
const value2 = 1;
binding.updateValue(value2);
alert("Button Clicked!");
});
});


};

I have an infinite while loop on the target checking the value of sampledata, and if "sampledata" becomes some non-zero value, an LED will be toggled on the board, and another variable will also be incremented that I can monitor via link to another GUI Composer text box.

I get the "Button Clicked!" alert when I press the button, but I do not see sampledata is being set.  (The LED is not toggling, the variable is not being incremented).

Do I need to put the "GcWidget.queerySelector" somewhere else?  Or is there something else that I need to do to get this to work?

Thanks!

  • Note, I have a workaround, where I implement a dummy/hidden input box, use GUI Composer to link the value field of this new input to a "buttonpress" variable on the target.  With the button, I can use very similar code to update the value in the input box, and that in turn will be transferred to the target.  

    But it should still be possible to write a value directly to pm.buttonpress, and I would still like to investigate this option.  

    Anyway, the work-around:

    const init = () => {

    GcWidget.querySelector('#myButton').then(widget => {
    widget.addEventListener('click', async () => {

    myFunction();
    });
    });

    var myFunction = function(){
    const binding = bindingRegistry.getBinding('input_1.value');
    var value = binding.getValue();
    value++;
    binding.updateValue(value);
    alert("myFunction() called");

    };