Skip to content

Commit 78c42a3

Browse files
committed
Updated constructor information
1 parent 00b33eb commit 78c42a3

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

Diff for: docs/README.md

+20-16
Original file line numberDiff line numberDiff line change
@@ -11,39 +11,43 @@ For connecting more boards together an [RS-485](RS485.md) network is recommended
1111
Library initialization
1212
----------------------
1313

14+
You first need to create an ICSC object using one of the constructors:
15+
1416
```C++
15-
ICSC.begin(stationId, baudRate);
16-
ICSC.begin(stationId, baudRate, &SerialPort);
17-
ICSC.begin(stationId, baudRate, &SerialPort, DEPin);
18-
ICSC.begin(stationId, baudRate, DEPin);
17+
ICSC(Stream *d, uint8_t station);
18+
ICSC(Stream &d, uint8_t station);
19+
ICSC(Stream *d, uint8_t station, int depin);
20+
ICSC(Stream &d, uint8_t station, int depin);
1921
```
2022
21-
Initialize the serial port and internal structures. stationId is the ID of the local station. Set the baud rate to be the same on all stations. &SerialPort is a pointer to a HardwareSerial device, such as &Serial1. If not specified, defaults to &Serial. DEPin is the pin to use to control the RE#/DE pins of an RS-485 transceiver chip if needed. If not specified RE#/DE operation is disabled.
23+
The `Stream` is the device you wish to communicate over. `station` is the number (or single letter code) of this station, and `depin` is, if provided, the DE/RE pin pair of a MAX485 chip or similar.
2224
2325
Example:
2426
2527
```C++
2628
#include <ICSC.h>
2729
30+
ICSC icsc(Serial, 'A', 3);
31+
2832
void setup()
2933
{
30-
ICSC.begin(3, 115200, &Serial1);
34+
icsc.begin();
3135
}
3236
```
3337

3438
Register a reception command
3539
----------------------------
3640

3741
```C++
38-
ICSC.registerCommand(commandID, commandCallback);
42+
ICSC::registerCommand(commandID, commandCallback);
3943
```
4044
4145
Register a new command to be acted upon. Calls the function commandCallback when a packet with this commandID is received.
4246
4347
Example:
4448
4549
```C++
46-
ICSC.registerCommand('T', &tick);
50+
icsc.registerCommand('T', &tick);
4751
4852
void tick(unsigned char source, char command, unsigned char length, char *data)
4953
{
@@ -55,52 +59,52 @@ Unregister a reception command
5559
------------------------------
5660

5761
```C++
58-
ICSC.unregisterCommand(commandID);
62+
ICSC::unregisterCommand(commandID);
5963
```
6064
6165
Remove a registered callback command from the list of recognized commands at this station.
6266
6367
Example:
6468
6569
```C++
66-
ICSC.unregisterCommand('T');
70+
icsc.unregisterCommand('T');
6771
```
6872

6973
Send a packet
7074
-------------
7175

7276
```C++
73-
ICSC.send(destination, commandID, length, data);
77+
ICSC::send(destination, commandID, length, data);
7478
```
7579
7680
Send a packet to a remote station. The commandID should match a command registered in the remote station. Length is the number of bytes of data to include in the packet. Data is a pointer to the data to send (should be cast to a char * if it isn't already).
7781
7882
Example:
7983
8084
```C++
81-
ICSC.send(6, 'T', 5, (char *)&myData);
85+
icsc.send(6, 'T', 5, (char *)&myData);
8286
```
8387

8488
Send a broadcast
8589
----------------
8690

8791
```C++
88-
ICSC.broadcast(command, length, data);
92+
ICSC::broadcast(command, length, data);
8993
```
9094
9195
Send a packet to all stations. The default address for broadcasting is 0 (can be edited in the ICSC.h file). Apart from that broadcast() works like send().
9296
9397
Example:
9498
9599
```C++
96-
ICSC.broadcast('T', 1, (char *)&myData);
100+
icsc.broadcast('T', 1, (char *)&myData);
97101
```
98102

99103
Performing reception
100104
--------------------
101105

102106
```C++
103-
ICSC.process();
107+
ICSC::process();
104108
```
105109

106110
This function should be called during any long loops, and on every pass of the main loop() function.
@@ -110,7 +114,7 @@ Example:
110114
```C++
111115
void loop()
112116
{
113-
ICSC.process();
117+
icsc.process();
114118
// ...
115119
}
116120
```

0 commit comments

Comments
 (0)