Merge remote-tracking branch 'origin/next' into kilrah/Bootloader
Conflicts: radio/src/Makefile
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
#!/bin/env python
|
||||
|
||||
import sys, glob
|
||||
|
||||
string = sys.argv[1]
|
||||
translation = sys.argv[2]
|
||||
after = sys.argv[3]
|
||||
|
||||
def addLine(filename, newline):
|
||||
print filename, newline
|
||||
lines = file(filename, 'r').readlines()
|
||||
for i, line in enumerate(lines):
|
||||
if after in line:
|
||||
lines.insert(i+1, newline + '\n')
|
||||
break
|
||||
file(filename, 'w').writelines(lines)
|
||||
|
||||
def modifyTranslations():
|
||||
for filename in ['translations/en.h'] + glob.glob('translations/*.h.txt'):
|
||||
newline = "#define " + string + " "*(23-len(string)) + '"' + translation + '"'
|
||||
addLine(filename, newline)
|
||||
|
||||
def modifyDeclaration():
|
||||
newline = "extern const pm_char S" + string + "[];"
|
||||
filename = "translations.h"
|
||||
addLine(filename, newline)
|
||||
|
||||
def modifyDefinition():
|
||||
newline = "const pm_char S" + string + "[] PROGMEM = " + string + ";"
|
||||
filename = "translations.cpp"
|
||||
addLine(filename, newline)
|
||||
|
||||
modifyTranslations()
|
||||
modifyDeclaration()
|
||||
modifyDefinition()
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
#!/bin/env python
|
||||
|
||||
SIGN_BIT = (0x80) # Sign bit for a A-law byte.
|
||||
QUANT_MASK = (0xf) # Quantization field mask.
|
||||
SEG_SHIFT = (4) # Left shift for segment number.
|
||||
SEG_MASK = (0x70) # Segment field mask.
|
||||
BIAS = (0x84) # Bias for linear code.
|
||||
|
||||
def alaw2linear(a_val):
|
||||
a_val ^= 0x55
|
||||
|
||||
t = a_val & QUANT_MASK
|
||||
seg = (a_val & SEG_MASK) >> SEG_SHIFT
|
||||
if (seg):
|
||||
t = (t + t + 1 + 32) << (seg + 2)
|
||||
else:
|
||||
t = (t + t + 1 ) << 3
|
||||
|
||||
if a_val & SIGN_BIT:
|
||||
return t
|
||||
else:
|
||||
return -t
|
||||
|
||||
def ulaw2linear(u_val):
|
||||
# Complement to obtain normal u-law value.
|
||||
u_val = ~u_val
|
||||
|
||||
# Extract and bias the quantization bits. Then
|
||||
# shift up by the segment number and subtract out the bias.
|
||||
t = ((u_val & QUANT_MASK) << 3) + BIAS
|
||||
t <<= (u_val & SEG_MASK) >> SEG_SHIFT
|
||||
|
||||
if u_val & SIGN_BIT:
|
||||
return (BIAS - t)
|
||||
else:
|
||||
return (t - BIAS)
|
||||
|
||||
def pcmTable(fn):
|
||||
result = []
|
||||
for i in range(256):
|
||||
result.append(fn(i))
|
||||
return result
|
||||
|
||||
def tableToString(name, table):
|
||||
result = 'const int16_t ' + name + '[256] = { '
|
||||
result += ', '.join([str(i) for i in table])
|
||||
result += ' };'
|
||||
return result
|
||||
|
||||
print tableToString('alawTable', pcmTable(alaw2linear))
|
||||
print tableToString('ulawTable', pcmTable(ulaw2linear))
|
||||
@@ -0,0 +1,29 @@
|
||||
#!/bin/env python
|
||||
|
||||
import math
|
||||
|
||||
samples = 1024
|
||||
amplitudes = (32000, 0, 4000, 0, 4000)
|
||||
|
||||
max = 0
|
||||
min = 0
|
||||
|
||||
for i in range(samples):
|
||||
sample = 0.0
|
||||
for harmonic, amplitude in enumerate(amplitudes):
|
||||
sample += math.sin(math.pi*2*i*(harmonic+1)/samples) * amplitude / 2
|
||||
sample = int(sample)
|
||||
if sample > max:
|
||||
max = sample
|
||||
elif sample < min:
|
||||
min = sample
|
||||
print "%d," % sample,
|
||||
if i % 10 == 9:
|
||||
print
|
||||
|
||||
print
|
||||
print 'Range is:', min, max
|
||||
|
||||
if max > 32767 or min < -32768:
|
||||
print "Invalid range!"
|
||||
|
||||
+20
-2
@@ -40,6 +40,13 @@ translations = {'cz': [('\\200', u'á'),
|
||||
'es': [('\\200', u'Ñ'),
|
||||
('\\201', u'ñ')],
|
||||
|
||||
'fi': [('\\200', u'å'),
|
||||
('\\201', u'ä'),
|
||||
('\\202', u'ö'),
|
||||
('\\203', u'Å'),
|
||||
('\\204', u'Ä'),
|
||||
('\\205', u'Ö')],
|
||||
|
||||
'fr': [('\\200', u'é'),
|
||||
('\\201', u'è'),
|
||||
('\\202', u'à'),
|
||||
@@ -99,6 +106,11 @@ translations = {'cz': [('\\200', u'á'),
|
||||
('\\203', u'Å'),
|
||||
('\\204', u'Ä'),
|
||||
('\\205', u'Ö')],
|
||||
|
||||
'en': [],
|
||||
|
||||
'all': [('\\306', u'Δ')],
|
||||
|
||||
}
|
||||
|
||||
# Take care of command line options
|
||||
@@ -112,7 +124,7 @@ args = parser.parse_args()
|
||||
if args.language not in translations:
|
||||
parser.error(args.language + ' is not a supported language. Try one of the supported ones: ' + str(translations.keys()))
|
||||
system.exit()
|
||||
|
||||
|
||||
# Read the input file into a buffer
|
||||
in_file = codecs.open( args.input, "r", "utf-8" )
|
||||
text = in_file.read()
|
||||
@@ -124,7 +136,13 @@ for before, after in translations[args.language]:
|
||||
text = text.replace(before, after)
|
||||
else:
|
||||
text = text.replace(after, before)
|
||||
|
||||
|
||||
for before, after in translations["all"]:
|
||||
if args.reverse:
|
||||
text = text.replace(before, after)
|
||||
else:
|
||||
text = text.replace(after, before)
|
||||
|
||||
# Write the result to a temporary file
|
||||
out_file = codecs.open(args.output, 'w', 'utf-8')
|
||||
out_file.write( text )
|
||||
|
||||
+2
-2
@@ -137,7 +137,7 @@ def ttsEn():
|
||||
"amp", "amps",
|
||||
"meter per second", "meters per second",
|
||||
"", "",
|
||||
"kilometer per hour","kilometers per hour",
|
||||
"kilometer per hour", "kilometers per hour",
|
||||
"meter", "meters",
|
||||
"degree", "degrees",
|
||||
"percent", "percent",
|
||||
@@ -146,7 +146,7 @@ def ttsEn():
|
||||
"watt", "watts",
|
||||
"db", "db",
|
||||
"foot", "feet",
|
||||
"knot", "knots",
|
||||
"mile per hour", "miles per hour",
|
||||
"hour", "hours",
|
||||
"minute", "minutes",
|
||||
"second", "seconds",
|
||||
|
||||
Reference in New Issue
Block a user