483 views
in System Integration by

Another question for you all! thank you for all your help so far! 

I have managed to receive data from the device and display on the GUI, now i'd like to do the opposite and send data from the GUI to the device to control lights. 

I have created a device property called Rval1 , i am trying to get the device driver to use this value but so far no luck.  

 

Here is the code within the device driver;

 

void DeviceDriver_SetRcolour()

{
#ifdef _ApplicationDeviceClass_

{


softPwmCreate(RED_PIN, Rval1, 100);
}

#endif
}

 

If I write Rval1 = 100;  it works fine.... so there is no hardware issue. I just cant seem to work out where I am going wrong sending the "Rval1" from the gui so the device driver reads it and places it within the softPwmCreate() line of code. 

 

1 Answer

0 votes
by
Hello,

in principle you choose the right approach to send data to the device.

What I'm wondering is that DeviceDriver_SetRcolour() has no parameter - but it is called with the current value of the property... There must be a linker error or warning. Are you using another Rval1 variable within your device driver?

In order to find the missing part, you can add some printf() statement within your device driver to print the current value.

Best regards,

Manfred.
by

Thank you! 

Changing the code to this has worked:

 

int DeviceDriver_SetRcolour (Rval1)

{

{
#ifdef _ApplicationDeviceClass_
{


{
softPwmCreate(RED_PIN, Rval1, 100);
}
 

 

The only issue i am having now is the value doesn't update with the GUI widget. It receives the first signal then nothing.  I have a ValueDisplay on the gui representing Rval1 so i know the value is changing correctly, but the device isn't. 

For some context, its a simple LED RGB strip I am learning to control with the GUI. I thought it would be easier to learn by sending the data as one property for each R, G and B. When i first turn it on, the lights represent the initial colour I select, however it wont change after this. does the OnSet method update whenever the current Rval1 is changed or do I need further methods to update the Rval1 every time the value changes. 

 

Thank you for all your help! 

 

by
Without knowing your code it is difficult to give you further helpful advices...

But: I'm wondering about "softPwmCreate()" - the name indicates that something is created. Maybe there are further API functions to set a current PWM value?

From my understanding, a PWM should be created when the device driver is initialized, and the PWM value should change when the device property of your GUI application changes.

Maybe you can first implement your device driver, just using printf() statements and test this with the GUI application, finally you can add your RGB strip.
by

Thank you! that was the problem. 

I needed the softPwmCreate in the initialisation section with the initial value as 0, then the softpwmWrite() function in the GUI function !

I now have a working RGB led controller. laugh 

 

by
Great to hear that your RGB LED controller is now working.

Embedded Wizard Website | Privacy Policy | Imprint

...