Bonjour,
Je suis en train de créer une voiture téléguidée avec Arduino, et pour la télécommande, j'aimerais utiliser un écran OLED I²C 128x64 (driver SSD1306, classique ). Celui affichera simplement quelques informations transmises par la voiture.
Mon programme est relativement gros, avec quand même pas mal de variables. La RAM est à 40% à la compilation. Or, la bibliothèque d'Adafruit bouffe BEAUCOUP de RAM pour écrire sur l'écran, donc je suis passé à U8G2.
Car elle a un mode sans "Frame Buffer", qui utilise moins de mémoire qu'avec (38% pour l'exemple Hello World! quand même !). Celui-ci est le suivant :
Examples >> U8g2 >> page_buffer >> HelloWorld
/*
HelloWorld.ino
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
Copyright (c) 2016, olikraus@gmail.com
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or other
materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 Oct 2018:
U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2
make -f Makefile.184.uno
text
8732 default, all active
8500 -232 -2.65% no U8G2_WITH_CLIP_WINDOW_SUPPORT
8316 -416 -4.76% no U8G2_WITH_FONT_ROTATION
8606 -126 -1.44% no U8G2_WITH_UNICODE
8692 -40 -0.45% no U8G2_WITH_INTERSECTION
8328 -404 -4.62% no U8G2_WITH_INTERSECTION no U8G2_WITH_CLIP_WINDOW_SUPPORT
8718 -14 -4.86% no U8G2_WITH_HVLINE_SPEED_OPTIMIZATION
8026 -706 -8.08% no U8G2_WITH_FONT_ROTATION no U8G2_WITH_INTERSECTION no U8G2_WITH_CLIP_WINDOW_SUPPORT
Some flags depend on each other: `U8G2_WITH_INTERSECTION` is required for `U8G2_WITH_CLIP_WINDOW_SUPPORT`, so `U8G2_WITH_INTERSECTION` is partly active as long
as `U8G2_WITH_CLIP_WINDOW_SUPPORT` is requested.
*/
#include <Arduino.h>
#include <U8g2lib.h>
#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#endif
#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>
#endif
/*
U8g2lib Example Overview:
Frame Buffer Examples: clearBuffer/sendBuffer. Fast, but may not work with all Arduino boards because of RAM consumption
Page Buffer Examples: firstPage/nextPage. Less RAM usage, should work with all Arduino boards.
U8x8 Text Only Example: No RAM usage, direct communication with display controller. No graphics, 8x8 Text only.
This is a page buffer example.
*/
U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);
void setup(void) {
u8g2.begin();
}
void loop(void) {
u8g2.firstPage();
do {
u8g2.setFont(u8g2_font_ncenB10_tr);
u8g2.drawStr(0,24,"Hello World!");
} while ( u8g2.nextPage() );
}
Ce que me pose problème, c'est le while
utilisé dans le code. Cet exemple est-il bloquant ? Mon programme ne doit surtout pas l'être, sous peine de risquer de rater des données de la voiture, ou de ne pas envoyer les commandes du joystick assez vite...
Ma question est donc : Le programme utilisant ces lignes est-il bloquant ?
do {
u8g2.setFont(u8g2_font_ncenB10_tr);
u8g2.drawStr(0,24,"Hello World!");
} while ( u8g2.nextPage() );
Dites moi si il manque des infos !
Merci d'avance pour vos réponses,
Cordialement
Pandaroux007