void main(void) { int offset; int ret; int i; DsDisplayBlockClear(0, 0, 240, 120); DsPrintf(20,0,16,"Looking up memo..."); /* Read each chunk of data from the memo */ offset = 0; for (i=0; i<NR_CHUNKS; i++) { int len = strlen(pp_file_data[i]); char buf[512]; memset(buf, 0, 512); if ( (ret = read_memo(FILENAME, buf, offset, len)) >= 0) { char str[NAME_SIZE]; int j; /* Success! Display the data and the length of the memo */ DsDisplayBlockClear(0, 40, 240, 11); DsPrintf(10,40,32,"Read OK, length: "); itoa(str, offset+len); DsPrintf(100,40,32, str); DsDisplayBlockClear(0, 110, 240, 11); DsPrintf(10,110,32, buf); /* Verify that the data matches the input */ for (j=0; j<len; j++) { if (buf[j] != *(pp_file_data[i]+j)) { DsDisplayBlockClear(0, 40, 240, 11); DsPrintf(10,40,32,"Data not consistent:"); goto out; } } } else { /* Failure! */ DsDisplayBlockClear(0, 40, 240, 11); switch (ret) { case -1: DsPrintf(10,40,32,"Read error DbOpen"); break; case -2: DsPrintf(10,40,32,"Read error DbReadText"); break; case -3: DsPrintf(10,40,32,"Read error DbReadField"); break; case -4: DsPrintf(10,40,32,"Read error DbFindRecord"); break; case -5: DsPrintf(10,40,32,"Read error strcmp"); break; default: break; } } offset+=len; } out: /* Cleanup after the app */ wait_anykey(); DsEventClear(); DsDisplayBlockClear(0, 0, 240, 120); DsAddinTerminate(); }
static void pwm_error(void) { lcd_locate(0, LCD_LINES - 2); lcd_puts_P(PSTR("Error:PWM controller\nnot found")); wait_anykey(); }