Merge pull request #3163 from martinbudden/bf_remove_sprintf
Replace sprintf with tfp_sprintf
This commit is contained in:
commit
dc40954e60
|
@ -47,7 +47,7 @@
|
||||||
/* Includes ------------------------------------------------------------------*/
|
/* Includes ------------------------------------------------------------------*/
|
||||||
#include "stm32f7xx.h"
|
#include "stm32f7xx.h"
|
||||||
#include "Legacy/stm32_hal_legacy.h"
|
#include "Legacy/stm32_hal_legacy.h"
|
||||||
#include <stdio.h>
|
#include <stddef.h>
|
||||||
/* Exported types ------------------------------------------------------------*/
|
/* Exported types ------------------------------------------------------------*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
|
@ -38,6 +37,7 @@
|
||||||
#include "cms/cms_types.h"
|
#include "cms/cms_types.h"
|
||||||
#include "cms/cms_menu_blackbox.h"
|
#include "cms/cms_menu_blackbox.h"
|
||||||
|
|
||||||
|
#include "common/printf.h"
|
||||||
#include "common/utils.h"
|
#include "common/utils.h"
|
||||||
|
|
||||||
#include "config/feature.h"
|
#include "config/feature.h"
|
||||||
|
@ -108,22 +108,22 @@ static void cmsx_Blackbox_GetDeviceStatus()
|
||||||
unit = "MB";
|
unit = "MB";
|
||||||
|
|
||||||
if (!sdcard_isInserted()) {
|
if (!sdcard_isInserted()) {
|
||||||
snprintf(cmsx_BlackboxStatus, CMS_BLACKBOX_STRING_LENGTH, "NO CARD");
|
tfp_sprintf(cmsx_BlackboxStatus, "NO CARD");
|
||||||
} else if (!sdcard_isFunctional()) {
|
} else if (!sdcard_isFunctional()) {
|
||||||
snprintf(cmsx_BlackboxStatus, CMS_BLACKBOX_STRING_LENGTH, "FAULT");
|
tfp_sprintf(cmsx_BlackboxStatus, "FAULT");
|
||||||
} else {
|
} else {
|
||||||
switch (afatfs_getFilesystemState()) {
|
switch (afatfs_getFilesystemState()) {
|
||||||
case AFATFS_FILESYSTEM_STATE_READY:
|
case AFATFS_FILESYSTEM_STATE_READY:
|
||||||
snprintf(cmsx_BlackboxStatus, CMS_BLACKBOX_STRING_LENGTH, "READY");
|
tfp_sprintf(cmsx_BlackboxStatus, "READY");
|
||||||
storageDeviceIsWorking = true;
|
storageDeviceIsWorking = true;
|
||||||
break;
|
break;
|
||||||
case AFATFS_FILESYSTEM_STATE_INITIALIZATION:
|
case AFATFS_FILESYSTEM_STATE_INITIALIZATION:
|
||||||
snprintf(cmsx_BlackboxStatus, CMS_BLACKBOX_STRING_LENGTH, "INIT");
|
tfp_sprintf(cmsx_BlackboxStatus, "INIT");
|
||||||
break;
|
break;
|
||||||
case AFATFS_FILESYSTEM_STATE_FATAL:
|
case AFATFS_FILESYSTEM_STATE_FATAL:
|
||||||
case AFATFS_FILESYSTEM_STATE_UNKNOWN:
|
case AFATFS_FILESYSTEM_STATE_UNKNOWN:
|
||||||
default:
|
default:
|
||||||
snprintf(cmsx_BlackboxStatus, CMS_BLACKBOX_STRING_LENGTH, "FAULT");
|
tfp_sprintf(cmsx_BlackboxStatus, "FAULT");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -142,25 +142,25 @@ static void cmsx_Blackbox_GetDeviceStatus()
|
||||||
|
|
||||||
storageDeviceIsWorking = flashfsIsReady();
|
storageDeviceIsWorking = flashfsIsReady();
|
||||||
if (storageDeviceIsWorking) {
|
if (storageDeviceIsWorking) {
|
||||||
snprintf(cmsx_BlackboxStatus, CMS_BLACKBOX_STRING_LENGTH, "READY");
|
tfp_sprintf(cmsx_BlackboxStatus, "READY");
|
||||||
|
|
||||||
const flashGeometry_t *geometry = flashfsGetGeometry();
|
const flashGeometry_t *geometry = flashfsGetGeometry();
|
||||||
storageUsed = flashfsGetOffset() / 1024;
|
storageUsed = flashfsGetOffset() / 1024;
|
||||||
storageFree = (geometry->totalSize / 1024) - storageUsed;
|
storageFree = (geometry->totalSize / 1024) - storageUsed;
|
||||||
} else {
|
} else {
|
||||||
snprintf(cmsx_BlackboxStatus, CMS_BLACKBOX_STRING_LENGTH, "FAULT");
|
tfp_sprintf(cmsx_BlackboxStatus, "FAULT");
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
default:
|
default:
|
||||||
snprintf(cmsx_BlackboxStatus, CMS_BLACKBOX_STRING_LENGTH, "---");
|
tfp_sprintf(cmsx_BlackboxStatus, "---");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Storage counters */
|
/* Storage counters */
|
||||||
snprintf(cmsx_BlackboxDeviceStorageUsed, CMS_BLACKBOX_STRING_LENGTH, "%ld%s", storageUsed, unit);
|
tfp_sprintf(cmsx_BlackboxDeviceStorageUsed, "%ld%s", storageUsed, unit);
|
||||||
snprintf(cmsx_BlackboxDeviceStorageFree, CMS_BLACKBOX_STRING_LENGTH, "%ld%s", storageFree, unit);
|
tfp_sprintf(cmsx_BlackboxDeviceStorageFree, "%ld%s", storageFree, unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
static long cmsx_Blackbox_onEnter(void)
|
static long cmsx_Blackbox_onEnter(void)
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
@ -323,7 +322,7 @@ static void osdDrawSingleElement(uint8_t item)
|
||||||
|
|
||||||
const char vtxBandLetter = vtx58BandLetter[band];
|
const char vtxBandLetter = vtx58BandLetter[band];
|
||||||
const char *vtxChannelName = vtx58ChannelNames[channel];
|
const char *vtxChannelName = vtx58ChannelNames[channel];
|
||||||
sprintf(buff, "%c:%s:%d", vtxBandLetter, vtxChannelName, power);
|
tfp_sprintf(buff, "%c:%s:%d", vtxBandLetter, vtxChannelName, power);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -450,7 +449,7 @@ static void osdDrawSingleElement(uint8_t item)
|
||||||
}
|
}
|
||||||
|
|
||||||
case OSD_DEBUG:
|
case OSD_DEBUG:
|
||||||
sprintf(buff, "DBG %5d %5d %5d %5d", debug[0], debug[1], debug[2], debug[3]);
|
tfp_sprintf(buff, "DBG %5d %5d %5d %5d", debug[0], debug[1], debug[2], debug[3]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OSD_PITCH_ANGLE:
|
case OSD_PITCH_ANGLE:
|
||||||
|
@ -755,14 +754,13 @@ static void osdUpdateStats(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef BLACKBOX
|
#ifdef BLACKBOX
|
||||||
static void osdGetBlackboxStatusString(char * buff, uint8_t len)
|
static void osdGetBlackboxStatusString(char * buff)
|
||||||
{
|
{
|
||||||
bool storageDeviceIsWorking = false;
|
bool storageDeviceIsWorking = false;
|
||||||
uint32_t storageUsed = 0;
|
uint32_t storageUsed = 0;
|
||||||
uint32_t storageTotal = 0;
|
uint32_t storageTotal = 0;
|
||||||
|
|
||||||
switch (blackboxConfig()->device)
|
switch (blackboxConfig()->device) {
|
||||||
{
|
|
||||||
#ifdef USE_SDCARD
|
#ifdef USE_SDCARD
|
||||||
case BLACKBOX_DEVICE_SDCARD:
|
case BLACKBOX_DEVICE_SDCARD:
|
||||||
storageDeviceIsWorking = sdcard_isInserted() && sdcard_isFunctional() && (afatfs_getFilesystemState() == AFATFS_FILESYSTEM_STATE_READY);
|
storageDeviceIsWorking = sdcard_isInserted() && sdcard_isFunctional() && (afatfs_getFilesystemState() == AFATFS_FILESYSTEM_STATE_READY);
|
||||||
|
@ -789,10 +787,10 @@ static void osdGetBlackboxStatusString(char * buff, uint8_t len)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (storageDeviceIsWorking) {
|
if (storageDeviceIsWorking) {
|
||||||
uint16_t storageUsedPercent = (storageUsed * 100) / storageTotal;
|
const uint16_t storageUsedPercent = (storageUsed * 100) / storageTotal;
|
||||||
snprintf(buff, len, "%d%%", storageUsedPercent);
|
tfp_sprintf(buff, "%d%%", storageUsedPercent);
|
||||||
} else {
|
} else {
|
||||||
snprintf(buff, len, "FAULT");
|
tfp_sprintf(buff, "FAULT");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -864,7 +862,7 @@ static void osdShowStats(void)
|
||||||
|
|
||||||
#ifdef BLACKBOX
|
#ifdef BLACKBOX
|
||||||
if (osdConfig()->enabled_stats[OSD_STAT_BLACKBOX] && blackboxConfig()->device && blackboxConfig()->device != BLACKBOX_DEVICE_SERIAL) {
|
if (osdConfig()->enabled_stats[OSD_STAT_BLACKBOX] && blackboxConfig()->device && blackboxConfig()->device != BLACKBOX_DEVICE_SERIAL) {
|
||||||
osdGetBlackboxStatusString(buff, 10);
|
osdGetBlackboxStatusString(buff);
|
||||||
osdDisplayStatisticLabel(top++, "BLACKBOX", buff);
|
osdDisplayStatisticLabel(top++, "BLACKBOX", buff);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -30,7 +30,6 @@
|
||||||
#include "cms/cms.h"
|
#include "cms/cms.h"
|
||||||
#include "cms/cms_types.h"
|
#include "cms/cms_types.h"
|
||||||
|
|
||||||
#include "common/printf.h"
|
|
||||||
#include "common/utils.h"
|
#include "common/utils.h"
|
||||||
|
|
||||||
#include "config/parameter_group.h"
|
#include "config/parameter_group.h"
|
||||||
|
|
|
@ -64,7 +64,7 @@ serialPort_t *debugSerialPort = NULL;
|
||||||
#define dprintf(x) if (debugSerialPort) printf x
|
#define dprintf(x) if (debugSerialPort) printf x
|
||||||
#else
|
#else
|
||||||
#define dprintf(x)
|
#define dprintf(x)
|
||||||
#endif
|
#endif // SMARTAUDIO_DPRINTF
|
||||||
|
|
||||||
#include "build/debug.h"
|
#include "build/debug.h"
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,10 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#if !defined(UNIT_TEST) && !defined(SITL) && !(USBD_DEBUG_LEVEL > 0)
|
||||||
|
#pragma GCC poison sprintf snprintf
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(STM32F745xx) || defined(STM32F746xx) || defined(STM32F722xx)
|
#if defined(STM32F745xx) || defined(STM32F746xx) || defined(STM32F722xx)
|
||||||
#include "stm32f7xx.h"
|
#include "stm32f7xx.h"
|
||||||
#include "stm32f7xx_hal.h"
|
#include "stm32f7xx_hal.h"
|
||||||
|
|
|
@ -51,7 +51,9 @@
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
/* Includes ------------------------------------------------------------------*/
|
||||||
#include "stm32f7xx_hal.h"
|
#include "stm32f7xx_hal.h"
|
||||||
|
#if (USBD_DEBUG_LEVEL > 0)
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#endif
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue