Modifying byte array for 7x28 display

hi!
I'm writing data to a flipdot board of size 7x28. This is done by sending a 3-byte length prefix, a 28-byte data and 1-byte suffix.

I get the board to display the first two lines of text. But I would like the text to rotate over the board and come back at the position it started in.

Does anybody know what is missing in my code? At this moment the r[0]=studio[i+j]; is not doing anything.

when I use r[0]=random(128) it displays 28 times a scattered field over the display.

Thanks already!

code:



// control pin
int txden = 8;

// data prefix
byte data_prefix[] = {0x80, 0x83, 0x15};

// data suffix
byte data_suffix[] = {0x8F};

// studio
byte studio[] = {B0000000, B0000000, B0000000, B0101100, B0101010, B0011010, B0000000, B0000010, B0111110, B0000010, B0000000, B0111110, B0100000, B0111110, B0000000, B0111110, B0100010, B0011100, B0000000, B0111110, B0000000, B0111110, B0100010, B0111110, B0000000, B0000000, B0000000, B0000000};

// designs
byte designs[] = {B0000000, B0111110, B0100010, B0011100, B0000000, B0111110, B0101010, B0101010, B0000000, B0101100, B0101010, B0011010, B0000000, B0111110, B0000000, B0111110, B0100010, B0111010, B0000000, B0111110, B0000010, B0111110, B0000000, B0101100, B0101010, B0011010, B0000000, B0000000};


void setup() {
  // put your setup code here, to run once:
Serial.begin(57600);  
    pinMode(txden, OUTPUT);
    digitalWrite(txden, HIGH); // master

    Serial.write(data_prefix, 3);
    Serial.write(designs, 28);
    Serial.write(data_suffix, 1);
    delay(1000);

    Serial.write(data_prefix, 3);
    Serial.write(studio, 28);
    Serial.write(data_suffix, 1);
    delay(1000);

    int i,j;
    byte r[]={0};
    for (j=0;j<=28;j++){
    Serial.write(data_prefix,3);
    for (i=0;i<28;i++){
      r[0]=studio[i+j];
      //r[0]=random(128);
      Serial.write(r, 1);
      }
      Serial.write(data_suffix,1);
      delay(250);
    }
}

void loop() {
  // put your main code here, to run repeatedly:

}

byte r[]={0};

Why has the r array only got a single element ?

Hi Bob
Because it gets updated for 28 times. One byte represents the dot pattern for one of the 28 columns.
So in the end it writes the 3-byte prefix, 28 x 1 byte data , 1-byte suffix.

But maybe this can be done more efficiently?

Are you saying that the r array holds more than a single value at a time or that it only holds a single value at a time ?

If the former then it does not need to be an array whereas if the latter then it needs to have more elements and when saving data to them the index needs to be correct rather than always zero

Hi bob yes it holds a single value, and directly writes the value to the display for each 28 times in the forloop.

Then it does not need to be an array, but that is not the real problem

Take a look at

r[0]=studio[i+j];

How many elements does the studio array have ?

What is the range of values that i+j will result in ?

Yeah the range is the problem that I can't figure out.

I want the byte at i to be the previous value of i+1 (the element in the studio array, when rotating left). But the one at i=1 must go to i=28 then.

The studio array has 28 elements, but the rotating part of the indexes I'm stuck with.

are you saying you want to scroll the text vertically, STUDIO slowly disappearing from the top of the display whilst DESIGN enters at the bottom or do you want STUDIO to be shifted LEFT column by column whilst DISPLAY enters from the RIGHT side ?

// control pin
const int txden = 8;

// data
byte data[] = {
  0x80, 0x83, 0x15, //prefix
  0,0,0,0,0,0,0, // dot data
  0,0,0,0,0,0,0, // dot data
  0,0,0,0,0,0,0, // dot data
  0,0,0,0,0,0,0, // dot data
  0x8F // suffix
};

// studio designs
const byte studioDesigns[] = {B0000000, B0000000, B0000000, B0101100, B0101010, B0011010, B0000000, B0000010, B0111110, B0000010, B0000000, B0111110, B0100000, B0111110, B0000000, B0111110, B0100010, B0011100, B0000000, B0111110, B0000000, B0111110, B0100010, B0111110, B0000000, B0000000, B0000000, B0000000, B0000000, B0000000,
B0000000, B0111110, B0100010, B0011100, B0000000, B0111110, B0101010, B0101010, B0000000, B0101100, B0101010, B0011010, B0000000, B0111110, B0000000, B0111110, B0100010, B0111010, B0000000, B0111110, B0000010, B0111110, B0000000, B0101100, B0101010, B0011010, B0000000, B0000000,
B0000000, B0000000};

int pos;

void setup() {
    Serial.begin(57600);  
    pinMode(txden, OUTPUT);
    digitalWrite(txden, HIGH); // master
}

void loop() {
  for (int k=3; k<30; k++) data[k] = data[k+1]; //scroll dot data to left
  data[30] = studioDesigns[pos]; //insert next dots from message
  Serial.write(data, 32); //update display
  pos++; //move to next dots from message
  if (pos >= sizeof(studioDesigns)) pos = 0;
  delay(250);
}
1 Like

Hi,

I mean to have the text scrolled horizontally, right to left for example.

Thank you Paul, this is what I was looking for!

1 Like

That's great to hear. It's important to me that you learn something from the code I gave you, so please try to read and understand it and ask any questions.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.