Skip to content

Commit

Permalink
Minimize progmem when not used
Browse files Browse the repository at this point in the history
  • Loading branch information
pschatzmann committed Jul 16, 2024
1 parent a14790e commit 4440bb6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/stm32-i2s.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,20 @@ void Report_Error() {
* @brief Write log output to Serial
*/
void STM32_LOG(const char *fmt, ...) {
char log_buffer[200];
strcpy(log_buffer, "STM32: ");
// char log_buffer[200];
// strcpy(log_buffer, "STM32: ");
// va_list arg;
// va_start(arg, fmt);
// int len = vsnprintf(log_buffer + 7, 200, fmt, arg);
// va_end(arg);
// Serial.println(log_buffer);
// Serial.flush();

// minimize progmem when not used
va_list arg;
va_start(arg, fmt);
int len = vsnprintf(log_buffer + 7, 200, fmt, arg);
self_I2S->STM32_LOG(fmt, arg);
va_end(arg);
Serial.println(log_buffer);
Serial.flush();
}

#ifdef USE_FULL_ASSERT
Expand Down
11 changes: 11 additions & 0 deletions src/stm32-i2s.h
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,17 @@ class Stm32I2sClass {
return rc == HAL_OK ? bytes : 0;
}

void STM32_LOG(const char *fmt, ...) {
char log_buffer[200];
strcpy(log_buffer, "STM32: ");
va_list arg;
va_start(arg, fmt);
int len = vsnprintf(log_buffer + 7, 200, fmt, arg);
va_end(arg);
Serial.println(log_buffer);
Serial.flush();
}

protected:
I2SSettingsSTM32 settings;
I2S_HandleTypeDef hi2s3;
Expand Down

0 comments on commit 4440bb6

Please sign in to comment.