-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
media.cpp
59 lines (50 loc) · 1.32 KB
/
media.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/**
* Bill Siever
* 2021-11-20 Initial Version
*
* Development environment specifics:
* Written in Microsoft PXT
*
* This code is released under the [MIT License](http://opensource.org/licenses/MIT).
* Please review the LICENSE.md file included with this example. If you have any questions
* or concerns with licensing, please contact [email protected].
* Distributed as-is; no warranty is given.
*/
#include "pxt.h"
#include "MicroBit.h"
#include "MediaReporter.h"
#include "debug.h"
static MediaReporter *reporter = NULL;
using namespace pxt;
namespace media {
bool isInitialized() {
if(reporter == NULL) {
uBit.display.scroll("Media not started");
return false;
} else {
return true;
}
}
//%
void startMediaService() {
if(reporter == NULL) {
reporter = MediaReporter::getInstance();
}
}
//%
void sendCode(uint8_t number) {
if(!isInitialized()) return;
reporter->sendCode(number);
reporter->sendCode(0);
}
//%
bool isEnabled() {
DEBUG("Media isEnabled\n");
return reporter ? reporter->isEnabled() : false;
}
//%
void setStatusChangeHandler(Action action) {
if(!reporter) return;
reporter->setStatusChangeHandler(action);
}
}