hw.seed.PrintLine not working with floats


I created a brand new project using the python script and added just five lines of code to main that print out a couple of lines to the serial monitor. The output I am getting does not look right (the float is not showing up). I tried this in some other situations and every time I try to PrintLine a float, it does not work. Sometimes instead of nothing it looks like it is replacing the %f with unintialized memory. What am I doing wrong?


---- Opened the serial port COM3 ----
Print an int value: 1341
Print a float value:

Here is the source:

#include “daisy_pod.h”
#include “daisysp.h”

using namespace daisy;
using namespace daisysp;

DaisyPod hw;

void AudioCallback(AudioHandle::InputBuffer in, AudioHandle::OutputBuffer out, size_t size)
for (size_t i = 0; i < size; i++)
out[0][i] = in[0][i];
out[1][i] = in[1][i];

int main(void)
hw.SetAudioBlockSize(4); // number of samples handled per callback


int myint = 1341;
float myfloat = 1.234f;
hw.seed.PrintLine(“Print an int value: %d”, myint);
hw.seed.PrintLine(“Print a float value: %f”, myfloat);

while(1) {}

see this:

1 Like

Ah okay. Thanks! That makes sense. I think if it adds a lot of overhead to the limited flash space I’ll just sprintf my floats instead. If this was in the comments of daisy_seed.h – maybe in the function descriptions for Print and PrintLine – it might save people some headache trying to figure out what’s going on.

another option is to use the formatting from FixedCapStr

float f = 1.234;
FixedCapStr<7> str;
str.AppendFloat(f, 5);
1 Like

Yet another option is to use ST-LINK and gdb with dprintf():

Linux bash commands to build, flash and run the debugger are:

make program
make openocd

and in another terminal run

make debug
1 Like