Black Lives Matter - Action and Equality. ... Adafruit joins the Stop Hate for Profit campaign.
0

Fadecandy Scrolling Text Example Displays As Mirrored
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Fadecandy Scrolling Text Example Displays As Mirrored

by dmairq on Tue Dec 10, 2019 1:37 pm

I'm trying to use Fadecandy to display some scrolling text. I can get it to work however it shows up on the pixel array as if it's mirrored with each letter flipped. I've searched the internet and these forums but cannot figure out how to fix or why it's happening. Watching a working example on youtube (DRUPAL) the code I'm using is the same but his shows properly while mine is flipped so each individual letter is backward like I'm seeing it in a mirror... Any suggestions?

dmairq
 
Posts: 5
Joined: Wed Sep 05, 2018 3:27 pm

Re: Fadecandy Scrolling Text Example Displays As Mirrored

by dmairq on Tue Dec 17, 2019 1:51 pm

Answering my own question in case anyone runs into this. I finally found a hint from one similar issue on the google fade candy forum.

https://groups.google.com/forum/#!searchin/fadecandy/text$20mirror%7Csort:date/fadecandy/kvtNQ02uYdM/AJBQ8EK-EwAJ

I have no idea why this needs to be done but the fix for me was to use the suggestion of an "x-flipped (negative)".

This line of code flipped my mirrored text so it displayed correctly. The sixth argument (0-spacing) did the trick. (Note that this line is not using ledGrid8x8 but rather ledGrid. ledGrid8x8 does call ledGrid in the OPC code but the needed argument isn't present. )

Code: Select all | TOGGLE FULL SIZE
  opc.ledGrid(0, 8, 8, width/2,  height/2, 0 - spacing, spacing, 0, true);


So in summary, I modified the example grid24x8z_text and commented out the extra 8x8 grids down to one 8x8 and set up the grid using the negative ledSpacing argument of ledGrid.

Code: Select all | TOGGLE FULL SIZE
OPC opc;
PFont f;
PShader blur;

void setup()
{
  size(640, 360, P2D);

  // Horizontal blur, from the SepBlur Processing example
  blur = loadShader("blur.glsl");
  blur.set("blurSize", 50);
  blur.set("sigma", 8.0f);
  blur.set("horizontalPass", 1);

  // Connect to the local instance of fcserver. You can change this line to connect to another computer's fcserver
  opc = new OPC(this, "candypi.local", 7890);

  // Map an 8x8 grid of LEDs to the center of the window, scaled to take up most of the space
  float spacing = height / 16.0;
  // opc.ledGrid8x8(0, width/2,  height/2, spacing, 0, true);

  // This line flipped mirrored text allowing it to display correctly.  The sixth argument (0-spacing) did the trick.  Note it's not
  // ledGrid8x8 which calls ledGrid in the OPC code.
  opc.ledGrid(0, 8, 8, width/2,  height/2, 0 - spacing, spacing, 0, true);
 
  // Put two more 8x8 grids to the left and to the right of that one.
  // opc.ledGrid8x8(64, width/2 - spacing * 8, height/2, spacing, 0, true);
  // opc.ledGrid8x8(128, width/2 + spacing * 8, height/2, spacing, 0, true);

  // Create the font
  f = createFont("Futura", 200);
  textFont(f);
}

void scrollMessage(String s, float speed)
{
  int x = int( width + (millis() * -speed) % (textWidth(s) + width) );
 
 
  text(s, x, 250); 
  //popMatrix();
 
   
}

void draw()
{
 
  background(0);
 
  fill(190, 50, 255);
  scrollMessage("WORKING!", 0.05);
 
  filter(blur);
 
}


dmairq
 
Posts: 5
Joined: Wed Sep 05, 2018 3:27 pm

Please be positive and constructive with your questions and comments.