Closed keekychen closed 6 months ago
Well... TaskScheduler is a header-only library. It comes in two parts: TaskSchedulerDeclarations.h
and TaskScheduler.h
. You must not include TaskScheduler.h
in multiple compilation units. You did so by #include
ing that file in MyScheduler.cpp
and in sketch_jan11a.ino
, both via MyScheduler.h
.
MyScheduler.h
shall #include
file TaskSchedulerDeclarations.h
. Then, TaskScheduler.h
(which also has definitions, not just declarations) shall be #include
d only in file MyScheduler.cpp
. Then, only a single compilation unit will have the definitions and your linker errors will go away.
I have below simple files structure try to wrap TaskScheduler Task and execute() ... in to a class so what I can better organize my code.
sketch_jan11a.ino:
MyScheduler.h:
MyScheduler.cpp
I use Arduino IDE 2.2.1, when I compile above code, IDE will give me a
I tried many ways try to understand why it happen includes:
no lucky.
Could someone share me why I have this problem and how to fix it? Thank you!