A couple of queries on component creation:
I'm working on a simple component which has a couple of 'optional' connections:
If the user leaves these as 'unconnected' a warning is given that the unconnected pins may cause problems. Is there a 'correct' way to allow unconnected pins?
The component will allow one or optionally two controls to be used - is there a way to hide the second set of pins if the user deselects the second controller.
Is there a way to test for a unconnected pin in a macro (this is not an error - the pin can either be connected to a PWM pin or jumpered to 5V on the driver board)
Some FC components have properties with 'collapsible' subsections - I couldn't create these in my own component - how do you go about creating them?
Many thanks
Martin
Component Creation
Moderator: Benj
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Component Creation
Hi Martin
Hidden pins still generate code and so need to be connected to avoid the error. The easy fix is that when pins are hidden you take the value of a valid pin property and copy this value to your hidden pins in the property change event macro.
To add sections right click the properties window and select add category. This has a variable name just as the properties do and can be hidden in the same manner hiding any properties nested inside.
Hope this helps.
Hidden pins still generate code and so need to be connected to avoid the error. The easy fix is that when pins are hidden you take the value of a valid pin property and copy this value to your hidden pins in the property change event macro.
To add sections right click the properties window and select add category. This has a variable name just as the properties do and can be hidden in the same manner hiding any properties nested inside.
Hope this helps.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Valued Contributor
- Posts: 1191
- Joined: Wed May 31, 2017 11:57 am
- Has thanked: 70 times
- Been thanked: 440 times
- Contact:
Re: Component Creation
Not having a lot of joy with this:
Importing the CAL_PWM component generates a heap of errors in v8 (though seems ok in v7)
I haven't managed a neat solution to the NC pin problem - do you have any examples of altering the properties at compile time?
Martin
Importing the CAL_PWM component generates a heap of errors in v8 (though seems ok in v7)
This using an Arduino Nano as target. I've tried using different PWM channels. Transferring back to v7 and it seems to compile AOK. I only use Enable and SetDuty8Bit (at present) from the CAL_PWM.Launching the compiler...
E:\Flowcode\Common\Compilers\avr\batchfiles\avra.bat atmega328p "C:\Users\Martin\DOWNLO~1\Flowcode1.elf" "C:\Users\Martin\DOWNLO~1\Flowcode1.c" "C:\Users\Martin\DOWNLO~1\Flowcode1.lst"
C:\Users\Martin\DOWNLO~1>"E:\Flowcode\Common\Compilers\avr\batchfiles\..\bin\avr-gcc.exe" -mmcu=atmega328p -Os -ffunction-sections -fdata-sections -funsigned-char -o "C:\Users\Martin\DOWNLO~1\Flowcode1.elf" "C:\Users\Martin\DOWNLO~1\Flowcode1.c" -lm -Wl,-gc-sections
In file included from C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\includes.c:484,
from C:\Users\Martin\DOWNLO~1\Flowcode1.c
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\/AVR\AVR_CAL_PWM.c:106:4: error: #error "PWM channel selected is greater then available PWM Channel Count"
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\/AVR\AVR_CAL_PWM.c:477:3: warning: #warning "Period control register not available on target device, period will default to 255 + 1"
In file included from C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\includes.c:484,
from C:\Users\Martin\DOWNLO~1\Flowcode1.c
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\/AVR\AVR_CAL_PWM.c: In function 'FC_CAL_PWM_Enable_1':
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\/AVR\AVR_CAL_PWM.c:503: error: 'MX_TCCR_X' undeclared (first use in this function)
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\/AVR\AVR_CAL_PWM.c:503: error: (Each undeclared identifier is reported only once
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\/AVR\AVR_CAL_PWM.c:503: error: for each function it appears in.)
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\/AVR\AVR_CAL_PWM.c:503: error: 'MX_PWM_COM0_X' undeclared (first use in this function)
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\/AVR\AVR_CAL_PWM.c:508: error: 'MX_PWM_COM1_X' undeclared (first use in this function)
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\/AVR\AVR_CAL_PWM.c: In function 'FC_CAL_PWM_Disable_1':
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\/AVR\AVR_CAL_PWM.c:534: error: 'MX_TCCR_X' undeclared (first use in this function)
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\/AVR\AVR_CAL_PWM.c:534: error: 'MX_PWM_COM1_X' undeclared (first use in this function)
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\/AVR\AVR_CAL_PWM.c: In function 'FC_CAL_PWM_SetDuty8Bit_1':
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\/AVR\AVR_CAL_PWM.c:554: error: 'MX_DUTY_REG_X' undeclared (first use in this function)
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\/AVR\AVR_CAL_PWM.c: In function 'FC_CAL_PWM_SetDuty10Bit_1':
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\/AVR\AVR_CAL_PWM.c:830: error: 'MX_DUTY_REG_X' undeclared (first use in this function)
I haven't managed a neat solution to the NC pin problem - do you have any examples of altering the properties at compile time?
Martin
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: Component Creation
Hi Martin,
The errors you have are due to a bug in the PWM CAL component for Arduino
I have now fixed this and attached the component, to go into your C:\ProgramData\MatrixTSL\FlowcodeV8\Components directory,
This will hopefully get pushed out to the auto-update system tomorrow, if you want to wait for that instead.
Thanks
Leigh
The errors you have are due to a bug in the PWM CAL component for Arduino
I have now fixed this and attached the component, to go into your C:\ProgramData\MatrixTSL\FlowcodeV8\Components directory,
This will hopefully get pushed out to the auto-update system tomorrow, if you want to wait for that instead.
Thanks
Leigh
- Attachments
-
- cal_pwm.fcpx
- (9.99 KiB) Downloaded 354 times
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: Component Creation
We usually update properties when one of them changes, by adding code into an Ev_Property event macrodo you have any examples of altering the properties at compile time?
This can be done with sim icons,
such as this example that reads the CHANNEL property of a cal_uart component and sets the value of a panel property The SIM functions can also be called from a calculation icon Just in case the image is difficult to read, here is the calculation code for a property copy from cal_uart to our local panel property
Code: Select all
::Component .Property .SetValue (this,"MY_PORT", ::Component .Property .GetValue (cal_uart,"PORT"))
Hope that helps
Leigh