title: Dot led P10 display line scroll function for scrolling string
body: <p>I am working on developing a driver in c for P10 dot led panel. The driver is working great with max 2 displays, but the problem occurred when I tried to connect 3 displays in a road.</p>
  
  <p>I made the P10 display as a 2 dimensional array (shown on the first picture).<br>
  This is the array for only 1 display. The array site is greenDisplayRAM [16][4] .I have 2 color and 2 different array.
  The scroll function I am using is: </p>
  
  <pre><code>    int lineScroll(unsigned int line, int zeroBit, LedColor LEDColor) {
      switch (LEDColor) {
          case Green:
          {
              unsigned long long tam = 0;
              unsigned int y1 = line % 4;
              unsigned int y2 = line / 4;
              int owerFlow;
              zeroBit = 1 - zeroBit;
  
              owerFlow = (greenDisplayRAM[(y2 * 4)][y1] / 128)&amp;0x01;
              tam = greenDisplayRAM[(y2 * 4)][y1];
              tam = tam &lt;&lt; 8;
              tam = tam + greenDisplayRAM[(y2 * 4) + 1][y1];
              tam = tam &lt;&lt; 8;
              tam = tam + greenDisplayRAM[(y2 * 4) + 2][y1];
              tam = tam &lt;&lt; 8;
              tam = tam + greenDisplayRAM[(y2 * 4) + 3][y1];
  
              tam = tam &lt;&lt; 1;
              tam = tam + zeroBit;
  
              greenDisplayRAM[(y2 * 4) ][y1] = (long long) (tam &gt;&gt; 24)&amp;0xFF;
              greenDisplayRAM[(y2 * 4) + 1][y1] = (long long) (tam &gt;&gt; 16)&amp;0xFF;
              greenDisplayRAM[(y2 * 4) + 2][y1] = (long long) (tam &gt;&gt; 8)&amp;0xFF;
              greenDisplayRAM[(y2 * 4) + 3][y1] = (long long) (tam &amp; 0xFF);
  
              return owerFlow;
          }
          case Red:
          {
              unsigned long long tam = 0;
              unsigned int y1 = line % 4;
              unsigned int y2 = line / 4;
              int owerFlow;
              zeroBit = 1 - zeroBit;
  
              owerFlow = (redDisplayRAM[(y2 * 4)][y1] / 128)&amp;0x01;
              tam = redDisplayRAM[(y2 * 4)][y1];
              tam = tam &lt;&lt; 8;
              tam = tam + redDisplayRAM[(y2 * 4) + 1][y1];
              tam = tam &lt;&lt; 8;
              tam = tam + redDisplayRAM[(y2 * 4) + 2][y1];
              tam = tam &lt;&lt; 8;
              tam = tam + redDisplayRAM[(y2 * 4) + 3][y1];
  
              tam = tam &lt;&lt; 1;
              tam = tam + zeroBit;
              redDisplayRAM[(y2 * 4) ][y1] = (long long) (tam &gt;&gt; 24)&amp;0xFF;
              redDisplayRAM[(y2 * 4) + 1][y1] = (long long) (tam &gt;&gt; 16)&amp;0xFF;
              redDisplayRAM[(y2 * 4) + 2][y1] = (long long) (tam &gt;&gt; 8)&amp;0xFF;
              redDisplayRAM[(y2 * 4) + 3][y1] = (long long) (tam &amp; 0xFF);
              return owerFlow;
          }
          default:
          {
              return -1;
          }
      }
     }
  </code></pre>
  
  <p>This was working great. Then I connected 2 displays and modified the function above. The new function line scroll is: </p>
  
  <pre><code>int lineScroll(unsigned int line, int zeroBit, LedColor LEDColor) {
      switch (LEDColor) {
          case Green:
          {
              unsigned long long tam = 0;
              unsigned int y1 = line % 4;
              unsigned int y2 = line / 4;
              int owerFlow;
              zeroBit = 1 - zeroBit;
  
              owerFlow = (greenDisplayRAM[(y2 * 8)][y1] / 128)&amp;0x01;
              tam = greenDisplayRAM[(y2 * 8)][y1];
              tam = tam &lt;&lt; 8;
              tam = tam + greenDisplayRAM[(y2 * 8) + 1][y1];
              tam = tam &lt;&lt; 8;
              tam = tam + greenDisplayRAM[(y2 * 8) + 2][y1];
              tam = tam &lt;&lt; 8;
              tam = tam + greenDisplayRAM[(y2 * 8) + 3][y1];
              tam = tam &lt;&lt; 8;
              tam = tam + greenDisplayRAM[(y2 * 8) + 4][y1];
              tam = tam &lt;&lt; 8;
              tam = tam + greenDisplayRAM[(y2 * 8) + 5][y1];
              tam = tam &lt;&lt; 8;
              tam = tam + greenDisplayRAM[(y2 * 8) + 6][y1];
              tam = tam &lt;&lt; 8;
              tam = tam + greenDisplayRAM[(y2 * 8) + 7][y1];
              tam = tam &lt;&lt; 1;
              tam = tam + zeroBit;
  
              greenDisplayRAM[(y2 * 8)][y1] = (long long) (tam &gt;&gt; 56)&amp;0xFF;
              greenDisplayRAM[(y2 * 8) + 1][y1] = (long long) (tam &gt;&gt; 48)&amp;0xFF;
              greenDisplayRAM[(y2 * 8) + 2][y1] = (long long) (tam &gt;&gt; 40)&amp;0xFF;
              greenDisplayRAM[(y2 * 8) + 3][y1] = (long long) (tam &gt;&gt; 32)&amp;0xFF;
  
  
              greenDisplayRAM[(y2 * 8) + 4][y1] = (long long) (tam &gt;&gt; 24)&amp;0xFF;
              greenDisplayRAM[(y2 * 8) + 5][y1] = (long long) (tam &gt;&gt; 16)&amp;0xFF;
              greenDisplayRAM[(y2 * 8) + 6][y1] = (long long) (tam &gt;&gt; 8)&amp;0xFF;
              greenDisplayRAM[(y2 * 8) + 7][y1] = (long long) (tam &amp; 0xFF);
  
              return owerFlow;
          }
          case Red:
          {
              unsigned long long tam = 0;
              unsigned int y1 = line % 4;
              unsigned int y2 = line / 4;
              int owerFlow;
              zeroBit = 1 - zeroBit;
  
              owerFlow = (redDisplayRAM[(y2 * 8)][y1] / 128)&amp;0x01;
              tam = redDisplayRAM[(y2 * 8)][y1];
              tam = tam &lt;&lt; 8;
              tam = tam + redDisplayRAM[(y2 * 8) + 1][y1];
              tam = tam &lt;&lt; 8;
              tam = tam + redDisplayRAM[(y2 * 8) + 2][y1];
              tam = tam &lt;&lt; 8;
              tam = tam + redDisplayRAM[(y2 * 8) + 3][y1];
              tam = tam &lt;&lt; 8;
              tam = tam + redDisplayRAM[(y2 * 8) + 4][y1];
              tam = tam &lt;&lt; 8;
              tam = tam + redDisplayRAM[(y2 * 8) + 5][y1];
              tam = tam &lt;&lt; 8;
              tam = tam + redDisplayRAM[(y2 * 8) + 6][y1];
              tam = tam &lt;&lt; 8;
              tam = tam + redDisplayRAM[(y2 * 8) + 7][y1];
              tam = tam &lt;&lt; 1;
              tam = tam + zeroBit;
  
              redDisplayRAM[(y2 * 8)][y1] = (long long) (tam &gt;&gt; 56)&amp;0xFF;
              redDisplayRAM[(y2 * 8) + 1][y1] = (long long) (tam &gt;&gt; 48)&amp;0xFF;
              redDisplayRAM[(y2 * 8) + 2][y1] = (long long) (tam &gt;&gt; 40)&amp;0xFF;
              redDisplayRAM[(y2 * 8) + 3][y1] = (long long) (tam &gt;&gt; 32)&amp;0xFF;
  
  
              redDisplayRAM[(y2 * 8) + 4][y1] = (long long) (tam &gt;&gt; 24)&amp;0xFF;
              redDisplayRAM[(y2 * 8) + 5][y1] = (long long) (tam &gt;&gt; 16)&amp;0xFF;
              redDisplayRAM[(y2 * 8) + 6][y1] = (long long) (tam &gt;&gt; 8)&amp;0xFF;
              redDisplayRAM[(y2 * 8) + 7][y1] = (long long) (tam &amp; 0xFF);
  
              return owerFlow;
          }
          default:
          {
              return -1;
          }
      }
     }
  </code></pre>
  
  <p>Then I tried to connect 3th display, but the logic that I used before for the line scroll function is not working here. 
  The array for 3 displays is shown in the picture.</p>
  
  <p>The idea was: the linescroll function to get the byte [11][0] and to shift it left for one bit, and to add the next bit that it needs to be shown on the zero bit. Shifting the byte to the left means that the bit will be added in the end of [10][0] and etc for the line
  The way I am calling the function: </p>
  
  <pre><code>for (i = 0; i &lt; 96; i++) { // for all columns 32 per display 3 display 96 columns
      for (w = 0; w &lt; 16; w++) { //for all line in the display
         lineScroll(w,0, Green);
      }
  __delay_ms(30);
  }
  </code></pre>
  
  <p>So the function is called 16 times for 16 different lines that the displays has, and plus that much times we need to shift the bite ( in the example 3*32 (P10 has 32 colums))
  Can you please give me some ideas of how to make this work for n number of displays? </p>
  
  <p>I would appreciate any idea.</p>