Added fix for handing when printing to usb

feature/yukon
ZodiusInfuser 2023-08-04 16:29:51 +01:00
rodzic 8075f04434
commit 9198338a73
2 zmienionych plików z 13 dodań i 7 usunięć

Wyświetl plik

@ -1,5 +1,6 @@
#pragma once
#include "pico/stdlib.h"
#include <iostream>
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;
}
}

Wyświetl plik

@ -870,8 +870,7 @@ namespace pimoroni {
void Yukon::__print_named_readings(std::string section_name, std::vector<std::pair<std::string, float>> 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) + ", ");
}
}
}