From c838703b4c9b9dee45e16807b02758cbf2ef8530 Mon Sep 17 00:00:00 2001 From: HACKER3000 Date: Sat, 19 Sep 2020 10:05:28 +0200 Subject: [PATCH 01/21] Bug Fixes, More Patterns, and improovements --- Commands.h | 2 +- GradientPalettes.h | 427 ++++++++++++---------- Twinkles.h | 3 +- esp8266-fastled-webserver.ino | 660 +++++++++++++++++++--------------- 4 files changed, 610 insertions(+), 482 deletions(-) diff --git a/Commands.h b/Commands.h index bbb7a0f4..5868d6f9 100644 --- a/Commands.h +++ b/Commands.h @@ -185,7 +185,7 @@ unsigned long decodeIRCode() { delay(20); if (results.value != 0) - Serial.println(results.value); + //Serial.println(results.value); // Prepare to receive the next IR code irReceiver.resume(); diff --git a/GradientPalettes.h b/GradientPalettes.h index 9928500c..c3692fdd 100644 --- a/GradientPalettes.h +++ b/GradientPalettes.h @@ -11,10 +11,11 @@ // Size: 16 bytes of program space. DEFINE_GRADIENT_PALETTE( ib_jul01_gp ) { - 0, 194, 1, 1, - 94, 1, 29, 18, - 132, 57,131, 28, - 255, 113, 1, 1}; + 0, 194, 1, 1, + 941, 29, 18, + 132, 57, 131, 28, + 255, 113, 1, 1 +}; // Gradient palette "es_vintage_57_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/vintage/tn/es_vintage_57.png.index.html @@ -22,11 +23,12 @@ DEFINE_GRADIENT_PALETTE( ib_jul01_gp ) { // Size: 20 bytes of program space. DEFINE_GRADIENT_PALETTE( es_vintage_57_gp ) { - 0, 2, 1, 1, - 53, 18, 1, 0, + 0, 2, 1, 1, + 53, 18, 1, 0, 104, 69, 29, 1, - 153, 167,135, 10, - 255, 46, 56, 4}; + 153, 167, 135, 10, + 255, 46, 56, 4 +}; // Gradient palette "es_vintage_01_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/vintage/tn/es_vintage_01.png.index.html @@ -34,14 +36,15 @@ DEFINE_GRADIENT_PALETTE( es_vintage_57_gp ) { // Size: 32 bytes of program space. DEFINE_GRADIENT_PALETTE( es_vintage_01_gp ) { - 0, 4, 1, 1, - 51, 16, 0, 1, - 76, 97,104, 3, - 101, 255,131, 19, + 0, 4, 1, 1, + 51, 16, 0, 1, + 76, 97, 104, 3, + 101, 255, 131, 19, 127, 67, 9, 4, 153, 16, 0, 1, 229, 4, 1, 1, - 255, 4, 1, 1}; + 255, 4, 1, 1 +}; // Gradient palette "es_rivendell_15_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/rivendell/tn/es_rivendell_15.png.index.html @@ -49,11 +52,12 @@ DEFINE_GRADIENT_PALETTE( es_vintage_01_gp ) { // Size: 20 bytes of program space. DEFINE_GRADIENT_PALETTE( es_rivendell_15_gp ) { - 0, 1, 14, 5, + 0, 1, 14, 5, 101, 16, 36, 14, 165, 56, 68, 30, - 242, 150,156, 99, - 255, 150,156, 99}; + 242, 150, 156, 99, + 255, 150, 156, 99 +}; // Gradient palette "rgi_15_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/ds/rgi/tn/rgi_15.png.index.html @@ -61,15 +65,16 @@ DEFINE_GRADIENT_PALETTE( es_rivendell_15_gp ) { // Size: 36 bytes of program space. DEFINE_GRADIENT_PALETTE( rgi_15_gp ) { - 0, 4, 1, 31, - 31, 55, 1, 16, - 63, 197, 3, 7, - 95, 59, 2, 17, + 0, 4, 1, 31, + 31, 55, 1, 16, + 63, 197, 3, 7, + 95, 59, 2, 17, 127, 6, 2, 34, 159, 39, 6, 33, 191, 112, 13, 32, 223, 56, 9, 35, - 255, 22, 6, 38}; + 255, 22, 6, 38 +}; // Gradient palette "retro2_16_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/ma/retro2/tn/retro2_16.png.index.html @@ -77,8 +82,9 @@ DEFINE_GRADIENT_PALETTE( rgi_15_gp ) { // Size: 8 bytes of program space. DEFINE_GRADIENT_PALETTE( retro2_16_gp ) { - 0, 188,135, 1, - 255, 46, 7, 1}; + 0, 188, 135, 1, + 255, 46, 7, 1 +}; // Gradient palette "Analogous_1_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/red/tn/Analogous_1.png.index.html @@ -86,11 +92,12 @@ DEFINE_GRADIENT_PALETTE( retro2_16_gp ) { // Size: 20 bytes of program space. DEFINE_GRADIENT_PALETTE( Analogous_1_gp ) { - 0, 3, 0,255, - 63, 23, 0,255, - 127, 67, 0,255, + 0, 3, 0, 255, + 63, 23, 0, 255, + 127, 67, 0, 255, 191, 142, 0, 45, - 255, 255, 0, 0}; + 255, 255, 0, 0 +}; // Gradient palette "es_pinksplash_08_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/pink_splash/tn/es_pinksplash_08.png.index.html @@ -98,11 +105,12 @@ DEFINE_GRADIENT_PALETTE( Analogous_1_gp ) { // Size: 20 bytes of program space. DEFINE_GRADIENT_PALETTE( es_pinksplash_08_gp ) { - 0, 126, 11,255, + 0, 126, 11, 255, 127, 197, 1, 22, - 175, 210,157,172, - 221, 157, 3,112, - 255, 157, 3,112}; + 175, 210, 157, 172, + 221, 157, 3, 112, + 255, 157, 3, 112 +}; // Gradient palette "es_pinksplash_07_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/pink_splash/tn/es_pinksplash_07.png.index.html @@ -110,13 +118,14 @@ DEFINE_GRADIENT_PALETTE( es_pinksplash_08_gp ) { // Size: 28 bytes of program space. DEFINE_GRADIENT_PALETTE( es_pinksplash_07_gp ) { - 0, 229, 1, 1, - 61, 242, 4, 63, - 101, 255, 12,255, - 127, 249, 81,252, - 153, 255, 11,235, + 0, 229, 1, 1, + 61, 242, 4, 63, + 101, 255, 12, 255, + 127, 249, 81, 252, + 153, 255, 11, 235, 193, 244, 5, 68, - 255, 232, 1, 5}; + 255, 232, 1, 5 +}; // Gradient palette "Coral_reef_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/other/tn/Coral_reef.png.index.html @@ -124,12 +133,13 @@ DEFINE_GRADIENT_PALETTE( es_pinksplash_07_gp ) { // Size: 24 bytes of program space. DEFINE_GRADIENT_PALETTE( Coral_reef_gp ) { - 0, 40,199,197, - 50, 10,152,155, - 96, 1,111,120, - 96, 43,127,162, - 139, 10, 73,111, - 255, 1, 34, 71}; + 0, 40, 199, 197, + 50, 10, 152, 155, + 96, 1, 111, 120, + 96, 43, 127, 162, + 139, 10, 73, 111, + 255, 1, 34, 71 +}; // Gradient palette "es_ocean_breeze_068_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/ocean_breeze/tn/es_ocean_breeze_068.png.index.html @@ -137,12 +147,13 @@ DEFINE_GRADIENT_PALETTE( Coral_reef_gp ) { // Size: 24 bytes of program space. DEFINE_GRADIENT_PALETTE( es_ocean_breeze_068_gp ) { - 0, 100,156,153, - 51, 1, 99,137, + 0, 100, 156, 153, + 51, 1, 99, 137, 101, 1, 68, 84, - 104, 35,142,168, - 178, 0, 63,117, - 255, 1, 10, 10}; + 104, 35, 142, 168, + 178, 0, 63, 117, + 255, 1, 10, 10 +}; // Gradient palette "es_ocean_breeze_036_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/ocean_breeze/tn/es_ocean_breeze_036.png.index.html @@ -150,10 +161,11 @@ DEFINE_GRADIENT_PALETTE( es_ocean_breeze_068_gp ) { // Size: 16 bytes of program space. DEFINE_GRADIENT_PALETTE( es_ocean_breeze_036_gp ) { - 0, 1, 6, 7, - 89, 1, 99,111, - 153, 144,209,255, - 255, 0, 73, 82}; + 0, 1, 6, 7, + 89, 1, 99, 111, + 153, 144, 209, 255, + 255, 0, 73, 82 +}; // Gradient palette "departure_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/mjf/tn/departure.png.index.html @@ -161,18 +173,19 @@ DEFINE_GRADIENT_PALETTE( es_ocean_breeze_036_gp ) { // Size: 88 bytes of program space. DEFINE_GRADIENT_PALETTE( departure_gp ) { - 0, 8, 3, 0, - 42, 23, 7, 0, - 63, 75, 38, 6, - 84, 169, 99, 38, - 106, 213,169,119, - 116, 255,255,255, - 138, 135,255,138, - 148, 22,255, 24, - 170, 0,255, 0, - 191, 0,136, 0, + 0, 8, 3, 0, + 42, 23, 7, 0, + 63, 75, 38, 6, + 84, 169, 99, 38, + 106, 213, 169, 119, + 116, 255, 255, 255, + 138, 135, 255, 138, + 148, 22, 255, 24, + 170, 0, 255, 0, + 191, 0, 136, 0, 212, 0, 55, 0, - 255, 0, 55, 0}; + 255, 0, 55, 0 +}; // Gradient palette "es_landscape_64_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/landscape/tn/es_landscape_64.png.index.html @@ -180,15 +193,16 @@ DEFINE_GRADIENT_PALETTE( departure_gp ) { // Size: 36 bytes of program space. DEFINE_GRADIENT_PALETTE( es_landscape_64_gp ) { - 0, 0, 0, 0, - 37, 2, 25, 1, - 76, 15,115, 5, - 127, 79,213, 1, - 128, 126,211, 47, - 130, 188,209,247, - 153, 144,182,205, - 204, 59,117,250, - 255, 1, 37,192}; + 0, 0, 0, 0, + 37, 2, 25, 1, + 76, 15, 115, 5, + 127, 79, 213, 1, + 128, 126, 211, 47, + 130, 188, 209, 247, + 153, 144, 182, 205, + 204, 59, 117, 250, + 255, 1, 37, 192 +}; // Gradient palette "es_landscape_33_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/landscape/tn/es_landscape_33.png.index.html @@ -196,12 +210,13 @@ DEFINE_GRADIENT_PALETTE( es_landscape_64_gp ) { // Size: 24 bytes of program space. DEFINE_GRADIENT_PALETTE( es_landscape_33_gp ) { - 0, 1, 5, 0, - 19, 32, 23, 1, - 38, 161, 55, 1, - 63, 229,144, 1, - 66, 39,142, 74, - 255, 1, 4, 1}; + 0, 1, 5, 0, + 19, 32, 23, 1, + 38, 161, 55, 1, + 63, 229, 144, 1, + 66, 39, 142, 74, + 255, 1, 4, 1 +}; // Gradient palette "rainbowsherbet_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/ma/icecream/tn/rainbowsherbet.png.index.html @@ -209,13 +224,14 @@ DEFINE_GRADIENT_PALETTE( es_landscape_33_gp ) { // Size: 28 bytes of program space. DEFINE_GRADIENT_PALETTE( rainbowsherbet_gp ) { - 0, 255, 33, 4, - 43, 255, 68, 25, - 86, 255, 7, 25, - 127, 255, 82,103, - 170, 255,255,242, - 209, 42,255, 22, - 255, 87,255, 65}; + 0, 255, 33, 4, + 43, 255, 68, 25, + 86, 255, 7, 25, + 127, 255, 82, 103, + 170, 255, 255, 242, + 209, 42, 255, 22, + 255, 87, 255, 65 +}; // Gradient palette "gr65_hult_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/hult/tn/gr65_hult.png.index.html @@ -223,12 +239,13 @@ DEFINE_GRADIENT_PALETTE( rainbowsherbet_gp ) { // Size: 24 bytes of program space. DEFINE_GRADIENT_PALETTE( gr65_hult_gp ) { - 0, 247,176,247, - 48, 255,136,255, - 89, 220, 29,226, - 160, 7, 82,178, - 216, 1,124,109, - 255, 1,124,109}; + 0, 247, 176, 247, + 48, 255, 136, 255, + 89, 220, 29, 226, + 160, 7, 82, 178, + 216, 1, 124, 109, + 255, 1, 124, 109 +}; // Gradient palette "gr64_hult_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/hult/tn/gr64_hult.png.index.html @@ -236,14 +253,15 @@ DEFINE_GRADIENT_PALETTE( gr65_hult_gp ) { // Size: 32 bytes of program space. DEFINE_GRADIENT_PALETTE( gr64_hult_gp ) { - 0, 1,124,109, - 66, 1, 93, 79, + 0, 1, 124, 109, + 66, 1, 93, 79, 104, 52, 65, 1, - 130, 115,127, 1, + 130, 115, 127, 1, 150, 52, 65, 1, 201, 1, 86, 72, 239, 0, 55, 45, - 255, 0, 55, 45}; + 255, 0, 55, 45 +}; // Gradient palette "GMT_drywet_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/gmt/tn/GMT_drywet.png.index.html @@ -251,13 +269,14 @@ DEFINE_GRADIENT_PALETTE( gr64_hult_gp ) { // Size: 28 bytes of program space. DEFINE_GRADIENT_PALETTE( GMT_drywet_gp ) { - 0, 47, 30, 2, - 42, 213,147, 24, - 84, 103,219, 52, - 127, 3,219,207, - 170, 1, 48,214, - 212, 1, 1,111, - 255, 1, 7, 33}; + 0, 47, 30, 2, + 42, 213, 147, 24, + 84, 103, 219, 52, + 127, 3, 219, 207, + 170, 1, 48, 214, + 212, 1, 1, 111, + 255, 1, 7, 33 +}; // Gradient palette "ib15_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/ing/general/tn/ib15.png.index.html @@ -265,12 +284,13 @@ DEFINE_GRADIENT_PALETTE( GMT_drywet_gp ) { // Size: 24 bytes of program space. DEFINE_GRADIENT_PALETTE( ib15_gp ) { - 0, 113, 91,147, - 72, 157, 88, 78, - 89, 208, 85, 33, + 0, 113, 91, 147, + 72, 157, 88, 78, + 89, 208, 85, 33, 107, 255, 29, 11, 141, 137, 31, 39, - 255, 59, 33, 89}; + 255, 59, 33, 89 +}; // Gradient palette "Fuschia_7_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/ds/fuschia/tn/Fuschia-7.png.index.html @@ -278,11 +298,12 @@ DEFINE_GRADIENT_PALETTE( ib15_gp ) { // Size: 20 bytes of program space. DEFINE_GRADIENT_PALETTE( Fuschia_7_gp ) { - 0, 43, 3,153, - 63, 100, 4,103, + 0, 43, 3, 153, + 63, 100, 4, 103, 127, 188, 5, 66, - 191, 161, 11,115, - 255, 135, 20,182}; + 191, 161, 11, 115, + 255, 135, 20, 182 +}; // Gradient palette "es_emerald_dragon_08_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/emerald_dragon/tn/es_emerald_dragon_08.png.index.html @@ -290,10 +311,11 @@ DEFINE_GRADIENT_PALETTE( Fuschia_7_gp ) { // Size: 16 bytes of program space. DEFINE_GRADIENT_PALETTE( es_emerald_dragon_08_gp ) { - 0, 97,255, 1, - 101, 47,133, 1, + 0, 97, 255, 1, + 101, 47, 133, 1, 178, 13, 43, 1, - 255, 2, 10, 1}; + 255, 2, 10, 1 +}; // Gradient palette "lava_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/neota/elem/tn/lava.png.index.html @@ -301,19 +323,20 @@ DEFINE_GRADIENT_PALETTE( es_emerald_dragon_08_gp ) { // Size: 52 bytes of program space. DEFINE_GRADIENT_PALETTE( lava_gp ) { - 0, 0, 0, 0, - 46, 18, 0, 0, - 96, 113, 0, 0, + 0, 0, 0, 0, + 46, 18, 0, 0, + 96, 113, 0, 0, 108, 142, 3, 1, 119, 175, 17, 1, 146, 213, 44, 2, 174, 255, 82, 4, - 188, 255,115, 4, - 202, 255,156, 4, - 218, 255,203, 4, - 234, 255,255, 4, - 244, 255,255, 71, - 255, 255,255,255}; + 188, 255, 115, 4, + 202, 255, 156, 4, + 218, 255, 203, 4, + 234, 255, 255, 4, + 244, 255, 255, 71, + 255, 255, 255, 255 +}; // Gradient palette "fire_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/neota/elem/tn/fire.png.index.html @@ -321,13 +344,14 @@ DEFINE_GRADIENT_PALETTE( lava_gp ) { // Size: 28 bytes of program space. DEFINE_GRADIENT_PALETTE( fire_gp ) { - 0, 1, 1, 0, - 76, 32, 5, 0, + 0, 1, 1, 0, + 76, 32, 5, 0, 146, 192, 24, 0, - 197, 220,105, 5, - 240, 252,255, 31, - 250, 252,255,111, - 255, 255,255,255}; + 197, 220, 105, 5, + 240, 252, 255, 31, + 250, 252, 255, 111, + 255, 255, 255, 255 +}; // Gradient palette "Colorfull_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/atmospheric/tn/Colorfull.png.index.html @@ -335,17 +359,18 @@ DEFINE_GRADIENT_PALETTE( fire_gp ) { // Size: 44 bytes of program space. DEFINE_GRADIENT_PALETTE( Colorfull_gp ) { - 0, 10, 85, 5, - 25, 29,109, 18, - 60, 59,138, 42, - 93, 83, 99, 52, + 0, 10, 85, 5, + 25, 29, 109, 18, + 60, 59, 138, 42, + 93, 83, 99, 52, 106, 110, 66, 64, 109, 123, 49, 65, 113, 139, 35, 66, - 116, 192,117, 98, - 124, 255,255,137, - 168, 100,180,155, - 255, 22,121,174}; + 116, 192, 117, 98, + 124, 255, 255, 137, + 168, 100, 180, 155, + 255, 22, 121, 174 +}; // Gradient palette "Magenta_Evening_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/atmospheric/tn/Magenta_Evening.png.index.html @@ -353,13 +378,14 @@ DEFINE_GRADIENT_PALETTE( Colorfull_gp ) { // Size: 28 bytes of program space. DEFINE_GRADIENT_PALETTE( Magenta_Evening_gp ) { - 0, 71, 27, 39, - 31, 130, 11, 51, - 63, 213, 2, 64, - 70, 232, 1, 66, - 76, 252, 1, 69, + 0, 71, 27, 39, + 31, 130, 11, 51, + 63, 213, 2, 64, + 70, 232, 1, 66, + 76, 252, 1, 69, 108, 123, 2, 51, - 255, 46, 9, 35}; + 255, 46, 9, 35 +}; // Gradient palette "Pink_Purple_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/atmospheric/tn/Pink_Purple.png.index.html @@ -367,17 +393,18 @@ DEFINE_GRADIENT_PALETTE( Magenta_Evening_gp ) { // Size: 44 bytes of program space. DEFINE_GRADIENT_PALETTE( Pink_Purple_gp ) { - 0, 19, 2, 39, - 25, 26, 4, 45, - 51, 33, 6, 52, - 76, 68, 62,125, - 102, 118,187,240, - 109, 163,215,247, - 114, 217,244,255, - 122, 159,149,221, - 149, 113, 78,188, - 183, 128, 57,155, - 255, 146, 40,123}; + 0, 19, 2, 39, + 25, 26, 4, 45, + 51, 33, 6, 52, + 76, 68, 62, 125, + 102, 118, 187, 240, + 109, 163, 215, 247, + 114, 217, 244, 255, + 122, 159, 149, 221, + 149, 113, 78, 188, + 183, 128, 57, 155, + 255, 146, 40, 123 +}; // Gradient palette "Sunset_Real_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/atmospheric/tn/Sunset_Real.png.index.html @@ -385,13 +412,14 @@ DEFINE_GRADIENT_PALETTE( Pink_Purple_gp ) { // Size: 28 bytes of program space. DEFINE_GRADIENT_PALETTE( Sunset_Real_gp ) { - 0, 120, 0, 0, - 22, 179, 22, 0, - 51, 255,104, 0, - 85, 167, 22, 18, - 135, 100, 0,103, - 198, 16, 0,130, - 255, 0, 0,160}; + 0, 120, 0, 0, + 22, 179, 22, 0, + 51, 255, 104, 0, + 85, 167, 22, 18, + 135, 100, 0, 103, + 198, 16, 0, 130, + 255, 0, 0, 160 +}; // Gradient palette "es_autumn_19_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/autumn/tn/es_autumn_19.png.index.html @@ -399,19 +427,20 @@ DEFINE_GRADIENT_PALETTE( Sunset_Real_gp ) { // Size: 52 bytes of program space. DEFINE_GRADIENT_PALETTE( es_autumn_19_gp ) { - 0, 26, 1, 1, - 51, 67, 4, 1, - 84, 118, 14, 1, - 104, 137,152, 52, + 0, 26, 1, 1, + 51, 67, 4, 1, + 84, 118, 14, 1, + 104, 137, 152, 52, 112, 113, 65, 1, - 122, 133,149, 59, - 124, 137,152, 52, + 122, 133, 149, 59, + 124, 137, 152, 52, 135, 113, 65, 1, - 142, 139,154, 46, + 142, 139, 154, 46, 163, 113, 13, 1, 204, 55, 3, 1, 249, 17, 1, 1, - 255, 17, 1, 1}; + 255, 17, 1, 1 +}; // Gradient palette "BlacK_Blue_Magenta_White_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/basic/tn/BlacK_Blue_Magenta_White.png.index.html @@ -419,13 +448,14 @@ DEFINE_GRADIENT_PALETTE( es_autumn_19_gp ) { // Size: 28 bytes of program space. DEFINE_GRADIENT_PALETTE( BlacK_Blue_Magenta_White_gp ) { - 0, 0, 0, 0, - 42, 0, 0, 45, - 84, 0, 0,255, - 127, 42, 0,255, - 170, 255, 0,255, - 212, 255, 55,255, - 255, 255,255,255}; + 0, 0, 0, 0, + 42, 0, 0, 45, + 84, 0, 0, 255, + 127, 42, 0, 255, + 170, 255, 0, 255, + 212, 255, 55, 255, + 255, 255, 255, 255 +}; // Gradient palette "BlacK_Magenta_Red_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/basic/tn/BlacK_Magenta_Red.png.index.html @@ -433,11 +463,12 @@ DEFINE_GRADIENT_PALETTE( BlacK_Blue_Magenta_White_gp ) { // Size: 20 bytes of program space. DEFINE_GRADIENT_PALETTE( BlacK_Magenta_Red_gp ) { - 0, 0, 0, 0, - 63, 42, 0, 45, - 127, 255, 0,255, + 0, 0, 0, 0, + 63, 42, 0, 45, + 127, 255, 0, 255, 191, 255, 0, 45, - 255, 255, 0, 0}; + 255, 255, 0, 0 +}; // Gradient palette "BlacK_Red_Magenta_Yellow_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/basic/tn/BlacK_Red_Magenta_Yellow.png.index.html @@ -445,13 +476,14 @@ DEFINE_GRADIENT_PALETTE( BlacK_Magenta_Red_gp ) { // Size: 28 bytes of program space. DEFINE_GRADIENT_PALETTE( BlacK_Red_Magenta_Yellow_gp ) { - 0, 0, 0, 0, - 42, 42, 0, 0, - 84, 255, 0, 0, + 0, 0, 0, 0, + 42, 42, 0, 0, + 84, 255, 0, 0, 127, 255, 0, 45, - 170, 255, 0,255, + 170, 255, 0, 255, 212, 255, 55, 45, - 255, 255,255, 0}; + 255, 255, 255, 0 +}; // Gradient palette "Blue_Cyan_Yellow_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/basic/tn/Blue_Cyan_Yellow.png.index.html @@ -459,14 +491,24 @@ DEFINE_GRADIENT_PALETTE( BlacK_Red_Magenta_Yellow_gp ) { // Size: 20 bytes of program space. DEFINE_GRADIENT_PALETTE( Blue_Cyan_Yellow_gp ) { - 0, 0, 0,255, - 63, 0, 55,255, - 127, 0,255,255, - 191, 42,255, 45, - 255, 255,255, 0}; + 0, 0, 0, 255, + 63, 0, 55, 255, + 127, 0, 255, 255, + 191, 42, 255, 45, + 255, 255, 255, 0 +}; -// Single array of defined cpt-city color palettes. +DEFINE_GRADIENT_PALETTE( Vapour ) { + 111, 234, 230, 255, + 246, 163, 239, 255, + 80, 216, 236, 255, + 221, 109, 251, 255, + 238, 205, 105, 255, +}; + + +//Single array of defined cpt-city color palettes. // This will let us programmatically choose one based on // a number, rather than having to activate each explicitly // by name every time. @@ -509,10 +551,11 @@ const TProgmemRGBGradientPalettePtr gGradientPalettes[] = { BlacK_Blue_Magenta_White_gp, BlacK_Magenta_Red_gp, BlacK_Red_Magenta_Yellow_gp, - Blue_Cyan_Yellow_gp }; + Blue_Cyan_Yellow_gp, + Vapour +}; // Count of how many cpt-city gradients are defined: const uint8_t gGradientPaletteCount = sizeof( gGradientPalettes) / sizeof( TProgmemRGBGradientPalettePtr ); - diff --git a/Twinkles.h b/Twinkles.h index bcc5d6ae..6d372bb8 100644 --- a/Twinkles.h +++ b/Twinkles.h @@ -76,7 +76,7 @@ void colortwinkles() // Make each pixel brighter or darker, depending on // its 'direction' flag. brightenOrDarkenEachPixel( FADE_IN_SPEED, FADE_OUT_SPEED); - + // Now consider adding a new random twinkle if ( random8() < DENSITY ) { int pos = random16(NUM_LEDS); @@ -115,4 +115,3 @@ void incandescentTwinkles() gCurrentPalette = CRGBPalette16( l, l, l, l, l, l, l, l, l, l, l, l, l, l, l, l ); colortwinkles(); } - diff --git a/esp8266-fastled-webserver.ino b/esp8266-fastled-webserver.ino index a06bff8b..59473050 100644 --- a/esp8266-fastled-webserver.ino +++ b/esp8266-fastled-webserver.ino @@ -32,35 +32,39 @@ extern "C" { #include #include #include -//#include +#include +#include #include #include -//#include +#include +#include +#include #include // https://github.com/tzapu/WiFiManager/tree/development +#include #include "GradientPalettes.h" #define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0])) #include "Field.h" -//#define RECV_PIN D4 -//IRrecv irReceiver(RECV_PIN); +#define RECV_PIN D7 +IRrecv irReceiver(RECV_PIN); -//#include "Commands.h" +#include "Commands.h" WiFiManager wifiManager; ESP8266WebServer webServer(80); -//WebSocketsServer webSocketsServer = WebSocketsServer(81); +WebSocketsServer webSocketsServer = WebSocketsServer(81); ESP8266HTTPUpdateServer httpUpdateServer; #include "FSBrowser.h" -#define DATA_PIN D5 +#define DATA_PIN D8 #define LED_TYPE WS2811 #define COLOR_ORDER RGB -#define NUM_LEDS 200 +#define NUM_LEDS 30 -#define MILLI_AMPS 2000 // IMPORTANT: set the max milli-Amps of your power supply (4A = 4000mA) +#define MILLI_AMPS 8000 // IMPORTANT: set the max milli-Amps of your power supply (4A = 4000mA) #define FRAMES_PER_SECOND 120 // here you can control the speed. With the Access Point / Web Server the animations run a bit slower. String nameString; @@ -146,6 +150,7 @@ PatternAndNameList patterns = { { colorWavesPlayground, "Color Waves Playground" }, // twinkle patterns + { twinkels, "Twinkels" }, { rainbowTwinkles, "Rainbow Twinkles" }, { snowTwinkles, "Snow Twinkles" }, { cloudTwinkles, "Cloud Twinkles" }, @@ -167,6 +172,7 @@ PatternAndNameList patterns = { { cloud2Twinkles, "Cloud 2 Twinkles" }, { oceanTwinkles, "Ocean Twinkles" }, + { palettebow, "PaletteBow" }, { rainbow, "Rainbow" }, { rainbowWithGlitter, "Rainbow With Glitter" }, { rainbowSolid, "Solid Rainbow" }, @@ -189,33 +195,101 @@ typedef struct { typedef PaletteAndName PaletteAndNameList[]; const CRGBPalette16 palettes[] = { - RainbowColors_p, - RainbowStripeColors_p, - CloudColors_p, - LavaColors_p, - OceanColors_p, - ForestColors_p, - PartyColors_p, - HeatColors_p + RainbowColors_p, + RainbowStripeColors_p, + CloudColors_p, + LavaColors_p, + OceanColors_p, + ForestColors_p, + PartyColors_p, + HeatColors_p, + Vapour, + Sunset_Real_gp, + es_rivendell_15_gp, + es_ocean_breeze_036_gp, + rgi_15_gp, + retro2_16_gp, + Analogous_1_gp, + es_pinksplash_08_gp, + Coral_reef_gp, + es_ocean_breeze_068_gp, + es_pinksplash_07_gp, + es_vintage_01_gp, + departure_gp, + es_landscape_64_gp, + es_landscape_33_gp, + rainbowsherbet_gp, + gr65_hult_gp, + gr64_hult_gp, + GMT_drywet_gp, + ib_jul01_gp, + es_vintage_57_gp, + ib15_gp, + Fuschia_7_gp, + es_emerald_dragon_08_gp, + lava_gp, + fire_gp, + Colorfull_gp, + Magenta_Evening_gp, + Pink_Purple_gp, + es_autumn_19_gp, + BlacK_Blue_Magenta_White_gp, + BlacK_Magenta_Red_gp, + BlacK_Red_Magenta_Yellow_gp, + Blue_Cyan_Yellow_gp }; const uint8_t paletteCount = ARRAY_SIZE(palettes); const String paletteNames[paletteCount] = { - "Rainbow", - "Rainbow Stripe", - "Cloud", - "Lava", - "Ocean", - "Forest", - "Party", - "Heat", + "Rainbow", + "Rainbow Stripe", + "Cloud", + "Lava", + "Ocean", + "Forest", + "Party", + "Heat", + "Vapourwave", + "Sunset Real gp", + "rivendell 15", + "ocean breeze 036", + "rgi 15", + "retro2 16", + "Analogous 1", + "pinksplash 08", + "Coral reef", + "ocean breeze 068", + "pinksplash 07", + "vintage 01", + "departure", + "landscape 64", + "landscape 33", + "rainbowsherbet", + "gr65 hult", + "gr64 hult", + "GMT drywet", + "ib jul01", + "vintage 57", + "ib15", + "Fuschia 7", + "emerald dragon 08", + "lava", + "fire", + "Colorfull", + "Magenta Evening", + "Pink Purple", + "autumn 19", + "BlacK Blue Magenta White", + "BlacK Magenta Red", + "BlacK Red Magenta Yellow", + "Blue Cyan Yellow" }; #include "Fields.h" void setup() { - WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP + WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP WiFi.setSleepMode(WIFI_NONE_SLEEP); Serial.begin(115200); @@ -235,7 +309,7 @@ void setup() { FastLED.setBrightness(brightness); - // irReceiver.enableIRIn(); // Start the receiver + irReceiver.enableIRIn(); // Start the receiver Serial.println(); Serial.print( F("Heap: ") ); Serial.println(system_get_free_heap_size()); @@ -286,13 +360,13 @@ void setup() { //automatically connect using saved credentials if they exist //If connection fails it starts an access point with the specified name - if(wifiManager.autoConnect(nameChar)){ + if (wifiManager.autoConnect(nameChar)) { Serial.println("Wi-Fi connected"); } else { Serial.println("Wi-Fi manager portal running"); } - + httpUpdateServer.setup(&webServer); webServer.on("/all", HTTP_GET, []() { @@ -438,9 +512,9 @@ void setup() { //first callback is called after the request has ended with all parsed arguments //second callback handles file uploads at that location webServer.on("/edit", HTTP_POST, []() { - webServer.sendHeader("Access-Control-Allow-Origin", "*"); - webServer.send(200, "text/plain", ""); - }, handleFileUpload); + webServer.sendHeader("Access-Control-Allow-Origin", "*"); + webServer.send(200, "text/plain", ""); + }, handleFileUpload); webServer.serveStatic("/", SPIFFS, "/", "max-age=86400"); @@ -450,11 +524,13 @@ void setup() { webServer.begin(); Serial.println("HTTP web server started"); - // webSocketsServer.begin(); - // webSocketsServer.onEvent(webSocketEvent); - // Serial.println("Web socket server started"); + webSocketsServer.begin(); + webSocketsServer.onEvent(webSocketEvent); + Serial.println("Web socket server started"); autoPlayTimeout = millis() + (autoplayDuration * 1000); + + ArduinoOTA.begin(); } void sendInt(uint8_t value) @@ -467,29 +543,30 @@ void sendString(String value) webServer.send(200, "text/plain", value); } + void broadcastInt(String name, uint8_t value) { String json = "{\"name\":\"" + name + "\",\"value\":" + String(value) + "}"; - // webSocketsServer.broadcastTXT(json); + webSocketsServer.broadcastTXT(json); } void broadcastString(String name, String value) { String json = "{\"name\":\"" + name + "\",\"value\":\"" + String(value) + "\"}"; - // webSocketsServer.broadcastTXT(json); + webSocketsServer.broadcastTXT(json); } void loop() { // Add entropy to random number generator; we use a lot of it. random16_add_entropy(random(65535)); - // webSocketsServer.loop(); + //webSocketsServer.loop(); wifiManager.process(); webServer.handleClient(); MDNS.update(); - // timeClient.update(); + // timeClient.update(); static bool hasConnected = false; EVERY_N_SECONDS(1) { @@ -513,7 +590,7 @@ void loop() { checkPingTimer(); - // handleIrInput(); + handleIrInput(); if (power == 0) { fill_solid(leds, NUM_LEDS, CRGB::Black); @@ -522,9 +599,9 @@ void loop() { return; } - // EVERY_N_SECONDS(10) { - // Serial.print( F("Heap: ") ); Serial.println(system_get_free_heap_size()); - // } + EVERY_N_SECONDS(10) { + Serial.print( F("Heap: ") ); Serial.println(system_get_free_heap_size()); + } // change to a new cpt-city gradient palette EVERY_N_SECONDS( secondsPerPalette ) { @@ -550,251 +627,247 @@ void loop() { // insert a delay to keep the framerate modest FastLED.delay(1000 / FRAMES_PER_SECOND); + + ArduinoOTA.handle(); } -//void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t length) { -// -// switch (type) { -// case WStype_DISCONNECTED: -// Serial.printf("[%u] Disconnected!\n", num); -// break; -// -// case WStype_CONNECTED: -// { -// IPAddress ip = webSocketsServer.remoteIP(num); -// Serial.printf("[%u] Connected from %d.%d.%d.%d url: %s\n", num, ip[0], ip[1], ip[2], ip[3], payload); -// -// // send message to client -// // webSocketsServer.sendTXT(num, "Connected"); -// } -// break; -// -// case WStype_TEXT: -// Serial.printf("[%u] get Text: %s\n", num, payload); -// -// // send message to client -// // webSocketsServer.sendTXT(num, "message here"); -// -// // send data to all connected clients -// // webSocketsServer.broadcastTXT("message here"); -// break; -// -// case WStype_BIN: -// Serial.printf("[%u] get binary length: %u\n", num, length); -// hexdump(payload, length); -// -// // send message to client -// // webSocketsServer.sendBIN(num, payload, lenght); -// break; -// } -//} - -//void handleIrInput() -//{ -// InputCommand command = readCommand(); -// -// if (command != InputCommand::None) { -// Serial.print("command: "); -// Serial.println((int) command); -// } -// -// switch (command) { -// case InputCommand::Up: { -// adjustPattern(true); -// break; -// } -// case InputCommand::Down: { -// adjustPattern(false); -// break; -// } -// case InputCommand::Power: { -// setPower(power == 0 ? 1 : 0); -// break; -// } -// case InputCommand::BrightnessUp: { -// adjustBrightness(true); -// break; -// } -// case InputCommand::BrightnessDown: { -// adjustBrightness(false); -// break; -// } -// case InputCommand::PlayMode: { // toggle pause/play -// setAutoplay(!autoplay); -// break; -// } -// -// // pattern buttons -// -// case InputCommand::Pattern1: { -// setPattern(0); -// break; -// } -// case InputCommand::Pattern2: { -// setPattern(1); -// break; -// } -// case InputCommand::Pattern3: { -// setPattern(2); -// break; -// } -// case InputCommand::Pattern4: { -// setPattern(3); -// break; -// } -// case InputCommand::Pattern5: { -// setPattern(4); -// break; -// } -// case InputCommand::Pattern6: { -// setPattern(5); -// break; -// } -// case InputCommand::Pattern7: { -// setPattern(6); -// break; -// } -// case InputCommand::Pattern8: { -// setPattern(7); -// break; -// } -// case InputCommand::Pattern9: { -// setPattern(8); -// break; -// } -// case InputCommand::Pattern10: { -// setPattern(9); -// break; -// } -// case InputCommand::Pattern11: { -// setPattern(10); -// break; -// } -// case InputCommand::Pattern12: { -// setPattern(11); -// break; -// } -// -// // custom color adjustment buttons -// -// case InputCommand::RedUp: { -// solidColor.red += 8; -// setSolidColor(solidColor); -// break; -// } -// case InputCommand::RedDown: { -// solidColor.red -= 8; -// setSolidColor(solidColor); -// break; -// } -// case InputCommand::GreenUp: { -// solidColor.green += 8; -// setSolidColor(solidColor); -// break; -// } -// case InputCommand::GreenDown: { -// solidColor.green -= 8; -// setSolidColor(solidColor); -// break; -// } -// case InputCommand::BlueUp: { -// solidColor.blue += 8; -// setSolidColor(solidColor); -// break; -// } -// case InputCommand::BlueDown: { -// solidColor.blue -= 8; -// setSolidColor(solidColor); -// break; -// } -// -// // color buttons -// -// case InputCommand::Red: { -// setSolidColor(CRGB::Red); -// break; -// } -// case InputCommand::RedOrange: { -// setSolidColor(CRGB::OrangeRed); -// break; -// } -// case InputCommand::Orange: { -// setSolidColor(CRGB::Orange); -// break; -// } -// case InputCommand::YellowOrange: { -// setSolidColor(CRGB::Goldenrod); -// break; -// } -// case InputCommand::Yellow: { -// setSolidColor(CRGB::Yellow); -// break; -// } -// -// case InputCommand::Green: { -// setSolidColor(CRGB::Green); -// break; -// } -// case InputCommand::Lime: { -// setSolidColor(CRGB::Lime); -// break; -// } -// case InputCommand::Aqua: { -// setSolidColor(CRGB::Aqua); -// break; -// } -// case InputCommand::Teal: { -// setSolidColor(CRGB::Teal); -// break; -// } -// case InputCommand::Navy: { -// setSolidColor(CRGB::Navy); -// break; -// } -// -// case InputCommand::Blue: { -// setSolidColor(CRGB::Blue); -// break; -// } -// case InputCommand::RoyalBlue: { -// setSolidColor(CRGB::RoyalBlue); -// break; -// } -// case InputCommand::Purple: { -// setSolidColor(CRGB::Purple); -// break; -// } -// case InputCommand::Indigo: { -// setSolidColor(CRGB::Indigo); -// break; -// } -// case InputCommand::Magenta: { -// setSolidColor(CRGB::Magenta); -// break; -// } -// -// case InputCommand::White: { -// setSolidColor(CRGB::White); -// break; -// } -// case InputCommand::Pink: { -// setSolidColor(CRGB::Pink); -// break; -// } -// case InputCommand::LightPink: { -// setSolidColor(CRGB::LightPink); -// break; -// } -// case InputCommand::BabyBlue: { -// setSolidColor(CRGB::CornflowerBlue); -// break; -// } -// case InputCommand::LightBlue: { -// setSolidColor(CRGB::LightBlue); -// break; -// } -// } -//} +void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t length) { + + switch (type) { + case WStype_DISCONNECTED: + Serial.printf("[%u] Disconnected!\n", num); + break; + + case WStype_CONNECTED: + { + IPAddress ip = webSocketsServer.remoteIP(num); + Serial.printf("[%u] Connected from %d.%d.%d.%d url: %s\n", num, ip[0], ip[1], ip[2], ip[3], payload); + + //send message to client + webSocketsServer.sendTXT(num, "Connected"); + } + break; + + case WStype_TEXT: + Serial.printf("[%u] get Text: %s\n", num, payload); + + //send message to client + webSocketsServer.sendTXT(num, "message here"); + + //send data to all connected clients + webSocketsServer.broadcastTXT("message here"); + break; + + case WStype_BIN: + Serial.printf("[%u] get binary length: %u\n", num, length); + hexdump(payload, length); + + //send message to client + webSocketsServer.sendBIN(num, payload, length); + break; + } +} + +void handleIrInput() +{ + InputCommand command = readCommand(); + + if (command != InputCommand::None) { + Serial.print("command: "); + Serial.println((int) command); + } + + switch (command) { + case InputCommand::Up: { + adjustPattern(true); + break; + } + case InputCommand::Down: { + adjustPattern(false); + break; + } + case InputCommand::Power: { + setPower(power == 0 ? 1 : 0); + break; + } + case InputCommand::BrightnessUp: { + adjustBrightness(true); + break; + } + case InputCommand::BrightnessDown: { + adjustBrightness(false); + break; + } + case InputCommand::PlayMode: { + setAutoplay(!autoplay); + break; + } + + case InputCommand::Pattern1: { + setPattern(0); + break; + } + case InputCommand::Pattern2: { + setPattern(1); + break; + } + case InputCommand::Pattern3: { + setPattern(2); + break; + } + case InputCommand::Pattern4: { + setPattern(3); + break; + } + case InputCommand::Pattern5: { + setPattern(4); + break; + } + case InputCommand::Pattern6: { + setPattern(5); + break; + } + case InputCommand::Pattern7: { + setPattern(6); + break; + } + case InputCommand::Pattern8: { + setPattern(7); + break; + } + case InputCommand::Pattern9: { + setPattern(8); + break; + } + case InputCommand::Pattern10: { + setPattern(9); + break; + } + case InputCommand::Pattern11: { + setPattern(10); + break; + } + case InputCommand::Pattern12: { + setPattern(11); + break; + } + + case InputCommand::RedUp: { + solidColor.red += 8; + setSolidColor(solidColor); + break; + } + case InputCommand::RedDown: { + solidColor.red -= 8; + setSolidColor(solidColor); + break; + } + case InputCommand::GreenUp: { + solidColor.green += 8; + setSolidColor(solidColor); + break; + } + case InputCommand::GreenDown: { + solidColor.green -= 8; + setSolidColor(solidColor); + break; + } + case InputCommand::BlueUp: { + solidColor.blue += 8; + setSolidColor(solidColor); + break; + } + case InputCommand::BlueDown: { + solidColor.blue -= 8; + setSolidColor(solidColor); + break; + } + + case InputCommand::Red: { + setSolidColor(CRGB::Red); + break; + } + case InputCommand::RedOrange: { + setSolidColor(CRGB::OrangeRed); + break; + } + case InputCommand::Orange: { + setSolidColor(CRGB::Orange); + break; + } + case InputCommand::YellowOrange: { + setSolidColor(CRGB::Goldenrod); + break; + } + case InputCommand::Yellow: { + setSolidColor(CRGB::Yellow); + break; + } + + case InputCommand::Green: { + setSolidColor(CRGB::Green); + break; + } + case InputCommand::Lime: { + setSolidColor(CRGB::Lime); + break; + } + case InputCommand::Aqua: { + setSolidColor(CRGB::Aqua); + break; + } + case InputCommand::Teal: { + setSolidColor(CRGB::Teal); + break; + } + case InputCommand::Navy: { + setSolidColor(CRGB::Navy); + break; + } + + case InputCommand::Blue: { + setSolidColor(CRGB::Blue); + break; + } + case InputCommand::RoyalBlue: { + setSolidColor(CRGB::RoyalBlue); + break; + } + case InputCommand::Purple: { + setSolidColor(CRGB::Purple); + break; + } + case InputCommand::Indigo: { + setSolidColor(CRGB::Indigo); + break; + } + case InputCommand::Magenta: { + setSolidColor(CRGB::Magenta); + break; + } + + case InputCommand::White: { + setSolidColor(CRGB::White); + break; + } + case InputCommand::Pink: { + setSolidColor(CRGB::Pink); + break; + } + case InputCommand::LightPink: { + setSolidColor(CRGB::LightPink); + break; + } + case InputCommand::BabyBlue: { + setSolidColor(CRGB::CornflowerBlue); + break; + } + case InputCommand::LightBlue: { + setSolidColor(CRGB::LightBlue); + break; + } + } +} void loadSettings() { @@ -1013,6 +1086,11 @@ void rainbow() fill_rainbow( leds, NUM_LEDS, gHue, 255 / NUM_LEDS); } +void palettebow() +{ + fill_solid(leds, NUM_LEDS, ColorFromPalette(palettes[currentPaletteIndex], gHue, 255)); +} + void rainbowWithGlitter() { // built-in FastLED rainbow, plus some random sparkly glitter @@ -1070,7 +1148,7 @@ void juggle() static uint8_t thisbright = 255; // How bright should the LED/display be. static uint8_t basebeat = 5; // Higher = faster movement. - static uint8_t lastSecond = 99; // Static variable, means it's only defined once. This is our 'debounce' variable. + static uint8_t lastSecond = 99; // Static variable, means it's only defined once. This is our 'debounce' variable. uint8_t secondHand = (millis() / 1000) % 30; // IMPORTANT!!! Change '30' to a different value to change duration of the loop. if (lastSecond != secondHand) { // Debounce to make sure we're not repeating an assignment. @@ -1147,6 +1225,14 @@ void pride() } } + +void twinkels() +{ + gCurrentPalette = palettes[currentPaletteIndex]; + colortwinkles(); +} + + void radialPaletteShift() { for (uint16_t i = 0; i < NUM_LEDS; i++) { From f73dcad0e15823e39f167716aedf7a41335a023d Mon Sep 17 00:00:00 2001 From: HACKER3000 Date: Sat, 19 Sep 2020 11:01:22 +0200 Subject: [PATCH 02/21] more. MORE! --- esp8266-fastled-webserver.ino | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/esp8266-fastled-webserver.ino b/esp8266-fastled-webserver.ino index 59473050..7be1f081 100644 --- a/esp8266-fastled-webserver.ino +++ b/esp8266-fastled-webserver.ino @@ -172,7 +172,9 @@ PatternAndNameList patterns = { { cloud2Twinkles, "Cloud 2 Twinkles" }, { oceanTwinkles, "Ocean Twinkles" }, - { palettebow, "PaletteBow" }, + { coolerpalettebow, "PaletteBow" }, + { palettebowglitter, "PaletteBow With Glitter" }, + { palettebow, "Solid PaletteBow" }, { rainbow, "Rainbow" }, { rainbowWithGlitter, "Rainbow With Glitter" }, { rainbowSolid, "Solid Rainbow" }, @@ -1091,6 +1093,20 @@ void palettebow() fill_solid(leds, NUM_LEDS, ColorFromPalette(palettes[currentPaletteIndex], gHue, 255)); } +void coolerpalettebow() +{ + static uint8_t startindex = 0; + startindex--; + fill_palette( leds, NUM_LEDS, startindex, (256 / NUM_LEDS) + 1, palettes[currentPaletteIndex], 255, LINEARBLEND); +} + +void palettebowglitter() +{ + // built-in FastLED rainbow, plus some random sparkly glitter + palettebow(); + addGlitter(80); +} + void rainbowWithGlitter() { // built-in FastLED rainbow, plus some random sparkly glitter @@ -1373,9 +1389,8 @@ void colorwaves( CRGB* ledarray, uint16_t numleds, CRGBPalette16& palette) } // Alternate rendering function just scrolls the current palette -// across the defined LED strip. -void palettetest( CRGB* ledarray, uint16_t numleds, const CRGBPalette16& gCurrentPalette) -{ +// across the defined LED strip.a +void palettetest( CRGB* ledarray, uint16_t numleds, const CRGBPalette16& gCurrentPalette) { static uint8_t startindex = 0; startindex--; fill_palette( ledarray, numleds, startindex, (256 / NUM_LEDS) + 1, gCurrentPalette, 255, LINEARBLEND); From 528ebd2ee750cdc9728be26e44ff88feed2469d2 Mon Sep 17 00:00:00 2001 From: HACKER3000 Date: Sat, 19 Sep 2020 11:23:29 +0200 Subject: [PATCH 03/21] fixes and more patterns --- GradientPalettes.h | 10 +++++----- esp8266-fastled-webserver.ino | 14 +++++++++++++- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/GradientPalettes.h b/GradientPalettes.h index c3692fdd..5f6400b0 100644 --- a/GradientPalettes.h +++ b/GradientPalettes.h @@ -500,11 +500,11 @@ DEFINE_GRADIENT_PALETTE( Blue_Cyan_Yellow_gp ) { DEFINE_GRADIENT_PALETTE( Vapour ) { - 111, 234, 230, 255, - 246, 163, 239, 255, - 80, 216, 236, 255, - 221, 109, 251, 255, - 238, 205, 105, 255, + 0, 111, 234, 230, + 64, 246, 163, 239, + 128, 80, 216, 236, + 192, 221, 109, 251, + 255, 238, 205, 105 }; diff --git a/esp8266-fastled-webserver.ino b/esp8266-fastled-webserver.ino index 7be1f081..30d1f6ea 100644 --- a/esp8266-fastled-webserver.ino +++ b/esp8266-fastled-webserver.ino @@ -61,7 +61,7 @@ ESP8266HTTPUpdateServer httpUpdateServer; #define DATA_PIN D8 #define LED_TYPE WS2811 -#define COLOR_ORDER RGB +#define COLOR_ORDER GRB #define NUM_LEDS 30 #define MILLI_AMPS 8000 // IMPORTANT: set the max milli-Amps of your power supply (4A = 4000mA) @@ -184,6 +184,8 @@ PatternAndNameList patterns = { { juggle, "Juggle" }, { fire, "Fire" }, { water, "Water" }, + { firepal, "PaletteFire" }, + { waterpal, "PaletteWater" }, { showSolidColor, "Solid Color" } }; @@ -1197,6 +1199,16 @@ void water() heatMap(IceColors_p, false); } +void firepal() +{ + heatMap(palettes[currentPaletteIndex], true); +} + +void waterpal() +{ + heatMap(palettes[currentPaletteIndex], false); +} + // Pride2015 by Mark Kriegsman: https://gist.github.com/kriegsman/964de772d64c502760e5 // This function draws rainbows with an ever-changing, // widely-varying set of parameters. From 60f63772a007ba82651d2f33cfb63b3c89271196 Mon Sep 17 00:00:00 2001 From: HACKER3000 Date: Mon, 13 Dec 2021 16:24:02 +0100 Subject: [PATCH 04/21] oops --- GradientPalettes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GradientPalettes.h b/GradientPalettes.h index 5f6400b0..8d5ba1d9 100644 --- a/GradientPalettes.h +++ b/GradientPalettes.h @@ -12,7 +12,7 @@ DEFINE_GRADIENT_PALETTE( ib_jul01_gp ) { 0, 194, 1, 1, - 941, 29, 18, + 194, 29, 18, 132, 57, 131, 28, 255, 113, 1, 1 }; From d84ac6d87e0792c8b16197d67467fcb0a5cdee0a Mon Sep 17 00:00:00 2001 From: HACKER3000 Date: Mon, 13 Dec 2021 16:27:38 +0100 Subject: [PATCH 05/21] back to default configuration --- esp8266-fastled-webserver.ino | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/esp8266-fastled-webserver.ino b/esp8266-fastled-webserver.ino index 30d1f6ea..c47271d8 100644 --- a/esp8266-fastled-webserver.ino +++ b/esp8266-fastled-webserver.ino @@ -64,7 +64,7 @@ ESP8266HTTPUpdateServer httpUpdateServer; #define COLOR_ORDER GRB #define NUM_LEDS 30 -#define MILLI_AMPS 8000 // IMPORTANT: set the max milli-Amps of your power supply (4A = 4000mA) +#define MILLI_AMPS 2000 // IMPORTANT: set the max milli-Amps of your power supply (4A = 4000mA) #define FRAMES_PER_SECOND 120 // here you can control the speed. With the Access Point / Web Server the animations run a bit slower. String nameString; @@ -313,7 +313,7 @@ void setup() { FastLED.setBrightness(brightness); - irReceiver.enableIRIn(); // Start the receiver + //irReceiver.enableIRIn(); // Start the receiver Serial.println(); Serial.print( F("Heap: ") ); Serial.println(system_get_free_heap_size()); @@ -528,9 +528,9 @@ void setup() { webServer.begin(); Serial.println("HTTP web server started"); - webSocketsServer.begin(); - webSocketsServer.onEvent(webSocketEvent); - Serial.println("Web socket server started"); + //webSocketsServer.begin(); + //webSocketsServer.onEvent(webSocketEvent); + //Serial.println("Web socket server started"); autoPlayTimeout = millis() + (autoplayDuration * 1000); From 4e5e010459bc0f724ac2ffd95504a457c5ee0b16 Mon Sep 17 00:00:00 2001 From: HACKER3000 Date: Mon, 13 Dec 2021 16:39:35 +0100 Subject: [PATCH 06/21] fixed formatting --- GradientPalettes.h | 418 +++++++++++++++++++++------------------------ 1 file changed, 193 insertions(+), 225 deletions(-) diff --git a/GradientPalettes.h b/GradientPalettes.h index 8d5ba1d9..a7192c95 100644 --- a/GradientPalettes.h +++ b/GradientPalettes.h @@ -11,11 +11,10 @@ // Size: 16 bytes of program space. DEFINE_GRADIENT_PALETTE( ib_jul01_gp ) { - 0, 194, 1, 1, - 194, 29, 18, - 132, 57, 131, 28, - 255, 113, 1, 1 -}; + 0, 194, 1, 1, + 94, 1, 29, 18, + 132, 57,131, 28, + 255, 113, 1, 1}; // Gradient palette "es_vintage_57_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/vintage/tn/es_vintage_57.png.index.html @@ -23,12 +22,11 @@ DEFINE_GRADIENT_PALETTE( ib_jul01_gp ) { // Size: 20 bytes of program space. DEFINE_GRADIENT_PALETTE( es_vintage_57_gp ) { - 0, 2, 1, 1, - 53, 18, 1, 0, + 0, 2, 1, 1, + 53, 18, 1, 0, 104, 69, 29, 1, - 153, 167, 135, 10, - 255, 46, 56, 4 -}; + 153, 167,135, 10, + 255, 46, 56, 4}; // Gradient palette "es_vintage_01_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/vintage/tn/es_vintage_01.png.index.html @@ -36,15 +34,14 @@ DEFINE_GRADIENT_PALETTE( es_vintage_57_gp ) { // Size: 32 bytes of program space. DEFINE_GRADIENT_PALETTE( es_vintage_01_gp ) { - 0, 4, 1, 1, - 51, 16, 0, 1, - 76, 97, 104, 3, - 101, 255, 131, 19, + 0, 4, 1, 1, + 51, 16, 0, 1, + 76, 97,104, 3, + 101, 255,131, 19, 127, 67, 9, 4, 153, 16, 0, 1, 229, 4, 1, 1, - 255, 4, 1, 1 -}; + 255, 4, 1, 1}; // Gradient palette "es_rivendell_15_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/rivendell/tn/es_rivendell_15.png.index.html @@ -52,12 +49,11 @@ DEFINE_GRADIENT_PALETTE( es_vintage_01_gp ) { // Size: 20 bytes of program space. DEFINE_GRADIENT_PALETTE( es_rivendell_15_gp ) { - 0, 1, 14, 5, + 0, 1, 14, 5, 101, 16, 36, 14, 165, 56, 68, 30, - 242, 150, 156, 99, - 255, 150, 156, 99 -}; + 242, 150,156, 99, + 255, 150,156, 99}; // Gradient palette "rgi_15_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/ds/rgi/tn/rgi_15.png.index.html @@ -65,16 +61,15 @@ DEFINE_GRADIENT_PALETTE( es_rivendell_15_gp ) { // Size: 36 bytes of program space. DEFINE_GRADIENT_PALETTE( rgi_15_gp ) { - 0, 4, 1, 31, - 31, 55, 1, 16, - 63, 197, 3, 7, - 95, 59, 2, 17, + 0, 4, 1, 31, + 31, 55, 1, 16, + 63, 197, 3, 7, + 95, 59, 2, 17, 127, 6, 2, 34, 159, 39, 6, 33, 191, 112, 13, 32, 223, 56, 9, 35, - 255, 22, 6, 38 -}; + 255, 22, 6, 38}; // Gradient palette "retro2_16_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/ma/retro2/tn/retro2_16.png.index.html @@ -82,9 +77,8 @@ DEFINE_GRADIENT_PALETTE( rgi_15_gp ) { // Size: 8 bytes of program space. DEFINE_GRADIENT_PALETTE( retro2_16_gp ) { - 0, 188, 135, 1, - 255, 46, 7, 1 -}; + 0, 188,135, 1, + 255, 46, 7, 1}; // Gradient palette "Analogous_1_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/red/tn/Analogous_1.png.index.html @@ -92,12 +86,11 @@ DEFINE_GRADIENT_PALETTE( retro2_16_gp ) { // Size: 20 bytes of program space. DEFINE_GRADIENT_PALETTE( Analogous_1_gp ) { - 0, 3, 0, 255, - 63, 23, 0, 255, - 127, 67, 0, 255, + 0, 3, 0,255, + 63, 23, 0,255, + 127, 67, 0,255, 191, 142, 0, 45, - 255, 255, 0, 0 -}; + 255, 255, 0, 0}; // Gradient palette "es_pinksplash_08_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/pink_splash/tn/es_pinksplash_08.png.index.html @@ -105,12 +98,11 @@ DEFINE_GRADIENT_PALETTE( Analogous_1_gp ) { // Size: 20 bytes of program space. DEFINE_GRADIENT_PALETTE( es_pinksplash_08_gp ) { - 0, 126, 11, 255, + 0, 126, 11,255, 127, 197, 1, 22, - 175, 210, 157, 172, - 221, 157, 3, 112, - 255, 157, 3, 112 -}; + 175, 210,157,172, + 221, 157, 3,112, + 255, 157, 3,112}; // Gradient palette "es_pinksplash_07_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/pink_splash/tn/es_pinksplash_07.png.index.html @@ -118,14 +110,13 @@ DEFINE_GRADIENT_PALETTE( es_pinksplash_08_gp ) { // Size: 28 bytes of program space. DEFINE_GRADIENT_PALETTE( es_pinksplash_07_gp ) { - 0, 229, 1, 1, - 61, 242, 4, 63, - 101, 255, 12, 255, - 127, 249, 81, 252, - 153, 255, 11, 235, + 0, 229, 1, 1, + 61, 242, 4, 63, + 101, 255, 12,255, + 127, 249, 81,252, + 153, 255, 11,235, 193, 244, 5, 68, - 255, 232, 1, 5 -}; + 255, 232, 1, 5}; // Gradient palette "Coral_reef_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/other/tn/Coral_reef.png.index.html @@ -133,13 +124,12 @@ DEFINE_GRADIENT_PALETTE( es_pinksplash_07_gp ) { // Size: 24 bytes of program space. DEFINE_GRADIENT_PALETTE( Coral_reef_gp ) { - 0, 40, 199, 197, - 50, 10, 152, 155, - 96, 1, 111, 120, - 96, 43, 127, 162, - 139, 10, 73, 111, - 255, 1, 34, 71 -}; + 0, 40,199,197, + 50, 10,152,155, + 96, 1,111,120, + 96, 43,127,162, + 139, 10, 73,111, + 255, 1, 34, 71}; // Gradient palette "es_ocean_breeze_068_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/ocean_breeze/tn/es_ocean_breeze_068.png.index.html @@ -147,13 +137,12 @@ DEFINE_GRADIENT_PALETTE( Coral_reef_gp ) { // Size: 24 bytes of program space. DEFINE_GRADIENT_PALETTE( es_ocean_breeze_068_gp ) { - 0, 100, 156, 153, - 51, 1, 99, 137, + 0, 100,156,153, + 51, 1, 99,137, 101, 1, 68, 84, - 104, 35, 142, 168, - 178, 0, 63, 117, - 255, 1, 10, 10 -}; + 104, 35,142,168, + 178, 0, 63,117, + 255, 1, 10, 10}; // Gradient palette "es_ocean_breeze_036_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/ocean_breeze/tn/es_ocean_breeze_036.png.index.html @@ -161,11 +150,10 @@ DEFINE_GRADIENT_PALETTE( es_ocean_breeze_068_gp ) { // Size: 16 bytes of program space. DEFINE_GRADIENT_PALETTE( es_ocean_breeze_036_gp ) { - 0, 1, 6, 7, - 89, 1, 99, 111, - 153, 144, 209, 255, - 255, 0, 73, 82 -}; + 0, 1, 6, 7, + 89, 1, 99,111, + 153, 144,209,255, + 255, 0, 73, 82}; // Gradient palette "departure_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/mjf/tn/departure.png.index.html @@ -173,19 +161,18 @@ DEFINE_GRADIENT_PALETTE( es_ocean_breeze_036_gp ) { // Size: 88 bytes of program space. DEFINE_GRADIENT_PALETTE( departure_gp ) { - 0, 8, 3, 0, - 42, 23, 7, 0, - 63, 75, 38, 6, - 84, 169, 99, 38, - 106, 213, 169, 119, - 116, 255, 255, 255, - 138, 135, 255, 138, - 148, 22, 255, 24, - 170, 0, 255, 0, - 191, 0, 136, 0, + 0, 8, 3, 0, + 42, 23, 7, 0, + 63, 75, 38, 6, + 84, 169, 99, 38, + 106, 213,169,119, + 116, 255,255,255, + 138, 135,255,138, + 148, 22,255, 24, + 170, 0,255, 0, + 191, 0,136, 0, 212, 0, 55, 0, - 255, 0, 55, 0 -}; + 255, 0, 55, 0}; // Gradient palette "es_landscape_64_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/landscape/tn/es_landscape_64.png.index.html @@ -193,16 +180,15 @@ DEFINE_GRADIENT_PALETTE( departure_gp ) { // Size: 36 bytes of program space. DEFINE_GRADIENT_PALETTE( es_landscape_64_gp ) { - 0, 0, 0, 0, - 37, 2, 25, 1, - 76, 15, 115, 5, - 127, 79, 213, 1, - 128, 126, 211, 47, - 130, 188, 209, 247, - 153, 144, 182, 205, - 204, 59, 117, 250, - 255, 1, 37, 192 -}; + 0, 0, 0, 0, + 37, 2, 25, 1, + 76, 15,115, 5, + 127, 79,213, 1, + 128, 126,211, 47, + 130, 188,209,247, + 153, 144,182,205, + 204, 59,117,250, + 255, 1, 37,192}; // Gradient palette "es_landscape_33_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/landscape/tn/es_landscape_33.png.index.html @@ -210,13 +196,12 @@ DEFINE_GRADIENT_PALETTE( es_landscape_64_gp ) { // Size: 24 bytes of program space. DEFINE_GRADIENT_PALETTE( es_landscape_33_gp ) { - 0, 1, 5, 0, - 19, 32, 23, 1, - 38, 161, 55, 1, - 63, 229, 144, 1, - 66, 39, 142, 74, - 255, 1, 4, 1 -}; + 0, 1, 5, 0, + 19, 32, 23, 1, + 38, 161, 55, 1, + 63, 229,144, 1, + 66, 39,142, 74, + 255, 1, 4, 1}; // Gradient palette "rainbowsherbet_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/ma/icecream/tn/rainbowsherbet.png.index.html @@ -224,14 +209,13 @@ DEFINE_GRADIENT_PALETTE( es_landscape_33_gp ) { // Size: 28 bytes of program space. DEFINE_GRADIENT_PALETTE( rainbowsherbet_gp ) { - 0, 255, 33, 4, - 43, 255, 68, 25, - 86, 255, 7, 25, - 127, 255, 82, 103, - 170, 255, 255, 242, - 209, 42, 255, 22, - 255, 87, 255, 65 -}; + 0, 255, 33, 4, + 43, 255, 68, 25, + 86, 255, 7, 25, + 127, 255, 82,103, + 170, 255,255,242, + 209, 42,255, 22, + 255, 87,255, 65}; // Gradient palette "gr65_hult_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/hult/tn/gr65_hult.png.index.html @@ -239,13 +223,12 @@ DEFINE_GRADIENT_PALETTE( rainbowsherbet_gp ) { // Size: 24 bytes of program space. DEFINE_GRADIENT_PALETTE( gr65_hult_gp ) { - 0, 247, 176, 247, - 48, 255, 136, 255, - 89, 220, 29, 226, - 160, 7, 82, 178, - 216, 1, 124, 109, - 255, 1, 124, 109 -}; + 0, 247,176,247, + 48, 255,136,255, + 89, 220, 29,226, + 160, 7, 82,178, + 216, 1,124,109, + 255, 1,124,109}; // Gradient palette "gr64_hult_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/hult/tn/gr64_hult.png.index.html @@ -253,15 +236,14 @@ DEFINE_GRADIENT_PALETTE( gr65_hult_gp ) { // Size: 32 bytes of program space. DEFINE_GRADIENT_PALETTE( gr64_hult_gp ) { - 0, 1, 124, 109, - 66, 1, 93, 79, + 0, 1,124,109, + 66, 1, 93, 79, 104, 52, 65, 1, - 130, 115, 127, 1, + 130, 115,127, 1, 150, 52, 65, 1, 201, 1, 86, 72, 239, 0, 55, 45, - 255, 0, 55, 45 -}; + 255, 0, 55, 45}; // Gradient palette "GMT_drywet_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/gmt/tn/GMT_drywet.png.index.html @@ -269,14 +251,13 @@ DEFINE_GRADIENT_PALETTE( gr64_hult_gp ) { // Size: 28 bytes of program space. DEFINE_GRADIENT_PALETTE( GMT_drywet_gp ) { - 0, 47, 30, 2, - 42, 213, 147, 24, - 84, 103, 219, 52, - 127, 3, 219, 207, - 170, 1, 48, 214, - 212, 1, 1, 111, - 255, 1, 7, 33 -}; + 0, 47, 30, 2, + 42, 213,147, 24, + 84, 103,219, 52, + 127, 3,219,207, + 170, 1, 48,214, + 212, 1, 1,111, + 255, 1, 7, 33}; // Gradient palette "ib15_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/ing/general/tn/ib15.png.index.html @@ -284,13 +265,12 @@ DEFINE_GRADIENT_PALETTE( GMT_drywet_gp ) { // Size: 24 bytes of program space. DEFINE_GRADIENT_PALETTE( ib15_gp ) { - 0, 113, 91, 147, - 72, 157, 88, 78, - 89, 208, 85, 33, + 0, 113, 91,147, + 72, 157, 88, 78, + 89, 208, 85, 33, 107, 255, 29, 11, 141, 137, 31, 39, - 255, 59, 33, 89 -}; + 255, 59, 33, 89}; // Gradient palette "Fuschia_7_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/ds/fuschia/tn/Fuschia-7.png.index.html @@ -298,12 +278,11 @@ DEFINE_GRADIENT_PALETTE( ib15_gp ) { // Size: 20 bytes of program space. DEFINE_GRADIENT_PALETTE( Fuschia_7_gp ) { - 0, 43, 3, 153, - 63, 100, 4, 103, + 0, 43, 3,153, + 63, 100, 4,103, 127, 188, 5, 66, - 191, 161, 11, 115, - 255, 135, 20, 182 -}; + 191, 161, 11,115, + 255, 135, 20,182}; // Gradient palette "es_emerald_dragon_08_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/emerald_dragon/tn/es_emerald_dragon_08.png.index.html @@ -311,11 +290,10 @@ DEFINE_GRADIENT_PALETTE( Fuschia_7_gp ) { // Size: 16 bytes of program space. DEFINE_GRADIENT_PALETTE( es_emerald_dragon_08_gp ) { - 0, 97, 255, 1, - 101, 47, 133, 1, + 0, 97,255, 1, + 101, 47,133, 1, 178, 13, 43, 1, - 255, 2, 10, 1 -}; + 255, 2, 10, 1}; // Gradient palette "lava_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/neota/elem/tn/lava.png.index.html @@ -323,20 +301,19 @@ DEFINE_GRADIENT_PALETTE( es_emerald_dragon_08_gp ) { // Size: 52 bytes of program space. DEFINE_GRADIENT_PALETTE( lava_gp ) { - 0, 0, 0, 0, - 46, 18, 0, 0, - 96, 113, 0, 0, + 0, 0, 0, 0, + 46, 18, 0, 0, + 96, 113, 0, 0, 108, 142, 3, 1, 119, 175, 17, 1, 146, 213, 44, 2, 174, 255, 82, 4, - 188, 255, 115, 4, - 202, 255, 156, 4, - 218, 255, 203, 4, - 234, 255, 255, 4, - 244, 255, 255, 71, - 255, 255, 255, 255 -}; + 188, 255,115, 4, + 202, 255,156, 4, + 218, 255,203, 4, + 234, 255,255, 4, + 244, 255,255, 71, + 255, 255,255,255}; // Gradient palette "fire_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/neota/elem/tn/fire.png.index.html @@ -344,14 +321,13 @@ DEFINE_GRADIENT_PALETTE( lava_gp ) { // Size: 28 bytes of program space. DEFINE_GRADIENT_PALETTE( fire_gp ) { - 0, 1, 1, 0, - 76, 32, 5, 0, + 0, 1, 1, 0, + 76, 32, 5, 0, 146, 192, 24, 0, - 197, 220, 105, 5, - 240, 252, 255, 31, - 250, 252, 255, 111, - 255, 255, 255, 255 -}; + 197, 220,105, 5, + 240, 252,255, 31, + 250, 252,255,111, + 255, 255,255,255}; // Gradient palette "Colorfull_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/atmospheric/tn/Colorfull.png.index.html @@ -359,18 +335,17 @@ DEFINE_GRADIENT_PALETTE( fire_gp ) { // Size: 44 bytes of program space. DEFINE_GRADIENT_PALETTE( Colorfull_gp ) { - 0, 10, 85, 5, - 25, 29, 109, 18, - 60, 59, 138, 42, - 93, 83, 99, 52, + 0, 10, 85, 5, + 25, 29,109, 18, + 60, 59,138, 42, + 93, 83, 99, 52, 106, 110, 66, 64, 109, 123, 49, 65, 113, 139, 35, 66, - 116, 192, 117, 98, - 124, 255, 255, 137, - 168, 100, 180, 155, - 255, 22, 121, 174 -}; + 116, 192,117, 98, + 124, 255,255,137, + 168, 100,180,155, + 255, 22,121,174}; // Gradient palette "Magenta_Evening_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/atmospheric/tn/Magenta_Evening.png.index.html @@ -378,14 +353,13 @@ DEFINE_GRADIENT_PALETTE( Colorfull_gp ) { // Size: 28 bytes of program space. DEFINE_GRADIENT_PALETTE( Magenta_Evening_gp ) { - 0, 71, 27, 39, - 31, 130, 11, 51, - 63, 213, 2, 64, - 70, 232, 1, 66, - 76, 252, 1, 69, + 0, 71, 27, 39, + 31, 130, 11, 51, + 63, 213, 2, 64, + 70, 232, 1, 66, + 76, 252, 1, 69, 108, 123, 2, 51, - 255, 46, 9, 35 -}; + 255, 46, 9, 35}; // Gradient palette "Pink_Purple_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/atmospheric/tn/Pink_Purple.png.index.html @@ -393,18 +367,17 @@ DEFINE_GRADIENT_PALETTE( Magenta_Evening_gp ) { // Size: 44 bytes of program space. DEFINE_GRADIENT_PALETTE( Pink_Purple_gp ) { - 0, 19, 2, 39, - 25, 26, 4, 45, - 51, 33, 6, 52, - 76, 68, 62, 125, - 102, 118, 187, 240, - 109, 163, 215, 247, - 114, 217, 244, 255, - 122, 159, 149, 221, - 149, 113, 78, 188, - 183, 128, 57, 155, - 255, 146, 40, 123 -}; + 0, 19, 2, 39, + 25, 26, 4, 45, + 51, 33, 6, 52, + 76, 68, 62,125, + 102, 118,187,240, + 109, 163,215,247, + 114, 217,244,255, + 122, 159,149,221, + 149, 113, 78,188, + 183, 128, 57,155, + 255, 146, 40,123}; // Gradient palette "Sunset_Real_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/atmospheric/tn/Sunset_Real.png.index.html @@ -412,14 +385,13 @@ DEFINE_GRADIENT_PALETTE( Pink_Purple_gp ) { // Size: 28 bytes of program space. DEFINE_GRADIENT_PALETTE( Sunset_Real_gp ) { - 0, 120, 0, 0, - 22, 179, 22, 0, - 51, 255, 104, 0, - 85, 167, 22, 18, - 135, 100, 0, 103, - 198, 16, 0, 130, - 255, 0, 0, 160 -}; + 0, 120, 0, 0, + 22, 179, 22, 0, + 51, 255,104, 0, + 85, 167, 22, 18, + 135, 100, 0,103, + 198, 16, 0,130, + 255, 0, 0,160}; // Gradient palette "es_autumn_19_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/autumn/tn/es_autumn_19.png.index.html @@ -427,20 +399,19 @@ DEFINE_GRADIENT_PALETTE( Sunset_Real_gp ) { // Size: 52 bytes of program space. DEFINE_GRADIENT_PALETTE( es_autumn_19_gp ) { - 0, 26, 1, 1, - 51, 67, 4, 1, - 84, 118, 14, 1, - 104, 137, 152, 52, + 0, 26, 1, 1, + 51, 67, 4, 1, + 84, 118, 14, 1, + 104, 137,152, 52, 112, 113, 65, 1, - 122, 133, 149, 59, - 124, 137, 152, 52, + 122, 133,149, 59, + 124, 137,152, 52, 135, 113, 65, 1, - 142, 139, 154, 46, + 142, 139,154, 46, 163, 113, 13, 1, 204, 55, 3, 1, 249, 17, 1, 1, - 255, 17, 1, 1 -}; + 255, 17, 1, 1}; // Gradient palette "BlacK_Blue_Magenta_White_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/basic/tn/BlacK_Blue_Magenta_White.png.index.html @@ -448,14 +419,13 @@ DEFINE_GRADIENT_PALETTE( es_autumn_19_gp ) { // Size: 28 bytes of program space. DEFINE_GRADIENT_PALETTE( BlacK_Blue_Magenta_White_gp ) { - 0, 0, 0, 0, - 42, 0, 0, 45, - 84, 0, 0, 255, - 127, 42, 0, 255, - 170, 255, 0, 255, - 212, 255, 55, 255, - 255, 255, 255, 255 -}; + 0, 0, 0, 0, + 42, 0, 0, 45, + 84, 0, 0,255, + 127, 42, 0,255, + 170, 255, 0,255, + 212, 255, 55,255, + 255, 255,255,255}; // Gradient palette "BlacK_Magenta_Red_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/basic/tn/BlacK_Magenta_Red.png.index.html @@ -463,12 +433,11 @@ DEFINE_GRADIENT_PALETTE( BlacK_Blue_Magenta_White_gp ) { // Size: 20 bytes of program space. DEFINE_GRADIENT_PALETTE( BlacK_Magenta_Red_gp ) { - 0, 0, 0, 0, - 63, 42, 0, 45, - 127, 255, 0, 255, + 0, 0, 0, 0, + 63, 42, 0, 45, + 127, 255, 0,255, 191, 255, 0, 45, - 255, 255, 0, 0 -}; + 255, 255, 0, 0}; // Gradient palette "BlacK_Red_Magenta_Yellow_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/basic/tn/BlacK_Red_Magenta_Yellow.png.index.html @@ -476,14 +445,13 @@ DEFINE_GRADIENT_PALETTE( BlacK_Magenta_Red_gp ) { // Size: 28 bytes of program space. DEFINE_GRADIENT_PALETTE( BlacK_Red_Magenta_Yellow_gp ) { - 0, 0, 0, 0, - 42, 42, 0, 0, - 84, 255, 0, 0, + 0, 0, 0, 0, + 42, 42, 0, 0, + 84, 255, 0, 0, 127, 255, 0, 45, - 170, 255, 0, 255, + 170, 255, 0,255, 212, 255, 55, 45, - 255, 255, 255, 0 -}; + 255, 255,255, 0}; // Gradient palette "Blue_Cyan_Yellow_gp", originally from // http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/basic/tn/Blue_Cyan_Yellow.png.index.html @@ -491,18 +459,17 @@ DEFINE_GRADIENT_PALETTE( BlacK_Red_Magenta_Yellow_gp ) { // Size: 20 bytes of program space. DEFINE_GRADIENT_PALETTE( Blue_Cyan_Yellow_gp ) { - 0, 0, 0, 255, - 63, 0, 55, 255, - 127, 0, 255, 255, - 191, 42, 255, 45, - 255, 255, 255, 0 -}; + 0, 0, 0,255, + 63, 0, 55,255, + 127, 0,255,255, + 191, 42,255, 45, + 255, 255,255, 0}; DEFINE_GRADIENT_PALETTE( Vapour ) { - 0, 111, 234, 230, - 64, 246, 163, 239, - 128, 80, 216, 236, + 0, 111, 234, 230, + 64, 246, 163, 239, + 128, 80, 216, 236, 192, 221, 109, 251, 255, 238, 205, 105 }; @@ -559,3 +526,4 @@ const TProgmemRGBGradientPalettePtr gGradientPalettes[] = { // Count of how many cpt-city gradients are defined: const uint8_t gGradientPaletteCount = sizeof( gGradientPalettes) / sizeof( TProgmemRGBGradientPalettePtr ); + From 3cbbb7e5a0923e2c4429191ea3cba29fed33697b Mon Sep 17 00:00:00 2001 From: HACKER3000 Date: Mon, 13 Dec 2021 16:42:45 +0100 Subject: [PATCH 07/21] ArduinoOTA enable/disable --- esp8266-fastled-webserver.ino | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/esp8266-fastled-webserver.ino b/esp8266-fastled-webserver.ino index c47271d8..c1afc690 100644 --- a/esp8266-fastled-webserver.ino +++ b/esp8266-fastled-webserver.ino @@ -67,6 +67,8 @@ ESP8266HTTPUpdateServer httpUpdateServer; #define MILLI_AMPS 2000 // IMPORTANT: set the max milli-Amps of your power supply (4A = 4000mA) #define FRAMES_PER_SECOND 120 // here you can control the speed. With the Access Point / Web Server the animations run a bit slower. +//#define OTA //Uncomment to enable ArduinoOTA + String nameString; #include "Ping.h" @@ -534,7 +536,10 @@ void setup() { autoPlayTimeout = millis() + (autoplayDuration * 1000); +#ifdef OTA ArduinoOTA.begin(); +#endif + } void sendInt(uint8_t value) @@ -631,8 +636,10 @@ void loop() { // insert a delay to keep the framerate modest FastLED.delay(1000 / FRAMES_PER_SECOND); - +#ifdef OTA ArduinoOTA.handle(); +#endif + } void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t length) { From 1e5b1f99a6f6a282bef5aba9a801695a6e6e99c7 Mon Sep 17 00:00:00 2001 From: HACKER3000 Date: Mon, 13 Dec 2021 16:45:26 +0100 Subject: [PATCH 08/21] commented out unfinished code --- esp8266-fastled-webserver.ino | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/esp8266-fastled-webserver.ino b/esp8266-fastled-webserver.ino index c1afc690..52d768a2 100644 --- a/esp8266-fastled-webserver.ino +++ b/esp8266-fastled-webserver.ino @@ -662,11 +662,13 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t length case WStype_TEXT: Serial.printf("[%u] get Text: %s\n", num, payload); + /* //send message to client - webSocketsServer.sendTXT(num, "message here"); + webSocketsServer.sendTXT(num, payload); //send data to all connected clients - webSocketsServer.broadcastTXT("message here"); + webSocketsServer.broadcastTXT(payload); + */ break; case WStype_BIN: From 60a24055c6dda755ae7b30f616392d0bfac60b35 Mon Sep 17 00:00:00 2001 From: HACKER3000 Date: Mon, 13 Dec 2021 16:46:24 +0100 Subject: [PATCH 09/21] Update GradientPalettes.h --- GradientPalettes.h | 1 + 1 file changed, 1 insertion(+) diff --git a/GradientPalettes.h b/GradientPalettes.h index a7192c95..32181140 100644 --- a/GradientPalettes.h +++ b/GradientPalettes.h @@ -527,3 +527,4 @@ const TProgmemRGBGradientPalettePtr gGradientPalettes[] = { const uint8_t gGradientPaletteCount = sizeof( gGradientPalettes) / sizeof( TProgmemRGBGradientPalettePtr ); + From 04a06263bc6dd834b23096d0c0a73379faa173fb Mon Sep 17 00:00:00 2001 From: HACKER3000 Date: Mon, 13 Dec 2021 16:58:28 +0100 Subject: [PATCH 10/21] more cleaning up --- esp8266-fastled-webserver.ino | 56 +++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/esp8266-fastled-webserver.ino b/esp8266-fastled-webserver.ino index 52d768a2..b2fc368b 100644 --- a/esp8266-fastled-webserver.ino +++ b/esp8266-fastled-webserver.ino @@ -32,37 +32,40 @@ extern "C" { #include #include #include -#include -#include +//#include +//#include #include #include -#include -#include -#include +//#include +//#include +//#include #include // https://github.com/tzapu/WiFiManager/tree/development -#include #include "GradientPalettes.h" +#ifdef OTA +#include +#endif + #define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0])) #include "Field.h" -#define RECV_PIN D7 -IRrecv irReceiver(RECV_PIN); +//#define RECV_PIN D7 +//IRrecv irReceiver(RECV_PIN); -#include "Commands.h" +//#include "Commands.h" WiFiManager wifiManager; ESP8266WebServer webServer(80); -WebSocketsServer webSocketsServer = WebSocketsServer(81); +//WebSocketsServer webSocketsServer = WebSocketsServer(81); ESP8266HTTPUpdateServer httpUpdateServer; #include "FSBrowser.h" -#define DATA_PIN D8 +#define DATA_PIN D5 #define LED_TYPE WS2811 -#define COLOR_ORDER GRB -#define NUM_LEDS 30 +#define COLOR_ORDER RGB +#define NUM_LEDS 200 #define MILLI_AMPS 2000 // IMPORTANT: set the max milli-Amps of your power supply (4A = 4000mA) #define FRAMES_PER_SECOND 120 // here you can control the speed. With the Access Point / Web Server the animations run a bit slower. @@ -152,7 +155,7 @@ PatternAndNameList patterns = { { colorWavesPlayground, "Color Waves Playground" }, // twinkle patterns - { twinkels, "Twinkels" }, + { twinkels, "Twinkles" }, { rainbowTwinkles, "Rainbow Twinkles" }, { snowTwinkles, "Snow Twinkles" }, { cloudTwinkles, "Cloud Twinkles" }, @@ -556,13 +559,13 @@ void sendString(String value) void broadcastInt(String name, uint8_t value) { String json = "{\"name\":\"" + name + "\",\"value\":" + String(value) + "}"; - webSocketsServer.broadcastTXT(json); + //webSocketsServer.broadcastTXT(json); } void broadcastString(String name, String value) { String json = "{\"name\":\"" + name + "\",\"value\":\"" + String(value) + "\"}"; - webSocketsServer.broadcastTXT(json); + //webSocketsServer.broadcastTXT(json); } void loop() { @@ -599,7 +602,7 @@ void loop() { checkPingTimer(); - handleIrInput(); + //handleIrInput(); if (power == 0) { fill_solid(leds, NUM_LEDS, CRGB::Black); @@ -608,9 +611,9 @@ void loop() { return; } - EVERY_N_SECONDS(10) { + /*EVERY_N_SECONDS(10) { Serial.print( F("Heap: ") ); Serial.println(system_get_free_heap_size()); - } + }*/ // change to a new cpt-city gradient palette EVERY_N_SECONDS( secondsPerPalette ) { @@ -642,7 +645,7 @@ void loop() { } -void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t length) { +/*void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t length) { switch (type) { case WStype_DISCONNECTED: @@ -662,13 +665,13 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t length case WStype_TEXT: Serial.printf("[%u] get Text: %s\n", num, payload); - /* + //send message to client - webSocketsServer.sendTXT(num, payload); + //webSocketsServer.sendTXT(num, payload); //send data to all connected clients - webSocketsServer.broadcastTXT(payload); - */ + //webSocketsServer.broadcastTXT(payload); + break; case WStype_BIN: @@ -679,8 +682,9 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t length webSocketsServer.sendBIN(num, payload, length); break; } -} +}*/ +/* void handleIrInput() { InputCommand command = readCommand(); @@ -880,7 +884,7 @@ void handleIrInput() break; } } -} +}*/ void loadSettings() { From 7c51222f0aa0523bd3cc9c6850c6d5c2fe3b92db Mon Sep 17 00:00:00 2001 From: Henry Gabryjelski Date: Mon, 13 Dec 2021 12:00:50 -0800 Subject: [PATCH 11/21] formatting fix --- esp8266-fastled-webserver/include/GradientPalettes.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esp8266-fastled-webserver/include/GradientPalettes.hpp b/esp8266-fastled-webserver/include/GradientPalettes.hpp index 10b32732..f3ded543 100644 --- a/esp8266-fastled-webserver/include/GradientPalettes.hpp +++ b/esp8266-fastled-webserver/include/GradientPalettes.hpp @@ -35,6 +35,6 @@ DECLARE_GRADIENT_PALETTE( BlacK_Blue_Magenta_White_gp ); DECLARE_GRADIENT_PALETTE( BlacK_Magenta_Red_gp ); DECLARE_GRADIENT_PALETTE( BlacK_Red_Magenta_Yellow_gp ); DECLARE_GRADIENT_PALETTE( Blue_Cyan_Yellow_gp ); -DECLARE_GRADIENT_PALETTE( Vapour_gp); +DECLARE_GRADIENT_PALETTE( Vapour_gp ); #endif From 40f03789aba3e7f2d872831a48537278b09dde8f Mon Sep 17 00:00:00 2001 From: Henry Gabryjelski Date: Mon, 13 Dec 2021 12:01:39 -0800 Subject: [PATCH 12/21] BUG -- Why using `{}` is critical... --- esp8266-fastled-webserver/commands.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/esp8266-fastled-webserver/commands.cpp b/esp8266-fastled-webserver/commands.cpp index a5b8a159..1330f0f5 100644 --- a/esp8266-fastled-webserver/commands.cpp +++ b/esp8266-fastled-webserver/commands.cpp @@ -198,8 +198,9 @@ unsigned long decodeIRCode() { if (irReceiver.decode(&results)) { delay(20); - if (results.value != 0) + if (results.value != 0) { //Serial.println(results.value); + } // Prepare to receive the next IR code irReceiver.resume(); From 092ec1837090fac285e92fcbaca0f8ec07c99fad Mon Sep 17 00:00:00 2001 From: Henry Gabryjelski Date: Mon, 13 Dec 2021 12:09:38 -0800 Subject: [PATCH 13/21] Avoid expansion of gradient palettes (~3k RAM) --- .../esp8266-fastled-webserver.ino | 83 ------------------- 1 file changed, 83 deletions(-) diff --git a/esp8266-fastled-webserver/esp8266-fastled-webserver.ino b/esp8266-fastled-webserver/esp8266-fastled-webserver.ino index e1cf9a65..88139bf5 100644 --- a/esp8266-fastled-webserver/esp8266-fastled-webserver.ino +++ b/esp8266-fastled-webserver/esp8266-fastled-webserver.ino @@ -254,47 +254,6 @@ const CRGBPalette16 palettes[] = { ForestColors_p, PartyColors_p, HeatColors_p, - Sunset_Real_gp, - es_rivendell_15_gp, - - es_ocean_breeze_036_gp, - rgi_15_gp, - retro2_16_gp, - Analogous_1_gp, - es_pinksplash_08_gp, - - Coral_reef_gp, - es_ocean_breeze_068_gp, - es_pinksplash_07_gp, - es_vintage_01_gp, - departure_gp, - - es_landscape_64_gp, - es_landscape_33_gp, - rainbowsherbet_gp, - gr65_hult_gp, - gr64_hult_gp, - - GMT_drywet_gp, - ib_jul01_gp, - es_vintage_57_gp, - ib15_gp, - Fuschia_7_gp, - - es_emerald_dragon_08_gp, - lava_gp, - fire_gp, - Colorfull_gp, - Magenta_Evening_gp, - - Pink_Purple_gp, - es_autumn_19_gp, - BlacK_Blue_Magenta_White_gp, - BlacK_Magenta_Red_gp, - BlacK_Red_Magenta_Yellow_gp, - - Blue_Cyan_Yellow_gp, - Vapour_gp, }; const uint8_t paletteCount = ARRAY_SIZE2(palettes); @@ -308,48 +267,6 @@ const String paletteNames[] = { "Forest", "Party", "Heat", - "Sunset Real gp", - "rivendell 15", - - "ocean breeze 036", - "rgi 15", - "retro2 16", - "Analogous 1", - "pinksplash 08", - - "Coral reef", - "ocean breeze 068", - "pinksplash 07", - "vintage 01", - "departure", - - "landscape 64", - "landscape 33", - "rainbowsherbet", - "gr65 hult", - "gr64 hult", - - "GMT drywet", - "ib jul01", - "vintage 57", - "ib15", - "Fuschia 7", - - "emerald dragon 08", - "lava", - "fire", - "Colorfull", - "Magenta Evening", - - "Pink Purple", - "autumn 19", - "BlacK Blue Magenta White", - "BlacK Magenta Red", - "BlacK Red Magenta Yellow", - - "Blue Cyan Yellow", - "Vapourwave", - }; const uint8_t paletteNameCount = ARRAY_SIZE2(paletteNames); static_assert(paletteCount == paletteNameCount, ""); From 71691805d2a35a698e8c7d45de889f2752863bd2 Mon Sep 17 00:00:00 2001 From: Henry Gabryjelski Date: Mon, 13 Dec 2021 12:17:45 -0800 Subject: [PATCH 14/21] Formatting changes only --- esp8266-fastled-webserver/commands.cpp | 406 ++++++++++++------------- 1 file changed, 203 insertions(+), 203 deletions(-) diff --git a/esp8266-fastled-webserver/commands.cpp b/esp8266-fastled-webserver/commands.cpp index 1330f0f5..2a96494b 100644 --- a/esp8266-fastled-webserver/commands.cpp +++ b/esp8266-fastled-webserver/commands.cpp @@ -484,209 +484,209 @@ InputCommand readCommand(unsigned int holdDelay) { void handleIrInput() { - InputCommand command = readCommand(); - - if (command != InputCommand::None) { - Serial.print("command: "); - Serial.println((int) command); - } - - switch (command) { - case InputCommand::Up: { - adjustPattern(true); - break; - } - case InputCommand::Down: { - adjustPattern(false); - break; - } - case InputCommand::Power: { - setPower(power == 0 ? 1 : 0); - break; - } - case InputCommand::BrightnessUp: { - adjustBrightness(true); - break; - } - case InputCommand::BrightnessDown: { - adjustBrightness(false); - break; - } - case InputCommand::PlayMode: { // toggle pause/play - setAutoplay(!autoplay); - break; - } - - // pattern buttons - - case InputCommand::Pattern1: { - setPattern(0); - break; - } - case InputCommand::Pattern2: { - setPattern(1); - break; - } - case InputCommand::Pattern3: { - setPattern(2); - break; - } - case InputCommand::Pattern4: { - setPattern(3); - break; - } - case InputCommand::Pattern5: { - setPattern(4); - break; - } - case InputCommand::Pattern6: { - setPattern(5); - break; - } - case InputCommand::Pattern7: { - setPattern(6); - break; - } - case InputCommand::Pattern8: { - setPattern(7); - break; - } - case InputCommand::Pattern9: { - setPattern(8); - break; - } - case InputCommand::Pattern10: { - setPattern(9); - break; - } - case InputCommand::Pattern11: { - setPattern(10); - break; - } - case InputCommand::Pattern12: { - setPattern(11); - break; - } - - // custom color adjustment buttons - - case InputCommand::RedUp: { - solidColor.red += 8; - setSolidColor(solidColor); - break; - } - case InputCommand::RedDown: { - solidColor.red -= 8; - setSolidColor(solidColor); - break; - } - case InputCommand::GreenUp: { - solidColor.green += 8; - setSolidColor(solidColor); - break; - } - case InputCommand::GreenDown: { - solidColor.green -= 8; - setSolidColor(solidColor); - break; - } - case InputCommand::BlueUp: { - solidColor.blue += 8; - setSolidColor(solidColor); - break; - } - case InputCommand::BlueDown: { - solidColor.blue -= 8; - setSolidColor(solidColor); - break; - } - - // color buttons - - case InputCommand::Red: { - setSolidColor(CRGB::Red); - break; - } - case InputCommand::RedOrange: { - setSolidColor(CRGB::OrangeRed); - break; - } - case InputCommand::Orange: { - setSolidColor(CRGB::Orange); - break; - } - case InputCommand::YellowOrange: { - setSolidColor(CRGB::Goldenrod); - break; - } - case InputCommand::Yellow: { - setSolidColor(CRGB::Yellow); - break; - } - - case InputCommand::Green: { - setSolidColor(CRGB::Green); - break; - } - case InputCommand::Lime: { - setSolidColor(CRGB::Lime); - break; - } - case InputCommand::Aqua: { - setSolidColor(CRGB::Aqua); - break; - } - case InputCommand::Teal: { - setSolidColor(CRGB::Teal); - break; - } - case InputCommand::Navy: { - setSolidColor(CRGB::Navy); - break; - } - - case InputCommand::Blue: { - setSolidColor(CRGB::Blue); - break; - } - case InputCommand::RoyalBlue: { - setSolidColor(CRGB::RoyalBlue); - break; - } - case InputCommand::Purple: { - setSolidColor(CRGB::Purple); - break; - } - case InputCommand::Indigo: { - setSolidColor(CRGB::Indigo); - break; - } - case InputCommand::Magenta: { - setSolidColor(CRGB::Magenta); - break; - } - - case InputCommand::White: { - setSolidColor(CRGB::White); - break; - } - case InputCommand::Pink: { - setSolidColor(CRGB::Pink); - break; - } - case InputCommand::LightPink: { - setSolidColor(CRGB::LightPink); - break; - } - case InputCommand::BabyBlue: { - setSolidColor(CRGB::CornflowerBlue); - break; - } - case InputCommand::LightBlue: { - setSolidColor(CRGB::LightBlue); - break; - } - } + InputCommand command = readCommand(); + + if (command != InputCommand::None) { + Serial.print("command: "); + Serial.println((int) command); + } + + switch (command) { + case InputCommand::Up: { + adjustPattern(true); + break; + } + case InputCommand::Down: { + adjustPattern(false); + break; + } + case InputCommand::Power: { + setPower(power == 0 ? 1 : 0); + break; + } + case InputCommand::BrightnessUp: { + adjustBrightness(true); + break; + } + case InputCommand::BrightnessDown: { + adjustBrightness(false); + break; + } + case InputCommand::PlayMode: { // toggle pause/play + setAutoplay(!autoplay); + break; + } + + // pattern buttons + + case InputCommand::Pattern1: { + setPattern(0); + break; + } + case InputCommand::Pattern2: { + setPattern(1); + break; + } + case InputCommand::Pattern3: { + setPattern(2); + break; + } + case InputCommand::Pattern4: { + setPattern(3); + break; + } + case InputCommand::Pattern5: { + setPattern(4); + break; + } + case InputCommand::Pattern6: { + setPattern(5); + break; + } + case InputCommand::Pattern7: { + setPattern(6); + break; + } + case InputCommand::Pattern8: { + setPattern(7); + break; + } + case InputCommand::Pattern9: { + setPattern(8); + break; + } + case InputCommand::Pattern10: { + setPattern(9); + break; + } + case InputCommand::Pattern11: { + setPattern(10); + break; + } + case InputCommand::Pattern12: { + setPattern(11); + break; + } + + // custom color adjustment buttons + + case InputCommand::RedUp: { + solidColor.red += 8; + setSolidColor(solidColor); + break; + } + case InputCommand::RedDown: { + solidColor.red -= 8; + setSolidColor(solidColor); + break; + } + case InputCommand::GreenUp: { + solidColor.green += 8; + setSolidColor(solidColor); + break; + } + case InputCommand::GreenDown: { + solidColor.green -= 8; + setSolidColor(solidColor); + break; + } + case InputCommand::BlueUp: { + solidColor.blue += 8; + setSolidColor(solidColor); + break; + } + case InputCommand::BlueDown: { + solidColor.blue -= 8; + setSolidColor(solidColor); + break; + } + + // color buttons + + case InputCommand::Red: { + setSolidColor(CRGB::Red); + break; + } + case InputCommand::RedOrange: { + setSolidColor(CRGB::OrangeRed); + break; + } + case InputCommand::Orange: { + setSolidColor(CRGB::Orange); + break; + } + case InputCommand::YellowOrange: { + setSolidColor(CRGB::Goldenrod); + break; + } + case InputCommand::Yellow: { + setSolidColor(CRGB::Yellow); + break; + } + + case InputCommand::Green: { + setSolidColor(CRGB::Green); + break; + } + case InputCommand::Lime: { + setSolidColor(CRGB::Lime); + break; + } + case InputCommand::Aqua: { + setSolidColor(CRGB::Aqua); + break; + } + case InputCommand::Teal: { + setSolidColor(CRGB::Teal); + break; + } + case InputCommand::Navy: { + setSolidColor(CRGB::Navy); + break; + } + + case InputCommand::Blue: { + setSolidColor(CRGB::Blue); + break; + } + case InputCommand::RoyalBlue: { + setSolidColor(CRGB::RoyalBlue); + break; + } + case InputCommand::Purple: { + setSolidColor(CRGB::Purple); + break; + } + case InputCommand::Indigo: { + setSolidColor(CRGB::Indigo); + break; + } + case InputCommand::Magenta: { + setSolidColor(CRGB::Magenta); + break; + } + + case InputCommand::White: { + setSolidColor(CRGB::White); + break; + } + case InputCommand::Pink: { + setSolidColor(CRGB::Pink); + break; + } + case InputCommand::LightPink: { + setSolidColor(CRGB::LightPink); + break; + } + case InputCommand::BabyBlue: { + setSolidColor(CRGB::CornflowerBlue); + break; + } + case InputCommand::LightBlue: { + setSolidColor(CRGB::LightBlue); + break; + } + } } #endif From 93552236e67367f5151585d77239905953f0b58d Mon Sep 17 00:00:00 2001 From: Henry Gabryjelski Date: Mon, 13 Dec 2021 12:19:33 -0800 Subject: [PATCH 15/21] IR handling code already in commands.cpp --- .../esp8266-fastled-webserver.ino | 211 +----------------- 1 file changed, 3 insertions(+), 208 deletions(-) diff --git a/esp8266-fastled-webserver/esp8266-fastled-webserver.ino b/esp8266-fastled-webserver/esp8266-fastled-webserver.ino index 88139bf5..614e85da 100644 --- a/esp8266-fastled-webserver/esp8266-fastled-webserver.ino +++ b/esp8266-fastled-webserver/esp8266-fastled-webserver.ino @@ -725,9 +725,9 @@ void loop() { return; } - /*EVERY_N_SECONDS(10) { - Serial.print( F("Heap: ") ); Serial.println(system_get_free_heap_size()); - }*/ + // EVERY_N_SECONDS(10) { + // Serial.print( F("Heap: ") ); Serial.println(system_get_free_heap_size()); + // } // change to a new cpt-city gradient palette EVERY_N_SECONDS( secondsPerPalette ) { @@ -802,211 +802,6 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t length } */ -/* TODO -- Move IR support to separate file -#if defined(ENABLE_IR) -void handleIrInput() -{ - InputCommand command = readCommand(); - - if (command != InputCommand::None) { - Serial.print("command: "); - Serial.println((int) command); - } - - switch (command) { - case InputCommand::Up: { - adjustPattern(true); - break; - } - case InputCommand::Down: { - adjustPattern(false); - break; - } - case InputCommand::Power: { - setPower(power == 0 ? 1 : 0); - break; - } - case InputCommand::BrightnessUp: { - adjustBrightness(true); - break; - } - case InputCommand::BrightnessDown: { - adjustBrightness(false); - break; - } - case InputCommand::PlayMode: { - setAutoplay(!autoplay); - break; - } - - case InputCommand::Pattern1: { - setPattern(0); - break; - } - case InputCommand::Pattern2: { - setPattern(1); - break; - } - case InputCommand::Pattern3: { - setPattern(2); - break; - } - case InputCommand::Pattern4: { - setPattern(3); - break; - } - case InputCommand::Pattern5: { - setPattern(4); - break; - } - case InputCommand::Pattern6: { - setPattern(5); - break; - } - case InputCommand::Pattern7: { - setPattern(6); - break; - } - case InputCommand::Pattern8: { - setPattern(7); - break; - } - case InputCommand::Pattern9: { - setPattern(8); - break; - } - case InputCommand::Pattern10: { - setPattern(9); - break; - } - case InputCommand::Pattern11: { - setPattern(10); - break; - } - case InputCommand::Pattern12: { - setPattern(11); - break; - } - - case InputCommand::RedUp: { - solidColor.red += 8; - setSolidColor(solidColor); - break; - } - case InputCommand::RedDown: { - solidColor.red -= 8; - setSolidColor(solidColor); - break; - } - case InputCommand::GreenUp: { - solidColor.green += 8; - setSolidColor(solidColor); - break; - } - case InputCommand::GreenDown: { - solidColor.green -= 8; - setSolidColor(solidColor); - break; - } - case InputCommand::BlueUp: { - solidColor.blue += 8; - setSolidColor(solidColor); - break; - } - case InputCommand::BlueDown: { - solidColor.blue -= 8; - setSolidColor(solidColor); - break; - } - - case InputCommand::Red: { - setSolidColor(CRGB::Red); - break; - } - case InputCommand::RedOrange: { - setSolidColor(CRGB::OrangeRed); - break; - } - case InputCommand::Orange: { - setSolidColor(CRGB::Orange); - break; - } - case InputCommand::YellowOrange: { - setSolidColor(CRGB::Goldenrod); - break; - } - case InputCommand::Yellow: { - setSolidColor(CRGB::Yellow); - break; - } - - case InputCommand::Green: { - setSolidColor(CRGB::Green); - break; - } - case InputCommand::Lime: { - setSolidColor(CRGB::Lime); - break; - } - case InputCommand::Aqua: { - setSolidColor(CRGB::Aqua); - break; - } - case InputCommand::Teal: { - setSolidColor(CRGB::Teal); - break; - } - case InputCommand::Navy: { - setSolidColor(CRGB::Navy); - break; - } - - case InputCommand::Blue: { - setSolidColor(CRGB::Blue); - break; - } - case InputCommand::RoyalBlue: { - setSolidColor(CRGB::RoyalBlue); - break; - } - case InputCommand::Purple: { - setSolidColor(CRGB::Purple); - break; - } - case InputCommand::Indigo: { - setSolidColor(CRGB::Indigo); - break; - } - case InputCommand::Magenta: { - setSolidColor(CRGB::Magenta); - break; - } - - case InputCommand::White: { - setSolidColor(CRGB::White); - break; - } - case InputCommand::Pink: { - setSolidColor(CRGB::Pink); - break; - } - case InputCommand::LightPink: { - setSolidColor(CRGB::LightPink); - break; - } - case InputCommand::BabyBlue: { - setSolidColor(CRGB::CornflowerBlue); - break; - } - case InputCommand::LightBlue: { - setSolidColor(CRGB::LightBlue); - break; - } - } -} -#endif // defined(ENABLE_IR) -*/ - // TODO: Save settings in file system, not EEPROM! const uint8_t SETTINGS_MAGIC_BYTE = 0x96; void readSettings() From a3baf6161418d16dc6686edf92fb0c4bba542801 Mon Sep 17 00:00:00 2001 From: Henry Gabryjelski Date: Mon, 13 Dec 2021 12:34:31 -0800 Subject: [PATCH 16/21] Websockets == development phase only --- esp8266-fastled-webserver/config.h | 11 ++++++ .../esp8266-fastled-webserver.ino | 37 ++++++++++++++----- platformio.ini | 2 +- 3 files changed, 39 insertions(+), 11 deletions(-) diff --git a/esp8266-fastled-webserver/config.h b/esp8266-fastled-webserver/config.h index a1527196..d94d58ae 100644 --- a/esp8266-fastled-webserver/config.h +++ b/esp8266-fastled-webserver/config.h @@ -177,6 +177,17 @@ #if ((ENABLE_ARDUINO_OTA != 0) && (ENABLE_ARDUINO_OTA != 1)) #error "ENABLE_ARDUINO_OTA must be undefined (defaults to 0), 0, or 1" #endif + #if !defined(ENABLE_WEBSOCKETS) + #define ENABLE_WEBSOCKETS 0 + #endif + #if ((ENABLE_WEBSOCKETS != 0) && (ENABLE_WEBSOCKETS != 1)) + #error "ENABLE_WEBSOCKETS must be undefined (defaults to 0), 0, or 1" + #endif + #if ENABLE_WEBSOCKETS + #warning "ENABLE_WEBSOCKETS is still in development, and is NOT supported" + #endif + + #endif diff --git a/esp8266-fastled-webserver/esp8266-fastled-webserver.ino b/esp8266-fastled-webserver/esp8266-fastled-webserver.ino index 614e85da..ac524741 100644 --- a/esp8266-fastled-webserver/esp8266-fastled-webserver.ino +++ b/esp8266-fastled-webserver/esp8266-fastled-webserver.ino @@ -20,7 +20,10 @@ WiFiManager wifiManager; ESP8266WebServer webServer(80); -//WebSocketsServer webSocketsServer = WebSocketsServer(81); + +#if ENABLE_WEBSOCKETS +WebSocketsServer webSocketsServer = WebSocketsServer(81); +#endif // ENABLE_WEBSOCKETS ESP8266HTTPUpdateServer httpUpdateServer; int utcOffsetInSeconds = -6 * 60 * 60; @@ -640,9 +643,11 @@ void setup() { webServer.begin(); Serial.println("HTTP web server started"); - //webSocketsServer.begin(); - //webSocketsServer.onEvent(webSocketEvent); - //Serial.println("Web socket server started"); +#if ENABLE_WEBSOCKETS + webSocketsServer.begin(); + webSocketsServer.onEvent(webSocketEvent); + Serial.println("Web socket server started"); +#endif // ENABLE_WEBSOCKETS autoPlayTimeout = millis() + (autoplayDuration * 1000); #if ENABLE_ARDUINO_OTA @@ -664,14 +669,24 @@ void sendString(String value) void broadcastInt(String name, uint8_t value) { +#if ENABLE_WEBSOCKETS String json = "{\"name\":\"" + name + "\",\"value\":" + String(value) + "}"; - //webSocketsServer.broadcastTXT(json); + webSocketsServer.broadcastTXT(json); +#else + (void)name; + (void)value; +#endif // ENABLE_WEBSOCKETS } void broadcastString(String name, String value) { +#if ENABLE_WEBSOCKETS String json = "{\"name\":\"" + name + "\",\"value\":\"" + String(value) + "\"}"; - //webSocketsServer.broadcastTXT(json); + webSocketsServer.broadcastTXT(json); +#else + (void)name; + (void)value; +#endif // ENABLE_WEBSOCKETS } // TODO: Add board-specific entropy sources @@ -761,7 +776,9 @@ void loop() { } -/* TODO -- Move websocket support to separate file +// TODO -- Move websocket support to separate file +#if ENABLE_WEBSOCKETS +/* Have to explicitly comment this out ... else Arduino build fails (Arduino attempts to pull all functions out of .ino, and WStype_t isn't defined) void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t length) { switch (type) { @@ -782,12 +799,11 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t length case WStype_TEXT: Serial.printf("[%u] get Text: %s\n", num, payload); - //send message to client - //webSocketsServer.sendTXT(num, payload); + webSocketsServer.sendTXT(num, payload); //send data to all connected clients - //webSocketsServer.broadcastTXT(payload); + webSocketsServer.broadcastTXT(payload); break; @@ -801,6 +817,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t length } } */ +#endif // ENABLE_WEBSOCKETS // TODO: Save settings in file system, not EEPROM! const uint8_t SETTINGS_MAGIC_BYTE = 0x96; diff --git a/platformio.ini b/platformio.ini index 962ce5ef..0d2f3209 100644 --- a/platformio.ini +++ b/platformio.ini @@ -39,7 +39,7 @@ default_envs = fastled_webserver__d1_mini, fib512__d1_mini, fib256__d1_mini, fib src_dir = ./esp8266-fastled-webserver/ data_dir = ./esp8266-fastled-webserver/data -build_cache_dir = ~/.buildcache +; build_cache_dir = ~/.buildcache [common] ldscript_1m128k = eagle.flash.1m128.ld From 4549d0beb66a3b0e8a6c8cc75d878e8fbffb53a0 Mon Sep 17 00:00:00 2001 From: Henry Gabryjelski Date: Mon, 13 Dec 2021 13:45:23 -0800 Subject: [PATCH 17/21] Example for trying out a build with IR enabled --- README.md | 2 +- esp8266-fastled-webserver/Websockets.cpp | 80 +++++++++++++++++++ esp8266-fastled-webserver/commands.cpp | 15 +++- esp8266-fastled-webserver/common.h | 32 ++++++-- .../esp8266-fastled-webserver.ino | 75 +---------------- platformio_override_example.ini | 12 +++ 6 files changed, 134 insertions(+), 82 deletions(-) create mode 100644 esp8266-fastled-webserver/Websockets.cpp diff --git a/README.md b/README.md index d381b755..6d4b72bf 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ The app is installed via the Arduino IDE which can be [downloaded here](https:// The app depends on the following libraries. They must either be downloaded from GitHub and placed in the Arduino 'libraries' folder, or installed as [described here](https://www.arduino.cc/en/Guide/Libraries) by using the Arduino library manager. * [FastLED](https://github.com/FastLED/FastLED) -* [IRremoteESP8266](https://github.com/sebastienwarin/IRremoteESP8266) +* [IRremoteESP8266](https://github.com/crankyoldgit/IRremoteESP8266) * [Arduino WebSockets](https://github.com/Links2004/arduinoWebSockets) * [Arduino JSON](https://arduinojson.org) * [lolrol LittleFS](https://github.com/lorol/LITTLEFS) -- (integrated into ESP32 core v2, which is not used here yet) diff --git a/esp8266-fastled-webserver/Websockets.cpp b/esp8266-fastled-webserver/Websockets.cpp new file mode 100644 index 00000000..c1d71686 --- /dev/null +++ b/esp8266-fastled-webserver/Websockets.cpp @@ -0,0 +1,80 @@ +/* + ESP8266 FastLED WebServer: https://github.com/jasoncoon/esp8266-fastled-webserver + Copyright (C) Jason Coon + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#if ENABLE_WEBSOCKETS + +#include "common.h" + +// #include +#include + + +WebSocketsServer webSocketsServer = WebSocketsServer(81); + +void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t length) { + switch (type) { + case WStype_DISCONNECTED: + Serial.printf("[%u] Disconnected!\n", num); + break; + + case WStype_CONNECTED: + IPAddress ip = webSocketsServer.remoteIP(num); + Serial.printf("[%u] Connected from %d.%d.%d.%d url: %s\n", num, ip[0], ip[1], ip[2], ip[3], payload); + + //send message to client + webSocketsServer.sendTXT(num, "Connected"); + break; + + case WStype_TEXT: + Serial.printf("[%u] get Text: %s\n", num, payload); + + //send message to client + webSocketsServer.sendTXT(num, payload); + + //send data to all connected clients + webSocketsServer.broadcastTXT(payload); + + break; + + case WStype_BIN: + Serial.printf("[%u] get binary length: %u\n", num, length); + hexdump(payload, length); + + //send message to client + webSocketsServer.sendBIN(num, payload, length); + break; + } +} + +void InitializeWebSocketServer(void) { + webSocketsServer.begin(); + webSocketsServer.onEvent(webSocketEvent); + Serial.println("Web socket server started"); +} +void broadcastInt(String name, uint8_t value) { + String json = "{\"name\":\"" + name + "\",\"value\":" + String(value) + "}"; + webSocketsServer.broadcastTXT(json); +} +void broadcastString(String name, String value) +{ + String json = "{\"name\":\"" + name + "\",\"value\":\"" + String(value) + "\"}"; + webSocketsServer.broadcastTXT(json); +} + + +#endif // ENABLE_WEBSOCKETS diff --git a/esp8266-fastled-webserver/commands.cpp b/esp8266-fastled-webserver/commands.cpp index 2a96494b..5576790f 100644 --- a/esp8266-fastled-webserver/commands.cpp +++ b/esp8266-fastled-webserver/commands.cpp @@ -18,14 +18,13 @@ #include "common.h" -#if defined(ENABLE_IR) +#if ENABLE_IR #include #include #include -extern IRrecv irReceiver; -IRrecv irReceiver(RECV_PIN); +IRrecv irReceiver(IR_RECV_PIN); enum class InputCommand { None, @@ -492,6 +491,10 @@ void handleIrInput() } switch (command) { + case InputCommand::None: { + // does nothing, but must be handled due to use of scoped enumeration + break; + } case InputCommand::Up: { adjustPattern(true); break; @@ -689,4 +692,10 @@ void handleIrInput() } } + +void InitializeIR(void) { + irReceiver.enableIRIn(); // Start the receiver +} + + #endif diff --git a/esp8266-fastled-webserver/common.h b/esp8266-fastled-webserver/common.h index 8b09cb71..fa805456 100644 --- a/esp8266-fastled-webserver/common.h +++ b/esp8266-fastled-webserver/common.h @@ -46,8 +46,6 @@ #include #include #include - //#include - //#include #include #include // https://github.com/tzapu/WiFiManager/tree/development @@ -116,9 +114,6 @@ constexpr int LedCount() { } void writeAndCommitSettings(); -void broadcastInt(String name, uint8_t value); -void broadcastString(String name, String value); - #if defined(ESP32) || defined(ESP8266) // Optional: (LGPL) https://github.com/sinricpro/ESPTrueRandom.git#ed198f459da6d7af65dd13317a4fdc97b23991b4 @@ -232,11 +227,38 @@ extern CRGB leds[NUM_PIXELS]; #include "include/Fields.hpp" #include "include/FSBrowser.hpp" + // IR (commands.cpp) #if defined(ENABLE_IR) + void InitializeIR(void); void handleIrInput(); #else inline void handleIrInput() {} +#endif // defined(ENABLE_IR) + +// TODO: move these functions out of main .INO file +// they are currently used by IR & main .INO file +#if defined(ENABLE_IR) + void setPower(uint8_t value); + void setAutoplay(uint8_t value); + //void setAutoplayDuration(uint8_t value); + void setSolidColor(CRGB color); + //void setSolidColor(uint8_t r, uint8_t g, uint8_t b); + void adjustPattern(bool up); + void setPattern(uint8_t value); + //void setPatternName(String name); + void adjustBrightness(bool up); +#endif // defined(ENABLE_IR) + + +#if ENABLE_WEBSOCKETS + void InitializeWebSocketServer(void); + void broadcastInt(String name, uint8_t value); + void broadcastString(String name, String value); +#else + // these are put here for convenience + inline void broadcastInt(String, uint8_t) {}; + inline void broadcastString(String, String) {}; #endif // ping.cpp diff --git a/esp8266-fastled-webserver/esp8266-fastled-webserver.ino b/esp8266-fastled-webserver/esp8266-fastled-webserver.ino index ac524741..7eeb5c2d 100644 --- a/esp8266-fastled-webserver/esp8266-fastled-webserver.ino +++ b/esp8266-fastled-webserver/esp8266-fastled-webserver.ino @@ -21,9 +21,6 @@ WiFiManager wifiManager; ESP8266WebServer webServer(80); -#if ENABLE_WEBSOCKETS -WebSocketsServer webSocketsServer = WebSocketsServer(81); -#endif // ENABLE_WEBSOCKETS ESP8266HTTPUpdateServer httpUpdateServer; int utcOffsetInSeconds = -6 * 60 * 60; @@ -326,7 +323,7 @@ void setup() { FastLED.setBrightness(brightness); #if defined(ENABLE_IR) - irReceiver.enableIRIn(); // Start the receiver + InitializeIR(); #endif Serial.println(); @@ -644,9 +641,7 @@ void setup() { Serial.println("HTTP web server started"); #if ENABLE_WEBSOCKETS - webSocketsServer.begin(); - webSocketsServer.onEvent(webSocketEvent); - Serial.println("Web socket server started"); + InitializeWebSocketServer(); #endif // ENABLE_WEBSOCKETS autoPlayTimeout = millis() + (autoplayDuration * 1000); @@ -666,29 +661,6 @@ void sendString(String value) webServer.send(200, "text/plain", value); } - -void broadcastInt(String name, uint8_t value) -{ -#if ENABLE_WEBSOCKETS - String json = "{\"name\":\"" + name + "\",\"value\":" + String(value) + "}"; - webSocketsServer.broadcastTXT(json); -#else - (void)name; - (void)value; -#endif // ENABLE_WEBSOCKETS -} - -void broadcastString(String name, String value) -{ -#if ENABLE_WEBSOCKETS - String json = "{\"name\":\"" + name + "\",\"value\":\"" + String(value) + "\"}"; - webSocketsServer.broadcastTXT(json); -#else - (void)name; - (void)value; -#endif // ENABLE_WEBSOCKETS -} - // TODO: Add board-specific entropy sources // e.g., using `uint32_t esp_random()`, if exposed in Arduino ESP32 / ESP8266 BSPs // e.g., directly reading from 0x3FF20E44 on ESP8266 (dangerous! no entropy validation, whitening) @@ -776,49 +748,6 @@ void loop() { } -// TODO -- Move websocket support to separate file -#if ENABLE_WEBSOCKETS -/* Have to explicitly comment this out ... else Arduino build fails (Arduino attempts to pull all functions out of .ino, and WStype_t isn't defined) -void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t length) { - - switch (type) { - case WStype_DISCONNECTED: - Serial.printf("[%u] Disconnected!\n", num); - break; - - case WStype_CONNECTED: - { - IPAddress ip = webSocketsServer.remoteIP(num); - Serial.printf("[%u] Connected from %d.%d.%d.%d url: %s\n", num, ip[0], ip[1], ip[2], ip[3], payload); - - //send message to client - webSocketsServer.sendTXT(num, "Connected"); - } - break; - - case WStype_TEXT: - Serial.printf("[%u] get Text: %s\n", num, payload); - - //send message to client - webSocketsServer.sendTXT(num, payload); - - //send data to all connected clients - webSocketsServer.broadcastTXT(payload); - - break; - - case WStype_BIN: - Serial.printf("[%u] get binary length: %u\n", num, length); - hexdump(payload, length); - - //send message to client - webSocketsServer.sendBIN(num, payload, length); - break; - } -} -*/ -#endif // ENABLE_WEBSOCKETS - // TODO: Save settings in file system, not EEPROM! const uint8_t SETTINGS_MAGIC_BYTE = 0x96; void readSettings() diff --git a/platformio_override_example.ini b/platformio_override_example.ini index 8876284c..7cf80f1c 100644 --- a/platformio_override_example.ini +++ b/platformio_override_example.ini @@ -18,3 +18,15 @@ build_flags = -D PIXELS_ON_DATA_PIN_5=17 -D PIXELS_ON_DATA_PIN_6=19 + +; This environment example enable IR decoding, +; which requires adding a new library dependency. +[env:custom_fib256_with_IR] +extends = common__d1_mini +lib_deps = + ${esp8266.lib_deps} + crankyoldgit/IRremoteESP8266 @ ^2.8.0 +build_flags = + ${common.build_flags_esp8266} + -D PRODUCT_FIBONACCI256 + -D ENABLE_IR=1 From 024427d513c3efa4afb810dda425722652084288 Mon Sep 17 00:00:00 2001 From: Henry Gabryjelski Date: Mon, 13 Dec 2021 13:46:55 -0800 Subject: [PATCH 18/21] fix ENABLE_IR check --- esp8266-fastled-webserver/commands.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esp8266-fastled-webserver/commands.cpp b/esp8266-fastled-webserver/commands.cpp index 5576790f..b10ca745 100644 --- a/esp8266-fastled-webserver/commands.cpp +++ b/esp8266-fastled-webserver/commands.cpp @@ -18,7 +18,7 @@ #include "common.h" -#if ENABLE_IR +#if defined(ENABLE_IR) #include #include From bc10af221cd5fa2f2b1f4bd6a647ca7fa4a4ca04 Mon Sep 17 00:00:00 2001 From: Henry Gabryjelski Date: Mon, 13 Dec 2021 13:55:36 -0800 Subject: [PATCH 19/21] Avoid #if vs. #ifdef confusion for ENABLE_IR --- esp8266-fastled-webserver/commands.cpp | 2 +- esp8266-fastled-webserver/common.h | 8 ++++---- esp8266-fastled-webserver/config.h | 11 ++++++++++- .../esp8266-fastled-webserver.ino | 8 ++++---- .../include/configs/controller/controller_esp32.h | 2 +- .../include/configs/controller/controller_esp8266.h | 2 +- .../include/configs/controller/controller_template.h | 2 +- .../include/configs/product/product_template.h | 7 ++++--- 8 files changed, 26 insertions(+), 16 deletions(-) diff --git a/esp8266-fastled-webserver/commands.cpp b/esp8266-fastled-webserver/commands.cpp index b10ca745..5576790f 100644 --- a/esp8266-fastled-webserver/commands.cpp +++ b/esp8266-fastled-webserver/commands.cpp @@ -18,7 +18,7 @@ #include "common.h" -#if defined(ENABLE_IR) +#if ENABLE_IR #include #include diff --git a/esp8266-fastled-webserver/common.h b/esp8266-fastled-webserver/common.h index fa805456..a70d5b2a 100644 --- a/esp8266-fastled-webserver/common.h +++ b/esp8266-fastled-webserver/common.h @@ -229,16 +229,16 @@ extern CRGB leds[NUM_PIXELS]; // IR (commands.cpp) -#if defined(ENABLE_IR) +#if ENABLE_IR void InitializeIR(void); void handleIrInput(); #else inline void handleIrInput() {} -#endif // defined(ENABLE_IR) +#endif // ENABLE_IR // TODO: move these functions out of main .INO file // they are currently used by IR & main .INO file -#if defined(ENABLE_IR) +#if ENABLE_IR void setPower(uint8_t value); void setAutoplay(uint8_t value); //void setAutoplayDuration(uint8_t value); @@ -248,7 +248,7 @@ extern CRGB leds[NUM_PIXELS]; void setPattern(uint8_t value); //void setPatternName(String name); void adjustBrightness(bool up); -#endif // defined(ENABLE_IR) +#endif // ENABLE_IR #if ENABLE_WEBSOCKETS diff --git a/esp8266-fastled-webserver/config.h b/esp8266-fastled-webserver/config.h index d94d58ae..af7f0f84 100644 --- a/esp8266-fastled-webserver/config.h +++ b/esp8266-fastled-webserver/config.h @@ -127,7 +127,16 @@ #if !defined(DEFAULT_COLOR_CORRECTION) #error "DEFAULT_COLOR_CORRECTION must be defined by product" #endif - #if defined(ENABLE_IR) && !defined(IR_RECV_PIN) + #if !defined(ENABLE_IR) + #define ENABLE_IR 0 + #endif + #if ((ENABLE_IR != 0) && (ENABLE_IR != 1)) + #error "ENABLE_IR must be undefined (defaults to 0), 0, or 1" + #endif + #if ENABLE_IR + #warning "ENABLE_IR is still in development, and is NOT supported" + #endif + #if ENABLE_IR && !defined(IR_RECV_PIN) #error "IR_RECV_PIN must be defined by product when ENABLE_IR is defined" #endif #if !defined(NAME_PREFIX) diff --git a/esp8266-fastled-webserver/esp8266-fastled-webserver.ino b/esp8266-fastled-webserver/esp8266-fastled-webserver.ino index 7eeb5c2d..a4430e6a 100644 --- a/esp8266-fastled-webserver/esp8266-fastled-webserver.ino +++ b/esp8266-fastled-webserver/esp8266-fastled-webserver.ino @@ -322,9 +322,9 @@ void setup() { FastLED.setBrightness(brightness); -#if defined(ENABLE_IR) +#if ENABLE_IR InitializeIR(); -#endif +#endif // ENABLE_IR Serial.println(); Serial.println(F("System Info:")); @@ -702,9 +702,9 @@ void loop() { } checkPingTimer(); -#if defined(ENABLE_IR) +#if ENABLE_IR handleIrInput(); // empty function when ENABLE_IR is not defined -#endif +#endif // ENABLE_IR if (power == 0) { fill_solid(leds, NUM_PIXELS, CRGB::Black); diff --git a/esp8266-fastled-webserver/include/configs/controller/controller_esp32.h b/esp8266-fastled-webserver/include/configs/controller/controller_esp32.h index 20085658..3d0c2c3b 100644 --- a/esp8266-fastled-webserver/include/configs/controller/controller_esp32.h +++ b/esp8266-fastled-webserver/include/configs/controller/controller_esp32.h @@ -51,7 +51,7 @@ static_assert(PARALLEL_OUTPUT_CHANNELS <= 4, "While ESP32 supports 16 parallel o -#if defined(ENABLE_IR) && !defined(IR_RECV_PIN) +#if defined(ENABLE_IR) && ENABLE_IR && !defined(IR_RECV_PIN) // Default pin for ESP32 is 16 (for d1 mini32, this is the same physical location as D4 on the d1 mini) #define IR_RECV_PIN 16 // TODO: VERIFY THIS IS CORRECT VALUE #endif diff --git a/esp8266-fastled-webserver/include/configs/controller/controller_esp8266.h b/esp8266-fastled-webserver/include/configs/controller/controller_esp8266.h index e8c62b0c..e3bfddc7 100644 --- a/esp8266-fastled-webserver/include/configs/controller/controller_esp8266.h +++ b/esp8266-fastled-webserver/include/configs/controller/controller_esp8266.h @@ -46,7 +46,7 @@ static_assert(PARALLEL_OUTPUT_CHANNELS <= 6, "ESP8266 only supports six parallel #define DATA_PIN_6 D2 // d1 mini #endif -#if defined(ENABLE_IR) && !defined(IR_RECV_PIN) +#if defined(ENABLE_IR) && ENABLE_IR && !defined(IR_RECV_PIN) #define IR_RECV_PIN D4 #endif diff --git a/esp8266-fastled-webserver/include/configs/controller/controller_template.h b/esp8266-fastled-webserver/include/configs/controller/controller_template.h index a658e2db..1248b63d 100644 --- a/esp8266-fastled-webserver/include/configs/controller/controller_template.h +++ b/esp8266-fastled-webserver/include/configs/controller/controller_template.h @@ -38,7 +38,7 @@ #define FASTLED_INTERRUPT_RETRY_COUNT 0 // ENABLE_IR defines whether to include support for an IR receiver -// #define ENABLE_IR +// #define ENABLE_IR 1 // #define IR_RECV_PIN D4 // d1 mini // #define IR_RECV_PIN 16 // d1 mini32 (same physical location as D4 on the d1 mini) diff --git a/esp8266-fastled-webserver/include/configs/product/product_template.h b/esp8266-fastled-webserver/include/configs/product/product_template.h index 7ea04679..5ad1e4a9 100644 --- a/esp8266-fastled-webserver/include/configs/product/product_template.h +++ b/esp8266-fastled-webserver/include/configs/product/product_template.h @@ -163,9 +163,10 @@ #define PARALLEL_OUTPUT_CHANNELS 1 #endif -// // By default, no IR support is included. Define ENABLE_IR to enable IR support. -// #define ENABLE_IR -// // When ENABLE_IR is defined, can also override controller-specific default: +// // By default, no IR support is included. Define ENABLE_IR as to enable IR support. +// #define ENABLE_IR 1 + +// // When ENABLE_IR is defined as 1, can also override controller-specific default: // // #define IR_RECV_PIN D99 From 95723dab121482988877269951723b13bb1dbb7f Mon Sep 17 00:00:00 2001 From: Henry Gabryjelski Date: Mon, 13 Dec 2021 15:54:44 -0800 Subject: [PATCH 20/21] Comments updates only --- .../esp8266-fastled-webserver.ino | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/esp8266-fastled-webserver/esp8266-fastled-webserver.ino b/esp8266-fastled-webserver/esp8266-fastled-webserver.ino index a4430e6a..e6542a76 100644 --- a/esp8266-fastled-webserver/esp8266-fastled-webserver.ino +++ b/esp8266-fastled-webserver/esp8266-fastled-webserver.ino @@ -983,9 +983,19 @@ void palettebow() void coolerpalettebow() { - static uint8_t startindex = 0; - startindex--; - fill_palette( leds, NUM_PIXELS, startindex, (256 / NUM_PIXELS) + 1, palettes[currentPaletteIndex], 255, LINEARBLEND); + static uint8_t paletteStartIndex = 0; + // Why is it safe to use a `paletteStartIndex` over 16? + // The palettes array is defined as an array of `CRGBPalette16`, + // which means there are exactly 16 CRGB elements. Therefore, + // the only valid indices are [0..15]. + // + // fill_palette() calls ColorFromPalette(). + // Manual review shows that *each* of the ColorFromPalette<>() functions safely + // accept any `uint8_t` value for the start index. Therefore, there's an + // undocumented contract that the `uint8_t startIndex` provided to the function + // can be any value, without causing out-of-bounds access of the palette array. + paletteStartIndex--; + fill_palette( leds, NUM_PIXELS, paletteStartIndex, (256 / NUM_PIXELS) + 1, palettes[currentPaletteIndex], 255, LINEARBLEND); } void palettebowglitter() @@ -1337,7 +1347,7 @@ void colorWavesFibonacci() #endif // Alternate rendering function just scrolls the current palette -// across the defined LED strip.a +// across the defined LED strip. void palettetest( CRGB* ledarray, uint16_t numleds, const CRGBPalette16& gCurrentPalette) { static uint8_t startindex = 0; startindex--; From 45121485cf437306ab0112173e68f70ac93a8fad Mon Sep 17 00:00:00 2001 From: Henry Gabryjelski Date: Mon, 13 Dec 2021 16:06:47 -0800 Subject: [PATCH 21/21] One more function to pull into websockets.cpp --- esp8266-fastled-webserver/Websockets.cpp | 3 +++ esp8266-fastled-webserver/common.h | 1 + esp8266-fastled-webserver/esp8266-fastled-webserver.ino | 5 +++-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/esp8266-fastled-webserver/Websockets.cpp b/esp8266-fastled-webserver/Websockets.cpp index c1d71686..902753b4 100644 --- a/esp8266-fastled-webserver/Websockets.cpp +++ b/esp8266-fastled-webserver/Websockets.cpp @@ -66,6 +66,9 @@ void InitializeWebSocketServer(void) { webSocketsServer.onEvent(webSocketEvent); Serial.println("Web socket server started"); } +void handleWebSocketLoop(void) { + webSocketsServer.loop(); +} void broadcastInt(String name, uint8_t value) { String json = "{\"name\":\"" + name + "\",\"value\":" + String(value) + "}"; webSocketsServer.broadcastTXT(json); diff --git a/esp8266-fastled-webserver/common.h b/esp8266-fastled-webserver/common.h index a70d5b2a..502fc48c 100644 --- a/esp8266-fastled-webserver/common.h +++ b/esp8266-fastled-webserver/common.h @@ -253,6 +253,7 @@ extern CRGB leds[NUM_PIXELS]; #if ENABLE_WEBSOCKETS void InitializeWebSocketServer(void); + void handleWebSocketLoop(void); void broadcastInt(String name, uint8_t value); void broadcastString(String name, String value); #else diff --git a/esp8266-fastled-webserver/esp8266-fastled-webserver.ino b/esp8266-fastled-webserver/esp8266-fastled-webserver.ino index e6542a76..3a0583a1 100644 --- a/esp8266-fastled-webserver/esp8266-fastled-webserver.ino +++ b/esp8266-fastled-webserver/esp8266-fastled-webserver.ino @@ -672,8 +672,6 @@ void loop() { // Modify random number generator seed; we use a lot of it. (Note: this is still deterministic) random16_add_entropy(random(65535)); - //webSocketsServer.loop(); - wifiManager.process(); webServer.handleClient(); MDNS.update(); @@ -705,6 +703,9 @@ void loop() { #if ENABLE_IR handleIrInput(); // empty function when ENABLE_IR is not defined #endif // ENABLE_IR +#if ENABLE_WEBSOCKETS + handleWebSocketLoop(); +#endif if (power == 0) { fill_solid(leds, NUM_PIXELS, CRGB::Black);