I started to use Log::Print for debug. It worked fine for strings I wrote in the code like this: “debug text”
But now I am trying to print numbers from variables, for example in the seed/Blink.cpp example, I would like to print the value of the led (0 or 1), led_state
#include “daisy_seed.h”
// Use the daisy namespace to prevent having to type
// daisy:: before all libdaisy functions
using namespace daisy;
// Declare a DaisySeed object called hardware
DaisySeed hardware;
TimerHandle timer;
int main(void)
{
// Declare a variable to store the state we want to set for the LED.
bool led_state;
led_state = true;
// Configure and Initialize the Daisy Seed
// These are separate to allow reconfiguration of any of the internal
// components before initialization.
hardware.Configure();
hardware.Init();
hardware.StartLog(true); //(true) se queda esperando que la PC escuche en cada PrintLine()
// Loop forever
for( ; ; )
{
// Set the onboard LED
hardware.SetLed(led_state);
hardware.PrintLine(“changing Led”); //HERE I WOULD LIKE TO PRINT led_state
// Toggle the LED state for the next time around.
led_state = !led_state;
// Wait 500ms
System::Delay(500);
}
}
The problem is that Print() only accepts const char*, can you use Print() with a variable?
int myint = 42;
float myfloat = 1.234f;
hw.PrintLine("Print an int value:%d", myint);
hw.PrintLine("Print a float value:%.3f", myfloat);
hw.PrintLine("Mix them: %f is ok, but %d is the %s", myfloat, myint, "answer");
i can get it daisy logger’s PrintLine function to print characters but not full strings. i’ve tested the serial monitors in both visual studio and arduino ide. is it possible to print a string?
when i do something like:
std::string test = "test string";
hw.PrintLine( "here's a string: %s",test);