mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-21 15:25:36 +03:00
Minor code size reduction. Adding some const correctness.
This commit is contained in:
parent
138fd963a7
commit
947bb0d918
5 changed files with 15 additions and 11 deletions
|
@ -69,7 +69,7 @@ static void putchw(void *putp, putcf putf, int n, char z, char *bf)
|
||||||
putf(putp, ch);
|
putf(putp, ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tfp_format(void *putp, putcf putf, char *fmt, va_list va)
|
void tfp_format(void *putp, putcf putf, const char *fmt, va_list va)
|
||||||
{
|
{
|
||||||
char bf[12];
|
char bf[12];
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@ void init_printf(void *putp, void (*putf) (void *, char))
|
||||||
stdout_putp = putp;
|
stdout_putp = putp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tfp_printf(char *fmt, ...)
|
void tfp_printf(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list va;
|
va_list va;
|
||||||
va_start(va, fmt);
|
va_start(va, fmt);
|
||||||
|
@ -168,7 +168,7 @@ static void putcp(void *p, char c)
|
||||||
*(*((char **) p))++ = c;
|
*(*((char **) p))++ = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tfp_sprintf(char *s, char *fmt, ...)
|
void tfp_sprintf(char *s, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list va;
|
va_list va;
|
||||||
|
|
||||||
|
|
|
@ -107,10 +107,10 @@ regs Kusti, 23.10.2004
|
||||||
|
|
||||||
void init_printf(void *putp, void (*putf) (void *, char));
|
void init_printf(void *putp, void (*putf) (void *, char));
|
||||||
|
|
||||||
void tfp_printf(char *fmt, ...);
|
void tfp_printf(const char *fmt, ...);
|
||||||
void tfp_sprintf(char *s, char *fmt, ...);
|
void tfp_sprintf(char *s, const char *fmt, ...);
|
||||||
|
|
||||||
void tfp_format(void *putp, void (*putf) (void *, char), char *fmt, va_list va);
|
void tfp_format(void *putp, void (*putf) (void *, char), const char *fmt, va_list va);
|
||||||
|
|
||||||
#define printf tfp_printf
|
#define printf tfp_printf
|
||||||
#define sprintf tfp_sprintf
|
#define sprintf tfp_sprintf
|
||||||
|
|
|
@ -90,7 +90,7 @@ int a2d(char ch)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
char a2i(char ch, char **src, int base, int *nump)
|
char a2i(char ch, const char **src, int base, int *nump)
|
||||||
{
|
{
|
||||||
char *p = *src;
|
char *p = *src;
|
||||||
int num = 0;
|
int num = 0;
|
||||||
|
|
|
@ -20,7 +20,7 @@ void uli2a(unsigned long int num, unsigned int base, int uc, char *bf);
|
||||||
void li2a(long num, char *bf);
|
void li2a(long num, char *bf);
|
||||||
void ui2a(unsigned int num, unsigned int base, int uc, char *bf);
|
void ui2a(unsigned int num, unsigned int base, int uc, char *bf);
|
||||||
void i2a(int num, char *bf);
|
void i2a(int num, char *bf);
|
||||||
char a2i(char ch, char **src, int base, int *nump);
|
char a2i(char ch, const char **src, int base, int *nump);
|
||||||
char *ftoa(float x, char *floatString);
|
char *ftoa(float x, char *floatString);
|
||||||
float fastA2F(const char *p);
|
float fastA2F(const char *p);
|
||||||
|
|
||||||
|
|
|
@ -378,24 +378,28 @@ void showBatteryPage(void)
|
||||||
void showSensorsPage(void)
|
void showSensorsPage(void)
|
||||||
{
|
{
|
||||||
uint8_t rowIndex = PAGE_TITLE_LINE_COUNT;
|
uint8_t rowIndex = PAGE_TITLE_LINE_COUNT;
|
||||||
|
static const char *format = "%c = %5d %5d %5d";
|
||||||
|
|
||||||
i2c_OLED_set_line(rowIndex++);
|
i2c_OLED_set_line(rowIndex++);
|
||||||
i2c_OLED_send_string(" X Y Z");
|
i2c_OLED_send_string(" X Y Z");
|
||||||
|
|
||||||
if (sensors(SENSOR_ACC)) {
|
if (sensors(SENSOR_ACC)) {
|
||||||
tfp_sprintf(lineBuffer, "A = %5d %5d %5d", accSmooth[X], accSmooth[Y], accSmooth[Z]);
|
tfp_sprintf(lineBuffer, format, 'A', accSmooth[X], accSmooth[Y], accSmooth[Z]);
|
||||||
padLineBuffer();
|
padLineBuffer();
|
||||||
i2c_OLED_set_line(rowIndex++);
|
i2c_OLED_set_line(rowIndex++);
|
||||||
i2c_OLED_send_string(lineBuffer);
|
i2c_OLED_send_string(lineBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sensors(SENSOR_GYRO)) {
|
if (sensors(SENSOR_GYRO)) {
|
||||||
tfp_sprintf(lineBuffer, "G = %5d %5d %5d", gyroADC[X], gyroADC[Y], gyroADC[Z]);
|
tfp_sprintf(lineBuffer, format, 'G', gyroADC[X], gyroADC[Y], gyroADC[Z]);
|
||||||
padLineBuffer();
|
padLineBuffer();
|
||||||
i2c_OLED_set_line(rowIndex++);
|
i2c_OLED_set_line(rowIndex++);
|
||||||
i2c_OLED_send_string(lineBuffer);
|
i2c_OLED_send_string(lineBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MAG
|
#ifdef MAG
|
||||||
if (sensors(SENSOR_MAG)) {
|
if (sensors(SENSOR_MAG)) {
|
||||||
tfp_sprintf(lineBuffer, "M = %5d %5d %5d", magADC[X], magADC[Y], magADC[Z]);
|
tfp_sprintf(lineBuffer, format, 'M', magADC[X], magADC[Y], magADC[Z]);
|
||||||
padLineBuffer();
|
padLineBuffer();
|
||||||
i2c_OLED_set_line(rowIndex++);
|
i2c_OLED_set_line(rowIndex++);
|
||||||
i2c_OLED_send_string(lineBuffer);
|
i2c_OLED_send_string(lineBuffer);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue