New feature: Added sintables for aprs

aprs_dev
Richard Meadows 2015-03-30 15:50:47 +01:00
rodzic 860d339adb
commit 746a1d278e
3 zmienionych plików z 134 dodań i 0 usunięć

Wyświetl plik

@ -154,6 +154,11 @@ TAGFILES = $(SOURCES) $(shell $(CAT) $(OBJECTS:.o=.d) \
#
all: $(TARGET).elf etags
# Rule for generating sintable
sintable:
@$(ECHO) 'Generating ax25 lookup table...'
python tools/ax25_lookup/ax25_lookup.py > inc/ax25_sintable.h
# Rule for generating object and dependancy files from source files.
#
# Creates a directory in the output tree if nessesary. File is only

Wyświetl plik

@ -0,0 +1,67 @@
/**
* Autogenerated sine tables. See tools/ax25_lookup/ax25_lookup.py
*/
#ifndef AX25_SINTABLE_H
#define AX25_SINTABLE_H
#define AX25_SINTABLE_ORDER 8
#define AX25_SINTABLE_LENGTH 256
/**
* 1st quadrant sin lookup table for 1.6kHz deviation
*
* Length: 256
* Frequency Resolution: 7.805 Hz
*/
uint16_t sintable_256_1600hz[] = {
0, 1, 3, 4, 5, 6, 8, 9, 10, 11, 13, 14, 15, 16, 18,
19, 20, 21, 23, 24, 25, 26, 28, 29, 30, 31, 33, 34, 35, 36,
38, 39, 40, 41, 42, 44, 45, 46, 47, 49, 50, 51, 52, 53, 55,
56, 57, 58, 60, 61, 62, 63, 64, 65, 67, 68, 69, 70, 71, 73,
74, 75, 76, 77, 78, 80, 81, 82, 83, 84, 85, 87, 88, 89, 90,
91, 92, 93, 94, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,
108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122,
123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137,
138, 139, 140, 140, 141, 142, 143, 144, 145, 146, 147, 148, 148, 149, 150,
151, 152, 153, 154, 154, 155, 156, 157, 158, 158, 159, 160, 161, 162, 162,
163, 164, 165, 165, 166, 167, 168, 168, 169, 170, 170, 171, 172, 173, 173,
174, 175, 175, 176, 176, 177, 178, 178, 179, 180, 180, 181, 181, 182, 183,
183, 184, 184, 185, 185, 186, 186, 187, 187, 188, 188, 189, 189, 190, 190,
191, 191, 192, 192, 193, 193, 193, 194, 194, 195, 195, 195, 196, 196, 197,
197, 197, 198, 198, 198, 199, 199, 199, 199, 200, 200, 200, 201, 201, 201,
201, 202, 202, 202, 202, 202, 203, 203, 203, 203, 203, 203, 204, 204, 204,
204, 204, 204, 204, 204, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205,
205
};
/**
* 1st quadrant sin lookup table for 2.5kHz deviation
*
* Length: 256
* Frequency Resolution: 7.805 Hz
*/
uint16_t sintable_256_2500hz[] = {
0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 27,
29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
59, 61, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 85,
87, 89, 91, 93, 95, 97, 99, 100, 102, 104, 106, 108, 110, 112, 113,
115, 117, 119, 121, 123, 124, 126, 128, 130, 132, 133, 135, 137, 139, 140,
142, 144, 146, 148, 149, 151, 153, 154, 156, 158, 160, 161, 163, 165, 166,
168, 170, 171, 173, 175, 176, 178, 180, 181, 183, 184, 186, 188, 189, 191,
192, 194, 196, 197, 199, 200, 202, 203, 205, 206, 208, 209, 211, 212, 214,
215, 217, 218, 219, 221, 222, 224, 225, 226, 228, 229, 231, 232, 233, 235,
236, 237, 239, 240, 241, 243, 244, 245, 246, 248, 249, 250, 251, 253, 254,
255, 256, 257, 258, 260, 261, 262, 263, 264, 265, 266, 267, 268, 270, 271,
272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 282, 283, 284, 285,
286, 287, 288, 289, 290, 290, 291, 292, 293, 294, 294, 295, 296, 297, 297,
298, 299, 300, 300, 301, 302, 302, 303, 304, 304, 305, 305, 306, 307, 307,
308, 308, 309, 309, 310, 310, 311, 311, 312, 312, 313, 313, 313, 314, 314,
315, 315, 315, 316, 316, 316, 317, 317, 317, 317, 318, 318, 318, 318, 319,
319, 319, 319, 319, 319, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320,
320
};
#endif /* AX25_SINTABLE_H */

Wyświetl plik

@ -0,0 +1,62 @@
#!/bin/python
import numpy as np
import math
length = 256
deviation_f = 2500
def print_sintable(deviation_f):
f_resolution = 7.805347443
deviation = (deviation_f/f_resolution)
# Generate our sin table
quadrant_range = np.arange(0, np.pi/2, (np.pi/2)/length)
sintable = np.multiply(np.sin(quadrant_range), deviation)
# stringify
strings = [ "{0:0.0f}".format(x) for x in sintable ]
maxlen = max([ len(s) for s in strings ])
# stringify in equal parts
strings = [ "{0:>{width}.0f}".format(x, width=maxlen) for x in sintable ]
string = ", ".join(strings)
# lines
line_len = int(math.floor(78 / (maxlen+2))*(maxlen+2))
lines = [string[x:x+line_len].rstrip() for x in range(0, len(string), line_len)]
string = "\n ".join(lines)
print "/**"
print " * 1st quadrant sin lookup table for {0:0.1f}kHz deviation".format(deviation_f/1000.0)
print " *"
print " * Length: {0}".format(length)
print " * Frequency Resolution: {0:0.3f} Hz".format(f_resolution)
print " */"
print "uint16_t sintable_{0}_{1}hz[] = {{".format(length, deviation_f)
print " "+string
print "};"
print
print "/**"
print " * Autogenerated sine tables. See tools/ax25_lookup/ax25_lookup.py"
print " */"
print
print "#ifndef AX25_SINTABLE_H"
print "#define AX25_SINTABLE_H"
print
print
print "#define AX25_SINTABLE_ORDER {0:d}".format(int(math.log(length, 2)))
print "#define AX25_SINTABLE_LENGTH {0:d}".format(length)
print
print
print_sintable(1600)
print_sintable(2500)
print "#endif /* AX25_SINTABLE_H */"