leo25 / arduino

Automatically exported from code.google.com/p/arduino
0 stars 0 forks source link

Add print(int8_t) and println(int8_t) to format ASCII digits as with uint8_t. #627

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
You can apparently distinguish three different single byte types: char, 
uint8_t, int8_t.  Calling print on the first outputs a single byte (e.g. 'A'); 
the second the digits as ASCII (e.g. '6' , '5').  We should add an overload for 
the third to behave the same as the second.

Original issue reported on code.google.com by dmel...@gmail.com on 6 Sep 2011 at 4:21

GoogleCodeExporter commented 9 years ago
Here is a patch to add this to the Print API

Original comment by paul.sto...@gmail.com on 9 Sep 2011 at 11:52

Attachments:

GoogleCodeExporter commented 9 years ago
Here is a simple test sketch.

If you run this, it works either way.  The patch is not necessary.  The 
compiler promotes signed char to int automatically if there is not a dedicated 
function for signed char.

void setup() {
  Serial.begin(9600);
  Serial.println("begin");
}

void loop() {
  signed char  a = -65;
  byte    b = 200;
  char    c = 'c';

  Serial.println(a);
  Serial.println(b);
  Serial.println(c);
  Serial.println();
  delay(2500);
}

Original comment by paul.sto...@gmail.com on 9 Sep 2011 at 11:58

GoogleCodeExporter commented 9 years ago

Original comment by dmel...@gmail.com on 16 Dec 2011 at 10:08