<?xml version="1.0" encoding="UTF-8"?>        <rss version="2.0"
             xmlns:atom="http://www.w3.org/2005/Atom"
             xmlns:dc="http://purl.org/dc/elements/1.1/"
             xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
             xmlns:admin="http://webns.net/mvcb/"
             xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
             xmlns:content="http://purl.org/rss/1.0/modules/content/">
        <channel>
            <title>
									FastledXLemming-BLE esp32 - Projects				            </title>
            <link>https://www.simhubdash.com/community-2/projects/fastledxlemming-ble-esp32/</link>
            <description>All about SimHub!</description>
            <language>en-US</language>
            <lastBuildDate>Mon, 07 Sep 2026 17:44:07 +0000</lastBuildDate>
            <generator>wpForo</generator>
            <ttl>60</ttl>
							                    <item>
                        <title>RE: FastledXLemming-BLE esp32</title>
                        <link>https://www.simhubdash.com/community-2/projects/fastledxlemming-ble-esp32/#post-5766</link>
                        <pubDate>Tue, 06 Sep 2022 00:33:56 +0000</pubDate>
                        <description><![CDATA[This may be easier to do with NeoPixelBus, rather than FastLED.
 
I&#039;ve got an implementation of NeoPixelBus library that&#039;s working on ESP8266, that I&#039;ll be soon confirming works with ESP32...]]></description>
                        <content:encoded><![CDATA[<p>This may be easier to do with NeoPixelBus, rather than FastLED.</p>
<p> </p>
<p>I've got an implementation of NeoPixelBus library that's working on ESP8266, that I'll be soon confirming works with ESP32.</p>
<p> </p>
<p>Here's my implementation of SHRGBLedsBase with NeoPixelBus (Leaving it up to the reader how to use this)</p>
<pre contenteditable="false">#ifndef __SHRGBLEDSNEOPIXEL_H__
#define __SHRGBLEDSNEOPIXEL_H__

#include "SHRGBLedsBase.h"
#include &lt;NeoPixelAnimator.h&gt;
#include &lt;NeoPixelBrightnessBus.h&gt;
#include &lt;NeoPixelBus.h&gt;
#include &lt;NeoPixelSegmentBus.h&gt;

#if (WS2812B_RGBENCODING == 0)
#define NEOPIXEL_FEATURE NeoGrbFeature
#elif (WS2812B_RGBENCODING == 1)
#define NEOPIXEL_FEATURE NeoRgbFeature
#else
#define NEOPIXEL_FEATURE NeoBrgFeature
#endif

static NeoPixelBus&lt;NEOPIXEL_FEATURE, Neo800KbpsMethod&gt; NeoPixel_strip(WS2812B_RGBLEDCOUNT, WS2812B_DATAPIN);

class SHRGBLedsNeoPixelBus : public SHRGBLedsBase {
private:
	unsigned long lastRead = 0;

public:

	void begin(int maxLeds, int righttoleft, bool testMode) {
    Serial.println("Starting NeoPixelBus");
		SHRGBLedsBase::begin(maxLeds, righttoleft);
		NeoPixel_strip.Begin();
		NeoPixel_strip.Show();

		if (testMode &gt; 0) {
			for (int i = 0; i &lt; maxLeds; i++) {
				NeoPixel_strip.SetPixelColor(i, RgbColor(255, 0, 0));
				NeoPixel_strip.Show();
			}
		}
	}

	void show() {
		NeoPixel_strip.Show();
	}

protected:
	void setPixelColor(uint8_t lednumber, uint8_t r, uint8_t g, uint8_t b) {
		NeoPixel_strip.SetPixelColor(lednumber, RgbColor(r, g, b));
	}
	
};

#endif</pre>]]></content:encoded>
						                            <category domain="https://www.simhubdash.com/community-2/projects/">Projects</category>                        <dc:creator>zcorneli</dc:creator>
                        <guid isPermaLink="true">https://www.simhubdash.com/community-2/projects/fastledxlemming-ble-esp32/#post-5766</guid>
                    </item>
				                    <item>
                        <title>RE: FastledXLemming-BLE esp32</title>
                        <link>https://www.simhubdash.com/community-2/projects/fastledxlemming-ble-esp32/#post-5430</link>
                        <pubDate>Thu, 30 Jun 2022 13:13:58 +0000</pubDate>
                        <description><![CDATA[current proggress:
-button worked well
-leds seems worked, need to figure out the custom serial protocol (didn&#039;t work).
to do:
-back to the main topic (ws2812 how to get it work on esp32...]]></description>
                        <content:encoded><![CDATA[<p>current proggress:</p>
<p>-button worked well</p>
<p>-<span style="text-decoration: line-through">leds seems worked</span>, need to figure out the custom serial protocol (didn't work).</p>
<p>to do:</p>
<p>-back to the main topic (ws2812 how to get it work on esp32)</p>
<p>-add something like (tm1638, oled, or small lcd to get worked on)</p>
<p> </p>
<p></p>
<pre contenteditable="false">#include 
#include "BluetoothSerial.h"
#include 
#include 
#include 

#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
#endif

BleGamepad bleGamepad("F1Wheel", "mbohben", 100); // Shows how you can customise the device name, manufacturer name and initial battery level

//def
#define ROWS 5
#define COLS 4
#define BUF_SIZE 64
#define REV_LIGHTS_COUNT 8
#define WS2812_PIN 5

//fastled
char simHubMessageBuf;
BluetoothSerial EEBlue;
CRGB leds;

const byte ColorNone = {0, 0, 0};
const byte ColorBlue = {0, 0, 168};
const byte ColorGreen = {0, 168, 0};
const byte ColorYellow = {168, 168, 0};
const byte ColorRed = {168, 0, 0};

int spd;
int revs;

//keypad
uint8_t rowPins = {13, 12, 14, 27, 26}; // ESP32 pins used for rows      --&gt; adjust to suit --&gt; Pinout on board: R1, R2, R3, R4
uint8_t colPins = {15, 4, 16, 17}; // ESP32 pins used for columns   --&gt; adjust to suit --&gt; Pinout on board: Q1, Q2, Q3, Q4
uint8_t keymap =
    {
      {1,2,3,4},
      {5,6,7,8},
      {9,10,11,12},
      {13,14,15,16},
      {17,18,19,20}
};

Keypad customKeypad = Keypad(makeKeymap(keymap), rowPins, colPins, ROWS, COLS);

void setup() {
  BleGamepadConfiguration bleGamepadConfig;
    bleGamepadConfig.setAutoReport(false);
    bleGamepadConfig.setControllerType(CONTROLLER_TYPE_GAMEPAD);
    bleGamepadConfig.setButtonCount(20);
    bleGamepadConfig.setHatSwitchCount(0);
    bleGamepadConfig.setWhichSpecialButtons(false, false, false, false, false, false, false, false);
    bleGamepadConfig.setWhichAxes(false, false, false, false, false, false, false, false);
    bleGamepadConfig.setWhichSimulationControls(false, false, false, false, false);
    Serial.begin(115200);
    Serial.println("setup");
  memset(simHubMessageBuf, 0x0, BUF_SIZE);
  bleGamepad.begin(&amp;bleGamepadConfig);

  FastLED.addLeds&lt;NEOPIXEL, WS2812_PIN&gt;(leds, REV_LIGHTS_COUNT);
}

void loop() {
  if (EEBlue.available() &gt; 0) {
    EEBlue.readBytesUntil('{', simHubMessageBuf, BUF_SIZE);
    int readCount = EEBlue.readBytesUntil('}', simHubMessageBuf, BUF_SIZE);
    simHubMessageBuf = 0x0;
    processMessage();
    memset(simHubMessageBuf, 0x0, BUF_SIZE);
  }
  FastLED.show();
  KeypadUpdate();
  delay(10);
}


void processMessage() {
  char msgType = simHubMessageBuf;

  switch (msgType) {
    case 'R': {
      sscanf(&amp;simHubMessageBuf, "%d", &amp;revs);
      int numOfLightsToShow = round((revs / 100.0f) * REV_LIGHTS_COUNT);
      for(int i=0; i &lt; REV_LIGHTS_COUNT; i++) {
        const byte *color = i &lt; numOfLightsToShow ? ledColor(i) : ColorNone;
        leds.setRGB(color, color, color);
      }
      break;
    }
    case 'S':
      sscanf(&amp;simHubMessageBuf, "%d", &amp;spd);
      break;
  }

  Serial.print("Revs: ");
  Serial.println(revs);
  Serial.print("Speed: ");
  Serial.println(spd);
}

const byte* ledColor(int index) {
  switch(index) {
    case 7:
      return ColorBlue;
    case 6:
    case 5:
      return ColorRed;
    case 4:
    case 3:
      return ColorYellow;
    default: 
      return ColorGreen;  
  }
}

void KeypadUpdate()
{
    customKeypad.getKeys();

    for (int i = 0; i &lt; LIST_MAX; i++) // Scan the whole key list.      //LIST_MAX is provided by the Keypad library and gives the number of buttons of the Keypad instance
    {
        if (customKeypad.key.stateChanged) // Only find keys that have changed state.
        {
            uint8_t keystate = customKeypad.key.kstate;

            if (bleGamepad.isConnected())
            {
                if (keystate == PRESSED)
                {
                    bleGamepad.press(customKeypad.key.kchar);
                } // Press or release button based on the current state
                if (keystate == RELEASED)
                {
                    bleGamepad.release(customKeypad.key.kchar);
                }

                bleGamepad.sendReport(); // Send the HID report after values for all button states are updated, and at least one button state had changed
            }
        }
    }
}</pre>
<p></p>]]></content:encoded>
						                            <category domain="https://www.simhubdash.com/community-2/projects/">Projects</category>                        <dc:creator>mbohben</dc:creator>
                        <guid isPermaLink="true">https://www.simhubdash.com/community-2/projects/fastledxlemming-ble-esp32/#post-5430</guid>
                    </item>
				                    <item>
                        <title>RE: FastledXLemming-BLE esp32</title>
                        <link>https://www.simhubdash.com/community-2/projects/fastledxlemming-ble-esp32/#post-5272</link>
                        <pubDate>Mon, 20 Jun 2022 18:18:09 +0000</pubDate>
                        <description><![CDATA[help me please]]></description>
                        <content:encoded><![CDATA[<p>help me please</p>]]></content:encoded>
						                            <category domain="https://www.simhubdash.com/community-2/projects/">Projects</category>                        <dc:creator>mbohben</dc:creator>
                        <guid isPermaLink="true">https://www.simhubdash.com/community-2/projects/fastledxlemming-ble-esp32/#post-5272</guid>
                    </item>
				                    <item>
                        <title>RE: FastledXLemming-BLE esp32</title>
                        <link>https://www.simhubdash.com/community-2/projects/fastledxlemming-ble-esp32/#post-5258</link>
                        <pubDate>Wed, 15 Jun 2022 12:25:04 +0000</pubDate>
                        <description><![CDATA[UP please]]></description>
                        <content:encoded><![CDATA[<p>UP please</p>]]></content:encoded>
						                            <category domain="https://www.simhubdash.com/community-2/projects/">Projects</category>                        <dc:creator>mbohben</dc:creator>
                        <guid isPermaLink="true">https://www.simhubdash.com/community-2/projects/fastledxlemming-ble-esp32/#post-5258</guid>
                    </item>
				                    <item>
                        <title>FastledXLemming-BLE esp32</title>
                        <link>https://www.simhubdash.com/community-2/projects/fastledxlemming-ble-esp32/#post-5241</link>
                        <pubDate>Sun, 12 Jun 2022 15:19:59 +0000</pubDate>
                        <description><![CDATA[just straight to the topic, any help on getting fastled to work over lemmings-ble-gamepad?
there is my sample code, tested with matrix and direct button. its works well. but cant figure out...]]></description>
                        <content:encoded><![CDATA[<p>just straight to the topic, any help on getting fastled to work over lemmings-ble-gamepad?</p>
<p>there is my sample code, tested with matrix and direct button. its works well. but cant figure out how to make fastled connect to simhub over esp32.</p>
<p>*edit: cant upload ino file</p>
<p></p>
<pre contenteditable="false">/*
 * This code programs a number of pins on an ESP32 as buttons on a BLE gamepad
 *
 * It uses arrays to cut down on code
 *
 * Before using, adjust the numOfButtons, buttonPins and physicalButtons to suit your senario
 *
 */

#include 
#include  // https://github.com/lemmingDev/ESP32-BLE-Gamepad
#include 

BleGamepad bleGamepad("F1esp32", "mbohben", 100);

#define numOfButtons 21

byte previousButtonStates;
byte currentButtonStates;
byte buttonPins = {13, 12, 14, 27, 26, 25, 33, 32, 35, 34, 39, 36, 23, 22, 1, 3, 21, 19, 18, 5, 17};
byte physicalButtons = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21};

///////fastled/////

#define BUF_SIZE 64
#define REV_LIGHTS_COUNT 16

#define WS2812_PIN 12

char simHubMessageBuf;
BluetoothSerial bleGamepad;
CRGB leds;

const byte ColorNone = {0, 0, 0};
const byte ColorBlue = {0, 0, 168};
const byte ColorGreen = {0, 168, 0};
const byte ColorYellow = {168, 168, 0};
const byte ColorRed = {168, 0, 0};

int spd;
int revs;

//////////////////

void setup()
{
    for (byte currentPinIndex = 0; currentPinIndex &lt; numOfButtons; currentPinIndex++)
    {
        pinMode(buttonPins, INPUT_PULLUP);
        previousButtonStates = HIGH;
        currentButtonStates = HIGH;
    }

    BleGamepadConfiguration bleGamepadConfig;
    Serial.begin(115200);
    bleGamepadConfig.setAutoReport(false);
    bleGamepadConfig.setButtonCount(numOfButtons);
    Serial.println("setup");
    memset(simHubMessageBuf, 0x0, BUF_SIZE);
    bleGamepad.begin(&amp;bleGamepadConfig);

    FastLED.addLeds&lt;NEOPIXEL, WS2812_PIN&gt;(leds, REV_LIGHTS_COUNT);

    // changing bleGamepadConfig after the begin function has no effect, unless you call the begin function again
}

//////////////////

void loop()
{
    if (bleGamepad.isConnected())
    {
        for (byte currentIndex = 0; currentIndex &lt; numOfButtons; currentIndex++)
        {
            currentButtonStates = digitalRead(buttonPins);

            if (currentButtonStates != previousButtonStates)
            {
                if (currentButtonStates == HIGH)
                {
                    bleGamepad.press(physicalButtons);
                }
                else
                {
                    bleGamepad.release(physicalButtons);
                }
            }
        }

        if (currentButtonStates != previousButtonStates)
        {
            for (byte currentIndex = 0; currentIndex &lt; numOfButtons; currentIndex++)
            {
                previousButtonStates = currentButtonStates;
            }

            bleGamepad.sendReport();
        }

        delay(20);
    }
    
    if (EEBlue.available() &gt; 0) {
    EEBlue.readBytesUntil('{', simHubMessageBuf, BUF_SIZE);
    int readCount = EEBlue.readBytesUntil('}', simHubMessageBuf, BUF_SIZE);
    simHubMessageBuf = 0x0;
    processMessage();
    memset(simHubMessageBuf, 0x0, BUF_SIZE);
  }
  FastLED.show();
}

////////////fastled/////////

void processMessage() {
  char msgType = simHubMessageBuf;

  switch (msgType) {
    case 'R': {
      sscanf(&amp;simHubMessageBuf, "%d", &amp;revs);
      int numOfLightsToShow = round((revs / 100.0f) * REV_LIGHTS_COUNT);
      for(int i=0; i &lt; REV_LIGHTS_COUNT; i++) {
        const byte *color = i &lt; numOfLightsToShow ? ledColor(i) : ColorNone;
        leds.setRGB(color, color, color);
      }
      break;
    }
    case 'S':
      sscanf(&amp;simHubMessageBuf, "%d", &amp;spd);
      break;
  }

  Serial.print("Revs: ");
  Serial.println(revs);
  Serial.print("Speed: ");
  Serial.println(spd);
}

const byte* ledColor(int index) {
  switch(index) {
    case 7:
      return ColorBlue;
    case 6:
    case 5:
      return ColorRed;
    case 4:
    case 3:
      return ColorYellow;
    default: 
      return ColorGreen;  
  }
}</pre>
<p></p>
<p> </p>
<p></p>
<p>https://www.simhubdash.com/community-2/postid/5430/</p>
<p></p>]]></content:encoded>
						                            <category domain="https://www.simhubdash.com/community-2/projects/">Projects</category>                        <dc:creator>mbohben</dc:creator>
                        <guid isPermaLink="true">https://www.simhubdash.com/community-2/projects/fastledxlemming-ble-esp32/#post-5241</guid>
                    </item>
							        </channel>
        </rss>
		