Finalisation gestion d'icones dans l'écran de veille.

Correction fonctions de gestion des icones.
Ajout et modification des bitmaps d'icones.
Ajout fonction de changement d'icone en cours de déroulement.
This commit is contained in:
2026-05-22 18:19:07 +02:00
parent 41fdaaa1ae
commit a7dd5da698
3 changed files with 58 additions and 83 deletions

View File

@@ -75,6 +75,7 @@ void showInit() {
delay(100); // Serial.println(_oledmsg);
}
void showLOGO(int16_t gt) { /*--------- logo on SSD1306 -------------*/
ledRGB(BLANK);
oled.clearDisplay(); oled.invertDisplay(true);
oled.drawBitmap(
LOGO_X0, LOGO_Y0,logo_bmp, LOGO_WIDTH, LOGO_HEIGHT, LOGO_COLOR);
@@ -84,6 +85,7 @@ void showLOGO(int16_t gt) { /*--------- logo on SSD1306 -------------*/
oled.invertDisplay(false);
}
void showTITRE() { // TextSize(2)=>10char, TextSize(1)=>22char,
ledRGB(GREEN);
oled.clearDisplay();
oled.setCursor(0,0); oled.setTextSize(2); // doble scale
oled.setTextColor(SSD1306_WHITE);
@@ -142,32 +144,32 @@ void showSAUVE(uint16_t t, char* txt) {
oled.display();
}
typedef struct s_iconMvt {
int xp,yp,dy;
int xp,yp,dx,dy; // x & y position, dx & dy to add for next move
} t_iconMvt;
typedef struct s_sprite {
int count, h, w, x, y, dy;
const unsigned char *bmp;
t_iconMvt *iconsMvt;
int count, h, w; // sprite count & sizes
const unsigned char *bmp; // bitmap address
t_iconMvt *iconsMvt; // icons displacement
} t_sprite ;
//const unsigned char *Abmp[] = {&flake_bmp, &smiley_bmp, &frown_bmp};
void initSprite(t_sprite *s, int c, int h, int w, int x, int y, int dy, const unsigned char *bmp,t_iconMvt *iconsMvt) {
//t_iconMvt iconsMvt[c]; //WIP malloc ?? || Arg
s->count=c; s->h=h; s->w=w; s->x=x; s->y=y; s->dy=dy;
void initSprite(t_sprite *s, int c, int w, int h, const unsigned char *bmp, t_iconMvt *icons) {
s->count=c; s->h=h; s->w=w;
s->iconsMvt=icons;
for(int i=0; i< s->count; i++) {
iconsMvt[i].xp = random(1 - s->w, OLED_WIDTH);
iconsMvt[i].yp = -s->h;
iconsMvt[i].dy = random(1, 6);
s->iconsMvt[i].xp = random(1 - w, OLED_WIDTH);
s->iconsMvt[i].yp = - h;
s->iconsMvt[i].dy = random(1, 6);
}
s->bmp=bmp;
s->iconsMvt= iconsMvt;
}
void drawSprite(t_sprite *s, Adafruit_SSD1306 d) {
void drawSprite(t_sprite *s) {
//int8_t iconsMvt[FLOCONS][3];
d.clearDisplay();
oled.clearDisplay();
for(int i=0; i < s->count; i++) {
d.drawBitmap(
oled.drawBitmap(
s->iconsMvt[i].xp, s->iconsMvt[i].yp, s->bmp, s->w, s->h, SSD1306_WHITE);
}
//d.display(); // Show the display buffer on the screen
@@ -184,4 +186,22 @@ void updateSprite(t_sprite *s) {
}
} // f=0; f< sprites.count; f++)
}
uint16_t changeSprite(t_sprite *s, uint16_t count){
count++;
if ( count >100 && count <= 200) {
s->bmp = smiley_bmp;
}
else if ( count >200 && count <= 300) {
s->bmp = neutral_bmp;
}
else if ( count >300 && count <= 400) {
s->bmp = frown_bmp;
}
else if ( count >400 && count <= 500) {
s->bmp = flake_bmp;
}
else if ( count >500 ) count = 0;
return count;
}
#endif // _INSOLAB_DISPLAYS_H_