How can I reduce the code size?

Description:

For some target platforms you might reach the limit of the available code size. In this case you have to search in your C-code and in the EmWi application, how you can optimize the code size. Therefore this article lists the most efficient tips to save code size in your EmWi application.

 

Solution:

1.) Avoid the usage of big bitmap resources

 

2.) Reduce the font range to the necessary limit.

 

3.) Don’t use too many different fonts and font sizes. Each font brick in your project causes EmWi to generate an extra set of glyphs.

 

4.) Reduce the font quality. Even if the glyphs are compressed in the code, "High" font quality generates 4 Bit glyphs, "Medium" 2 Bit and "Low" generates 1 Bit glyphs.

 

5.) Set the attribute "Optimization" in your profile to "High". Dependent on the optimization level, EmWi suppresses the code generation for unused resources, classes, constants methods and variables. For any members, referenced only from outside (e.g.: the application class) you need to set the attribute "Generate" to "true" to avoid the optimization of the corresponding code.

 

6.) Optimal use of the inheritance in your class hierarchy.

 

7.) Merge similar Icons/Images to a single file. By this way EmWi can reach a higher compression with the resource converter and you can easily access such a image frame by setting the attribute "FrameSize" and select a frame number by the property "FrameNumber" in your Views::Image or Views::Frame object. As an example, have a look in the file AquaCheckBox.png file that is installed with the EmWi Software.

 

See also:

HowTo document [HT-013-Memory_usage_of_EmWi.pdf]

 

Keywords:

ROM, memory, flash, code, code size, optimization, reduce, save, shrink

 

Last update on 2010-08-19 by Mario Stefanutti.

Go back