Skip to content

Commit 04c40c5

Browse files
committed
Adding examples breaking the current build.
1 parent 406093e commit 04c40c5

12 files changed

+150
-0
lines changed

Diff for: examples/Breaks_1/Breaks_1.ino

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include <Arduino_Threads.h>
2+
3+
void setup()
4+
{
5+
Thread.start();
6+
}
7+
8+
void loop()
9+
{
10+
11+
}

Diff for: examples/Breaks_1/SharedVariables.h

Whitespace-only changes.

Diff for: examples/Breaks_1/Thread.inot

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/* This fails to compile because it doesn't look like a
2+
* declaration and a definitio but rather like an attempt
3+
* to overload myFunc with the same signature (again)
4+
* resulting in a compile error.
5+
*/
6+
7+
int myFunc(int const a, int const b);
8+
9+
void setup()
10+
{
11+
12+
}
13+
14+
void loop()
15+
{
16+
static int c = 0;
17+
c += myFunc(0,c);
18+
}
19+
20+
int myFunc(int const a, int const b)
21+
{
22+
return (a + b);
23+
}

Diff for: examples/Breaks_2/Breaks_2.ino

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include <Arduino_Threads.h>
2+
3+
void setup()
4+
{
5+
Thread.start();
6+
}
7+
8+
void loop()
9+
{
10+
11+
}

Diff for: examples/Breaks_2/SharedVariables.h

Whitespace-only changes.

Diff for: examples/Breaks_2/Thread.inot

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/* This fails to compile because myEventHandler has the
2+
* function signature of 'void Thread::myEventHandler(void)'
3+
* and is a member function of 'class Thread' while
4+
* attachInterrupt expects a function with the signature
5+
* 'void myEventHandler(void)'
6+
*/
7+
8+
void myEventHandler()
9+
{
10+
/* Do something. */
11+
}
12+
13+
void setup()
14+
{
15+
attachInterrupt(digitalPinToInterrupt(2), myEventHandler, CHANGE);
16+
}
17+
18+
void loop()
19+
{
20+
21+
}

Diff for: examples/Breaks_3/Breaks_3.ino

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include <Arduino_Threads.h>
2+
3+
void setup()
4+
{
5+
Thread.start();
6+
}
7+
8+
void loop()
9+
{
10+
11+
}

Diff for: examples/Breaks_3/SharedVariables.h

Whitespace-only changes.

Diff for: examples/Breaks_3/Thread.inot

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/* This fails to compile because in-class-initialisation of
2+
* a static member variable is forbidden.
3+
*/
4+
5+
static int my_global_variable = 0;
6+
7+
void setup()
8+
{
9+
10+
}
11+
12+
void loop()
13+
{
14+
15+
}

Diff for: examples/Breaks_4/Breaks_4.ino

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include <Arduino_Threads.h>
2+
3+
void setup()
4+
{
5+
Thread.start();
6+
}
7+
8+
void loop()
9+
{
10+
11+
}

Diff for: examples/Breaks_4/SharedVariables.h

Whitespace-only changes.

Diff for: examples/Breaks_4/Thread.inot

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/* Breaks for all kind of stuff ...
2+
*/
3+
4+
/**************************************************************************************
5+
* CONSTANTS
6+
**************************************************************************************/
7+
8+
static byte constexpr LSM6DSOX_ADDRESS = 0x6A;
9+
static byte constexpr LSM6DSOX_WHO_AM_I_REG = 0x0F;
10+
11+
/**************************************************************************************
12+
* GLOBAL VARIABLES
13+
**************************************************************************************/
14+
15+
BusDevice lsm6dsox(Wire, LSM6DSOX_ADDRESS);
16+
17+
/**************************************************************************************
18+
* FUNCTIONS
19+
**************************************************************************************/
20+
21+
byte lsm6dsox_read_reg(byte const reg_addr)
22+
{
23+
byte read_buf = 0;
24+
lsm6dsox.wire().write_then_read(&reg_addr, 1, &read_buf, 1);
25+
return read_buf;
26+
}
27+
28+
/**************************************************************************************
29+
* SETUP/LOOP
30+
**************************************************************************************/
31+
32+
void setup()
33+
{
34+
Serial.begin(9600);
35+
}
36+
37+
void loop()
38+
{
39+
/* Sleep between 5 and 500 ms */
40+
rtos::ThisThread::sleep_for(rtos::Kernel::Clock::duration_u32(random(5,500)));
41+
/* Try to read some data from the LSM6DSOX. */
42+
byte const who_am_i = lsm6dsox_read_reg(LSM6DSOX_WHO_AM_I_REG);
43+
/* Print thread id and chip id value to serial. */
44+
char msg[64] = {0};
45+
snprintf(msg, sizeof(msg), "%s: LSM6DSOX[WHO_AM_I] = 0x%X", rtos::ThisThread::get_name(), who_am_i);
46+
Serial.println(msg);
47+
}

0 commit comments

Comments
 (0)