Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********************************************
- *
- * HORLOGE PLASMA (prototype)
- *
- * L.VOLFOVSKY 26/01/2022
- *********************************************/
- #define WITH_PLASMA
- #include <WiFi.h>
- const char* ssid = "freebox_chezmoi";
- const char* password = "1234567890";
- #include <ESP32Time.h>
- #define R1 25
- #define G1 26
- #define BL1 27
- #define R2 14
- #define G2 12
- #define BL2 13
- #define CH_A 23
- #define CH_B 19
- #define CH_C 5
- #define CH_D 17
- #define CH_E -1 // assign to any available pin if using two panels or 64x64 panels with 1/32 scan
- #define LAT 4
- #define OE 15
- #define CLK 16
- #include <ESP32-HUB75-MatrixPanel-I2S-DMA.h>
- #include <FastLED.h>
- #define PANEL_WIDTH 64
- #define PANEL_HEIGHT 32 // Panel height of 64 will required PIN_E to be defined.
- #define PANELS_NUMBER 2 // Number of chained panels, if just a single panel, obviously set to 1
- #define PIN_E -1
- #define PANE_WIDTH PANEL_WIDTH * PANELS_NUMBER
- #define PANE_HEIGHT PANEL_HEIGHT
- MatrixPanel_I2S_DMA *hdisplay = nullptr;
- uint16_t time_counter = 0, cycles = 0, fps = 0;
- CRGB currentColor;
- //CRGBPalette16 palettes[] = {HeatColors_p, LavaColors_p, RainbowColors_p, RainbowStripeColors_p, CloudColors_p};
- //CRGBPalette16 palettes[] = {HeatColors2_p, LavaColors_p, CloudColors_p, OceanColors_p, ForestColors_p};
- CRGBPalette16 palettes[] = {HeatColors2_p, LavaColors2_p, CloudColors2_p, OceanColors2_p, ForestColors2_p};
- CRGBPalette16 currentPalette = palettes[0];
- uint8_t intensite = 32;
- //=================================================================================
- void setup() {
- Serial.begin(115200);
- HUB75_I2S_CFG::i2s_pins _pins={R1, G1, BL1, R2, G2, BL2, CH_A, CH_B, CH_C, CH_D, CH_E, LAT, OE, CLK};
- HUB75_I2S_CFG mxconfig(
- PANEL_WIDTH
- ,PANEL_HEIGHT
- ,PANELS_NUMBER
- ,_pins
- );
- hdisplay = new MatrixPanel_I2S_DMA(mxconfig);
- hdisplay->setBrightness8(intensite); // 0-255 => 0-100%
- if( not hdisplay->begin() ) {
- Serial.println("I2S memory allocation failed...");
- }
- for (int r=31; r<=255; r+=32) {
- for (int g=31; g<=255; g+=32) {
- for (int b=31; b<=255; b+=32) {
- hdisplay->fillScreenRGB888(r, g, b);
- delay(1);
- }
- }
- }
- hdisplay->fillScreenRGB888(0, 0, 0);
- Serial.print("Connecting to ");
- Serial.println(ssid);
- hdisplay->setTextSize(1);
- hdisplay->setCursor(0,0);
- hdisplay->printf("Cnx:%s",ssid);
- hdisplay->setCursor(0,10);
- WiFi.begin(ssid, password);
- int nbtry = 0;
- while (WiFi.status() != WL_CONNECTED && nbtry++<20) {
- delay(500);
- Serial.print(".");
- hdisplay->print(".");
- }
- hdisplay->setCursor(0,10);
- if (nbtry<20) {
- Serial.println();
- Serial.println("Connecte au WiFi.");
- Serial.println("IP: ");
- Serial.println(WiFi.localIP());
- hdisplay->print(WiFi.localIP());
- ESP32Time.begin();
- }
- else {
- Serial.println();
- Serial.println("Connexion impossible.");
- hdisplay->print("Erreur cnx...");
- }
- delay(2000);
- currentPalette = palettes[0];
- }
- //=================================================================================
- void loop() {
- time_t t = time(NULL);
- struct tm *t_st;
- t_st = localtime(&t);
- #ifdef WITH_PLASMA
- for (int x = 0; x < PANE_WIDTH; x++) {
- for (int y = 0; y < PANE_HEIGHT; y++) {
- int16_t v = 0;
- uint8_t wibble = sin8(time_counter);
- v += sin16(x * wibble * 3 + time_counter);
- v += cos16(y * (128 - wibble) + time_counter);
- v += sin16(y * x * cos8(-time_counter) / 8);
- currentColor = ColorFromPalette(currentPalette, (v >> 8) + 127); //, brightness, currentBlendType);
- hdisplay->drawPixelRGB888(x, y, currentColor.r, currentColor.g, currentColor.b);
- }
- if (x%3==0) {
- hdisplay->setTextSize(2);
- hdisplay->setCursor(15,4);
- hdisplay->setTextColor(hdisplay->color444(255, 255, 255));
- hdisplay->printf("%02d:%02d:%02d",t_st->tm_hour, t_st->tm_min, t_st->tm_sec);
- hdisplay->setTextSize(1);
- hdisplay->setCursor(2,22);
- hdisplay->printf("%c%c%c%c%c%c%c%c %02d/%02d/%04d", "Q M V "[t_st->tm_wday], "iLMeJeS"[t_st->tm_wday], "muarena"[t_st->tm_wday], "anrcudm"[t_st->tm_wday], "nddrdre"[t_st->tm_wday], "ciieied"[t_st->tm_wday], "h d di"[t_st->tm_wday], "e i i "[t_st->tm_wday], t_st->tm_mday, 1 + t_st->tm_mon, 1900 + t_st->tm_year);
- }
- }
- #else
- static uint32_t dly_afftime=0;
- if (millis()-dly_afftime > 1000) {
- dly_afftime = millis();
- hdisplay->fillScreenRGB888(0, 0, 0);
- hdisplay->setTextSize(2);
- hdisplay->setCursor(15,4);
- hdisplay->setTextColor(hdisplay->color444(255, 255, 255));
- hdisplay->printf("%02d:%02d:%02d",t_st->tm_hour, t_st->tm_min, t_st->tm_sec);
- hdisplay->setTextSize(1);
- hdisplay->setCursor(2,22);
- hdisplay->printf("%c%c%c%c%c%c%c%c %02d/%02d/%04d", "Q M V "[t_st->tm_wday], "iLMeJeS"[t_st->tm_wday], "muarena"[t_st->tm_wday], "anrcudm"[t_st->tm_wday], "nddrdre"[t_st->tm_wday], "ciieied"[t_st->tm_wday], "h d di"[t_st->tm_wday], "e i i "[t_st->tm_wday], t_st->tm_mday, 1 + t_st->tm_mon, 1900 + t_st->tm_year);
- }
- #endif
- #ifdef WITH_PLASMA
- ++time_counter;
- ++cycles;
- if (cycles >= 512) {
- time_counter = 0;
- cycles = 0;
- int pal = random(0,sizeof(palettes)/sizeof(palettes[0]));
- currentPalette = palettes[pal];
- }
- #endif
- }
- //
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement