You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • jsiConsolePrintf is like printf (I'd google it)... It needs a format string at the start which specifies what the next arguments actually are.

    In Espruino I added some special format characters for JS variables, see this

    So you want to do something like:

    for(i = 0; i < 128; ++i)
        jsiConsolePrintf("%d, ", in[i]);
      jsiConsolePrintf("\n");
    

    That'll output a comma-separated list of numbers. If you want to output just the actual character you can use %c - jsiConsolePrintf("%c", in[i]);.

    jsiConsolePrint itself expects a C string - that's a pointer to a list of characters that is terminated with a 0 character, so you won't be able to just pass in the character itself.

    If you did want to use it, you'd have to do:

    char buf[2];
    buf[0] = myCharacter;
    buf[1] = 0;
    jsiConsolePrint(buf);
    

    (Of course you could also use jsiConsolePrintChar, which is probably what you want)

    ... anyway, it's just one of the many reasons that programming embedded devices in C is painful :)

About

Avatar for Gordon @Gordon started