Skip to content

Commit 8d175ed

Browse files
authored
feat: add default begin() param (#35)
1 parent 589dcdf commit 8d175ed

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

library.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=Blues Wireless Notecard
2-
version=1.2.10
2+
version=1.3.0
33
author=Blues Wireless
44
maintainer=Blues Wireless <[email protected]>
55
sentence=An easy to use Notecard Library for Arduino.

src/Notecard.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class Notecard
4848
void begin(uint32_t i2cAddress = NOTE_I2C_ADDR_DEFAULT,
4949
uint32_t i2cMax = NOTE_I2C_MAX_DEFAULT,
5050
TwoWire &wirePort = Wire);
51-
void begin(HardwareSerial &serial, int speed);
51+
void begin(HardwareSerial &serial, int speed = 9600);
5252
void setDebugOutputStream(Stream &dbgserial);
5353
void clearDebugOutputStream(void);
5454
void i2cTest(int Adjustment);

test/notecard-test.cpp

+27-1
Original file line numberDiff line numberDiff line change
@@ -989,6 +989,31 @@ int test_notecard_begin_i2c_parameter_for_wirePort_has_begin_method_called()
989989
return result;
990990
}
991991

992+
int test_notecard_begin_serial_default_parameter_for_baud_rate_is_passed_to_note_c()
993+
{
994+
int result;
995+
Notecard notecard;
996+
const unsigned int baud = 9600;
997+
998+
// Setup
999+
hardwareSerialBegin_Parameters.baud = (baud - 1);
1000+
1001+
// Action
1002+
notecard.begin(Serial);
1003+
1004+
// Evaluate Result
1005+
if (baud == hardwareSerialBegin_Parameters.baud)
1006+
{
1007+
result = 0;
1008+
}
1009+
else
1010+
{
1011+
result = 39;
1012+
}
1013+
1014+
return result;
1015+
}
1016+
9921017
struct TestFunction;
9931018
typedef int (*test_fn)(void);
9941019
int runTests(TestFunction *tests_, size_t cnt_);
@@ -1053,7 +1078,8 @@ int main(void)
10531078
{test_notecard_responseError_does_not_modify_j_object_parameter_value_before_passing_to_note_c, "test_notecard_responseError_does_not_modify_j_object_parameter_value_before_passing_to_note_c"},
10541079
{test_notecard_responseError_does_not_modify_note_c_result_value_before_returning_to_caller, "test_notecard_responseError_does_not_modify_note_c_result_value_before_returning_to_caller"},
10551080
{test_notecard_begin_i2c_default_parameter_for_wirePort_has_begin_method_called, "test_notecard_begin_i2c_default_parameter_for_wirePort_has_begin_method_called"},
1056-
{test_notecard_begin_i2c_parameter_for_wirePort_has_begin_method_called, "test_notecard_begin_i2c_parameter_for_wirePort_has_begin_method_called"}
1081+
{test_notecard_begin_i2c_parameter_for_wirePort_has_begin_method_called, "test_notecard_begin_i2c_parameter_for_wirePort_has_begin_method_called"},
1082+
{test_notecard_begin_serial_default_parameter_for_baud_rate_is_passed_to_note_c, "test_notecard_begin_serial_default_parameter_for_baud_rate_is_passed_to_note_c"}
10571083
};
10581084

10591085
return runTests(tests, (sizeof(tests) / sizeof(TestFunction)));

0 commit comments

Comments
 (0)