点播P10显示行滚动功能,用于滚动字符串

时间:2017-08-18 22:47:49

标签: c++ c arrays

我正在开发用于P10点阵面板的c驱动程序。驱动程序在最多2个显示器上运行良好,但是当我尝试在道路上连接3个显示器时出现问题。

我将P10显示器设为二维阵列(如第一张图所示) 这是仅用于显示的数组。数组网站是greenDisplayRAM [16] [4]。我有2种颜色和2种不同的数组。 我正在使用的滚动功能是:

    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)&0x01;
            tam = greenDisplayRAM[(y2 * 4)][y1];
            tam = tam << 8;
            tam = tam + greenDisplayRAM[(y2 * 4) + 1][y1];
            tam = tam << 8;
            tam = tam + greenDisplayRAM[(y2 * 4) + 2][y1];
            tam = tam << 8;
            tam = tam + greenDisplayRAM[(y2 * 4) + 3][y1];

            tam = tam << 1;
            tam = tam + zeroBit;

            greenDisplayRAM[(y2 * 4) ][y1] = (long long) (tam >> 24)&0xFF;
            greenDisplayRAM[(y2 * 4) + 1][y1] = (long long) (tam >> 16)&0xFF;
            greenDisplayRAM[(y2 * 4) + 2][y1] = (long long) (tam >> 8)&0xFF;
            greenDisplayRAM[(y2 * 4) + 3][y1] = (long long) (tam & 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)&0x01;
            tam = redDisplayRAM[(y2 * 4)][y1];
            tam = tam << 8;
            tam = tam + redDisplayRAM[(y2 * 4) + 1][y1];
            tam = tam << 8;
            tam = tam + redDisplayRAM[(y2 * 4) + 2][y1];
            tam = tam << 8;
            tam = tam + redDisplayRAM[(y2 * 4) + 3][y1];

            tam = tam << 1;
            tam = tam + zeroBit;
            redDisplayRAM[(y2 * 4) ][y1] = (long long) (tam >> 24)&0xFF;
            redDisplayRAM[(y2 * 4) + 1][y1] = (long long) (tam >> 16)&0xFF;
            redDisplayRAM[(y2 * 4) + 2][y1] = (long long) (tam >> 8)&0xFF;
            redDisplayRAM[(y2 * 4) + 3][y1] = (long long) (tam & 0xFF);
            return owerFlow;
        }
        default:
        {
            return -1;
        }
    }
   }

这很有效。然后我连接了2个显示器并修改了上面的功能。新的功能行滚动是:

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)&0x01;
            tam = greenDisplayRAM[(y2 * 8)][y1];
            tam = tam << 8;
            tam = tam + greenDisplayRAM[(y2 * 8) + 1][y1];
            tam = tam << 8;
            tam = tam + greenDisplayRAM[(y2 * 8) + 2][y1];
            tam = tam << 8;
            tam = tam + greenDisplayRAM[(y2 * 8) + 3][y1];
            tam = tam << 8;
            tam = tam + greenDisplayRAM[(y2 * 8) + 4][y1];
            tam = tam << 8;
            tam = tam + greenDisplayRAM[(y2 * 8) + 5][y1];
            tam = tam << 8;
            tam = tam + greenDisplayRAM[(y2 * 8) + 6][y1];
            tam = tam << 8;
            tam = tam + greenDisplayRAM[(y2 * 8) + 7][y1];
            tam = tam << 1;
            tam = tam + zeroBit;

            greenDisplayRAM[(y2 * 8)][y1] = (long long) (tam >> 56)&0xFF;
            greenDisplayRAM[(y2 * 8) + 1][y1] = (long long) (tam >> 48)&0xFF;
            greenDisplayRAM[(y2 * 8) + 2][y1] = (long long) (tam >> 40)&0xFF;
            greenDisplayRAM[(y2 * 8) + 3][y1] = (long long) (tam >> 32)&0xFF;


            greenDisplayRAM[(y2 * 8) + 4][y1] = (long long) (tam >> 24)&0xFF;
            greenDisplayRAM[(y2 * 8) + 5][y1] = (long long) (tam >> 16)&0xFF;
            greenDisplayRAM[(y2 * 8) + 6][y1] = (long long) (tam >> 8)&0xFF;
            greenDisplayRAM[(y2 * 8) + 7][y1] = (long long) (tam & 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)&0x01;
            tam = redDisplayRAM[(y2 * 8)][y1];
            tam = tam << 8;
            tam = tam + redDisplayRAM[(y2 * 8) + 1][y1];
            tam = tam << 8;
            tam = tam + redDisplayRAM[(y2 * 8) + 2][y1];
            tam = tam << 8;
            tam = tam + redDisplayRAM[(y2 * 8) + 3][y1];
            tam = tam << 8;
            tam = tam + redDisplayRAM[(y2 * 8) + 4][y1];
            tam = tam << 8;
            tam = tam + redDisplayRAM[(y2 * 8) + 5][y1];
            tam = tam << 8;
            tam = tam + redDisplayRAM[(y2 * 8) + 6][y1];
            tam = tam << 8;
            tam = tam + redDisplayRAM[(y2 * 8) + 7][y1];
            tam = tam << 1;
            tam = tam + zeroBit;

            redDisplayRAM[(y2 * 8)][y1] = (long long) (tam >> 56)&0xFF;
            redDisplayRAM[(y2 * 8) + 1][y1] = (long long) (tam >> 48)&0xFF;
            redDisplayRAM[(y2 * 8) + 2][y1] = (long long) (tam >> 40)&0xFF;
            redDisplayRAM[(y2 * 8) + 3][y1] = (long long) (tam >> 32)&0xFF;


            redDisplayRAM[(y2 * 8) + 4][y1] = (long long) (tam >> 24)&0xFF;
            redDisplayRAM[(y2 * 8) + 5][y1] = (long long) (tam >> 16)&0xFF;
            redDisplayRAM[(y2 * 8) + 6][y1] = (long long) (tam >> 8)&0xFF;
            redDisplayRAM[(y2 * 8) + 7][y1] = (long long) (tam & 0xFF);

            return owerFlow;
        }
        default:
        {
            return -1;
        }
    }
   }

然后我尝试连接第3个显示器,但我之前用于行滚动功能的逻辑在这里不起作用。 3个显示器的阵列如图所示。

想法是:linescroll函数获取字节[11] [0]并将其向左移位一位,并添加需要在零位上显示的下一位。将字节向左移动意味着该位将添加到[10] [0]的末尾,等等 我调用函数的方式:

for (i = 0; i < 96; i++) { // for all columns 32 per display 3 display 96 columns
    for (w = 0; w < 16; w++) { //for all line in the display
       lineScroll(w,0, Green);
    }
__delay_ms(30);
}

因此,对于显示器具有的16个不同的行,该函数被调用16次,并且加上我们需要移动咬合的次数(在示例中3 * 32(P10具有32个列)) 你能否告诉我一些关于如何为n个显示器工作的想法?

我会很感激。

0 个答案:

没有答案