5 def generate(outfile, tablename, tablelength, samplerate):
6 fout = open(os.path.expanduser(outfile),
"w")
7 fout.write(
'#ifndef ' + tablename +
'_H_' +
'\n')
8 fout.write(
'#define ' + tablename +
'_H_' +
'\n \n')
9 fout.write(
'#if ARDUINO >= 100'+
'\n')
10 fout.write(
'#include "Arduino.h"'+
'\n')
11 fout.write(
'#else'+
'\n')
12 fout.write(
'#include "WProgram.h"'+
'\n')
13 fout.write(
'#endif'+
'\n')
14 fout.write(
'#include "mozzi_pgmspace.h"'+
'\n \n')
15 fout.write(
'#define ' + tablename +
'_NUM_CELLS '+ str(len(values))+
'\n')
16 fout.write(
'#define ' + tablename +
'_SAMPLERATE '+ str(samplerate)+
'\n \n')
17 outstring =
'CONSTTABLE_STORAGE(int8_t) ' + tablename +
'_DATA [] = {' 19 for num
in range(tablelength):
20 outstring += str(num/32) +
", " 23 outstring = textwrap.fill(outstring, 80)
25 fout.write(
'\n \n #endif /* ' + tablename +
'_H_ */\n')
27 print "wrote " + outfile
29 generate(
"~/Desktop/phasor8192_uint8.h",
"phasor8192", 8192,
"8192")