File tree Expand file tree Collapse file tree 3 files changed +10
-10
lines changed
master_writer_custombuffer
slave_receiver_custombuffer
slave_sender_custombuffer Expand file tree Collapse file tree 3 files changed +10
-10
lines changed Original file line number Diff line number Diff line change 16
16
// The following text will not fit into the default buffer of 32 bytes.
17
17
static const char text[] = " You really won't believe it, but x is " ;
18
18
19
- size_t constexpr RECEIVE_BUFFER_SIZE = 0 ; // There is no receive in this sketch.
20
- size_t constexpr TRANSMIT_BUFFER_SIZE = 42 ; // Enhance the buffer to 42 characters.
19
+ constexpr size_t RECEIVE_BUFFER_SIZE = 0 ; // There is no receive in this sketch.
20
+ constexpr size_t TRANSMIT_BUFFER_SIZE = 42 ; // Enhance the buffer to 42 characters.
21
21
22
22
SET_WIRE_BUFFERS (RECEIVE_BUFFER_SIZE, TRANSMIT_BUFFER_SIZE,
23
23
true /* master buffers needed */ , false /* no slave buffers needed */ );
@@ -34,8 +34,8 @@ static byte x = 0;
34
34
35
35
void loop () {
36
36
Wire.beginTransmission (8 ); // transmit to device #8
37
- Wire.write (text); // sends five bytes
38
- Wire.write (x); // sends one byte
37
+ Wire.write (text); // sends multiple bytes
38
+ Wire.write (x); // sends one byte
39
39
Wire.endTransmission (); // stop transmitting
40
40
41
41
x++;
Original file line number Diff line number Diff line change 13
13
#include < TwoWireBuffers.h>
14
14
#include " Arduino.h"
15
15
16
- size_t constexpr RECEIVE_BUFFER_SIZE = 42 ; // Be able receive up to 42 characters in one message.
17
- size_t constexpr TRANSMIT_BUFFER_SIZE = 0 ; // There is no transmit in this sketch.
16
+ constexpr size_t RECEIVE_BUFFER_SIZE = 42 ; // Be able receive up to 42 characters in one message.
17
+ constexpr size_t TRANSMIT_BUFFER_SIZE = 0 ; // There is no transmit in this sketch.
18
18
19
19
SET_WIRE_BUFFERS (RECEIVE_BUFFER_SIZE, TRANSMIT_BUFFER_SIZE,
20
20
true /* master buffers needed */ , false /* no slave buffers needed */ );
@@ -36,10 +36,10 @@ void loop() {
36
36
// this function is registered as an event, see setup()
37
37
void receiveEvent (int howMany) {
38
38
while (1 < Wire.available ()) { // loop through all but the last
39
- char c = Wire.read (); // receive byte as a character
39
+ const char c = Wire.read (); // receive byte as a character
40
40
Serial.print (c); // print the character
41
41
}
42
- int x = Wire.read (); // receive byte as an integer
42
+ const int x = Wire.read (); // receive byte as an integer
43
43
Serial.println (x); // print the integer
44
44
}
45
45
Original file line number Diff line number Diff line change 15
15
16
16
static const char text[] = " hello " ; // respond with message of 6 bytes
17
17
18
- size_t constexpr RECEIVE_BUFFER_SIZE = 0 ; // There is no receive in this sketch.
19
- size_t constexpr TRANSMIT_BUFFER_SIZE = sizeof (text)-1 ; // Don't need a byte for the \0
18
+ constexpr size_t RECEIVE_BUFFER_SIZE = 0 ; // There is no receive in this sketch.
19
+ constexpr size_t TRANSMIT_BUFFER_SIZE = sizeof (text)-1 ; // Don't need a byte for the \0
20
20
21
21
SET_WIRE_BUFFERS (RECEIVE_BUFFER_SIZE, TRANSMIT_BUFFER_SIZE,
22
22
true /* master buffers needed */ , false /* no slave buffers needed */ );
You can’t perform that action at this time.
0 commit comments