From db50729579200f4c7b8429e49d51274272380b0f Mon Sep 17 00:00:00 2001 From: Christophe JEANNEROT Date: Sat, 6 Dec 2025 12:23:34 +0100 Subject: [PATCH] =?UTF-8?q?T=C3=A9l=C3=A9verser=20les=20fichiers=20vers=20?= =?UTF-8?q?"D1=20mini"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- D1 mini/DHTtester.ino | 74 +++ D1 mini/Lire_la_temparature.ino | 69 +++ ...es_adresses_pour_sonde_de_temp_DS18B20.ino | 72 +++ D1 mini/logo azylis + Sonde.ino | 108 +++++ D1 mini/ssd1306_128x64_i2c.ino | 430 ++++++++++++++++++ 5 files changed, 753 insertions(+) create mode 100644 D1 mini/DHTtester.ino create mode 100644 D1 mini/Lire_la_temparature.ino create mode 100644 D1 mini/R_cuperer_les_adresses_pour_sonde_de_temp_DS18B20.ino create mode 100644 D1 mini/logo azylis + Sonde.ino create mode 100644 D1 mini/ssd1306_128x64_i2c.ino diff --git a/D1 mini/DHTtester.ino b/D1 mini/DHTtester.ino new file mode 100644 index 0000000..585120e --- /dev/null +++ b/D1 mini/DHTtester.ino @@ -0,0 +1,74 @@ +// Example testing sketch for various DHT humidity/temperature sensors +// Written by ladyada, public domain + +// REQUIRES the following Arduino libraries: +// - DHT Sensor Library: https://github.com/adafruit/DHT-sensor-library +// - Adafruit Unified Sensor Lib: https://github.com/adafruit/Adafruit_Sensor + +#include "DHT.h" + +#define DHTPIN D4 // Digital pin connected to the DHT sensor +// Feather HUZZAH ESP8266 note: use pins 3, 4, 5, 12, 13 or 14 -- +// Pin 15 can work but DHT must be disconnected during program upload. + +// Uncomment whatever type you're using! +//#define DHTTYPE DHT11 // DHT 11 +#define DHTTYPE DHT11 // DHT 22 (AM2302), AM2321 +//#define DHTTYPE DHT21 // DHT 21 (AM2301) + +// Connect pin 1 (on the left) of the sensor to +5V +// NOTE: If using a board with 3.3V logic like an Arduino Due connect pin 1 +// to 3.3V instead of 5V! +// Connect pin 2 of the sensor to whatever your DHTPIN is +// Connect pin 3 (on the right) of the sensor to GROUND (if your sensor has 3 pins) +// Connect pin 4 (on the right) of the sensor to GROUND and leave the pin 3 EMPTY (if your sensor has 4 pins) +// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor + +// Initialize DHT sensor. +// Note that older versions of this library took an optional third parameter to +// tweak the timings for faster processors. This parameter is no longer needed +// as the current DHT reading algorithm adjusts itself to work on faster procs. +DHT dht(DHTPIN, DHTTYPE); + +void setup() { + Serial.begin(9600); + Serial.println(F("DHTxx test!")); + + dht.begin(); +} + +void loop() { + // Wait a few seconds between measurements. + delay(2000); + + // Reading temperature or humidity takes about 250 milliseconds! + // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor) + float h = dht.readHumidity(); + // Read temperature as Celsius (the default) + float t = dht.readTemperature(); + // Read temperature as Fahrenheit (isFahrenheit = true) + float f = dht.readTemperature(true); + + // Check if any reads failed and exit early (to try again). + if (isnan(h) || isnan(t) || isnan(f)) { + Serial.println(F("Failed to read from DHT sensor!")); + return; + } + + // Compute heat index in Fahrenheit (the default) + float hif = dht.computeHeatIndex(f, h); + // Compute heat index in Celsius (isFahreheit = false) + float hic = dht.computeHeatIndex(t, h, false); + + Serial.print(F("Humidity: ")); + Serial.print(h); + Serial.print(F("% Temperature: ")); + Serial.print(t); + Serial.print(F("°C ")); + Serial.print(f); + Serial.print(F("°F Heat index: ")); + Serial.print(hic); + Serial.print(F("°C ")); + Serial.print(hif); + Serial.println(F("°F")); +} diff --git a/D1 mini/Lire_la_temparature.ino b/D1 mini/Lire_la_temparature.ino new file mode 100644 index 0000000..cfb8f25 --- /dev/null +++ b/D1 mini/Lire_la_temparature.ino @@ -0,0 +1,69 @@ +#include +#include + +// Data wire is plugged into port 4 on the Arduino or ESP32 +#define ONE_WIRE_BUS D4 +#define TEMPERATURE_PRECISION 10 + +// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs) +OneWire oneWire(ONE_WIRE_BUS); + +// Pass our oneWire reference to Dallas Temperature. +DallasTemperature sensors(&oneWire); + +// Tableaux contenant l'adresse de chaque sonde OneWire | arrays to hold device addresses +DeviceAddress Thermometer = { 0x28, 0x9C, 0x7D, 0x6E, 0x4F, 0x20, 0x1, 0x27 }; + +void setup() { + Serial.begin(115200); + + // Start up the library + sensors.begin(); + + // locate devices on the bus + Serial.print("Locating devices..."); + Serial.print("Found "); + Serial.print(sensors.getDeviceCount(), DEC); + Serial.println(" devices."); + + // report parasite power requirements + Serial.print("Parasite power is: "); + if (sensors.isParasitePowerMode()) Serial.println("ON"); + else Serial.println("OFF"); + + // Vérifie sir les capteurs sont connectés | check and report if sensors are conneted + if (!sensors.getAddress(Thermometer, 0)) Serial.println("Unable to find address for Device 0"); + + // set the resolution to 9 bit per device + sensors.setResolution(Thermometer, TEMPERATURE_PRECISION); + + // On vérifie que le capteur st correctement configuré | Check that ensor is correctly configured + Serial.print("Device Resolution: "); + Serial.print(sensors.getResolution(Thermometer), DEC); + Serial.println(); +} + +void printTemperature(String label, DeviceAddress deviceAddress){ + float tempC = sensors.getTempC(deviceAddress); + Serial.print(label); + if (tempC == -127.00) { + Serial.print("Error getting temperature"); + } else { + Serial.print(" Temp C: "); + Serial.print(tempC); + Serial.print(" Temp F: "); + Serial.println(DallasTemperature::toFahrenheit(tempC)); + } +} + +void loop() { + // put your main code here, to run repeatedly: + Serial.print("Requesting temperatures..."); + sensors.requestTemperatures(); + Serial.println("DONE"); + + // print the device information + printTemperature("Temperature : ", Thermometer); + + delay(5000); +} diff --git a/D1 mini/R_cuperer_les_adresses_pour_sonde_de_temp_DS18B20.ino b/D1 mini/R_cuperer_les_adresses_pour_sonde_de_temp_DS18B20.ino new file mode 100644 index 0000000..c10fbf7 --- /dev/null +++ b/D1 mini/R_cuperer_les_adresses_pour_sonde_de_temp_DS18B20.ino @@ -0,0 +1,72 @@ +/* + * One Wire scanner + * Testé sur la carte ESP32 Wemos LoLin32 Lite | Checked on Wemos LoLin32 Lite development board + * Code inspiré de l'exemple livré avec la librairie Arduino DallasTemperature + * Code inspired by DallasTemperature Arduino library from + * http://milesburton.com/Dallas_Temperature_Control_Library + */ +#include +// Bus OneWie connecté sur la broche 4 | OneWire bus connected on Pin 4 +// Installer une résistance de 4.7K entre le +5V et le cable de données +// A 4.7K resistor is necessary between +5V and Data wire +#define PIN_ONEWIRE D4 +OneWire ds(PIN_ONEWIRE); + +byte i; +byte type_s; +byte data[12]; +byte addr[8]; + +void OneWireScanner(){ + if ( !ds.search(addr)) { + Serial.println("No more addresses."); + Serial.println(); + ds.reset_search(); + return; + } + + Serial.print("ROM = "); + for( i = 0; i < 8; i++) { + Serial.write(' '); + Serial.print("0x"); + Serial.print(addr[i], HEX); + if ( i != 7 ) { + Serial.print(", "); + } + } + + if (OneWire::crc8(addr, 7) != addr[7]) { + Serial.println("CRC is not valid!"); + return; + } + Serial.println(); + + // the first ROM byte indicates which chip + switch (addr[0]) { + case 0x10: + Serial.println(" Chip = DS18S20"); // or old DS1820 + type_s = 1; + break; + case 0x28: + Serial.println(" Chip = DS18B20"); + type_s = 0; + break; + case 0x22: + Serial.println(" Chip = DS1822"); + type_s = 0; + break; + default: + Serial.println("Device is not a DS18x20 family device."); + return; + } +} + +void setup() { + Serial.begin(115200); +} + +void loop() { + // put your main code here, to run repeatedly: + OneWireScanner(); + delay(5000); +} diff --git a/D1 mini/logo azylis + Sonde.ino b/D1 mini/logo azylis + Sonde.ino new file mode 100644 index 0000000..9b992e7 --- /dev/null +++ b/D1 mini/logo azylis + Sonde.ino @@ -0,0 +1,108 @@ +/************************************************************************** +Auteur : Christophe JEANNEROT + + - Gestion d'un ecran LCD de 0.9 Pouces + - Relevé d'une sonde DHT + **************************************************************************/ + +#include +#include +#include +#include + +// définition de la taille de l'ecran +#define SCREEN_WIDTH 128 // Largeur +#define SCREEN_HEIGHT 64 // Hauteur + +#define OLED_RESET -1 // Pas de PIN de reset sur l'écran +#define SCREEN_ADDRESS 0x3C // Adresse de l'ecran +Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); + +// LOGO AZYLIS +#define LOGO_HEIGHT 45 +#define LOGO_WIDTH 64 +static const unsigned char PROGMEM logo_bmp[] = +{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, +0xFF, 0xFF, 0xDF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x8F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, +0xFF, 0xFF, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0xFE, 0x00, 0x00, 0x00, 0x7F, +0xFF, 0xFE, 0x03, 0xFE, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xFE, 0x03, 0xFE, 0x00, 0x00, 0x00, 0xFF, +0xFF, 0xFC, 0x01, 0xFE, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xFC, 0x01, 0xFE, 0x00, 0x00, 0x03, 0xFF, +0xFF, 0xF8, 0x00, 0xFF, 0xFF, 0xF0, 0x07, 0xFF, 0xFF, 0xF8, 0x00, 0xFF, 0xFF, 0xE0, 0x0F, 0xFF, +0xFF, 0xF0, 0x00, 0x7F, 0xFF, 0xC0, 0x1F, 0xFF, 0xFF, 0xE0, 0x00, 0x7F, 0xFF, 0x80, 0x3F, 0xFF, +0xFF, 0xE0, 0x20, 0x3F, 0xFF, 0x00, 0x7F, 0xFF, 0xFF, 0xC0, 0x20, 0x1F, 0xFE, 0x00, 0xFF, 0xFF, +0xFF, 0xC0, 0x70, 0x1F, 0xFC, 0x01, 0xFF, 0xFF, 0xFF, 0x80, 0x70, 0x0F, 0xF8, 0x03, 0xFF, 0xFF, +0xFF, 0x80, 0xF8, 0x0F, 0xF8, 0x07, 0xFF, 0xFF, 0xFF, 0x01, 0xFC, 0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0xC3, 0x80, 0x01, 0xC3, 0xC0, 0x00, 0x00, 0x0F, 0xC3, 0xC0, 0x01, 0xC3, 0xC0, 0x00, 0x00, 0x1F, +0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; + +void setup() { + Serial.begin(9600); + + // Reset de l'écran + display.clearDisplay(); + + // Affichage du Logo sur l'écran + AffichageLogo(); + + // Effet Flash du LOGO + display.invertDisplay(true); + delay(1000); + display.invertDisplay(false); + delay(1000); + + // Affichage + Affichage(); + +} + +void loop() { +} + + +void Affichage(void) { + display.clearDisplay(); + + + display.setTextSize(2); // Draw 2X-scale text + display.setTextColor(SSD1306_WHITE); + display.setCursor(0,0); + display.println(F(" MA MAISON")); //display.println(0xDEADBEEF, HEX); + + display.setTextSize(1); // Normal 1:1 pixel scale + display.println(F("")); + display.setTextColor(SSD1306_WHITE); // Draw white text + display.println(F("Temparature : 18.0")); + display.println(F("")); + display.println(F("")); + display.setTextColor(SSD1306_BLACK, SSD1306_WHITE); // Draw 'inverse' text + display.println(F(" ")); + display.println(F(" TROP Froid !!!! ")); + + + + display.display(); + //delay(10000); +} + + +void AffichageLogo(void) { + display.clearDisplay(); + + display.drawBitmap( + (display.width() - LOGO_WIDTH ) / 2, + (display.height() - LOGO_HEIGHT) / 2, + logo_bmp, LOGO_WIDTH, LOGO_HEIGHT, 1); + display.display(); + delay(1000); +} diff --git a/D1 mini/ssd1306_128x64_i2c.ino b/D1 mini/ssd1306_128x64_i2c.ino new file mode 100644 index 0000000..f48b2b0 --- /dev/null +++ b/D1 mini/ssd1306_128x64_i2c.ino @@ -0,0 +1,430 @@ +/************************************************************************** + This is an example for our Monochrome OLEDs based on SSD1306 drivers + + Pick one up today in the adafruit shop! + ------> http://www.adafruit.com/category/63_98 + + This example is for a 128x64 pixel display using I2C to communicate + 3 pins are required to interface (two I2C and one reset). + + Adafruit invests time and resources providing this open + source code, please support Adafruit and open-source + hardware by purchasing products from Adafruit! + + Written by Limor Fried/Ladyada for Adafruit Industries, + with contributions from the open source community. + BSD license, check license.txt for more information + All text above, and the splash screen below must be + included in any redistribution. + **************************************************************************/ + +#include +#include +#include +#include + +#define SCREEN_WIDTH 128 // OLED display width, in pixels +#define SCREEN_HEIGHT 64 // OLED display height, in pixels + +// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins) +// The pins for I2C are defined by the Wire-library. +// On an arduino UNO: A4(SDA), A5(SCL) +// On an arduino MEGA 2560: 20(SDA), 21(SCL) +// On an arduino LEONARDO: 2(SDA), 3(SCL), ... +#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin) +#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32 +Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); + +#define NUMFLAKES 10 // Number of snowflakes in the animation example + +#define LOGO_HEIGHT 45 +#define LOGO_WIDTH 64 +static const unsigned char PROGMEM logo_bmp[] = +{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, +0xFF, 0xFF, 0xDF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x8F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, +0xFF, 0xFF, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0xFE, 0x00, 0x00, 0x00, 0x7F, +0xFF, 0xFE, 0x03, 0xFE, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xFE, 0x03, 0xFE, 0x00, 0x00, 0x00, 0xFF, +0xFF, 0xFC, 0x01, 0xFE, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xFC, 0x01, 0xFE, 0x00, 0x00, 0x03, 0xFF, +0xFF, 0xF8, 0x00, 0xFF, 0xFF, 0xF0, 0x07, 0xFF, 0xFF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03, 0xE0, 0x20, 0x1F, +0xF8, 0x3C, 0x00, 0x18, 0x03, 0xE0, 0x00, 0x1F, 0xF8, 0x1C, 0x00, 0x08, 0x43, 0xE0, 0x00, 0x1F, +0xF8, 0x1F, 0x83, 0x00, 0x43, 0xF8, 0xC3, 0xFF, 0xF0, 0x0F, 0x83, 0x00, 0xC3, 0xF8, 0xC0, 0x1F, +0xF0, 0x0F, 0x07, 0x80, 0xC3, 0xF8, 0xC0, 0x0F, 0xE0, 0x0E, 0x0F, 0x81, 0xC3, 0xF8, 0xE0, 0x0F, +0xE0, 0x04, 0x1F, 0xC1, 0xC3, 0xF8, 0xFF, 0x0F, 0xE0, 0x04, 0x01, 0xC3, 0xC0, 0x00, 0x00, 0x0F, +0xC3, 0x80, 0x01, 0xC3, 0xC0, 0x00, 0x00, 0x0F, 0xC3, 0xC0, 0x01, 0xC3, 0xC0, 0x00, 0x00, 0x1F, +0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; + +void setup() { + Serial.begin(9600); + + // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally + if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) { + Serial.println(F("SSD1306 allocation failed")); + for(;;); // Don't proceed, loop forever + } + + // Show initial display buffer contents on the screen -- + // the library initializes this with an Adafruit splash screen. + //display.display(); + //delay(2000); // Pause for 2 seconds + + // Clear the buffer + display.clearDisplay(); + + // Draw a single pixel in white + //display.drawPixel(10, 10, SSD1306_WHITE); + + // Show the display buffer on the screen. You MUST call display() after + // drawing commands to make them visible on screen! + //display.display(); + //delay(2000); + // display.display() is NOT necessary after every single drawing command, + // unless that's what you want...rather, you can batch up a bunch of + // drawing operations and then update the screen all at once by calling + // display.display(). These examples demonstrate both approaches... + + //testdrawline(); // Draw many lines + + //testdrawrect(); // Draw rectangles (outlines) + + //testfillrect(); // Draw rectangles (filled) + + //testdrawcircle(); // Draw circles (outlines) + + //testfillcircle(); // Draw circles (filled) + + //testdrawroundrect(); // Draw rounded rectangles (outlines) + + //testfillroundrect(); // Draw rounded rectangles (filled) + + //testdrawtriangle(); // Draw triangles (outlines) + + //testfilltriangle(); // Draw triangles (filled) + + //testdrawchar(); // Draw characters of the default font + + + + //testscrolltext(); // Draw scrolling text + + testdrawbitmap(); // Draw a small bitmap image + + // Invert and restore display, pausing in-between + display.invertDisplay(true); + delay(1000); + display.invertDisplay(false); + delay(1000); + + testdrawstyles(); // Draw 'stylized' characters + + //testanimate(logo_bmp, LOGO_WIDTH, LOGO_HEIGHT); // Animate bitmaps +} + +void loop() { +} + +void testdrawline() { + int16_t i; + + display.clearDisplay(); // Clear display buffer + + for(i=0; i=0; i-=4) { + display.drawLine(0, display.height()-1, display.width()-1, i, SSD1306_WHITE); + display.display(); + delay(1); + } + delay(250); + + display.clearDisplay(); + + for(i=display.width()-1; i>=0; i-=4) { + display.drawLine(display.width()-1, display.height()-1, i, 0, SSD1306_WHITE); + display.display(); + delay(1); + } + for(i=display.height()-1; i>=0; i-=4) { + display.drawLine(display.width()-1, display.height()-1, 0, i, SSD1306_WHITE); + display.display(); + delay(1); + } + delay(250); + + display.clearDisplay(); + + for(i=0; i0; i-=3) { + // The INVERSE color is used so circles alternate white/black + display.fillCircle(display.width() / 2, display.height() / 2, i, SSD1306_INVERSE); + display.display(); // Update screen with each newly-drawn circle + delay(1); + } + + delay(2000); +} + +void testdrawroundrect(void) { + display.clearDisplay(); + + for(int16_t i=0; i0; i-=5) { + // The INVERSE color is used so triangles alternate white/black + display.fillTriangle( + display.width()/2 , display.height()/2-i, + display.width()/2-i, display.height()/2+i, + display.width()/2+i, display.height()/2+i, SSD1306_INVERSE); + display.display(); + delay(1); + } + + delay(2000); +} + +void testdrawchar(void) { + display.clearDisplay(); + + display.setTextSize(1); // Normal 1:1 pixel scale + display.setTextColor(SSD1306_WHITE); // Draw white text + display.setCursor(0, 0); // Start at top-left corner + display.cp437(true); // Use full 256 char 'Code Page 437' font + + // Not all the characters will fit on the display. This is normal. + // Library will draw what it can and the rest will be clipped. + for(int16_t i=0; i<256; i++) { + if(i == '\n') display.write(' '); + else display.write(i); + } + + display.display(); + delay(2000); +} + +void testdrawstyles(void) { + display.clearDisplay(); + + + display.setTextSize(2); // Draw 2X-scale text + display.setTextColor(SSD1306_WHITE); + display.setCursor(0,0); + display.println(F(" MA MAISON")); //display.println(0xDEADBEEF, HEX); + + display.setTextSize(1); // Normal 1:1 pixel scale + display.println(F("")); + display.setTextColor(SSD1306_WHITE); // Draw white text + display.println(F("Temparature : 18.0")); + display.println(F("")); + display.println(F("")); + display.setTextColor(SSD1306_BLACK, SSD1306_WHITE); // Draw 'inverse' text + display.println(F(" ")); + display.println(F(" TROP Froid !!!! ")); + + + + display.display(); + //delay(10000); +} + +void testscrolltext(void) { + display.clearDisplay(); + + display.setTextSize(2); // Draw 2X-scale text + display.setTextColor(SSD1306_WHITE); + display.setCursor(10, 0); + display.println(F("scroll")); + display.display(); // Show initial text + delay(100); + + // Scroll in various directions, pausing in-between: + display.startscrollright(0x00, 0x0F); + delay(2000); + display.stopscroll(); + delay(1000); + display.startscrollleft(0x00, 0x0F); + delay(2000); + display.stopscroll(); + delay(1000); + display.startscrolldiagright(0x00, 0x07); + delay(2000); + display.startscrolldiagleft(0x00, 0x07); + delay(2000); + display.stopscroll(); + delay(1000); +} + +void testdrawbitmap(void) { + display.clearDisplay(); + + display.drawBitmap( + (display.width() - LOGO_WIDTH ) / 2, + (display.height() - LOGO_HEIGHT) / 2, + logo_bmp, LOGO_WIDTH, LOGO_HEIGHT, 1); + display.display(); + delay(1000); +} + +#define XPOS 0 // Indexes into the 'icons' array in function below +#define YPOS 1 +#define DELTAY 2 + +void testanimate(const uint8_t *bitmap, uint8_t w, uint8_t h) { + int8_t f, icons[NUMFLAKES][3]; + + // Initialize 'snowflake' positions + for(f=0; f< NUMFLAKES; f++) { + icons[f][XPOS] = random(1 - LOGO_WIDTH, display.width()); + icons[f][YPOS] = -LOGO_HEIGHT; + icons[f][DELTAY] = random(1, 6); + Serial.print(F("x: ")); + Serial.print(icons[f][XPOS], DEC); + Serial.print(F(" y: ")); + Serial.print(icons[f][YPOS], DEC); + Serial.print(F(" dy: ")); + Serial.println(icons[f][DELTAY], DEC); + } + + for(;;) { // Loop forever... + display.clearDisplay(); // Clear the display buffer + + // Draw each snowflake: + for(f=0; f< NUMFLAKES; f++) { + display.drawBitmap(icons[f][XPOS], icons[f][YPOS], bitmap, w, h, SSD1306_WHITE); + } + + display.display(); // Show the display buffer on the screen + delay(200); // Pause for 1/10 second + + // Then update coordinates of each flake... + for(f=0; f< NUMFLAKES; f++) { + icons[f][YPOS] += icons[f][DELTAY]; + // If snowflake is off the bottom of the screen... + if (icons[f][YPOS] >= display.height()) { + // Reinitialize to a random position, just off the top + icons[f][XPOS] = random(1 - LOGO_WIDTH, display.width()); + icons[f][YPOS] = -LOGO_HEIGHT; + icons[f][DELTAY] = random(1, 6); + } + } + } +}