본문 바로가기

SET_COLOR_TEXT 명령어

Result

 

Example

SIZE_EFFECT_PACKETSIZE_EFFECT_PACKET
 
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 * colorTextGroup[2] = {"미세먼지\n","보통"};   //  디스플레이 출력 텍스트 : "미세먼지\n","보통"
    int textTotalLen = strlen(colorTextGroup[0]) + strlen(colorTextGroup[1]);  // 텍스트 길이 계산
    uint8_t fontSize = 1;   // 폰트 크기 : 1
    uint8_t actionCmd = 0x00;  // 액션 : 디폴트
    short actionTime = 0x00000; //  액션 이동 시간 : 0
    uint8_t saveCmdGap = 0;  //  플래시 저장 여부 : false
    uint8_t pageNum = 0;   //  페이지 : 0
    int chColor[2];  //  (미세먼지)폰트 컬러 : white
    chColor[0] = 0x00ffffff; //  (미세먼지)폰트 컬러 : white
    chColor[1] = 0x00ff0000; //  (보통)폰트 컬러 : red
    int bgColor = 0x00000000; //  배경 색 : black
    uint8_t textGroupCount = 2; //  텍스트 그룹 카운트: 2 ("미세먼지","보통")

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

    int idx = INIT_VALUE;
    int bufLen = (SIZE_PAGE + SIZE_BG_COLOR + SIZE_FONT_SIZE + SIZE_TEXT_GROUP_COUNT + SIZE_ACTION_CMD + SIZE_ACTION_TIME + 
SIZE_EFFECT_PACKET
 );
    bufLen += (textTotalLen);
    bufLen += (SIZE_FONT_COLOR * textGroupCount);
    bufLen += (SIZE_TEXT_LEN * textGroupCount);
    char * sendBuf = (char*) malloc (bufLen);
    sendBuf[idx++] = pageNum;
    //     BG Color
    sendBuf[idx++] = (uint8_t)(((bgColor & 0x00ff0000) >> 16) / 8);
    sendBuf[idx++] = (uint8_t)(((bgColor & 0x0000ff00) >> 8) / 8);
    sendBuf[idx++] = (uint8_t)(((bgColor & 0x000000ff) >> 0) / 8);
    sendBuf[idx++] = fontSize;
    sendBuf[idx++] = textGroupCount;
    //    Color Text Group 
    for (int i = 0; i < textGroupCount; i++) {
        sendBuf[idx++] = strlen(colorTextGroup[i]); // Color Group Text Size Send
        for (int j = 0; j <strlen(colorTextGroup[i]); j++) {
        sendBuf[idx++] = colorTextGroup[i][j];
        } 
        sendBuf[idx++] = (uint8_t)(((chColor[i] & 0x00ff0000) >> 16) / 8);
        sendBuf[idx++] = (uint8_t)(((chColor[i] & 0x0000ff00) >> 8) / 8);
        sendBuf[idx++] = (uint8_t)(((chColor[i] & 0x000000ff) >> 0) / 8);
    }

 
    uint8_t _cmd = (uint8_t)(SET_COLOR_TEXT + saveCmdGap);
    sendBuf[idx++] = actionCmd;
    sendBuf[idx++] = (uint8_t)((actionTime & 0x0000ff00) >> 8);
    sendBuf[idx++] = (uint8_t)(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); 
 
    transmit_data(_cmd, (char*)sendBuf, bufLen);
    free(sendBuf);


    }

Code Download