Bonjour,
Je voulais tester mon ecran grace aux exemples de la bibliothèque u8glib recommandée !
Voici l'erreur :
Arduino : 1.8.12 (Windows Store 1.8.33.0) (Windows 10), Carte : "Arduino Nano, ATmega328P"
HelloWorld:51:3: error: 'u8g' was not declared in this scope
u8g.setFont(u8g_font_unifont);
^~~
C:\Users\guibr\AppData\Local\Temp\arduino_modified_sketch_277546\HelloWorld.ino:51:3: note: suggested alternative: 'u8'
u8g.setFont(u8g_font_unifont);
^~~
u8
C:\Users\guibr\AppData\Local\Temp\arduino_modified_sketch_277546\HelloWorld.ino: In function 'void setup()':
HelloWorld:64:8: error: 'u8g' was not declared in this scope
if ( u8g.getMode() == U8G_MODE_R3G3B2 ) {
^~~
C:\Users\guibr\AppData\Local\Temp\arduino_modified_sketch_277546\HelloWorld.ino:64:8: note: suggested alternative: 'u8'
if ( u8g.getMode() == U8G_MODE_R3G3B2 ) {
^~~
u8
C:\Users\guibr\AppData\Local\Temp\arduino_modified_sketch_277546\HelloWorld.ino: In function 'void loop()':
HelloWorld:82:3: error: 'u8g' was not declared in this scope
u8g.firstPage();
^~~
C:\Users\guibr\AppData\Local\Temp\arduino_modified_sketch_277546\HelloWorld.ino:82:3: note: suggested alternative: 'u8'
u8g.firstPage();
^~~
u8
Utilisation de la bibliothèque U8glib version 1.19.1 dans le dossier: C:\Users\guibr\Documents\Arduino\libraries\U8glib
exit status 1
'u8g' was not declared in this scope
[code]
#include <U8glib.h>
/*
HelloWorld.pde
"Hello World!" example code.
>>> Before compiling: Please remove comment from the constructor of the
>>> connected graphics display (see below).
Universal 8bit Graphics Library, https://github.com/olikraus/u8glib/
Copyright (c) 2012, 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.
*/
#include "U8glib.h"
void draw(void) {
// graphic commands to redraw the complete screen should be placed here
u8g.setFont(u8g_font_unifont);
//u8g.setFont(u8g_font_osb21);
u8g.drawStr( 0, 22, "Hello World!");
}
void setup(void) {
// flip screen, if required
// u8g.setRot180();
// set SPI backup if required
//u8g.setHardwareBackup(u8g_backup_avr_spi);
// assign default color value
if ( u8g.getMode() == U8G_MODE_R3G3B2 ) {
u8g.setColorIndex(255); // white
}
else if ( u8g.getMode() == U8G_MODE_GRAY2BIT ) {
u8g.setColorIndex(3); // max intensity
}
else if ( u8g.getMode() == U8G_MODE_BW ) {
u8g.setColorIndex(1); // pixel on
}
else if ( u8g.getMode() == U8G_MODE_HICOLOR ) {
u8g.setHiColorByRGB(255,255,255);
}
pinMode(8, OUTPUT);
}
void loop(void) {
// picture loop
u8g.firstPage();
do {
draw();
} while( u8g.nextPage() );
// rebuild the picture after some delay
//delay(50);
}
[/code]