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:
@@ -85,31 +85,26 @@ void playPop(){ anyrtttl::blocking::play(PIEZO, _pop_);}
|
|||||||
void playClk(){ anyrtttl::blocking::play(PIEZO, _clk_);}
|
void playClk(){ anyrtttl::blocking::play(PIEZO, _clk_);}
|
||||||
|
|
||||||
// Snooze screen saver
|
// Snooze screen saver
|
||||||
#define SNOOZE_HEIGHT 16
|
#define ICON_HEIGHT 16
|
||||||
#define SNOOZE_WIDTH 16
|
#define ICON_WIDTH 16
|
||||||
#define XPOS 0 // Indexes into the 'icons' array in function below
|
|
||||||
#define YPOS 1
|
|
||||||
#define DELTAY 2
|
|
||||||
#define _DISPLAYWIDTH 128
|
|
||||||
#define _DISPLAYHEIGHT 32
|
|
||||||
#define FLOCONS 4 // snowflakes in animation
|
|
||||||
|
|
||||||
const unsigned char flake_bmp [] PROGMEM = {
|
const unsigned char flake_bmp [] PROGMEM = {
|
||||||
0x01, 0x80, 0xc3, 0xc3, 0xe3, 0xc7, 0xfb, 0xdf, 0x7f, 0xfe, 0x3f, 0xfc, 0x1f, 0xf8, 0x0f, 0xf0,
|
0x00, 0x00, 0x00, 0x70, 0x38, 0x70, 0x38, 0x70, 0x3c, 0xe0, 0x0e, 0xee, 0x07, 0xce, 0x1f, 0xfe,
|
||||||
0x0f, 0xf0, 0x1f, 0xf8, 0x3f, 0xfc, 0x7f, 0xfe, 0xfb, 0xdf, 0xe3, 0xc7, 0xc3, 0xc3, 0x01, 0x80
|
0x7f, 0xf0, 0x73, 0xc0, 0x77, 0xe0, 0x07, 0x78, 0x0f, 0x78, 0x0e, 0x38, 0x0e, 0x00, 0x00, 0x00
|
||||||
};
|
};
|
||||||
// 'smiley', 16x16px
|
// 'smiley', 16x16px
|
||||||
const unsigned char smiley_bmp [] PROGMEM = {
|
const unsigned char smiley_bmp [] PROGMEM = {
|
||||||
0x07, 0xc0, 0x1f, 0xf0, 0x3f, 0xf8, 0x7f, 0xfc, 0x63, 0x8c, 0xdd, 0x76, 0xd3, 0x96, 0xe7, 0xce,
|
0x07, 0xc0, 0x1f, 0xf0, 0x3f, 0xf8, 0x7f, 0xfc, 0x63, 0x8c, 0xdd, 0x76, 0xd3, 0x96, 0xe7, 0xce,
|
||||||
0xff, 0xfe, 0xfd, 0x7e, 0x6f, 0xec, 0x73, 0x9c, 0x3c, 0x78, 0x1f, 0xf0, 0x07, 0xc0, 0x00, 0x00
|
0xff, 0xfe, 0xfd, 0x7e, 0x67, 0xcc, 0x70, 0x1c, 0x3c, 0x78, 0x1f, 0xf0, 0x07, 0xc0, 0x00, 0x00
|
||||||
};
|
};
|
||||||
// 'frown', 16x16px
|
// 'frown', 16x16px
|
||||||
const unsigned char frown_bmp [] PROGMEM = {
|
const unsigned char frown_bmp [] PROGMEM = {
|
||||||
0x07, 0xc0, 0x1f, 0xf0, 0x3f, 0xf8, 0x67, 0xcc, 0x53, 0x94, 0xdd, 0x76, 0xd9, 0x36, 0xe1, 0x0e,
|
0x07, 0xc0, 0x1f, 0xf0, 0x3f, 0xf8, 0x67, 0xcc, 0x53, 0x94, 0xdd, 0x76, 0xd9, 0x36, 0xe1, 0x0e,
|
||||||
0xff, 0xfe, 0xff, 0xfe, 0x78, 0x3c, 0x73, 0x9c, 0x37, 0xd8, 0x1f, 0xf0, 0x07, 0xc0, 0x00, 0x00
|
0xff, 0xfe, 0xff, 0xfe, 0x78, 0x3c, 0x73, 0x9c, 0x37, 0xd8, 0x1f, 0xf0, 0x07, 0xc0, 0x00, 0x00
|
||||||
};
|
};
|
||||||
//sprite_t smiley = { 6, 16, 16, 0, 1, 2, smiley_bmp };
|
// 'neutral', 16x16px
|
||||||
//sprite_t frown = { unsigned short c6, 16, 16, 0, 1, 2, frown_bmp };
|
const unsigned char neutral_bmp [] PROGMEM = {
|
||||||
|
0x07, 0xc0, 0x1f, 0xf0, 0x3f, 0xf8, 0x67, 0xcc, 0x53, 0x94, 0xdd, 0x76, 0xd9, 0x36, 0xe1, 0x0e,
|
||||||
|
0xff, 0xfe, 0xfd, 0x7e, 0x7f, 0xfc, 0x70, 0x1c, 0x3f, 0xf8, 0x1f, 0xf0, 0x07, 0xc0, 0x00, 0x00
|
||||||
|
};
|
||||||
#endif // _INSOLAB_BITMAP_H_
|
#endif // _INSOLAB_BITMAP_H_
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ void showInit() {
|
|||||||
delay(100); // Serial.println(_oledmsg);
|
delay(100); // Serial.println(_oledmsg);
|
||||||
}
|
}
|
||||||
void showLOGO(int16_t gt) { /*--------- logo on SSD1306 -------------*/
|
void showLOGO(int16_t gt) { /*--------- logo on SSD1306 -------------*/
|
||||||
|
ledRGB(BLANK);
|
||||||
oled.clearDisplay(); oled.invertDisplay(true);
|
oled.clearDisplay(); oled.invertDisplay(true);
|
||||||
oled.drawBitmap(
|
oled.drawBitmap(
|
||||||
LOGO_X0, LOGO_Y0,logo_bmp, LOGO_WIDTH, LOGO_HEIGHT, LOGO_COLOR);
|
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);
|
oled.invertDisplay(false);
|
||||||
}
|
}
|
||||||
void showTITRE() { // TextSize(2)=>10char, TextSize(1)=>22char,
|
void showTITRE() { // TextSize(2)=>10char, TextSize(1)=>22char,
|
||||||
|
ledRGB(GREEN);
|
||||||
oled.clearDisplay();
|
oled.clearDisplay();
|
||||||
oled.setCursor(0,0); oled.setTextSize(2); // doble scale
|
oled.setCursor(0,0); oled.setTextSize(2); // doble scale
|
||||||
oled.setTextColor(SSD1306_WHITE);
|
oled.setTextColor(SSD1306_WHITE);
|
||||||
@@ -142,32 +144,32 @@ void showSAUVE(uint16_t t, char* txt) {
|
|||||||
oled.display();
|
oled.display();
|
||||||
}
|
}
|
||||||
typedef struct s_iconMvt {
|
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;
|
} t_iconMvt;
|
||||||
|
|
||||||
typedef struct s_sprite {
|
typedef struct s_sprite {
|
||||||
int count, h, w, x, y, dy;
|
int count, h, w; // sprite count & sizes
|
||||||
const unsigned char *bmp;
|
const unsigned char *bmp; // bitmap address
|
||||||
t_iconMvt *iconsMvt;
|
t_iconMvt *iconsMvt; // icons displacement
|
||||||
} t_sprite ;
|
} 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) {
|
void initSprite(t_sprite *s, int c, int w, int h, const unsigned char *bmp, t_iconMvt *icons) {
|
||||||
//t_iconMvt iconsMvt[c]; //WIP malloc ?? || Arg
|
s->count=c; s->h=h; s->w=w;
|
||||||
s->count=c; s->h=h; s->w=w; s->x=x; s->y=y; s->dy=dy;
|
s->iconsMvt=icons;
|
||||||
for(int i=0; i< s->count; i++) {
|
for(int i=0; i< s->count; i++) {
|
||||||
iconsMvt[i].xp = random(1 - s->w, OLED_WIDTH);
|
s->iconsMvt[i].xp = random(1 - w, OLED_WIDTH);
|
||||||
iconsMvt[i].yp = -s->h;
|
s->iconsMvt[i].yp = - h;
|
||||||
iconsMvt[i].dy = random(1, 6);
|
s->iconsMvt[i].dy = random(1, 6);
|
||||||
}
|
}
|
||||||
s->bmp=bmp;
|
s->bmp=bmp;
|
||||||
s->iconsMvt= iconsMvt;
|
|
||||||
}
|
}
|
||||||
void drawSprite(t_sprite *s, Adafruit_SSD1306 d) {
|
void drawSprite(t_sprite *s) {
|
||||||
//int8_t iconsMvt[FLOCONS][3];
|
//int8_t iconsMvt[FLOCONS][3];
|
||||||
d.clearDisplay();
|
oled.clearDisplay();
|
||||||
for(int i=0; i < s->count; i++) {
|
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);
|
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
|
//d.display(); // Show the display buffer on the screen
|
||||||
@@ -184,4 +186,22 @@ void updateSprite(t_sprite *s) {
|
|||||||
}
|
}
|
||||||
} // f=0; f< sprites.count; f++)
|
} // 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_
|
#endif // _INSOLAB_DISPLAYS_H_
|
||||||
|
|||||||
@@ -32,6 +32,8 @@
|
|||||||
- return to caller on time out
|
- return to caller on time out
|
||||||
* Sleep mode not stable, forum at :
|
* Sleep mode not stable, forum at :
|
||||||
"https://github.com/earlephilhower/arduino-pico/issues/345"
|
"https://github.com/earlephilhower/arduino-pico/issues/345"
|
||||||
|
-----------------------------------------------------------------------
|
||||||
|
Mod: 2026/05/27 added 2 bitmap to sreen saver
|
||||||
-----------------------------------------------------------------------*/
|
-----------------------------------------------------------------------*/
|
||||||
#define BUTTONPLUS 14 // PullUp 10K I=.33 mA
|
#define BUTTONPLUS 14 // PullUp 10K I=.33 mA
|
||||||
#define BUTTONMINUS 15 // PullUp 10K I=.33 mA
|
#define BUTTONMINUS 15 // PullUp 10K I=.33 mA
|
||||||
@@ -61,7 +63,7 @@ volatile uint16_t downTime; // count down time
|
|||||||
volatile uint16_t lastSetTime, lastStepTime, time2save=0;
|
volatile uint16_t lastSetTime, lastStepTime, time2save=0;
|
||||||
volatile boolean plusPushed=false; volatile boolean minusPushed=false;
|
volatile boolean plusPushed=false; volatile boolean minusPushed=false;
|
||||||
char sMsg[16];
|
char sMsg[16];
|
||||||
screen_t screen=sTITRE;
|
screen_t screen=sNONE;
|
||||||
#include <EEPROM.h>
|
#include <EEPROM.h>
|
||||||
#include "displays.h" // Oled functions & led RGB
|
#include "displays.h" // Oled functions & led RGB
|
||||||
#include "pt.h" // proto threads
|
#include "pt.h" // proto threads
|
||||||
@@ -120,7 +122,7 @@ void setup() {
|
|||||||
lastStepTime=stepTime;
|
lastStepTime=stepTime;
|
||||||
showLOGO(greetTime);
|
showLOGO(greetTime);
|
||||||
minusPushed=false; plusPushed=false; // in case button pushed while LOGO
|
minusPushed=false; plusPushed=false; // in case button pushed while LOGO
|
||||||
ledRGB(GREEN);
|
screen=sTITRE;
|
||||||
}
|
}
|
||||||
void loop() { // CPU 0 dedicated to refresh display
|
void loop() { // CPU 0 dedicated to refresh display
|
||||||
// TODO not recall screen if values did not change
|
// TODO not recall screen if values did not change
|
||||||
@@ -328,40 +330,26 @@ static PT_THREAD(pSauve(pt_t *lc)) { //
|
|||||||
}
|
}
|
||||||
|
|
||||||
static PT_THREAD(pVeille(pt_t *lc)) { // OK and avoid bounces
|
static PT_THREAD(pVeille(pt_t *lc)) { // OK and avoid bounces
|
||||||
static int8_t f, icons[FLOCONS][3];
|
const int nbSprites = 10;
|
||||||
|
static t_iconMvt icons[nbSprites];
|
||||||
|
static t_sprite sprite;
|
||||||
|
static uint16_t nbpass=0;
|
||||||
PT_BEGIN(lc);
|
PT_BEGIN(lc);
|
||||||
PT_WAIT_UNTIL(lc, (screen==sVEILLE));
|
PT_WAIT_UNTIL(lc, (screen==sVEILLE));
|
||||||
ledRGB(NONE);
|
ledRGB(NONE);
|
||||||
for(f=0; f< FLOCONS; f++) {
|
|
||||||
icons[f][XPOS] = random(1 - SNOOZE_WIDTH, oled.width());
|
initSprite(&sprite,nbSprites,16,16, flake_bmp, icons); // load values to sprite
|
||||||
icons[f][YPOS] = -SNOOZE_HEIGHT;
|
|
||||||
icons[f][DELTAY] = random(1, 6);
|
|
||||||
}
|
|
||||||
do {
|
do {
|
||||||
oled.clearDisplay();
|
drawSprite(&sprite);
|
||||||
for(f=0; f< FLOCONS; f++) { // ~ 10 ok for this screen
|
PT_DELAY(lc, 40);
|
||||||
oled.drawBitmap(
|
|
||||||
icons[f][XPOS], icons[f][YPOS], flake_bmp,
|
|
||||||
SNOOZE_WIDTH, SNOOZE_HEIGHT, SSD1306_WHITE);
|
|
||||||
}
|
|
||||||
PT_DELAY(lc, 80);
|
|
||||||
if (!(plusPushed || minusPushed)) {
|
if (!(plusPushed || minusPushed)) {
|
||||||
oled.display();
|
oled.display();
|
||||||
PT_DELAY(lc, 80);
|
PT_DELAY(lc, 40);
|
||||||
// Then update coordinates of each icon
|
updateSprite(&sprite); // update coordinates of each sprite
|
||||||
for(f=0; f< FLOCONS; f++) {
|
|
||||||
icons[f][YPOS] += icons[f][DELTAY];
|
|
||||||
// If snowflake is off the bottom of the screen...
|
|
||||||
if (icons[f][YPOS] >= oled.height()) {
|
|
||||||
// Reinitialize to a random position, just off the top
|
|
||||||
icons[f][XPOS] = random(1 - SNOOZE_WIDTH, oled.width());
|
|
||||||
icons[f][YPOS] = -SNOOZE_HEIGHT;
|
|
||||||
icons[f][DELTAY] = random(1, 6);
|
|
||||||
}
|
|
||||||
//PT_DELAY(lc, 100);
|
|
||||||
} // f=0; f< NUMFLAKES; f++)
|
|
||||||
}
|
}
|
||||||
|
nbpass = changeSprite(&sprite, nbpass);
|
||||||
} while (!(plusPushed || minusPushed ));
|
} while (!(plusPushed || minusPushed ));
|
||||||
|
|
||||||
minusPushed=false; plusPushed=false;
|
minusPushed=false; plusPushed=false;
|
||||||
oled.clearDisplay();
|
oled.clearDisplay();
|
||||||
PT_DELAY(lc, 200);
|
PT_DELAY(lc, 200);
|
||||||
@@ -369,33 +357,6 @@ static PT_THREAD(pVeille(pt_t *lc)) { // OK and avoid bounces
|
|||||||
PT_END(lc); // to try: exit & return flag ?
|
PT_END(lc); // to try: exit & return flag ?
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ICONS 4
|
|
||||||
t_iconMvt icons[ICONS];
|
|
||||||
t_sprite sprite;
|
|
||||||
|
|
||||||
static PT_THREAD(pBugVeille(pt_t *lc)) { // OK and avoid bounces
|
|
||||||
PT_BEGIN(lc);
|
|
||||||
PT_WAIT_UNTIL(lc, (screen==sVEILLE));
|
|
||||||
ledRGB(NONE);
|
|
||||||
|
|
||||||
initSprite(&sprite,ICONS,16,16,0,1,2, flake_bmp, icons); // load values to sprite
|
|
||||||
do {
|
|
||||||
drawSprite(&sprite, oled);
|
|
||||||
PT_DELAY(lc, 80);
|
|
||||||
if (!(plusPushed || minusPushed)) {
|
|
||||||
oled.display();
|
|
||||||
PT_DELAY(lc, 80);
|
|
||||||
updateSprite(&sprite); // update coordinates of each sprite
|
|
||||||
}
|
|
||||||
} while (!(plusPushed || minusPushed ));
|
|
||||||
|
|
||||||
minusPushed=false; plusPushed=false;
|
|
||||||
oled.clearDisplay();
|
|
||||||
PT_DELAY(lc, 200);
|
|
||||||
screen=sCHOIX;// sTITRE; //
|
|
||||||
PT_END(lc); // to try: exit & return flag ?
|
|
||||||
}
|
|
||||||
|
|
||||||
void loop1() { // CPU 1 dedicated to run threads
|
void loop1() { // CPU 1 dedicated to run threads
|
||||||
pMinus (&pMINUS); // process minus button
|
pMinus (&pMINUS); // process minus button
|
||||||
pPlus (&pPLUS); // process plus button
|
pPlus (&pPLUS); // process plus button
|
||||||
@@ -408,7 +369,6 @@ void loop1() { // CPU 1 dedicated to run threads
|
|||||||
pDuree (&pDUREE); // process screen DUREE
|
pDuree (&pDUREE); // process screen DUREE
|
||||||
pSauve (&pSAUVE); // process screen SAUVE
|
pSauve (&pSAUVE); // process screen SAUVE
|
||||||
pVeille(&pVEILLE); // process screen saver
|
pVeille(&pVEILLE); // process screen saver
|
||||||
|
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* code debug
|
* code debug
|
||||||
|
|||||||
Reference in New Issue
Block a user