Différences entre versions de « Arduino Memoire Optimiser PrgMem »
Ligne 1 : | Ligne 1 : | ||
{{Arduino-Memoire-NAV}} | {{Arduino-Memoire-NAV}} | ||
− | == | + | == Introduction == |
+ | {{bloc-etroit|text=Cette partie s'attarde sur l'optimisation du programme. | ||
+ | |||
When you compile your sketch, the IDE will tell you how big the program image is. If you have reached or exceeded the space available, some of these optimizations may help get you back under the limit. | When you compile your sketch, the IDE will tell you how big the program image is. If you have reached or exceeded the space available, some of these optimizations may help get you back under the limit. | ||
− | This is not meant to be a definitive treatise on how to optimize your code - there are libraries full of books on the subject. What is presented here are just some simple tips to help harvest the low-hanging fruit. | + | This is not meant to be a definitive treatise on how to optimize your code - there are libraries full of books on the subject. What is presented here are just some simple tips to help harvest the low-hanging fruit. }} |
+ | |||
+ | {{ADFImage|Arduino-Memoire-01.jpg|640px}} | ||
+ | |||
+ | == Enlever le "code mort" == | ||
+ | Le "code mort" (Dead Code) sont des portions de codes compilées, téléversée/téléchargé en mémoire RAM '''mais jamais utilisé!'''. | ||
+ | |||
+ | If your project is a mash-up of code from several sources, chances are there are parts that are not getting used and can be eliminated to save space. | ||
+ | |||
+ | * '''Unused Libraries''' - Are all the #include libraries actually used? | ||
+ | * '''Unused Functions''' - Are all the functions acutally being called? | ||
+ | * '''Unused Variables''' - Are all the variables actually being used? | ||
+ | * '''Unreachable Code''' - Are there conditional expressions which will never be true? | ||
+ | |||
+ | === Truc & astuce === | ||
+ | If you are not sure about an #include, a function or a variable. Comment it out. If the program still compiles, that code is not being used. | ||
+ | |||
+ | == Consolider les codes répétitifs == | ||
+ | |||
+ | If you have the same sequence of code statements in two or more places, consider making a function out of them. | ||
+ | |||
+ | == Eliminer le Bootloader == | ||
+ | If space is really-really tight, you might consider eliminating the bootloader. This can save as much as 2K or 4K of Flash - depending on which bootloader you are currently using. | ||
+ | |||
+ | The downside of this is that you will need to load your code using an ISP programmer instead of via a standard USB cable. | ||
+ | |||
{{Arduino-Memoire-TRAILER}} | {{Arduino-Memoire-TRAILER}} |
Version du 4 septembre 2013 à 11:17
Introduction
Cette partie s'attarde sur l'optimisation du programme.
When you compile your sketch, the IDE will tell you how big the program image is. If you have reached or exceeded the space available, some of these optimizations may help get you back under the limit.
This is not meant to be a definitive treatise on how to optimize your code - there are libraries full of books on the subject. What is presented here are just some simple tips to help harvest the low-hanging fruit.
Crédit: AdaFruit Industries www.adafruit.com
Enlever le "code mort"
Le "code mort" (Dead Code) sont des portions de codes compilées, téléversée/téléchargé en mémoire RAM mais jamais utilisé!.
If your project is a mash-up of code from several sources, chances are there are parts that are not getting used and can be eliminated to save space.
- Unused Libraries - Are all the #include libraries actually used?
- Unused Functions - Are all the functions acutally being called?
- Unused Variables - Are all the variables actually being used?
- Unreachable Code - Are there conditional expressions which will never be true?
Truc & astuce
If you are not sure about an #include, a function or a variable. Comment it out. If the program still compiles, that code is not being used.
Consolider les codes répétitifs
If you have the same sequence of code statements in two or more places, consider making a function out of them.
Eliminer le Bootloader
If space is really-really tight, you might consider eliminating the bootloader. This can save as much as 2K or 4K of Flash - depending on which bootloader you are currently using.
The downside of this is that you will need to load your code using an ISP programmer instead of via a standard USB cable.
Source: Memories of an Arduino. Crédit AdaFruit Industries.
Créé par Bill Earl pour AdaFruit Industries.
Traduit par Meurisse D. pour MCHobby.be
Traduit avec l'autorisation d'AdaFruit Industries - Translated with the permission from Adafruit Industries - www.adafruit.com
Toute référence, mention ou extrait de cette traduction doit être explicitement accompagné du texte suivant : « Traduction par MCHobby (www.MCHobby.be) - Vente de kit et composants » avec un lien vers la source (donc cette page) et ce quelque soit le média utilisé.
L'utilisation commercial de la traduction (texte) et/ou réalisation, même partielle, pourrait être soumis à redevance. Dans tous les cas de figures, vous devez également obtenir l'accord du(des) détenteur initial des droits. Celui de MC Hobby s'arrêtant au travail de traduction proprement dit.