AceRoutine  1.5.0
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. It is currently only used by CoroutineScheduler::list() but I think
33 // it's worth it to make debugging easier.
34 
35 static const char kStatusSuspendedString[] PROGMEM = "Suspended";
36 static const char kStatusYieldingString[] PROGMEM = "Yielding";
37 static const char kStatusDelayingString[] PROGMEM = "Delaying";
38 static const char kStatusRunningString[] PROGMEM = "Running";
39 static const char kStatusEndingString[] PROGMEM = "Ending";
40 static const char kStatusTerminatedString[] PROGMEM = "Terminated";
41 
42 // Store the array of PROGMEM pointers in PROGMEM as well, saving 14 bytes of
43 // RAM on AVR, and 28 bytes on ESP8266.
44 const __FlashStringHelper* const sStatusStrings[] PROGMEM = {
45  FPSTR(kStatusSuspendedString),
46  FPSTR(kStatusYieldingString),
47  FPSTR(kStatusDelayingString),
48  FPSTR(kStatusRunningString),
49  FPSTR(kStatusEndingString),
50  FPSTR(kStatusTerminatedString),
51 };
52 
53 }
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