Animated fan on OLED

Hello,
I have the project to display an animated fan on OLED 0.96 inches.
It works fine with
display.drawBitmap(68, 0, fan1 , LOGO_WIDTH, LOGO_HEIGHT, WHITE);
delay
display.drawBitmap(68, 0, fan2 , LOGO_WIDTH, LOGO_HEIGHT, WHITE);
delay
display.drawBitmap(68, 0, fan3 , LOGO_WIDTH, LOGO_HEIGHT, WHITE);

but i would like to use an array to display fan[i], where i goes from 0 to 2.

display.drawBitmap doesn't seem to accept that; or i don't know how to do that.

Anyone to help me ??

Thanks a lot.

Christian

Please post your best effort to use an array

I'm new to Arduino so...
if i post here, it's for help ?

If we can't see what you tried then we can only guess what you did wrong so please post the code and use code tags when you do

const unsigned char ventilo1 [] PROGMEM = {.....
const unsigned char ventilo2 [] PROGMEM = {.....
const unsigned char ventilo3 [] PROGMEM = {

switch (Vitesses) {
	case 0:
    //Effacer écran
	//Afficher logo elica
	display.clearDisplay();
	display.drawBitmap(0, 0,  elica1b, 128, 64, WHITE);
	display.drawBitmap(37, 5,  ampoule_off30, 30, 30, WHITE);
	display.display();
	pcf8574.digitalWrite(P0, HIGH);
	pcf8574.digitalWrite(P1, HIGH);
	pcf8574.digitalWrite(P2, HIGH);
	pcf8574.digitalWrite(P3, HIGH);

	if (LED_status==1){ 
	//On allume LED
	pcf8574.digitalWrite(P4, LOW);
	}
	else {
	//On éteint LED
	pcf8574.digitalWrite(P4, HIGH);
	}

	
    break;
	case 1:
	//Effacer écran
    //Afficher vitesse1
	//Afficher ventilo
	display.clearDisplay();
	CurrentTime=millis();
		if (CurrentTime-Mytime>300){
		v=v+1;
			if(v==3){
			v=0;
			}
		//Afficher v
		display.drawBitmap(68, 0, ventilo1 , LOGO_WIDTH, LOGO_HEIGHT, WHITE);
		//display.display();
		Mytime= millis();
		}
		else {
		//Afficher v
		display.drawBitmap(68, 0,  ventilo1, LOGO_WIDTH, LOGO_HEIGHT, WHITE);
		//display.display();
		}
	display.drawBitmap(2, 5,  v1, 38, 50, WHITE);
	pcf8574.digitalWrite(P0, LOW);
	pcf8574.digitalWrite(P1, HIGH);
	pcf8574.digitalWrite(P2, HIGH);
	pcf8574.digitalWrite(P3, HIGH);
	if (LED_status==1){ 
	//On affiche logo led on
	display.drawBitmap(37, 5,  ampoule_on30, 30, 30, WHITE);
	//display.display();
	//On allume LED
	pcf8574.digitalWrite(P4, LOW);
	}
	else {
	//On affiche logo led off
	display.drawBitmap(37, 5,  ampoule_off30, 30, 30, WHITE);
	//display.display();

	//On éteint LED
	pcf8574.digitalWrite(P4, HIGH);
	}

I want to display.drawBitmap(68, 0, fan[v], LOGO_WIDTH, LOGO_HEIGHT, WHITE);

Please elaborate. What happens when you use it? The code you posted doesn't seem to even attempt to do it. So you should also post the sketch that contains that code.

We help people do things not do things for people.

// 'ventilo1', 60x60px
const unsigned char ventilo1 [] PROGMEM = {
  0x00, 0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xfe, 0x00, 0x00, 0x00, 
  0x00, 0x00, 0x1f, 0xf0, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x03, 0xf0, 0x00, 0x00, 
  0x00, 0x01, 0xe0, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x1e, 0x00, 0x00, 
  0x00, 0x0f, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x03, 0xc0, 0x00, 
  0x00, 0x78, 0x00, 0x03, 0xf8, 0x01, 0xe0, 0x00, 0x00, 0xf0, 0x00, 0x0f, 0xff, 0x00, 0xf0, 0x00, 
  0x01, 0xe0, 0x00, 0x1f, 0xff, 0x80, 0x38, 0x00, 0x01, 0xc0, 0x00, 0x3f, 0xff, 0xe0, 0x38, 0x00, 
  0x03, 0x80, 0x00, 0x3f, 0xff, 0xf0, 0x1c, 0x00, 0x07, 0x00, 0x00, 0x7f, 0xff, 0xf8, 0x0e, 0x00, 
  0x06, 0x00, 0x00, 0x7f, 0xff, 0xfc, 0x06, 0x00, 0x0e, 0x00, 0x00, 0x7f, 0xff, 0xfc, 0x07, 0x00, 
  0x1c, 0x00, 0x00, 0x7f, 0xff, 0xfe, 0x03, 0x80, 0x18, 0x01, 0xe0, 0x7f, 0xff, 0xff, 0x01, 0x80, 
  0x18, 0x07, 0xe0, 0x7f, 0xff, 0xff, 0x01, 0xc0, 0x30, 0x0f, 0xf0, 0x3f, 0xff, 0xff, 0x00, 0xc0, 
  0x30, 0x1f, 0xf8, 0x3f, 0xff, 0xff, 0x80, 0xc0, 0x70, 0x1f, 0xf8, 0x3f, 0xff, 0xff, 0x80, 0xe0, 
  0x60, 0x3f, 0xfc, 0x3f, 0xff, 0xff, 0x80, 0x60, 0x60, 0x3f, 0xfc, 0x00, 0x7f, 0xff, 0x80, 0x60, 
  0x60, 0x7f, 0xfe, 0x04, 0x3f, 0xff, 0x80, 0x60, 0x60, 0x7f, 0xff, 0x1f, 0x9f, 0xff, 0x00, 0x70, 
  0xe0, 0xff, 0xff, 0x3f, 0xce, 0x00, 0x00, 0x70, 0xe0, 0xff, 0xfe, 0x79, 0xe0, 0x00, 0x00, 0x30, 
  0xc0, 0xff, 0xfe, 0x70, 0xe0, 0x00, 0x00, 0x30, 0xc0, 0xff, 0xfe, 0x70, 0xe0, 0x00, 0x00, 0x30, 
  0xc0, 0xff, 0xfe, 0x70, 0xe6, 0x00, 0x00, 0x30, 0xc0, 0xff, 0xfe, 0x71, 0xe7, 0xc0, 0x00, 0x30, 
  0xe0, 0xff, 0xfe, 0x7f, 0xe7, 0xf0, 0x00, 0x30, 0xe0, 0xff, 0xff, 0x3f, 0xcf, 0xfc, 0x00, 0x70, 
  0x60, 0xff, 0xff, 0x9f, 0x1f, 0xfe, 0x00, 0x70, 0x60, 0xff, 0xff, 0xc0, 0x3f, 0xff, 0x00, 0x60, 
  0x60, 0x7f, 0xff, 0xc0, 0xff, 0xff, 0x00, 0x60, 0x60, 0x7f, 0xff, 0x87, 0xff, 0xff, 0x80, 0x60, 
  0x70, 0x3f, 0xff, 0x07, 0xff, 0xff, 0x80, 0xe0, 0x30, 0x3f, 0xfe, 0x07, 0xff, 0xff, 0x80, 0xc0, 
  0x30, 0x1f, 0xfc, 0x0f, 0xff, 0xff, 0x80, 0xc0, 0x38, 0x07, 0xf0, 0x0f, 0xff, 0xff, 0x81, 0xc0, 
  0x18, 0x01, 0xc0, 0x1f, 0xff, 0xff, 0x01, 0x80, 0x1c, 0x00, 0x00, 0x3f, 0xff, 0xff, 0x03, 0x80, 
  0x0e, 0x00, 0x00, 0x3f, 0xff, 0xfe, 0x03, 0x00, 0x0e, 0x00, 0x00, 0x7f, 0xff, 0xfe, 0x07, 0x00, 
  0x07, 0x00, 0x00, 0x7f, 0xff, 0xfc, 0x0e, 0x00, 0x03, 0x80, 0x00, 0x7f, 0xff, 0xf0, 0x1c, 0x00, 
  0x01, 0x80, 0x00, 0x7f, 0xff, 0xe0, 0x18, 0x00, 0x01, 0xc0, 0x00, 0x1f, 0xff, 0x80, 0x38, 0x00, 
  0x00, 0xe0, 0x00, 0x07, 0xfc, 0x00, 0x70, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x01, 0xe0, 0x00, 
  0x00, 0x3c, 0x00, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 
  0x00, 0x07, 0x80, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x03, 0xe0, 0x00, 0x00, 0x7c, 0x00, 0x00, 
  0x00, 0x00, 0xfc, 0x00, 0x03, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xe0, 0x7f, 0xc0, 0x00, 0x00, 
  0x00, 0x00, 0x07, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xe0, 0x00, 0x00, 0x00
};
// 'ventilo2', 60x60px
const unsigned char ventilo2 [] PROGMEM = {
  0x00, 0x00, 0x00, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xfc, 0x00, 0x00, 0x00, 
  0x00, 0x00, 0x1f, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x0f, 0xe0, 0x00, 0x00, 
  0x00, 0x01, 0xf8, 0x00, 0x01, 0xf8, 0x00, 0x00, 0x00, 0x07, 0xc0, 0x00, 0x00, 0x3e, 0x00, 0x00, 
  0x00, 0x0f, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x07, 0x80, 0x00, 
  0x00, 0x38, 0x00, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 
  0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x01, 0xc0, 0x01, 0x00, 0x07, 0xc0, 0x38, 0x00, 
  0x03, 0x80, 0x1f, 0xc0, 0x1f, 0xf0, 0x1c, 0x00, 0x07, 0x00, 0x7f, 0xe0, 0x3f, 0xfc, 0x0e, 0x00, 
  0x07, 0x01, 0xff, 0xe0, 0x7f, 0xfe, 0x0e, 0x00, 0x0e, 0x03, 0xff, 0xe0, 0x7f, 0xfe, 0x07, 0x00, 
  0x0c, 0x07, 0xff, 0xe0, 0xff, 0xff, 0x03, 0x00, 0x1c, 0x0f, 0xff, 0xe0, 0xff, 0xff, 0x83, 0x80, 
  0x18, 0x1f, 0xff, 0xe1, 0xff, 0xff, 0x81, 0x80, 0x38, 0x1f, 0xff, 0xe1, 0xff, 0xff, 0xc1, 0xc0, 
  0x38, 0x3f, 0xff, 0xe1, 0xff, 0xff, 0xc1, 0xc0, 0x30, 0x7f, 0xff, 0xe1, 0xff, 0xff, 0xe0, 0xc0, 
  0x70, 0x7f, 0xff, 0xf3, 0xff, 0xff, 0xe0, 0xe0, 0x70, 0x7f, 0xff, 0xe0, 0x7f, 0xff, 0xe0, 0xe0, 
  0x60, 0xff, 0xff, 0xce, 0x3f, 0xff, 0xe0, 0x60, 0x60, 0xff, 0xff, 0x9f, 0x9f, 0xff, 0xe0, 0x60, 
  0x60, 0xff, 0xff, 0x3f, 0xcf, 0xff, 0xe0, 0x60, 0xe0, 0xff, 0xff, 0x7f, 0xef, 0xff, 0xe0, 0x70, 
  0xe0, 0xff, 0xfe, 0x70, 0xe7, 0xff, 0xe0, 0x70, 0xe0, 0xff, 0xfe, 0x70, 0xe7, 0xff, 0xe0, 0x70, 
  0xe0, 0x7f, 0xfe, 0x70, 0xe7, 0xff, 0xe0, 0x70, 0xe0, 0x7f, 0xfe, 0x79, 0xe1, 0xff, 0xe0, 0x70, 
  0xe0, 0x3f, 0xff, 0x7f, 0xe0, 0x3f, 0xc0, 0x70, 0x60, 0x1f, 0xff, 0x3f, 0xc0, 0x1f, 0xc0, 0x60, 
  0x60, 0x07, 0xf8, 0x1f, 0x98, 0x07, 0x80, 0x60, 0x60, 0x00, 0x00, 0x40, 0x3c, 0x00, 0x00, 0x60, 
  0x70, 0x00, 0x00, 0x70, 0xfe, 0x00, 0x00, 0xe0, 0x70, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xe0, 
  0x30, 0x00, 0x03, 0xff, 0xff, 0x80, 0x00, 0xc0, 0x38, 0x00, 0x07, 0xff, 0xff, 0x80, 0x01, 0xc0, 
  0x38, 0x00, 0x1f, 0xff, 0xff, 0xc0, 0x01, 0xc0, 0x18, 0x00, 0x7f, 0xff, 0xff, 0xc0, 0x01, 0x80, 
  0x1c, 0x00, 0x7f, 0xff, 0xff, 0xe0, 0x03, 0x80, 0x0c, 0x00, 0x7f, 0xff, 0xff, 0xe0, 0x03, 0x00, 
  0x0e, 0x00, 0x7f, 0xff, 0xff, 0xe0, 0x07, 0x00, 0x07, 0x00, 0x3f, 0xff, 0xff, 0xe0, 0x0e, 0x00, 
  0x07, 0x00, 0x3f, 0xff, 0xff, 0xc0, 0x0e, 0x00, 0x03, 0x80, 0x1f, 0xff, 0xff, 0xc0, 0x1c, 0x00, 
  0x01, 0xc0, 0x0f, 0xff, 0xff, 0x80, 0x38, 0x00, 0x00, 0xe0, 0x03, 0xff, 0xff, 0x00, 0x70, 0x00, 
  0x00, 0x70, 0x01, 0xff, 0xfe, 0x00, 0xe0, 0x00, 0x00, 0x38, 0x00, 0x3f, 0xf8, 0x01, 0xc0, 0x00, 
  0x00, 0x1e, 0x00, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 
  0x00, 0x07, 0xc0, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x01, 0xf0, 0x00, 0x00, 0xf8, 0x00, 0x00, 
  0x00, 0x00, 0x7f, 0x00, 0x0f, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xff, 0x80, 0x00, 0x00, 
  0x00, 0x00, 0x03, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00, 0x00
};
// 'ventilo3', 60x60px
const unsigned char ventilo3 [] PROGMEM = {
  0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xfc, 0x00, 0x00, 0x00, 
  0x00, 0x00, 0x1f, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x0f, 0xe0, 0x00, 0x00, 
  0x00, 0x01, 0xf8, 0x00, 0x01, 0xf8, 0x00, 0x00, 0x00, 0x07, 0xc0, 0x00, 0x00, 0x3e, 0x00, 0x00, 
  0x00, 0x0f, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x07, 0x80, 0x00, 
  0x00, 0x38, 0x00, 0xff, 0x80, 0x03, 0xc0, 0x00, 0x00, 0x70, 0x03, 0xff, 0xf0, 0x00, 0xe0, 0x00, 
  0x00, 0xe0, 0x0f, 0xff, 0xfc, 0x00, 0x70, 0x00, 0x01, 0xc0, 0x1f, 0xff, 0xfe, 0x00, 0x38, 0x00, 
  0x03, 0x80, 0x1f, 0xff, 0xff, 0x80, 0x1c, 0x00, 0x07, 0x00, 0x3f, 0xff, 0xff, 0xc0, 0x0e, 0x00, 
  0x07, 0x00, 0x3f, 0xff, 0xff, 0xc0, 0x0e, 0x00, 0x0e, 0x00, 0x7f, 0xff, 0xff, 0xe0, 0x07, 0x00, 
  0x0c, 0x00, 0x7f, 0xff, 0xff, 0xe0, 0x03, 0x00, 0x1c, 0x00, 0x7f, 0xff, 0xff, 0xe0, 0x03, 0x80, 
  0x18, 0x00, 0x3f, 0xff, 0xff, 0xe0, 0x01, 0x80, 0x38, 0x00, 0x3f, 0xff, 0xff, 0xc0, 0x01, 0xc0, 
  0x30, 0x00, 0x3f, 0xff, 0xff, 0x00, 0x01, 0xc0, 0x30, 0x00, 0x1f, 0xff, 0xfc, 0x00, 0x00, 0xc0, 
  0x70, 0x00, 0x0f, 0xff, 0xf8, 0x00, 0x00, 0xe0, 0x70, 0x00, 0x07, 0xf0, 0xf0, 0x00, 0x00, 0xe0, 
  0x60, 0x00, 0x07, 0xc0, 0x20, 0x00, 0x00, 0x60, 0x60, 0x1e, 0x01, 0x9f, 0x80, 0xfe, 0x00, 0x60, 
  0xe0, 0x1f, 0x81, 0x3f, 0xc7, 0xff, 0x80, 0x60, 0xe0, 0x3f, 0xc0, 0x7f, 0xef, 0xff, 0xc0, 0x70, 
  0xe0, 0x3f, 0xf8, 0x78, 0xe7, 0xff, 0xe0, 0x70, 0xe0, 0x7f, 0xfe, 0x70, 0xf7, 0xff, 0xe0, 0x70, 
  0xe0, 0x7f, 0xfe, 0x70, 0xf7, 0xff, 0xf0, 0x70, 0xe0, 0x7f, 0xfe, 0x78, 0xe7, 0xff, 0xf0, 0x70, 
  0xe0, 0x7f, 0xff, 0x7f, 0xe7, 0xff, 0xf0, 0x70, 0xe0, 0x7f, 0xff, 0x3f, 0xcf, 0xff, 0xf0, 0x60, 
  0x60, 0x7f, 0xff, 0x9f, 0x9f, 0xff, 0xf0, 0x60, 0x60, 0x7f, 0xff, 0xc0, 0x3f, 0xff, 0xf0, 0x60, 
  0x70, 0x7f, 0xff, 0xf0, 0x7f, 0xff, 0xf0, 0xe0, 0x70, 0x7f, 0xff, 0xfc, 0x7f, 0xff, 0xe0, 0xe0, 
  0x30, 0x3f, 0xff, 0xfc, 0x7f, 0xff, 0xe0, 0xc0, 0x30, 0x3f, 0xff, 0xf8, 0x7f, 0xff, 0xe1, 0xc0, 
  0x38, 0x3f, 0xff, 0xf8, 0x3f, 0xff, 0xc1, 0xc0, 0x18, 0x1f, 0xff, 0xf8, 0x3f, 0xff, 0x81, 0x80, 
  0x1c, 0x1f, 0xff, 0xf8, 0x3f, 0xff, 0x83, 0x80, 0x0c, 0x0f, 0xff, 0xf0, 0x3f, 0xff, 0x03, 0x00, 
  0x0e, 0x07, 0xff, 0xf0, 0x7f, 0xfe, 0x07, 0x00, 0x07, 0x03, 0xff, 0xe0, 0x7f, 0xfc, 0x0e, 0x00, 
  0x07, 0x01, 0xff, 0xc0, 0x3f, 0xf0, 0x0e, 0x00, 0x03, 0x80, 0xff, 0x80, 0x3f, 0xc0, 0x1c, 0x00, 
  0x01, 0xc0, 0x3e, 0x00, 0x1f, 0x00, 0x38, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 
  0x00, 0xf0, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x01, 0xc0, 0x00, 
  0x00, 0x1e, 0x00, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 
  0x00, 0x07, 0xc0, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x01, 0xf0, 0x00, 0x01, 0xf8, 0x00, 0x00, 
  0x00, 0x00, 0x7f, 0x00, 0x0f, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xff, 0x80, 0x00, 0x00, 
  0x00, 0x00, 0x03, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x80, 0x00, 0x00, 0x00
};

const char *const string_table[] PROGMEM = {ventilo1,ventilo2,ventilo3};

display.drawBitmap(68, 0, string_table[i] , LOGO_WIDTH, LOGO_HEIGHT, WHITE);


I 'd like to select ventilo1,2 or 3 to display with index i.

My code is here.

And it doesnt happen nothing because compilation error.

So in the same way (code tags) that you post code, post the actual compilation error.

Christian:
Let's start with the basic.
Before we get into the use of a 2 D array, Can you write a single letter on the display??

What display are you using??

What library are use using??

Have you instructed the compiler to load the Library??

Once we have the display writing a string or Char on the display, Then we will work on the Array.
Ken Kloster

1 Like

topic resolved...
I found how to work.

const unsigned char ventilo1 [] PROGMEM = {...};
const unsigned char ventilo2 [] PROGMEM = {...};
const unsigned char ventilo3 [] PROGMEM = {...};

const uint8_t *ventil[] = {     //global array of pointers to the private data 
   ventilo1, ventilo2, ventilo3
};

With gfx library, i display the desired ventilo by

display.drawBitmap(68, 0, *ventil[v]* , LOGO_WIDTH, LOGO_HEIGHT, WHITE);

The end, thx to all replies.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.