© Dialog Semiconductor 2008. All rights reserved.
All brand and product names are trademarks or service marks of their respective owners. Printed in Europe.
DA852x-UG02-608 Page 30 of 47
User Guide Release 2.0
DA852X E Ink Evaluation Kit
Display Controllers
Delay((standby_extend)/1000);
setbit(ONOFFB,0);
//now update old_state[] with current values
for (i=0;i<device;i++) {
old_state[i]=state[i];
}
return;
}
3.6.2
Creating a Hex string from state outputs
It may be convenient to treat long arrays as hex strings, for import and export purposes.
This function will convert between hex string and state array.
Input: state[] array as global variable
Output: OutputString as global variable
Globals: topplane,
device
void Create_String(void)
{
int i,val;
char string[MAX_OUTPUTS]="";
state[topplane]=0;
for (i=device-1;i>=3;i=i-4) {
val=state[i]*8+state[i-1]*4+state[i-2]*2+state[i-3];
sprintf(string,"%s%x",string,val);
}
strcpy (OutputString,string);
return ;
}
3.6.3
Decode a hex string to state array
It may be convenient to treat long arrays as hex strings, for import and export purposes.
This function will convert between hex string and state array.
Input: pointer to data string
Output: state[] array as global variable
Globals: topplane,
device
Int String_to_Array ( char *data)
{ int i,j,val,length;
int index;
char *poi=NULL;
length=strlen(data);
for (i=0;i<(length);i++){
poi=&data[length-1-i]; //rightmost character
sscanf (poi, "%1x", &val); //convert one character
// to decimal equivalent.
//decode variable into its constituent 4 bits
for (j=0;j<=3;j++){
index=4*i+j;
if ((index<=device-1)&(index>=0)&(index!=topplane))
state[index]=(val>>j)&0x01;
}
}
return 0;
}