본문 바로가기

SET_TEXT 명령어

Result

 

Example

void setup() {
    // put your setup code here, to run once:
    Serial.begin(115200);
    Serial2.begin(115200,SERIAL_8N1, 18, 19);
    // put your main code here, to run repeatedly:
    char * text = "날씨\n맑음"; //  디스플레이 출력 텍스트 : "날씨\n맑음"
    int textColor = 0x00ff0000; //  폰트 컬러 : red
    int bgColor = 0x00000000;   //  배경 색 : black
    uint8_t fontSize = 1;       //  폰트 크기 : 1
    uint8_t actionCmd = 0x00;   //  액션 : 디폴트 
    uint8_t pageNum = 1;        //  페이지 : 1
    short actionTime = 0x00;    //  액션 이동 시간 : 00

    uint8_t effectCmd = 0x00; //  효과 : 없음
    short  effectBorderTime  = 0x00;  //  Effect Border Blink 주기 
    int effectBorderColor  = 0;             //  Effect Border RGB 색상 
    uint8_t effectColorSpeed= 0x00;  // Effect Color effect 주기
    short  effectStarRainTime= 0x00;   // Effect  Star 속도 


    char * sendBuf;
    uint8_t textLen;
    int idx= 0;
    int sendBufLen;
    uint8_t cmd;
    uint8_t fontColor[3];
    uint8_t scrColor[3];
    textLen = strlen(text);
    sendBufLen = SIZE_PAGE + SIZE_TEXT_LEN + textLen + SIZE_FONT_SIZE + SIZE_FONT_COLOR + SIZE_BG_COLOR + SIZE_ACTION_CMD + SIZE_ACTION_TIME

                              +SIZE_EFFECT_PACKET;
    sendBuf = (char*)malloc(sendBufLen); 

    fontColor[0] = (uint8_t) (((textColor & 0x00ff0000) >> 16) / 8);  // font color - red
    fontColor[1] = (uint8_t) (((textColor & 0x0000ff00) >> 8) / 8);   // font color - blue
    fontColor[2] = (uint8_t) (((textColor & 0x000000ff) >> 0) / 8);   // font color - blue
    scrColor[0] = (uint8_t) (((bgColor & 0x00ff0000) >> 16) / 8);     // screen color - red
    scrColor[1] = (uint8_t) (((bgColor & 0x0000ff00) >> 8) / 8);      // screen color - blue
    scrColor[2] = (uint8_t) (((bgColor & 0x000000ff) >> 0) / 8);      // screen color - blue

    sendBuf[idx++] = pageNum;            
    sendBuf[idx++] = textLen;            

    for (int i = 0; i <textLen; i++) {
        sendBuf[idx++] = text[i];
    }
    sendBuf[idx++] = fontSize;           
    sendBuf[idx++] = fontColor[0];       
    sendBuf[idx++] = fontColor[1];       
    sendBuf[idx++] = fontColor[2];       
    sendBuf[idx++] = scrColor[0];      
    sendBuf[idx++] = scrColor[1];       
    sendBuf[idx++] = scrColor[2];       
    sendBuf[idx++] = actionCmd;
    sendBuf[idx++] = (actionTime & 0x0000ff00 >> 8);
    sendBuf[idx++] = (actionTime & 0x000000ff); 



    sendBuf[idx++] = (effectCmd& 0x000000ff); 
    sendBuf[idx++] = (effectBorderTime & 0x0000ff00 >> 8); 
    sendBuf[idx++] = (effectBorderTime & 0x000000ff); 
    sendBuf[idx++] = (effectBorderColor & 0x00ff0000) >> 16) / 8);
    sendBuf[idx++] = (effectBorderColor & 0x0000ff00) >> 8) / 8);
    sendBuf[idx++] = (effectBorderColor & 0x000000ff) >> 0) / 8);
    sendBuf[idx++] = effectColorSpeed; 
    sendBuf[idx++] = effectStarRainTime & 0x0000ff00 >> 8); 
    sendBuf[idx++] = effectStarRainTime & 0x000000ff); 


    cmd = (uint8_t)SET_TEXT;
    transmit_data(cmd, (char*)sendBuf, sendBufLen);
    free(sendBuf);
}




Code Download