Geetings,我试图从头文件(.h)中读取字符串文件到 arduino。它的编译很好,但我不能调用字符串。当我串行打印字符串时,显示器上只会出现乱码。这是我的arduino代码:
#include <epd4in2.h>
#include <epdif.h>
#include <epdpaint.h>
#include <fonts.h>
#include <SPI.h>
#include "epd4in2.h"
#include "imagedata.h"
#include "epdpaint.h"
#include "list.h"
#define COLORED 0
#define UNCOLORED 1
String test1;
String test2;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial.print("port test");
Epd epd;
if (epd.Init() != 0) {
Serial.println("e-Paper init failed");
return;
}
test1 = String(DATA_1[0]);\
Serial.println(test1);
test2 = String(DATA_1[1]);
Serial.println(test2);
/* This clears the SRAM of the e-paper display */
epd.ClearFrame();
/* Due to RAM not enough in Arduino UNO, a frame buffer is not allowed. */
unsigned char image[1500];
Paint paint(image, 400, 28); //width should be the multiple of 8
paint.Clear(UNCOLORED);
paint.DrawStringAt(0, 0, "test1", &Font24, COLORED);
epd.SetPartialWindow(paint.GetImage(), 100, 40, paint.GetWidth(),
paint.GetHeight());
paint.Clear(COLORED);
paint.DrawStringAt(100, 2, "test2", &Font24, UNCOLORED);
epd.SetPartialWindow(paint.GetImage(), 0, 64, paint.GetWidth(),
paint.GetHeight());
/* This displays the data from the SRAM in e-Paper module */
epd.DisplayFrame();
/* Deep sleep */
epd.Sleep();
}
void loop() {
// put your main code here, to run repeatedly:
}
这里是 .h 文件中的数据:
extern const String DATA_1[] PROGMEM = { "bat", "2244"};
extern const String DATA_2[] PROGMEM = { "bmp", "15662"};
extern const String DATA_3[] PROGMEM = { "docx", "16670"};
extern const String DATA_4[] PROGMEM = { "jpg", "150645"};
extern const String DATA_5[] PROGMEM = { "mp3", "9882324"};
extern const String DATA_6[] PROGMEM = { "txt", "807"};
extern const String DATA_7[] PROGMEM = { "url", "118"};
我使用 .bat 脚本创建了这个列表。
我对此很陌生,因此将不胜感激。亲切的问候路易吉