diff --git a/libraries/yukon/logging.hpp b/libraries/yukon/logging.hpp index 21da5a1d..e6cf2a04 100644 --- a/libraries/yukon/logging.hpp +++ b/libraries/yukon/logging.hpp @@ -1,5 +1,6 @@ #pragma once +#include "pico/stdlib.h" #include namespace pimoroni { @@ -16,18 +17,25 @@ namespace pimoroni { uint level = LOG_INFO; void warn(std::string message) { - if(level >= LOG_WARN) - std::cout << message; + if(level >= LOG_WARN) { + print(message); + } } void info(std::string message) { if(level >= LOG_INFO) { - std::cout << message; + print(message); } } void debug(std::string message) { if(level >= LOG_DEBUG) { + print(message); + } + } + //stdio_usb_connected() + void print(std::string message) { + if(stdio_usb_connected()) { std::cout << message; } } diff --git a/libraries/yukon/yukon.cpp b/libraries/yukon/yukon.cpp index db90690f..910ca860 100644 --- a/libraries/yukon/yukon.cpp +++ b/libraries/yukon/yukon.cpp @@ -870,8 +870,7 @@ namespace pimoroni { void Yukon::__print_named_readings(std::string section_name, std::vector> named_readings) { if(!named_readings.empty()) { - std::cout << section_name << " "; - //printf("%s ", section_name.c_str()); + logging.print(section_name + " "); for(auto it = named_readings.begin(); it != named_readings.end(); it++) { std::string name = it->first; @@ -881,8 +880,7 @@ namespace pimoroni { //if type(value) is bool: // print(f"{name} = {int(value)},", end=" ") # Output 0 or 1 rather than True of False, so bools can appear on plotter charts //else: - //printf("%s = %f, ", name.c_str(), value); - std::cout << name << " = " << value << ", "; + logging.print(name + " = " + std::to_string(value) + ", "); } } }