2009/3/4 David VanHorn <d...@mobilefusioninc.com>: > so manually creating the table with a spreadsheet would be one way, though > icky. > I'm hoping there's a way to have the compiler generate it for me?
Use COG http://nedbatchelder.com/code/cog/ for generating tables in your source There is example - cog generate table for ADC values for 5 jumpers with weighted resistors and one resistor to ground. // table.cog // C source with cog scripts // this file must be edited in project #include <avr/io.h> #include <avr/pgmspace.h> uint8_t get_options() { const uint16_t level_table[] PROGMEM = { // COG will generate table content here /*[[[cog rground = 6.8 resistors = [160.0, 82.0, 39.0, 20.0, 10.0] nres = len(resistors) code = 0 for i in range(1,2**nres) : rpar = 0 for k in range(nres) : if i & (1<<k) : rpar += 1 / resistors[k] prevcode, code = code, 1024.0 * rground / (1.0/rpar + rground) cog.outl(' %d,' % round( (prevcode+code)/2 ) ) ]]]*/ //[[[end]]] }; uint16_t value = get_adc_average(ADC_OPTIONS,2); return search_level( value, jumper_levels, sizeof(jumper_levels)/sizeof(jumper_levels[0])); } # makefile rule for generating intermediate C-files from cog-files COG = python c:/bin/cog/scripts/cog.py %.c : %.cog echo ==== make $@ from $< ; $(COG) $< >$@ table.o must be included in obj-file list of project OR table.c must be included in CSRC list for automatic (re)generation table.c from table.cog -- wbr, ReAl _______________________________________________ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list