def write(self): gentools.print_header("BUILD_H") if self.ok: gentools.define_string("BUILD_REV", self.rev, maxwidth=self.STRING_LEN) gentools.define_string("BUILD_BRANCH", self.branch.split("/")[-1], maxwidth=self.STRING_LEN) gentools.define_int("BUILD_DIRTY", self.dirty) else: gentools.define_string("BUILD_REV", "UNKNOWN") gentools.define_string("BUILD_BRANCH", "UNKNOWN") gentools.define_int("BUILD_DIRTY", 0) gentools.define_int("BUILD_TIME", int(time.mktime(time.localtime()))) gentools.define_string("BUILD_TARGET", self.target, maxwidth=self.STRING_LEN) print gentools.define_int("BUILD_STRING_LEN", self.STRING_LEN) gentools.print_footer("BUILD_H")
print " static uint8_t avg_cpt = 0; /* Counter for averaging */\\" print " int16_t tmp_radio;\\" for c in nrmchans: value, min_pprz = norm_chan(c) print " tmp_radio = ppm_pulses[RADIO_%s] - SYS_TICS_OF_USEC(%s);\\" % ( c.function, c.neutral) print " rc_values[RADIO_%s] = %s;\\" % (c.function, value) print " Bound(rc_values[RADIO_%s], %s, MAX_PPRZ); \\\n\\" % (c.function, min_pprz) for c in avgchans: print " avg_rc_values[RADIO_%s] += ppm_pulses[RADIO_%s];\\" % (c.function, c.function) print " avg_cpt++;\\" print " if (avg_cpt == RC_AVG_PERIOD) {\\" print " avg_cpt = 0;\\" for c in avgchans: value, min_pprz = norm_chan(c) print " tmp_radio = avg_rc_values[RADIO_%s] / RC_AVG_PERIOD - SYS_TICS_OF_USEC(%s);\\" % ( c.function, c.neutral) print " rc_values[RADIO_%s] = %s;\\" % (c.function, value) print " avg_rc_values[RADIO_%s] = 0;\\" % c.function print " Bound(rc_values[RADIO_%s], %s, MAX_PPRZ); \\\n\\" % (c.function, min_pprz) print " rc_values_contains_avg_channels = TRUE;\\" print " }\\" print "}" gentools.print_footer(H)
def postamble(self, outfile): gentools.print_footer( self._get_include_guard(), outfile=outfile)
def postamble(self, outfile): gentools.print_footer(self.H, outfile=outfile)
print "#define NormalizePpm() {\\" print " static uint8_t avg_cpt = 0; /* Counter for averaging */\\" print " int16_t tmp_radio;\\" for c in nrmchans: value, min_pprz = norm_chan(c) print " tmp_radio = ppm_pulses[RADIO_%s] - SYS_TICS_OF_USEC(%s);\\" % (c.function, c.neutral) print " rc_values[RADIO_%s] = %s;\\" % (c.function, value) print " Bound(rc_values[RADIO_%s], %s, MAX_PPRZ); \\\n\\" % (c.function, min_pprz) for c in avgchans: print " avg_rc_values[RADIO_%s] += ppm_pulses[RADIO_%s];\\" % (c.function, c.function) print " avg_cpt++;\\" print " if (avg_cpt == RC_AVG_PERIOD) {\\" print " avg_cpt = 0;\\" for c in avgchans: value, min_pprz = norm_chan(c) print " tmp_radio = avg_rc_values[RADIO_%s] / RC_AVG_PERIOD - SYS_TICS_OF_USEC(%s);\\" % (c.function, c.neutral) print " rc_values[RADIO_%s] = %s;\\" % (c.function, value) print " avg_rc_values[RADIO_%s] = 0;\\" % c.function print " Bound(rc_values[RADIO_%s], %s, MAX_PPRZ); \\\n\\" % (c.function, min_pprz) print " rc_values_contains_avg_channels = TRUE;\\" print " }\\" print "}" gentools.print_footer(H)
def postamble(self, outfile): gentools.print_footer(self._get_include_guard(), outfile=outfile)