Skip to content

Commit 2c1ee7c

Browse files
committed
Update generic selection in Readme
1 parent 445c9e8 commit 2c1ee7c

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

README.md

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -97,22 +97,21 @@ There is no Analog Pin definition such as A0. Just use 11, 14, 15, or 32 for the
9797

9898
### No polymorph functions:
9999

100-
There is no free C++ compiler for MCS51 chip, we can not use polymorph functions. So you can not expect the compiler will choose a function according to the parameter's type.
101-
102-
The biggest difference may be the ```Serial.print``` function. Here is what you should do in CH55xduino
103-
104-
| datatype | Print on USB | Println on USB | Print on UART0 | Println on UART0 |
105-
|----------|--------------|----------------|----------------|------------------|
106-
| int | USBSerial\_print\_i(P) | USBSerial\_println\_i(P) | Serial0\_print\_i(P) | Serial0\_println\_i(P) |
107-
| unsigned | USBSerial\_print\_u(P) | USBSerial\_println\_u(P) | Serial0\_print\_u(P) | Serial0\_println\_u(P) |
108-
| float | USBSerial\_print\_f(P) | USBSerial\_println\_f(P) | Serial0\_print\_f(P) | Serial0\_println\_f(P) |
109-
| float with precision | USBSerial\_print\_f(P,Q) | USBSerial\_println\_f(P,Q) | Serial0\_print\_f(P,Q) | Serial0\_println\_f(P,Q) |
110-
| char | USBSerial\_print\_c(P) | USBSerial\_println\_c(P) | Serial0\_print\_c(P) | Serial0\_println\_c(P) |
111-
| char * (str) | USBSerial\_print\_s(P) | USBSerial\_println\_s(P) | Serial0\_print\_s(P) | Serial0\_println\_s(P) |
112-
| char array with length | USBSerial\_print\_sn(P,Q) | USBSerial\_println\_sn(P,Q) | Serial0\_print\_sn(P,Q) | Serial0\_println\_sn(P,Q) |
113-
| int with base | USBSerial\_print\_ub(P,Q) | USBSerial\_println\_ub(P,Q) | Serial0\_print\_ub(P,Q) | Serial0\_println\_ub(P,Q) |
114-
115-
They are defined in ```Arduino.h```.
100+
There is no free C++ compiler for MCS51 chip, we can not use polymorph functions. However, since commit 13402 of SDCC, the generic selection is functional. Ch55xduino supports generic selection since 0.0.11.
101+
102+
If you are using a version higher than 0.0.11, the print function can choose a function according to the parameter's type.
103+
104+
For example. If you want to print to the USB-CDC virtual serial port, you can do:
105+
106+
```
107+
USBSerial_print(val); //val: the value to print - any data type
108+
USBSerial_print(val, format) //specifies the number base (for integral data types) or number of decimal places (for floating point types)
109+
USBSerial_print(charPointer, length) //specifies the string length to be printed
110+
```
111+
112+
It is also possible to do ``` USBSerial_println ```. If you want to print to Serial0 or Serial1, just use ``` Serial0_print ``` or ``` Serial1_print ```.
113+
114+
They are defined in ```genericPrintSelection.h```.
116115

117116
### Memory model:
118117

0 commit comments

Comments
 (0)