Hi,
I'm making a custom object to send text to tiar/HW/OLED128x64nice
I took look at the tiar/HW/strbar object to know what output my object should give to have the same behaviour, but something weird happens. When I send it to line 2 of the display, it is more or less correctly displayed. But whenever I send the same output to either line 1,3 or 4 the axo crashes.
The object that works has a float connector and a string attribute and then creates a string with some bits set so the tiar object knows what to do with it. I tried recreating this, but must be making a mistake somewhere.
original object code:
"Local Data"
char c[2 + strlen("attr_prefix")];
"init code"
strcpy(&c[2], "attr_prefix");
c[0] = 1; //string bar mode
"k-rate code"
int32_t v = __SSAT(inlet_in,28)>>21; if(v >= 0) c[1] = (uint8_t)(v + 1); // must not be zero ! else c[1] = (uint8_t)(256 + v); outlet_out = c;
my object code:
//append int tot str
char* addItoS(int i, char* s){
int32_t v = __SSAT(i,28)>>21;
char c[2]; /// this shows "amamp" but I want it to display "amp"
// char c[2 + strlen(s)]; /// for some reason this shows "UUUUU" instead of "amamp"
c[0] = 1; /// this is needed so the tiar object shows the value v as a bar in the display
if(v >= 0)
c[1] = (uint8_t)(v + 1); // must not be zero !
else
c[1] = (uint8_t)(256 + v);
strcat(&c[2],s);
return c;
}
I call this from K-rate code and a potentiometer is assigned to changing the value, it changes the bar correspondingly in size.
outlet_S1L2 = addItoS(rev_dec_hold,"amp");
this is what happens:
Whenever I use a different screen line the display line becomes garbage and the axo crashes...