【发布时间】:2017-07-24 14:07:26
【问题描述】:
我正在做一个只需要使用自定义字体的项目。我已经将所有拉丁字母定义为字节数组,因此我可以简单地将数组值复制到要写入的变量中。下面是我的代码的 sn-p。
void menuInit() {
byte customChar1[8];
byte customChar2[8];
byte customChar3[8];
byte customChar4[8];
byte customChar5[8];
byte customChar6[8];
byte customChar7[8];
byte customChar8[8];
for (int i = 0; i <= 7; i++) {
customChar1[i] = H[i];
customChar2[i] = E[i];
customChar3[i] = A[i];
customChar4[i] = T[i];
}
lcd.createChar(0, customChar1);
lcd.createChar(1, customChar2);
lcd.createChar(2, customChar3);
lcd.createChar(3, customChar4);
lcd.setCursor(0, 0);
lcd.write(byte(0));
lcd.write(byte(1));
lcd.write(byte(2));
lcd.write(byte(3));
for (int i = 0; i <= 7; i++) {
customChar1[i] = C[i];
customChar2[i] = O[i];
customChar3[i] = O[i];
customChar4[i] = L[i];
}
lcd.createChar(0, customChar1);
lcd.createChar(1, customChar2);
lcd.createChar(2, customChar3);
lcd.createChar(3, customChar4);
lcd.setCursor(0, 1);
lcd.write(byte(0));
lcd.write(byte(1));
lcd.write(byte(2));
lcd.write(byte(3));
Arduino LCD 文档说我需要在lcd.write() 中写入byte(int) 才能打印创建的自定义字符。但是,如果我这样做,我的 LCD 上会显示两行“COOL”。这可能是因为第一行和第二行都引用了相同的地址。有什么办法可以将字节值复制到其他地方并让它保持原样?
【问题讨论】:
-
在尝试提出更多问题之前,请阅读Why is “Can someone help me?” not an actual question?。
标签: arduino lcd custom-font