Bonjour / bonsoir
Ceci est mon premier post sur le forum, je me suis lancé dans l'aventure arduino il y a un mois, j’attends encore que la poste me livre qqs composants...
Je me suis fait un altimètre à base de bmp280 ( i2c) un arduino nano et un écran lcd 128*64 ( i2c)
J'ai travaillé à partir de sketch déjà réalisé que j'ai intégré/mixé/bidouillé.
Mon altimètre fonctionne , mais je souhaite integrer un logo au début du programme.
J'ai travaillé à partir de l'exemple XBM dans la bibliothèque u8glib, et j'ai obtenu ce que je voulais. J'ai donc copié les bout de programme pour les integrer dans le sketch de l'altimètre, et la j'ai une erreur lors de la compilation, mais il televerse bien le programme.
Au final, je ne vois que la première ligne de mon logo.
Je joins le fichier ino :
#include "Wire.h"
#include "U8glib.h"
#include "BMP280.h"
#define P0 1024.01 //1013.25
BMP280 bmp;
// This function read Nbytes bytes from I2C device at address Address.
// Put read bytes starting at register Register in the Data array.
void I2Cread(uint8_t Address, uint8_t Register, uint8_t Nbytes, uint8_t* Data)
{
// Set register address
Wire.beginTransmission(Address);
Wire.write(Register);
Wire.endTransmission();
// Read Nbytes
Wire.requestFrom(Address, Nbytes);
uint8_t index=0;
while (Wire.available())
Data[index++]=Wire.read();
}
// Write a byte (Data) in device (Address) at register (Register)
void I2CwriteByte(uint8_t Address, uint8_t Register, uint8_t Data)
{
// Set register address
Wire.beginTransmission(Address);
Wire.write(Register);
Wire.write(Data);
Wire.endTransmission();
}
// OLED Type
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NO_ACK);
#define u8g_logo_width 100
#define u8g_logo_height 25
//static unsigned char u8g_logo_bits[] = {
static unsigned char u8g_logo_bits[] U8G_PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0,
0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc1, 0x01, 0x00, 0x00,
0xc0, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc1, 0x01, 0x00,
0x00, 0xc0, 0xf1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc1, 0x01,
0x00, 0x00, 0xc0, 0xe1, 0xf8, 0xf0, 0x07, 0xf0, 0x7b, 0xe0, 0xc3, 0xcf,
0x0f, 0x1f, 0x00, 0xc0, 0xe1, 0xf8, 0xf3, 0x07, 0xf0, 0xff, 0xf0, 0xc7,
0xcf, 0x8f, 0x3f, 0x00, 0xc0, 0xf1, 0x80, 0x83, 0x03, 0x70, 0xce, 0x79,
0xcf, 0xc1, 0xc1, 0x71, 0x00, 0xc0, 0x7f, 0xf8, 0x83, 0xe3, 0x73, 0xce,
0x39, 0xce, 0xc1, 0xc1, 0x7f, 0x00, 0xc0, 0x1f, 0xfc, 0xc3, 0xe1, 0x73,
0xce, 0x39, 0xce, 0xc1, 0xc1, 0x7f, 0x00, 0xc0, 0x39, 0x9c, 0xe3, 0x00,
0x70, 0xce, 0x39, 0xce, 0xc1, 0xc1, 0x01, 0x00, 0xc0, 0x71, 0x9c, 0xe3,
0x00, 0x70, 0xce, 0x79, 0xcf, 0xc1, 0xc1, 0x03, 0x00, 0xc0, 0xe1, 0xfc,
0xf3, 0x07, 0x70, 0xce, 0xf1, 0x87, 0x8f, 0x8f, 0x3f, 0x00, 0xc0, 0xe1,
0xf1, 0xf3, 0x07, 0x70, 0xce, 0xe1, 0x03, 0x0f, 0x0f, 0x3f, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00 };
void draw3(void) {
// graphic commands to redraw the complete screen should be placed here
u8g.drawXBMP( 2, 25, u8g_logo_width, u8g_logo_height, u8g_logo_bits);
}
int bouton1=3;
char sT[20];
char sP[9];
char sA[9];
char sA_MIN[9];
char sA_MAX[9];
double A_MIN = 0;
double A_MAX = 0;
void draw(double P, double A) {
u8g.setFont(u8g_font_courB10);
dtostrf(P, 4, 2, sP);
dtostrf(A, 4, 1, sA);
u8g.drawStr( 1, 30, "Bar: ");
u8g.drawStr( 45, 30, sP);
u8g.drawStr( 1, 55, "Alt: ");
u8g.setFont(u8g_font_courB18);
u8g.drawStr( 40, 60, sA);
}
void draw2(double T, double A_MIN, double A_MAX) {
u8g.setFont(u8g_font_unifont);
dtostrf(A_MIN, 4, 0, sA_MIN);
dtostrf(A_MAX, 4, 0, sA_MAX);
dtostrf(T, 4, 1, sT);
u8g.drawStr( 5, 20, "A Min: ");
u8g.drawStr( 60, 20, sA_MIN);
u8g.drawStr( 5, 40, "A Max: ");
u8g.drawStr( 60, 40, sA_MAX);
u8g.drawStr( 5, 60, "Temp: ");
u8g.drawStr( 60, 60, sT);
}
void setup() {
pinMode(bouton1, INPUT_PULLUP);
//Serial.begin(9600);
if (!bmp.begin()) {
Serial.println("BMP init failed!");
while (1);
}
else do {
draw3();
} while( u8g.nextPage() );
bmp.setOversampling(4);
delay(3000);
u8g.setColorIndex(1);
u8g.setFont(u8g_font_unifont);
// Arduino initializations
Wire.begin();
}
void loop() {
double T, P;
char result = bmp.startMeasurment();
if (result != 0) {
delay(result);
result = bmp.getTemperatureAndPressure(T, P);
if (result != 0) {
double A = bmp.altitude(P, P0);
if ( A > A_MAX) {
A_MAX = A;
}
if ( A < A_MIN || A_MIN == 0) {
A_MIN = A;
}
u8g.firstPage();
do {
draw(P, A);
} while ( u8g.nextPage() );
u8g.firstPage();
delay(200);
}
else {
Serial.println("Error.");
}
}
else {
Serial.println("Error.");
}
if ( digitalRead(bouton1) == 0)
{ do {
draw2(T, A_MIN, A_MAX);
} while ( u8g.nextPage() );
u8g.firstPage();
delay(4000);
}
delay(100);
}
et l'erreur que j'obtiens :
/tmp/ccQsyOIu.s: Assembler messages:
/tmp/ccQsyOIu.s:1733: Warning: ignoring changed section attributes for .progmem.data
Le croquis utilise 28 986 octets (94%) de l'espace de stockage de programmes. Le maximum est de 30 720 octets.
Les variables globales utilisent 774 octets (37%) de mémoire dynamique, ce qui laisse 1 274 octets pour les variables locales. Le maximum est de 2 048 octets.
si je change le static static unsigned char u8g_logo_bits[] U8G_PROGMEM = {
par const, l'erreur disparait, mais l'image ne s'affiche pas pour autant. ( "truc" trouvé sur le net)
Si quelqu'un sait comment remédier à mon problème...