Add music
This commit is contained in:
25
libs/core/control.cpp
Normal file
25
libs/core/control.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
#include "pxt.h"
|
||||
|
||||
namespace control {
|
||||
|
||||
/**
|
||||
* Announce that an event happened to registered handlers.
|
||||
* @param src ID of the Component that generated the event
|
||||
* @param value Component specific code indicating the cause of the event.
|
||||
* @param mode optional definition of how the event should be processed after construction.
|
||||
*/
|
||||
//% weight=21 blockGap=12 blockId="control_raise_event"
|
||||
//% block="raise event|from %src|with value value" blockExternalInputs=1
|
||||
void raiseEvent(int src, int value) {
|
||||
pxt::raiseEvent(src, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocates the next user notification event
|
||||
*/
|
||||
//% help=control/allocate-notify-event
|
||||
int allocateNotifyEvent() {
|
||||
return pxt::allocateNotifyEvent();
|
||||
}
|
||||
|
||||
}
|
3
libs/core/dal.d.ts
vendored
3
libs/core/dal.d.ts
vendored
@ -647,6 +647,9 @@ declare const enum DAL {
|
||||
// built/dockermake/node_modules/ev3api-bin/include/uart.h
|
||||
// built/dockermake/pxtapp/pxt.h
|
||||
ID_BUTTON_BASE = 100,
|
||||
DEVICE_EVT_ANY = 0,
|
||||
DEVICE_ID_NOTIFY = 10000,
|
||||
DEVICE_ID_NOTIFY_ONE = 10001,
|
||||
// built/dockermake/pxtapp/pxtbase.h
|
||||
PXT_REF_TAG_STRING = 1,
|
||||
PXT_REF_TAG_BUFFER = 2,
|
||||
|
@ -9,8 +9,6 @@
|
||||
#include <assert.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define DEVICE_EVT_ANY 0
|
||||
|
||||
void *operator new(size_t size) {
|
||||
return malloc(size);
|
||||
}
|
||||
@ -237,6 +235,14 @@ static void *evtDispatcher(void *dummy) {
|
||||
}
|
||||
}
|
||||
|
||||
int allocateNotifyEvent() {
|
||||
static volatile int notifyId;
|
||||
pthread_mutex_lock(&eventMutex);
|
||||
int res = ++notifyId;
|
||||
pthread_mutex_unlock(&eventMutex);
|
||||
return res;
|
||||
}
|
||||
|
||||
void raiseEvent(int id, int event) {
|
||||
auto e = mkEvent(id, event);
|
||||
pthread_mutex_lock(&eventMutex);
|
||||
@ -293,5 +299,4 @@ void dmesg(const char *format, ...) {
|
||||
fflush(dmesgFile);
|
||||
fdatasync(fileno(dmesgFile));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
namespace pxt {
|
||||
void raiseEvent(int id, int event);
|
||||
int allocateNotifyEvent();
|
||||
void sleep_core_us(uint64_t us);
|
||||
|
||||
class Button;
|
||||
@ -15,4 +16,8 @@ typedef Button *Button_;
|
||||
extern "C" void target_init();
|
||||
}
|
||||
|
||||
#define DEVICE_EVT_ANY 0
|
||||
#define DEVICE_ID_NOTIFY 10000
|
||||
#define DEVICE_ID_NOTIFY_ONE 10001
|
||||
|
||||
#endif
|
||||
|
@ -7,6 +7,7 @@
|
||||
"pxt.h",
|
||||
"pxtcore.h",
|
||||
"linux.cpp",
|
||||
"control.cpp",
|
||||
"buttons.cpp",
|
||||
"screen.cpp",
|
||||
"screen.ts",
|
||||
|
18
libs/core/shims.d.ts
vendored
18
libs/core/shims.d.ts
vendored
@ -1,4 +1,22 @@
|
||||
// Auto-generated. Do not edit.
|
||||
declare namespace control {
|
||||
|
||||
/**
|
||||
* Announce that an event happened to registered handlers.
|
||||
* @param src ID of the Component that generated the event
|
||||
* @param value Component specific code indicating the cause of the event.
|
||||
* @param mode optional definition of how the event should be processed after construction.
|
||||
*/
|
||||
//% weight=21 blockGap=12 blockId="control_raise_event"
|
||||
//% block="raise event|from %src|with value value" blockExternalInputs=1 shim=control::raiseEvent
|
||||
function raiseEvent(src: int32, value: int32): void;
|
||||
|
||||
/**
|
||||
* Allocates the next user notification event
|
||||
*/
|
||||
//% help=control/allocate-notify-event shim=control::allocateNotifyEvent
|
||||
function allocateNotifyEvent(): int32;
|
||||
}
|
||||
declare namespace input {
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user