【发布时间】:2013-04-09 22:37:53
【问题描述】:
我使用 TLC5940 和移位寄存器制作了一个 24 x 15 LED 矩阵,在 Arduino Due 上运行。
首先,我想打印一个 ASCII 字符,例如。 'A' 直接显示。
所以我在 PROGMEM 中存储了一个字体数组,使用 a link I found:
PROGMEM prog_uchar font[][5] = {
{0x00,0x00,0x00,0x00,0x00}, // 0x20 32
{0x00,0x00,0x6f,0x00,0x00}, // ! 0x21 33
...
{0x08,0x14,0x22,0x41,0x00}, // < 0x3c 60
{0x14,0x14,0x14,0x14,0x14}, // = 0x3d 61
{0x00,0x41,0x22,0x14,0x08}, // > 0x3e 62
{0x02,0x01,0x51,0x09,0x06}, // ? 0x3f 63
etc.
现在,奇怪的是,一切几乎都可以正常工作,但略有变化。 例如,'>' 变成这样:
00000000 --> 00001000
01000001 --> 00000000
00100010 --> 01000001
00010100 --> 00100010
00001000 --> 00010100
所以我认为这是一个指针边界问题。可能是我看了太久,不知道!
这是相关代码,我在其中硬编码了“
unsigned char testgt[] = {0x00,0x41,0x22,0x14,0x08};
for (int iterations = 0; iterations < time; iterations++)
{
unsigned char indexOfWidth = 0;
unsigned char indexOfHeight = 0;
for (int col = x; col < x + charWidth; col++)
{
openCol(col);
Tlc.clear();
unsigned char b = testgt[indexOfWidth];//pgm_read_byte_near(font[ch] + indexOfWidth );
//Serial.println(b);
indexOfHeight = 0;
for (int ledNum = y; ledNum < y + charHeight; ledNum++)
{
if (b & (1 << indexOfHeight))
{
setRainbowSinkValue(ledNum, 100);
}
indexOfHeight++;
}
indexOfWidth++;
Tlc.update();
}
}
你能看出什么不对吗?最可能的问题是位操作,但这是有道理的...... b&1... b&2... b&4... b&8... b&16... b & 32... b&64... b & 128...
【问题讨论】:
标签: c arduino bit-manipulation led