How does DOF format the colour info it sends for Programmable LEDs?

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #197972
    Johnny T
    Participant
      @johnnyt

      ** EDIT ** I’ve sussed this now. I’ll leave the post up in case it helps someone else.

      The colour is passed as three R,G,B bytes.

      I just declared global variables and set them in a function:

      void ReceiveColorData() {
      while(!Serial.available()) {};
      byteBlue = Serial.read();
      while(!Serial.available()) {};
      byteRed = Serial.read();
      while(!Serial.available()) {};
      byteGreen = Serial.read();
      }

      I then use them like this….

      for(word ledNr = firstLed; ledNr < endLedNr; ledNr++) {
      ReceiveColorData();
      leds[ledNr] = CRGB(byteRed,byteGreen,byteBlue);
      }

      I will post my whole code when it’s fully finished – again, just on the off-chance others may benefit. I found most of it online so would be good to pass that on to others.

      ** ORIGINAL POST BELOW **

      Hi all,

      I’m trying to re-write some Arduino code I found online to use the FastLED library.

      My machine is an arcade cabinet with a set of WS2811 programmable LEDs running up both sides of the cab.

      I have set up my Left LEDs / Right LEDs and I’ve just set the whole strip to be the Back LEDs. This seems to work fine but I’ve noticed a problem with the colours.

      For instance, when I started Stranger Things Stranger Edition the ‘attract’ mode of LEDs that shimmers up the machine are blue (they should be red).

      If I open the “DOF Test Table” and drop a ball in the Red hole my LEDs go blue. The Green hole does nothing and the Blue hole is green. The white hole does nothing either.

      So…. I have a problem….. and I wondered if you could help…..

      I’m looking at the source code for DOF (TeensyStripController.cs) and I’ve found the UpdateOutputs function:

      protected override void UpdateOutputs(byte[] OutputValues)
      {
      if (ComPort == null)
      {
      throw new Exception("Comport is not initialized");
      }
      byte[] CommandData;
      byte[] AnswerData;
      int BytesRead;
      int SourcePosition = 0;
      for (int i = 0; i < 8; i++) { int NrOfLedsOnStrip = NumberOfLedsPerStrip; if (NrOfLedsOnStrip > 0)
      {
      int TargetPosition = i * NumberOfLedsPerChannel;
      CommandData = new byte[5] { (byte)'R', (byte)(TargetPosition >> 8), (byte)(TargetPosition & 255), (byte)(NrOfLedsOnStrip >> 8), (byte)(NrOfLedsOnStrip & 255) };

      ComPort.Write(CommandData, 0, 5);
      ComPort.Write(OutputValues, SourcePosition * 3, NrOfLedsOnStrip * 3);

      So this is sending an “R” to tell my Arduino code to get ready to receive something…

      It’s then sending two words containing the first LED and the Number of LEDs affected.

      It is then writing the “OutputValues” variable which, I’m presuming, contains the data needed to light the LEDs.

      So far so good…..

      My code deals with the two words (first LED, no. of LEDs) fine but now on to the “OutputValues”…

      My original code (that I found online) contains the following:

      word ReceiveWord() {
      while(!Serial.available()) {};
      word wordValue=Serial.read()<<8;
      while(!Serial.available()) {};
      wordValue=wordValue|Serial.read();
      return wordValue;
      }

      And I’ve converted this to use the CRGB Object in the FastLED library….

      int ReceiveColorData() {
      CRGB colorValue;
      while (!Serial.available()) {};
      colorValue.red = Serial.read();
      while (!Serial.available()) {};
      colorValue.green = Serial.read();
      while (!Serial.available()) {};
      colorValue.blue = Serial.read();
      return colorValue;
      }

      But I got to wondering how the Brightness is passed across?? And maybe the OutputValues aren’t just Red/Green/Blue ???

      I found “private void UpdaterThreadDoIt()” inside OutputControllerCompleteBase.cs but I’m not really understanding where the values come from or what format they are in?

      I wondered if someone could tell me in what format (or just detail how) the colour data is passed from DOF to the Arduino ??

      A big thanks for all your help.

      :-)

    Viewing 1 post (of 1 total)

    Forums are currently locked.

    ©2024 VPinBall.com

    Log in with your credentials

    Forgot your details?