├── .vscode ├── arduino.json ├── c_cpp_properties.json └── settings.json └── Servant.ino /.vscode/arduino.json: -------------------------------------------------------------------------------- 1 | { 2 | "board": "esp32:esp32:heltec_wifi_kit_32", 3 | "configuration": "FlashFreq=80,UploadSpeed=921600", 4 | "sketch": "Servant.ino", 5 | "port": "/dev/cu.SLAB_USBtoUART", 6 | "output": "../../servantbuild/", 7 | "programmer": "AVRISP mkII" 8 | } -------------------------------------------------------------------------------- /.vscode/c_cpp_properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "Mac", 5 | "includePath": [ 6 | "/Users/dave/Library/Arduino15/packages/esp32/tools/**", 7 | "/Users/dave/Library/Arduino15/packages/esp32/hardware/esp32/1.0.1/**", 8 | "/Users/dave/Documents/Arduino/libraries/FastLED2", 9 | "/Users/Dave/Documents/Arduino/libraries/U8g2/src", 10 | "/Users/Dave/Documents/Arduino/libraries/Adafruit_GFX_Library/**" 11 | ], 12 | "forcedInclude": [], 13 | "macFrameworkPath": [ 14 | "/System/Library/Frameworks", 15 | "/Library/Frameworks" 16 | ], 17 | "intelliSenseMode": "clang-x64" 18 | } 19 | ], 20 | "version": 4 21 | } -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "algorithm": "cpp", 4 | "limits": "cpp", 5 | "__bit_reference": "cpp", 6 | "__split_buffer": "cpp", 7 | "initializer_list": "cpp", 8 | "iterator": "cpp", 9 | "string": "cpp", 10 | "string_view": "cpp", 11 | "vector": "cpp", 12 | "cmath": "cpp" 13 | } 14 | } -------------------------------------------------------------------------------- /Servant.ino: -------------------------------------------------------------------------------- 1 | // Quick-and-Dirty Demo of FastLED Parallel Strip Support on ESP32 2 | // 3 | // Uses FastLED's RMT support on the ESP32 to drive 8 channels in parallel 4 | // 5 | // (c) 2019 Dave Plummer 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | #include // Assumes 3.2 or better 26 | #include // So we can talk to the CUU text 27 | #include // FastLED for the LED panels 28 | #include // Handy color and hue stuff 29 | #include // Adafruit GFX for the panels 30 | #include // A nice font for the VFD 31 | 32 | #define LED_PIN0 21 // These work for me on a Heltec Wiki32 board 33 | #define LED_PIN1 22 34 | #define LED_PIN2 19 35 | #define LED_PIN3 5 36 | #define LED_PIN4 17 37 | #define LED_PIN5 0 38 | #define LED_PIN6 2 39 | #define LED_PIN7 12 40 | 41 | #define USE_TFT 1 // Use the little TFT on the Heltec board to diplay framerate 42 | #define STACK_SIZE 4096 // Stack size for each new thread 43 | #define ARRAYSIZE(n) (sizeof(n)/sizeof(n[0])) // Count of elements in array, as opposed to bytecount 44 | 45 | #define STRIP_SIZE 144*7 // Just over 1000 LEDs per segment x 8 segments = 8064 LEDs 46 | 47 | CRGB g_rgbData0[STRIP_SIZE]; // Frame buffers (color bytes) for the 8 LED strip segments 48 | CRGB g_rgbData1[STRIP_SIZE]; 49 | CRGB g_rgbData2[STRIP_SIZE]; 50 | CRGB g_rgbData3[STRIP_SIZE]; 51 | CRGB g_rgbData4[STRIP_SIZE]; 52 | CRGB g_rgbData5[STRIP_SIZE]; 53 | CRGB g_rgbData6[STRIP_SIZE]; 54 | CRGB g_rgbData7[STRIP_SIZE]; 55 | 56 | // FPS 57 | // 58 | // Given a millisecond value for when the last frame took place and the current timestamp returns the number of 59 | // frames per second, as low as 0. Never exceeds 999 so you can make some width assumptions. 60 | 61 | #define MS_PER_SECOND 1000 62 | 63 | int FPS(unsigned long start, unsigned long end) 64 | { 65 | unsigned long msDuration = end - start; 66 | float fpsf = 1.0f / (msDuration / (float)MS_PER_SECOND); 67 | int FPS = (int)fpsf; 68 | if (FPS > 999) 69 | FPS = 999; 70 | return FPS; 71 | } 72 | volatile int g_FPS; 73 | 74 | // Enable the Heltec Wif Kit 32 TFT board. Undefine this if you are on a different board. 75 | 76 | #if USE_TFT 77 | U8G2_SSD1306_128X64_NONAME_F_SW_I2C g_TFT(U8G2_R2, 15, 4, 16); 78 | #endif 79 | TaskHandle_t g_taskTFT = nullptr; 80 | 81 | // TFTUpdateLoop 82 | // 83 | // Displays statistics on the Heltec's built in TFT board. If you are using a different board, you would simply get rid of 84 | // this or modify it to fit a screen you do have. You could also try serial output, as it's on a low-pri thread it shouldn't 85 | // disturb the primary cores, but I haven't tried it myself. 86 | 87 | void TFTUpdateLoop(void *) 88 | { 89 | #if USE_TFT 90 | g_TFT.clear(); 91 | #endif 92 | 93 | for (;;) 94 | { 95 | char szBuffer[256]; 96 | #if USE_TFT 97 | g_TFT.setDisplayRotation(U8G2_R2); 98 | g_TFT.clearBuffer(); // clear the internal memory 99 | g_TFT.setFont(u8g2_font_profont15_tf); // choose a suitable font 100 | 101 | g_TFT.setCursor(0,10); 102 | g_TFT.print("Update Speed: "); 103 | g_TFT.print(g_FPS); 104 | g_TFT.sendBuffer(); 105 | 106 | #endif 107 | delay(200); 108 | } 109 | } 110 | 111 | // setup 112 | // 113 | // Invoked once at boot, does initial chip setup and application initial 114 | 115 | void setup() 116 | { 117 | #if USE_TFT 118 | g_TFT.begin(); 119 | g_TFT.clear(); 120 | g_TFT.clearBuffer(); // clear the internal memory 121 | g_TFT.setFont(u8g2_font_profont15_tf); // choose a suitable font 122 | g_TFT.setCursor(0,10); 123 | g_TFT.println("TFT Ready"); 124 | g_TFT.sendBuffer(); 125 | #endif 126 | 127 | Serial.begin(115200); 128 | 129 | // Spin off the TFT stuff as a separate worker thread 130 | xTaskCreatePinnedToCore(TFTUpdateLoop, "TFT Loop", STACK_SIZE, nullptr, 0, &g_taskTFT, 0); // UI stuff not bound to any core and at lower priority 131 | 132 | // Add all 8 segmetns to FastLED 133 | FastLED.addLeds(g_rgbData0, STRIP_SIZE); 134 | FastLED.addLeds(g_rgbData1, STRIP_SIZE); 135 | FastLED.addLeds(g_rgbData2, STRIP_SIZE); 136 | FastLED.addLeds(g_rgbData3, STRIP_SIZE); 137 | FastLED.addLeds(g_rgbData4, STRIP_SIZE); 138 | FastLED.addLeds(g_rgbData5, STRIP_SIZE); 139 | FastLED.addLeds(g_rgbData6, STRIP_SIZE); 140 | FastLED.addLeds(g_rgbData7, STRIP_SIZE); 141 | 142 | // Check yourself before you wreck yourself, make sure your power supply doesn't burn down your shop 143 | FastLED.setBrightness(4); 144 | } 145 | 146 | 147 | void loop() 148 | { 149 | // Simple walking rainbow offset on the various strips 150 | 151 | static int hue = 0; 152 | hue+=8; 153 | 154 | fill_rainbow(g_rgbData0, STRIP_SIZE, hue, 5); 155 | fill_rainbow(g_rgbData1, STRIP_SIZE, hue+32, 5); 156 | fill_rainbow(g_rgbData2, STRIP_SIZE, hue+64, 5); 157 | fill_rainbow(g_rgbData3, STRIP_SIZE, hue+96, 5); 158 | fill_rainbow(g_rgbData4, STRIP_SIZE, hue+128, 5); 159 | fill_rainbow(g_rgbData5, STRIP_SIZE, hue+160, 5); 160 | fill_rainbow(g_rgbData6, STRIP_SIZE, hue+192, 5); 161 | fill_rainbow(g_rgbData7, STRIP_SIZE, hue+224, 5); 162 | 163 | unsigned static long lastTime = 0; 164 | FastLED.show(); 165 | g_FPS = FPS(lastTime, millis()); 166 | lastTime = millis(); 167 | delay(5); 168 | } --------------------------------------------------------------------------------