positive integer control Johannes Taelman BSD ctrl.axh
Indexed filename string combiner with some extra's: -checks the SDcard how many tables are saved using the same prefix (only as long as indices follow up, counter stops when it finds an unused index number). -seperate filename outputs for selected filename (for loading) and free filename (for saving) -wraps the index input so it can only select from the available indices. -3 extra load inputs: first index (normally index 000) last index (free index minus one, eg. index 011 if index 012 is empty, in other words, last one that you've saved) random index (randomly selects an index number from the available indices) Remco van der Most BSD table.axh
chibios/ext/fatfs/src/ff.h fatfs 0?cnt:1); I=i; int i0 = i/10; c[offset+2] = '0'+i-10*i0; i = i0; i0 = i/10; c[offset+1] = '0'+i-10*i0; i = i0; i0 = i/10; c[offset+0] = '0'+i-10*i0; outlet_autoload=1; } int trg=inlet_first||inlet_last||inlet_rnd; if(trg&&!first){ first=1; int i=0; if(inlet_last){ i=cnt-1; } else if(inlet_rnd){ i=(int32_t)((GenerateRandomNumber()>>6)%cnt); } I=i; int i0 = i/10; c[offset+2] = '0'+i-10*i0; i = i0; i0 = i/10; c[offset+1] = '0'+i-10*i0; i = i0; i0 = i/10; c[offset+0] = '0'+i-10*i0; outlet_autoload=1; }else if(!trg){first=0;} outlet_selected = &c[0]; outlet_free = &C[0]; disp_free=cnt; disp_sel=I;]]> save table to sdcard, added a "save ready" trigger. Useful if you need to halt another load/save until this one has finished. Johannes Taelman BSD table.axh chibios/ext/fatfs/src/ff.h fatfs 0) && !ntrig) { ntrig=1; FIL FileObject; FRESULT err; UINT bytes_written; codec_clearbuffer(); err = f_open(&FileObject, inlet_filename, FA_WRITE | FA_CREATE_ALWAYS); if (err != FR_OK) {report_fatfs_error(err,inlet_filename); return;} int rem_sz = sizeof(*attr_table.array)*attr_table.LENGTH; int offset = 0; while (rem_sz>0) { if (rem_sz>sizeof(fbuff)) { memcpy((char *)fbuff,(char *)(&attr_table.array[0]) + offset, sizeof(fbuff)); err = f_write(&FileObject, fbuff, sizeof(fbuff),&bytes_written); rem_sz -= sizeof(fbuff); offset += sizeof(fbuff); } else { memcpy((char *)fbuff,(char *)(&attr_table.array[0]) + offset, rem_sz); err = f_write(&FileObject, fbuff, rem_sz, &bytes_written); rem_sz = 0; } } if (err != FR_OK) report_fatfs_error(err,inlet_filename); err = f_close(&FileObject); if (err != FR_OK) report_fatfs_error(err,inlet_filename); outlet_ready=1; } else if (!(inlet_trig>0)) ntrig=0;]]> no -8 22 1936 1066