Hello,
many good questions, which I had to answer myself too (with some reverse engineering).
>>-Depending on application, I want to use one or two quadratur decoders. If I want to use both, must I create two interfaces and two templates, one for each decoder or is there a way to use one interface with two templates? In this case, what is the best way to ex/include the bean according to settings in descendant bean? Encapsulate in boolean group?
A boolean group is good just for enable/disable something. Simple, but for multiple things that might not be a good choice.
The solutions is to use a 'list of components': I have attached you an example I had created to implement an LED matrix (for a larger project): the matrix consists of a variable row of lines and columns. The rows are implemented with a variable number of 'LED' components, and the columns are 2 times a 8bit LEDbyte (see attached screenshots).
Now how to create this in the component is unfortunately a lot of 'magic sauce' and some try and error on my side. One thing is that you have to set up the properties correctly (see as well the screenshot I have attached).
Notice the 'ItemsSymb' with name 'Row': this is actually what you can use in your driver:
void %'ModuleName'%.%On(void)
{
%:maxRow=%RowSymbolNumItems
%:maxRow-=1
%:maxCol=%ColumnSymbolNumItems
%:maxCol-=1
/* revert back to previous state */
%for i from [0..%maxRow]
inherited.Row%i.On(); /* anode row %i status */
%endfor
%for i from [0..%maxCol]
inherited.Column%i.PutVal(0x00); /* cathode column %i status */
%endfor
}
Notice as well %RowSymbolNumItems: this gives you the number of elements in the list.
When you generate code for it, you will get something like this:
void LEDM1_On(void)
{
/* revert back to previous state */
Inhr1_On(); /* anode row 0 status */
Inhr2_On(); /* anode row 1 status */
Inhr3_On(); /* anode row 2 status */
Inhr4_On(); /* anode row 3 status */
Inhr5_On(); /* anode row 4 status */
Inhr6_PutVal(0x00); /* cathode column 0 status */
Inhr7_PutVal(0x00); /* cathode column 1 status */
}
Best thing is if you inspect my component (learning from that example).
>>-If I create local templates and afterwards an local interface (same location), I'm not able to assign created template to interface. With gloabl template, that doesn't happen...
Not sure what you mean here?
>>-How do I specify a name for the inherited bean in order to avoid the Inhr* names given by PE.
Good one :smileyhappy:. That was one of the first things I did for most of my components. Go to your 'Beans' folder and open the *.bean file in a text editor. Then search for
<InhrBeanBaseName>......</InhrBeanBaseName>
And change the name there.
>>-Sometimes I experience that PE doesn't list the inherited method in the component tree? Although I follow same inheritance scheme as with other beans where they show.
Yes, I was wondering too, and I believe this is the setting in the .bean file which affects this:
<ShowInheritedMethodsEventsInPrjTree>true</ShowInheritedMethodsEventsInPrjTree>
Check if this is set to false in your case.
>>Sorry to take up your time with such basic questions... As we only got license for CW8.2.3 and the old "Bean Wizard" I feel that I'm hassling here and there with usablity issues that might in the mean time - especially since the transition to CW10.1 - have resolved itself.
No need to feel sorry about this, and these are in fact some advanced questions anyway. I know that the Processor Expert team is monitoring that list, and they know that many things especially in the documentation need to be improved. MCU10.2 comes with a new "Bean Wizard" (well, it is named "Component Wizard") within eclipse. But if you are used to the 'classic' Bean Wizard, it is still there under
<installation>\MCU\ProcessorExpert\BeanWizard.exe
As the forum only allows me to attach 3 files, I'll post the example in a follow-up.
Hope that helps,
BK