AceRoutine  1.4.2
A low-memory, fast-switching, cooperative multitasking library using stackless coroutines on Arduino platforms.
Coroutine.cpp
1 /*
2 MIT License
3 
4 Copyright (c) 2018 Brian T. Park
5 
6 Permission is hereby granted, free of charge, to any person obtaining a copy
7 of this software and associated documentation files (the "Software"), to deal
8 in the Software without restriction, including without limitation the rights
9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions:
12 
13 The above copyright notice and this permission notice shall be included in all
14 copies or substantial portions of the Software.
15 
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 SOFTWARE.
23 */
24 
25 #include "Coroutine.h"
26 #include "compat.h" // FPSTR()
27 
28 namespace ace_routine {
29 
30 // Create the sStatusStrings lookup table to translate Status integer to a
31 // human-readable string. When it is used, it increases flash memory by 86
32 // bytes, and static RAM by 14 bytes. It is currently only used by
33 // CoroutineScheduler::list() but I think it's worth it to make debugging
34 // easier.
35 
36 static const char kStatusSuspendedString[] PROGMEM = "Suspended";
37 static const char kStatusYieldingString[] PROGMEM = "Yielding";
38 static const char kStatusDelayingString[] PROGMEM = "Delaying";
39 static const char kStatusRunningString[] PROGMEM = "Running";
40 static const char kStatusEndingString[] PROGMEM = "Ending";
41 static const char kStatusTerminatedString[] PROGMEM = "Terminated";
42 
43 const __FlashStringHelper* const sStatusStrings[] = {
44  FPSTR(kStatusSuspendedString),
45  FPSTR(kStatusYieldingString),
46  FPSTR(kStatusDelayingString),
47  FPSTR(kStatusRunningString),
48  FPSTR(kStatusEndingString),
49  FPSTR(kStatusTerminatedString),
50 };
51 
52 }
FPSTR
#define FPSTR(p)
A macro that converts a const char* that already points to a PROGMEM string to a const __FlashStringH...
Definition: compat.h:87
compat.h
Coroutine.h