I wrote simple code for my Digispark (Attiny85 with Micronucleus bootloader) in Arduino IDE:
#include <DigiUSB.h>
String inst;
void setup() {
DigiUSB.begin();
pinMode(1, OUTPUT);
}
void loop() {
if (DigiUSB.available()) {
char inp = DigiUSB.read();
if (inp == '\n') {
DigiUSB.println(inst);
DigiUSB.println(inst.length());
inst = "";
}
else {
inst += inp;
}
}
DigiUSB.delay(1);
}
DigiUSB works just like Serial communication in classic boards
If i send string and newline char i expect it to output this string back and print its length, but instead i receiving null string and 0 in any case
Is it problem with code or microcontroller itself?
EDIT: Its seems to be digispark library problem itself:
DigiUSB.println() and DigiUSB.print() accept only char arrays
Also, there is no toCharArray() from classic arduino lib and no c_str() so i cant use atoi()