Chciałbym powtórzyć po kilka razy 2 rzeczy w pętli. Czy ktoś mógłby powiedzieć czym zastąpić nieprawidłowe void loop(20)? i usunąć ewentualne błędy? Proszę chociaż o naprowadzenie na właściwe rozwiązanie.
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>
Adafruit_PCD8544 display = Adafruit_PCD8544(4, 6, 8, 10, 12);
#define NUMFLAKES 10
#define XPOS 0
#define YPOS 1
#define DELTAY 2
#define LOGO1_GLCD_WIDTH
#define LOGO2_GLCD_WIDTH
#define LOGO16_GLCD_HEIGHT 16
#define LOGO16_GLCD_WIDTH 16
static const unsigned char PROGMEM logo1_glcd_bmp[] =
{ B00000000, B10000000,
B00000000, B10000000,
B00000000, B10000000,
B00000001, B11000000,
B00000001, B11000000,
B00000011, B11100000,
B00001111, B11111000,
B11111111, B11111111,
B00001111, B11111000,
B00000011, B11100000,
B00000001, B11000000,
B00000001, B11000000,
B00000000, B10000000,
B00000000, B10000000,
B00000000, B10000000,
B00000000, B10000000 };
static const unsigned char PROGMEM logo2_glcd_bmp[] =
{ B00000000, B10000000,
B00001111, B11100000,
B00111111, B11111000,
B00111111, B11111000,
B00011111, B11110000,
B00000111, B11000000,
B00000001, B00000000,
B00000011, B10000000,
B00000001, B00000000,
B00000010, B00000000,
B00000001, B10000000,
B00000000, B10000000,
B00000000, B01000000,
B00000000, B01000000,
B00000000, B10000000,
B00000000, B10000000 };
void setup() {
display.begin();
display.setContrast(50);
display.invertDisplay(true);
delay(1000);
display.invertDisplay(false);
delay(1000);
testdrawbitmap(logo1_glcd_bmp, LOGO1_GLCD_WIDTH, LOGO1_GLCD_HEIGHT);
testdrawbitmap(logo2_glcd_bmp, LOGO2_GLCD_WIDTH, LOGO2_GLCD_HEIGHT);
}
void loop(20) {
display.setRotation(0);
void testdrawbitmap(const uint8_t *bitmap, uint8_t w, uint8_t h) {
uint8_t icons[NUMFLAKES][3];
randomSeed(666); // whatever seed
// initialize
for (uint8_t f=0; f< NUMFLAKES; f++) {
icons[f][XPOS] = random(display.width());
icons[f][YPOS] = 0;
icons[f][DELTAY] = random(5) + 1;
}
while (1) {
// draw each icon
for (uint8_t f=0; f< NUMFLAKES; f++) {
display.drawBitmap(icons[f][XPOS], icons[f][YPOS], logo1_glcd_bmp, w, h, BLACK);
}
display.display();
delay(200);
// then erase it + move it
for (uint8_t f=0; f< NUMFLAKES; f++) {
display.drawBitmap(icons[f][XPOS], icons[f][YPOS], logo1_glcd_bmp, w, h, WHITE);
// move it
icons[f][YPOS] += icons[f][DELTAY];
// if its gone, reinit
if (icons[f][YPOS] > display.height()) {
icons[f][XPOS] = random(display.width());
icons[f][YPOS] = 0;
icons[f][DELTAY] = random(5) + 1;
}
}
}
}
}
void loop(20) {
display.setRotation(2);
void testdrawbitmap(const uint8_t *bitmap, uint8_t w, uint8_t h) {
uint8_t icons[NUMFLAKES][3];
randomSeed(666); // whatever seed
// initialize
for (uint8_t f=0; f< NUMFLAKES; f++) {
icons[f][XPOS] = random(display.width());
icons[f][YPOS] = 0;
icons[f][DELTAY] = random(5) + 1;
}
while (1) {
// draw each icon
for (uint8_t f=0; f< NUMFLAKES; f++) {
display.drawBitmap(icons[f][XPOS], icons[f][YPOS], logo2_glcd_bmp, w, h, BLACK);
}
display.display();
delay(200);
// then erase it + move it
for (uint8_t f=0; f< NUMFLAKES; f++) {
display.drawBitmap(icons[f][XPOS], icons[f][YPOS], logo2_glcd_bmp, w, h, WHITE);
// move it
icons[f][YPOS] += icons[f][DELTAY];
// if its gone, reinit
if (icons[f][YPOS] > display.height()) {
icons[f][XPOS] = random(display.width());
icons[f][YPOS] = 0;
icons[f][DELTAY] = random(5) + 1;
}
}
}
}
}