How the best form to Fill a Array Char, with 40 spaces ?
Im using this (bold in code) to concat, but I m afraid this not a good idea, because the system have no sufficient memory and processor to execute this rotine all times.
somebody, can say a better c ode ?
Code:
void EscreveDisplay (unsigned char *pMensagem, unsigned int pDelaySec){
unsigned char cDispPacote [52];
int iComDisplay = 2;
unsigned int iLims;
unsigned int iLenMsg, iLenCont, iContIndex;
int iBcc;
iDisplaySend = 1;
if (pDelaySec > 0)
Delay(pDelaySec * 1000);
iLims = 46;
cDispPacote [0] = 129;
cDispPacote [1] = 126;
cDispPacote [2] = iLims % 256;
cDispPacote [3] = iLims / 256;
cDispPacote [4] = 1 % 256;
cDispPacote [5] = 1 / 256;
cDispPacote [6] = 0 % 256;
cDispPacote [7] = 0 / 256;
cDispPacote [8] = 76;
cDispPacote [9] = 202;
iLenMsg = strlen (pMensagem);
if (iLenMsg > 40)
iLenMsg = 40;
if (iLenMsg < 40){
for(iLenCont=iLenMsg; iLenCont<40; iLenCont++)
strcat (pMensagem, ".");
}
for(iLenCont=0; iLenCont<40; iLenCont++){
iContIndex = iLenCont + 10;
cDispPacote [iContIndex] = pMensagem [iLenCont];
}
iBcc = cDispPacote [4];
cDispPacote [50] = iBcc;
cDispPacote [51] = '\0';
for(iContIndex=0; iContIndex<=51; iContIndex++){
ToCom (iComDisplay, cDispPacote[iContIndex]);
}
iDisplaySend=0;
}