ต้องการรวมโค้ดจอ 4.2 inch E-paper module b กับ SD Card Module เข้าด้วยกันครับ *เพิ่งเริ่มศึกษาด้านนี้*

สวัสดีครับ ผมใช้บอร์ด DEVIO NB-DEVKIT I กับโมดูลจอ 4.2 inch E-paper module b และ SD Card Module ที่มีการเชื่อมต่อแบบ SPI ครับพยามยามลองวิธีแก้ตามหลายๆตัวอย่างแล้วก็ไม่เป็นผลเลยครับ พอจะมีทางทำให้สามารถใช้งานร่วมกันได้ไหมครับ

#การต่อสายตามรูปนี้เลยครับ

#โค้ดครับ

/* Includes ------------------------------------------------------------------*/
#include "FS.h"
#include "SD.h"
#include "SPI.h"
/*--------E-Paper -----------*/
#include "DEV_Config.h"
#include "EPD.h"
#include "GUI_Paint.h"
#include "imagedata.h"
#include "SENSOR_BLACK.h"
#include "SENSOR_RED.h"
/*--------------------------*/
float temperature = 0.00;
float pressure = 0.00;
float voltage = 0.00;
float current = 0.00;
/*--------------------------*/

void setup() {
  Serial.begin(115200);
  
  if (!SD.begin()) {
    Serial.println("Card Mount Failed");
    return;
  }

/*แสดงรูปภาพโชว์ตอนเริ่มการทำงานของจอ E-Paper*/
  EpaperLogo();
  delay(500);

}

void loop() {

  temperature = float(random(0, 100));
  pressure = float(random(0, 100));
  voltage = float(random(0, 100));
  current = float(random(0, 100));


  Serial.print("----------------------------------------------\r\n");
  Serial.print("  Temperature = "); Serial.print(temperature); Serial.println(" C ");
  Serial.print("  Pressure = "); Serial.print(pressure); Serial.println(" Bar ");
  Serial.print("  Current = "); Serial.print(current); Serial.println(" A ");
  Serial.print("  Voltage = "); Serial.print(voltage); Serial.println(" V ");
  Serial.print("----------------------------------------------\r\n");


  epaperSensor();
  Serial.println("Show Data on E-paper........OK");

  sendSDcard();
  Serial.println("Send Data to SD card........OK");
  delay(5000);
}
[/codebyte]

#ส่วนฟังก์ชั่นต่างๆครับ
[codebyte language=cpp]
/*------------------------------------------- SD CARD -----------------------------------------------*/
void appendFile(fs::FS &fs, const char * path, const char * message) {
  Serial.printf("Appending to file: %s\n", path);

  File file = fs.open(path, FILE_APPEND);
  if (!file) {
    Serial.println("Failed to open file for appending");
    return;
  }
  if (file.print(message)) {
    Serial.println("Message appended");
  } else {
    Serial.println("Append failed");
  }
  file.close();
}
/*------------------------------------------------------------------------------------------------------*/
/*------------------------------------------ LOGO on E-PAPER---------------------------------*/
void EpaperLogo() {
  DEV_Module_Init();
  EPD_4IN2B_V2_Init();
  EPD_4IN2B_V2_Clear();
  DEV_Delay_ms(500);
  UBYTE *BlackImage, *RYImage; // Red or Yellow
  UWORD Imagesize = ((EPD_4IN2B_V2_WIDTH % 8 == 0) ? (EPD_4IN2B_V2_WIDTH / 8 ) : (EPD_4IN2B_V2_WIDTH / 8 + 1)) * EPD_4IN2B_V2_HEIGHT;
  if ((BlackImage = (UBYTE *)malloc(Imagesize)) == NULL) {
    printf("Failed to apply for black memory...\r\n");
    while (1);
  }
  if ((RYImage = (UBYTE *)malloc(Imagesize)) == NULL) {
    printf("Failed to apply for red memory...\r\n");
    while (1);
  }

  printf("NewImage:BlackImage and RYImage\r\n");
  Paint_NewImage(BlackImage, EPD_4IN2B_V2_WIDTH, EPD_4IN2B_V2_HEIGHT, 0, WHITE);
  Paint_NewImage(RYImage, EPD_4IN2B_V2_WIDTH, EPD_4IN2B_V2_HEIGHT, 0, WHITE);

  //Select Image
  Paint_SelectImage(BlackImage);
  Paint_Clear(WHITE);
  Paint_SelectImage(RYImage);
  Paint_Clear(WHITE);


#if 1   // show image for array    
  printf("1.show LOGO \r\n");
  EPD_4IN2B_V2_Display(gImage_4in2bc_b, gImage_4in2bc_ry);
  DEV_Delay_ms(3000);
#endif


}
/*------------------------------------------------------------------------------------------------------*/
/*------------------------------------ SENSOR DATA to SD card-----------------------------*/
void sendSDcard() {

  //============================================================
  String dataString = "";
  //============================================================
  dataString += "\n";
  dataString += String(temperature);
  dataString += " C ";
  dataString += ",";
  dataString += String(current);
  dataString += " A ";
  dataString += ",";
  dataString += String(voltage);
  dataString += " V ";
  dataString += ",";
  dataString += String(pressure);
  dataString += " Bar ";

  appendFile(SD, "/MP03_Report.CSV", dataString.c_str());
}

