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: GUI Composer: Simple example for setting value on target with button

Part Number: TMS320F28379D


Hello,

Can you provide a simple example for using a GUI Composer v3 button to set a value on the target?

I understand the step of adding an event listener for "clicked".   What I'm missing is how to set data on the target.

GcWidget.querySelector('#button').then(widget => {
widget.addEventListener('clicked', () => alert("Button Clicked!"));
});

If I have a global variable in the sample application on  the target called 'sampledata', I guess is that I need to work with widget.pm.sampledata.  What I want to do is something like this:

GcWidget.querySelector('#button').then(widget => {
widget.addEventListener('clicked', () => widget.pm.sampledata = 1
});

...but of course the 'widget.pm.sampledata=1' is not the right syntax.

I have looked at the gallery for projects with search term "button".  The projects there are either for v2 applications or do not use buttons with actual hardware.

Thanks!

  • HI Mark,

    Sorry for the delay on your various GC questions. The functionality you seek is not straightforward to implement and requires some additional investigation.

    ki

  • GcWidget.querySelector('#button').then(widget => {
    widget.addEventListener('clicked', () => widget.pm.sampledata = 1
    });

    Try something like:

        GcWidget.querySelector('#button').then(widget => {
            widget.addEventListener('click', async () => {
                const binding = bindingRegistry.getBinding('pm.sampledata');
                const value = binding.getValue();
                value = 1;
                binding.updateValue(value);
            });

    Thanks

    ki