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 1616// The following text will not fit into the default buffer of 32 bytes.
1717static const char text[] = " You really won't believe it, but x is " ;
1818
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.
2121
2222SET_WIRE_BUFFERS (RECEIVE_BUFFER_SIZE, TRANSMIT_BUFFER_SIZE,
2323 true /* master buffers needed */ , false /* no slave buffers needed */ );
@@ -34,8 +34,8 @@ static byte x = 0;
3434
3535void loop () {
3636 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
3939 Wire.endTransmission (); // stop transmitting
4040
4141 x++;
Original file line number Diff line number Diff line change 1313#include < TwoWireBuffers.h>
1414#include " Arduino.h"
1515
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.
1818
1919SET_WIRE_BUFFERS (RECEIVE_BUFFER_SIZE, TRANSMIT_BUFFER_SIZE,
2020 true /* master buffers needed */ , false /* no slave buffers needed */ );
@@ -36,10 +36,10 @@ void loop() {
3636// this function is registered as an event, see setup()
3737void receiveEvent (int howMany) {
3838 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
4040 Serial.print (c); // print the character
4141 }
42- int x = Wire.read (); // receive byte as an integer
42+ const int x = Wire.read (); // receive byte as an integer
4343 Serial.println (x); // print the integer
4444}
4545
Original file line number Diff line number Diff line change 1515
1616static const char text[] = " hello " ; // respond with message of 6 bytes
1717
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
2020
2121SET_WIRE_BUFFERS (RECEIVE_BUFFER_SIZE, TRANSMIT_BUFFER_SIZE,
2222 true /* master buffers needed */ , false /* no slave buffers needed */ );
You can’t perform that action at this time.
0 commit comments