Hi, ich habe das Problem, dass ich ein TFT Bildschirm mit einem Arduino Mega 2560 betreibe und das Programm mittlerweile so groß geworden ist, dass ich es gerne in mehrer Sketches unterteilen würde. Ich finde im Internet immer wieder Tipps, wie ich einen neuen Tab anlege. Aber welche Endung muss er haben? Wie kann ich von Tab zu Tab springen? Wie übertrage ich globale Variablen? Vielleicht hat jemand sowas schonmal gemacht und kann mir einen Programmausschnitt geben oder mir eine Quelle zeigen, wo dies beschrieben ist.
Ja jetzt müsste man halt C programmieren können. Multi-file sketches A sketch can contain multiple files (tabs). To manage them, click on the right-facing arrow just above the scroll bar near the top of the environment. Tabs have one of four extensions: no extension, .c, .cpp, or .h (if you provide any other extension, the period will be converted to an underscore). When your sketch is compiled, all tabs with no extension are concatenated together to form the "main sketch file". Tabs with .c or .cpp extensions are compiled separately. To use tabs with a .h extension, you need to #include it (using "double quotes" not <angle brackets>). Transformations to the main sketch file The Arduino environment performs a few transformations to your main sketch file (the concatenation of all the tabs in the sketch without extensions) before passing it to the avr-gcc compiler. First, #include "Arduino.h", or for versions less than 1.0, #include "WProgram.h" is added to the top of your sketch. This header file (found in <ARDUINO>/hardware/cores/<CORE>/) includes all the defintions needed for the standard Arduino core. Next, the environment searches for function definitions within your main sketch file and creates declarations (prototypes) for them. These are inserted after any comments or pre-processor statements (#includes or #defines), but before any other statements (including type declarations). This means that if you want to use a custom type as a function argument, you should declare it within a separate header file. Also, this generation isn't perfect: it won't create prototypes for functions that have default argument values, or which are declared within a namespace or class. Finally, the contents of the current target's main.cxx file are appended to the bottom of your sketch.
Wikipedia zu Adurino: "Die Arduino-IDE bringt einen Code-Editor mit und bindet gcc als Compiler ein." Schmeiss den Arduino-Blindenstock weg und bediene den gcc Compiler direkt, auf dass du die Möglichketen von C/C++ erkennst.
Also phinix, du gehst in der Arduino-IDE oben rechts auf den kleinen Button mit dem Pfeil nach unten und erstellst einen neuen Tab mit irgendeinem Namen, eine Endung musst du nicht eingeben. Diese Datei erscheint dann direkt auch als neuer Tab in der selben Leiste, wo auch der eben beschriebene Button ist. Die neue Datei stellt eine einfache Erweiterung des Hauptsketches dar und wird vorm Kompilieren mit diesem zusammen gefügt, du musst dir also über globale Variablen usw. keine sorgen machen... Gruß, luoc
Erleuchter schrieb: > Schmeiss den Arduino-Blindenstock weg und bediene den gcc Compiler > direkt, auf dass du die Möglichketen von C/C++ erkennst. Der Spruch zum Sonntag!
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.