Embedded C within a component. [Resolved]
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: Embedded C within a component.
This demo is significantly improved in the Ev_Property respect. It will work with any number of properties as long as the the naming of the property variables remains consistent.
It also auto calculates the sizes for you now too .
It also auto calculates the sizes for you now too .
- Attachments
-
- CGenDemo2.fcfx
- (19.08 KiB) Downloaded 233 times
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
- 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: Embedded C within a component.
Without the size could be fine too, just remember to remove the line in the AddHeader that adds the size in the [] brackets.
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
- 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: Embedded C within a component.
There was a bug in example 2 in the Ev_Property loop. Now fixed with an additional MaxImages property. Also another bug in the ShowImages macro. Need to learn to slow down and take my time more but my dad rang me mid flow.
Here is the exported component, Named CGenDemo under Misc.
This is the generated header code from the exported component.
And here is the switch statement.
I've also noticed the ImageData properties should be "Line Of Text" type properties and not "Multiple Lines Of Text" as carriage returns in the data will likely break the code generation without correct \ termination.
Here is the exported component, Named CGenDemo under Misc.
This is the generated header code from the exported component.
Code: Select all
//AddHeader Added Content
const char Image0[8] = {1,2,3,4,5,6,7,8};
const char Image1[4] = {1,2,3,4};
//AddHeader Added Content End
Code: Select all
switch (FCL_IMAGEINDEX)
{
case 1:
{
#if (1) // 2 > 1
FCV_RETURN = Image1[FCL_DATAPOINTER];
// #else
//Code has been optimised out by the pre-processor
#endif
break;
}
case 2:
{
#if (0) // 2 > 2
//Code has been optimised out by the pre-processor
// #else
#endif
break;
}
case 3:
{
#if (0) // 2 > 3
//Code has been optimised out by the pre-processor
// #else
#endif
break;
}
default:
{
#if (1) // 2 > 0
FCV_RETURN = Image0[FCL_DATAPOINTER];
// #else
//Code has been optimised out by the pre-processor
#endif
}
}
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
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Embedded C within a component.
Hi Ben,
You have Image Data 0 & Image Data 1 within properties.
All the image data (from 1 to whatever is required) will only be contained within supplementary code window in the form of: etc.
Can the properties just be deleted so the data within supplementary code window be picked up instead?
If the c code within ShowImage was left as:
etc I'm assuming all will work ok without any changes?
You have Image Data 0 & Image Data 1 within properties.
All the image data (from 1 to whatever is required) will only be contained within supplementary code window in the form of:
Code: Select all
char const unsigned Image1[]={75,165,10,153,74,169,74,173,73,165,42,153,241,177,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,09,161,138,193,43,234,235,209,138,189,138,185,170,197,11,226,11,222,41,161,51,186,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,42,157,43,230,170,193,138,189,11,226,108,250,108,254,76,246,0,0,0};
char const unsigned Image2[] =
{255,127,255,127,255,127,255,127,255,127,255,127,255,127,255,127,255,127,255,127,255,127,255,127,255,127,255,127,255,127,255,127,255,127,255,127,255,127,239,189,157,243,90,235,83,202,255,127,255,127,255,127,255,127,255,127,255,127,255,127,255,127,255,127,
255,127,255,127,255,127,255,127,255,127,255,127,255,127,255,127,255,127,255,127,255,127,255,127,255,127,255,127,255,127,255,127,255,127,255,127,255,127,255,127,255,127,239,189,157,243,90,235,83,202,255,127,255,127,255,127,255,127,255,127,255,127,255,127,
255,127,255,127,255,127,255,127,255,127,255,127,255,127,255,127,255,127,255,127,255,127,255,127,255,127,255,127,255,127,255,127,255,127};
char const unsigned Image3[] =
{,150,255,150,255,238,185,192,253,192,125,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,96,126,96,254,96,254,
128,254,128,254,160,254,160,254,192,254,192,254,224,254,0,127,0,0,64,125,32,253,32,253,64,253,64,253,96,253,96,253,128,253,128,253,173,169,150,255,150,255,15,190,192,253,192,125,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,96,254,128,254,128,254,160,254,160,254,192,254,192,254,192,254,224,254,224,126,0,0,32,125,32,253,64,253,64,253,96,253,96,253,96,253,128,253};
Can the properties just be deleted so the data within supplementary code window be picked up instead?
If the c code within ShowImage was left as:
Code: Select all
FCV_RETURN = Image1[FCL_DATAPOINTER];
Code: Select all
FCV_RETURN = Image2[FCL_DATAPOINTER];
Code: Select all
FCV_RETURN = Image3[FCL_DATAPOINTER];
Martin
- 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: Embedded C within a component.
Hi Martin,
Yes you can simply have the array declarations in the supplementary code and then reference using the NumImages decisions and the switch statement.
I was probably over engineering things
Yes you can simply have the array declarations in the supplementary code and then reference using the NumImages decisions and the switch statement.
I was probably over engineering things
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
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Embedded C within a component.
Thanks Ben,
So I will just need number of images.
The Max number is determined by how many switch statements are added within ShowImage macro.
I think it would be better is this number was generated via a variable set within ShowImage macro
I will make adjustments and let you know how I get on.
So I will just need number of images.
The Max number is determined by how many switch statements are added within ShowImage macro.
I think it would be better is this number was generated via a variable set within ShowImage macro
I will make adjustments and let you know how I get on.
Martin
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Embedded C within a component.
I'm going to manually add image size.
The panel properties I'm happy with as it sets the value to my manually added MaxNumberOfImages: This is what I'm trying to replace: Modified flowchart and saved as a component (attached).
Created a flowchart using the new component (also attached).
Compile and got:
Most likely I have mucked it up somehow?
Unfortunately, I believe this is to be advance component design.
I'm just learning basic component design, so feel I'm running before walking.
The panel properties I'm happy with as it sets the value to my manually added MaxNumberOfImages: This is what I'm trying to replace: Modified flowchart and saved as a component (attached).
Created a flowchart using the new component (also attached).
Compile and got:
Code: Select all
Flowcode1.c:
84: char const unsigned Image1[]={75,165,10,153,74,169,74,173,73,165,42,153,241,177,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,09,161,138,193,43,234,235,209,138,189,138,185,170,197,11,226,11,222,41,161,51,186,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,42,157,43,230,170,193,138,189,11,226,108,250,108,254,76,246,0,0,0};
^ (1098) conflicting declarations for variable "Image1" (Flowcode1.c:68)
(908) exit status = 1
(908) exit status = 1
Error returned from [xc8.exe]
C:\Program Files (x86)\Flowcode\Compilers\pic\batch\pic_xc8_comp.bat reported error code 1
Unfortunately, I believe this is to be advance component design.
I'm just learning basic component design, so feel I'm running before walking.
- Attachments
-
- CGenDemo3.fcfx
- (20.35 KiB) Downloaded 238 times
-
- Flowcode1.fcfx
- (7.35 KiB) Downloaded 250 times
Martin
- 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: Embedded C within a component.
Hi Martin,
You can get rid of all the code in the Ev_AddHeader macro as this just declares the ROM arrays but you are already doing this in the supplementary code window.
You can get rid of all the code in the Ev_AddHeader macro as this just declares the ROM arrays but you are already doing this in the supplementary code window.
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
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Embedded C within a component.
Hi Ben,
completely removed all the code within AddHeader and deleted AddHeader from Events.
Exported component and refreshed the flwochart using the component.
on compiling I get:I have added two component macros as NumImages is also set to 2
Now I have changed to but sill the RETURN is undeclared even though there is a local Return:
completely removed all the code within AddHeader and deleted AddHeader from Events.
Exported component and refreshed the flwochart using the component.
on compiling I get:
Code: Select all
Flowcode1.c:
72: char const unsigned Image1[]={75,165,10,153,74,169,74,173,73,165,42,153,241,177,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,09,161,138,193,43,234,235,209,138,189,138,185,170,197,11,226,11,222,41,161,51,186,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,42,157,43,230,170,193,138,189,11,226,108,250,108,254,76,246,0,0,0};
(223) digit out of range ^
Flowcode1.c: FCD_040e1_CGenDemo1__ShowImage()
115: FCV_RETURN = Image1[FCL_DATAPOINTER];
^ (192) undefined identifier "FCV_RETURN"
^ (192) undefined identifier "FCL_DATAPOINTER"
128: FCV_RETURN = Image2[FCL_DATAPOINTER];
^ (192) undefined identifier "FCV_RETURN"
^ (192) undefined identifier "FCL_DATAPOINTER"
(908) exit status = 1
(908) exit status = 1
Error returned from [xc8.exe]
C:\Program Files (x86)\Flowcode\Compilers\pic\batch\pic_xc8_comp.bat reported error code 1
FINISHED
Now I have changed
Code: Select all
FCV_RETURN = Image1[FCL_DATAPOINTER];
Code: Select all
FCL_RETURN = Image1[FCL_DATAPOINTER];
Martin
- 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: Embedded C within a component.
Hi Martin,
Did you send me the right file?
If you did then where in your project do you reference the Image1 variables using the switch icon? I'll make the changes for you just need to know where to look.
Did you send me the right file?
If you did then where in your project do you reference the Image1 variables using the switch icon? I'll make the changes for you just need to know where to look.
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
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Embedded C within a component.
Hi Ben,
call macro
Yes I believe I did, but there are so many macros I should have said, sorry.Benj wrote:Did you send me the right file?
The Code within switch statement is inBenj wrote:where in your project do you reference the Image1
Code: Select all
StoreBitmapData
Fantastic, Thanks Ben you're a star.Benj wrote:'ll make the changes for you just need to know where to look.
Martin
- 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: Embedded C within a component.
Thanks Martin,
I've replied to your PM.
I've replied to your PM.
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
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Embedded C within a component.
Thanks Ben, it's really appreciated.
I will check it out and let you know how the testing went.
Does it work as is , or only will work when the whole flowchart is converted to a component?
I will check it out and let you know how the testing went.
Does it work as is , or only will work when the whole flowchart is converted to a component?
Martin
- 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: Embedded C within a component.
Hi Martin,
The decisions will generate if until you export and then they will use #if.
So you will probably get compile errors until you export.
The decisions will generate if until you export and then they will use #if.
So you will probably get compile errors until you export.
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
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Embedded C within a component.
Hi Ben,
Thank you for the updated flowchart.
Wow, You're a genius!
I don't get an undefined message relating to ImageX unless I deliberately set Numimages to 4 when I have 3 images stored.
This is expected of course:
Thank you for all your help.
Flowchart compiles OK with the component added.
Now for testing.
Thank you for the updated flowchart.
Wow, You're a genius!
I don't get an undefined message relating to ImageX unless I deliberately set Numimages to 4 when I have 3 images stored.
This is expected of course:
Code: Select all
Component 480 x 275 47K40 Test1.c: FCD_00fa1_FT810__StoreBitmapData()
3499: FCL_DATA = Image4[FCL_DATAPOINTER];
^ (192) undefined identifier "Image4"
(981) pointer required ^
(981) pointer required ^
Component 480 x 275 47K40 Test1.c: main()
4285: FCD_00fa1_FT810__Initialise();
^ (361) function declared implicit int (warning)
(908) exit status = 1
(908) exit status = 1
Error returned from [xc8.exe]
C:\Program Files (x86)\Flowcode\Compilers\pic\batch\pic_xc8_comp.bat reported error code 1
Flowchart compiles OK with the component added.
Now for testing.
Martin
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Embedded C within a component.
Update:
Component is working great after exporting.
After adding another 30 switch branches (50 in total), I found the example CGenDemo really useful as well.
I have added a routine within both EV, Components,Property and EV, Components, Initialise to dynamically update total images left: Thanks Martin for your input.
Thanks again Ben, could not have complete the component without your valuable help.
Component is working great after exporting.
After adding another 30 switch branches (50 in total), I found the example CGenDemo really useful as well.
I have added a routine within both EV, Components,Property and EV, Components, Initialise to dynamically update total images left: Thanks Martin for your input.
Thanks again Ben, could not have complete the component without your valuable help.
Martin