From 6b5dd6c07bacdd6d3d143671a31e0adf87b06055 Mon Sep 17 00:00:00 2001 From: Michal Moskal Date: Mon, 10 Jul 2017 11:42:30 +0100 Subject: [PATCH] Add control.dmesg --- libs/core/control.cpp | 5 +++++ libs/core/core.ts | 2 +- libs/core/input.ts | 4 ++-- libs/core/pxtcore.h | 2 +- libs/core/shims.d.ts | 4 ++++ 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/libs/core/control.cpp b/libs/core/control.cpp index 00cbb611..c291a452 100644 --- a/libs/core/control.cpp +++ b/libs/core/control.cpp @@ -22,4 +22,9 @@ int allocateNotifyEvent() { return pxt::allocateNotifyEvent(); } +/** Write data to DMESG debugging buffer. */ +//% +void dmesg(String s) { + DMESG("# %s", s->data); +} } diff --git a/libs/core/core.ts b/libs/core/core.ts index 6587e2d8..4f896f65 100644 --- a/libs/core/core.ts +++ b/libs/core/core.ts @@ -1,4 +1,4 @@ -namespace core { +namespace control { let nextComponentId = 20000; export class Component { diff --git a/libs/core/input.ts b/libs/core/input.ts index d5de41a2..08b6376a 100644 --- a/libs/core/input.ts +++ b/libs/core/input.ts @@ -116,7 +116,7 @@ namespace input.internal { } } - export class Sensor extends core.Component { + export class Sensor extends control.Component { protected port: number constructor() { @@ -407,7 +407,7 @@ namespace input.internal { } namespace input { - export class ButtonWrapper extends core.Component { + export class ButtonWrapper extends control.Component { private downTime: number; private _isPressed: boolean; private _wasPressed: boolean; diff --git a/libs/core/pxtcore.h b/libs/core/pxtcore.h index c85c8fde..fb98e3b3 100644 --- a/libs/core/pxtcore.h +++ b/libs/core/pxtcore.h @@ -3,7 +3,7 @@ namespace pxt { void dmesg(const char *fmt, ...); -#define DMESG dmesg +#define DMESG pxt::dmesg } #endif diff --git a/libs/core/shims.d.ts b/libs/core/shims.d.ts index 128e5879..d6da5179 100644 --- a/libs/core/shims.d.ts +++ b/libs/core/shims.d.ts @@ -51,6 +51,10 @@ declare namespace control { */ //% help=control/allocate-notify-event shim=control::allocateNotifyEvent function allocateNotifyEvent(): int32; + + /** Write data to DMESG debugging buffer. */ + //% shim=control::dmesg + function dmesg(s: string): void; } declare namespace input {