/*--------- SENSOR on E-PAPER ---------*/
void epaperSensor() {
  UBYTE *BlackImage, *RYImage;
  UWORD Imagesize = ((EPD_4IN2B_V2_WIDTH % 8 == 0) ? (EPD_4IN2B_V2_WIDTH / 8 ) : (EPD_4IN2B_V2_WIDTH / 8 + 1)) * EPD_4IN2B_V2_HEIGHT;
  if ((BlackImage = (UBYTE *)malloc(Imagesize)) == NULL) {
    printf("Failed to apply for black memory...\r\n");
    while (1);
  }
  if ((RYImage = (UBYTE *)malloc(Imagesize)) == NULL) {
    printf("Failed to apply for red memory...\r\n");
    while (1);
  }
#if 1
  //1. Black Image
  Paint_SelectImage(BlackImage);
  Paint_Clear(WHITE);
  //-------------------------------------------
  Paint_DrawBitMap(gImage_SENSOR_BLACK);
  //-------------------------------------------
  Paint_DrawString_EN(110, 20, "MP03.PROJECT", &Font24, WHITE, BLACK);
  Paint_DrawString_EN(50, 80, "Temperature(C):", &Font20, WHITE, BLACK);
  Paint_DrawString_EN(50, 140, "Pressure(Bar):", &Font20, WHITE, BLACK);
  Paint_DrawString_EN(50, 200, "Current(A):", &Font20, WHITE, BLACK);
  Paint_DrawString_EN(50, 260, "Voltage(V):", &Font20, WHITE, BLACK);
  Paint_DrawString_EN(355, 80, "C", &Font20, WHITE, BLACK);
  Paint_DrawString_EN(350, 140, "Bar", &Font20, WHITE, BLACK);
  Paint_DrawString_EN(350, 200, "A", &Font20, WHITE, BLACK);
  Paint_DrawString_EN(350, 260, "V", &Font20, WHITE, BLACK);

  Paint_DrawPoint(350, 80, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT);

  /*2.red image*/
  printf("  - 2.1 Draw red image\r\n");
  Paint_SelectImage(RYImage);
  Paint_Clear(WHITE);
  //-------------------------------------------
  Paint_DrawBitMap(gImage_SENSOR_RED);
  //-------------------------------------------
  Paint_DrawNum(270, 80, temperature, &Font20, BLACK, WHITE);  //////////////////////////////////////////////////
  Paint_DrawNum(280, 140, pressure, &Font20, BLACK, WHITE);
  Paint_DrawNum(280, 200, current, &Font20, BLACK, WHITE);
  Paint_DrawNum(280, 260, voltage, &Font20, BLACK, WHITE);

  printf("EPD_Display\r\n");
  EPD_4IN2B_V2_Display(BlackImage, RYImage);
  DEV_Delay_ms(5000);
#endif
}

ผมว่าสายไหนที่ใช้ พิน ซ้ำเช่น 18 เราย้ายได้นะครับ

ลองเปลี่ยนแล้วครับ ก็ยังไม่ได้ครับ :joy:

ย้ายโค้ตตามด้วยรึป่าวครับ

ลองเปลี่ยนขาแล้วแยกทดสอบแต่ละตัวก็ Compile ผ่านได้หมดครับ แต่พอรวมกันมัน Compile ผ่านแต่ไม่มีอะไรเกิดขึ้นเลยครับ