integrated pxt-microbit
This commit is contained in:
@ -1,4 +0,0 @@
|
||||
# core
|
||||
|
||||
The core library.
|
||||
|
@ -1,240 +0,0 @@
|
||||
{
|
||||
"Math.randomBoolean":"يقوم بإنشاء قيمة 'صحيح' أو 'false' عشوائياً، تماما مثل التقليب عمله.",
|
||||
"Math.randomBoolean|block":"اختيار عشوائي true أو false",
|
||||
"Math|block":"الرياضيات",
|
||||
"String.fromCharCode":"جعل سلسلة من رمز الحرف ASCII معطى.",
|
||||
"String.fromCharCode|block":"النص من حرف رمز %code",
|
||||
"String|block":"السلسلة",
|
||||
"basic":"يوفر الوصول إلى الوظيفة الأساسية الصغرى: بت.",
|
||||
"basic.clearScreen":"إيقاف تشغيل كافة المصابيح",
|
||||
"basic.clearScreen|block":"مسح الشاشة",
|
||||
"basic.forever":"تكرار التعليمات البرمجية إلى الأبد في الخلفية. في كل تكرار، يسمح رموز أخرى لتشغيل.",
|
||||
"basic.forever|block":"إلى الأبد",
|
||||
"basic.pause":"إيقاف مؤقت للوقت المحدد بالمللي ثانية",
|
||||
"basic.pause|block":"إيقاف %pause (مللي ثانية)",
|
||||
"basic.pause|param|ms":"كم من الوقت للتوقف، على سبيل المثال: 100، 200، 500، 1000، 2000",
|
||||
"basic.plotLeds":"يرسم صورة على شاشة LED.",
|
||||
"basic.plotLeds|param|leds":"نمط من المصابيح لتشغيل\/إيقاف تشغيل",
|
||||
"basic.showAnimation":"ويبين تسلسل الشاشات LED كالرسوم متحركة.",
|
||||
"basic.showAnimation|param|interval":"الوقت بالمللي ثانية بين كل رسم",
|
||||
"basic.showAnimation|param|leds":"نمط من المصابيح لتشغيل\/إيقاف تشغيل",
|
||||
"basic.showLeds":"يرسم صورة على شاشة LED.",
|
||||
"basic.showLeds|block":"إظهار المصابيح",
|
||||
"basic.showLeds|param|interval":"الوقت بالمللي ثانية وقفه بعد الرسم",
|
||||
"basic.showLeds|param|leds":"نمط الصمام لتشغيل\/إيقاف تشغيل",
|
||||
"basic.showNumber":"قم بالتمرير رقم على الشاشة. إذا كان العدد يناسب على الشاشة (أي هو رقم واحد)، لا يتم تمرير.",
|
||||
"basic.showNumber|block":"show|number %number",
|
||||
"basic.showNumber|param|interval":"سرعة التمرير؛ على سبيل المثال: 150، 200-100، 100",
|
||||
"basic.showString":"عرض النص على الشاشة، حرف واحد في كل مرة. إذا كانت السلسلة يناسب على الشاشة (أي حرف واحد)، لا يتم تمرير.",
|
||||
"basic.showString|block":"show|string %text",
|
||||
"basic.showString|param|interval":"طريقة سريعة لتحويل الأحرف؛ على سبيل المثال: 150، 200-100، 100",
|
||||
"basic.showString|param|text":"النص للتمرير على الشاشة، على سبيل المثال: \"مرحبا!\"",
|
||||
"basic|block":"الأساسية",
|
||||
"control":"المرافق وقت التشغيل والحدث.",
|
||||
"control.inBackground":"الجداول الزمنية للتعليمات البرمجية التي يتم تشغيلها في الخلفية.",
|
||||
"control.inBackground|block":"تشغيل في الخلفية",
|
||||
"control.reset":"يعيد تعيين الصغير: بت ال بي بي سي.",
|
||||
"control.reset|block":"إعادة تعيين",
|
||||
"control|block":"التحكم",
|
||||
"game":"محرك لعبة واحدة تقودها العفريت",
|
||||
"game.addScore":"إضافة نقاط إلى النتيجة الحالية",
|
||||
"game.addScore|block":"تغيير درجة by|%points",
|
||||
"game.addScore|param|points":"كمية من النقاط لتغيير، على سبيل المثال: 1",
|
||||
"game.gameOver":"يعرض لعبة الرسوم المتحركة.",
|
||||
"game.gameOver|block":"انتهت اللعبة",
|
||||
"game.score":"يحصل على النتيجة الحالية",
|
||||
"game.score|block":"نقاط",
|
||||
"game.setScore":"تعيين القيمة إلى النتيجة الحالية",
|
||||
"game.setScore|param|value":"تودو",
|
||||
"game.startCountdown":"بدء تشغيل جهاز ضبط وقت العد التنازلي لعبة",
|
||||
"game.startCountdown|block":"بدء تشغيل countdown| (مللي ثانية) %duration",
|
||||
"game.startCountdown|param|ms":"مدة العد التنازلي في ميلي ثانية، على سبيل المثال: 10000",
|
||||
"game|block":"لعبة",
|
||||
"images":"إنشاء والتلاعب وعرض الصور الصمام.",
|
||||
"images.createBigImage":"يقوم بإنشاء صورة مع إطارات 2.",
|
||||
"images.createBigImage|block":"إنشاء صورة كبيرة",
|
||||
"images.createImage":"يقوم بإنشاء صورة التي تناسبها على شاشة LED.",
|
||||
"images.createImage|block":"إنشاء الصورة",
|
||||
"images|block":"الصور",
|
||||
"input":"الأحداث والبيانات من أجهزة الاستشعار",
|
||||
"input.acceleration":"الحصول على قيمة التسارع في المجلس الملي-جرافيتيس (عندما يتم إرساء المجلس شقة مع الشاشة حتى, x = 0, y = 0 و z = 1024)",
|
||||
"input.acceleration|block":"|%NAME التسارع (mg)",
|
||||
"input.acceleration|param|dimension":"تودو",
|
||||
"input.buttonIsPressed":"الحصول على حالة زر (ضغط أو لا) '' '' و '' ب ''.",
|
||||
"input.buttonIsPressed|block":"button|%NAME|is الضغط",
|
||||
"input.calibrate":"معايرة بوصلة عفا عليها الزمن، والتلقائي.",
|
||||
"input.compassHeading":"الحصول على عنوان البوصلة البوصلة الحالية في درجات.",
|
||||
"input.compassHeading|block":"بوصلة العنوان (°)",
|
||||
"input.lightLevel":"يقرأ مستوى الضوء المطبقة على شاشة LED في طائفة من '' 0 '' (الظلام) إلى 255 '' '' مشرق.",
|
||||
"input.lightLevel|block":"مستوى الضوء",
|
||||
"input.magneticForce":"الحصول على قيمة القوة المغناطيسية في '' الصغرى-Teslas '' ('' µT ''). هذه الوظيفة غير معتمدة في المحاكاة.",
|
||||
"input.magneticForce|block":"القوة المغناطيسية (µT) |%NAME",
|
||||
"input.magneticForce|param|dimension":"تودو",
|
||||
"input.onButtonPressed":"القيام بشيء عند الضغط على زر ('' '' أو '' ب '' أو كلا '' أ + ب '')",
|
||||
"input.onButtonPressed|block":"على button|%NAME|pressed",
|
||||
"input.onButtonPressed|param|body":"تودو",
|
||||
"input.onButtonPressed|param|button":"تودو",
|
||||
"input.onGesture":"وتولى تشغيل التعليمات البرمجية عند هو مواجهة الشاشة.",
|
||||
"input.onGesture|block":"على |%NAME",
|
||||
"input.onGesture|param|body":"تودو",
|
||||
"input.onLogoDown":"وتولى تشغيل التعليمات البرمجية عند الشعار وتتجه نزولا والمجلس بشكل عمودي.",
|
||||
"input.onLogoDown|param|body":"تودو",
|
||||
"input.onLogoUp":"وتولى تشغيل التعليمات البرمجية عند الشعار وتتجه صعودا والمجلس بشكل عمودي.",
|
||||
"input.onLogoUp|param|body":"تودو",
|
||||
"input.onPinPressed":"تفعل شيئا عند الضغط على رقم التعريف الشخصي ('' P0 '' أو '' P1 '' أو كلا '' P2 '').",
|
||||
"input.onPinPressed|block":"على pin|%NAME|pressed",
|
||||
"input.onPinPressed|param|body":"تودو",
|
||||
"input.onPinPressed|param|name":"تودو",
|
||||
"input.onScreenDown":"وتولى تشغيل التعليمات البرمجية عند هو أسفل الشاشة.",
|
||||
"input.onScreenDown|param|body":"تودو",
|
||||
"input.onScreenUp":"وتولى تشغيل التعليمات البرمجية عند هو مواجهة الشاشة.",
|
||||
"input.onScreenUp|param|body":"تودو",
|
||||
"input.onShake":"وتولى تشغيل التعليمات البرمجية عند هو هز الجهاز.",
|
||||
"input.onShake|param|body":"تودو",
|
||||
"input.pinIsPressed":"الحصول على دولة طرف (ضغط أو لا). ويتطلب عقد الأرض من أجل إغلاق الدائرة.",
|
||||
"input.pinIsPressed|block":"pin|%NAME|is الضغط",
|
||||
"input.pinIsPressed|param|name":"دبوس المستخدمة للكشف عن لمسة",
|
||||
"input.rotation":"الملعب للجهاز، وتناوب على طول '' المحور ''، بدرجات.",
|
||||
"input.rotation|block":"|%NAME دوران (°)",
|
||||
"input.rotation|param|kind":"تودو",
|
||||
"input.runningTime":"يحصل على عدد المللي ثانية المنقضية منذ السلطة في.",
|
||||
"input.runningTime|block":"إدارة الوقت (مللي ثانية)",
|
||||
"input.setAccelerometerRange":"يعين نطاق العينة التسارع في جاذبيات.",
|
||||
"input.setAccelerometerRange|block":"تعيين نطاق % accelerometer|range",
|
||||
"input.setAccelerometerRange|param|range":"قيمة وصف قوتها القصوى لقياس التسارع",
|
||||
"input.temperature":"يحصل على درجة حرارة مئوية درجات (درجة مئوية).",
|
||||
"input.temperature|block":"درجة الحرارة (درجة مئوية)",
|
||||
"input|block":"الإدخال",
|
||||
"led":"التحكم في شاشة LED.",
|
||||
"led.brightness":"الحصول على سطوع الشاشة من 0 (إيقاف) إلى 255 (مشرق كامل).",
|
||||
"led.brightness|block":"سطوع",
|
||||
"led.fadeIn":"يتلاشى في العرض على الشاشة.",
|
||||
"led.fadeIn|param|ms":"تودو",
|
||||
"led.fadeOut":"إخفاء مستوى سطوع الشاشة.",
|
||||
"led.fadeOut|param|ms":"تودو",
|
||||
"led.plot":"قم بتشغيل باستخدام الصمام المحدد x, y إحداثيات (س الأفقي، ص العمودي). (0, 0) هو أعلى اليسار.",
|
||||
"led.plotAll":"تشغيل كافة المصابيح",
|
||||
"led.plotBarGraph":"يعرض رسم بياني شريطي عمودي استناداً إلى 'قيمة' والقيمة 'عالية'.\nإذا كان 'عالية' هو 0، ويحصل ضبط التخطيط تلقائياً.",
|
||||
"led.plotBarGraph|block":"رسم بياني شريطي من الإقلاع القيمة % إلى %high",
|
||||
"led.plotBarGraph|param|high":"الحد الأقصى للقيمة. إذا كان 0, الحد الأقصى للقيمة المعدلة تلقائياً، على سبيل المثال: 0",
|
||||
"led.plotBarGraph|param|value":"القيمة الحالية الأرض",
|
||||
"led.plot|block":"plot|x %x|y %y",
|
||||
"led.plot|param|x":"تودو",
|
||||
"led.plot|param|y":"تودو",
|
||||
"led.point":"الحصول على حالة تشغيل\/إيقاف استخدام الصمام المحدد x, y إحداثيات. (0, 0) هو أعلى اليسار.",
|
||||
"led.point|block":"point|x %x|y %y",
|
||||
"led.point|param|x":"تودو",
|
||||
"led.point|param|y":"تودو",
|
||||
"led.screenshot":"تأخذ لقطة للشاشة LED وترجع صورة.",
|
||||
"led.setBrightness":"تعيين سطوع الشاشة من 0 (إيقاف) إلى 255 (مشرق كامل).",
|
||||
"led.setBrightness|block":"قم بتعيين القيمة % السطوع",
|
||||
"led.setBrightness|param|value":"قيمة السطوع، على سبيل المثال: 255، 127، 0",
|
||||
"led.setDisplayMode":"تعيين وضع العرض بين الأسود والأبيض واللون الرمادي لجعلها المصابيح.",
|
||||
"led.setDisplayMode|param|mode":"تودو",
|
||||
"led.stopAnimation":"إلغاء الحركة الحالية ومسح أخرى انتظارا للرسوم المتحركة.",
|
||||
"led.stopAnimation|block":"وقف الرسوم المتحركة",
|
||||
"led.toggle":"يبدل بكسل خاص",
|
||||
"led.toggleAll":"عكس العرض LED الحالية",
|
||||
"led.toggle|param|x":"تودو",
|
||||
"led.toggle|param|y":"تودو",
|
||||
"led.unplot":"إيقاف استخدام الصمام المحدد x, y إحداثيات (س الأفقي، ص العمودي). (0, 0) هو أعلى اليسار.",
|
||||
"led.unplot|block":"unplot|x %x|y %y",
|
||||
"led.unplot|param|x":"تودو",
|
||||
"led.unplot|param|y":"تودو",
|
||||
"led|block":"شاشة",
|
||||
"music":"جيل نغمات الموسيقى عن طريق الرقم السري '''' P0 ''.",
|
||||
"music.beat":"إرجاع المدة للفوز في ميلي ثانية",
|
||||
"music.beat|block":"%fraction|beat",
|
||||
"music.changeTempoBy":"تغيير الإيقاع بالمبلغ المحدد",
|
||||
"music.changeTempoBy|block":"تغيير الإيقاع بواسطة (bpm) | قيمة %",
|
||||
"music.changeTempoBy|param|bpm":"التغيير في دقات في الدقيقة الواحدة للايقاع، على سبيل المثال: 20",
|
||||
"music.noteFrequency":"يحصل على تكرار الملاحظة.",
|
||||
"music.noteFrequency|block":"%note",
|
||||
"music.noteFrequency|param|name":"ملاحظة اسم",
|
||||
"music.playTone":"يلعب نغمة عن طريق الرقم السري '''' P0 '' لمدة معينة.",
|
||||
"music.playTone|block":"play|tone %note = device_note|for %duration = device_beat",
|
||||
"music.playTone|param|frequency":"الملعب لهجة للعب في هرتز (هرتز)",
|
||||
"music.playTone|param|ms":"مدة نغمة في ميلي ثانية (مللي ثانية)",
|
||||
"music.rest":"تقع (يلعب شيئا) لفترة زمنية محددة عن طريق الرقم السري '''' P0 ''.",
|
||||
"music.rest|block":"|%duration بقية (مللي ثانية) = device_beat",
|
||||
"music.rest|param|ms":"مدة الراحة في ميلي ثانية (مللي ثانية)",
|
||||
"music.ringTone":"يلعب نغمة عن طريق الرقم السري '''' P0 ''.",
|
||||
"music.ringTone|block":"عصابة لهجة (هرتز) |%note = device_note",
|
||||
"music.ringTone|param|frequency":"الملعب لهجة للعب في هرتز (هرتز)",
|
||||
"music.setTempo":"يحدد وتيرة إلى المبلغ المحدد",
|
||||
"music.setTempo|block":"ضبط الإيقاع (نبضة في الدقيقة) | قيمة %",
|
||||
"music.setTempo|param|bpm":"يدق على وتيرة جديدة في كل دقيقة، على سبيل المثال: 120",
|
||||
"music.tempo":"تقوم بإرجاع الإيقاع في نبضة في الدقيقة. الإيقاع هو السرعة (bpm = نبضة في الدقيقة) في اللعب وتلاحظ فيه. أكبر قيمة الإيقاع، سيتم تشغيل أسرع وتلاحظ.",
|
||||
"music.tempo|block":"الإيقاع (نبضة في الدقيقة)",
|
||||
"music|block":"الموسيقى",
|
||||
"pins":"التحكم في التيارات في دبابيس للإشارات التناظرية\/الرقمية، الماكينات، i2c،...",
|
||||
"pins.analogPitch":"يبث إشارات تحوير (بوم) عرض نبض بدبوس الملعب الحالي. استخدام 'النظير تعيين pin الملعب' لتعريف pin في الملعب.",
|
||||
"pins.analogPitch|param|frequency":"تودو",
|
||||
"pins.analogPitch|param|ms":"تودو",
|
||||
"pins.analogReadPin":"قراءة القيمة موصل النظير، وهذا هو، كقيمة بين 0 و 1023 وتتألف.",
|
||||
"pins.analogReadPin|block":"%name read|pin التناظرية",
|
||||
"pins.analogReadPin|param|name":"دبوس الكتابة إلى",
|
||||
"pins.analogSetPeriod":"تكوين تحوير عرض النبضة (PWM) التناظرية المخرجات إلى قيمة معينة في * * ميكرو * * أو '' 1\/1000 ميلي ثانية.\nإذا لم يتم تكوين هذا الدبوس تمثيلي الإخراج (باستخدام 'الكتابة التناظرية دبوس')، قد العملية أي تأثير.",
|
||||
"pins.analogSetPeriod|block":"تعيين النظير period|pin %pin|to مايكروون % (المايكروثانيه)",
|
||||
"pins.analogSetPeriod|param|micros":"الفترة في الدقيقة ثانية. على سبيل المثال: 20000",
|
||||
"pins.analogSetPeriod|param|name":"دبوس التناظرية لتعيين الفترة إلى",
|
||||
"pins.analogSetPitchPin":"تعيين رقم pin المستخدم عند استخدام 'دبابيس-> التناظرية في الملعب'.",
|
||||
"pins.analogSetPitchPin|param|name":"تودو",
|
||||
"pins.analogWritePin":"تعيين القيمة رابط تمثيلي. يجب أن تتألف القيمة بين 0 و 1023.",
|
||||
"pins.analogWritePin|block":"القيمة % %name|to write|pin التناظرية",
|
||||
"pins.analogWritePin|param|name":"اسم دبوس الكتابة إلى",
|
||||
"pins.analogWritePin|param|value":"قيمة لكتابة رقم التعريف الشخصي بين '' 0 '' و '' 1023 ''. على سبيل المثال: 1023, 0",
|
||||
"pins.digitalReadPin":"قراءة المحدد رقم pin أو موصل أما 0 أو 1",
|
||||
"pins.digitalReadPin|block":"read|pin رقمي %name",
|
||||
"pins.digitalReadPin|param|name":"رقم التعريف الشخصي لقراءة من",
|
||||
"pins.digitalWritePin":"تعيين قيمة رقم pin أو الرابط إلى 0 أو 1.",
|
||||
"pins.digitalWritePin|block":"القيمة % %name|to write|pin الرقمي",
|
||||
"pins.digitalWritePin|param|name":"دبوس الكتابة إلى",
|
||||
"pins.digitalWritePin|param|value":"قيمة لتعيين رقم pin، 1 على سبيل المثال، 0",
|
||||
"pins.i2cReadNumber":"قراءة رقم واحد من عنوان I2C 7 بت.",
|
||||
"pins.i2cReadNumber|block":"i2c قراءة عنوان number|at %address|of الشكل %format = i2c_sizeof",
|
||||
"pins.i2cWriteNumber":"كتابة رقم واحد لعنوان I2C 7 بت.",
|
||||
"pins.i2cWriteNumber|block":"i2c يكتب عنوان number|at %address|with % قيمة value|of %format الشكل = i2c_sizeof",
|
||||
"pins.map":"إعادة تعيين عدد من مجموعة واحدة إلى أخرى. فالحصول على تعيين قيمة '' من منخفضة '' إلى '' إلى انخفاض ''، قيمة '' من السامي '' إلى '' إلى ارتفاع ''، قيم الفترات الفاصلة بين القيم بينهما، إلخ.",
|
||||
"pins.map|block":"خريطة % value|from %fromLow|from منخفضة %fromHigh|to ارتفاع منخفض %toLow|to عالية %toHigh",
|
||||
"pins.map|param|fromHigh":"العليا ملزمة للنطاق الحالي للقيمة، على سبيل المثال: 1023",
|
||||
"pins.map|param|fromLow":"الحد الأدنى للنطاق الحالي للقيمة",
|
||||
"pins.map|param|toHigh":"الحد الأعلى المستهدفة القيمة تتراوح، على سبيل المثال: 4",
|
||||
"pins.map|param|toLow":"الحد الأدنى للنطاق المستهدف للقيمة",
|
||||
"pins.map|param|value":"قيمة للتعيين في نطاقات",
|
||||
"pins.onPulsed":"تكوين هذا الرقم السري لأحد مدخلات رقمية، وينشئ الأحداث حيث الطابع الزمني هو المدة التي كان هذا الرقم '' عالية '' أو '' منخفضة ''.",
|
||||
"pins.onPulsed|block":"on|pin %pin|pulsed %pulse",
|
||||
"pins.pulseDuration":"يحصل على مدة نبض الماضي في مايكرو-ثانية. يجب أن يتم استدعاء هذه الدالة من معالج '' أونبولسيد ''.",
|
||||
"pins.pulseDuration|block":"مدة النبضة (المايكروثانيه)",
|
||||
"pins.servoSetPulse":"تكوين هذا دبوس آيو كناتج التناظرية\/بوم وتكوين الفترة بأن يكون 20 مللي ثانية، وتعيين عرض النبض، استناداً إلى القيمة التي تعطي * * ميكرو * * أو '' 1\/1000 ميلي ثانية.",
|
||||
"pins.servoSetPulse|block":"تعيين مضاعفات pulse|pin value|to (المايكروثانيه) % % مايكروون",
|
||||
"pins.servoSetPulse|param|micros":"مدة النبضة في الدقيقة ثانية، على سبيل المثال: 1500",
|
||||
"pins.servoSetPulse|param|name":"اسم دبوس",
|
||||
"pins.servoWritePin":"تكتب قيمة إلى مضاعفات، السيطرة الرمح تبعاً لذلك. في مضاعفات قياسية، سيؤدي هذا إلى تعيين زاوية الرمح (بالدرجات)، تتحرك الرمح لهذا التوجه. في مضاعفات تناوب مستمر، وهذا سيتم تعيين سرعة الماكينة (مع '' 0 '''' بسرعة كاملة في اتجاه واحد، '' 180 '' يجري كامل السرعة في أخرى، وقيمة قرب '' 90 '' يجري أي حركة).",
|
||||
"pins.servoWritePin|block":"مضاعفات write|pin %name|to القيمة %",
|
||||
"pins.servoWritePin|param|name":"دبوس الكتابة إلى",
|
||||
"pins.servoWritePin|param|value":"زاوية أو التناوب سرعة، على سبيل المثال: 180، 90، 0",
|
||||
"pins.setPull":"تكوين السحب من هذا الرقم.",
|
||||
"pins.setPull|block":"تعيين pull|pin %pin|to %pull",
|
||||
"pins.setPull|param|name":"رقم التعريف الشخصي لتعيين وضع الانسحاب في",
|
||||
"pins.setPull|param|pull":"أحد تكوينات السحب مبيد: بولوب، المنسدلة، بولنوني ",
|
||||
"pins|block":"دبابيس",
|
||||
"serial":"قراءة وكتابة البيانات عبر اتصال تسلسلي.",
|
||||
"serial.readLine":"يقرأ سطر من النص من المنفذ التسلسلي.",
|
||||
"serial.readLine|block":"قراءة سطر للمسلسل",
|
||||
"serial.redirect":"بشكل حيوي تكوين مثيل تسلسلي استخدام دبابيس خلاف أوسبتكس واسبر.",
|
||||
"serial.redirect|block":"إعادة توجيه المسلسل to| TX %tx| RX % rx|at % معدل معدل الباود",
|
||||
"serial.redirect|param|rx":"دبوس الاستقبال الجديدة",
|
||||
"serial.redirect|param|tx":"دبابيس الإرسال الجديدة",
|
||||
"serial.writeLine":"طباعة سطر من النص للمسلسل",
|
||||
"serial.writeLine|block":"serial|write خط %text",
|
||||
"serial.writeNumber":"طباعة قيمة رقمية للمسلسل",
|
||||
"serial.writeNumber|block":"قيمة % رقم serial|write",
|
||||
"serial.writeString":"يرسل جزء من النص من خلال اتصال تسلسلي.",
|
||||
"serial.writeString|block":"كتابة المسلسل سلسلة %text",
|
||||
"serial.writeValue":"يكتب '' الاسم: قيمة '' زوج الخط للمسلسل.",
|
||||
"serial.writeValue|block":"serial|write قيمة %name| = القيمة %",
|
||||
"serial.writeValue|param|name":"اسم القيمة الدفق، على سبيل المثال: x",
|
||||
"serial.writeValue|param|value":"يكتب",
|
||||
"serial|block":"مصدر الاتصال"
|
||||
}
|
@ -1,92 +0,0 @@
|
||||
{
|
||||
"Math.randomBoolean":"Erzeugt einen \"echten\" oder \"falschen\" Wert zufällig, wie eine Münze werfen.",
|
||||
"String.fromCharCode":"Machen Sie eine Zeichenfolge aus den angegebenen ASCII-Zeichencode.",
|
||||
"basic":"Bietet Zugriff auf grundlegende Mikro: Bit-Funktionalität.",
|
||||
"basic.clearScreen":"Schalten Sie alle LEDs",
|
||||
"basic.forever":"Den Code für immer im Hintergrund wiederholt. Bei jeder Iteration können andere Codes ausgeführt.",
|
||||
"basic.pause":"Pause für die angegebene Zeit in Millisekunden",
|
||||
"basic.plotLeds":"Zeichnet ein Bild auf dem LED-Bildschirm.",
|
||||
"basic.showAnimation":"Zeigt eine Folge von LED-Screens als Animation.",
|
||||
"basic.showLeds":"Zeichnet ein Bild auf dem LED-Bildschirm.",
|
||||
"basic.showNumber":"Blättern Sie eine Zahl auf dem Bildschirm. Wenn die Zahl auf dem Bildschirm passt (d. h. eine einzelne Ziffer), nicht scrollen.",
|
||||
"basic.showString":"Text auf dem Display, ein Zeichen zu einem Zeitpunkt anzeigen. Wenn die Zeichenfolge auf dem Bildschirm passt (d. h. einen Buchstaben), wird kein Bildlauf.",
|
||||
"control":"Laufzeit und Ereignis-Dienstprogramme.",
|
||||
"control.inBackground":"Zeitpläne codieren, die im Hintergrund laufen.",
|
||||
"control.reset":"Das BBC-Mikro: Bit setzt.",
|
||||
"game":"Eine Einzel-LED-Sprite-game-engine",
|
||||
"game.addScore":"Den aktuellen Punktestand hinzugefügt Punkte",
|
||||
"game.gameOver":"Zeigt ein Spiel über Animation.",
|
||||
"game.score":"Ruft den aktuellen Punktestand",
|
||||
"game.setScore":"Legt den aktuellen Wert der Partitur",
|
||||
"game.startCountdown":"Startet einen Spiel Countdowntimer",
|
||||
"images":"Erstellung, Bearbeitung und Anzeige LED-Bilder.",
|
||||
"images.createBigImage":"Erzeugt ein Bild mit 2 Bildern.",
|
||||
"images.createImage":"Erstellt ein Bild, das passt auf dem LED-Bildschirm.",
|
||||
"input":"Ereignisse und Daten von Sensoren",
|
||||
"input.acceleration":"Der Beschleunigungswert in Milli-Gravitys zu bekommen (wenn das Board legt flach mit dem Bildschirm auf, X = 0, y = 0 und Z =-1024)",
|
||||
"input.buttonIsPressed":"Erhalten Sie den Zustand der Schaltfläche (gepresst oder nicht) für '' ein '' und '' B''.",
|
||||
"input.calibrate":"Veraltet, Kompass Kalibrierung erfolgt automatisch.",
|
||||
"input.compassHeading":"Erhalten Sie die aktuellen Kompass-Kompass-Kurs in Grad.",
|
||||
"input.lightLevel":"Liest die Lichtintensität auf dem LED-Bildschirm in einem Bereich von '' 0'' (dunkel) bis cm 255 cm hell angewendet.",
|
||||
"input.magneticForce":"Rufen Sie den Magnetkraft-Wert in cm Mikro-Tesla '' ('' µT''). Diese Funktion wird nicht im Simulator unterstützt.",
|
||||
"input.onButtonPressed":"Etwas zu tun, wenn eine ('' A'', '' B'' oder beide '' A + B'') gedrückt ist",
|
||||
"input.onGesture":"Fügt Code ausgeführt, wenn der Bildschirm nach oben.",
|
||||
"input.onLogoDown":"Fügt Code ausgeführt, wenn das Logo orientiert sich nach unten und das Board vertikal ist.",
|
||||
"input.onLogoUp":"Fügt Code ausgeführt, wenn das Logo orientiert sich nach oben und das Board vertikal ist.",
|
||||
"input.onPinPressed":"Tun Sie etwas, wenn eine Pin ('' P0'', '' P1'' oder beide '' P2'') gedrückt wird.",
|
||||
"input.onScreenDown":"Fügt Code ausgeführt, wenn der Bildschirm ist nach unten.",
|
||||
"input.onScreenUp":"Fügt Code ausgeführt, wenn der Bildschirm nach oben.",
|
||||
"input.onShake":"Fügt Code ausgeführt, wenn das Gerät geschüttelt wird.",
|
||||
"input.pinIsPressed":"Holen Sie sich den Pin-Zustand (gepresst oder nicht). Verlangt, die behaupten, die Schaltung zu schließen.",
|
||||
"input.rotation":"Die Tonhöhe des Geräts, Rotation entlang der '' x-Achse '' in Grad.",
|
||||
"input.runningTime":"Ruft die Anzahl der Millisekunden seit macht auf vergangen.",
|
||||
"input.setAccelerometerRange":"Legt den Beschleunigungsmesser Beispiel in Schwerkräfte.",
|
||||
"input.temperature":"Ruft die Temperatur in Celsius Grad (° C).",
|
||||
"led":"Steuerung von LED-Bildschirm.",
|
||||
"led.brightness":"Steigen Sie die Helligkeit des Bildschirms von 0 () bis 255 (volle hell).",
|
||||
"led.fadeIn":"Anzeige auf dem Bildschirm eingeblendet wird.",
|
||||
"led.fadeOut":"Die Helligkeit des Bildschirms ausgeblendet.",
|
||||
"led.plot":"Schalten Sie den angegebenen LED mit x \/ y-Koordinaten (X ist horizontal, y ist vertikal). (0,0) ist oben links.",
|
||||
"led.plotAll":"Schaltet alle LEDS",
|
||||
"led.plotBarGraph":"Zeigt eine vertikale Balkendiagramm anhand der 'Wert' und 'hoch' Wert.\nWenn 'hoch' ist 0, das Diagramm wird automatisch angepasst.",
|
||||
"led.point":"Erhalten Sie den ein-\/Zustand der angegebenen LED mit x \/ y-Koordinaten. (0,0) ist oben links.",
|
||||
"led.screenshot":"Nimmt einen Screenshot von dem LED-Bildschirm und gibt ein Bild.",
|
||||
"led.setBrightness":"Legen Sie die Helligkeit des Bildschirms von 0 (aus) auf 255 (volle hell).",
|
||||
"led.setDisplayMode":"Stellt den Anzeigemodus zwischen schwarz und weiß und Graustufen für das Rendern von LEDs.",
|
||||
"led.stopAnimation":"Bricht die aktuelle Animation und löscht andere ausstehende Animationen.",
|
||||
"led.toggle":"Schaltet ein bestimmtes Pixels",
|
||||
"led.toggleAll":"Kehrt die aktuelle LED-Anzeige",
|
||||
"led.unplot":"Schalten Sie den angegebenen LED mit x \/ y-Koordinaten (X ist horizontal, y ist vertikal). (0,0) ist oben links.",
|
||||
"music":"Generation der Musiktöne durch Pin '' P0''.",
|
||||
"music.beat":"Gibt die Dauer von einem Beat in Millisekunden",
|
||||
"music.changeTempoBy":"Das Tempo zu ändern, um den angegebenen Betrag",
|
||||
"music.noteFrequency":"Ruft die Frequenz einer Note.",
|
||||
"music.playTone":"Spielt einen Ton durch Pin '' P0'' für die angegebene Dauer.",
|
||||
"music.rest":"Ruht (spielt nichts) für eine bestimmte Zeit durch Pin '' P0''.",
|
||||
"music.ringTone":"Spielt einen Ton durch Pin '' P0''.",
|
||||
"music.setTempo":"Legt das Tempo auf den angegebenen Betrag",
|
||||
"music.tempo":"Gibt das Tempo in Schlägen pro Minute. Das Tempo ist die Geschwindigkeit (Bpm = Beats pro Minute) welche Noten spielen. Je größer der Tempowert werden desto schnelleren die Noten spielen.",
|
||||
"pins":"Steuerströmen Pins für analoge\/digitale Signale, Servos, i2c...",
|
||||
"pins.analogPitch":"Eine Puls-Weiten-Modulation (PWM) Signal an der aktuellen Tonhöhe Pin ausgibt. Verwenden Sie 'Analog legen Tonhöhe Pin' die Tonhöhe Pin definieren.",
|
||||
"pins.analogReadPin":"Lesen Sie den Connector-Wert als Analog, d. h. als Wert zwischen 0 und 1023.",
|
||||
"pins.analogSetPeriod":"Konfiguriert die Pulsweitenmodulation (PWM) über den analogen Ausgang auf den angegebenen Wert in ** Mikrosekunden ** oder \"1\/1000' Millisekunden.\nWenn dieser Pin nicht als ein analoger Ausgang (mit 'analog schreiben Pin') konfiguriert ist, ist die Operation wirkungslos.",
|
||||
"pins.analogSetPitchPin":"Legt die Pin mit 'Stifte-> analoge Tonhöhe' verwendet.",
|
||||
"pins.analogWritePin":"Legen Sie den Connector-Wert als analoge. Wert muss zwischen 0 und 1023 bestehen.",
|
||||
"pins.digitalReadPin":"Lesen Sie die angegebene Pin oder Connector als 0 oder 1",
|
||||
"pins.digitalWritePin":"Legen Sie einen Pin oder Connector Wert auf 0 oder 1.",
|
||||
"pins.i2cReadNumber":"Lesen Sie eine Zahl von 7-Bit-I2C-Adresse.",
|
||||
"pins.i2cWriteNumber":"Schreiben Sie eine Zahl in eine 7-Bit-I2C-Adresse.",
|
||||
"pins.map":"Re-Karten eine Zahl aus einem Bereich in einen anderen. D. h. ein Wert '' von Low '' würden '' zu niedrig '', '' von hoher '' der Wert bis cm zu hoch '' Werte dazwischen zu Werte dazwischen, etc. zugeordnet bekommen.",
|
||||
"pins.onPulsed":"Dieser Pin mit einem digitalen Eingang konfiguriert, und generiert Ereignisse wo der Zeitstempel die Dauer ist, die dieser Pin entweder '' hoch '' oder '' niedrig '' war.",
|
||||
"pins.pulseDuration":"Ruft die Dauer des letzten Impulses in Mikrosekunden. Diese Funktion sollte von einem '' OnPulsed''-Handler aufgerufen werden.",
|
||||
"pins.servoSetPulse":"Konfiguriert dieser IO-Pin als Ausgang Analog\/Pwm, konfiguriert den Zeitraum um 20 ms zu sein und legt die Pulslänge, basierend auf dem Wert ist es gegeben ** Mikrosekunden ** oder \"1\/1000' Millisekunden.",
|
||||
"pins.servoWritePin":"Schreibt einen Wert in das Servo Steuerung der Welle entsprechend. Auf einem standard-Servo wird dies den Winkel der Welle (in Grad), Umzug der Welle in dieser Ausrichtung festgelegt. Auf eine kontinuierliche Rotation-Servo wird dies die Geschwindigkeit der Servo (mit '' 0'' wird Höchstgeschwindigkeit in der einen Richtung cm 180 cm voll zu beschleunigen, in die andere und einen Wert in der Nähe von '' 90 cm wird keine Bewegung) festgelegt.",
|
||||
"pins.setPull":"Die Anziehungskraft dieser Pin konfiguriert.",
|
||||
"serial":"Lesen und Schreiben von Daten über eine serielle Verbindung.",
|
||||
"serial.readLine":"Liest eine Textzeile aus der seriellen Schnittstelle.",
|
||||
"serial.redirect":"Dynamisch konfigurieren die serielle Instanz um Pins als USBTX und USBRX verwenden.",
|
||||
"serial.writeLine":"Druckt eine Textzeile an die serielle",
|
||||
"serial.writeNumber":"Druckt einen numerischen Wert an die serielle",
|
||||
"serial.writeString":"Sendet ein Stück Text über serielle Verbindung.",
|
||||
"serial.writeValue":"Schreibt ein '' Name: Wert '' Zeile an die serielle Paar."
|
||||
}
|
@ -1,92 +0,0 @@
|
||||
{
|
||||
"Math.randomBoolean":"Genera un valor 'verdadero' o 'false' al azar, al igual que una moneda de los bancos.",
|
||||
"String.fromCharCode":"Hacer una cadena desde el código de carácter ASCII dado.",
|
||||
"basic":"Proporciona acceso a funcionalidad básica micro: bit.",
|
||||
"basic.clearScreen":"Apagar todos los LEDs",
|
||||
"basic.forever":"Repite el código para siempre en el fondo. En cada iteración, permite otros códigos ejecutar.",
|
||||
"basic.pause":"Pausa para el tiempo especificado en milisegundos",
|
||||
"basic.plotLeds":"Dibuja una imagen en la pantalla de LED.",
|
||||
"basic.showAnimation":"Muestra una secuencia de pantallas de LED como una animación.",
|
||||
"basic.showLeds":"Dibuja una imagen en la pantalla de LED.",
|
||||
"basic.showNumber":"Desplácese a un número en la pantalla. Si el número cabe en la pantalla (es decir, es un solo dígito), no se desplazan.",
|
||||
"basic.showString":"Mostrar texto en la pantalla, un carácter a la vez. Si la cadena encaja en la pantalla (es decir, es una letra), no se desplacen.",
|
||||
"control":"Utilidades de tiempo de ejecución y evento.",
|
||||
"control.inBackground":"Horarios de código que se ejecutan en segundo plano.",
|
||||
"control.reset":"Restablece el BBC micro: bit.",
|
||||
"game":"Un motor de juego de sprite solo LED",
|
||||
"game.addScore":"Añade puntos a la cuenta corriente",
|
||||
"game.gameOver":"Muestra un juego más de animación.",
|
||||
"game.score":"Obtiene la puntuación actual",
|
||||
"game.setScore":"Establece el valor de cuenta actual",
|
||||
"game.startCountdown":"Comienza un temporizador de cuenta atrás juego",
|
||||
"images":"Creación, manipulación y visualización de imágenes LED.",
|
||||
"images.createBigImage":"Crea una imagen con 2 marcos.",
|
||||
"images.createImage":"Crea una imagen que encaja en la pantalla de LED.",
|
||||
"input":"Eventos y datos de los sensores",
|
||||
"input.acceleration":"Obtener el valor de la aceleración en milli-gravitys (cuando es poner la junta plana con la pantalla hacia arriba, x = 0, y = 0 y z =-1024)",
|
||||
"input.buttonIsPressed":"Obtener el estado de botón (presionado o no) para '' A'' y '' B''.",
|
||||
"input.calibrate":"Obsoleto, brújula calibración es automática.",
|
||||
"input.compassHeading":"Consigue el actual rumbo de la brújula brújula en grados.",
|
||||
"input.lightLevel":"Lee el nivel de luz aplicado a la pantalla de LED en un rango de '' 0'' (oscuro) a '' 255'' brillante.",
|
||||
"input.magneticForce":"Obtener el valor de la fuerza magnética en '' micro Teslas'' ('' μT ''). Esta función no se admite en el simulador.",
|
||||
"input.onButtonPressed":"Hacer algo cuando se pulsa un botón ('' A'', '' B'' o ambos '' A + B'')",
|
||||
"input.onGesture":"Concede el código a ejecutar cuando la pantalla quede mirando hacia arriba.",
|
||||
"input.onLogoDown":"Concede el código a ejecutar cuando el logo está orientado hacia abajo y el tablero es vertical.",
|
||||
"input.onLogoUp":"Concede el código a ejecutar cuando el logo está orientado hacia arriba y el tablero es vertical.",
|
||||
"input.onPinPressed":"Hacer algo cuando se pulsa un pin ('' P0'', '' P1'' o '' ambos P2'').",
|
||||
"input.onScreenDown":"Concede el código a ejecutar cuando la pantalla esté hacia abajo.",
|
||||
"input.onScreenUp":"Concede el código a ejecutar cuando la pantalla quede mirando hacia arriba.",
|
||||
"input.onShake":"Concede el código a ejecutar cuando se agita el dispositivo.",
|
||||
"input.pinIsPressed":"Obtener el estado de pin (presionado o no). Requiere para mantener el suelo para cerrar el circuito.",
|
||||
"input.rotation":"El tono del dispositivo de rotación a lo largo del '' x '', en grados.",
|
||||
"input.runningTime":"Obtiene. que el número de milisegundos transcurrido desde el poder.",
|
||||
"input.setAccelerometerRange":"Establece el intervalo de muestra de acelerómetro en gravedades.",
|
||||
"input.temperature":"Obtiene la temperatura en grados Celsius grados (° C).",
|
||||
"led":"Control de la pantalla LED.",
|
||||
"led.brightness":"Bajar el brillo de la pantalla de 0 () a 255 (completo brillante).",
|
||||
"led.fadeIn":"Difumina en la pantalla.",
|
||||
"led.fadeOut":"Se descolora hacia fuera el brillo de la pantalla.",
|
||||
"led.plot":"Encienda el LED especificado usando, coordenadas x y (x es horizontal, es vertical). (0,0) es la parte superior izquierda.",
|
||||
"led.plotAll":"Enciende todos los LEDS",
|
||||
"led.plotBarGraph":"Muestra un gráfico de barras vertical basado en el 'valor' y ' valor '.\nSi 'alto' es 0, la carta es ajustada automáticamente.",
|
||||
"led.point":"Obtener el estado de encendido de la especificada usando LED, coordenadas x y. (0,0) es la parte superior izquierda.",
|
||||
"led.screenshot":"Toma una captura de pantalla de la pantalla LED y devuelve una imagen.",
|
||||
"led.setBrightness":"Configurar el brillo de la pantalla de 0 (off) a 255 (completo brillante).",
|
||||
"led.setDisplayMode":"Establece el modo de pantalla entre el blanco y negro y escala de grises para la representación de LEDs.",
|
||||
"led.stopAnimation":"Cancela la animación actual y borra otros pendiente de animaciones.",
|
||||
"led.toggle":"Alterna un píxel particular",
|
||||
"led.toggleAll":"Invierte la actual pantalla de LED",
|
||||
"led.unplot":"Apagar el LED especificado usando, coordenadas x y (x es horizontal, es vertical). (0,0) es la parte superior izquierda.",
|
||||
"music":"Generación de tonos de la música a través de pin '' P0''.",
|
||||
"music.beat":"Devuelve la duración de un beat en milisegundos",
|
||||
"music.changeTempoBy":"Cambiar el tempo en la cantidad especificada",
|
||||
"music.noteFrequency":"Obtiene la frecuencia de una nota.",
|
||||
"music.playTone":"Se reproduce un tono a través de pin '' P0'' la duración determinada.",
|
||||
"music.rest":"Descansa (juega nada) durante un tiempo especificado a través de pin '' P0''.",
|
||||
"music.ringTone":"Toca un tono a través de pin '' P0''.",
|
||||
"music.setTempo":"El ritmo se establece en la cantidad especificada",
|
||||
"music.tempo":"Vuelve el ritmo en pulsaciones por minuto. Tempo es la velocidad (bpm = beats por minuto) en qué juego de notas. Cuanto mayor sea el valor del tempo, se juegan más rápido las notas.",
|
||||
"pins":"Control de corrientes de Pins para señales de analógico\/digital, servos, i2c...",
|
||||
"pins.analogPitch":"Emite una señal de ancho de pulso modulación (PWM) para el pin de la echada actual. Utilice 'analog set pin pitch' para definir el pin pitch.",
|
||||
"pins.analogReadPin":"Lea el valor de conector como analógica, es decir, como un valor comprendido entre 0 y 1023.",
|
||||
"pins.analogSetPeriod":"Configura la modulación por ancho de pulso (PWM) de la analógica de salida para el valor dado en ** microsegundos ** o ' 1\/1000 «milisegundos.\nSi este pin no está configurado como un análogo de salida (usando 'escritura analógica pin'), la operación no tiene efecto.",
|
||||
"pins.analogSetPitchPin":"Establece el pin cuando se usa 'pins-> tono analógico'.",
|
||||
"pins.analogWritePin":"Establezca el valor de conector como analógica. Debe estar conformados por valor de entre 0 y 1023.",
|
||||
"pins.digitalReadPin":"Leer el pin especificado o conector como 0 o 1",
|
||||
"pins.digitalWritePin":"Establecer un valor de pin o conector de 0 o 1.",
|
||||
"pins.i2cReadNumber":"Leer un número de 7 bits I2C dirección.",
|
||||
"pins.i2cWriteNumber":"Escribir un número en una dirección de 7 bits I2C.",
|
||||
"pins.map":"Volver a le asigna un número del uno al otro. Es decir, un valor de '' de baja '' conseguir asignado a '' a la baja '', un valor de '' de alta '' a '' a '', valores intermedios a intermedios, etc. de valores.",
|
||||
"pins.onPulsed":"Configura este pin a una entrada digital y genera eventos donde la marca de tiempo es la duración que este pin fue '' alto '' o '' baja ''.",
|
||||
"pins.pulseDuration":"Obtiene la duración del último pulso en micro segundos. Esta función debe ser llamada desde un controlador de '' onPulsed''.",
|
||||
"pins.servoSetPulse":"Configura este pin IO como salida analógica\/pwm, configura el período para ser ms 20 y establece el ancho de pulso, basado en el valor se da ** microsegundos ** o ' 1\/1000 «milisegundos.",
|
||||
"pins.servoWritePin":"Escribe un valor en el servo, control del eje por consiguiente. En un servo estándar, esto ajustará el ángulo del eje (en grados), moviendo el eje para que la orientación. En un servo de rotación continua, esto ajustará la velocidad del servo (siendo '' 0'' máxima velocidad en una dirección, '' 180'' lleno de velocidad en el otro y un valor de cerca de '' 90'' no que ningún movimiento).",
|
||||
"pins.setPull":"Configura el tirón de este pin.",
|
||||
"serial":"Leer y escribir datos en una conexión en serie.",
|
||||
"serial.readLine":"Lee una línea de texto del puerto serial.",
|
||||
"serial.redirect":"Configurar dinámicamente la instancia serial para usar pernos excepto USBTX y USBRX.",
|
||||
"serial.writeLine":"Imprime una línea de texto para la serie",
|
||||
"serial.writeNumber":"Imprime un valor numérico a la serie",
|
||||
"serial.writeString":"Envía un fragmento de texto a través de la conexión en serie.",
|
||||
"serial.writeValue":"Escribe un \"nombre: valor '' par línea de la serie."
|
||||
}
|
@ -1,166 +0,0 @@
|
||||
{
|
||||
"Math.randomBoolean":"Génère une valeur « true » ou « false » au hasard, tout comme le retournement d’une pièce de monnaie.",
|
||||
"String.fromCharCode":"Faire une chaîne de la donnée code de caractères ASCII.",
|
||||
"basic":"Permet d’accéder aux fonctionnalités de base micro : bit.",
|
||||
"basic.clearScreen":"Désactiver toutes les LEDs",
|
||||
"basic.forever":"Répète le code pour toujours en arrière-plan. À chaque itération, permet aux autres codes d’exécuter.",
|
||||
"basic.pause":"Pause pendant la durée spécifiée en millisecondes",
|
||||
"basic.pause|param|ms":"Combien de temps pour faire une pause pour, par exemple : 100, 200, 500, 1000, 2000",
|
||||
"basic.plotLeds":"Dessine une image sur l’écran LED.",
|
||||
"basic.plotLeds|param|leds":"modèle de LED à allumer\/éteindre",
|
||||
"basic.showAnimation":"Montre une séquence d’écrans LED comme une animation.",
|
||||
"basic.showAnimation|param|interval":"temps en millisecondes entre chaque rafraîchissement",
|
||||
"basic.showAnimation|param|leds":"modèle de LED à allumer\/éteindre",
|
||||
"basic.showLeds":"Dessine une image sur l’écran LED.",
|
||||
"basic.showLeds|param|interval":"temps en millisecondes pour faire une pause après dessin",
|
||||
"basic.showLeds|param|leds":"le modèle de LED pour activer\/désactiver",
|
||||
"basic.showNumber":"Mettez en surbrillance un numéro sur l’écran. Si le numéro s’inscrit sur l’écran (c'est-à-dire un seul chiffre), ne défilent pas.",
|
||||
"basic.showNumber|param|interval":"Vitesse de défilement ; par exemple : -100, 200, 100, 150",
|
||||
"basic.showString":"Afficher du texte à l’écran, un caractère à la fois. Si la chaîne s’inscrit sur l’écran (c'est-à-dire une lettre), ne défile pas.",
|
||||
"basic.showString|param|interval":"quelle vitesse de déplacement des personnages ; par exemple : -100, 200, 100, 150",
|
||||
"basic.showString|param|text":"le texte à faire défiler sur l’écran, par exemple : « Bonjour ! »",
|
||||
"control":"Utilitaires d’exécution et événements.",
|
||||
"control.inBackground":"Horaires du code qui s’exécutent en arrière-plan.",
|
||||
"control.reset":"Réinitialise le BBC micro : bit.",
|
||||
"game":"Un moteur de jeu unique-LED sprite",
|
||||
"game.addScore":"Ajoute des points pour le score actuel",
|
||||
"game.addScore|param|points":"nombre de points à changer, par exemple : 1",
|
||||
"game.gameOver":"Affiche un jeu au dessus de l’animation.",
|
||||
"game.score":"Obtient le score actuel",
|
||||
"game.setScore":"Définit la valeur actuelle de la partition",
|
||||
"game.setScore|param|value":"TODO",
|
||||
"game.startCountdown":"Commence un compte à rebours jeu",
|
||||
"game.startCountdown|param|ms":"durée du compte à rebours en millisecondes, par exemple : 10000",
|
||||
"images":"Création, manipulation et affichage d’images LED.",
|
||||
"images.createBigImage":"Crée une image avec 2 images.",
|
||||
"images.createImage":"Crée une image qui s’adapte à l’écran LED.",
|
||||
"input":"Événements et des données provenant de capteurs",
|
||||
"input.acceleration":"Obtenir la valeur de l’accélération en milli-gravitys (lorsque le jury pose plat avec l’écran vers le haut, x = 0, y = 0 et z =-1024)",
|
||||
"input.acceleration|param|dimension":"TODO",
|
||||
"input.buttonIsPressed":"Obtenir l’état du bouton (pressé ou non) pour '' A'' et '' B''.",
|
||||
"input.calibrate":"Obsolète, boussole de calibrage est automatique.",
|
||||
"input.compassHeading":"Obtenir le cap compas boussole actuel en degrés.",
|
||||
"input.lightLevel":"Lit le niveau de lumière appliqué à l’écran LED dans une gamme de '' 0'' (noir) à 255 '''' lumineux.",
|
||||
"input.magneticForce":"Obtenir la valeur de la force magnétique dans '' micro-Teslas'' ('' µT''). Cette fonction n’est pas pris en charge dans le simulateur.",
|
||||
"input.magneticForce|param|dimension":"TODO",
|
||||
"input.onButtonPressed":"Faire quelque chose quand vous appuyez sur un bouton ('' A'', '' B'' ou les deux '' A + B'')",
|
||||
"input.onButtonPressed|param|body":"TODO",
|
||||
"input.onButtonPressed|param|button":"TODO",
|
||||
"input.onGesture":"Attache le code à exécuter lorsque l’écran vers le haut.",
|
||||
"input.onGesture|param|body":"TODO",
|
||||
"input.onLogoDown":"Attache le code à exécuter lorsque le logo est orienté vers le bas et le jury est vertical.",
|
||||
"input.onLogoDown|param|body":"TODO",
|
||||
"input.onLogoUp":"Attache le code à exécuter lorsque le logo est orienté vers le haut et le jury est vertical.",
|
||||
"input.onLogoUp|param|body":"TODO",
|
||||
"input.onPinPressed":"Faire quelque chose lorsque vous appuyez sur une broche ('' P0'', '' P1'' ou les deux '' P2'').",
|
||||
"input.onPinPressed|param|body":"TODO",
|
||||
"input.onPinPressed|param|name":"TODO",
|
||||
"input.onScreenDown":"Attache le code à exécuter lorsque l’écran vers le bas.",
|
||||
"input.onScreenDown|param|body":"TODO",
|
||||
"input.onScreenUp":"Attache le code à exécuter lorsque l’écran vers le haut.",
|
||||
"input.onScreenUp|param|body":"TODO",
|
||||
"input.onShake":"Attache le code à exécuter lorsque l’appareil est secoué.",
|
||||
"input.onShake|param|body":"TODO",
|
||||
"input.pinIsPressed":"Obtenir l’état de la broche (pressé ou non). Nécessite de tenir au sol pour fermer le circuit.",
|
||||
"input.pinIsPressed|param|name":"broche utilisée pour détecter le toucher",
|
||||
"input.rotation":"La hauteur de l’appareil, rotation sur axe le '' x '', en degrés.",
|
||||
"input.rotation|param|kind":"TODO",
|
||||
"input.runningTime":"Obtient le nombre de millisecondes écoulées depuis le pouvoir sur.",
|
||||
"input.setAccelerometerRange":"Définit la plage d’échantillon accéléromètre de gravités.",
|
||||
"input.setAccelerometerRange|param|range":"une valeur décrivent l’assurer une rigidité maximale d’accélération mesurée",
|
||||
"input.temperature":"Obtient la température en Celsius degrés (° C).",
|
||||
"led":"Contrôle de l’écran LED.",
|
||||
"led.brightness":"Descendre la luminosité de l’écran de 0 () à 255 (pleine intensité).",
|
||||
"led.fadeIn":"Fondu dans l’affichage à l’écran.",
|
||||
"led.fadeIn|param|ms":"TODO",
|
||||
"led.fadeOut":"S’évanouit la luminosité de l’écran.",
|
||||
"led.fadeOut|param|ms":"TODO",
|
||||
"led.plot":"Allumer la LED spécifiée par x, y coordonnées (x est horizontal, y est verticale). (0,0) est en haut à gauche.",
|
||||
"led.plotAll":"Tous les voyants s’allume",
|
||||
"led.plotBarGraph":"Affiche un graphique à barres vertical basé sur la « valeur » et la valeur « élevée ».\nSi « élevé » est 0, le tableau s’ajuste automatiquement.",
|
||||
"led.plotBarGraph|param|high":"valeur maximale. Si 0, la valeur maximale ramenée automatiquement, par exemple : 0",
|
||||
"led.plotBarGraph|param|value":"valeur actuelle pour tracer",
|
||||
"led.plot|param|x":"TODO",
|
||||
"led.plot|param|y":"TODO",
|
||||
"led.point":"Obtenir l’État marche\/arrêt de la LED spécifiée par x, y coordonnées. (0,0) est en haut à gauche.",
|
||||
"led.point|param|x":"TODO",
|
||||
"led.point|param|y":"TODO",
|
||||
"led.screenshot":"Prend une capture d’écran de l’écran LED et renvoie une image.",
|
||||
"led.setBrightness":"Régler la luminosité de l’écran de 0 (off) à 255 (pleine intensité).",
|
||||
"led.setBrightness|param|value":"valeur de la luminosité, par exemple : 255, 127, 0",
|
||||
"led.setDisplayMode":"Définit le mode d’affichage entre noir et blanc et gris pour le rendu des LEDs.",
|
||||
"led.setDisplayMode|param|mode":"TODO",
|
||||
"led.stopAnimation":"Annule l’animation actuelle et efface les autres en attente d’animations.",
|
||||
"led.toggle":"Active\/désactive un pixel particulier",
|
||||
"led.toggleAll":"Inverse l’affichage actuel",
|
||||
"led.toggle|param|x":"TODO",
|
||||
"led.toggle|param|y":"TODO",
|
||||
"led.unplot":"Éteindre la LED spécifiée par x, y coordonnées (x est horizontal, y est verticale). (0,0) est en haut à gauche.",
|
||||
"led.unplot|param|x":"TODO",
|
||||
"led.unplot|param|y":"TODO",
|
||||
"music":"Génération de sonneries musicales via broche '' P0''.",
|
||||
"music.beat":"Retourne la durée d’un battement en milli-secondes",
|
||||
"music.changeTempoBy":"Changer le tempo de la quantité spécifiée",
|
||||
"music.changeTempoBy|param|bpm":"Le changement en battements par minute au tempo, par exemple : 20",
|
||||
"music.noteFrequency":"Obtient la fréquence d’une note.",
|
||||
"music.noteFrequency|param|name":"le nom de la note",
|
||||
"music.playTone":"Joue une tonalité via broche '' P0'' pour la durée donnée.",
|
||||
"music.playTone|param|frequency":"hauteur de la tonalité pour jouer en Hertz (Hz)",
|
||||
"music.playTone|param|ms":"durée de la tonalité en millisecondes (ms)",
|
||||
"music.rest":"Repose (joue rien) pendant une durée spécifiée via broche '' P0''.",
|
||||
"music.rest|param|ms":"reposer la durée en millisecondes (ms)",
|
||||
"music.ringTone":"Joue une tonalité via broche '' P0''.",
|
||||
"music.ringTone|param|frequency":"hauteur de la tonalité pour jouer en Hertz (Hz)",
|
||||
"music.setTempo":"Définit le tempo à la quantité spécifiée",
|
||||
"music.setTempo|param|bpm":"Le nouveau tempo en battements par minute, par exemple : 120",
|
||||
"music.tempo":"Retourne le tempo en battements par minute. Tempo est la vitesse (bpm = battements par minute) à qui jouent des notes. Plus la valeur du tempo, plus vite les notes jouera.",
|
||||
"pins":"Contrôle des courants à Pins pour signaux analogiques\/numériques, servos, i2c...",
|
||||
"pins.analogPitch":"Émet un signal de modulation (PWM) de largeur d’impulsion à l’axe de tangage actuelle. Utilisez « analog set axe de tangage » pour définir l’axe de tangage.",
|
||||
"pins.analogPitch|param|frequency":"TODO",
|
||||
"pins.analogPitch|param|ms":"TODO",
|
||||
"pins.analogReadPin":"Lire la valeur de connecteur analogique, c'est-à-dire comme une valeur comprise entre 0 et 1023.",
|
||||
"pins.analogReadPin|param|name":"broche d’écrire à",
|
||||
"pins.analogSetPeriod":"Configure la modulation de largeur d’impulsion (PWM) de la sortie à la valeur donnée en analogique ** microsecondes ** ou « 1\/1000' millisecondes.\nSi cette broche n’est pas configurée comme un analogue de sortie (en utilisant « écriture analogique pin »), l’opération n’a aucun effet.",
|
||||
"pins.analogSetPeriod|param|micros":"période en micro secondes. par exemple : 20000",
|
||||
"pins.analogSetPeriod|param|name":"broche analogique pour définir le délai",
|
||||
"pins.analogSetPitchPin":"Définit l’axe utilisé lors de l’utilisation de « pins-> pitch analogique ».",
|
||||
"pins.analogSetPitchPin|param|name":"TODO",
|
||||
"pins.analogWritePin":"Définissez la valeur de connecteur analogique. Valeur doit être comprise entre 0 et 1023.",
|
||||
"pins.analogWritePin|param|name":"nom de la broche d’écrire à",
|
||||
"pins.analogWritePin|param|value":"valeur à écrire sur la broche entre '' 0'' et '' 1023''. par exemple : 1023, 0",
|
||||
"pins.digitalReadPin":"Lire la broche spécifié ou le connecteur comme 0 ou 1",
|
||||
"pins.digitalReadPin|param|name":"broche pour lire à partir",
|
||||
"pins.digitalWritePin":"Définir une valeur de code pin ou le connecteur à 0 ou 1.",
|
||||
"pins.digitalWritePin|param|name":"broche d’écrire à",
|
||||
"pins.digitalWritePin|param|value":"valeur à définir sur la broche, 1 par exemple, 0",
|
||||
"pins.i2cReadNumber":"Lire un numéro de 7-bit I2C adresse.",
|
||||
"pins.i2cWriteNumber":"Écrire un nombre à une adresse I2C de 7 bits.",
|
||||
"pins.map":"Remappe un nombre d’une plage à l’autre. Autrement dit, une valeur '' de faible '' serait sont mappée aux '' à faible '', une valeur de '' de haut '' à '' à haute '', valeurs intermédiaires à etc in-between, de valeurs.",
|
||||
"pins.map|param|fromHigh":"limite la supérieure de la gamme actuelle de la valeur, par exemple : 1023",
|
||||
"pins.map|param|fromLow":"la limite inférieure de la gamme actuelle de la valeur",
|
||||
"pins.map|param|toHigh":"la limite supérieure de la cible de la valeur du rang, par exemple : 4",
|
||||
"pins.map|param|toLow":"la limite inférieure de la fourchette cible de la valeur",
|
||||
"pins.map|param|value":"valeur à la carte dans les rangs",
|
||||
"pins.onPulsed":"Configure cette broche pour une entrée numérique et génère des événements où l’horodatage est la durée pendant laquelle cette broche a été '' élevé '' ou '' faible ''.",
|
||||
"pins.pulseDuration":"Obtient la durée de la dernière impulsion en microsecondes. Cette fonction doit être appelée à partir d’un gestionnaire de '' onPulsed''.",
|
||||
"pins.servoSetPulse":"Configure cette broche e\/s comme une sortie analogique\/pwm, configure le laps de temps pour être 20 ms et définit la largeur d’impulsion, basée sur la valeur, il est donné ** microsecondes ** ou « 1\/1000' millisecondes.",
|
||||
"pins.servoSetPulse|param|micros":"durée de l’impulsion en micro secondes, par exemple : 1500",
|
||||
"pins.servoSetPulse|param|name":"nom de code PIN",
|
||||
"pins.servoWritePin":"Écrit une valeur à l’asservissement, contrôle de l’arbre en conséquence. Sur un servo standard, cette fonction définira l’angle de l’arbre (en degrés), déplacer l’arbre à cette orientation. Sur un servo de rotation continue, cette fonction définira la vitesse du servo (avec '' 0'' en pleine vitesse dans une seule direction, '' 180'' en pleine vitesse dans l’autre et une valeur de près de 90 '''' aucun mouvement).",
|
||||
"pins.servoWritePin|param|name":"broche d’écrire à",
|
||||
"pins.servoWritePin|param|value":"angle ou rotation à vitesse, par exemple : 0, 90 et 180",
|
||||
"pins.setPull":"Configure l’attraction de cette broche.",
|
||||
"pins.setPull|param|name":"broche pour définir le mode de traction sur",
|
||||
"pins.setPull|param|pull":"une des configurations mbed pull : PullUp, menu déroulant, PullNone ",
|
||||
"serial":"Lire et écrire des données sur une connexion série.",
|
||||
"serial.readLine":"Lit une ligne de texte à partir du port série.",
|
||||
"serial.redirect":"Configuration dynamique de l’instance de série pour utiliser des épingles autres que USBTX et USBRX.",
|
||||
"serial.redirect|param|rx":"le nouveau NIP de réception",
|
||||
"serial.redirect|param|tx":"les nouvelles goupilles de transmission",
|
||||
"serial.writeLine":"Imprime une ligne de texte pour le numéro de série",
|
||||
"serial.writeNumber":"Imprime une valeur numérique de la série",
|
||||
"serial.writeString":"Envoie un morceau de texte via la connexion série.",
|
||||
"serial.writeValue":"Écrit un « nom : valeur '' paire de ligne de la série.",
|
||||
"serial.writeValue|param|name":"nom de la valeur stream, par exemple : x",
|
||||
"serial.writeValue|param|value":"Écrire"
|
||||
}
|
@ -1,92 +0,0 @@
|
||||
{
|
||||
"Math.randomBoolean":"硬貨を弾くことのようなちょうど 'true' または 'false' の値をランダムに生成します。",
|
||||
"String.fromCharCode":"指定された ASCII 文字コードから文字列を確認します。",
|
||||
"basic":"基本的なマイクロ: ビット機能へのアクセスを提供します。",
|
||||
"basic.clearScreen":"すべての Led をオフにします。",
|
||||
"basic.forever":"永遠にバック グラウンドでコードを繰り返します。各イテレーションを実行するその他のコードを使用できます。",
|
||||
"basic.pause":"ミリ秒で指定された時間一時停止します。",
|
||||
"basic.plotLeds":"LED 画面にイメージを描画します。",
|
||||
"basic.showAnimation":"アニメーションとして LED スクリーンのシーケンスを示しています。",
|
||||
"basic.showLeds":"LED 画面にイメージを描画します。",
|
||||
"basic.showNumber":"画面上の数字をスクロールします。数が画面上に収まる場合 (つまりは 1 桁)、スクロールしません。",
|
||||
"basic.showString":"一度に 1 つの文字の表示のテキストを表示します。文字列が画面上に収まる場合 (すなわち、1 つの文字)、スクロールしません。",
|
||||
"control":"ランタイムおよびイベント ユーティリティ。",
|
||||
"control.inBackground":"スケジュールは、バック グラウンドで実行されるコードします。",
|
||||
"control.reset":"BBC のマイクロ: ビットをリセットします。",
|
||||
"game":"単一 LED スプライト ゲーム エンジン",
|
||||
"game.addScore":"現在のスコアにポイントを追加します。",
|
||||
"game.gameOver":"ゲーム アニメーションを表示します。",
|
||||
"game.score":"現在のスコアを取得します。",
|
||||
"game.setScore":"現在のスコアの値を設定します",
|
||||
"game.startCountdown":"ゲームのカウント ダウン タイマーを開始します。",
|
||||
"images":"作成、操作および LED の画像を表示します。",
|
||||
"images.createBigImage":"2 フレームを持つイメージを作成します。",
|
||||
"images.createImage":"LED 画面に合ったイメージを作成します。",
|
||||
"input":"イベントやセンサーからのデータ",
|
||||
"input.acceleration":"ミリ gravitys の加速度値を取得 (ボードを敷設するときフラット スクリーンを x = 0、y = 0、z = 1024年)",
|
||||
"input.buttonIsPressed":"'、' と 'B' のボタンの状態 (押されてかどうか) を取得します。",
|
||||
"input.calibrate":"時代遅れ、コンパス キャリブレーションは自動です。",
|
||||
"input.compassHeading":"度で、現在のコンパス コンパス針路を取得します。",
|
||||
"input.lightLevel":"'0 ' (暗い)「255」明るいから適用範囲内の LED スクリーン光レベルを読み取ります。",
|
||||
"input.magneticForce":"「マイクロ ・ テスラ」(μ '' T '') の磁気力の値を取得します。シミュレータでは、この関数はサポートされていません。",
|
||||
"input.onButtonPressed":"'、'、' B '(両方の' A + B ') ボタンが押されたときに何か",
|
||||
"input.onGesture":"画面を向いているときに実行するコードをアタッチします。",
|
||||
"input.onLogoDown":"ロゴは下方向とボードが垂直方向に実行されるコードをアタッチします。",
|
||||
"input.onLogoUp":"ロゴは上方向きとボードが垂直方向に実行されるコードをアタッチします。",
|
||||
"input.onPinPressed":"(「P0 '' や '' P1 '' 両方 '' P2 '') ピンが押されたときに何かを行います。",
|
||||
"input.onScreenDown":"画面が直面しているときに実行するコードをアタッチします。",
|
||||
"input.onScreenUp":"画面を向いているときに実行するコードをアタッチします。",
|
||||
"input.onShake":"デバイスを振るときに実行するコードをアタッチします。",
|
||||
"input.pinIsPressed":"(押すか) ピンの状態を取得します。回路を閉じるために地面を保持する必要があります。",
|
||||
"input.rotation":"度の 'x ' に沿って回転デバイスのピッチです。",
|
||||
"input.runningTime":"電源から経過したミリ秒数を取得します。",
|
||||
"input.setAccelerometerRange":"吊り下げた状態で加速度計のサンプル範囲を設定します。",
|
||||
"input.temperature":"摂氏温度を取得度 (° C)。",
|
||||
"led":"LED 画面を制御します。",
|
||||
"led.brightness":"画面の明るさから得る 0 (オフ) 255 (完全明るい)。",
|
||||
"led.fadeIn":"画面がフェードインします。",
|
||||
"led.fadeOut":"画面の明るさをフェードアウトします。",
|
||||
"led.plot":"オンに指定した LED を使用して x 座標と y 座標 (x は横方向、y は縦方向)。(0, 0) は左上。",
|
||||
"led.plotAll":"すべての LED が点灯します。",
|
||||
"led.plotBarGraph":"'値' と '高' の値に基づく垂直棒グラフを表示します。\n場合は '高' は 0、グラフを自動的に調整を取得します。",
|
||||
"led.point":"使用して指定された LED のオン\/オフ状態を取得 x 座標と y 座標。(0, 0) は左上。",
|
||||
"led.screenshot":"LED 画面のスクリーン ショットを取り、画像を返します。",
|
||||
"led.setBrightness":"画面の明るさ 0 (オフ) に設定 255 (完全明るい)。",
|
||||
"led.setDisplayMode":"黒と白とグレースケールの Led を表示するための表示モードを設定します。",
|
||||
"led.stopAnimation":"現在のアニメーションをキャンセルし、保留中のアニメーション他をクリアします。",
|
||||
"led.toggle":"特定のピクセルを切り替えます",
|
||||
"led.toggleAll":"現在の LED ディスプレイを反転します",
|
||||
"led.unplot":"指定した LED を使用してオフに x 座標と y 座標 (x は横方向、y は縦方向)。(0, 0) は左上。",
|
||||
"music":"ピン「P0 '' を介して音楽の音の生成。",
|
||||
"music.beat":"ビートのデュレーションをミリ秒単位で返します",
|
||||
"music.changeTempoBy":"指定した量によってテンポを変更します。",
|
||||
"music.noteFrequency":"ノートの頻度を取得します。",
|
||||
"music.playTone":"指定された期間のピン 'P0' を通じて調子を果たしています。",
|
||||
"music.rest":"かかっている (何も果たしている) ピン 'P0' により指定した時刻に。",
|
||||
"music.ringTone":"ピン「P0 '' から音をを再生します。",
|
||||
"music.setTempo":"テンポを一定に設定します",
|
||||
"music.tempo":"1 分あたりのビートのテンポを返します。速度はテンポ (bpm = 1 分あたりのビート) ノートを遊んで。テンポの値が大きいほど、高速のノートが再生されます。",
|
||||
"pins":"アナログ\/デジタル信号、サーボ、i2c、ピンで電流を制御します。",
|
||||
"pins.analogPitch":"現在のピッチ端子にパルス幅変調 (PWM) 信号を出力します。'アナログ設定ピッチ pin' を使用して、ピッチのピンを定義します。",
|
||||
"pins.analogReadPin":"つまり、0 から 1023年の間から成る値としてアナログ、としてコネクタ値を読み取る。",
|
||||
"pins.analogSetPeriod":"アナログで与えられた値に出力のパルス幅変調 (PWM) を構成 * * マイクロ秒 * * または '' 1\/1000年ミリ秒。\nこのピンはアナログ出力 ('アナログ書き込みピン' を使用) として構成されていない場合、操作には影響がありません。",
|
||||
"pins.analogSetPitchPin":"'ピン-> アナログ ピッチ' を使用するときに使用される pin を設定します。",
|
||||
"pins.analogWritePin":"アナログ コネクタの値を設定します。値は、0 から 1023年の間で構成する必要があります。",
|
||||
"pins.digitalReadPin":"0 または 1 のいずれかとして指定した pin またはコネクタを読む",
|
||||
"pins.digitalWritePin":"0 または 1 のいずれかにピンまたはコネクタの値を設定します。",
|
||||
"pins.i2cReadNumber":"7 ビット I2C アドレスから 1 つの番号を読み取る。",
|
||||
"pins.i2cWriteNumber":"7 ビット I2C アドレスに 1 つの番号を書きます。",
|
||||
"pins.map":"1 つの範囲から別の数字を再マップします。つまり、'から低 'の値 'に高'、値、中間などに中間値方' に ''から高' の値マッピングでしょう。",
|
||||
"pins.onPulsed":"デジタル入力にこの pin を構成し、タイムスタンプがこのピンは '高' または '低' 期間のイベントを生成します。",
|
||||
"pins.pulseDuration":"マイクロ秒で最後のパルスの期間を取得します。この関数は、' onPulsed ' ハンドラーから呼び出す必要があります。",
|
||||
"pins.servoSetPulse":"アナログ\/pwm 出力としてこの IO ピンを構成します、20 ms にする期間を構成し、それは与えられる値に基づいて、パルス幅を設定します * * マイクロ秒 * * または '' 1\/1000年ミリ秒です。",
|
||||
"pins.servoWritePin":"それに応じてシャフトを制御するサーボに値を書き込みます。標準サーボの軸をその方向に移動 (単位は度)、シャフトの角度に設定されます。連続回転サーボに、これは (' 0 ' 1 つの方向、「180」に満ちているフルスピード速度の他、と '' 90」の動きではないことに近い値であること) とサーボ スピードを設定します。",
|
||||
"pins.setPull":"このピンのプルを構成します。",
|
||||
"serial":"シリアル接続を介してデータを読み書きします。",
|
||||
"serial.readLine":"シリアル ポートからテキスト行を読み取ります。",
|
||||
"serial.redirect":"USBTX と USBRX 以外のピンを使用するシリアルのインスタンスの動的な設定。",
|
||||
"serial.writeLine":"連続するテキストの行を印刷します。",
|
||||
"serial.writeNumber":"連続する数値値を出力します。",
|
||||
"serial.writeString":"シリアル接続を使用してテキストの一部を送信します。",
|
||||
"serial.writeValue":"書き込み、「名前: 値」ペアのシリアル ライン。"
|
||||
}
|
@ -1,173 +0,0 @@
|
||||
{
|
||||
"Math.randomBoolean": "Generates a `true` or `false` value randomly, just like flipping a coin.",
|
||||
"String.fromCharCode": "Make a string from the given ASCII character code.",
|
||||
"basic": "Provides access to basic micro:bit functionality.",
|
||||
"basic.clearScreen": "Turn off all LEDs",
|
||||
"basic.forever": "Repeats the code forever in the background. On each iteration, allows other codes to run.",
|
||||
"basic.pause": "Pause for the specified time in milliseconds",
|
||||
"basic.pause|param|ms": "how long to pause for, eg: 100, 200, 500, 1000, 2000",
|
||||
"basic.plotLeds": "Draws an image on the LED screen.",
|
||||
"basic.plotLeds|param|leds": "pattern of LEDs to turn on/off",
|
||||
"basic.showAnimation": "Shows a sequence of LED screens as an animation.",
|
||||
"basic.showAnimation|param|interval": "time in milliseconds between each redraw",
|
||||
"basic.showAnimation|param|leds": "pattern of LEDs to turn on/off",
|
||||
"basic.showLeds": "Draws an image on the LED screen.",
|
||||
"basic.showLeds|param|interval": "time in milliseconds to pause after drawing",
|
||||
"basic.showLeds|param|leds": "the pattern of LED to turn on/off",
|
||||
"basic.showNumber": "Scroll a number on the screen. If the number fits on the screen (i.e. is a single digit), do not scroll.",
|
||||
"basic.showNumber|param|interval": "speed of scroll; eg: 150, 100, 200, -100",
|
||||
"basic.showString": "Display text on the display, one character at a time. If the string fits on the screen (i.e. is one letter), does not scroll.",
|
||||
"basic.showString|param|interval": "how fast to shift characters; eg: 150, 100, 200, -100",
|
||||
"basic.showString|param|text": "the text to scroll on the screen, eg: \"Hello!\"",
|
||||
"control": "Runtime and event utilities.",
|
||||
"control.inBackground": "Schedules code that run in the background.",
|
||||
"control.reset": "Resets the BBC micro:bit.",
|
||||
"control.waitMicros": "Blocks the current fiber for the given microseconds",
|
||||
"control.waitMicros|param|micros": "number of micro-seconds to wait. eg: 4",
|
||||
"game": "A single-LED sprite game engine",
|
||||
"game.addScore": "Adds points to the current score",
|
||||
"game.addScore|param|points": "amount of points to change, eg: 1",
|
||||
"game.gameOver": "Displays a game over animation.",
|
||||
"game.score": "Gets the current score",
|
||||
"game.setScore": "Sets the current score value",
|
||||
"game.setScore|param|value": "TODO",
|
||||
"game.startCountdown": "Starts a game countdown timer",
|
||||
"game.startCountdown|param|ms": "countdown duration in milliseconds, eg: 10000",
|
||||
"images": "Creation, manipulation and display of LED images.",
|
||||
"images.createBigImage": "Creates an image with 2 frames.",
|
||||
"images.createImage": "Creates an image that fits on the LED screen.",
|
||||
"input": "Events and data from sensors",
|
||||
"input.acceleration": "Get the acceleration value in milli-gravitys (when the board is laying flat with the screen up, x=0, y=0 and z=-1024)",
|
||||
"input.acceleration|param|dimension": "TODO",
|
||||
"input.buttonIsPressed": "Get the button state (pressed or not) for ``A`` and ``B``.",
|
||||
"input.calibrate": "Obsolete, compass calibration is automatic.",
|
||||
"input.compassHeading": "Get the current compass heading in degrees.",
|
||||
"input.lightLevel": "Reads the light level applied to the LED screen in a range from ``0`` (dark) to ``255`` bright.",
|
||||
"input.magneticForce": "Get the magnetic force value in ``micro-Teslas`` (``µT``). This function is not supported in the simulator.",
|
||||
"input.magneticForce|param|dimension": "TODO",
|
||||
"input.onButtonPressed": "Do something when a button (``A``, ``B`` or both ``A+B``) is pressed",
|
||||
"input.onButtonPressed|param|body": "TODO",
|
||||
"input.onButtonPressed|param|button": "TODO",
|
||||
"input.onGesture": "Do something when when a gesture is done (like shaking the micro:bit).",
|
||||
"input.onGesture|param|body": "TODO",
|
||||
"input.onLogoDown": "Attaches code to run when the logo is oriented downwards and the board is vertical.",
|
||||
"input.onLogoDown|param|body": "TODO",
|
||||
"input.onLogoUp": "Attaches code to run when the logo is oriented upwards and the board is vertical.",
|
||||
"input.onLogoUp|param|body": "TODO",
|
||||
"input.onPinPressed": "Do something when a pin is pressed.",
|
||||
"input.onPinPressed|param|body": "the code to run when the pin is pressed",
|
||||
"input.onPinPressed|param|name": "the pin that needs to be pressed",
|
||||
"input.onPinReleased": "Do something when a pin is released.",
|
||||
"input.onPinReleased|param|body": "the code to run when the pin is released",
|
||||
"input.onPinReleased|param|name": "the pin that needs to be released",
|
||||
"input.onScreenDown": "Attaches code to run when the screen is facing down.",
|
||||
"input.onScreenDown|param|body": "TODO",
|
||||
"input.onScreenUp": "Attaches code to run when the screen is facing up.",
|
||||
"input.onScreenUp|param|body": "TODO",
|
||||
"input.onShake": "Attaches code to run when the device is shaken.",
|
||||
"input.onShake|param|body": "TODO",
|
||||
"input.pinIsPressed": "Get the pin state (pressed or not). Requires to hold the ground to close the circuit.",
|
||||
"input.pinIsPressed|param|name": "pin used to detect the touch",
|
||||
"input.rotation": "The pitch or roll of the device, rotation along the ``x-axis`` or ``y-axis``, in degrees.",
|
||||
"input.rotation|param|kind": "TODO",
|
||||
"input.runningTime": "Gets the number of milliseconds elapsed since power on.",
|
||||
"input.setAccelerometerRange": "Sets the accelerometer sample range in gravities.",
|
||||
"input.setAccelerometerRange|param|range": "a value describe the maximum strengh of acceleration measured",
|
||||
"input.temperature": "Gets the temperature in Celsius degrees (°C).",
|
||||
"led": "Control of the LED screen.",
|
||||
"led.brightness": "Get the screen brightness from 0 (off) to 255 (full bright).",
|
||||
"led.fadeIn": "Fades in the screen display.",
|
||||
"led.fadeIn|param|ms": "TODO",
|
||||
"led.fadeOut": "Fades out the screen brightness.",
|
||||
"led.fadeOut|param|ms": "TODO",
|
||||
"led.plot": "Turn on the specified LED using x, y coordinates (x is horizontal, y is vertical). (0,0) is upper left.",
|
||||
"led.plotAll": "Turns all LEDS on",
|
||||
"led.plotBarGraph": "Displays a vertical bar graph based on the `value` and `high` value.\nIf `high` is 0, the chart gets adjusted automatically.",
|
||||
"led.plotBarGraph|param|high": "maximum value. If 0, maximum value adjusted automatically, eg: 0",
|
||||
"led.plotBarGraph|param|value": "current value to plot",
|
||||
"led.plot|param|x": "TODO",
|
||||
"led.plot|param|y": "TODO",
|
||||
"led.point": "Get the on/off state of the specified LED using x, y coordinates. (0,0) is upper left.",
|
||||
"led.point|param|x": "TODO",
|
||||
"led.point|param|y": "TODO",
|
||||
"led.screenshot": "Takes a screenshot of the LED screen and returns an image.",
|
||||
"led.setBrightness": "Set the screen brightness from 0 (off) to 255 (full bright).",
|
||||
"led.setBrightness|param|value": "the brightness value, eg:255, 127, 0",
|
||||
"led.setDisplayMode": "Sets the display mode between black and white and greyscale for rendering LEDs.",
|
||||
"led.setDisplayMode|param|mode": "TODO",
|
||||
"led.stopAnimation": "Cancels the current animation and clears other pending animations.",
|
||||
"led.toggle": "Toggles a particular pixel",
|
||||
"led.toggleAll": "Inverts the current LED display",
|
||||
"led.toggle|param|x": "TODO",
|
||||
"led.toggle|param|y": "TODO",
|
||||
"led.unplot": "Turn off the specified LED using x, y coordinates (x is horizontal, y is vertical). (0,0) is upper left.",
|
||||
"led.unplot|param|x": "TODO",
|
||||
"led.unplot|param|y": "TODO",
|
||||
"music": "Generation of music tones through pin ``P0``.",
|
||||
"music.beat": "Returns the duration of a beat in milli-seconds",
|
||||
"music.changeTempoBy": "Change the tempo by the specified amount",
|
||||
"music.changeTempoBy|param|bpm": "The change in beats per minute to the tempo, eg: 20",
|
||||
"music.noteFrequency": "Gets the frequency of a note.",
|
||||
"music.noteFrequency|param|name": "the note name",
|
||||
"music.playTone": "Plays a tone through pin ``P0`` for the given duration.",
|
||||
"music.playTone|param|frequency": "pitch of the tone to play in Hertz (Hz)",
|
||||
"music.playTone|param|ms": "tone duration in milliseconds (ms)",
|
||||
"music.rest": "Rests (plays nothing) for a specified time through pin ``P0``.",
|
||||
"music.rest|param|ms": "rest duration in milliseconds (ms)",
|
||||
"music.ringTone": "Plays a tone through pin ``P0``.",
|
||||
"music.ringTone|param|frequency": "pitch of the tone to play in Hertz (Hz)",
|
||||
"music.setTempo": "Sets the tempo to the specified amount",
|
||||
"music.setTempo|param|bpm": "The new tempo in beats per minute, eg: 120",
|
||||
"music.tempo": "Returns the tempo in beats per minute. Tempo is the speed (bpm = beats per minute) at which notes play. The larger the tempo value, the faster the notes will play.",
|
||||
"pins": "Control currents in Pins for analog/digital signals, servos, i2c, ...",
|
||||
"pins.analogPitch": "Emits a Pulse-width modulation (PWM) signal to the current pitch pin. Use `analog set pitch pin` to define the pitch pin.",
|
||||
"pins.analogPitch|param|frequency": "TODO",
|
||||
"pins.analogPitch|param|ms": "TODO",
|
||||
"pins.analogReadPin": "Read the connector value as analog, that is, as a value comprised between 0 and 1023.",
|
||||
"pins.analogReadPin|param|name": "pin to write to",
|
||||
"pins.analogSetPeriod": "Configures the Pulse-width modulation (PWM) of the analog output to the given value in **microseconds** or `1/1000` milliseconds.\nIf this pin is not configured as an analog output (using `analog write pin`), the operation has no effect.",
|
||||
"pins.analogSetPeriod|param|micros": "period in micro seconds. eg:20000",
|
||||
"pins.analogSetPeriod|param|name": "analog pin to set period to",
|
||||
"pins.analogSetPitchPin": "Sets the pin used when using `pins->analog pitch`.",
|
||||
"pins.analogSetPitchPin|param|name": "TODO",
|
||||
"pins.analogWritePin": "Set the connector value as analog. Value must be comprised between 0 and 1023.",
|
||||
"pins.analogWritePin|param|name": "pin name to write to",
|
||||
"pins.analogWritePin|param|value": "value to write to the pin between ``0`` and ``1023``. eg:1023,0",
|
||||
"pins.digitalReadPin": "Read the specified pin or connector as either 0 or 1",
|
||||
"pins.digitalReadPin|param|name": "pin to read from",
|
||||
"pins.digitalWritePin": "Set a pin or connector value to either 0 or 1.",
|
||||
"pins.digitalWritePin|param|name": "pin to write to",
|
||||
"pins.digitalWritePin|param|value": "value to set on the pin, 1 eg,0",
|
||||
"pins.i2cReadNumber": "Read one number from 7-bit I2C address.",
|
||||
"pins.i2cWriteNumber": "Write one number to a 7-bit I2C address.",
|
||||
"pins.map": "Re-maps a number from one range to another. That is, a value of ``from low`` would get mapped to ``to low``, a value of ``from high`` to ``to high``, values in-between to values in-between, etc.",
|
||||
"pins.map|param|fromHigh": "the upper bound of the value's current range, eg: 1023",
|
||||
"pins.map|param|fromLow": "the lower bound of the value's current range",
|
||||
"pins.map|param|toHigh": "the upper bound of the value's target range, eg: 4",
|
||||
"pins.map|param|toLow": "the lower bound of the value's target range",
|
||||
"pins.map|param|value": "value to map in ranges",
|
||||
"pins.onPulsed": "Configures this pin to a digital input, and generates events where the timestamp is the duration that this pin was either ``high`` or ``low``.",
|
||||
"pins.pulseDuration": "Gets the duration of the last pulse in micro-seconds. This function should be called from a ``onPulsed`` handler.",
|
||||
"pins.servoSetPulse": "Configures this IO pin as an analog/pwm output, configures the period to be 20 ms, and sets the pulse width, based on the value it is given **microseconds** or `1/1000` milliseconds.",
|
||||
"pins.servoSetPulse|param|micros": "pulse duration in micro seconds, eg:1500",
|
||||
"pins.servoSetPulse|param|name": "pin name",
|
||||
"pins.servoWritePin": "Writes a value to the servo, controlling the shaft accordingly. On a standard servo, this will set the angle of the shaft (in degrees), moving the shaft to that orientation. On a continuous rotation servo, this will set the speed of the servo (with ``0`` being full-speed in one direction, ``180`` being full speed in the other, and a value near ``90`` being no movement).",
|
||||
"pins.servoWritePin|param|name": "pin to write to",
|
||||
"pins.servoWritePin|param|value": "angle or rotation speed, eg:180,90,0",
|
||||
"pins.setPull": "Configures the pull of this pin.",
|
||||
"pins.setPull|param|name": "pin to set the pull mode on",
|
||||
"pins.setPull|param|pull": "one of the mbed pull configurations: PullUp, PullDown, PullNone ",
|
||||
"pins.spiWrite": "Write to the SPI slave and return the response",
|
||||
"pins.spiWrite|param|value": "Data to be sent to the SPI slave",
|
||||
"serial": "Reading and writing data over a serial connection.",
|
||||
"serial.readLine": "Reads a line of text from the serial port.",
|
||||
"serial.redirect": "Dynamically configuring the serial instance to use pins other than USBTX and USBRX.",
|
||||
"serial.redirect|param|rx": "the new reception pin",
|
||||
"serial.redirect|param|tx": "the new transmission pins",
|
||||
"serial.writeLine": "Prints a line of text to the serial",
|
||||
"serial.writeNumber": "Prints a numeric value to the serial",
|
||||
"serial.writeString": "Sends a piece of text through Serial connection.",
|
||||
"serial.writeValue": "Writes a ``name: value`` pair line to the serial.",
|
||||
"serial.writeValue|param|name": "name of the value stream, eg: x",
|
||||
"serial.writeValue|param|value": "to write"
|
||||
}
|
@ -1,80 +0,0 @@
|
||||
{
|
||||
"Math.randomBoolean|block": "pick random true or false",
|
||||
"Math|block": "Math",
|
||||
"String.fromCharCode|block": "text from char code %code",
|
||||
"String|block": "String",
|
||||
"basic.clearScreen|block": "clear screen",
|
||||
"basic.forever|block": "forever",
|
||||
"basic.pause|block": "pause (ms) %pause",
|
||||
"basic.showLeds|block": "show leds",
|
||||
"basic.showNumber|block": "show|number %number",
|
||||
"basic.showString|block": "show|string %text",
|
||||
"basic|block": "basic",
|
||||
"control.inBackground|block": "run in background",
|
||||
"control.reset|block": "reset",
|
||||
"control.waitMicros|block": "wait (µs)%micros",
|
||||
"control|block": "control",
|
||||
"game.addScore|block": "change score by|%points",
|
||||
"game.gameOver|block": "game over",
|
||||
"game.score|block": "score",
|
||||
"game.startCountdown|block": "start countdown|(ms) %duration",
|
||||
"game|block": "game",
|
||||
"images.createBigImage|block": "create big image",
|
||||
"images.createImage|block": "create image",
|
||||
"images|block": "images",
|
||||
"input.acceleration|block": "acceleration (mg)|%NAME",
|
||||
"input.buttonIsPressed|block": "button|%NAME|is pressed",
|
||||
"input.compassHeading|block": "compass heading (°)",
|
||||
"input.lightLevel|block": "light level",
|
||||
"input.magneticForce|block": "magnetic force (µT)|%NAME",
|
||||
"input.onButtonPressed|block": "on button|%NAME|pressed",
|
||||
"input.onGesture|block": "on |%NAME",
|
||||
"input.onPinPressed|block": "on pin %NAME|pressed",
|
||||
"input.onPinReleased|block": "on pin %NAME|released",
|
||||
"input.pinIsPressed|block": "pin %NAME|is pressed",
|
||||
"input.rotation|block": "rotation (°)|%NAME",
|
||||
"input.runningTime|block": "running time (ms)",
|
||||
"input.setAccelerometerRange|block": "set accelerometer|range %range",
|
||||
"input.temperature|block": "temperature (°C)",
|
||||
"input|block": "input",
|
||||
"led.brightness|block": "brightness",
|
||||
"led.plotBarGraph|block": "plot bar graph of %value |up to %high",
|
||||
"led.plot|block": "plot|x %x|y %y",
|
||||
"led.point|block": "point|x %x|y %y",
|
||||
"led.setBrightness|block": "set brightness %value",
|
||||
"led.stopAnimation|block": "stop animation",
|
||||
"led.toggle|block": "toggle|x %x|y %y",
|
||||
"led.unplot|block": "unplot|x %x|y %y",
|
||||
"led|block": "led",
|
||||
"music.beat|block": "%fraction|beat",
|
||||
"music.changeTempoBy|block": "change tempo by (bpm)|%value",
|
||||
"music.noteFrequency|block": "%note",
|
||||
"music.playTone|block": "play|tone %note=device_note|for %duration=device_beat",
|
||||
"music.rest|block": "rest(ms)|%duration=device_beat",
|
||||
"music.ringTone|block": "ring tone (Hz)|%note=device_note",
|
||||
"music.setTempo|block": "set tempo to (bpm)|%value",
|
||||
"music.tempo|block": "tempo (bpm)",
|
||||
"music|block": "music",
|
||||
"pins.analogReadPin|block": "analog read|pin %name",
|
||||
"pins.analogSetPeriod|block": "analog set period|pin %pin|to (µs)%micros",
|
||||
"pins.analogWritePin|block": "analog write|pin %name|to %value",
|
||||
"pins.digitalReadPin|block": "digital read|pin %name",
|
||||
"pins.digitalWritePin|block": "digital write|pin %name|to %value",
|
||||
"pins.i2cReadNumber|block": "i2c read number|at address %address|of format %format=i2c_sizeof",
|
||||
"pins.i2cWriteNumber|block": "i2c write number|at address %address|with value %value|of format %format=i2c_sizeof",
|
||||
"pins.map|block": "map %value|from low %fromLow|from high %fromHigh|to low %toLow|to high %toHigh",
|
||||
"pins.onPulsed|block": "on|pin %pin|pulsed %pulse",
|
||||
"pins.pulseDuration|block": "pulse duration (µs)",
|
||||
"pins.servoSetPulse|block": "servo set pulse|pin %value|to (µs) %micros",
|
||||
"pins.servoWritePin|block": "servo write|pin %name|to %value",
|
||||
"pins.setPull|block": "set pull|pin %pin|to %pull",
|
||||
"pins.spiWrite|block": "spi write %value",
|
||||
"pins|block": "pins",
|
||||
"serial.readLine|block": "serial read line",
|
||||
"serial.redirect|block": "serial redirect to|TX %tx|RX %rx|at baud rate %rate",
|
||||
"serial.writeLine|block": "serial|write line %text",
|
||||
"serial.writeNumber|block": "serial|write number %value",
|
||||
"serial.writeString|block": "serial write string %text",
|
||||
"serial.writeValue|block": "serial|write value %name|= %value",
|
||||
"serial|block": "serial"
|
||||
}
|
@ -1,134 +0,0 @@
|
||||
#include "ksbit.h"
|
||||
|
||||
|
||||
/**
|
||||
* Provides access to basic micro:bit functionality.
|
||||
*/
|
||||
//% color=#0078D7 weight=100
|
||||
namespace basic {
|
||||
|
||||
/**
|
||||
* Scroll a number on the screen. If the number fits on the screen (i.e. is a single digit), do not scroll.
|
||||
* @param interval speed of scroll; eg: 150, 100, 200, -100
|
||||
*/
|
||||
//% help=basic/show-number
|
||||
//% weight=96
|
||||
//% blockId=device_show_number block="show|number %number" blockGap=8 icon="\uf1ec"
|
||||
//% async
|
||||
//% parts="ledmatrix"
|
||||
void showNumber(int value, int interval = 150) {
|
||||
if (interval < 0)
|
||||
return;
|
||||
|
||||
ManagedString t(value);
|
||||
if (value < 0 || value >= 10) {
|
||||
uBit.display.scroll(t, interval);
|
||||
} else {
|
||||
uBit.display.printChar(t.charAt(0), interval * 5);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws an image on the LED screen.
|
||||
* @param leds the pattern of LED to turn on/off
|
||||
* @param interval time in milliseconds to pause after drawing
|
||||
*/
|
||||
//% help=basic/show-leds
|
||||
//% weight=95 blockGap=8
|
||||
//% imageLiteral=1 async
|
||||
//% blockId=device_show_leds
|
||||
//% block="show leds" icon="\uf00a"
|
||||
//% parts="ledmatrix"
|
||||
void showLeds(ImageLiteral leds, int interval = 400) {
|
||||
uBit.display.print(MicroBitImage(imageBytes(leds)), 0, 0, 0, interval);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display text on the display, one character at a time. If the string fits on the screen (i.e. is one letter), does not scroll.
|
||||
* @param text the text to scroll on the screen, eg: "Hello!"
|
||||
* @param interval how fast to shift characters; eg: 150, 100, 200, -100
|
||||
*/
|
||||
//% help=basic/show-string
|
||||
//% weight=87 blockGap=8
|
||||
//% block="show|string %text" icon="\uf031"
|
||||
//% async
|
||||
//% blockId=device_print_message
|
||||
//% parts="ledmatrix"
|
||||
void showString(StringData *text, int interval = 150) {
|
||||
if (interval < 0)
|
||||
return;
|
||||
ManagedString s(text);
|
||||
int l = s.length();
|
||||
if (l == 0) {
|
||||
uBit.display.clear();
|
||||
fiber_sleep(interval * 5);
|
||||
} else if (l > 1) {
|
||||
uBit.display.scroll(s, interval);
|
||||
} else {
|
||||
uBit.display.print(s.charAt(0), interval * 5);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn off all LEDs
|
||||
*/
|
||||
//% help=basic/clear-screen weight=79
|
||||
//% blockId=device_clear_display block="clear screen" icon="\uf12d"
|
||||
//% parts="ledmatrix"
|
||||
void clearScreen() {
|
||||
uBit.display.image.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows a sequence of LED screens as an animation.
|
||||
* @param leds pattern of LEDs to turn on/off
|
||||
* @param interval time in milliseconds between each redraw
|
||||
*/
|
||||
//% help=basic/show-animation imageLiteral=1 async
|
||||
//% parts="ledmatrix"
|
||||
void showAnimation(ImageLiteral leds, int interval = 400) {
|
||||
uBit.display.animate(MicroBitImage(imageBytes(leds)), interval, 5, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws an image on the LED screen.
|
||||
* @param leds pattern of LEDs to turn on/off
|
||||
*/
|
||||
//% help=basic/plot-leds weight=80
|
||||
//% parts="ledmatrix"
|
||||
void plotLeds(ImageLiteral leds) {
|
||||
MicroBitImage i(imageBytes(leds));
|
||||
uBit.display.print(i, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
void forever_stub(void *a) {
|
||||
while (true) {
|
||||
runAction0((Action)a);
|
||||
fiber_sleep(20);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Repeats the code forever in the background. On each iteration, allows other codes to run.
|
||||
* @param body code to execute
|
||||
*/
|
||||
//% help=basic/forever weight=55 blockGap=8
|
||||
//% blockId=device_forever block="forever" icon="\uf01e"
|
||||
void forever(Action a) {
|
||||
if (a != 0) {
|
||||
incr(a);
|
||||
create_fiber(forever_stub, (void*)a);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Pause for the specified time in milliseconds
|
||||
* @param ms how long to pause for, eg: 100, 200, 500, 1000, 2000
|
||||
*/
|
||||
//% help=basic/pause weight=54
|
||||
//% async block="pause (ms) %pause"
|
||||
//% blockId=device_pause icon="\uf110"
|
||||
void pause(int ms) {
|
||||
fiber_sleep(ms);
|
||||
}
|
||||
}
|
@ -1,160 +0,0 @@
|
||||
#include "ksbit.h"
|
||||
|
||||
// keep in sync with github/pxt/pxtsim/libgeneric.ts
|
||||
enum class NumberFormat {
|
||||
Int8LE = 1,
|
||||
UInt8LE,
|
||||
Int16LE,
|
||||
UInt16LE,
|
||||
Int32LE,
|
||||
Int8BE,
|
||||
UInt8BE,
|
||||
Int16BE,
|
||||
UInt16BE,
|
||||
Int32BE,
|
||||
// UInt32,
|
||||
};
|
||||
|
||||
//% indexerGet=BufferMethods::getByte indexerSet=BufferMethods::setByte
|
||||
namespace BufferMethods {
|
||||
//%
|
||||
int getByte(Buffer buf, int off) {
|
||||
return max(ManagedBuffer(buf).getByte(off), 0);
|
||||
}
|
||||
|
||||
//%
|
||||
void setByte(Buffer buf, int off, int v) {
|
||||
ManagedBuffer(buf).setByte(off, v);
|
||||
}
|
||||
|
||||
//%
|
||||
uint8_t *getBytes(Buffer buf) {
|
||||
return buf->payload;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a number in specified format in the buffer.
|
||||
*/
|
||||
//%
|
||||
void setNumber(Buffer buf, NumberFormat format, int offset, int value)
|
||||
{
|
||||
int8_t i8;
|
||||
uint8_t u8;
|
||||
int16_t i16;
|
||||
uint16_t u16;
|
||||
int32_t i32;
|
||||
|
||||
ManagedBuffer b(buf);
|
||||
|
||||
// Assume little endian
|
||||
#define WRITEBYTES(isz, swap) isz = value; b.writeBytes(offset, (uint8_t*)&isz, sizeof(isz), swap); break
|
||||
|
||||
switch (format) {
|
||||
case NumberFormat::Int8LE: WRITEBYTES(i8, false);
|
||||
case NumberFormat::UInt8LE: WRITEBYTES(u8, false);
|
||||
case NumberFormat::Int16LE: WRITEBYTES(i16, false);
|
||||
case NumberFormat::UInt16LE: WRITEBYTES(u16, false);
|
||||
case NumberFormat::Int32LE: WRITEBYTES(i32, false);
|
||||
case NumberFormat::Int8BE: WRITEBYTES(i8, true);
|
||||
case NumberFormat::UInt8BE: WRITEBYTES(u8, true);
|
||||
case NumberFormat::Int16BE: WRITEBYTES(i16, true);
|
||||
case NumberFormat::UInt16BE: WRITEBYTES(u16, true);
|
||||
case NumberFormat::Int32BE: WRITEBYTES(i32, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a number in specified format from the buffer.
|
||||
*/
|
||||
//%
|
||||
int getNumber(Buffer buf, NumberFormat format, int offset)
|
||||
{
|
||||
int8_t i8;
|
||||
uint8_t u8;
|
||||
int16_t i16;
|
||||
uint16_t u16;
|
||||
int32_t i32;
|
||||
|
||||
ManagedBuffer b(buf);
|
||||
|
||||
// Assume little endian
|
||||
#define READBYTES(isz, swap) b.readBytes((uint8_t*)&isz, offset, sizeof(isz), swap); return isz
|
||||
|
||||
switch (format) {
|
||||
case NumberFormat::Int8LE: READBYTES(i8, false);
|
||||
case NumberFormat::UInt8LE: READBYTES(u8, false);
|
||||
case NumberFormat::Int16LE: READBYTES(i16, false);
|
||||
case NumberFormat::UInt16LE: READBYTES(u16, false);
|
||||
case NumberFormat::Int32LE: READBYTES(i32, false);
|
||||
case NumberFormat::Int8BE: READBYTES(i8, true);
|
||||
case NumberFormat::UInt8BE: READBYTES(u8, true);
|
||||
case NumberFormat::Int16BE: READBYTES(i16, true);
|
||||
case NumberFormat::UInt16BE: READBYTES(u16, true);
|
||||
case NumberFormat::Int32BE: READBYTES(i32, true);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Returns the length of a Buffer object. */
|
||||
//% property
|
||||
int length(Buffer s) {
|
||||
return s->length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill (a fragment) of the buffer with given value.
|
||||
*/
|
||||
//%
|
||||
void fill(Buffer buf, int value, int offset = 0, int length = -1)
|
||||
{
|
||||
ManagedBuffer(buf).fill(value, offset, length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a copy of a fragment of a buffer.
|
||||
*/
|
||||
//%
|
||||
Buffer slice(Buffer buf, int offset = 0, int length = -1)
|
||||
{
|
||||
return ManagedBuffer(buf).slice(offset, length).leakData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Shift buffer left in place, with zero padding.
|
||||
* @param offset number of bytes to shift; use negative value to shift right
|
||||
* @param start start offset in buffer. Default is 0.
|
||||
* @param length number of elements in buffer. If negative, length is set as the buffer length minus start. eg: -1
|
||||
*/
|
||||
//%
|
||||
void shift(Buffer buf, int offset, int start = 0, int length = -1)
|
||||
{
|
||||
ManagedBuffer(buf).shift(offset, start, length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotate buffer left in place.
|
||||
* @param offset number of bytes to shift; use negative value to shift right
|
||||
* @param start start offset in buffer. Default is 0.
|
||||
* @param length number of elements in buffer. If negative, length is set as the buffer length minus start. eg: -1
|
||||
*/
|
||||
//%
|
||||
void rotate(Buffer buf, int offset, int start = 0, int length = -1)
|
||||
{
|
||||
ManagedBuffer(buf).rotate(offset, start, length);
|
||||
}
|
||||
|
||||
// int readBytes(uint8_t *dst, int offset, int length, bool swapBytes = false) const;
|
||||
// int writeBytes(int dstOffset, uint8_t *src, int length, bool swapBytes = false);
|
||||
|
||||
/**
|
||||
* Write contents of `src` at `dstOffset` in current buffer.
|
||||
*/
|
||||
//%
|
||||
void write(Buffer buf, int dstOffset, Buffer src)
|
||||
{
|
||||
//Not supported, we only do up to 4 args :/
|
||||
//void write(Buffer buf, int dstOffset, Buffer src, int srcOffset = 0, int length = -1)
|
||||
ManagedBuffer(buf).writeBuffer(dstOffset, ManagedBuffer(src), 0, -1);
|
||||
}
|
||||
}
|
@ -1,202 +0,0 @@
|
||||
#include "ksbit.h"
|
||||
|
||||
/**
|
||||
* How to create the event.
|
||||
*/
|
||||
enum class EventCreationMode {
|
||||
/**
|
||||
* MicroBitEvent is initialised, and no further processing takes place.
|
||||
*/
|
||||
CreateOnly = CREATE_ONLY,
|
||||
/**
|
||||
* MicroBitEvent is initialised, and its event handlers are immediately fired (not suitable for use in interrupts!).
|
||||
*/
|
||||
CreateAndFire = CREATE_AND_FIRE,
|
||||
};
|
||||
|
||||
// note the trailing '_' in names - otherwise we get conflict with the pre-processor
|
||||
// this trailing underscore is removed by enums.d.ts generation process
|
||||
|
||||
// TODO shouldn't these be renamed to something more sensible anyways?
|
||||
|
||||
enum EventBusSource {
|
||||
MICROBIT_ID_BUTTON_A_ = MICROBIT_ID_BUTTON_A,
|
||||
MICROBIT_ID_BUTTON_B_ = MICROBIT_ID_BUTTON_B,
|
||||
MICROBIT_ID_BUTTON_AB_ = MICROBIT_ID_BUTTON_AB,
|
||||
MICROBIT_ID_RADIO_ = MICROBIT_ID_RADIO,
|
||||
MICROBIT_ID_GESTURE_ = MICROBIT_ID_GESTURE,
|
||||
MICROBIT_ID_ACCELEROMETER_ = MICROBIT_ID_ACCELEROMETER,
|
||||
MICROBIT_ID_IO_P0_ = MICROBIT_ID_IO_P0,
|
||||
MICROBIT_ID_IO_P1_ = MICROBIT_ID_IO_P1,
|
||||
MICROBIT_ID_IO_P2_ = MICROBIT_ID_IO_P2,
|
||||
MICROBIT_ID_IO_P3_ = MICROBIT_ID_IO_P3,
|
||||
MICROBIT_ID_IO_P4_ = MICROBIT_ID_IO_P4,
|
||||
MICROBIT_ID_IO_P5_ = MICROBIT_ID_IO_P5,
|
||||
MICROBIT_ID_IO_P6_ = MICROBIT_ID_IO_P6,
|
||||
MICROBIT_ID_IO_P7_ = MICROBIT_ID_IO_P7,
|
||||
//MICROBIT_ID_IO_P8_ = MICROBIT_ID_IO_P8,
|
||||
MICROBIT_ID_IO_P9_ = MICROBIT_ID_IO_P9,
|
||||
MICROBIT_ID_IO_P10_ = MICROBIT_ID_IO_P10,
|
||||
MICROBIT_ID_IO_P11_ = MICROBIT_ID_IO_P11,
|
||||
//MICROBIT_ID_IO_P12_ = MICROBIT_ID_IO_P12,
|
||||
//MICROBIT_ID_IO_P13_ = MICROBIT_ID_IO_P13,
|
||||
//MICROBIT_ID_IO_P14_ = MICROBIT_ID_IO_P14,
|
||||
//MICROBIT_ID_IO_P15_ = MICROBIT_ID_IO_P15,
|
||||
//MICROBIT_ID_IO_P16_ = MICROBIT_ID_IO_P16,
|
||||
MICROBIT_ID_IO_P19_ = MICROBIT_ID_IO_P19,
|
||||
MICROBIT_ID_IO_P20_ = MICROBIT_ID_IO_P20,
|
||||
MES_DEVICE_INFO_ID_ = MES_DEVICE_INFO_ID,
|
||||
MES_SIGNAL_STRENGTH_ID_ = MES_SIGNAL_STRENGTH_ID,
|
||||
MES_DPAD_CONTROLLER_ID_ = MES_DPAD_CONTROLLER_ID,
|
||||
MES_BROADCAST_GENERAL_ID_ = MES_BROADCAST_GENERAL_ID,
|
||||
};
|
||||
|
||||
enum EventBusValue {
|
||||
MICROBIT_EVT_ANY_ = MICROBIT_EVT_ANY,
|
||||
MICROBIT_BUTTON_EVT_CLICK_ = MICROBIT_BUTTON_EVT_CLICK,
|
||||
MICROBIT_RADIO_EVT_DATAGRAM_ = MICROBIT_RADIO_EVT_DATAGRAM,
|
||||
MICROBIT_ACCELEROMETER_EVT_DATA_UPDATE_ = MICROBIT_ACCELEROMETER_EVT_DATA_UPDATE,
|
||||
MES_ALERT_EVT_ALARM1_ = MES_ALERT_EVT_ALARM1,
|
||||
MES_ALERT_EVT_ALARM2_ = MES_ALERT_EVT_ALARM2,
|
||||
MES_ALERT_EVT_ALARM3_ = MES_ALERT_EVT_ALARM3,
|
||||
MES_ALERT_EVT_ALARM4_ = MES_ALERT_EVT_ALARM4,
|
||||
MES_ALERT_EVT_ALARM5_ = MES_ALERT_EVT_ALARM5,
|
||||
MES_ALERT_EVT_ALARM6_ = MES_ALERT_EVT_ALARM6,
|
||||
MES_ALERT_EVT_DISPLAY_TOAST_ = MES_ALERT_EVT_DISPLAY_TOAST,
|
||||
MES_ALERT_EVT_FIND_MY_PHONE_ = MES_ALERT_EVT_FIND_MY_PHONE,
|
||||
MES_ALERT_EVT_PLAY_RINGTONE_ = MES_ALERT_EVT_PLAY_RINGTONE,
|
||||
MES_ALERT_EVT_PLAY_SOUND_ = MES_ALERT_EVT_PLAY_SOUND,
|
||||
MES_ALERT_EVT_VIBRATE_ = MES_ALERT_EVT_VIBRATE,
|
||||
MES_CAMERA_EVT_LAUNCH_PHOTO_MODE_ = MES_CAMERA_EVT_LAUNCH_PHOTO_MODE,
|
||||
MES_CAMERA_EVT_LAUNCH_VIDEO_MODE_ = MES_CAMERA_EVT_LAUNCH_VIDEO_MODE,
|
||||
MES_CAMERA_EVT_START_VIDEO_CAPTURE_ = MES_CAMERA_EVT_START_VIDEO_CAPTURE,
|
||||
MES_CAMERA_EVT_STOP_PHOTO_MODE_ = MES_CAMERA_EVT_STOP_PHOTO_MODE,
|
||||
MES_CAMERA_EVT_STOP_VIDEO_CAPTURE_ = MES_CAMERA_EVT_STOP_VIDEO_CAPTURE,
|
||||
MES_CAMERA_EVT_STOP_VIDEO_MODE_ = MES_CAMERA_EVT_STOP_VIDEO_MODE,
|
||||
MES_CAMERA_EVT_TAKE_PHOTO_ = MES_CAMERA_EVT_TAKE_PHOTO,
|
||||
MES_CAMERA_EVT_TOGGLE_FRONT_REAR_ = MES_CAMERA_EVT_TOGGLE_FRONT_REAR,
|
||||
MES_DEVICE_DISPLAY_OFF_ = MES_DEVICE_DISPLAY_OFF,
|
||||
MES_DEVICE_DISPLAY_ON_ = MES_DEVICE_DISPLAY_ON,
|
||||
MES_DEVICE_GESTURE_DEVICE_SHAKEN_ = MES_DEVICE_GESTURE_DEVICE_SHAKEN,
|
||||
MES_DEVICE_INCOMING_CALL_ = MES_DEVICE_INCOMING_CALL,
|
||||
MES_DEVICE_INCOMING_MESSAGE_ = MES_DEVICE_INCOMING_MESSAGE,
|
||||
MES_DEVICE_ORIENTATION_LANDSCAPE_ = MES_DEVICE_ORIENTATION_LANDSCAPE,
|
||||
MES_DEVICE_ORIENTATION_PORTRAIT_ = MES_DEVICE_ORIENTATION_PORTRAIT,
|
||||
MES_DPAD_BUTTON_1_DOWN_ = MES_DPAD_BUTTON_1_DOWN,
|
||||
MES_DPAD_BUTTON_1_UP_ = MES_DPAD_BUTTON_1_UP,
|
||||
MES_DPAD_BUTTON_2_DOWN_ = MES_DPAD_BUTTON_2_DOWN,
|
||||
MES_DPAD_BUTTON_2_UP_ = MES_DPAD_BUTTON_2_UP,
|
||||
MES_DPAD_BUTTON_3_DOWN_ = MES_DPAD_BUTTON_3_DOWN,
|
||||
MES_DPAD_BUTTON_3_UP_ = MES_DPAD_BUTTON_3_UP,
|
||||
MES_DPAD_BUTTON_4_DOWN_ = MES_DPAD_BUTTON_4_DOWN,
|
||||
MES_DPAD_BUTTON_4_UP_ = MES_DPAD_BUTTON_4_UP,
|
||||
MES_DPAD_BUTTON_A_DOWN_ = MES_DPAD_BUTTON_A_DOWN,
|
||||
MES_DPAD_BUTTON_A_UP_ = MES_DPAD_BUTTON_A_UP,
|
||||
MES_DPAD_BUTTON_B_DOWN_ = MES_DPAD_BUTTON_B_DOWN,
|
||||
MES_DPAD_BUTTON_B_UP_ = MES_DPAD_BUTTON_B_UP,
|
||||
MES_DPAD_BUTTON_C_DOWN_ = MES_DPAD_BUTTON_C_DOWN,
|
||||
MES_DPAD_BUTTON_C_UP_ = MES_DPAD_BUTTON_C_UP,
|
||||
MES_DPAD_BUTTON_D_DOWN_ = MES_DPAD_BUTTON_D_DOWN,
|
||||
MES_DPAD_BUTTON_D_UP_ = MES_DPAD_BUTTON_D_UP,
|
||||
MES_REMOTE_CONTROL_EVT_FORWARD_ = MES_REMOTE_CONTROL_EVT_FORWARD,
|
||||
MES_REMOTE_CONTROL_EVT_NEXTTRACK_ = MES_REMOTE_CONTROL_EVT_NEXTTRACK,
|
||||
MES_REMOTE_CONTROL_EVT_PAUSE_ = MES_REMOTE_CONTROL_EVT_PAUSE,
|
||||
MES_REMOTE_CONTROL_EVT_PLAY_ = MES_REMOTE_CONTROL_EVT_PLAY,
|
||||
MES_REMOTE_CONTROL_EVT_PREVTRACK_ = MES_REMOTE_CONTROL_EVT_PREVTRACK,
|
||||
MES_REMOTE_CONTROL_EVT_REWIND_ = MES_REMOTE_CONTROL_EVT_REWIND,
|
||||
MES_REMOTE_CONTROL_EVT_STOP_ = MES_REMOTE_CONTROL_EVT_STOP,
|
||||
MES_REMOTE_CONTROL_EVT_VOLUMEDOWN_ = MES_REMOTE_CONTROL_EVT_VOLUMEDOWN,
|
||||
MES_REMOTE_CONTROL_EVT_VOLUMEUP_ = MES_REMOTE_CONTROL_EVT_VOLUMEUP,
|
||||
};
|
||||
|
||||
//% weight=1 color="#333333"
|
||||
namespace control {
|
||||
void fiberDone(void *a)
|
||||
{
|
||||
decr((Action)a);
|
||||
release_fiber();
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedules code that run in the background.
|
||||
*/
|
||||
//% help=control/in-background
|
||||
//% blockId="control_in_background" block="run in background" blockGap=8
|
||||
void inBackground(Action a) {
|
||||
runInBackground(a);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the BBC micro:bit.
|
||||
*/
|
||||
//% weight=30 async help=control/reset blockGap=8
|
||||
//% blockId="control_reset" block="reset"
|
||||
void reset() {
|
||||
microbit_reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* Blocks the current fiber for the given microseconds
|
||||
* @param micros number of micro-seconds to wait. eg: 4
|
||||
*/
|
||||
//% help=control/wait-micros weight=29
|
||||
//% blockId="control_wait_us" block="wait (µs)%micros"
|
||||
void waitMicros(int micros) {
|
||||
wait_us(micros);
|
||||
}
|
||||
|
||||
/**
|
||||
* Raises an event in the event bus.
|
||||
* @param src ID of the MicroBit Component that generated the event e.g. MICROBIT_ID_BUTTON_A.
|
||||
* @param value Component specific code indicating the cause of the event.
|
||||
* @param mode optional definition of how the event should be processed after construction (default is CREATE_AND_FIRE).
|
||||
*/
|
||||
//% weight=21 blockGap=12 blockId="control_raise_event" block="raise event|from source %src=control_event_source_id|with value %value=control_event_value_id" blockExternalInputs=1
|
||||
//% mode.defl=CREATE_AND_FIRE
|
||||
void raiseEvent(int src, int value, EventCreationMode mode) {
|
||||
MicroBitEvent evt(src, value, (MicroBitEventLaunchMode)mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Raises an event in the event bus.
|
||||
*/
|
||||
//% weight=20 blockGap=8 blockId="control_on_event" block="on event|from %src=control_event_source_id|with value %value=control_event_value_id"
|
||||
//% blockExternalInputs=1
|
||||
void onEvent(int src, int value, Action handler) {
|
||||
registerWithDal(src, value, handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the last event executed on the bus
|
||||
*/
|
||||
//% blockId=control_event_value" block="event value"
|
||||
//% weight=18
|
||||
int eventValue() {
|
||||
return pxt::lastEvent.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the timestamp of the last event executed on the bus
|
||||
*/
|
||||
//% blockId=control_event_timestamp" block="event timestamp"
|
||||
//% weight=19 blockGap=8
|
||||
int eventTimestamp() {
|
||||
return pxt::lastEvent.timestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a friendly name for the device derived from the its serial number
|
||||
*/
|
||||
//% blockId="control_device_name" block="device name" weight=10 blockGap=8
|
||||
StringData* deviceName() {
|
||||
return ManagedString(microbit_friendly_name()).leakData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Derive a unique, consistent serial number of this device from internal data.
|
||||
*/
|
||||
//% blockId="control_device_serial_number" block="device serial number" weight=9
|
||||
int deviceSerialNumber() {
|
||||
return microbit_serial_number();
|
||||
}
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
/**
|
||||
* Runtime and event utilities.
|
||||
*/
|
||||
//% weight=1 color="#333333"
|
||||
namespace control {
|
||||
|
||||
/**
|
||||
* Returns the value of a C++ runtime constant
|
||||
*/
|
||||
//% weight=2 weight=19 blockId="control_event_source_id" block="%id" blockGap=8
|
||||
//% shim=TD_ID
|
||||
export function eventSourceId(id: EventBusSource): number {
|
||||
return id;
|
||||
}
|
||||
/**
|
||||
* Returns the value of a C++ runtime constant
|
||||
*/
|
||||
//% weight=1 weight=19 blockId="control_event_value_id" block="%id"
|
||||
//% shim=TD_ID
|
||||
export function eventValueId(id: EventBusValue): number {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display specified error code and stop the program.
|
||||
*/
|
||||
//% shim=pxtrt::panic
|
||||
export function panic(code: number) { }
|
||||
|
||||
/**
|
||||
* If the condition is false, display msg on serial console, and panic with code 098.
|
||||
*/
|
||||
export function assert(condition: boolean, msg ?: string) {
|
||||
if (!condition) {
|
||||
console.log("ASSERTION FAILED")
|
||||
if (msg != null) {
|
||||
console.log(msg)
|
||||
}
|
||||
panic(98)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display warning in the simulator.
|
||||
*/
|
||||
//% shim=pxtrt::runtimeWarning
|
||||
export function runtimeWarning(message: string) { }
|
||||
}
|
@ -1,393 +0,0 @@
|
||||
#include "ksbit.h"
|
||||
#include <limits.h>
|
||||
|
||||
|
||||
namespace String_ {
|
||||
//%
|
||||
StringData *charAt(StringData *s, int pos) {
|
||||
return ManagedString((char)ManagedString(s).charAt(pos)).leakData();
|
||||
}
|
||||
|
||||
//%
|
||||
int charCodeAt(StringData *s, int index) {
|
||||
return ManagedString(s).charAt(index);
|
||||
}
|
||||
|
||||
//%
|
||||
StringData *concat(StringData *s, StringData *other) {
|
||||
ManagedString a(s), b(other);
|
||||
return (a + b).leakData();
|
||||
}
|
||||
|
||||
//%
|
||||
int compare(StringData *s, StringData *that) {
|
||||
return strcmp(s->data, that->data);
|
||||
}
|
||||
|
||||
//%
|
||||
int length(StringData *s) { return s->len; }
|
||||
|
||||
//%
|
||||
StringData *fromCharCode(int code)
|
||||
{
|
||||
return ManagedString((char)code).leakData();
|
||||
}
|
||||
|
||||
//%
|
||||
int toNumber(StringData *s) {
|
||||
return atoi(s->data);
|
||||
}
|
||||
|
||||
//%
|
||||
StringData *mkEmpty()
|
||||
{
|
||||
return ManagedString::EmptyString.leakData();
|
||||
}
|
||||
|
||||
//%
|
||||
StringData *substr(StringData *s, int start, int length)
|
||||
{
|
||||
if (length <= 0)
|
||||
return mkEmpty();
|
||||
if (start < 0)
|
||||
start = max(s->len + start, 0);
|
||||
length = min(length, s->len - start);
|
||||
ManagedString x(s);
|
||||
return x.substring(start, length).leakData();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
namespace Boolean_ {
|
||||
// Cache the string literals "true" and "false" when used.
|
||||
// Note that the representation of booleans stays the usual C-one.
|
||||
|
||||
static const char sTrue[] __attribute__ ((aligned (4))) = "\xff\xff\x04\x00" "true\0";
|
||||
static const char sFalse[] __attribute__ ((aligned (4))) = "\xff\xff\x05\x00" "false\0";
|
||||
|
||||
//%
|
||||
StringData* toString(bool v)
|
||||
{
|
||||
if (v) {
|
||||
return (StringData*)(void*)sTrue;
|
||||
} else {
|
||||
return (StringData*)(void*)sFalse;
|
||||
}
|
||||
}
|
||||
|
||||
//%
|
||||
bool bang(bool v) { return !v; }
|
||||
}
|
||||
|
||||
namespace Number_ {
|
||||
//%
|
||||
StringData* toString(int n)
|
||||
{
|
||||
return ManagedString(n).leakData();
|
||||
}
|
||||
|
||||
// +, - and friends are handled directly by assembly instructions
|
||||
// The comparisons are here as they are more code-size efficient
|
||||
|
||||
//%
|
||||
bool lt(int x, int y) { return x < y; }
|
||||
//%
|
||||
bool le(int x, int y) { return x <= y; }
|
||||
//%
|
||||
bool neq(int x, int y) { return x != y; }
|
||||
//%
|
||||
bool eq(int x, int y) { return x == y; }
|
||||
//%
|
||||
bool gt(int x, int y) { return x > y; }
|
||||
//%
|
||||
bool ge(int x, int y) { return x >= y; }
|
||||
|
||||
// These in fact call into C runtime on Cortex-M0
|
||||
//%
|
||||
int div(int x, int y) { return x / y; }
|
||||
//%
|
||||
int mod(int x, int y) { return x % y; }
|
||||
}
|
||||
|
||||
namespace Math_ {
|
||||
//%
|
||||
int pow(int x, int y)
|
||||
{
|
||||
if (y < 0)
|
||||
return 0;
|
||||
int r = 1;
|
||||
while (y) {
|
||||
if (y & 1)
|
||||
r *= x;
|
||||
y >>= 1;
|
||||
x *= x;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
//%
|
||||
int random(int max) {
|
||||
if (max == INT_MIN)
|
||||
return -microbit_random(INT_MAX);
|
||||
else if (max < 0)
|
||||
return -microbit_random(-max);
|
||||
else if (max == 0)
|
||||
return 0;
|
||||
else
|
||||
return microbit_random(max);
|
||||
}
|
||||
|
||||
//%
|
||||
int sqrt(int x)
|
||||
{
|
||||
return ::sqrt(x);
|
||||
}
|
||||
}
|
||||
|
||||
namespace Array_ {
|
||||
//%
|
||||
RefCollection *mk(uint32_t flags)
|
||||
{
|
||||
return new RefCollection(flags);
|
||||
}
|
||||
//%
|
||||
int length(RefCollection *c) { return c->length(); }
|
||||
//%
|
||||
void push(RefCollection *c, uint32_t x) { c->push(x); }
|
||||
//%
|
||||
uint32_t getAt(RefCollection *c, int x) { return c->getAt(x); }
|
||||
//%
|
||||
void removeAt(RefCollection *c, int x) { c->removeAt(x); }
|
||||
//%
|
||||
void setAt(RefCollection *c, int x, uint32_t y) { c->setAt(x, y); }
|
||||
//%
|
||||
int indexOf(RefCollection *c, uint32_t x, int start) { return c->indexOf(x, start); }
|
||||
//%
|
||||
int removeElement(RefCollection *c, uint32_t x) { return c->removeElement(x); }
|
||||
}
|
||||
|
||||
|
||||
// Import some stuff directly
|
||||
namespace pxt {
|
||||
//%
|
||||
void registerWithDal(int id, int event, Action a);
|
||||
//%
|
||||
uint32_t runAction3(Action a, int arg0, int arg1, int arg2);
|
||||
//%
|
||||
uint32_t runAction2(Action a, int arg0, int arg1);
|
||||
//%
|
||||
uint32_t runAction1(Action a, int arg0);
|
||||
//%
|
||||
uint32_t runAction0(Action a);
|
||||
//%
|
||||
Action mkAction(int reflen, int totallen, int startptr);
|
||||
//%
|
||||
RefRecord* mkClassInstance(int offset);
|
||||
//%
|
||||
void RefRecord_destroy(RefRecord *r);
|
||||
//%
|
||||
void RefRecord_print(RefRecord *r);
|
||||
//%
|
||||
void debugMemLeaks();
|
||||
//%
|
||||
int incr(uint32_t e);
|
||||
//%
|
||||
void decr(uint32_t e);
|
||||
//%
|
||||
uint32_t *allocate(uint16_t sz);
|
||||
//%
|
||||
int templateHash();
|
||||
//%
|
||||
int programHash();
|
||||
//%
|
||||
void *ptrOfLiteral(int offset);
|
||||
//%
|
||||
int getNumGlobals();
|
||||
}
|
||||
|
||||
namespace pxtrt {
|
||||
//%
|
||||
uint32_t ldloc(RefLocal *r) {
|
||||
return r->v;
|
||||
}
|
||||
|
||||
//%
|
||||
uint32_t ldlocRef(RefRefLocal *r) {
|
||||
uint32_t tmp = r->v;
|
||||
incr(tmp);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
//%
|
||||
void stloc(RefLocal *r, uint32_t v) {
|
||||
r->v = v;
|
||||
}
|
||||
|
||||
//%
|
||||
void stlocRef(RefRefLocal *r, uint32_t v) {
|
||||
decr(r->v);
|
||||
r->v = v;
|
||||
}
|
||||
|
||||
//%
|
||||
RefLocal *mkloc() {
|
||||
return new RefLocal();
|
||||
}
|
||||
|
||||
//%
|
||||
RefRefLocal *mklocRef() {
|
||||
return new RefRefLocal();
|
||||
}
|
||||
|
||||
// All of the functions below unref() self. This is for performance reasons -
|
||||
// the code emitter will not emit the unrefs for them.
|
||||
|
||||
//%
|
||||
uint32_t ldfld(RefRecord *r, int idx) {
|
||||
auto tmp = r->ld(idx);
|
||||
r->unref();
|
||||
return tmp;
|
||||
}
|
||||
|
||||
//%
|
||||
uint32_t ldfldRef(RefRecord *r, int idx) {
|
||||
auto tmp = r->ldref(idx);
|
||||
r->unref();
|
||||
return tmp;
|
||||
}
|
||||
|
||||
//%
|
||||
void stfld(RefRecord *r, int idx, uint32_t val) {
|
||||
r->st(idx, val);
|
||||
r->unref();
|
||||
}
|
||||
|
||||
//%
|
||||
void stfldRef(RefRecord *r, int idx, uint32_t val) {
|
||||
r->stref(idx, val);
|
||||
r->unref();
|
||||
}
|
||||
|
||||
// Store a captured local in a closure. It returns the action, so it can be chained.
|
||||
//%
|
||||
RefAction *stclo(RefAction *a, int idx, uint32_t v)
|
||||
{
|
||||
//DBG("STCLO "); a->print(); DBG("@%d = %p\n", idx, (void*)v);
|
||||
a->stCore(idx, v);
|
||||
return a;
|
||||
}
|
||||
|
||||
//%
|
||||
void panic(int code)
|
||||
{
|
||||
microbit_panic(code);
|
||||
}
|
||||
|
||||
//%
|
||||
int stringToBool(StringData *s) {
|
||||
if (s == NULL) return 0;
|
||||
if (s->len == 0) {
|
||||
s->decr();
|
||||
return 0;
|
||||
}
|
||||
s->decr();
|
||||
return 1;
|
||||
}
|
||||
|
||||
//%
|
||||
StringData* emptyToNull(StringData *s) {
|
||||
if (!s || s->len == 0)
|
||||
return NULL;
|
||||
return s;
|
||||
}
|
||||
|
||||
//%
|
||||
int ptrToBool(uint32_t p) {
|
||||
if (p) {
|
||||
decr(p);
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
//%
|
||||
RefMap *mkMap() {
|
||||
return new RefMap();
|
||||
}
|
||||
|
||||
//%
|
||||
uint32_t mapGet(RefMap *map, uint32_t key) {
|
||||
int i = map->findIdx(key);
|
||||
if (i < 0) {
|
||||
map->unref();
|
||||
return 0;
|
||||
}
|
||||
uint32_t r = map->data[i].val;
|
||||
map->unref();
|
||||
return r;
|
||||
}
|
||||
|
||||
//%
|
||||
uint32_t mapGetRef(RefMap *map, uint32_t key) {
|
||||
int i = map->findIdx(key);
|
||||
if (i < 0) {
|
||||
map->unref();
|
||||
return 0;
|
||||
}
|
||||
uint32_t r = incr(map->data[i].val);
|
||||
map->unref();
|
||||
return r;
|
||||
}
|
||||
|
||||
//%
|
||||
void mapSet(RefMap *map, uint32_t key, uint32_t val) {
|
||||
int i = map->findIdx(key);
|
||||
if (i < 0) {
|
||||
map->data.push_back({
|
||||
key << 1,
|
||||
val
|
||||
});
|
||||
} else {
|
||||
if (map->data[i].key & 1) {
|
||||
decr(map->data[i].val);
|
||||
map->data[i].key = key << 1;
|
||||
}
|
||||
map->data[i].val = val;
|
||||
}
|
||||
map->unref();
|
||||
}
|
||||
|
||||
//%
|
||||
void mapSetRef(RefMap *map, uint32_t key, uint32_t val) {
|
||||
int i = map->findIdx(key);
|
||||
if (i < 0) {
|
||||
map->data.push_back({
|
||||
(key << 1) | 1,
|
||||
val
|
||||
});
|
||||
} else {
|
||||
if (map->data[i].key & 1) {
|
||||
decr(map->data[i].val);
|
||||
} else {
|
||||
map->data[i].key = (key << 1) | 1;
|
||||
}
|
||||
map->data[i].val = val;
|
||||
}
|
||||
map->unref();
|
||||
}
|
||||
|
||||
//
|
||||
// Debugger
|
||||
//
|
||||
|
||||
//%
|
||||
void* getGlobalsPtr() {
|
||||
return globals;
|
||||
}
|
||||
|
||||
//%
|
||||
void runtimeWarning(StringData *s) {
|
||||
// noop for now
|
||||
}
|
||||
}
|
617
libs/microbit/dal.d.ts
vendored
617
libs/microbit/dal.d.ts
vendored
@ -1,617 +0,0 @@
|
||||
// Auto-generated. Do not edit.
|
||||
declare const enum DAL {
|
||||
// built/yt/yotta_modules/microbit-dal/inc//bluetooth/ExternalEvents.h
|
||||
MICROBIT_ID_BLE = 1000,
|
||||
MICROBIT_ID_BLE_UART = 1200,
|
||||
MICROBIT_BLE_EVT_CONNECTED = 1,
|
||||
MICROBIT_BLE_EVT_DISCONNECTED = 2,
|
||||
// built/yt/yotta_modules/microbit-dal/inc//bluetooth/MESEvents.h
|
||||
MES_REMOTE_CONTROL_ID = 1001,
|
||||
MES_REMOTE_CONTROL_EVT_PLAY = 1,
|
||||
MES_REMOTE_CONTROL_EVT_PAUSE = 2,
|
||||
MES_REMOTE_CONTROL_EVT_STOP = 3,
|
||||
MES_REMOTE_CONTROL_EVT_NEXTTRACK = 4,
|
||||
MES_REMOTE_CONTROL_EVT_PREVTRACK = 5,
|
||||
MES_REMOTE_CONTROL_EVT_FORWARD = 6,
|
||||
MES_REMOTE_CONTROL_EVT_REWIND = 7,
|
||||
MES_REMOTE_CONTROL_EVT_VOLUMEUP = 8,
|
||||
MES_REMOTE_CONTROL_EVT_VOLUMEDOWN = 9,
|
||||
MES_CAMERA_ID = 1002,
|
||||
MES_CAMERA_EVT_LAUNCH_PHOTO_MODE = 1,
|
||||
MES_CAMERA_EVT_LAUNCH_VIDEO_MODE = 2,
|
||||
MES_CAMERA_EVT_TAKE_PHOTO = 3,
|
||||
MES_CAMERA_EVT_START_VIDEO_CAPTURE = 4,
|
||||
MES_CAMERA_EVT_STOP_VIDEO_CAPTURE = 5,
|
||||
MES_CAMERA_EVT_STOP_PHOTO_MODE = 6,
|
||||
MES_CAMERA_EVT_STOP_VIDEO_MODE = 7,
|
||||
MES_CAMERA_EVT_TOGGLE_FRONT_REAR = 8,
|
||||
MES_ALERTS_ID = 1004,
|
||||
MES_ALERT_EVT_DISPLAY_TOAST = 1,
|
||||
MES_ALERT_EVT_VIBRATE = 2,
|
||||
MES_ALERT_EVT_PLAY_SOUND = 3,
|
||||
MES_ALERT_EVT_PLAY_RINGTONE = 4,
|
||||
MES_ALERT_EVT_FIND_MY_PHONE = 5,
|
||||
MES_ALERT_EVT_ALARM1 = 6,
|
||||
MES_ALERT_EVT_ALARM2 = 7,
|
||||
MES_ALERT_EVT_ALARM3 = 8,
|
||||
MES_ALERT_EVT_ALARM4 = 9,
|
||||
MES_ALERT_EVT_ALARM5 = 10,
|
||||
MES_ALERT_EVT_ALARM6 = 11,
|
||||
MES_SIGNAL_STRENGTH_ID = 1101,
|
||||
MES_SIGNAL_STRENGTH_EVT_NO_BAR = 1,
|
||||
MES_SIGNAL_STRENGTH_EVT_ONE_BAR = 2,
|
||||
MES_SIGNAL_STRENGTH_EVT_TWO_BAR = 3,
|
||||
MES_SIGNAL_STRENGTH_EVT_THREE_BAR = 4,
|
||||
MES_SIGNAL_STRENGTH_EVT_FOUR_BAR = 5,
|
||||
MES_DEVICE_INFO_ID = 1103,
|
||||
MES_DEVICE_ORIENTATION_LANDSCAPE = 1,
|
||||
MES_DEVICE_ORIENTATION_PORTRAIT = 2,
|
||||
MES_DEVICE_GESTURE_NONE = 3,
|
||||
MES_DEVICE_GESTURE_DEVICE_SHAKEN = 4,
|
||||
MES_DEVICE_DISPLAY_OFF = 5,
|
||||
MES_DEVICE_DISPLAY_ON = 6,
|
||||
MES_DEVICE_INCOMING_CALL = 7,
|
||||
MES_DEVICE_INCOMING_MESSAGE = 8,
|
||||
MES_DPAD_CONTROLLER_ID = 1104,
|
||||
MES_DPAD_BUTTON_A_DOWN = 1,
|
||||
MES_DPAD_BUTTON_A_UP = 2,
|
||||
MES_DPAD_BUTTON_B_DOWN = 3,
|
||||
MES_DPAD_BUTTON_B_UP = 4,
|
||||
MES_DPAD_BUTTON_C_DOWN = 5,
|
||||
MES_DPAD_BUTTON_C_UP = 6,
|
||||
MES_DPAD_BUTTON_D_DOWN = 7,
|
||||
MES_DPAD_BUTTON_D_UP = 8,
|
||||
MES_DPAD_BUTTON_1_DOWN = 9,
|
||||
MES_DPAD_BUTTON_1_UP = 10,
|
||||
MES_DPAD_BUTTON_2_DOWN = 11,
|
||||
MES_DPAD_BUTTON_2_UP = 12,
|
||||
MES_DPAD_BUTTON_3_DOWN = 13,
|
||||
MES_DPAD_BUTTON_3_UP = 14,
|
||||
MES_DPAD_BUTTON_4_DOWN = 15,
|
||||
MES_DPAD_BUTTON_4_UP = 16,
|
||||
MES_BROADCAST_GENERAL_ID = 2000,
|
||||
// built/yt/yotta_modules/microbit-dal/inc//bluetooth/MicroBitAccelerometerService.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc//bluetooth/MicroBitBLEManager.h
|
||||
MICROBIT_BLE_PAIR_REQUEST = 0x01,
|
||||
MICROBIT_BLE_PAIR_COMPLETE = 0x02,
|
||||
MICROBIT_BLE_PAIR_PASSCODE = 0x04,
|
||||
MICROBIT_BLE_PAIR_SUCCESSFUL = 0x08,
|
||||
MICROBIT_BLE_PAIRING_TIMEOUT = 90,
|
||||
MICROBIT_BLE_POWER_LEVELS = 8,
|
||||
MICROBIT_BLE_MAXIMUM_BONDS = 4,
|
||||
MICROBIT_BLE_EDDYSTONE_URL_ADV_INTERVAL = 400,
|
||||
// built/yt/yotta_modules/microbit-dal/inc//bluetooth/MicroBitButtonService.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc//bluetooth/MicroBitDFUService.h
|
||||
MICROBIT_DFU_OPCODE_START_DFU = 1,
|
||||
MICROBIT_DFU_HISTOGRAM_WIDTH = 5,
|
||||
MICROBIT_DFU_HISTOGRAM_HEIGHT = 5,
|
||||
// built/yt/yotta_modules/microbit-dal/inc//bluetooth/MicroBitEventService.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc//bluetooth/MicroBitIOPinService.h
|
||||
MICROBIT_IO_PIN_SERVICE_PINCOUNT = 19,
|
||||
MICROBIT_IO_PIN_SERVICE_DATA_SIZE = 10,
|
||||
MICROBIT_PWM_PIN_SERVICE_DATA_SIZE = 2,
|
||||
// built/yt/yotta_modules/microbit-dal/inc//bluetooth/MicroBitLEDService.h
|
||||
MICROBIT_BLE_MAXIMUM_SCROLLTEXT = 20,
|
||||
// built/yt/yotta_modules/microbit-dal/inc//bluetooth/MicroBitMagnetometerService.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc//bluetooth/MicroBitTemperatureService.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc//bluetooth/MicroBitUARTService.h
|
||||
MICROBIT_UART_S_DEFAULT_BUF_SIZE = 20,
|
||||
MICROBIT_UART_S_EVT_DELIM_MATCH = 1,
|
||||
MICROBIT_UART_S_EVT_HEAD_MATCH = 2,
|
||||
MICROBIT_UART_S_EVT_RX_FULL = 3,
|
||||
// built/yt/yotta_modules/microbit-dal/inc//core/ErrorNo.h
|
||||
MICROBIT_OK = 0,
|
||||
MICROBIT_INVALID_PARAMETER = -1001,
|
||||
MICROBIT_NOT_SUPPORTED = -1002,
|
||||
MICROBIT_CALIBRATION_IN_PROGRESS = -1003,
|
||||
MICROBIT_CALIBRATION_REQUIRED = -1004,
|
||||
MICROBIT_NO_RESOURCES = -1005,
|
||||
MICROBIT_BUSY = -1006,
|
||||
MICROBIT_CANCELLED = -1007,
|
||||
MICROBIT_I2C_ERROR = -1010,
|
||||
MICROBIT_SERIAL_IN_USE = -1011,
|
||||
MICROBIT_NO_DATA = -1012,
|
||||
MICROBIT_OOM = 20,
|
||||
MICROBIT_HEAP_ERROR = 30,
|
||||
MICROBIT_NULL_DEREFERENCE = 40,
|
||||
// built/yt/yotta_modules/microbit-dal/inc//core/EventModel.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc//core/MemberFunctionCallback.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc//core/MicroBitCompat.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc//core/MicroBitComponent.h
|
||||
MICROBIT_ID_BUTTON_A = 1,
|
||||
MICROBIT_ID_BUTTON_B = 2,
|
||||
MICROBIT_ID_BUTTON_RESET = 3,
|
||||
MICROBIT_ID_ACCELEROMETER = 4,
|
||||
MICROBIT_ID_COMPASS = 5,
|
||||
MICROBIT_ID_DISPLAY = 6,
|
||||
MICROBIT_IO_PINS = 20,
|
||||
MICROBIT_ID_IO_P0 = 7,
|
||||
MICROBIT_ID_IO_P1 = 8,
|
||||
MICROBIT_ID_IO_P2 = 9,
|
||||
MICROBIT_ID_IO_P3 = 10,
|
||||
MICROBIT_ID_IO_P4 = 11,
|
||||
MICROBIT_ID_IO_P5 = 12,
|
||||
MICROBIT_ID_IO_P6 = 13,
|
||||
MICROBIT_ID_IO_P7 = 14,
|
||||
MICROBIT_ID_IO_P9 = 16,
|
||||
MICROBIT_ID_IO_P10 = 17,
|
||||
MICROBIT_ID_IO_P11 = 18,
|
||||
MICROBIT_ID_IO_P19 = 24,
|
||||
MICROBIT_ID_IO_P20 = 25,
|
||||
MICROBIT_ID_BUTTON_AB = 26,
|
||||
MICROBIT_ID_GESTURE = 27,
|
||||
MICROBIT_ID_THERMOMETER = 28,
|
||||
MICROBIT_ID_RADIO = 29,
|
||||
MICROBIT_ID_RADIO_DATA_READY = 30,
|
||||
MICROBIT_ID_MULTIBUTTON_ATTACH = 31,
|
||||
MICROBIT_ID_SERIAL = 32,
|
||||
CALLIOPE_ID_IO_P0 = 33,
|
||||
CALLIOPE_ID_IO_P7 = 34,
|
||||
CALLIOPE_ID_IO_P8 = 35,
|
||||
CALLIOPE_ID_IO_P9 = 36,
|
||||
CALLIOPE_ID_IO_P13 = 37,
|
||||
CALLIOPE_ID_IO_P14 = 38,
|
||||
CALLIOPE_ID_IO_P15 = 39,
|
||||
MICROBIT_ID_MESSAGE_BUS_LISTENER = 1021,
|
||||
MICROBIT_ID_NOTIFY_ONE = 1022,
|
||||
MICROBIT_ID_NOTIFY = 1023,
|
||||
MICROBIT_COMPONENT_RUNNING = 0x01,
|
||||
// built/yt/yotta_modules/microbit-dal/inc//core/MicroBitDevice.h
|
||||
MICROBIT_NAME_LENGTH = 5,
|
||||
MICROBIT_NAME_CODE_LETTERS = 5,
|
||||
MICROBIT_PANIC_ERROR_CHARS = 4,
|
||||
// built/yt/yotta_modules/microbit-dal/inc//core/MicroBitFiber.h
|
||||
MICROBIT_SCHEDULER_RUNNING = 0x01,
|
||||
MICROBIT_FIBER_FLAG_FOB = 0x01,
|
||||
MICROBIT_FIBER_FLAG_PARENT = 0x02,
|
||||
MICROBIT_FIBER_FLAG_CHILD = 0x04,
|
||||
MICROBIT_FIBER_FLAG_DO_NOT_PAGE = 0x08,
|
||||
// built/yt/yotta_modules/microbit-dal/inc//core/MicroBitFont.h
|
||||
MICROBIT_FONT_WIDTH = 5,
|
||||
MICROBIT_FONT_HEIGHT = 5,
|
||||
MICROBIT_FONT_ASCII_START = 32,
|
||||
MICROBIT_FONT_ASCII_END = 126,
|
||||
// built/yt/yotta_modules/microbit-dal/inc//core/MicroBitHeapAllocator.h
|
||||
MICROBIT_MAXIMUM_HEAPS = 2,
|
||||
MICROBIT_HEAP_BLOCK_FREE = 0x80000000,
|
||||
// built/yt/yotta_modules/microbit-dal/inc//core/MicroBitListener.h
|
||||
MESSAGE_BUS_LISTENER_PARAMETERISED = 0x0001,
|
||||
MESSAGE_BUS_LISTENER_METHOD = 0x0002,
|
||||
MESSAGE_BUS_LISTENER_BUSY = 0x0004,
|
||||
MESSAGE_BUS_LISTENER_REENTRANT = 0x0008,
|
||||
MESSAGE_BUS_LISTENER_QUEUE_IF_BUSY = 0x0010,
|
||||
MESSAGE_BUS_LISTENER_DROP_IF_BUSY = 0x0020,
|
||||
MESSAGE_BUS_LISTENER_NONBLOCKING = 0x0040,
|
||||
MESSAGE_BUS_LISTENER_URGENT = 0x0080,
|
||||
MESSAGE_BUS_LISTENER_DELETING = 0x8000,
|
||||
// built/yt/yotta_modules/microbit-dal/inc//core/MicroBitSystemTimer.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc//core/NotifyEvents.h
|
||||
MICROBIT_DISPLAY_EVT_FREE = 1,
|
||||
MICROBIT_SERIAL_EVT_TX_EMPTY = 2,
|
||||
MICROBIT_UART_S_EVT_TX_EMPTY = 3,
|
||||
// built/yt/yotta_modules/microbit-dal/inc//drivers/CalliopeRGB.h
|
||||
RGB_LED_DEFAULT_GREEN = 0,
|
||||
RGB_LED_DEFAULT_RED = 0,
|
||||
RGB_LED_DEFAULT_BLUE = 0,
|
||||
RGB_LED_DEFAULT_WHITE = 0,
|
||||
RGB_KEEP_VALUE = -1,
|
||||
RGB_LED_MAX_INTENSITY = 50,
|
||||
// built/yt/yotta_modules/microbit-dal/inc//drivers/CalliopeSoundMotor.h
|
||||
CALLIOPE_SM_DEFAULT_DUTY_M = 50,
|
||||
CALLIOPE_SM_DEFAULT_DUTY_S = 100,
|
||||
CALLIOPE_SM_DEFAULT_FREQUENCY_S = 4000,
|
||||
CALLIOPE_SM_DEFAULT_SILENT_MODE = 1,
|
||||
CALLIOPE_SM_PRESCALER_M = 2,
|
||||
CALLIOPE_SM_PRESCALER_S = 0,
|
||||
CALLIOPE_SM_PRESCALER_S_LF = 4,
|
||||
CALLIOPE_SM_PERIOD_M = 100,
|
||||
CALLIOPE_MIN_FREQUENCY_HZ_S_NP = 245,
|
||||
CALLIOPE_MIN_FREQUENCY_HZ_S = 20,
|
||||
CALLIOPE_MAX_FREQUENCY_HZ_S = 20000,
|
||||
CALLIOPE_BOARD_FREQUENCY = 16000000,
|
||||
// built/yt/yotta_modules/microbit-dal/inc//drivers/DynamicPwm.h
|
||||
NO_PWMS = 3,
|
||||
MICROBIT_DEFAULT_PWM_PERIOD = 20000,
|
||||
PWM_PERSISTENCE_TRANSIENT = 1,
|
||||
PWM_PERSISTENCE_PERSISTENT = 2,
|
||||
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitAccelerometer-bmx.h
|
||||
BMX055_ACC_WHOAMI = 0x00,
|
||||
BMX055_ACC_D_X_LSB = 0x02,
|
||||
BMX055_ACC_D_X_MSB = 0x03,
|
||||
BMX055_ACC_D_Y_LSB = 0x04,
|
||||
BMX055_ACC_D_Y_MSB = 0x05,
|
||||
BMX055_ACC_D_Z_LSB = 0x06,
|
||||
BMX055_ACC_D_Z_MSB = 0x07,
|
||||
BMX055_ACC_D_TEMP = 0x08,
|
||||
BMX055_ACC_INT_STATUS_0 = 0x09,
|
||||
BMX055_ACC_INT_STATUS_1 = 0x0A,
|
||||
BMX055_ACC_INT_STATUS_2 = 0x0B,
|
||||
BMX055_ACC_INT_STATUS_3 = 0x0C,
|
||||
BMX055_ACC_FIFO_STATUS = 0x0E,
|
||||
BMX055_ACC_PMU_RANGE = 0x0F,
|
||||
BMX055_ACC_PMU_BW = 0x10,
|
||||
BMX055_ACC_PMU_LPW = 0x11,
|
||||
BMX055_ACC_PMU_LOW_POWER = 0x12,
|
||||
BMX055_ACC_D_HBW = 0x13,
|
||||
BMX055_ACC_BGW_SOFTRESET = 0x14,
|
||||
BMX055_ACC_INT_EN_0 = 0x16,
|
||||
BMX055_ACC_INT_EN_1 = 0x17,
|
||||
BMX055_ACC_INT_EN_2 = 0x18,
|
||||
BMX055_ACC_INT_MAP_0 = 0x19,
|
||||
BMX055_ACC_INT_MAP_1 = 0x1A,
|
||||
BMX055_ACC_INT_MAP_2 = 0x1B,
|
||||
BMX055_ACC_INT_SRC = 0x1E,
|
||||
BMX055_ACC_INT_OUT_CTRL = 0x20,
|
||||
BMX055_ACC_INT_RST_LATCH = 0x21,
|
||||
BMX055_ACC_INT_0 = 0x22,
|
||||
BMX055_ACC_INT_1 = 0x23,
|
||||
BMX055_ACC_INT_2 = 0x24,
|
||||
BMX055_ACC_INT_3 = 0x25,
|
||||
BMX055_ACC_INT_4 = 0x26,
|
||||
BMX055_ACC_INT_5 = 0x27,
|
||||
BMX055_ACC_INT_6 = 0x28,
|
||||
BMX055_ACC_INT_7 = 0x29,
|
||||
BMX055_ACC_INT_8 = 0x2A,
|
||||
BMX055_ACC_INT_9 = 0x2B,
|
||||
BMX055_ACC_INT_A = 0x2C,
|
||||
BMX055_ACC_INT_B = 0x2D,
|
||||
BMX055_ACC_INT_C = 0x2E,
|
||||
BMX055_ACC_INT_D = 0x2F,
|
||||
BMX055_ACC_FIFO_CONFIG_0 = 0x30,
|
||||
BMX055_ACC_PMU_SELF_TEST = 0x32,
|
||||
BMX055_ACC_TRIM_NVM_CTRL = 0x33,
|
||||
BMX055_ACC_BGW_SPI3_WDT = 0x34,
|
||||
BMX055_ACC_OFC_CTRL = 0x36,
|
||||
BMX055_ACC_OFC_SETTING = 0x37,
|
||||
BMX055_ACC_OFC_OFFSET_X = 0x38,
|
||||
BMX055_ACC_OFC_OFFSET_Y = 0x39,
|
||||
BMX055_ACC_OFC_OFFSET_Z = 0x3A,
|
||||
BMX055_ACC_TRIM_GPO = 0x3B,
|
||||
BMX055_ACC_TRIM_GP1 = 0x3C,
|
||||
BMX055_ACC_FIFO_CONFIG_1 = 0x3E,
|
||||
BMX055_ACC_FIFO_DATA = 0x3F,
|
||||
BMX055_GYRO_WHOAMI = 0x00,
|
||||
BMX055_GYRO_RATE_X_LSB = 0x02,
|
||||
BMX055_GYRO_RATE_X_MSB = 0x03,
|
||||
BMX055_GYRO_RATE_Y_LSB = 0x04,
|
||||
BMX055_GYRO_RATE_Y_MSB = 0x05,
|
||||
BMX055_GYRO_RATE_Z_LSB = 0x06,
|
||||
BMX055_GYRO_RATE_Z_MSB = 0x07,
|
||||
BMX055_GYRO_INT_STATUS_0 = 0x09,
|
||||
BMX055_GYRO_INT_STATUS_1 = 0x0A,
|
||||
BMX055_GYRO_INT_STATUS_2 = 0x0B,
|
||||
BMX055_GYRO_INT_STATUS_3 = 0x0C,
|
||||
BMX055_GYRO_FIFO_STATUS = 0x0E,
|
||||
BMX055_GYRO_RANGE = 0x0F,
|
||||
BMX055_GYRO_BW = 0x10,
|
||||
BMX055_GYRO_LPM1 = 0x11,
|
||||
BMX055_GYRO_LPM2 = 0x12,
|
||||
BMX055_GYRO_RATE_HBW = 0x13,
|
||||
BMX055_GYRO_BGW_SOFTRESET = 0x14,
|
||||
BMX055_GYRO_INT_EN_0 = 0x15,
|
||||
BMX055_GYRO_INT_EN_1 = 0x16,
|
||||
BMX055_GYRO_INT_MAP_0 = 0x17,
|
||||
BMX055_GYRO_INT_MAP_1 = 0x18,
|
||||
BMX055_GYRO_INT_MAP_2 = 0x19,
|
||||
BMX055_GYRO_INT_SRC_1 = 0x1A,
|
||||
BMX055_GYRO_INT_SRC_2 = 0x1B,
|
||||
BMX055_GYRO_INT_SRC_3 = 0x1C,
|
||||
BMX055_GYRO_FIFO_EN = 0x1E,
|
||||
BMX055_GYRO_INT_RST_LATCH = 0x21,
|
||||
BMX055_GYRO_HIGH_TH_X = 0x22,
|
||||
BMX055_GYRO_HIGH_DUR_X = 0x23,
|
||||
BMX055_GYRO_HIGH_TH_Y = 0x24,
|
||||
BMX055_GYRO_HIGH_DUR_Y = 0x25,
|
||||
BMX055_GYRO_HIGH_TH_Z = 0x26,
|
||||
BMX055_GYRO_HIGH_DUR_Z = 0x27,
|
||||
BMX055_GYRO_SOC = 0x31,
|
||||
BMX055_GYRO_A_FOC = 0x32,
|
||||
BMX055_GYRO_TRIM_NVM_CTRL = 0x33,
|
||||
BMX055_GYRO_BGW_SPI3_WDT = 0x34,
|
||||
BMX055_GYRO_OFC1 = 0x36,
|
||||
BMX055_GYRO_OFC2 = 0x37,
|
||||
BMX055_GYRO_OFC3 = 0x38,
|
||||
BMX055_GYRO_OFC4 = 0x39,
|
||||
BMX055_GYRO_TRIM_GP0 = 0x3A,
|
||||
BMX055_GYRO_TRIM_GP1 = 0x3B,
|
||||
BMX055_GYRO_BIST = 0x3C,
|
||||
BMX055_GYRO_FIFO_CONFIG_0 = 0x3D,
|
||||
BMX055_GYRO_FIFO_CONFIG_1 = 0x3E,
|
||||
BMX055_MAG_WHOAMI = 0x40,
|
||||
BMX055_MAG_Reserved = 0x41,
|
||||
BMX055_MAG_XOUT_LSB = 0x42,
|
||||
BMX055_MAG_XOUT_MSB = 0x43,
|
||||
BMX055_MAG_YOUT_LSB = 0x44,
|
||||
BMX055_MAG_YOUT_MSB = 0x45,
|
||||
BMX055_MAG_ZOUT_LSB = 0x46,
|
||||
BMX055_MAG_ZOUT_MSB = 0x47,
|
||||
BMX055_MAG_ROUT_LSB = 0x48,
|
||||
BMX055_MAG_ROUT_MSB = 0x49,
|
||||
BMX055_MAG_INT_STATUS = 0x4A,
|
||||
BMX055_MAG_PWR_CNTL1 = 0x4B,
|
||||
BMX055_MAG_PWR_CNTL2 = 0x4C,
|
||||
BMX055_MAG_INT_EN_1 = 0x4D,
|
||||
BMX055_MAG_INT_EN_2 = 0x4E,
|
||||
BMX055_MAG_LOW_THS = 0x4F,
|
||||
BMX055_MAG_HIGH_THS = 0x50,
|
||||
BMX055_MAG_REP_XY = 0x51,
|
||||
BMX055_MAG_REP_Z = 0x52,
|
||||
BMM050_DIG_X1 = 0x5D,
|
||||
BMM050_DIG_Y1 = 0x5E,
|
||||
BMM050_DIG_Z4_LSB = 0x62,
|
||||
BMM050_DIG_Z4_MSB = 0x63,
|
||||
BMM050_DIG_X2 = 0x64,
|
||||
BMM050_DIG_Y2 = 0x65,
|
||||
BMM050_DIG_Z2_LSB = 0x68,
|
||||
BMM050_DIG_Z2_MSB = 0x69,
|
||||
BMM050_DIG_Z1_LSB = 0x6A,
|
||||
BMM050_DIG_Z1_MSB = 0x6B,
|
||||
BMM050_DIG_XYZ1_LSB = 0x6C,
|
||||
BMM050_DIG_XYZ1_MSB = 0x6D,
|
||||
BMM050_DIG_Z3_LSB = 0x6E,
|
||||
BMM050_DIG_Z3_MSB = 0x6F,
|
||||
BMM050_DIG_XY2 = 0x70,
|
||||
BMM050_DIG_XY1 = 0x71,
|
||||
BMX055_ACC_ADDRESS = 0x18,
|
||||
BMX055_GYRO_ADDRESS = 0x68,
|
||||
BMX055_MAG_ADDRESS = 0x10,
|
||||
MS5637_ADDRESS = 0x76,
|
||||
AFS_2G = 0x03,
|
||||
AFS_4G = 0x05,
|
||||
AFS_8G = 0x08,
|
||||
AFS_16G = 0x0C,
|
||||
ABW_8Hz = 0,
|
||||
ABW_16Hz = 1,
|
||||
ABW_31Hz = 2,
|
||||
ABW_63Hz = 3,
|
||||
ABW_125Hz = 4,
|
||||
ABW_250Hz = 5,
|
||||
ABW_500Hz = 6,
|
||||
ABW_100Hz = 7,
|
||||
GFS_2000DPS = 0,
|
||||
GFS_1000DPS = 1,
|
||||
GFS_500DPS = 2,
|
||||
GFS_250DPS = 3,
|
||||
GFS_125DPS = 4,
|
||||
G_2000Hz523Hz = 0,
|
||||
G_2000Hz230Hz = 1,
|
||||
G_1000Hz116Hz = 2,
|
||||
G_400Hz47Hz = 3,
|
||||
G_200Hz23Hz = 4,
|
||||
G_100Hz12Hz = 5,
|
||||
G_200Hz64Hz = 6,
|
||||
G_100Hz32Hz = 7,
|
||||
MODR_10Hz = 0,
|
||||
MODR_2Hz = 1,
|
||||
MODR_6Hz = 2,
|
||||
MODR_8Hz = 3,
|
||||
MODR_15Hz = 4,
|
||||
MODR_20Hz = 5,
|
||||
MODR_25Hz = 6,
|
||||
MODR_30Hz = 7,
|
||||
lowPower = 0,
|
||||
Regular = 1,
|
||||
enhancedRegular = 2,
|
||||
highAccuracy = 3,
|
||||
ADC_256 = 0x00,
|
||||
ADC_512 = 0x02,
|
||||
ADC_1024 = 0x04,
|
||||
ADC_2048 = 0x06,
|
||||
ADC_4096 = 0x08,
|
||||
ADC_8192 = 0x0A,
|
||||
ADC_D1 = 0x40,
|
||||
ADC_D2 = 0x50,
|
||||
MICROBIT_ACCEL_PITCH_ROLL_VALID = 0x02,
|
||||
MICROBIT_ACCEL_ADDED_TO_IDLE = 0x04,
|
||||
MMA8653_STATUS = 0x00,
|
||||
MMA8653_OUT_X_MSB = 0x01,
|
||||
MMA8653_WHOAMI = 0x0D,
|
||||
MMA8653_XYZ_DATA_CFG = 0x0E,
|
||||
MMA8653_CTRL_REG1 = 0x2A,
|
||||
MMA8653_CTRL_REG2 = 0x2B,
|
||||
MMA8653_CTRL_REG3 = 0x2C,
|
||||
MMA8653_CTRL_REG4 = 0x2D,
|
||||
MMA8653_CTRL_REG5 = 0x2E,
|
||||
MMA8653_WHOAMI_VAL = 0x5A,
|
||||
MMA8653_SAMPLE_RANGES = 3,
|
||||
MMA8653_SAMPLE_RATES = 8,
|
||||
MICROBIT_ACCELEROMETER_EVT_DATA_UPDATE = 1,
|
||||
MICROBIT_ACCELEROMETER_EVT_NONE = 0,
|
||||
MICROBIT_ACCELEROMETER_EVT_TILT_UP = 1,
|
||||
MICROBIT_ACCELEROMETER_EVT_TILT_DOWN = 2,
|
||||
MICROBIT_ACCELEROMETER_EVT_TILT_LEFT = 3,
|
||||
MICROBIT_ACCELEROMETER_EVT_TILT_RIGHT = 4,
|
||||
MICROBIT_ACCELEROMETER_EVT_FACE_UP = 5,
|
||||
MICROBIT_ACCELEROMETER_EVT_FACE_DOWN = 6,
|
||||
MICROBIT_ACCELEROMETER_EVT_FREEFALL = 7,
|
||||
MICROBIT_ACCELEROMETER_EVT_3G = 8,
|
||||
MICROBIT_ACCELEROMETER_EVT_6G = 9,
|
||||
MICROBIT_ACCELEROMETER_EVT_8G = 10,
|
||||
MICROBIT_ACCELEROMETER_EVT_SHAKE = 11,
|
||||
MICROBIT_ACCELEROMETER_REST_TOLERANCE = 200,
|
||||
MICROBIT_ACCELEROMETER_TILT_TOLERANCE = 200,
|
||||
MICROBIT_ACCELEROMETER_FREEFALL_TOLERANCE = 400,
|
||||
MICROBIT_ACCELEROMETER_SHAKE_TOLERANCE = 400,
|
||||
MICROBIT_ACCELEROMETER_3G_TOLERANCE = 3072,
|
||||
MICROBIT_ACCELEROMETER_6G_TOLERANCE = 6144,
|
||||
MICROBIT_ACCELEROMETER_8G_TOLERANCE = 8192,
|
||||
MICROBIT_ACCELEROMETER_GESTURE_DAMPING = 5,
|
||||
MICROBIT_ACCELEROMETER_SHAKE_DAMPING = 10,
|
||||
MICROBIT_ACCELEROMETER_SHAKE_RTX = 30,
|
||||
MICROBIT_ACCELEROMETER_SHAKE_COUNT_THRESHOLD = 4,
|
||||
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitAccelerometer.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitButton.h
|
||||
MICROBIT_BUTTON_EVT_DOWN = 1,
|
||||
MICROBIT_BUTTON_EVT_UP = 2,
|
||||
MICROBIT_BUTTON_EVT_CLICK = 3,
|
||||
MICROBIT_BUTTON_EVT_LONG_CLICK = 4,
|
||||
MICROBIT_BUTTON_EVT_HOLD = 5,
|
||||
MICROBIT_BUTTON_EVT_DOUBLE_CLICK = 6,
|
||||
MICROBIT_BUTTON_LONG_CLICK_TIME = 1000,
|
||||
MICROBIT_BUTTON_HOLD_TIME = 1500,
|
||||
MICROBIT_BUTTON_STATE = 1,
|
||||
MICROBIT_BUTTON_STATE_HOLD_TRIGGERED = 2,
|
||||
MICROBIT_BUTTON_STATE_CLICK = 4,
|
||||
MICROBIT_BUTTON_STATE_LONG_CLICK = 8,
|
||||
MICROBIT_BUTTON_SIGMA_MIN = 0,
|
||||
MICROBIT_BUTTON_SIGMA_MAX = 12,
|
||||
MICROBIT_BUTTON_SIGMA_THRESH_HI = 8,
|
||||
MICROBIT_BUTTON_SIGMA_THRESH_LO = 2,
|
||||
MICROBIT_BUTTON_DOUBLE_CLICK_THRESH = 50,
|
||||
MICROBIT_BUTTON_SIMPLE_EVENTS = 0,
|
||||
MICROBIT_BUTTON_ALL_EVENTS = 1,
|
||||
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitCompass.h
|
||||
MAG3110_DEFAULT_ADDR = 0x1D,
|
||||
MAG_DR_STATUS = 0x00,
|
||||
MAG_OUT_X_MSB = 0x01,
|
||||
MAG_OUT_X_LSB = 0x02,
|
||||
MAG_OUT_Y_MSB = 0x03,
|
||||
MAG_OUT_Y_LSB = 0x04,
|
||||
MAG_OUT_Z_MSB = 0x05,
|
||||
MAG_OUT_Z_LSB = 0x06,
|
||||
MAG_WHOAMI = 0x07,
|
||||
MAG_SYSMOD = 0x08,
|
||||
MAG_OFF_X_MSB = 0x09,
|
||||
MAG_OFF_X_LSB = 0x0A,
|
||||
MAG_OFF_Y_MSB = 0x0B,
|
||||
MAG_OFF_Y_LSB = 0x0C,
|
||||
MAG_OFF_Z_MSB = 0x0D,
|
||||
MAG_OFF_Z_LSB = 0x0E,
|
||||
MAG_DIE_TEMP = 0x0F,
|
||||
MAG_CTRL_REG1 = 0x10,
|
||||
MAG_CTRL_REG2 = 0x11,
|
||||
MAG3110_SAMPLE_RATES = 11,
|
||||
MICROBIT_COMPASS_EVT_CAL_REQUIRED = 1,
|
||||
MICROBIT_COMPASS_EVT_CAL_START = 2,
|
||||
MICROBIT_COMPASS_EVT_CAL_END = 3,
|
||||
MICROBIT_COMPASS_EVT_DATA_UPDATE = 4,
|
||||
MICROBIT_COMPASS_EVT_CONFIG_NEEDED = 5,
|
||||
MICROBIT_COMPASS_EVT_CALIBRATE = 6,
|
||||
MICROBIT_COMPASS_STATUS_CALIBRATED = 2,
|
||||
MICROBIT_COMPASS_STATUS_CALIBRATING = 4,
|
||||
MICROBIT_COMPASS_STATUS_ADDED_TO_IDLE = 8,
|
||||
MAG3110_WHOAMI_VAL = 0xC4,
|
||||
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitCompassCalibrator.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitDisplay.h
|
||||
MICROBIT_DISPLAY_EVT_ANIMATION_COMPLETE = 1,
|
||||
MICROBIT_DISPLAY_EVT_LIGHT_SENSE = 2,
|
||||
MICROBIT_DISPLAY_DEFAULT_AUTOCLEAR = 1,
|
||||
MICROBIT_DISPLAY_SPACING = 1,
|
||||
MICROBIT_DISPLAY_GREYSCALE_BIT_DEPTH = 8,
|
||||
MICROBIT_DISPLAY_ANIMATE_DEFAULT_POS = -255,
|
||||
ANIMATION_MODE_NONE = 0,
|
||||
ANIMATION_MODE_STOPPED = 1,
|
||||
ANIMATION_MODE_SCROLL_TEXT = 2,
|
||||
ANIMATION_MODE_PRINT_TEXT = 3,
|
||||
ANIMATION_MODE_SCROLL_IMAGE = 4,
|
||||
ANIMATION_MODE_ANIMATE_IMAGE = 5,
|
||||
ANIMATION_MODE_ANIMATE_IMAGE_WITH_CLEAR = 6,
|
||||
ANIMATION_MODE_PRINT_CHARACTER = 7,
|
||||
DISPLAY_MODE_BLACK_AND_WHITE = 0,
|
||||
DISPLAY_MODE_GREYSCALE = 1,
|
||||
DISPLAY_MODE_BLACK_AND_WHITE_LIGHT_SENSE = 2,
|
||||
MICROBIT_DISPLAY_ROTATION_0 = 0,
|
||||
MICROBIT_DISPLAY_ROTATION_90 = 1,
|
||||
MICROBIT_DISPLAY_ROTATION_180 = 2,
|
||||
MICROBIT_DISPLAY_ROTATION_270 = 3,
|
||||
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitI2C.h
|
||||
MICROBIT_I2C_MAX_RETRIES = 9,
|
||||
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitIO.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitLightSensor.h
|
||||
MICROBIT_LIGHT_SENSOR_CHAN_NUM = 3,
|
||||
MICROBIT_LIGHT_SENSOR_AN_SET_TIME = 4000,
|
||||
MICROBIT_LIGHT_SENSOR_TICK_PERIOD = 5,
|
||||
MICROBIT_LIGHT_SENSOR_MAX_VALUE = 338,
|
||||
MICROBIT_LIGHT_SENSOR_MIN_VALUE = 75,
|
||||
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitMatrixMaps.h
|
||||
NO_CONN = 0,
|
||||
MICROBIT_DISPLAY_WIDTH = 5,
|
||||
MICROBIT_DISPLAY_HEIGHT = 5,
|
||||
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitMessageBus.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitMultiButton.h
|
||||
MICROBIT_MULTI_BUTTON_STATE_1 = 0x01,
|
||||
MICROBIT_MULTI_BUTTON_STATE_2 = 0x02,
|
||||
MICROBIT_MULTI_BUTTON_HOLD_TRIGGERED_1 = 0x04,
|
||||
MICROBIT_MULTI_BUTTON_HOLD_TRIGGERED_2 = 0x08,
|
||||
MICROBIT_MULTI_BUTTON_SUPRESSED_1 = 0X10,
|
||||
MICROBIT_MULTI_BUTTON_SUPRESSED_2 = 0x20,
|
||||
MICROBIT_MULTI_BUTTON_ATTACHED = 0x40,
|
||||
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitPin.h
|
||||
IO_STATUS_DIGITAL_IN = 0x01,
|
||||
IO_STATUS_DIGITAL_OUT = 0x02,
|
||||
IO_STATUS_ANALOG_IN = 0x04,
|
||||
IO_STATUS_ANALOG_OUT = 0x08,
|
||||
IO_STATUS_TOUCH_IN = 0x10,
|
||||
IO_STATUS_EVENT_ON_EDGE = 0x20,
|
||||
IO_STATUS_EVENT_PULSE_ON_EDGE = 0x40,
|
||||
IO_STATUS_EVENTBUS_ENABLED = 0x80,
|
||||
MICROBIT_PIN_MAX_OUTPUT = 1023,
|
||||
MICROBIT_PIN_MAX_SERVO_RANGE = 180,
|
||||
MICROBIT_PIN_DEFAULT_SERVO_RANGE = 2000,
|
||||
MICROBIT_PIN_DEFAULT_SERVO_CENTER = 1500,
|
||||
MICROBIT_PIN_EVENT_NONE = 0,
|
||||
MICROBIT_PIN_EVENT_ON_EDGE = 1,
|
||||
MICROBIT_PIN_EVENT_ON_PULSE = 2,
|
||||
MICROBIT_PIN_EVENT_ON_TOUCH = 3,
|
||||
MICROBIT_PIN_EVT_RISE = 2,
|
||||
MICROBIT_PIN_EVT_FALL = 3,
|
||||
MICROBIT_PIN_EVT_PULSE_HI = 4,
|
||||
MICROBIT_PIN_EVT_PULSE_LO = 5,
|
||||
PIN_CAPABILITY_DIGITAL = 0x01,
|
||||
PIN_CAPABILITY_ANALOG = 0x02,
|
||||
PIN_CAPABILITY_TOUCH = 0x04,
|
||||
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitRadio.h
|
||||
MICROBIT_RADIO_STATUS_INITIALISED = 0x0001,
|
||||
MICROBIT_RADIO_BASE_ADDRESS = 0x75626974,
|
||||
MICROBIT_RADIO_DEFAULT_GROUP = 0,
|
||||
MICROBIT_RADIO_DEFAULT_TX_POWER = 6,
|
||||
MICROBIT_RADIO_DEFAULT_FREQUENCY = 7,
|
||||
MICROBIT_RADIO_MAX_PACKET_SIZE = 32,
|
||||
MICROBIT_RADIO_HEADER_SIZE = 4,
|
||||
MICROBIT_RADIO_MAXIMUM_RX_BUFFERS = 4,
|
||||
MICROBIT_RADIO_PROTOCOL_DATAGRAM = 1,
|
||||
MICROBIT_RADIO_PROTOCOL_EVENTBUS = 2,
|
||||
MICROBIT_RADIO_EVT_DATAGRAM = 1,
|
||||
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitRadioDatagram.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitRadioEvent.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitSerial.h
|
||||
MICROBIT_SERIAL_DEFAULT_BAUD_RATE = 115200,
|
||||
MICROBIT_SERIAL_DEFAULT_BUFFER_SIZE = 20,
|
||||
MICROBIT_SERIAL_EVT_DELIM_MATCH = 1,
|
||||
MICROBIT_SERIAL_EVT_HEAD_MATCH = 2,
|
||||
MICROBIT_SERIAL_EVT_RX_FULL = 3,
|
||||
MICROBIT_SERIAL_RX_IN_USE = 1,
|
||||
MICROBIT_SERIAL_TX_IN_USE = 2,
|
||||
MICROBIT_SERIAL_RX_BUFF_INIT = 4,
|
||||
MICROBIT_SERIAL_TX_BUFF_INIT = 8,
|
||||
ASYNC = 0,
|
||||
SYNC_SPINWAIT = 1,
|
||||
SYNC_SLEEP = 2,
|
||||
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitStorage.h
|
||||
MICROBIT_STORAGE_MAGIC = 0xCAFE,
|
||||
MICROBIT_STORAGE_BLOCK_SIZE = 48,
|
||||
MICROBIT_STORAGE_KEY_SIZE = 16,
|
||||
MICROBIT_STORAGE_STORE_PAGE_OFFSET = 17,
|
||||
MICROBIT_STORAGE_SCRATCH_PAGE_OFFSET = 19,
|
||||
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitThermometer.h
|
||||
MICROBIT_THERMOMETER_PERIOD = 1000,
|
||||
MICROBIT_THERMOMETER_EVT_UPDATE = 1,
|
||||
MICROBIT_THERMOMETER_ADDED_TO_IDLE = 2,
|
||||
// built/yt/yotta_modules/microbit-dal/inc//drivers/TimedInterruptIn.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc//platform/yotta_cfg_mappings.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc//types/ManagedString.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc//types/ManagedType.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc//types/Matrix4.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc//types/MicroBitCoordinateSystem.h
|
||||
RAW = 0,
|
||||
SIMPLE_CARTESIAN = 1,
|
||||
NORTH_EAST_DOWN = 2,
|
||||
// built/yt/yotta_modules/microbit-dal/inc//types/MicroBitEvent.h
|
||||
MICROBIT_ID_ANY = 0,
|
||||
MICROBIT_EVT_ANY = 0,
|
||||
CREATE_ONLY = 0,
|
||||
CREATE_AND_FIRE = 1,
|
||||
// built/yt/yotta_modules/microbit-dal/inc//types/MicroBitImage.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc//types/PacketBuffer.h
|
||||
// built/yt/yotta_modules/microbit-dal/inc//types/RefCounted.h
|
||||
}
|
330
libs/microbit/enums.d.ts
vendored
330
libs/microbit/enums.d.ts
vendored
@ -1,330 +0,0 @@
|
||||
// Auto-generated. Do not edit.
|
||||
declare namespace images {
|
||||
}
|
||||
declare namespace basic {
|
||||
}
|
||||
|
||||
|
||||
declare enum Button {
|
||||
A = 1, // MICROBIT_ID_BUTTON_A
|
||||
B = 2, // MICROBIT_ID_BUTTON_B
|
||||
//% block="A+B"
|
||||
AB = 26, // MICROBIT_ID_BUTTON_AB
|
||||
}
|
||||
|
||||
|
||||
declare enum Dimension {
|
||||
//% block=x
|
||||
X = 0,
|
||||
//% block=y
|
||||
Y = 1,
|
||||
//% block=z
|
||||
Z = 2,
|
||||
//% block=strength
|
||||
Strength = 3,
|
||||
}
|
||||
|
||||
|
||||
declare enum Rotation {
|
||||
//% block=pitch
|
||||
Pitch = 0,
|
||||
//% block=roll
|
||||
Roll = 1,
|
||||
}
|
||||
|
||||
|
||||
declare enum TouchPin {
|
||||
P0 = 7, // MICROBIT_ID_IO_P0
|
||||
P1 = 8, // MICROBIT_ID_IO_P1
|
||||
P2 = 9, // MICROBIT_ID_IO_P2
|
||||
}
|
||||
|
||||
|
||||
declare enum AcceleratorRange {
|
||||
/**
|
||||
* The accelerator measures forces up to 1 gravity
|
||||
*/
|
||||
//% block="1g"
|
||||
OneG = 1,
|
||||
/**
|
||||
* The accelerator measures forces up to 2 gravity
|
||||
*/
|
||||
//% block="2g"
|
||||
TwoG = 2,
|
||||
/**
|
||||
* The accelerator measures forces up to 4 gravity
|
||||
*/
|
||||
//% block="4g"
|
||||
FourG = 4,
|
||||
/**
|
||||
* The accelerator measures forces up to 8 gravity
|
||||
*/
|
||||
//% block="8g"
|
||||
EightG = 8,
|
||||
}
|
||||
|
||||
|
||||
declare enum Gesture {
|
||||
/**
|
||||
* Raised when shaken
|
||||
*/
|
||||
//% block=shake
|
||||
Shake = 11, // MICROBIT_ACCELEROMETER_EVT_SHAKE
|
||||
/**
|
||||
* Raised when the logo is upward and the screen is vertical
|
||||
*/
|
||||
//% block="logo up"
|
||||
LogoUp = 1, // MICROBIT_ACCELEROMETER_EVT_TILT_UP
|
||||
/**
|
||||
* Raised when the logo is downward and the screen is vertical
|
||||
*/
|
||||
//% block="logo down"
|
||||
LogoDown = 2, // MICROBIT_ACCELEROMETER_EVT_TILT_DOWN
|
||||
/**
|
||||
* Raised when the screen is pointing down and the board is horizontal
|
||||
*/
|
||||
//% block="screen up"
|
||||
ScreenUp = 5, // MICROBIT_ACCELEROMETER_EVT_FACE_UP
|
||||
/**
|
||||
* Raised when the screen is pointing up and the board is horizontal
|
||||
*/
|
||||
//% block="screen down"
|
||||
ScreenDown = 6, // MICROBIT_ACCELEROMETER_EVT_FACE_DOWN
|
||||
/**
|
||||
* Raised when the screen is pointing left
|
||||
*/
|
||||
//% block="tilt left"
|
||||
TiltLeft = 3, // MICROBIT_ACCELEROMETER_EVT_TILT_LEFT
|
||||
/**
|
||||
* Raised when the screen is pointing right
|
||||
*/
|
||||
//% block="tilt right"
|
||||
TiltRight = 4, // MICROBIT_ACCELEROMETER_EVT_TILT_RIGHT
|
||||
/**
|
||||
* Raised when the board is falling!
|
||||
*/
|
||||
//% block="free fall"
|
||||
FreeFall = 7, // MICROBIT_ACCELEROMETER_EVT_FREEFALL
|
||||
/**
|
||||
* Raised when a 3G shock is detected
|
||||
*/
|
||||
//% block="3g"
|
||||
ThreeG = 8, // MICROBIT_ACCELEROMETER_EVT_3G
|
||||
/**
|
||||
* Raised when a 6G shock is detected
|
||||
*/
|
||||
//% block="6g"
|
||||
SixG = 9, // MICROBIT_ACCELEROMETER_EVT_6G
|
||||
}
|
||||
declare namespace input {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* How to create the event.
|
||||
*/
|
||||
|
||||
declare enum EventCreationMode {
|
||||
/**
|
||||
* MicroBitEvent is initialised, and no further processing takes place.
|
||||
*/
|
||||
CreateOnly = 0, // CREATE_ONLY
|
||||
/**
|
||||
* MicroBitEvent is initialised, and its event handlers are immediately fired (not suitable for use in interrupts!).
|
||||
*/
|
||||
CreateAndFire = 1, // CREATE_AND_FIRE
|
||||
}
|
||||
|
||||
|
||||
declare enum EventBusSource {
|
||||
MICROBIT_ID_BUTTON_A = 1, // MICROBIT_ID_BUTTON_A
|
||||
MICROBIT_ID_BUTTON_B = 2, // MICROBIT_ID_BUTTON_B
|
||||
MICROBIT_ID_BUTTON_AB = 26, // MICROBIT_ID_BUTTON_AB
|
||||
MICROBIT_ID_RADIO = 29, // MICROBIT_ID_RADIO
|
||||
MICROBIT_ID_GESTURE = 27, // MICROBIT_ID_GESTURE
|
||||
MICROBIT_ID_ACCELEROMETER = 4, // MICROBIT_ID_ACCELEROMETER
|
||||
MICROBIT_ID_IO_P0 = 7, // MICROBIT_ID_IO_P0
|
||||
MICROBIT_ID_IO_P1 = 8, // MICROBIT_ID_IO_P1
|
||||
MICROBIT_ID_IO_P2 = 9, // MICROBIT_ID_IO_P2
|
||||
MICROBIT_ID_IO_P3 = 10, // MICROBIT_ID_IO_P3
|
||||
MICROBIT_ID_IO_P4 = 11, // MICROBIT_ID_IO_P4
|
||||
MICROBIT_ID_IO_P5 = 12, // MICROBIT_ID_IO_P5
|
||||
MICROBIT_ID_IO_P6 = 13, // MICROBIT_ID_IO_P6
|
||||
MICROBIT_ID_IO_P7 = 14, // MICROBIT_ID_IO_P7
|
||||
//MICROBIT_ID_IO_P8_ = MICROBIT_ID_IO_P8,
|
||||
MICROBIT_ID_IO_P9 = 16, // MICROBIT_ID_IO_P9
|
||||
MICROBIT_ID_IO_P10 = 17, // MICROBIT_ID_IO_P10
|
||||
MICROBIT_ID_IO_P11 = 18, // MICROBIT_ID_IO_P11
|
||||
//MICROBIT_ID_IO_P12_ = MICROBIT_ID_IO_P12,
|
||||
//MICROBIT_ID_IO_P13_ = MICROBIT_ID_IO_P13,
|
||||
//MICROBIT_ID_IO_P14_ = MICROBIT_ID_IO_P14,
|
||||
//MICROBIT_ID_IO_P15_ = MICROBIT_ID_IO_P15,
|
||||
//MICROBIT_ID_IO_P16_ = MICROBIT_ID_IO_P16,
|
||||
MICROBIT_ID_IO_P19 = 24, // MICROBIT_ID_IO_P19
|
||||
MICROBIT_ID_IO_P20 = 25, // MICROBIT_ID_IO_P20
|
||||
MES_DEVICE_INFO_ID = 1103, // MES_DEVICE_INFO_ID
|
||||
MES_SIGNAL_STRENGTH_ID = 1101, // MES_SIGNAL_STRENGTH_ID
|
||||
MES_DPAD_CONTROLLER_ID = 1104, // MES_DPAD_CONTROLLER_ID
|
||||
MES_BROADCAST_GENERAL_ID = 2000, // MES_BROADCAST_GENERAL_ID
|
||||
}
|
||||
|
||||
|
||||
declare enum EventBusValue {
|
||||
MICROBIT_EVT_ANY = 0, // MICROBIT_EVT_ANY
|
||||
MICROBIT_BUTTON_EVT_CLICK = 3, // MICROBIT_BUTTON_EVT_CLICK
|
||||
MICROBIT_RADIO_EVT_DATAGRAM = 1, // MICROBIT_RADIO_EVT_DATAGRAM
|
||||
MICROBIT_ACCELEROMETER_EVT_DATA_UPDATE = 1, // MICROBIT_ACCELEROMETER_EVT_DATA_UPDATE
|
||||
MES_ALERT_EVT_ALARM1 = 6, // MES_ALERT_EVT_ALARM1
|
||||
MES_ALERT_EVT_ALARM2 = 7, // MES_ALERT_EVT_ALARM2
|
||||
MES_ALERT_EVT_ALARM3 = 8, // MES_ALERT_EVT_ALARM3
|
||||
MES_ALERT_EVT_ALARM4 = 9, // MES_ALERT_EVT_ALARM4
|
||||
MES_ALERT_EVT_ALARM5 = 10, // MES_ALERT_EVT_ALARM5
|
||||
MES_ALERT_EVT_ALARM6 = 11, // MES_ALERT_EVT_ALARM6
|
||||
MES_ALERT_EVT_DISPLAY_TOAST = 1, // MES_ALERT_EVT_DISPLAY_TOAST
|
||||
MES_ALERT_EVT_FIND_MY_PHONE = 5, // MES_ALERT_EVT_FIND_MY_PHONE
|
||||
MES_ALERT_EVT_PLAY_RINGTONE = 4, // MES_ALERT_EVT_PLAY_RINGTONE
|
||||
MES_ALERT_EVT_PLAY_SOUND = 3, // MES_ALERT_EVT_PLAY_SOUND
|
||||
MES_ALERT_EVT_VIBRATE = 2, // MES_ALERT_EVT_VIBRATE
|
||||
MES_CAMERA_EVT_LAUNCH_PHOTO_MODE = 1, // MES_CAMERA_EVT_LAUNCH_PHOTO_MODE
|
||||
MES_CAMERA_EVT_LAUNCH_VIDEO_MODE = 2, // MES_CAMERA_EVT_LAUNCH_VIDEO_MODE
|
||||
MES_CAMERA_EVT_START_VIDEO_CAPTURE = 4, // MES_CAMERA_EVT_START_VIDEO_CAPTURE
|
||||
MES_CAMERA_EVT_STOP_PHOTO_MODE = 6, // MES_CAMERA_EVT_STOP_PHOTO_MODE
|
||||
MES_CAMERA_EVT_STOP_VIDEO_CAPTURE = 5, // MES_CAMERA_EVT_STOP_VIDEO_CAPTURE
|
||||
MES_CAMERA_EVT_STOP_VIDEO_MODE = 7, // MES_CAMERA_EVT_STOP_VIDEO_MODE
|
||||
MES_CAMERA_EVT_TAKE_PHOTO = 3, // MES_CAMERA_EVT_TAKE_PHOTO
|
||||
MES_CAMERA_EVT_TOGGLE_FRONT_REAR = 8, // MES_CAMERA_EVT_TOGGLE_FRONT_REAR
|
||||
MES_DEVICE_DISPLAY_OFF = 5, // MES_DEVICE_DISPLAY_OFF
|
||||
MES_DEVICE_DISPLAY_ON = 6, // MES_DEVICE_DISPLAY_ON
|
||||
MES_DEVICE_GESTURE_DEVICE_SHAKEN = 4, // MES_DEVICE_GESTURE_DEVICE_SHAKEN
|
||||
MES_DEVICE_INCOMING_CALL = 7, // MES_DEVICE_INCOMING_CALL
|
||||
MES_DEVICE_INCOMING_MESSAGE = 8, // MES_DEVICE_INCOMING_MESSAGE
|
||||
MES_DEVICE_ORIENTATION_LANDSCAPE = 1, // MES_DEVICE_ORIENTATION_LANDSCAPE
|
||||
MES_DEVICE_ORIENTATION_PORTRAIT = 2, // MES_DEVICE_ORIENTATION_PORTRAIT
|
||||
MES_DPAD_BUTTON_1_DOWN = 9, // MES_DPAD_BUTTON_1_DOWN
|
||||
MES_DPAD_BUTTON_1_UP = 10, // MES_DPAD_BUTTON_1_UP
|
||||
MES_DPAD_BUTTON_2_DOWN = 11, // MES_DPAD_BUTTON_2_DOWN
|
||||
MES_DPAD_BUTTON_2_UP = 12, // MES_DPAD_BUTTON_2_UP
|
||||
MES_DPAD_BUTTON_3_DOWN = 13, // MES_DPAD_BUTTON_3_DOWN
|
||||
MES_DPAD_BUTTON_3_UP = 14, // MES_DPAD_BUTTON_3_UP
|
||||
MES_DPAD_BUTTON_4_DOWN = 15, // MES_DPAD_BUTTON_4_DOWN
|
||||
MES_DPAD_BUTTON_4_UP = 16, // MES_DPAD_BUTTON_4_UP
|
||||
MES_DPAD_BUTTON_A_DOWN = 1, // MES_DPAD_BUTTON_A_DOWN
|
||||
MES_DPAD_BUTTON_A_UP = 2, // MES_DPAD_BUTTON_A_UP
|
||||
MES_DPAD_BUTTON_B_DOWN = 3, // MES_DPAD_BUTTON_B_DOWN
|
||||
MES_DPAD_BUTTON_B_UP = 4, // MES_DPAD_BUTTON_B_UP
|
||||
MES_DPAD_BUTTON_C_DOWN = 5, // MES_DPAD_BUTTON_C_DOWN
|
||||
MES_DPAD_BUTTON_C_UP = 6, // MES_DPAD_BUTTON_C_UP
|
||||
MES_DPAD_BUTTON_D_DOWN = 7, // MES_DPAD_BUTTON_D_DOWN
|
||||
MES_DPAD_BUTTON_D_UP = 8, // MES_DPAD_BUTTON_D_UP
|
||||
MES_REMOTE_CONTROL_EVT_FORWARD = 6, // MES_REMOTE_CONTROL_EVT_FORWARD
|
||||
MES_REMOTE_CONTROL_EVT_NEXTTRACK = 4, // MES_REMOTE_CONTROL_EVT_NEXTTRACK
|
||||
MES_REMOTE_CONTROL_EVT_PAUSE = 2, // MES_REMOTE_CONTROL_EVT_PAUSE
|
||||
MES_REMOTE_CONTROL_EVT_PLAY = 1, // MES_REMOTE_CONTROL_EVT_PLAY
|
||||
MES_REMOTE_CONTROL_EVT_PREVTRACK = 5, // MES_REMOTE_CONTROL_EVT_PREVTRACK
|
||||
MES_REMOTE_CONTROL_EVT_REWIND = 7, // MES_REMOTE_CONTROL_EVT_REWIND
|
||||
MES_REMOTE_CONTROL_EVT_STOP = 3, // MES_REMOTE_CONTROL_EVT_STOP
|
||||
MES_REMOTE_CONTROL_EVT_VOLUMEDOWN = 9, // MES_REMOTE_CONTROL_EVT_VOLUMEDOWN
|
||||
MES_REMOTE_CONTROL_EVT_VOLUMEUP = 8, // MES_REMOTE_CONTROL_EVT_VOLUMEUP
|
||||
}
|
||||
declare namespace control {
|
||||
}
|
||||
|
||||
|
||||
declare enum DisplayMode {
|
||||
//% block="black and white"
|
||||
BackAndWhite = 0, // DISPLAY_MODE_BLACK_AND_WHITE
|
||||
//% block="greyscale"
|
||||
Greyscale = 1, // DISPLAY_MODE_GREYSCALE
|
||||
// TODO DISPLAY_MODE_BLACK_AND_WHITE_LIGHT_SENSE
|
||||
}
|
||||
declare namespace led {
|
||||
}
|
||||
|
||||
|
||||
declare enum DigitalPin {
|
||||
P0 = 7, // MICROBIT_ID_IO_P0
|
||||
P1 = 8, // MICROBIT_ID_IO_P1
|
||||
P2 = 9, // MICROBIT_ID_IO_P2
|
||||
P3 = 10, // MICROBIT_ID_IO_P3
|
||||
P4 = 11, // MICROBIT_ID_IO_P4
|
||||
P5 = 12, // MICROBIT_ID_IO_P5
|
||||
P6 = 13, // MICROBIT_ID_IO_P6
|
||||
P7 = 14, // MICROBIT_ID_IO_P7
|
||||
//P8 = MICROBIT_ID_IO_P8,
|
||||
P9 = 16, // MICROBIT_ID_IO_P9
|
||||
P10 = 17, // MICROBIT_ID_IO_P10
|
||||
P11 = 18, // MICROBIT_ID_IO_P11
|
||||
//P12 = MICROBIT_ID_IO_P12,
|
||||
//P13 = MICROBIT_ID_IO_P13,
|
||||
//P14 = MICROBIT_ID_IO_P14,
|
||||
//P15 = MICROBIT_ID_IO_P15,
|
||||
//P16 = MICROBIT_ID_IO_P16,
|
||||
P19 = 24, // MICROBIT_ID_IO_P19
|
||||
P20 = 25, // MICROBIT_ID_IO_P20
|
||||
}
|
||||
|
||||
|
||||
declare enum AnalogPin {
|
||||
P0 = 7, // MICROBIT_ID_IO_P0
|
||||
P1 = 8, // MICROBIT_ID_IO_P1
|
||||
P2 = 9, // MICROBIT_ID_IO_P2
|
||||
P3 = 10, // MICROBIT_ID_IO_P3
|
||||
P4 = 11, // MICROBIT_ID_IO_P4
|
||||
P10 = 17, // MICROBIT_ID_IO_P10
|
||||
}
|
||||
|
||||
|
||||
declare enum PulseValue {
|
||||
High = 4, // MICROBIT_PIN_EVT_PULSE_HI
|
||||
Low = 5, // MICROBIT_PIN_EVT_PULSE_LO
|
||||
}
|
||||
|
||||
|
||||
declare enum PinPullMode {
|
||||
//% block="down"
|
||||
PullDown = 0,
|
||||
//% block="up"
|
||||
PullUp = 1,
|
||||
//% block="none"
|
||||
PullNone = 2,
|
||||
}
|
||||
|
||||
|
||||
declare enum SerialPin {
|
||||
P0 = 7, // MICROBIT_ID_IO_P0
|
||||
P1 = 8, // MICROBIT_ID_IO_P1
|
||||
P2 = 9, // MICROBIT_ID_IO_P2
|
||||
//P8 = MICROBIT_ID_IO_P8,
|
||||
//P12 = MICROBIT_ID_IO_P12,
|
||||
//P13 = MICROBIT_ID_IO_P13,
|
||||
//P14 = MICROBIT_ID_IO_P14,
|
||||
//P15 = MICROBIT_ID_IO_P15,
|
||||
//P16 = MICROBIT_ID_IO_P16
|
||||
}
|
||||
|
||||
|
||||
declare enum BaudRate {
|
||||
//% block=115200
|
||||
BaudRate115200 = 115200,
|
||||
//% block=9600
|
||||
BaudRate9600 = 9600,
|
||||
}
|
||||
declare namespace serial {
|
||||
}
|
||||
|
||||
|
||||
declare enum NumberFormat {
|
||||
Int8LE = 1,
|
||||
UInt8LE = 2,
|
||||
Int16LE = 3,
|
||||
UInt16LE = 4,
|
||||
Int32LE = 5,
|
||||
Int8BE = 6,
|
||||
UInt8BE = 7,
|
||||
Int16BE = 8,
|
||||
UInt16BE = 9,
|
||||
Int32BE = 10,
|
||||
// UInt32,
|
||||
}
|
||||
|
||||
// Auto-generated. Do not edit. Really.
|
@ -1,739 +0,0 @@
|
||||
enum Direction {
|
||||
//% block=right
|
||||
Right,
|
||||
//% block=left
|
||||
Left
|
||||
}
|
||||
|
||||
enum LedSpriteProperty {
|
||||
//% block=x
|
||||
X,
|
||||
//% block=y
|
||||
Y,
|
||||
//% block=direction
|
||||
Direction,
|
||||
//% block=brightness
|
||||
Brightness,
|
||||
//% block=blink
|
||||
Blink
|
||||
}
|
||||
|
||||
/**
|
||||
* A single-LED sprite game engine
|
||||
*/
|
||||
//% color=#008272 weight=32
|
||||
namespace game {
|
||||
let _score: number = 0;
|
||||
let _life: number = 3;
|
||||
let _startTime: number = 0;
|
||||
let _endTime: number = 0;
|
||||
let _isGameOver: boolean = false;
|
||||
let _countdownPause: number = 0;
|
||||
let _level: number = 1;
|
||||
let _gameId: number = 0;
|
||||
let img: Image;
|
||||
let sprites: LedSprite[];
|
||||
|
||||
/**
|
||||
* Creates a new LED sprite pointing to the right.
|
||||
* @param x sprite horizontal coordinate, eg: 2
|
||||
* @param y sprite vertical coordinate, eg: 2
|
||||
*/
|
||||
//% weight=60
|
||||
//% blockId=game_create_sprite block="create sprite at|x: %x|y: %y"
|
||||
//% parts="ledmatrix"
|
||||
export function createSprite(x: number, y: number): LedSprite {
|
||||
init();
|
||||
let p = new LedSprite(x, y);
|
||||
sprites.push(p);
|
||||
plot();
|
||||
return p;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current score
|
||||
*/
|
||||
//% weight=9 help=game/score
|
||||
//% blockId=game_score block="score" blockGap=8
|
||||
export function score(): number {
|
||||
return _score;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds points to the current score
|
||||
* @param points amount of points to change, eg: 1
|
||||
*/
|
||||
//% weight=10 help=game/add-score
|
||||
//% blockId=game_add_score block="change score by|%points" blockGap=8
|
||||
//% parts="ledmatrix"
|
||||
export function addScore(points: number): void {
|
||||
setScore(_score + points);
|
||||
control.inBackground(() => {
|
||||
led.stopAnimation();
|
||||
basic.showAnimation(`0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 0 0 1 0 0 0 0 0
|
||||
0 0 0 0 0 0 0 1 0 0 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0
|
||||
0 0 1 0 0 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0 0 0 0 0 0 0 1 0 0 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 0 0 1 0 0 0 0 0`, 20);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a game countdown timer
|
||||
* @param ms countdown duration in milliseconds, eg: 10000
|
||||
*/
|
||||
//% weight=9 help=game/start-countdown
|
||||
//% blockId=game_start_countdown block="start countdown|(ms) %duration" blockGap=8
|
||||
//% parts="ledmatrix"
|
||||
export function startCountdown(ms: number): void {
|
||||
if (checkStart()) {
|
||||
basic.showAnimation(`1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0
|
||||
0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0
|
||||
1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0
|
||||
0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0
|
||||
1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0`, 400);
|
||||
_countdownPause = Math.max(500, ms);
|
||||
_startTime = -1;
|
||||
_endTime = input.runningTime() + _countdownPause;
|
||||
control.inBackground(() => {
|
||||
basic.pause(_countdownPause);
|
||||
gameOver();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a game over animation.
|
||||
*/
|
||||
//% weight=8 help=game/game-over
|
||||
//% blockId=game_game_over block="game over"
|
||||
//% parts="ledmatrix"
|
||||
export function gameOver(): void {
|
||||
if (!_isGameOver) {
|
||||
_isGameOver = true;
|
||||
unplugEvents();
|
||||
led.stopAnimation();
|
||||
led.setBrightness(255);
|
||||
led.setDisplayMode(DisplayMode.BackAndWhite);
|
||||
while (true) {
|
||||
for (let i = 0; i < 8; i++) {
|
||||
basic.clearScreen();
|
||||
basic.pause(100);
|
||||
basic.showLeds(`1 1 1 1 1
|
||||
1 1 1 1 1
|
||||
1 1 1 1 1
|
||||
1 1 1 1 1
|
||||
1 1 1 1 1`, 300);
|
||||
}
|
||||
basic.showAnimation(`1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 0 1 1 0 0 0 1 0 0 0 0 0 0 0 0 0
|
||||
1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 0 1 1 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
1 1 0 1 1 1 0 0 0 1 1 0 0 0 1 1 0 0 0 1 1 0 0 0 1 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 0 0 1 1 1 0 0 0 1 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 0 0 1 1 1 0 0 0 1 1 0 0 0 0 1 0 0 0 0 0`, 100);
|
||||
for (let j = 0; j < 3; j++) {
|
||||
basic.showString(" GAMEOVER ", 100);
|
||||
showScore();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// already in game over mode in another fiber
|
||||
while (true) {
|
||||
basic.pause(10000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current score value
|
||||
* @param value TODO
|
||||
*/
|
||||
//% weight=10 help=game/set-score
|
||||
export function setScore(value: number): void {
|
||||
_score = Math.max(0, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current life
|
||||
*/
|
||||
//% weight=10
|
||||
export function life(): number {
|
||||
return _life;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current life value
|
||||
* @param value TODO
|
||||
*/
|
||||
//% weight=10
|
||||
export function setLife(value: number): void {
|
||||
_life = Math.max(0, value);
|
||||
if (_life <= 0) {
|
||||
gameOver();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds life points to the current life
|
||||
* @param lives TODO
|
||||
*/
|
||||
//% weight=10
|
||||
export function addLife(lives: number): void {
|
||||
setLife(_life + lives);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the remaining time (since `start countdown`) or current time (since the device started or `start stopwatch`) in milliseconds.
|
||||
*/
|
||||
//% weight=10
|
||||
export function currentTime(): number {
|
||||
if (_endTime > 0) {
|
||||
return Math.max(0, _endTime - input.runningTime());
|
||||
} else {
|
||||
return input.runningTime() - _startTime;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes some life
|
||||
* @param life TODO
|
||||
*/
|
||||
//% weight=10
|
||||
//% parts="ledmatrix"
|
||||
export function removeLife(life: number): void {
|
||||
setLife(_life - life);
|
||||
control.inBackground(() => {
|
||||
led.stopAnimation();
|
||||
basic.showAnimation(`1 0 0 0 1 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0
|
||||
0 1 0 1 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0
|
||||
0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0
|
||||
0 1 0 1 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0
|
||||
1 0 0 0 1 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0`, 40);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Increments the level and display a message.
|
||||
*/
|
||||
//% weight=10
|
||||
//% parts="ledmatrix"
|
||||
export function levelUp(): void {
|
||||
_level = _level + 1;
|
||||
basic.showString("LEVEL:", 150);
|
||||
basic.showNumber(_level, 150);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current level
|
||||
*/
|
||||
//% weight=10
|
||||
export function level(): number {
|
||||
return _level;
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a stopwatch timer. `current time` will return the elapsed time.
|
||||
*/
|
||||
//% weight=10
|
||||
export function startStopwatch(): void {
|
||||
_startTime = input.runningTime();
|
||||
_endTime = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a value indicating if the game is still running. Returns `false` if game over.
|
||||
*/
|
||||
//% weight=10
|
||||
export function isRunning(): boolean {
|
||||
let running: boolean;
|
||||
return !_isGameOver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the score on the screen.
|
||||
*/
|
||||
//% weight=60
|
||||
//% parts="ledmatrix"
|
||||
export function showScore(): void {
|
||||
basic.showString(" SCORE ", 100);
|
||||
basic.showNumber(_score, 150);
|
||||
basic.showString(" ", 150);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if the game is display the game over sequence.
|
||||
*/
|
||||
export function isGameOver(): boolean {
|
||||
let over: boolean;
|
||||
return _isGameOver;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns false if game can't start
|
||||
*/
|
||||
function checkStart(): boolean {
|
||||
if (_countdownPause > 0 || _startTime > 0) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function unplugEvents(): void {
|
||||
input.onButtonPressed(Button.A, () => { });
|
||||
input.onButtonPressed(Button.B, () => { });
|
||||
input.onButtonPressed(Button.AB, () => {
|
||||
control.reset();
|
||||
});
|
||||
}
|
||||
|
||||
export class LedSprite {
|
||||
private _x: number;
|
||||
private _y: number;
|
||||
private _dir: number;
|
||||
private _brightness: number;
|
||||
private _blink: number;
|
||||
|
||||
constructor(x: number, y: number) {
|
||||
this._x = Math.clamp(0, 4, x);
|
||||
this._y = Math.clamp(0, 4, y);
|
||||
this._dir = 90;
|
||||
this._brightness = 255;
|
||||
init();
|
||||
sprites.push(this);
|
||||
plot();
|
||||
}
|
||||
|
||||
/**
|
||||
* Move a certain number of LEDs
|
||||
* @param this the sprite to move
|
||||
* @param leds number of leds to move, eg: 1, -1
|
||||
*/
|
||||
//% weight=50
|
||||
//% blockId=game_move_sprite block="%sprite|move by %leds" blockGap=8
|
||||
//% parts="ledmatrix"
|
||||
public move(leds: number): void {
|
||||
if (this._dir == 0) {
|
||||
this._y = this._y - leds;
|
||||
} else if (this._dir == 45) {
|
||||
this._x = this._x + leds;
|
||||
this._y = this._y - leds;
|
||||
} else if (this._dir == 90) {
|
||||
this._x = this._x + leds;
|
||||
} else if (this._dir == 135) {
|
||||
this._x = this._x + leds;
|
||||
this._y = this._y + leds;
|
||||
} else if (this._dir == 180) {
|
||||
this._y = this._y + leds;
|
||||
} else if (this._dir == -45) {
|
||||
this._x = this._x - leds;
|
||||
this._y = this._y - leds;
|
||||
} else if (this._dir == -90) {
|
||||
this._x = this._x - leds;
|
||||
} else {
|
||||
this._x = this._x - leds;
|
||||
this._y = this._y + leds;
|
||||
}
|
||||
this._x = Math.clamp(0, 4, this._x);
|
||||
this._y = Math.clamp(0, 4, this._y);
|
||||
plot();
|
||||
}
|
||||
|
||||
/**
|
||||
* Go to this position on the screen
|
||||
* @param this TODO
|
||||
* @param x TODO
|
||||
* @param y TODO
|
||||
*/
|
||||
//% parts="ledmatrix"
|
||||
public goTo(x: number, y: number): void {
|
||||
this._x = x;
|
||||
this._y = y;
|
||||
this._x = Math.clamp(0, 4, this._x);
|
||||
this._y = Math.clamp(0, 4, this._y);
|
||||
plot();
|
||||
}
|
||||
|
||||
/**
|
||||
* If touching the edge of the stage, then bounce away.
|
||||
* @param this TODO
|
||||
*/
|
||||
//% weight=18
|
||||
//% blockId=game_sprite_bounce block="%sprite|if on edge, bounce"
|
||||
//% parts="ledmatrix"
|
||||
public ifOnEdgeBounce(): void {
|
||||
if (this._dir == 0 && this._y == 0) {
|
||||
this._dir = 180;
|
||||
} else if (this._dir == 45 && (this._x == 4 || this._y == 0)) {
|
||||
if (this._x == 0 && this._y == 0) {
|
||||
this._dir = -135;
|
||||
} else if (this._y == 0) {
|
||||
this._dir = 135;
|
||||
} else {
|
||||
this._dir = -45;
|
||||
}
|
||||
} else if (this._dir == 90 && this._x == 4) {
|
||||
this._dir = -90;
|
||||
} else if (this._dir == 135 && (this._x == 4 || this._y == 4)) {
|
||||
if (this.x() == 4 && this.y() == 4) {
|
||||
this._dir = -45;
|
||||
} else if (this._y == 4) {
|
||||
this._dir = 45;
|
||||
} else {
|
||||
this._dir = -135;
|
||||
}
|
||||
} else if (this._dir == 180 && this._y == 4) {
|
||||
this._dir = 0;
|
||||
} else if (this._dir == -45 && (this._x == 0 || this._y == 0)) {
|
||||
if (this.x() == 0 && this.y() == 0) {
|
||||
this._dir = 135;
|
||||
} else if (this._y == 0) {
|
||||
this._dir = -135;
|
||||
} else {
|
||||
this._dir = 45;
|
||||
}
|
||||
} else if (this._dir == -90 && this._x == 0) {
|
||||
this._dir = 90;
|
||||
} else if (this._dir == -135 && (this._x == 0 || this._y == 4)) {
|
||||
if (this._x == 0 && this._y == 4) {
|
||||
this._dir = 45;
|
||||
} else if (this._y == 4) {
|
||||
this._dir = -45;
|
||||
} else {
|
||||
this._dir = 135;
|
||||
}
|
||||
}
|
||||
plot();
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn the sprite
|
||||
* @param this TODO
|
||||
* @param direction left or right
|
||||
* @param degrees angle in degrees to turn, eg: 45, 90, 180, 135
|
||||
*/
|
||||
//% weight=49
|
||||
//% blockId=game_turn_sprite block="%sprite|turn %direction|by (°) %degrees"
|
||||
public turn(direction: Direction, degrees: number) {
|
||||
if (direction == Direction.Right)
|
||||
this.setDirection(this._dir + degrees);
|
||||
else
|
||||
this.setDirection(this._dir - degrees);
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn to the right (clockwise)
|
||||
* @param this TODO
|
||||
* @param degrees TODO
|
||||
*/
|
||||
public turnRight(degrees: number): void {
|
||||
this.turn(Direction.Right, degrees);
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn to the left (counter-clockwise)
|
||||
* @param this TODO
|
||||
* @param degrees TODO
|
||||
*/
|
||||
public turnLeft(degrees: number): void {
|
||||
this.turn(Direction.Left, degrees);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a property of the sprite
|
||||
* @param property the name of the property to change
|
||||
* @param the updated value
|
||||
*/
|
||||
//% weight=29
|
||||
//% blockId=game_sprite_set_property block="%sprite|set %property|to %value" blockGap=8
|
||||
public set(property: LedSpriteProperty, value: number) {
|
||||
switch (property) {
|
||||
case LedSpriteProperty.X: this.setX(value); break;
|
||||
case LedSpriteProperty.Y: this.setY(value); break;
|
||||
case LedSpriteProperty.Direction: this.setDirection(value); break;
|
||||
case LedSpriteProperty.Brightness: this.setBrightness(value); break;
|
||||
case LedSpriteProperty.Blink: this.setBlink(value); break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes a property of the sprite
|
||||
* @param property the name of the property to change
|
||||
* @param value amount of change, eg: 1
|
||||
*/
|
||||
//% weight=30
|
||||
//% blockId=game_sprite_change_xy block="%sprite|change %property|by %value" blockGap=8
|
||||
public change(property: LedSpriteProperty, value: number) {
|
||||
switch (property) {
|
||||
case LedSpriteProperty.X: this.changeXBy(value); break;
|
||||
case LedSpriteProperty.Y: this.changeYBy(value); break;
|
||||
case LedSpriteProperty.Direction: this.changeDirectionBy(value); break;
|
||||
case LedSpriteProperty.Brightness: this.changeBrightnessBy(value); break;
|
||||
case LedSpriteProperty.Blink: this.changeBlinkBy(value); break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a property of the sprite
|
||||
* @param property the name of the property to change
|
||||
*/
|
||||
//% weight=28
|
||||
//% blockId=game_sprite_property block="%sprite|%property"
|
||||
public get(property: LedSpriteProperty) {
|
||||
switch (property) {
|
||||
case LedSpriteProperty.X: return this.x();
|
||||
case LedSpriteProperty.Y: return this.y();
|
||||
case LedSpriteProperty.Direction: return this.direction()
|
||||
case LedSpriteProperty.Brightness: return this.brightness();
|
||||
case LedSpriteProperty.Blink: return this.blink();
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the direction of the current sprite, rounded to the nearest multiple of 45
|
||||
* @param this TODO
|
||||
* @param degrees TODO
|
||||
*/
|
||||
//% parts="ledmatrix"
|
||||
public setDirection(degrees: number): void {
|
||||
this._dir = ((degrees / 45) % 8) * 45;
|
||||
if (this._dir <= -180) {
|
||||
this._dir = this._dir + 360;
|
||||
} else if (this._dir > 180) {
|
||||
this._dir = this._dir - 360;
|
||||
}
|
||||
plot();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reports the ``x`` position of a sprite on the LED screen
|
||||
* @param this TODO
|
||||
*/
|
||||
public x(): number {
|
||||
return this._x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reports the ``y`` position of a sprite on the LED screen
|
||||
* @param this TODO
|
||||
*/
|
||||
public y(): number {
|
||||
return this._y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reports the current direction of a sprite
|
||||
* @param this TODO
|
||||
*/
|
||||
public direction(): number {
|
||||
return this._dir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the ``x`` position of a sprite
|
||||
* @param this TODO
|
||||
* @param x TODO
|
||||
*/
|
||||
public setX(x: number): void {
|
||||
this.goTo(x, this._y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the ``y`` position of a sprite
|
||||
* @param this TODO
|
||||
* @param y TODO
|
||||
*/
|
||||
public setY(y: number): void {
|
||||
this.goTo(this._x, y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the ``y`` position by the given amount
|
||||
* @param this TODO
|
||||
* @param y TODO
|
||||
*/
|
||||
public changeYBy(y: number): void {
|
||||
this.goTo(this._x, this._y + y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the ``x`` position by the given amount
|
||||
* @param this TODO
|
||||
* @param x TODO
|
||||
*/
|
||||
public changeXBy(x: number): void {
|
||||
this.goTo(this._x + x, this._y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reports true if sprite is touching specified sprite
|
||||
* @param this TODO
|
||||
* @param other TODO
|
||||
*/
|
||||
//% weight=20
|
||||
//% blockId=game_sprite_touching_sprite block="%sprite|touching %other|?" blockGap=8
|
||||
public isTouching(other: LedSprite): boolean {
|
||||
return this._x == other._x && this._y == other._y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reports true if sprite is touching an edge
|
||||
* @param this TODO
|
||||
*/
|
||||
//% weight=19
|
||||
//% blockId=game_sprite_touching_edge block="%sprite|touching edge?" blockGap=8
|
||||
public isTouchingEdge(): boolean {
|
||||
return this._x == 0 || this._x == 4 || this._y == 0 || this._y == 4;
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns on the sprite (on by default)
|
||||
* @param this TODO
|
||||
*/
|
||||
public on(): void {
|
||||
this.setBrightness(255);
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns off the sprite (on by default)
|
||||
* @param this TODO
|
||||
*/
|
||||
public off(): void {
|
||||
this.setBrightness(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the ``brightness`` of a sprite
|
||||
* @param this TODO
|
||||
* @param brightness TODO
|
||||
*/
|
||||
//% parts="ledmatrix"
|
||||
public setBrightness(brightness: number): void {
|
||||
this._brightness = Math.clamp(0, 255, brightness);
|
||||
plot();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reports the ``brightness` of a sprite on the LED screen
|
||||
* @param this TODO
|
||||
*/
|
||||
public brightness(): number {
|
||||
let r: number;
|
||||
return this._brightness;
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the ``y`` position by the given amount
|
||||
* @param this TODO
|
||||
* @param value TODO
|
||||
*/
|
||||
public changeBrightnessBy(value: number): void {
|
||||
this.setBrightness(this._brightness + value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the ``direction`` position by the given amount by turning right
|
||||
* @param this TODO
|
||||
* @param angle TODO
|
||||
*/
|
||||
public changeDirectionBy(angle: number): void {
|
||||
this.turnRight(angle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the sprite from the game engine. All further operation of the sprite will not have any effect.
|
||||
* @param sprite TODO
|
||||
*/
|
||||
public delete(sprite: LedSprite): void {
|
||||
sprites.removeElement(sprite);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the blink duration interval in millisecond.
|
||||
* @param sprite TODO
|
||||
* @param ms TODO
|
||||
*/
|
||||
public setBlink(ms: number): void {
|
||||
this._blink = Math.clamp(0, 10000, ms);
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the ``blink`` duration by the given amount of millisecons
|
||||
* @param this TODO
|
||||
* @param ms TODO
|
||||
*/
|
||||
public changeBlinkBy(ms: number): void {
|
||||
this.setBlink(this._blink + ms);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reports the ``blink`` duration of a sprite
|
||||
* @param this TODO
|
||||
*/
|
||||
public blink(): number {
|
||||
let r: number;
|
||||
return this._blink;
|
||||
}
|
||||
|
||||
//% weight=-1
|
||||
//% parts="ledmatrix"
|
||||
public _plot(now: number) {
|
||||
let ps = this
|
||||
if (ps._brightness > 0) {
|
||||
let r = 0;
|
||||
if (ps._blink > 0) {
|
||||
r = (now / ps._blink) % 2;
|
||||
}
|
||||
if (r == 0) {
|
||||
img.setPixelBrightness(ps._x, ps._y, img.pixelBrightness(ps._x, ps._y) + ps._brightness);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function init(): void {
|
||||
if (img == null) {
|
||||
img = images.createImage(
|
||||
`0 0 0 0 0
|
||||
0 0 0 0 0
|
||||
0 0 0 0 0
|
||||
0 0 0 0 0
|
||||
0 0 0 0 0`);
|
||||
sprites = (<LedSprite[]>[]);
|
||||
led.setDisplayMode(DisplayMode.Greyscale);
|
||||
basic.forever(() => {
|
||||
basic.pause(30);
|
||||
plot();
|
||||
if (game.isGameOver()) {
|
||||
basic.pause(600);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Plots the current sprites on the screen
|
||||
*/
|
||||
//% parts="ledmatrix"
|
||||
function plot(): void {
|
||||
if (game.isGameOver()) {
|
||||
return;
|
||||
}
|
||||
let now = input.runningTime();
|
||||
img.clear();
|
||||
for (let i = 0; i < sprites.length; i++) {
|
||||
sprites[i]._plot(now);
|
||||
}
|
||||
img.plotImage(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an invalid sprite; used to initialize locals.
|
||||
*/
|
||||
//% weight=0
|
||||
export function invalidSprite(): LedSprite {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,17 +0,0 @@
|
||||
namespace console {
|
||||
export function log(msg: string) {
|
||||
serial.writeString(msg);
|
||||
serial.writeString("\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
namespace Math {
|
||||
/**
|
||||
* Generates a `true` or `false` value randomly, just like flipping a coin.
|
||||
*/
|
||||
//% blockId=logic_random block="pick random true or false"
|
||||
//% help=math/random-boolean color=230
|
||||
export function randomBoolean(): boolean {
|
||||
return Math.random(2) == 0;
|
||||
}
|
||||
}
|
@ -1,158 +0,0 @@
|
||||
#include "ksbit.h"
|
||||
|
||||
/**
|
||||
* Creation, manipulation and display of LED images.
|
||||
*/
|
||||
//% color=#5C2D91 weight=31
|
||||
namespace images {
|
||||
/**
|
||||
* Creates an image that fits on the LED screen.
|
||||
*/
|
||||
//% weight=75 help=images/create-image
|
||||
//% blockId=device_build_image block="create image"
|
||||
//% parts="ledmatrix"
|
||||
Image createImage(ImageLiteral leds) {
|
||||
return MicroBitImage(imageBytes(leds)).clone().leakData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an image with 2 frames.
|
||||
*/
|
||||
//% weight=74 help=images/create-big-image
|
||||
//% blockId=device_build_big_image block="create big image" imageLiteral=2
|
||||
//% parts="ledmatrix"
|
||||
Image createBigImage(ImageLiteral leds) {
|
||||
return createImage(leds);
|
||||
}
|
||||
}
|
||||
|
||||
namespace ImageMethods {
|
||||
/**
|
||||
* Plots the image at a given column to the screen
|
||||
*/
|
||||
//% help=images/plot-image
|
||||
//% parts="ledmatrix"
|
||||
void plotImage(Image i, int xOffset = 0) {
|
||||
uBit.display.print(MicroBitImage(i), -xOffset, 0, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows an frame from the image at offset ``x offset``.
|
||||
* @param xOffset column index to start displaying the image
|
||||
*/
|
||||
//% help=images/show-image weight=80 blockNamespace=images
|
||||
//% blockId=device_show_image_offset block="show image %sprite|at offset %offset" blockGap=8
|
||||
//% parts="ledmatrix"
|
||||
void showImage(Image sprite, int xOffset) {
|
||||
uBit.display.print(MicroBitImage(sprite), -xOffset, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the ``index``-th frame of the image on the screen.
|
||||
* @param xOffset column index to start displaying the image
|
||||
*/
|
||||
//% help=images/plot-frame weight=80
|
||||
//% parts="ledmatrix"
|
||||
void plotFrame(Image i, int xOffset) {
|
||||
// TODO showImage() used in original implementation
|
||||
plotImage(i, xOffset * 5);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scrolls an image .
|
||||
* @param frameOffset x offset moved on each animation step, eg: 5, 1, -1
|
||||
* @param interval time between each animation step in milli seconds, eg: 200
|
||||
*/
|
||||
//% help=images/show-image weight=79 async blockNamespace=images
|
||||
//% blockId=device_scroll_image block="scroll image %sprite|with offset %frameoffset|and interval (ms) %delay" blockGap=8
|
||||
//% parts="ledmatrix"
|
||||
void scrollImage(Image id, int frameOffset, int interval) {
|
||||
MicroBitImage i(id);
|
||||
if (i.getWidth() <= 5)
|
||||
showImage(id, 0);
|
||||
else
|
||||
uBit.display.animate(i, interval, frameOffset, 0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets all pixels off.
|
||||
*/
|
||||
//% help=images/clear
|
||||
//% parts="ledmatrix"
|
||||
void clear(Image i) {
|
||||
MicroBitImage(i).clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a specific pixel brightness at a given position
|
||||
*/
|
||||
//%
|
||||
//% parts="ledmatrix"
|
||||
void setPixelBrightness(Image i, int x, int y, int value) {
|
||||
MicroBitImage(i).setPixelValue(x, y, value);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the pixel brightness ([0..255]) at a given position
|
||||
*/
|
||||
//%
|
||||
//% parts="ledmatrix"
|
||||
int pixelBrightness(Image i, int x, int y) {
|
||||
int pix = MicroBitImage(i).getPixelValue(x, y);
|
||||
if (pix < 0) return 0;
|
||||
return pix;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the width in columns
|
||||
*/
|
||||
//% help=functions/width
|
||||
int width(Image i) {
|
||||
return i->width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the height in rows (always 5)
|
||||
*/
|
||||
//%
|
||||
int height(Image i) {
|
||||
return i->height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a pixel state at position ``(x,y)``
|
||||
* @param x TODO
|
||||
* @param y TODO
|
||||
* @param value TODO
|
||||
*/
|
||||
//% help=images/set-pixel
|
||||
//% parts="ledmatrix"
|
||||
void setPixel(Image i, int x, int y, bool value) {
|
||||
setPixelBrightness(i, x, y, value ? 255 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the pixel state at position ``(x,y)``
|
||||
* @param x TODO
|
||||
* @param y TODO
|
||||
*/
|
||||
//% help=images/pixel
|
||||
//% parts="ledmatrix"
|
||||
bool pixel(Image i, int x, int y) {
|
||||
return pixelBrightness(i, x, y) > 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Shows a particular frame of the image strip.
|
||||
* @param frame TODO
|
||||
*/
|
||||
//% weight=70 help=images/show-frame
|
||||
//% parts="ledmatrix"
|
||||
void showFrame(Image i, int frame) {
|
||||
showImage(i, frame * 5);
|
||||
}
|
||||
}
|
@ -1,320 +0,0 @@
|
||||
#include "ksbit.h"
|
||||
|
||||
enum class Button {
|
||||
A = MICROBIT_ID_BUTTON_A,
|
||||
B = MICROBIT_ID_BUTTON_B,
|
||||
//% block="A+B"
|
||||
AB = MICROBIT_ID_BUTTON_AB,
|
||||
};
|
||||
|
||||
enum class Dimension {
|
||||
//% block=x
|
||||
X = 0,
|
||||
//% block=y
|
||||
Y = 1,
|
||||
//% block=z
|
||||
Z = 2,
|
||||
//% block=strength
|
||||
Strength = 3,
|
||||
};
|
||||
|
||||
enum class Rotation {
|
||||
//% block=pitch
|
||||
Pitch = 0,
|
||||
//% block=roll
|
||||
Roll = 1,
|
||||
};
|
||||
|
||||
enum class TouchPin {
|
||||
P0 = MICROBIT_ID_IO_P0,
|
||||
P1 = MICROBIT_ID_IO_P1,
|
||||
P2 = MICROBIT_ID_IO_P2,
|
||||
};
|
||||
|
||||
enum class AcceleratorRange {
|
||||
/**
|
||||
* The accelerator measures forces up to 1 gravity
|
||||
*/
|
||||
//% block="1g"
|
||||
OneG = 1,
|
||||
/**
|
||||
* The accelerator measures forces up to 2 gravity
|
||||
*/
|
||||
//% block="2g"
|
||||
TwoG = 2,
|
||||
/**
|
||||
* The accelerator measures forces up to 4 gravity
|
||||
*/
|
||||
//% block="4g"
|
||||
FourG = 4,
|
||||
/**
|
||||
* The accelerator measures forces up to 8 gravity
|
||||
*/
|
||||
//% block="8g"
|
||||
EightG = 8
|
||||
};
|
||||
|
||||
enum class Gesture {
|
||||
/**
|
||||
* Raised when shaken
|
||||
*/
|
||||
//% block=shake
|
||||
Shake = MICROBIT_ACCELEROMETER_EVT_SHAKE,
|
||||
/**
|
||||
* Raised when the logo is upward and the screen is vertical
|
||||
*/
|
||||
//% block="logo up"
|
||||
LogoUp = MICROBIT_ACCELEROMETER_EVT_TILT_UP,
|
||||
/**
|
||||
* Raised when the logo is downward and the screen is vertical
|
||||
*/
|
||||
//% block="logo down"
|
||||
LogoDown = MICROBIT_ACCELEROMETER_EVT_TILT_DOWN,
|
||||
/**
|
||||
* Raised when the screen is pointing down and the board is horizontal
|
||||
*/
|
||||
//% block="screen up"
|
||||
ScreenUp = MICROBIT_ACCELEROMETER_EVT_FACE_UP,
|
||||
/**
|
||||
* Raised when the screen is pointing up and the board is horizontal
|
||||
*/
|
||||
//% block="screen down"
|
||||
ScreenDown = MICROBIT_ACCELEROMETER_EVT_FACE_DOWN,
|
||||
/**
|
||||
* Raised when the screen is pointing left
|
||||
*/
|
||||
//% block="tilt left"
|
||||
TiltLeft = MICROBIT_ACCELEROMETER_EVT_TILT_LEFT,
|
||||
/**
|
||||
* Raised when the screen is pointing right
|
||||
*/
|
||||
//% block="tilt right"
|
||||
TiltRight = MICROBIT_ACCELEROMETER_EVT_TILT_RIGHT,
|
||||
/**
|
||||
* Raised when the board is falling!
|
||||
*/
|
||||
//% block="free fall"
|
||||
FreeFall = MICROBIT_ACCELEROMETER_EVT_FREEFALL,
|
||||
/**
|
||||
* Raised when a 3G shock is detected
|
||||
*/
|
||||
//% block="3g"
|
||||
ThreeG = MICROBIT_ACCELEROMETER_EVT_3G,
|
||||
/**
|
||||
* Raised when a 6G shock is detected
|
||||
*/
|
||||
//% block="6g"
|
||||
SixG = MICROBIT_ACCELEROMETER_EVT_6G
|
||||
};
|
||||
|
||||
//% color=300 weight=99
|
||||
namespace input {
|
||||
/**
|
||||
* Do something when a button (``A``, ``B`` or both ``A+B``) is pressed
|
||||
* @param button TODO
|
||||
* @param body TODO
|
||||
*/
|
||||
//% help=input/on-button-pressed weight=85 blockGap=8
|
||||
//% blockId=device_button_event block="on button|%NAME|pressed" icon="\uf192"
|
||||
//% parts="buttonpair"
|
||||
void onButtonPressed(Button button, Action body) {
|
||||
registerWithDal((int)button, MICROBIT_BUTTON_EVT_CLICK, body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Do something when when a gesture is done (like shaking the micro:bit).
|
||||
* @param body TODO
|
||||
*/
|
||||
//% help=input/on-gesture weight=84 blockGap=8
|
||||
//% blockId=device_gesture_event block="on |%NAME" icon="\uf135"
|
||||
//% parts="accelerometer"
|
||||
void onGesture(Gesture gesture, Action body) {
|
||||
if ((int)gesture == MICROBIT_ACCELEROMETER_EVT_3G && uBit.accelerometer.getRange() < 3)
|
||||
uBit.accelerometer.setRange(4);
|
||||
else if ((int)gesture == MICROBIT_ACCELEROMETER_EVT_6G && uBit.accelerometer.getRange() < 6)
|
||||
uBit.accelerometer.setRange(8);
|
||||
registerWithDal(MICROBIT_ID_GESTURE, (int)gesture, body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Do something when a pin is pressed.
|
||||
* @param name the pin that needs to be pressed
|
||||
* @param body the code to run when the pin is pressed
|
||||
*/
|
||||
//% help=input/on-pin-pressed weight=83
|
||||
//% blockId=device_pin_event block="on pin %NAME|pressed" icon="\uf094"
|
||||
void onPinPressed(TouchPin name, Action body) {
|
||||
auto pin = getPin((int)name);
|
||||
if (!pin) return;
|
||||
|
||||
// Forces the PIN to switch to makey-makey style detection.
|
||||
pin->isTouched();
|
||||
registerWithDal((int)name, MICROBIT_BUTTON_EVT_CLICK, body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Do something when a pin is released.
|
||||
* @param name the pin that needs to be released
|
||||
* @param body the code to run when the pin is released
|
||||
*/
|
||||
//% help=input/on-pin-released weight=6 blockGap=8
|
||||
//% blockId=device_pin_released block="on pin %NAME|released" icon="\uf094"
|
||||
void onPinReleased(TouchPin name, Action body) {
|
||||
auto pin = getPin((int)name);
|
||||
if (!pin) return;
|
||||
|
||||
// Forces the PIN to switch to makey-makey style detection.
|
||||
pin->isTouched();
|
||||
registerWithDal((int)name, MICROBIT_BUTTON_EVT_UP, body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the button state (pressed or not) for ``A`` and ``B``.
|
||||
*/
|
||||
//% help=input/button-is-pressed weight=57
|
||||
//% block="button|%NAME|is pressed"
|
||||
//% blockId=device_get_button2
|
||||
//% icon="\uf192" blockGap=8
|
||||
//% parts="buttonpair"
|
||||
bool buttonIsPressed(Button button) {
|
||||
if (button == Button::A)
|
||||
return uBit.buttonA.isPressed();
|
||||
else if (button == Button::B)
|
||||
return uBit.buttonB.isPressed();
|
||||
else if (button == Button::AB)
|
||||
return uBit.buttonAB.isPressed();
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the pin state (pressed or not). Requires to hold the ground to close the circuit.
|
||||
* @param name pin used to detect the touch
|
||||
*/
|
||||
//% help=input/pin-is-pressed weight=56
|
||||
//% blockId="device_pin_is_pressed" block="pin %NAME|is pressed" icon="\uf094"
|
||||
//% blockGap=8
|
||||
bool pinIsPressed(TouchPin name) {
|
||||
auto pin = getPin((int)name);
|
||||
return pin && pin->isTouched();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current compass heading in degrees.
|
||||
*/
|
||||
//% help=input/compass-heading
|
||||
//% weight=56 icon="\uf14e"
|
||||
//% blockId=device_heading block="compass heading (°)" blockGap=8
|
||||
//% parts="compass"
|
||||
int compassHeading() {
|
||||
return uBit.compass.heading();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the temperature in Celsius degrees (°C).
|
||||
*/
|
||||
//% weight=55 icon="\uf06d"
|
||||
//% help=input/temperature
|
||||
//% blockId=device_temperature block="temperature (°C)" blockGap=8
|
||||
//% parts="thermometer"
|
||||
int temperature() {
|
||||
return uBit.thermometer.getTemperature();
|
||||
}
|
||||
|
||||
int getAccelerationStrength() {
|
||||
double x = uBit.accelerometer.getX();
|
||||
double y = uBit.accelerometer.getY();
|
||||
double z = uBit.accelerometer.getZ();
|
||||
return (int)sqrt(x*x+y*y+z*z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the acceleration value in milli-gravitys (when the board is laying flat with the screen up, x=0, y=0 and z=-1024)
|
||||
* @param dimension TODO
|
||||
*/
|
||||
//% help=input/acceleration weight=54 icon="\uf135"
|
||||
//% blockId=device_acceleration block="acceleration (mg)|%NAME" blockGap=8
|
||||
//% parts="accelerometer"
|
||||
int acceleration(Dimension dimension) {
|
||||
switch (dimension) {
|
||||
case Dimension::X: return uBit.accelerometer.getX();
|
||||
case Dimension::Y: return uBit.accelerometer.getY();
|
||||
case Dimension::Z: return uBit.accelerometer.getZ();
|
||||
case Dimension::Strength: return getAccelerationStrength();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reads the light level applied to the LED screen in a range from ``0`` (dark) to ``255`` bright.
|
||||
*/
|
||||
//% help=input/light-level weight=53
|
||||
//% blockId=device_get_light_level block="light level" blockGap=8 icon="\uf185"
|
||||
//% parts="ledmatrix"
|
||||
int lightLevel() {
|
||||
return uBit.display.readLightLevel();
|
||||
}
|
||||
|
||||
/**
|
||||
* The pitch or roll of the device, rotation along the ``x-axis`` or ``y-axis``, in degrees.
|
||||
* @param kind TODO
|
||||
*/
|
||||
//% help=input/rotation weight=52
|
||||
//% blockId=device_get_rotation block="rotation (°)|%NAME" blockGap=8 icon="\uf197"
|
||||
//% parts="accelerometer"
|
||||
int rotation(Rotation kind) {
|
||||
switch (kind) {
|
||||
case Rotation::Pitch: return uBit.accelerometer.getPitch();
|
||||
case Rotation::Roll: return uBit.accelerometer.getRoll();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the magnetic force value in ``micro-Teslas`` (``µT``). This function is not supported in the simulator.
|
||||
* @param dimension TODO
|
||||
*/
|
||||
//% help=input/magnetic-force weight=51
|
||||
//% blockId=device_get_magnetic_force block="magnetic force (µT)|%NAME" blockGap=8 icon="\uf076"
|
||||
//% parts="compass"
|
||||
int magneticForce(Dimension dimension) {
|
||||
if (!uBit.compass.isCalibrated())
|
||||
uBit.compass.calibrate();
|
||||
|
||||
switch (dimension) {
|
||||
case Dimension::X: return uBit.compass.getX() / 1000;
|
||||
case Dimension::Y: return uBit.compass.getY() / 1000;
|
||||
case Dimension::Z: return uBit.compass.getZ() / 1000;
|
||||
case Dimension::Strength: return uBit.compass.getFieldStrength() / 1000;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the number of milliseconds elapsed since power on.
|
||||
*/
|
||||
//% help=input/running-time weight=50
|
||||
//% blockId=device_get_running_time block="running time (ms)" icon="\uf017"
|
||||
int runningTime() {
|
||||
return system_timer_current_time();
|
||||
}
|
||||
|
||||
/**
|
||||
* Obsolete, compass calibration is automatic.
|
||||
*/
|
||||
//% help=input/calibrate weight=0
|
||||
void calibrate() { }
|
||||
|
||||
/**
|
||||
* Sets the accelerometer sample range in gravities.
|
||||
* @param range a value describe the maximum strengh of acceleration measured
|
||||
*/
|
||||
//% help=input/set-accelerometer-range
|
||||
//% blockId=device_set_accelerometer_range block="set accelerometer|range %range" icon="\uf135"
|
||||
//% weight=5
|
||||
//% parts="accelerometer"
|
||||
void setAccelerometerRange(AcceleratorRange range) {
|
||||
uBit.accelerometer.setRange((int)range);
|
||||
}
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
/**
|
||||
* Events and data from sensors
|
||||
*/
|
||||
//% color=#B4009E weight=99
|
||||
namespace input {
|
||||
/**
|
||||
* Attaches code to run when the screen is facing up.
|
||||
* @param body TODO
|
||||
*/
|
||||
//% help=input/on-screen-up
|
||||
export function onScreenUp(body: Action): void {
|
||||
onGesture(Gesture.ScreenUp, body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attaches code to run when the screen is facing down.
|
||||
* @param body TODO
|
||||
*/
|
||||
//% help=input/on-screen-down
|
||||
export function onScreenDown(body: Action): void {
|
||||
onGesture(Gesture.ScreenDown, body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attaches code to run when the device is shaken.
|
||||
* @param body TODO
|
||||
*/
|
||||
//% help=input/on-shake
|
||||
export function onShake(body: Action): void {
|
||||
onGesture(Gesture.Shake, body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attaches code to run when the logo is oriented upwards and the board is vertical.
|
||||
* @param body TODO
|
||||
*/
|
||||
//% help=input/on-logo-up
|
||||
export function onLogoUp(body: Action): void {
|
||||
onGesture(Gesture.LogoUp, body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attaches code to run when the logo is oriented downwards and the board is vertical.
|
||||
* @param body TODO
|
||||
*/
|
||||
//% help=input/on-logo-down
|
||||
export function onLogoDown(body: Action): void {
|
||||
onGesture(Gesture.LogoDown, body);
|
||||
}
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
#include "pxt.h"
|
||||
#include "ManagedBuffer.h"
|
||||
|
||||
using namespace pxt;
|
||||
MicroBitPin *getPin(int id);
|
||||
typedef ImageData* Image;
|
||||
typedef BufferData* Buffer;
|
||||
|
@ -1,112 +0,0 @@
|
||||
#include "ksbit.h"
|
||||
|
||||
enum class DisplayMode_ {
|
||||
//% block="black and white"
|
||||
BackAndWhite = DISPLAY_MODE_BLACK_AND_WHITE,
|
||||
//% block="greyscale"
|
||||
Greyscale = DISPLAY_MODE_GREYSCALE,
|
||||
// TODO DISPLAY_MODE_BLACK_AND_WHITE_LIGHT_SENSE
|
||||
};
|
||||
|
||||
//% color=3 weight=35
|
||||
namespace led {
|
||||
|
||||
/**
|
||||
* Turn on the specified LED using x, y coordinates (x is horizontal, y is vertical). (0,0) is upper left.
|
||||
* @param x TODO
|
||||
* @param y TODO
|
||||
*/
|
||||
//% help=led/plot weight=78
|
||||
//% blockId=device_plot block="plot|x %x|y %y" icon="\uf205" blockGap=8
|
||||
//% parts="ledmatrix"
|
||||
void plot(int x, int y) {
|
||||
uBit.display.image.setPixelValue(x, y, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn off the specified LED using x, y coordinates (x is horizontal, y is vertical). (0,0) is upper left.
|
||||
* @param x TODO
|
||||
* @param y TODO
|
||||
*/
|
||||
//% help=led/unplot weight=77
|
||||
//% blockId=device_unplot block="unplot|x %x|y %y" icon="\uf204" blockGap=8
|
||||
//% parts="ledmatrix"
|
||||
void unplot(int x, int y) {
|
||||
uBit.display.image.setPixelValue(x, y, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the on/off state of the specified LED using x, y coordinates. (0,0) is upper left.
|
||||
* @param x TODO
|
||||
* @param y TODO
|
||||
*/
|
||||
//% help=led/point weight=76
|
||||
//% blockId=device_point block="point|x %x|y %y" icon="\uf10c"
|
||||
//% parts="ledmatrix"
|
||||
bool point(int x, int y) {
|
||||
int pix = uBit.display.image.getPixelValue(x, y);
|
||||
return pix > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the screen brightness from 0 (off) to 255 (full bright).
|
||||
*/
|
||||
//% help=led/brightness weight=60
|
||||
//% blockId=device_get_brightness block="brightness" icon="\uf042" blockGap=8
|
||||
//% parts="ledmatrix"
|
||||
int brightness() {
|
||||
return uBit.display.getBrightness();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the screen brightness from 0 (off) to 255 (full bright).
|
||||
* @param value the brightness value, eg:255, 127, 0
|
||||
*/
|
||||
//% help=led/set-brightness weight=59
|
||||
//% blockId=device_set_brightness block="set brightness %value" icon="\uf042"
|
||||
//% parts="ledmatrix"
|
||||
void setBrightness(int value) {
|
||||
uBit.display.setBrightness(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancels the current animation and clears other pending animations.
|
||||
*/
|
||||
//% weight=50 help=led/stop-animation
|
||||
//% blockId=device_stop_animation block="stop animation" icon="\uf04d"
|
||||
//% parts="ledmatrix"
|
||||
void stopAnimation() {
|
||||
uBit.display.stopAnimation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the display mode between black and white and greyscale for rendering LEDs.
|
||||
* @param mode TODO
|
||||
*/
|
||||
//% weight=1 help=led/set-display-mode
|
||||
//% parts="ledmatrix"
|
||||
void setDisplayMode(DisplayMode_ mode) {
|
||||
uBit.display.setDisplayMode((DisplayMode)mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes a screenshot of the LED screen and returns an image.
|
||||
*/
|
||||
//% help=led/screenshot
|
||||
//% parts="ledmatrix"
|
||||
Image screenshot() {
|
||||
return uBit.display.screenShot().leakData();
|
||||
/*
|
||||
let Image img;
|
||||
img = image.createImage("");
|
||||
for (let i = 0; i < 5; i++) {
|
||||
for (let j = 0; j < 5; j++) {
|
||||
if (led.point(i, j)) {
|
||||
img.setPixel(i, j, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
return img;
|
||||
*/
|
||||
}
|
||||
}
|
@ -1,139 +0,0 @@
|
||||
/**
|
||||
* Control of the LED screen.
|
||||
*/
|
||||
//% color=#5C2D91 weight=97
|
||||
namespace led {
|
||||
|
||||
// what's the current high value
|
||||
let barGraphHigh = 0;
|
||||
// when was the current high value recorded
|
||||
let barGraphHighLast = 0;
|
||||
|
||||
/**
|
||||
* Displays a vertical bar graph based on the `value` and `high` value.
|
||||
* If `high` is 0, the chart gets adjusted automatically.
|
||||
* @param value current value to plot
|
||||
* @param high maximum value. If 0, maximum value adjusted automatically, eg: 0
|
||||
*/
|
||||
//% help=led/plot-bar-graph weight=20
|
||||
//% blockId=device_plot_bar_graph block="plot bar graph of %value |up to %high" icon="\uf080" blockExternalInputs=true
|
||||
//% parts="ledmatrix"
|
||||
export function plotBarGraph(value: number, high: number): void {
|
||||
let now = input.runningTime();
|
||||
serial.writeString(value.toString() + "\r\n");
|
||||
value = Math.abs(value);
|
||||
|
||||
if (high != 0) barGraphHigh = high;
|
||||
else if (value > barGraphHigh || now - barGraphHighLast > 10000) {
|
||||
barGraphHigh = value;
|
||||
barGraphHighLast = now;
|
||||
}
|
||||
|
||||
barGraphHigh = Math.max(barGraphHigh, 16);
|
||||
|
||||
let v = (value * 15) / barGraphHigh;
|
||||
let k = 0;
|
||||
for (let y = 4; y >= 0; --y) {
|
||||
for (let x = 0; x < 3; ++x) {
|
||||
if (k > v) {
|
||||
unplot(2 - x, y);
|
||||
unplot(2 + x, y);
|
||||
} else {
|
||||
plot(2 - x, y);
|
||||
plot(2 + x, y);
|
||||
}
|
||||
++k;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggles a particular pixel
|
||||
* @param x TODO
|
||||
* @param y TODO
|
||||
*/
|
||||
//% help=led/toggle weight=77
|
||||
//% blockId=device_led_toggle block="toggle|x %x|y %y" icon="\uf204" blockGap=8
|
||||
//% parts="ledmatrix"
|
||||
export function toggle(x: number, y: number): void {
|
||||
if (led.point(x, y)) {
|
||||
led.unplot(x, y);
|
||||
} else {
|
||||
led.plot(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns all LEDS on
|
||||
*/
|
||||
//% help=led/plot-all
|
||||
//% parts="ledmatrix"
|
||||
export function plotAll(): void {
|
||||
for (let i = 0; i < 5; i++) {
|
||||
for (let j = 0; j < 5; j++) {
|
||||
led.plot(i, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Inverts the current LED display
|
||||
*/
|
||||
//% help=led/toggle-all
|
||||
//% parts="ledmatrix"
|
||||
export function toggleAll(): void {
|
||||
for (let i = 0; i < 5; i++) {
|
||||
for (let j = 0; j < 5; j++) {
|
||||
led.toggle(i, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fades in the screen display.
|
||||
* @param ms TODO
|
||||
*/
|
||||
//% help=led/fade-in
|
||||
//% parts="ledmatrix"
|
||||
export function fadeIn(ms: number = 700): void {
|
||||
if (ms < 20) {
|
||||
led.setBrightness(255);
|
||||
return;
|
||||
}
|
||||
let dt = 50;
|
||||
let brightness = led.brightness();
|
||||
let start = input.runningTime();
|
||||
let elapsed = 0;
|
||||
while (elapsed < ms) {
|
||||
led.setBrightness(brightness + ((255 - brightness) * elapsed) / ms);
|
||||
basic.pause(dt);
|
||||
elapsed = input.runningTime() - start;
|
||||
}
|
||||
led.setBrightness(255);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fades out the screen brightness.
|
||||
* @param ms TODO
|
||||
*/
|
||||
//% help=led/fade-out
|
||||
//% parts="ledmatrix"
|
||||
export function fadeOut(ms: number = 700): void {
|
||||
if (ms < 20) {
|
||||
led.setBrightness(0);
|
||||
return;
|
||||
}
|
||||
let brightness = led.brightness();
|
||||
let dt = 50;
|
||||
let start = input.runningTime();
|
||||
let elapsed = 0;
|
||||
while (elapsed < ms) {
|
||||
led.setBrightness(brightness - (brightness * elapsed) / ms);
|
||||
basic.pause(dt);
|
||||
elapsed = input.runningTime() - start;
|
||||
}
|
||||
led.setBrightness(0);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
namespace messages {
|
||||
var streamid: string;
|
||||
|
||||
export function setStreamId(id: string) {
|
||||
streamid = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new message that includes the board serial number and the stream id if any
|
||||
*/
|
||||
export function createMessage() : Message {
|
||||
let m = new Message();
|
||||
m.addNumber('board', control.deviceSerialNumber());
|
||||
if (streamid != null && streamid.length > 0)
|
||||
m.addString('stream', streamid);
|
||||
return m;
|
||||
}
|
||||
|
||||
/**
|
||||
* A message containig custom data
|
||||
*/
|
||||
export class Message {
|
||||
private buffer:string = '';
|
||||
|
||||
/**
|
||||
* Adds a string field to the message
|
||||
*/
|
||||
//%
|
||||
public addString(name:string, value:string) {
|
||||
if (this.buffer.length > 0) this.buffer += ',';
|
||||
this.buffer += name + ':"' + value + '"';
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a number field to the message
|
||||
*/
|
||||
//%
|
||||
public addNumber(name:string, value: number) {
|
||||
if (this.buffer.length > 0) this.buffer += ',';
|
||||
this.buffer += name + ':' + value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the message to a JSON payload
|
||||
*/
|
||||
//%
|
||||
public toJSON() : string {
|
||||
return '{' + this.buffer + '}';
|
||||
}
|
||||
}
|
||||
}
|
@ -1,233 +0,0 @@
|
||||
enum Note {
|
||||
//% blockIdentity=music.noteFrequency
|
||||
C = 262,
|
||||
//% block=C#
|
||||
//% blockIdentity=music.noteFrequency
|
||||
CSharp = 277,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
D = 294,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
Eb = 311,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
E = 330,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
F = 349,
|
||||
//% block=F#
|
||||
//% blockIdentity=music.noteFrequency
|
||||
FSharp = 370,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
G = 392,
|
||||
//% block=G#
|
||||
//% blockIdentity=music.noteFrequency
|
||||
GSharp = 415,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
A = 440,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
Bb = 466,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
B = 494,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
C3 = 131,
|
||||
//% block=C#3
|
||||
//% blockIdentity=music.noteFrequency
|
||||
CSharp3 = 139,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
D3 = 147,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
Eb3 = 156,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
E3 = 165,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
F3 = 175,
|
||||
//% block=F#3
|
||||
//% blockIdentity=music.noteFrequency
|
||||
FSharp3 = 185,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
G3 = 196,
|
||||
//% block=G#3
|
||||
//% blockIdentity=music.noteFrequency
|
||||
GSharp3 = 208,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
A3 = 220,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
Bb3 = 233,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
B3 = 247,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
C4 = 262,
|
||||
//% block=C#4
|
||||
//% blockIdentity=music.noteFrequency
|
||||
CSharp4 = 277,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
D4 = 294,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
Eb4 = 311,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
E4 = 330,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
F4 = 349,
|
||||
//% block=F#4
|
||||
//% blockIdentity=music.noteFrequency
|
||||
FSharp4 = 370,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
G4 = 392,
|
||||
//% block=G#4
|
||||
//% blockIdentity=music.noteFrequency
|
||||
GSharp4 = 415,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
A4 = 440,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
Bb4 = 466,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
B4 = 494,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
C5 = 523,
|
||||
//% block=C#5
|
||||
//% blockIdentity=music.noteFrequency
|
||||
CSharp5 = 555,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
D5 = 587,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
Eb5 = 622,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
E5 = 659,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
F5 = 698,
|
||||
//% block=F#5
|
||||
//% blockIdentity=music.noteFrequency
|
||||
FSharp5 = 740,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
G5 = 784,
|
||||
//% block=G#5
|
||||
//% blockIdentity=music.noteFrequency
|
||||
GSharp5 = 831,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
A5 = 880,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
Bb5 = 932,
|
||||
//% blockIdentity=music.noteFrequency
|
||||
B5 = 989,
|
||||
}
|
||||
|
||||
enum BeatFraction {
|
||||
//% block=1
|
||||
Whole = 1,
|
||||
//% block="1/2"
|
||||
Half = 2,
|
||||
//% block="1/4"
|
||||
Quarter = 4,
|
||||
//% block="1/8"
|
||||
Eighth = 8,
|
||||
//% block="1/16"
|
||||
Sixteenth = 16
|
||||
}
|
||||
|
||||
/**
|
||||
* Generation of music tones through pin ``P0``.
|
||||
*/
|
||||
//% color=#D83B01 weight=98
|
||||
namespace music {
|
||||
let beatsPerMinute: number = 120;
|
||||
|
||||
/**
|
||||
* Plays a tone through pin ``P0`` for the given duration.
|
||||
* @param frequency pitch of the tone to play in Hertz (Hz)
|
||||
* @param ms tone duration in milliseconds (ms)
|
||||
*/
|
||||
//% help=music/play-tone weight=90
|
||||
//% blockId=device_play_note block="play|tone %note=device_note|for %duration=device_beat" icon="\uf025" blockGap=8
|
||||
//% parts="headphone"
|
||||
export function playTone(frequency: number, ms: number): void {
|
||||
pins.analogSetPitchPin(AnalogPin.P0);
|
||||
pins.analogPitch(frequency, ms);
|
||||
}
|
||||
|
||||
/**
|
||||
* Plays a tone through pin ``P0``.
|
||||
* @param frequency pitch of the tone to play in Hertz (Hz)
|
||||
*/
|
||||
//% help=music/ring-tone weight=80
|
||||
//% blockId=device_ring block="ring tone (Hz)|%note=device_note" icon="\uf025" blockGap=8
|
||||
//% parts="headphone"
|
||||
export function ringTone(frequency: number): void {
|
||||
pins.analogSetPitchPin(AnalogPin.P0);
|
||||
pins.analogPitch(frequency, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rests (plays nothing) for a specified time through pin ``P0``.
|
||||
* @param ms rest duration in milliseconds (ms)
|
||||
*/
|
||||
//% help=music/rest weight=79
|
||||
//% blockId=device_rest block="rest(ms)|%duration=device_beat"
|
||||
//% parts="headphone"
|
||||
export function rest(ms: number): void {
|
||||
playTone(0, ms);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the frequency of a note.
|
||||
* @param name the note name
|
||||
*/
|
||||
//% weight=50 help=music/note-frequency
|
||||
//% blockId=device_note block="%note"
|
||||
//% shim=TD_ID
|
||||
export function noteFrequency(name: Note): number {
|
||||
return name;
|
||||
}
|
||||
|
||||
function init() {
|
||||
if (beatsPerMinute <= 0) beatsPerMinute = 120;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the duration of a beat in milli-seconds
|
||||
*/
|
||||
//% help=music/beat weight=49
|
||||
//% blockId=device_beat block="%fraction|beat"
|
||||
export function beat(fraction?: BeatFraction): number {
|
||||
init();
|
||||
if (fraction == null) fraction = BeatFraction.Whole;
|
||||
let beat = 60000 / beatsPerMinute;
|
||||
if (fraction == BeatFraction.Whole) return beat;
|
||||
else if (fraction == BeatFraction.Half) return beat / 2;
|
||||
else if (fraction == BeatFraction.Quarter) return beat / 4
|
||||
else if (fraction == BeatFraction.Eighth) return beat / 8;
|
||||
else return beat / 16;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the tempo in beats per minute. Tempo is the speed (bpm = beats per minute) at which notes play. The larger the tempo value, the faster the notes will play.
|
||||
*/
|
||||
//% help=music/tempo weight=40
|
||||
//% blockId=device_tempo block="tempo (bpm)" blockGap=8
|
||||
export function tempo(): number {
|
||||
init();
|
||||
return beatsPerMinute;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the tempo by the specified amount
|
||||
* @param bpm The change in beats per minute to the tempo, eg: 20
|
||||
*/
|
||||
//% help=music/change-tempo weight=39
|
||||
//% blockId=device_change_tempo block="change tempo by (bpm)|%value" blockGap=8
|
||||
export function changeTempoBy(bpm: number): void {
|
||||
init();
|
||||
setTempo(beatsPerMinute + bpm);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the tempo to the specified amount
|
||||
* @param bpm The new tempo in beats per minute, eg: 120
|
||||
*/
|
||||
//% help=music/set-tempo weight=38
|
||||
//% blockId=device_set_tempo block="set tempo to (bpm)|%value"
|
||||
export function setTempo(bpm: number): void {
|
||||
init();
|
||||
if (bpm > 0) {
|
||||
beatsPerMinute = Math.max(1, bpm);
|
||||
}
|
||||
}
|
||||
}
|
@ -1 +0,0 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="142" height="180" viewBox="0 0 142 180"><rect ry=".3" rx="1" y="58.615" x="-8.878" height="23.571" width="17.143" transform="rotate(-45)" fill="#b3b3b3"/><rect ry=".3" rx="1" y="32.043" x="-8.878" height="23.571" width="17.143" transform="rotate(-45)" fill="#b3b3b3"/><path d="M.346 7.296c-.394.39-.31 4.797-.18 4.898l13.404 10.18c.117.12.337 4.76.73 4.368l5.506-5.56.01.01 6.51-6.444c.39-.392-4.25-.614-4.366-.73L11.777.612c-.1-.132-4.51-.215-4.898.18L4.087 3.636l-.01-.01-3.73 3.67z" fill="#b3b3b3"/><rect ry="6.85" rx="4.571" y="84.758" x="-20.128" height="75.571" width="39.643" transform="rotate(-45)"/><rect ry=".374" rx="1.038" y="29.442" x="-8.925" height="2.228" width="17.238" transform="rotate(-45)" fill="#fff"/><rect ry=".374" rx="1.038" y="55.939" x="-8.925" height="2.228" width="17.238" transform="rotate(-45)" fill="#fff"/><rect ry=".374" rx="1.038" y="82.392" x="-8.925" height="2.228" width="17.238" transform="rotate(-45)" fill="#fff"/><rect ry="2.317" rx="2.183" y="158.876" x="-9.774" height="25.568" width="18.935" transform="rotate(-45)"/><path d="M128.588 128.82s14.97 11.165 7.547 26.35c-8.426 17.24-25.57 20.653-25.57 20.653" fill="none" stroke="#000" stroke-width="6.6" stroke-linecap="round" stroke-linejoin="round"/></svg>
|
Before Width: | Height: | Size: 1.3 KiB |
@ -1,35 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<svg viewBox="0 0 500 500" xmlns="http://www.w3.org/2000/svg">
|
||||
<g transform="matrix(1, 0, 0, 1, -0.00023, -58.230297)">
|
||||
<ellipse style="fill: rgb(70, 70, 70);" cx="250.58" cy="308.81" rx="215" ry="215"/>
|
||||
<ellipse style="fill: rgb(0, 0, 0);" transform="matrix(1, 0, 0, 1.000001, -232.069031, 248.780606)" cx="482.069" cy="198.188" rx="23.028" ry="23.028"/>
|
||||
<ellipse style="fill: rgb(0, 0, 0);" transform="matrix(1, 0, 0, 0.999999, -232.067871, 110.041956)" cx="482.067" cy="198.188" rx="23.028" ry="23.028"/>
|
||||
<ellipse style="fill: rgb(0, 0, 0);" cx="389.12" cy="308.23" rx="23.028" ry="23.028"/>
|
||||
<ellipse style="fill: rgb(0, 0, 0);" cx="110.88" cy="308.23" rx="23.028" ry="23.028"/>
|
||||
<ellipse style="fill: rgb(0, 0, 0);" cx="250" cy="169.393" rx="23.028" ry="23.028"/>
|
||||
<g transform="matrix(1, 0, 0, 1, -0.000009, 0.000015)">
|
||||
<ellipse style="fill: rgb(0, 0, 0);" cx="250" cy="238.513" rx="23.028" ry="23.028" transform="matrix(1.000001, 0, 0, 0.999999, 69.996739, 69.71816)"/>
|
||||
<ellipse style="fill: rgb(0, 0, 0);" transform="matrix(1, 0, 0, 0.999999, -302.064453, 110.043115)" cx="482.064" cy="198.188" rx="23.028" ry="23.028"/>
|
||||
</g>
|
||||
<g transform="matrix(0.866026, 0.5, -0.5, 0.866026, 7.386552, -105.261086)">
|
||||
<ellipse style="fill: rgb(0, 0, 0);" transform="matrix(0.999999, 0, 0, 0.999999, -65.212313, 177.387415)" cx="482.068" cy="198.188" rx="23.028" ry="23.028"/>
|
||||
<ellipse style="fill: rgb(0, 0, 0);" cx="555.975" cy="236.836" rx="23.028" ry="23.028"/>
|
||||
<ellipse style="fill: rgb(0, 0, 0);" cx="277.735" cy="236.836" rx="23.028" ry="23.028"/>
|
||||
<ellipse style="fill: rgb(0, 0, 0);" cx="416.855" cy="97.999" rx="23.028" ry="23.028"/>
|
||||
</g>
|
||||
<g transform="matrix(0.5, 0.866026, -0.866026, 0.5, 246.635941, -171.170502)">
|
||||
<ellipse style="fill: rgb(0, 0, 0);" transform="matrix(0.999999, 0, 0, 0.999999, -65.212313, 177.387415)" cx="482.068" cy="198.188" rx="23.028" ry="23.028"/>
|
||||
<ellipse style="fill: rgb(0, 0, 0);" cx="555.975" cy="236.836" rx="23.028" ry="23.028"/>
|
||||
<ellipse style="fill: rgb(0, 0, 0);" cx="277.735" cy="236.836" rx="23.028" ry="23.028"/>
|
||||
<ellipse style="fill: rgb(0, 0, 0);" cx="416.855" cy="97.999" rx="23.028" ry="23.028"/>
|
||||
</g>
|
||||
<g transform="matrix(-0.5, 0.866026, -0.866026, -0.5, 641.934998, 245.84082)">
|
||||
<ellipse style="fill: rgb(0, 0, 0);" cx="250" cy="238.513" rx="23.028" ry="23.028" transform="matrix(1.000001, 0, 0, 0.999999, 69.996739, 69.71816)"/>
|
||||
<ellipse style="fill: rgb(0, 0, 0);" transform="matrix(1, 0, 0, 0.999999, -302.064453, 110.043115)" cx="482.064" cy="198.188" rx="23.028" ry="23.028"/>
|
||||
</g>
|
||||
<g transform="matrix(-0.500001, -0.866026, 0.866026, -0.500001, 108.063393, 678.85083)">
|
||||
<ellipse style="fill: rgb(0, 0, 0);" cx="250" cy="238.513" rx="23.028" ry="23.028" transform="matrix(1.000001, 0, 0, 0.999999, 69.996739, 69.71816)"/>
|
||||
<ellipse style="fill: rgb(0, 0, 0);" transform="matrix(1, 0, 0, 0.999999, -302.064453, 110.043115)" cx="482.064" cy="198.188" rx="23.028" ry="23.028"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
Before Width: | Height: | Size: 3.1 KiB |
@ -1,318 +0,0 @@
|
||||
#include "ksbit.h"
|
||||
|
||||
enum class DigitalPin {
|
||||
P0 = MICROBIT_ID_IO_P0,
|
||||
P1 = MICROBIT_ID_IO_P1,
|
||||
P2 = MICROBIT_ID_IO_P2,
|
||||
P3 = MICROBIT_ID_IO_P3,
|
||||
P4 = MICROBIT_ID_IO_P4,
|
||||
P5 = MICROBIT_ID_IO_P5,
|
||||
P6 = MICROBIT_ID_IO_P6,
|
||||
P7 = MICROBIT_ID_IO_P7,
|
||||
//P8 = MICROBIT_ID_IO_P8,
|
||||
P9 = MICROBIT_ID_IO_P9,
|
||||
P10 = MICROBIT_ID_IO_P10,
|
||||
P11 = MICROBIT_ID_IO_P11,
|
||||
//P12 = MICROBIT_ID_IO_P12,
|
||||
//P13 = MICROBIT_ID_IO_P13,
|
||||
//P14 = MICROBIT_ID_IO_P14,
|
||||
//P15 = MICROBIT_ID_IO_P15,
|
||||
//P16 = MICROBIT_ID_IO_P16,
|
||||
P19 = MICROBIT_ID_IO_P19,
|
||||
P20 = MICROBIT_ID_IO_P20,
|
||||
};
|
||||
|
||||
enum class AnalogPin {
|
||||
P0 = MICROBIT_ID_IO_P0,
|
||||
P1 = MICROBIT_ID_IO_P1,
|
||||
P2 = MICROBIT_ID_IO_P2,
|
||||
P3 = MICROBIT_ID_IO_P3,
|
||||
P4 = MICROBIT_ID_IO_P4,
|
||||
P10 = MICROBIT_ID_IO_P10,
|
||||
};
|
||||
|
||||
enum class PulseValue {
|
||||
High = MICROBIT_PIN_EVT_PULSE_HI,
|
||||
Low = MICROBIT_PIN_EVT_PULSE_LO
|
||||
};
|
||||
|
||||
enum class PinPullMode {
|
||||
//% block="down"
|
||||
PullDown = 0,
|
||||
//% block="up"
|
||||
PullUp = 1,
|
||||
//% block="none"
|
||||
PullNone = 2
|
||||
};
|
||||
|
||||
MicroBitPin *getPin(int id) {
|
||||
switch (id) {
|
||||
case MICROBIT_ID_IO_P0: return &uBit.io.P0;
|
||||
case MICROBIT_ID_IO_P1: return &uBit.io.P1;
|
||||
case MICROBIT_ID_IO_P2: return &uBit.io.P2;
|
||||
case MICROBIT_ID_IO_P3: return &uBit.io.P3;
|
||||
case MICROBIT_ID_IO_P4: return &uBit.io.P4;
|
||||
case MICROBIT_ID_IO_P5: return &uBit.io.P5;
|
||||
case MICROBIT_ID_IO_P6: return &uBit.io.P6;
|
||||
case MICROBIT_ID_IO_P7: return &uBit.io.P7;
|
||||
//case MICROBIT_ID_IO_P8: return &uBit.io.P8;
|
||||
case MICROBIT_ID_IO_P9: return &uBit.io.P9;
|
||||
case MICROBIT_ID_IO_P10: return &uBit.io.P10;
|
||||
case MICROBIT_ID_IO_P11: return &uBit.io.P11;
|
||||
//case MICROBIT_ID_IO_P12: return &uBit.io.P12;
|
||||
//case MICROBIT_ID_IO_P13: return &uBit.io.P13;
|
||||
//case MICROBIT_ID_IO_P14: return &uBit.io.P14;
|
||||
//case MICROBIT_ID_IO_P15: return &uBit.io.P15;
|
||||
//case MICROBIT_ID_IO_P16: return &uBit.io.P16;
|
||||
case MICROBIT_ID_IO_P19: return &uBit.io.P19;
|
||||
case MICROBIT_ID_IO_P20: return &uBit.io.P20;
|
||||
default: return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
namespace pins {
|
||||
#define PINOP(op) \
|
||||
MicroBitPin *pin = getPin((int)name); \
|
||||
if (!pin) return; \
|
||||
pin->op
|
||||
|
||||
#define PINREAD(op) \
|
||||
MicroBitPin *pin = getPin((int)name); \
|
||||
if (!pin) return 0; \
|
||||
return pin->op
|
||||
|
||||
|
||||
//%
|
||||
MicroBitPin *getPinAddress(int id) {
|
||||
return getPin(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the specified pin or connector as either 0 or 1
|
||||
* @param name pin to read from
|
||||
*/
|
||||
//% help=pins/digital-read-pin weight=30
|
||||
//% blockId=device_get_digital_pin block="digital read|pin %name" blockGap=8
|
||||
int digitalReadPin(DigitalPin name) {
|
||||
PINREAD(getDigitalValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a pin or connector value to either 0 or 1.
|
||||
* @param name pin to write to
|
||||
* @param value value to set on the pin, 1 eg,0
|
||||
*/
|
||||
//% help=pins/digital-write-pin weight=29
|
||||
//% blockId=device_set_digital_pin block="digital write|pin %name|to %value"
|
||||
void digitalWritePin(DigitalPin name, int value) {
|
||||
PINOP(setDigitalValue(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the connector value as analog, that is, as a value comprised between 0 and 1023.
|
||||
* @param name pin to write to
|
||||
*/
|
||||
//% help=pins/analog-read-pin weight=25
|
||||
//% blockId=device_get_analog_pin block="analog read|pin %name" blockGap="8"
|
||||
int analogReadPin(AnalogPin name) {
|
||||
PINREAD(getAnalogValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the connector value as analog. Value must be comprised between 0 and 1023.
|
||||
* @param name pin name to write to
|
||||
* @param value value to write to the pin between ``0`` and ``1023``. eg:1023,0
|
||||
*/
|
||||
//% help=pins/analog-write-pin weight=24
|
||||
//% blockId=device_set_analog_pin block="analog write|pin %name|to %value" blockGap=8
|
||||
void analogWritePin(AnalogPin name, int value) {
|
||||
PINOP(setAnalogValue(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the Pulse-width modulation (PWM) of the analog output to the given value in **microseconds** or `1/1000` milliseconds.
|
||||
* If this pin is not configured as an analog output (using `analog write pin`), the operation has no effect.
|
||||
* @param name analog pin to set period to
|
||||
* @param micros period in micro seconds. eg:20000
|
||||
*/
|
||||
//% help=pins/analog-set-period weight=23 blockGap=8
|
||||
//% blockId=device_set_analog_period block="analog set period|pin %pin|to (µs)%micros"
|
||||
void analogSetPeriod(AnalogPin name, int micros) {
|
||||
PINOP(setAnalogPeriodUs(micros));
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures this pin to a digital input, and generates events where the timestamp is the duration that this pin was either ``high`` or ``low``.
|
||||
*/
|
||||
//% help=pins/on-pulsed weight=22 blockGap=8
|
||||
//% blockId=pins_on_pulsed block="on|pin %pin|pulsed %pulse"
|
||||
void onPulsed(DigitalPin name, PulseValue pulse, Action body) {
|
||||
MicroBitPin* pin = getPin((int)name);
|
||||
if (!pin) return;
|
||||
|
||||
pin->eventOn(MICROBIT_PIN_EVENT_ON_PULSE);
|
||||
registerWithDal((int)name, (int)pulse, body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the duration of the last pulse in micro-seconds. This function should be called from a ``onPulsed`` handler.
|
||||
*/
|
||||
//% help=pins/pulse-duration
|
||||
//% blockId=pins_pulse_duration block="pulse duration (µs)"
|
||||
//% weight=21 blockGap=8
|
||||
int pulseDuration() {
|
||||
return pxt::lastEvent.timestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the duration of a pulse in microseconds
|
||||
* @param name the pin which measures the pulse
|
||||
* @param value the value of the pulse (default high)
|
||||
* @param maximum duration in micro-seconds
|
||||
*/
|
||||
//% blockId="pins_pulse_in" block="pulse in (µs)|pin %name|pulsed %value"
|
||||
//% weight=20
|
||||
int pulseIn(DigitalPin name, PulseValue value, int maxDuration = 2000000) {
|
||||
MicroBitPin* pin = getPin((int)name);
|
||||
if (!pin) return 0;
|
||||
|
||||
int pulse = value == PulseValue::High ? 1 : 0;
|
||||
uint64_t tick = system_timer_current_time_us();
|
||||
uint64_t maxd = (uint64_t)maxDuration;
|
||||
while(pin->getDigitalValue() != pulse) {
|
||||
if(system_timer_current_time_us() - tick > maxd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint64_t start = system_timer_current_time_us();
|
||||
while(pin->getDigitalValue() == pulse) {
|
||||
if(system_timer_current_time_us() - tick > maxd)
|
||||
return 0;
|
||||
}
|
||||
uint64_t end = system_timer_current_time_us();
|
||||
return end - start;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a value to the servo, controlling the shaft accordingly. On a standard servo, this will set the angle of the shaft (in degrees), moving the shaft to that orientation. On a continuous rotation servo, this will set the speed of the servo (with ``0`` being full-speed in one direction, ``180`` being full speed in the other, and a value near ``90`` being no movement).
|
||||
* @param name pin to write to
|
||||
* @param value angle or rotation speed, eg:180,90,0
|
||||
*/
|
||||
//% help=pins/servo-write-pin weight=20
|
||||
//% blockId=device_set_servo_pin block="servo write|pin %name|to %value" blockGap=8
|
||||
void servoWritePin(AnalogPin name, int value) {
|
||||
PINOP(setServoValue(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures this IO pin as an analog/pwm output, configures the period to be 20 ms, and sets the pulse width, based on the value it is given **microseconds** or `1/1000` milliseconds.
|
||||
* @param name pin name
|
||||
* @param micros pulse duration in micro seconds, eg:1500
|
||||
*/
|
||||
//% help=pins/servo-set-pulse weight=19
|
||||
//% blockId=device_set_servo_pulse block="servo set pulse|pin %value|to (µs) %micros"
|
||||
void servoSetPulse(AnalogPin name, int micros) {
|
||||
PINOP(setServoPulseUs(micros));
|
||||
}
|
||||
|
||||
|
||||
MicroBitPin* pitchPin = NULL;
|
||||
|
||||
/**
|
||||
* Sets the pin used when using `pins->analog pitch`.
|
||||
* @param name TODO
|
||||
*/
|
||||
//% help=pins/analog-set-pitch weight=12
|
||||
void analogSetPitchPin(AnalogPin name) {
|
||||
pitchPin = getPin((int)name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Emits a Pulse-width modulation (PWM) signal to the current pitch pin. Use `analog set pitch pin` to define the pitch pin.
|
||||
* @param frequency TODO
|
||||
* @param ms TODO
|
||||
*/
|
||||
//% help=pins/analog-pitch weight=14 async
|
||||
void analogPitch(int frequency, int ms) {
|
||||
if (pitchPin == NULL) return;
|
||||
if (frequency <= 0) {
|
||||
pitchPin->setAnalogValue(0);
|
||||
} else {
|
||||
pitchPin->setAnalogValue(512);
|
||||
pitchPin->setAnalogPeriodUs(1000000/frequency);
|
||||
}
|
||||
|
||||
if (ms > 0) {
|
||||
fiber_sleep(ms);
|
||||
pitchPin->setAnalogValue(0);
|
||||
// TODO why do we use wait_ms() here? it's a busy wait I think
|
||||
wait_ms(5);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Configures the pull of this pin.
|
||||
* @param name pin to set the pull mode on
|
||||
* @param pull one of the mbed pull configurations: PullUp, PullDown, PullNone
|
||||
*/
|
||||
//% help=pins/set-pull weight=3
|
||||
//% blockId=device_set_pull block="set pull|pin %pin|to %pull"
|
||||
void setPull(DigitalPin name, PinPullMode pull) {
|
||||
PinMode m = pull == PinPullMode::PullDown
|
||||
? PinMode::PullDown
|
||||
: pull == PinPullMode::PullUp ? PinMode::PullUp
|
||||
: PinMode::PullNone;
|
||||
PINOP(setPull(m));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new zero-initialized buffer.
|
||||
* @param size number of bytes in the buffer
|
||||
*/
|
||||
//%
|
||||
Buffer createBuffer(int size)
|
||||
{
|
||||
return ManagedBuffer(size).leakData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Read `size` bytes from a 7-bit I2C `address`.
|
||||
*/
|
||||
//%
|
||||
Buffer i2cReadBuffer(int address, int size, bool repeat = false)
|
||||
{
|
||||
Buffer buf = createBuffer(size);
|
||||
uBit.i2c.read(address << 1, (char*)buf->payload, size, repeat);
|
||||
return buf;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write bytes to a 7-bit I2C `address`.
|
||||
*/
|
||||
//%
|
||||
void i2cWriteBuffer(int address, Buffer buf, bool repeat = false)
|
||||
{
|
||||
uBit.i2c.write(address << 1, (char*)buf->payload, buf->length, repeat);
|
||||
}
|
||||
|
||||
SPI* spi = NULL;
|
||||
SPI* allocSPI() {
|
||||
if (spi == NULL)
|
||||
spi = new SPI(MOSI, MISO, SCK);
|
||||
return spi;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write to the SPI slave and return the response
|
||||
* @param value Data to be sent to the SPI slave
|
||||
*/
|
||||
//% help=pins/spi-write weight=5
|
||||
//% blockId=spi_write block="spi write %value"
|
||||
int spiWrite(int value) {
|
||||
auto p = allocSPI();
|
||||
return p->write(value);
|
||||
}
|
||||
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
/**
|
||||
* Control currents in Pins for analog/digital signals, servos, i2c, ...
|
||||
*/
|
||||
//% color=#A80000 weight=30
|
||||
namespace pins {
|
||||
/**
|
||||
* Re-maps a number from one range to another. That is, a value of ``from low`` would get mapped to ``to low``, a value of ``from high`` to ``to high``, values in-between to values in-between, etc.
|
||||
* @param value value to map in ranges
|
||||
* @param fromLow the lower bound of the value's current range
|
||||
* @param fromHigh the upper bound of the value's current range, eg: 1023
|
||||
* @param toLow the lower bound of the value's target range
|
||||
* @param toHigh the upper bound of the value's target range, eg: 4
|
||||
*/
|
||||
//% help=pins/map weight=23
|
||||
//% blockId=math_map block="map %value|from low %fromLow|from high %fromHigh|to low %toLow|to high %toHigh"
|
||||
export function map(value: number, fromLow: number, fromHigh: number, toLow: number, toHigh: number): number {
|
||||
return ((value - fromLow) * (toHigh - toLow)) / (fromHigh - fromLow) + toLow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read one number from 7-bit I2C address.
|
||||
*/
|
||||
//% help=pins/i2c-read-number blockGap=8
|
||||
//% blockId=pins_i2c_readnumber block="i2c read number|at address %address|of format %format=i2c_sizeof" weight=7
|
||||
export function i2cReadNumber(address: number, format: NumberFormat): number {
|
||||
let buf = pins.i2cReadBuffer(address, pins.sizeOf(format))
|
||||
return buf.getNumber(format, 0)
|
||||
}
|
||||
|
||||
/**
|
||||
* Write one number to a 7-bit I2C address.
|
||||
*/
|
||||
//% help=pins/i2c-write-number blockGap=8
|
||||
//% blockId=i2c_writenumber block="i2c write number|at address %address|with value %value|of format %format=i2c_sizeof" weight=6
|
||||
export function i2cWriteNumber(address: number, value: number, format: NumberFormat): void {
|
||||
let buf = createBuffer(pins.sizeOf(format))
|
||||
buf.setNumber(format, 0, value)
|
||||
pins.i2cWriteBuffer(address, buf)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the size in bytes of specified number format.
|
||||
*/
|
||||
//%
|
||||
export function sizeOf(format: NumberFormat) {
|
||||
switch (format) {
|
||||
case NumberFormat.Int8LE:
|
||||
case NumberFormat.UInt8LE:
|
||||
case NumberFormat.Int8BE:
|
||||
case NumberFormat.UInt8BE:
|
||||
return 1;
|
||||
case NumberFormat.Int16LE:
|
||||
case NumberFormat.UInt16LE:
|
||||
case NumberFormat.Int16BE:
|
||||
case NumberFormat.UInt16BE:
|
||||
return 2;
|
||||
case NumberFormat.Int32LE:
|
||||
case NumberFormat.Int32BE:
|
||||
return 4;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
interface Buffer {
|
||||
[index: number]: number;
|
||||
// rest defined in buffer.cpp
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
{
|
||||
"name": "microbit",
|
||||
"description": "The microbit core library",
|
||||
"installedVersion": "tsmdvf",
|
||||
"files": [
|
||||
"README.md",
|
||||
"dal.d.ts",
|
||||
"enums.d.ts",
|
||||
"shims.d.ts",
|
||||
"pxt-core.d.ts",
|
||||
"ksbit.h",
|
||||
"core.cpp",
|
||||
"pxt-helpers.ts",
|
||||
"helpers.ts",
|
||||
"images.cpp",
|
||||
"basic.cpp",
|
||||
"basic.ts",
|
||||
"input.cpp",
|
||||
"input.ts",
|
||||
"control.ts",
|
||||
"control.cpp",
|
||||
"game.ts",
|
||||
"led.cpp",
|
||||
"led.ts",
|
||||
"music.ts",
|
||||
"pins.cpp",
|
||||
"pins.ts",
|
||||
"serial.cpp",
|
||||
"serial.ts",
|
||||
"buffer.cpp",
|
||||
"pxtparts.json",
|
||||
"parts/speaker.svg",
|
||||
"parts/headphone.svg",
|
||||
"_locales/fr/microbit-jsdoc-strings.json"
|
||||
],
|
||||
"public": true,
|
||||
"dependencies": {},
|
||||
"yotta": {
|
||||
"configIsJustDefaults": true,
|
||||
"config": {
|
||||
"microbit-dal": {
|
||||
"bluetooth": {
|
||||
"enabled": 0
|
||||
},
|
||||
"debug": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,148 +0,0 @@
|
||||
{
|
||||
"buttonpair": {
|
||||
"simulationBehavior": "buttonpair",
|
||||
"visual": {
|
||||
"builtIn": "buttonpair",
|
||||
"width": 75,
|
||||
"height": 45,
|
||||
"pinDistance": 15,
|
||||
"pinLocations": [
|
||||
{"x": 0, "y": 0},
|
||||
{"x": 30, "y": 45},
|
||||
{"x": 45, "y": 0},
|
||||
{"x": 75, "y": 45}
|
||||
]
|
||||
},
|
||||
"numberOfPins": 4,
|
||||
"pinDefinitions": [
|
||||
{"target": "P14", "style": "male", "orientation": "-Z"},
|
||||
{"target": "ground", "style": "male", "orientation": "-Z"},
|
||||
{"target": "P15", "style": "male", "orientation": "-Z"},
|
||||
{"target": "ground", "style": "male", "orientation": "-Z"}
|
||||
],
|
||||
"instantiation": {
|
||||
"kind": "singleton"
|
||||
},
|
||||
"assembly": [
|
||||
{"part": true},
|
||||
{"pinIndices": [0, 1]},
|
||||
{"pinIndices": [2, 3]}
|
||||
]
|
||||
},
|
||||
"neopixel": {
|
||||
"simulationBehavior": "neopixel",
|
||||
"visual": {
|
||||
"builtIn": "neopixel",
|
||||
"width": 58,
|
||||
"height": 113,
|
||||
"pinDistance": 9,
|
||||
"pinLocations": [
|
||||
{"x": 10, "y": 0},
|
||||
{"x": 19, "y": 0},
|
||||
{"x": 28, "y": 0}
|
||||
]
|
||||
},
|
||||
"numberOfPins": 3,
|
||||
"pinDefinitions": [
|
||||
{"target": {"pinInstantiationIdx": 0}, "style": "solder", "orientation": "+Z"},
|
||||
{"target": "threeVolt", "style": "solder", "orientation": "+Z"},
|
||||
{"target": "ground", "style": "solder", "orientation": "+Z"}
|
||||
],
|
||||
"instantiation": {
|
||||
"kind": "function",
|
||||
"fullyQualifiedName": "neopixel.create",
|
||||
"argumentRoles": [
|
||||
{"pinInstantiationIdx": 0, "partParameter": "pin"},
|
||||
{"partParameter": "mode"}
|
||||
]
|
||||
},
|
||||
"assembly": [
|
||||
{"part": true, "pinIndices": [2]},
|
||||
{"pinIndices": [0, 1]}
|
||||
]
|
||||
},
|
||||
"ledmatrix": {
|
||||
"visual": {
|
||||
"builtIn": "ledmatrix",
|
||||
"width": 105,
|
||||
"height": 105,
|
||||
"pinDistance": 15,
|
||||
"pinLocations": [
|
||||
{"x": 0, "y": 0},
|
||||
{"x": 15, "y": 0},
|
||||
{"x": 30, "y": 0},
|
||||
{"x": 45, "y": 0},
|
||||
{"x": 105, "y": 105},
|
||||
{"x": 0, "y": 105},
|
||||
{"x": 15, "y": 105},
|
||||
{"x": 30, "y": 105},
|
||||
{"x": 45, "y": 105},
|
||||
{"x": 60, "y": 0}
|
||||
]
|
||||
},
|
||||
"simulationBehavior": "ledmatrix",
|
||||
"numberOfPins": 10,
|
||||
"instantiation": {"kind": "singleton"},
|
||||
"pinDefinitions": [
|
||||
{"target": "P6", "style": "male", "orientation": "-Z", "colorGroup": 0},
|
||||
{"target": "P7", "style": "male", "orientation": "-Z", "colorGroup": 0},
|
||||
{"target": "P8", "style": "male", "orientation": "-Z", "colorGroup": 0},
|
||||
{"target": "P9", "style": "male", "orientation": "-Z", "colorGroup": 0},
|
||||
{"target": "P10", "style": "male", "orientation": "-Z", "colorGroup": 0},
|
||||
{"target": "P12", "style": "male", "orientation": "-Z", "colorGroup": 1},
|
||||
{"target": "P13", "style": "male", "orientation": "-Z", "colorGroup": 1},
|
||||
{"target": "P16", "style": "male", "orientation": "-Z", "colorGroup": 1},
|
||||
{"target": "P19", "style": "male", "orientation": "-Z", "colorGroup": 1},
|
||||
{"target": "P20", "style": "male", "orientation": "-Z", "colorGroup": 1}
|
||||
],
|
||||
"assembly": [
|
||||
{"part": true},
|
||||
{"pinIndices": [0, 1, 2, 3, 4]},
|
||||
{"pinIndices": [5, 6, 7, 8, 9]}
|
||||
]
|
||||
},
|
||||
"headphone": {
|
||||
"numberOfPins": 2,
|
||||
"visual": {
|
||||
"image": "parts/headphone.svg",
|
||||
"width": 142,
|
||||
"height": 180,
|
||||
"pinDistance": 20,
|
||||
"pinLocations": [
|
||||
{"x": 17, "y": 11},
|
||||
{"x": 55, "y": 50}
|
||||
]
|
||||
},
|
||||
"pinDefinitions": [
|
||||
{"target": "P0", "style": "croc", "orientation": "Y"},
|
||||
{"target": "ground", "style": "croc", "orientation": "Y"}
|
||||
],
|
||||
"instantiation": {"kind": "singleton"},
|
||||
"assembly": [
|
||||
{"part": true, "pinIndices": [0]},
|
||||
{"pinIndices": [1]}
|
||||
]
|
||||
},
|
||||
"speaker": {
|
||||
"numberOfPins": 2,
|
||||
"visual": {
|
||||
"image": "parts/speaker.svg",
|
||||
"width": 500,
|
||||
"height": 500,
|
||||
"pinDistance": 70,
|
||||
"pinLocations": [
|
||||
{"x": 180, "y": 135},
|
||||
{"x": 320, "y": 135}
|
||||
]
|
||||
},
|
||||
"pinDefinitions": [
|
||||
{"target": "P0", "style": "male", "orientation": "-Z"},
|
||||
{"target": "ground", "style": "male", "orientation": "-Z"}
|
||||
],
|
||||
"instantiation": {"kind": "singleton"},
|
||||
"assembly": [
|
||||
{"part": true, "pinIndices": [0]},
|
||||
{"pinIndices": [1]}
|
||||
]
|
||||
}
|
||||
}
|
@ -1,71 +0,0 @@
|
||||
#include "ksbit.h"
|
||||
|
||||
enum class SerialPin {
|
||||
P0 = MICROBIT_ID_IO_P0,
|
||||
P1 = MICROBIT_ID_IO_P1,
|
||||
P2 = MICROBIT_ID_IO_P2,
|
||||
//P8 = MICROBIT_ID_IO_P8,
|
||||
//P12 = MICROBIT_ID_IO_P12,
|
||||
//P13 = MICROBIT_ID_IO_P13,
|
||||
//P14 = MICROBIT_ID_IO_P14,
|
||||
//P15 = MICROBIT_ID_IO_P15,
|
||||
//P16 = MICROBIT_ID_IO_P16
|
||||
};
|
||||
|
||||
enum class BaudRate {
|
||||
//% block=115200
|
||||
BaudRate115200 = 115200,
|
||||
//% block=9600
|
||||
BaudRate9600 = 9600
|
||||
};
|
||||
|
||||
//% weight=2 color=30
|
||||
namespace serial {
|
||||
// note that at least one // followed by % is needed per declaration!
|
||||
|
||||
/**
|
||||
* Reads a line of text from the serial port.
|
||||
*/
|
||||
//% help=serial/read-line
|
||||
//% blockId=serial_read_line block="serial read line"
|
||||
//% weight=20
|
||||
StringData* readLine() {
|
||||
return uBit.serial.readUntil(ManagedString("\n")).leakData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a piece of text through Serial connection.
|
||||
*/
|
||||
//% help=serial/write-string
|
||||
//% weight=87
|
||||
//% blockId=serial_writestring block="serial write string %text"
|
||||
void writeString(StringData *text) {
|
||||
uBit.serial.send(ManagedString(text));
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers an event to be fired when one of the delimiter is matched
|
||||
* @param delimiters the characters to match received characters against. eg:"\n"
|
||||
*/
|
||||
// help=serial/on-data-received
|
||||
// weight=19
|
||||
void onDataReceived(StringData* delimiters, Action body) {
|
||||
uBit.serial.eventOn(ManagedString(delimiters));
|
||||
registerWithDal(MICROBIT_ID_SERIAL, MICROBIT_SERIAL_EVT_DELIM_MATCH, body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamically configuring the serial instance to use pins other than USBTX and USBRX.
|
||||
* @param tx the new transmission pins
|
||||
* @param rx the new reception pin
|
||||
* @param baud the new baud rate. eg: 115200
|
||||
*/
|
||||
//% weight=10
|
||||
//% help=serial/redirect-to
|
||||
//% blockId=serial_redirect block="serial redirect to|TX %tx|RX %rx|at baud rate %rate"
|
||||
//% blockExternalInputs=1
|
||||
void redirect(SerialPin tx, SerialPin rx, BaudRate rate) {
|
||||
uBit.serial.redirect((PinName)tx, (PinName)rx);
|
||||
uBit.serial.baud((int)rate);
|
||||
}
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
/**
|
||||
* Reading and writing data over a serial connection.
|
||||
*/
|
||||
//% weight=2 color=#002050
|
||||
namespace serial {
|
||||
/**
|
||||
* Prints a line of text to the serial
|
||||
* @param value to send over serial
|
||||
*/
|
||||
//% weight=90
|
||||
//% help=serial/write-line blockGap=8
|
||||
//% blockId=serial_writeline block="serial|write line %text"
|
||||
export function writeLine(text: string): void {
|
||||
writeString(text + "\r\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints a numeric value to the serial
|
||||
*/
|
||||
//% help=serial/write-number
|
||||
//% weight=89 blockGap=8
|
||||
//% blockId=serial_writenumber block="serial|write number %value"
|
||||
export function writeNumber(value: number): void {
|
||||
writeString(value.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a ``name: value`` pair line to the serial.
|
||||
* @param name name of the value stream, eg: x
|
||||
* @param value to write
|
||||
*/
|
||||
//% weight=88 blockGap=8
|
||||
//% help=serial/write-value
|
||||
//% blockId=serial_writevalue block="serial|write value %name|= %value"
|
||||
export function writeValue(name: string, value: number): void {
|
||||
writeString(name + ":" + value + "\r\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers an event to be fired when a line has been received
|
||||
*/
|
||||
// help=serial/on-line-received
|
||||
// blockId=serial_on_line_received block="serial on line received"
|
||||
// weight=21 blockGap=8
|
||||
export function onLineReceived(body: Action): void {
|
||||
// serial.onDataReceived("\n", body);
|
||||
}
|
||||
}
|
727
libs/microbit/shims.d.ts
vendored
727
libs/microbit/shims.d.ts
vendored
@ -1,727 +0,0 @@
|
||||
// Auto-generated. Do not edit.
|
||||
|
||||
|
||||
/**
|
||||
* Creation, manipulation and display of LED images.
|
||||
*/
|
||||
//% color=#5C2D91 weight=31
|
||||
declare namespace images {
|
||||
|
||||
/**
|
||||
* Creates an image that fits on the LED screen.
|
||||
*/
|
||||
//% weight=75 help=images/create-image
|
||||
//% blockId=device_build_image block="create image"
|
||||
//% parts="ledmatrix" imageLiteral=1 shim=images::createImage
|
||||
function createImage(leds: string): Image;
|
||||
|
||||
/**
|
||||
* Creates an image with 2 frames.
|
||||
*/
|
||||
//% weight=74 help=images/create-big-image
|
||||
//% blockId=device_build_big_image block="create big image" imageLiteral=2
|
||||
//% parts="ledmatrix" shim=images::createBigImage
|
||||
function createBigImage(leds: string): Image;
|
||||
}
|
||||
|
||||
|
||||
declare interface Image {
|
||||
/**
|
||||
* Plots the image at a given column to the screen
|
||||
*/
|
||||
//% help=images/plot-image
|
||||
//% parts="ledmatrix" xOffset.defl=0 shim=ImageMethods::plotImage
|
||||
plotImage(xOffset?: number): void;
|
||||
|
||||
/**
|
||||
* Shows an frame from the image at offset ``x offset``.
|
||||
* @param xOffset column index to start displaying the image
|
||||
*/
|
||||
//% help=images/show-image weight=80 blockNamespace=images
|
||||
//% blockId=device_show_image_offset block="show image %sprite|at offset %offset" blockGap=8
|
||||
//% parts="ledmatrix" shim=ImageMethods::showImage
|
||||
showImage(xOffset: number): void;
|
||||
|
||||
/**
|
||||
* Draws the ``index``-th frame of the image on the screen.
|
||||
* @param xOffset column index to start displaying the image
|
||||
*/
|
||||
//% help=images/plot-frame weight=80
|
||||
//% parts="ledmatrix" shim=ImageMethods::plotFrame
|
||||
plotFrame(xOffset: number): void;
|
||||
|
||||
/**
|
||||
* Scrolls an image .
|
||||
* @param frameOffset x offset moved on each animation step, eg: 5, 1, -1
|
||||
* @param interval time between each animation step in milli seconds, eg: 200
|
||||
*/
|
||||
//% help=images/show-image weight=79 async blockNamespace=images
|
||||
//% blockId=device_scroll_image block="scroll image %sprite|with offset %frameoffset|and interval (ms) %delay" blockGap=8
|
||||
//% parts="ledmatrix" shim=ImageMethods::scrollImage
|
||||
scrollImage(frameOffset: number, interval: number): void;
|
||||
|
||||
/**
|
||||
* Sets all pixels off.
|
||||
*/
|
||||
//% help=images/clear
|
||||
//% parts="ledmatrix" shim=ImageMethods::clear
|
||||
clear(): void;
|
||||
|
||||
/**
|
||||
* Sets a specific pixel brightness at a given position
|
||||
*/
|
||||
//%
|
||||
//% parts="ledmatrix" shim=ImageMethods::setPixelBrightness
|
||||
setPixelBrightness(x: number, y: number, value: number): void;
|
||||
|
||||
/**
|
||||
* Gets the pixel brightness ([0..255]) at a given position
|
||||
*/
|
||||
//%
|
||||
//% parts="ledmatrix" shim=ImageMethods::pixelBrightness
|
||||
pixelBrightness(x: number, y: number): number;
|
||||
|
||||
/**
|
||||
* Gets the width in columns
|
||||
*/
|
||||
//% help=functions/width shim=ImageMethods::width
|
||||
width(): number;
|
||||
|
||||
/**
|
||||
* Gets the height in rows (always 5)
|
||||
*/
|
||||
//% shim=ImageMethods::height
|
||||
height(): number;
|
||||
|
||||
/**
|
||||
* Set a pixel state at position ``(x,y)``
|
||||
* @param x TODO
|
||||
* @param y TODO
|
||||
* @param value TODO
|
||||
*/
|
||||
//% help=images/set-pixel
|
||||
//% parts="ledmatrix" shim=ImageMethods::setPixel
|
||||
setPixel(x: number, y: number, value: boolean): void;
|
||||
|
||||
/**
|
||||
* Get the pixel state at position ``(x,y)``
|
||||
* @param x TODO
|
||||
* @param y TODO
|
||||
*/
|
||||
//% help=images/pixel
|
||||
//% parts="ledmatrix" shim=ImageMethods::pixel
|
||||
pixel(x: number, y: number): boolean;
|
||||
|
||||
/**
|
||||
* Shows a particular frame of the image strip.
|
||||
* @param frame TODO
|
||||
*/
|
||||
//% weight=70 help=images/show-frame
|
||||
//% parts="ledmatrix" shim=ImageMethods::showFrame
|
||||
showFrame(frame: number): void;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Provides access to basic micro:bit functionality.
|
||||
*/
|
||||
//% color=#0078D7 weight=100
|
||||
declare namespace basic {
|
||||
|
||||
/**
|
||||
* Scroll a number on the screen. If the number fits on the screen (i.e. is a single digit), do not scroll.
|
||||
* @param interval speed of scroll; eg: 150, 100, 200, -100
|
||||
*/
|
||||
//% help=basic/show-number
|
||||
//% weight=96
|
||||
//% blockId=device_show_number block="show|number %number" blockGap=8 icon="\uf1ec"
|
||||
//% async
|
||||
//% parts="ledmatrix" interval.defl=150 shim=basic::showNumber
|
||||
function showNumber(value: number, interval?: number): void;
|
||||
|
||||
/**
|
||||
* Draws an image on the LED screen.
|
||||
* @param leds the pattern of LED to turn on/off
|
||||
* @param interval time in milliseconds to pause after drawing
|
||||
*/
|
||||
//% help=basic/show-leds
|
||||
//% weight=95 blockGap=8
|
||||
//% imageLiteral=1 async
|
||||
//% blockId=device_show_leds
|
||||
//% block="show leds" icon="\uf00a"
|
||||
//% parts="ledmatrix" interval.defl=400 shim=basic::showLeds
|
||||
function showLeds(leds: string, interval?: number): void;
|
||||
|
||||
/**
|
||||
* Display text on the display, one character at a time. If the string fits on the screen (i.e. is one letter), does not scroll.
|
||||
* @param text the text to scroll on the screen, eg: "Hello!"
|
||||
* @param interval how fast to shift characters; eg: 150, 100, 200, -100
|
||||
*/
|
||||
//% help=basic/show-string
|
||||
//% weight=87 blockGap=8
|
||||
//% block="show|string %text" icon="\uf031"
|
||||
//% async
|
||||
//% blockId=device_print_message
|
||||
//% parts="ledmatrix" interval.defl=150 shim=basic::showString
|
||||
function showString(text: string, interval?: number): void;
|
||||
|
||||
/**
|
||||
* Turn off all LEDs
|
||||
*/
|
||||
//% help=basic/clear-screen weight=79
|
||||
//% blockId=device_clear_display block="clear screen" icon="\uf12d"
|
||||
//% parts="ledmatrix" shim=basic::clearScreen
|
||||
function clearScreen(): void;
|
||||
|
||||
/**
|
||||
* Shows a sequence of LED screens as an animation.
|
||||
* @param leds pattern of LEDs to turn on/off
|
||||
* @param interval time in milliseconds between each redraw
|
||||
*/
|
||||
//% help=basic/show-animation imageLiteral=1 async
|
||||
//% parts="ledmatrix" interval.defl=400 shim=basic::showAnimation
|
||||
function showAnimation(leds: string, interval?: number): void;
|
||||
|
||||
/**
|
||||
* Draws an image on the LED screen.
|
||||
* @param leds pattern of LEDs to turn on/off
|
||||
*/
|
||||
//% help=basic/plot-leds weight=80
|
||||
//% parts="ledmatrix" imageLiteral=1 shim=basic::plotLeds
|
||||
function plotLeds(leds: string): void;
|
||||
|
||||
/**
|
||||
* Repeats the code forever in the background. On each iteration, allows other codes to run.
|
||||
* @param body code to execute
|
||||
*/
|
||||
//% help=basic/forever weight=55 blockGap=8
|
||||
//% blockId=device_forever block="forever" icon="\uf01e" shim=basic::forever
|
||||
function forever(a: () => void): void;
|
||||
|
||||
/**
|
||||
* Pause for the specified time in milliseconds
|
||||
* @param ms how long to pause for, eg: 100, 200, 500, 1000, 2000
|
||||
*/
|
||||
//% help=basic/pause weight=54
|
||||
//% async block="pause (ms) %pause"
|
||||
//% blockId=device_pause icon="\uf110" shim=basic::pause
|
||||
function pause(ms: number): void;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//% color=300 weight=99
|
||||
declare namespace input {
|
||||
|
||||
/**
|
||||
* Do something when a button (``A``, ``B`` or both ``A+B``) is pressed
|
||||
* @param button TODO
|
||||
* @param body TODO
|
||||
*/
|
||||
//% help=input/on-button-pressed weight=85 blockGap=8
|
||||
//% blockId=device_button_event block="on button|%NAME|pressed" icon="\uf192"
|
||||
//% parts="buttonpair" shim=input::onButtonPressed
|
||||
function onButtonPressed(button: Button, body: () => void): void;
|
||||
|
||||
/**
|
||||
* Do something when when a gesture is done (like shaking the micro:bit).
|
||||
* @param body TODO
|
||||
*/
|
||||
//% help=input/on-gesture weight=84 blockGap=8
|
||||
//% blockId=device_gesture_event block="on |%NAME" icon="\uf135"
|
||||
//% parts="accelerometer" shim=input::onGesture
|
||||
function onGesture(gesture: Gesture, body: () => void): void;
|
||||
|
||||
/**
|
||||
* Do something when a pin is pressed.
|
||||
* @param name the pin that needs to be pressed
|
||||
* @param body the code to run when the pin is pressed
|
||||
*/
|
||||
//% help=input/on-pin-pressed weight=83
|
||||
//% blockId=device_pin_event block="on pin %NAME|pressed" icon="\uf094" shim=input::onPinPressed
|
||||
function onPinPressed(name: TouchPin, body: () => void): void;
|
||||
|
||||
/**
|
||||
* Do something when a pin is released.
|
||||
* @param name the pin that needs to be released
|
||||
* @param body the code to run when the pin is released
|
||||
*/
|
||||
//% help=input/on-pin-released weight=6 blockGap=8
|
||||
//% blockId=device_pin_released block="on pin %NAME|released" icon="\uf094" shim=input::onPinReleased
|
||||
function onPinReleased(name: TouchPin, body: () => void): void;
|
||||
|
||||
/**
|
||||
* Get the button state (pressed or not) for ``A`` and ``B``.
|
||||
*/
|
||||
//% help=input/button-is-pressed weight=57
|
||||
//% block="button|%NAME|is pressed"
|
||||
//% blockId=device_get_button2
|
||||
//% icon="\uf192" blockGap=8
|
||||
//% parts="buttonpair" shim=input::buttonIsPressed
|
||||
function buttonIsPressed(button: Button): boolean;
|
||||
|
||||
/**
|
||||
* Get the pin state (pressed or not). Requires to hold the ground to close the circuit.
|
||||
* @param name pin used to detect the touch
|
||||
*/
|
||||
//% help=input/pin-is-pressed weight=56
|
||||
//% blockId="device_pin_is_pressed" block="pin %NAME|is pressed" icon="\uf094"
|
||||
//% blockGap=8 shim=input::pinIsPressed
|
||||
function pinIsPressed(name: TouchPin): boolean;
|
||||
|
||||
/**
|
||||
* Get the current compass heading in degrees.
|
||||
*/
|
||||
//% help=input/compass-heading
|
||||
//% weight=56 icon="\uf14e"
|
||||
//% blockId=device_heading block="compass heading (°)" blockGap=8
|
||||
//% parts="compass" shim=input::compassHeading
|
||||
function compassHeading(): number;
|
||||
|
||||
/**
|
||||
* Gets the temperature in Celsius degrees (°C).
|
||||
*/
|
||||
//% weight=55 icon="\uf06d"
|
||||
//% help=input/temperature
|
||||
//% blockId=device_temperature block="temperature (°C)" blockGap=8
|
||||
//% parts="thermometer" shim=input::temperature
|
||||
function temperature(): number;
|
||||
|
||||
/**
|
||||
* Get the acceleration value in milli-gravitys (when the board is laying flat with the screen up, x=0, y=0 and z=-1024)
|
||||
* @param dimension TODO
|
||||
*/
|
||||
//% help=input/acceleration weight=54 icon="\uf135"
|
||||
//% blockId=device_acceleration block="acceleration (mg)|%NAME" blockGap=8
|
||||
//% parts="accelerometer" shim=input::acceleration
|
||||
function acceleration(dimension: Dimension): number;
|
||||
|
||||
/**
|
||||
* Reads the light level applied to the LED screen in a range from ``0`` (dark) to ``255`` bright.
|
||||
*/
|
||||
//% help=input/light-level weight=53
|
||||
//% blockId=device_get_light_level block="light level" blockGap=8 icon="\uf185"
|
||||
//% parts="ledmatrix" shim=input::lightLevel
|
||||
function lightLevel(): number;
|
||||
|
||||
/**
|
||||
* The pitch or roll of the device, rotation along the ``x-axis`` or ``y-axis``, in degrees.
|
||||
* @param kind TODO
|
||||
*/
|
||||
//% help=input/rotation weight=52
|
||||
//% blockId=device_get_rotation block="rotation (°)|%NAME" blockGap=8 icon="\uf197"
|
||||
//% parts="accelerometer" shim=input::rotation
|
||||
function rotation(kind: Rotation): number;
|
||||
|
||||
/**
|
||||
* Get the magnetic force value in ``micro-Teslas`` (``µT``). This function is not supported in the simulator.
|
||||
* @param dimension TODO
|
||||
*/
|
||||
//% help=input/magnetic-force weight=51
|
||||
//% blockId=device_get_magnetic_force block="magnetic force (µT)|%NAME" blockGap=8 icon="\uf076"
|
||||
//% parts="compass" shim=input::magneticForce
|
||||
function magneticForce(dimension: Dimension): number;
|
||||
|
||||
/**
|
||||
* Gets the number of milliseconds elapsed since power on.
|
||||
*/
|
||||
//% help=input/running-time weight=50
|
||||
//% blockId=device_get_running_time block="running time (ms)" icon="\uf017" shim=input::runningTime
|
||||
function runningTime(): number;
|
||||
|
||||
/**
|
||||
* Obsolete, compass calibration is automatic.
|
||||
*/
|
||||
//% help=input/calibrate weight=0 shim=input::calibrate
|
||||
function calibrate(): void;
|
||||
|
||||
/**
|
||||
* Sets the accelerometer sample range in gravities.
|
||||
* @param range a value describe the maximum strengh of acceleration measured
|
||||
*/
|
||||
//% help=input/set-accelerometer-range
|
||||
//% blockId=device_set_accelerometer_range block="set accelerometer|range %range" icon="\uf135"
|
||||
//% weight=5
|
||||
//% parts="accelerometer" shim=input::setAccelerometerRange
|
||||
function setAccelerometerRange(range: AcceleratorRange): void;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//% weight=1 color="#333333"
|
||||
declare namespace control {
|
||||
|
||||
/**
|
||||
* Schedules code that run in the background.
|
||||
*/
|
||||
//% help=control/in-background
|
||||
//% blockId="control_in_background" block="run in background" blockGap=8 shim=control::inBackground
|
||||
function inBackground(a: () => void): void;
|
||||
|
||||
/**
|
||||
* Resets the BBC micro:bit.
|
||||
*/
|
||||
//% weight=30 async help=control/reset blockGap=8
|
||||
//% blockId="control_reset" block="reset" shim=control::reset
|
||||
function reset(): void;
|
||||
|
||||
/**
|
||||
* Blocks the current fiber for the given microseconds
|
||||
* @param micros number of micro-seconds to wait. eg: 4
|
||||
*/
|
||||
//% help=control/wait-micros weight=29
|
||||
//% blockId="control_wait_us" block="wait (µs)%micros" shim=control::waitMicros
|
||||
function waitMicros(micros: number): void;
|
||||
|
||||
/**
|
||||
* Raises an event in the event bus.
|
||||
* @param src ID of the MicroBit Component that generated the event e.g. MICROBIT_ID_BUTTON_A.
|
||||
* @param value Component specific code indicating the cause of the event.
|
||||
* @param mode optional definition of how the event should be processed after construction (default is CREATE_AND_FIRE).
|
||||
*/
|
||||
//% weight=21 blockGap=12 blockId="control_raise_event" block="raise event|from source %src=control_event_source_id|with value %value=control_event_value_id" blockExternalInputs=1
|
||||
//% mode.defl=1 shim=control::raiseEvent
|
||||
function raiseEvent(src: number, value: number, mode?: EventCreationMode): void;
|
||||
|
||||
/**
|
||||
* Raises an event in the event bus.
|
||||
*/
|
||||
//% weight=20 blockGap=8 blockId="control_on_event" block="on event|from %src=control_event_source_id|with value %value=control_event_value_id"
|
||||
//% blockExternalInputs=1 shim=control::onEvent
|
||||
function onEvent(src: number, value: number, handler: () => void): void;
|
||||
|
||||
/**
|
||||
* Gets the value of the last event executed on the bus
|
||||
*/
|
||||
//% blockId=control_event_value" block="event value"
|
||||
//% weight=18 shim=control::eventValue
|
||||
function eventValue(): number;
|
||||
|
||||
/**
|
||||
* Gets the timestamp of the last event executed on the bus
|
||||
*/
|
||||
//% blockId=control_event_timestamp" block="event timestamp"
|
||||
//% weight=19 blockGap=8 shim=control::eventTimestamp
|
||||
function eventTimestamp(): number;
|
||||
|
||||
/**
|
||||
* Gets a friendly name for the device derived from the its serial number
|
||||
*/
|
||||
//% blockId="control_device_name" block="device name" weight=10 blockGap=8 shim=control::deviceName
|
||||
function deviceName(): string;
|
||||
|
||||
/**
|
||||
* Derive a unique, consistent serial number of this device from internal data.
|
||||
*/
|
||||
//% blockId="control_device_serial_number" block="device serial number" weight=9 shim=control::deviceSerialNumber
|
||||
function deviceSerialNumber(): number;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//% color=3 weight=35
|
||||
declare namespace led {
|
||||
|
||||
/**
|
||||
* Turn on the specified LED using x, y coordinates (x is horizontal, y is vertical). (0,0) is upper left.
|
||||
* @param x TODO
|
||||
* @param y TODO
|
||||
*/
|
||||
//% help=led/plot weight=78
|
||||
//% blockId=device_plot block="plot|x %x|y %y" icon="\uf205" blockGap=8
|
||||
//% parts="ledmatrix" shim=led::plot
|
||||
function plot(x: number, y: number): void;
|
||||
|
||||
/**
|
||||
* Turn off the specified LED using x, y coordinates (x is horizontal, y is vertical). (0,0) is upper left.
|
||||
* @param x TODO
|
||||
* @param y TODO
|
||||
*/
|
||||
//% help=led/unplot weight=77
|
||||
//% blockId=device_unplot block="unplot|x %x|y %y" icon="\uf204" blockGap=8
|
||||
//% parts="ledmatrix" shim=led::unplot
|
||||
function unplot(x: number, y: number): void;
|
||||
|
||||
/**
|
||||
* Get the on/off state of the specified LED using x, y coordinates. (0,0) is upper left.
|
||||
* @param x TODO
|
||||
* @param y TODO
|
||||
*/
|
||||
//% help=led/point weight=76
|
||||
//% blockId=device_point block="point|x %x|y %y" icon="\uf10c"
|
||||
//% parts="ledmatrix" shim=led::point
|
||||
function point(x: number, y: number): boolean;
|
||||
|
||||
/**
|
||||
* Get the screen brightness from 0 (off) to 255 (full bright).
|
||||
*/
|
||||
//% help=led/brightness weight=60
|
||||
//% blockId=device_get_brightness block="brightness" icon="\uf042" blockGap=8
|
||||
//% parts="ledmatrix" shim=led::brightness
|
||||
function brightness(): number;
|
||||
|
||||
/**
|
||||
* Set the screen brightness from 0 (off) to 255 (full bright).
|
||||
* @param value the brightness value, eg:255, 127, 0
|
||||
*/
|
||||
//% help=led/set-brightness weight=59
|
||||
//% blockId=device_set_brightness block="set brightness %value" icon="\uf042"
|
||||
//% parts="ledmatrix" shim=led::setBrightness
|
||||
function setBrightness(value: number): void;
|
||||
|
||||
/**
|
||||
* Cancels the current animation and clears other pending animations.
|
||||
*/
|
||||
//% weight=50 help=led/stop-animation
|
||||
//% blockId=device_stop_animation block="stop animation" icon="\uf04d"
|
||||
//% parts="ledmatrix" shim=led::stopAnimation
|
||||
function stopAnimation(): void;
|
||||
|
||||
/**
|
||||
* Sets the display mode between black and white and greyscale for rendering LEDs.
|
||||
* @param mode TODO
|
||||
*/
|
||||
//% weight=1 help=led/set-display-mode
|
||||
//% parts="ledmatrix" shim=led::setDisplayMode
|
||||
function setDisplayMode(mode: DisplayMode): void;
|
||||
|
||||
/**
|
||||
* Takes a screenshot of the LED screen and returns an image.
|
||||
*/
|
||||
//% help=led/screenshot
|
||||
//% parts="ledmatrix" shim=led::screenshot
|
||||
function screenshot(): Image;
|
||||
}
|
||||
declare namespace pins {
|
||||
|
||||
/**
|
||||
* Read the specified pin or connector as either 0 or 1
|
||||
* @param name pin to read from
|
||||
*/
|
||||
//% help=pins/digital-read-pin weight=30
|
||||
//% blockId=device_get_digital_pin block="digital read|pin %name" blockGap=8 shim=pins::digitalReadPin
|
||||
function digitalReadPin(name: DigitalPin): number;
|
||||
|
||||
/**
|
||||
* Set a pin or connector value to either 0 or 1.
|
||||
* @param name pin to write to
|
||||
* @param value value to set on the pin, 1 eg,0
|
||||
*/
|
||||
//% help=pins/digital-write-pin weight=29
|
||||
//% blockId=device_set_digital_pin block="digital write|pin %name|to %value" shim=pins::digitalWritePin
|
||||
function digitalWritePin(name: DigitalPin, value: number): void;
|
||||
|
||||
/**
|
||||
* Read the connector value as analog, that is, as a value comprised between 0 and 1023.
|
||||
* @param name pin to write to
|
||||
*/
|
||||
//% help=pins/analog-read-pin weight=25
|
||||
//% blockId=device_get_analog_pin block="analog read|pin %name" blockGap="8" shim=pins::analogReadPin
|
||||
function analogReadPin(name: AnalogPin): number;
|
||||
|
||||
/**
|
||||
* Set the connector value as analog. Value must be comprised between 0 and 1023.
|
||||
* @param name pin name to write to
|
||||
* @param value value to write to the pin between ``0`` and ``1023``. eg:1023,0
|
||||
*/
|
||||
//% help=pins/analog-write-pin weight=24
|
||||
//% blockId=device_set_analog_pin block="analog write|pin %name|to %value" blockGap=8 shim=pins::analogWritePin
|
||||
function analogWritePin(name: AnalogPin, value: number): void;
|
||||
|
||||
/**
|
||||
* Configures the Pulse-width modulation (PWM) of the analog output to the given value in **microseconds** or `1/1000` milliseconds.
|
||||
* If this pin is not configured as an analog output (using `analog write pin`), the operation has no effect.
|
||||
* @param name analog pin to set period to
|
||||
* @param micros period in micro seconds. eg:20000
|
||||
*/
|
||||
//% help=pins/analog-set-period weight=23 blockGap=8
|
||||
//% blockId=device_set_analog_period block="analog set period|pin %pin|to (µs)%micros" shim=pins::analogSetPeriod
|
||||
function analogSetPeriod(name: AnalogPin, micros: number): void;
|
||||
|
||||
/**
|
||||
* Configures this pin to a digital input, and generates events where the timestamp is the duration that this pin was either ``high`` or ``low``.
|
||||
*/
|
||||
//% help=pins/on-pulsed weight=22 blockGap=8
|
||||
//% blockId=pins_on_pulsed block="on|pin %pin|pulsed %pulse" shim=pins::onPulsed
|
||||
function onPulsed(name: DigitalPin, pulse: PulseValue, body: () => void): void;
|
||||
|
||||
/**
|
||||
* Gets the duration of the last pulse in micro-seconds. This function should be called from a ``onPulsed`` handler.
|
||||
*/
|
||||
//% help=pins/pulse-duration
|
||||
//% blockId=pins_pulse_duration block="pulse duration (µs)"
|
||||
//% weight=21 blockGap=8 shim=pins::pulseDuration
|
||||
function pulseDuration(): number;
|
||||
|
||||
/**
|
||||
* Returns the duration of a pulse in microseconds
|
||||
* @param name the pin which measures the pulse
|
||||
* @param value the value of the pulse (default high)
|
||||
* @param maximum duration in micro-seconds
|
||||
*/
|
||||
//% blockId="pins_pulse_in" block="pulse in (µs)|pin %name|pulsed %value"
|
||||
//% weight=20 maxDuration.defl=2000000 shim=pins::pulseIn
|
||||
function pulseIn(name: DigitalPin, value: PulseValue, maxDuration?: number): number;
|
||||
|
||||
/**
|
||||
* Writes a value to the servo, controlling the shaft accordingly. On a standard servo, this will set the angle of the shaft (in degrees), moving the shaft to that orientation. On a continuous rotation servo, this will set the speed of the servo (with ``0`` being full-speed in one direction, ``180`` being full speed in the other, and a value near ``90`` being no movement).
|
||||
* @param name pin to write to
|
||||
* @param value angle or rotation speed, eg:180,90,0
|
||||
*/
|
||||
//% help=pins/servo-write-pin weight=20
|
||||
//% blockId=device_set_servo_pin block="servo write|pin %name|to %value" blockGap=8 shim=pins::servoWritePin
|
||||
function servoWritePin(name: AnalogPin, value: number): void;
|
||||
|
||||
/**
|
||||
* Configures this IO pin as an analog/pwm output, configures the period to be 20 ms, and sets the pulse width, based on the value it is given **microseconds** or `1/1000` milliseconds.
|
||||
* @param name pin name
|
||||
* @param micros pulse duration in micro seconds, eg:1500
|
||||
*/
|
||||
//% help=pins/servo-set-pulse weight=19
|
||||
//% blockId=device_set_servo_pulse block="servo set pulse|pin %value|to (µs) %micros" shim=pins::servoSetPulse
|
||||
function servoSetPulse(name: AnalogPin, micros: number): void;
|
||||
|
||||
/**
|
||||
* Sets the pin used when using `pins->analog pitch`.
|
||||
* @param name TODO
|
||||
*/
|
||||
//% help=pins/analog-set-pitch weight=12 shim=pins::analogSetPitchPin
|
||||
function analogSetPitchPin(name: AnalogPin): void;
|
||||
|
||||
/**
|
||||
* Emits a Pulse-width modulation (PWM) signal to the current pitch pin. Use `analog set pitch pin` to define the pitch pin.
|
||||
* @param frequency TODO
|
||||
* @param ms TODO
|
||||
*/
|
||||
//% help=pins/analog-pitch weight=14 async shim=pins::analogPitch
|
||||
function analogPitch(frequency: number, ms: number): void;
|
||||
|
||||
/**
|
||||
* Configures the pull of this pin.
|
||||
* @param name pin to set the pull mode on
|
||||
* @param pull one of the mbed pull configurations: PullUp, PullDown, PullNone
|
||||
*/
|
||||
//% help=pins/set-pull weight=3
|
||||
//% blockId=device_set_pull block="set pull|pin %pin|to %pull" shim=pins::setPull
|
||||
function setPull(name: DigitalPin, pull: PinPullMode): void;
|
||||
|
||||
/**
|
||||
* Create a new zero-initialized buffer.
|
||||
* @param size number of bytes in the buffer
|
||||
*/
|
||||
//% shim=pins::createBuffer
|
||||
function createBuffer(size: number): Buffer;
|
||||
|
||||
/**
|
||||
* Read `size` bytes from a 7-bit I2C `address`.
|
||||
*/
|
||||
//% repeat.defl=0 shim=pins::i2cReadBuffer
|
||||
function i2cReadBuffer(address: number, size: number, repeat?: boolean): Buffer;
|
||||
|
||||
/**
|
||||
* Write bytes to a 7-bit I2C `address`.
|
||||
*/
|
||||
//% repeat.defl=0 shim=pins::i2cWriteBuffer
|
||||
function i2cWriteBuffer(address: number, buf: Buffer, repeat?: boolean): void;
|
||||
|
||||
/**
|
||||
* Write to the SPI slave and return the response
|
||||
* @param value Data to be sent to the SPI slave
|
||||
*/
|
||||
//% help=pins/spi-write weight=5
|
||||
//% blockId=spi_write block="spi write %value" shim=pins::spiWrite
|
||||
function spiWrite(value: number): number;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//% weight=2 color=30
|
||||
declare namespace serial {
|
||||
|
||||
/**
|
||||
* Reads a line of text from the serial port.
|
||||
*/
|
||||
//% help=serial/read-line
|
||||
//% blockId=serial_read_line block="serial read line"
|
||||
//% weight=20 shim=serial::readLine
|
||||
function readLine(): string;
|
||||
|
||||
/**
|
||||
* Sends a piece of text through Serial connection.
|
||||
*/
|
||||
//% help=serial/write-string
|
||||
//% weight=87
|
||||
//% blockId=serial_writestring block="serial write string %text" shim=serial::writeString
|
||||
function writeString(text: string): void;
|
||||
|
||||
/**
|
||||
* Dynamically configuring the serial instance to use pins other than USBTX and USBRX.
|
||||
* @param tx the new transmission pins
|
||||
* @param rx the new reception pin
|
||||
* @param baud the new baud rate. eg: 115200
|
||||
*/
|
||||
//% weight=10
|
||||
//% help=serial/redirect-to
|
||||
//% blockId=serial_redirect block="serial redirect to|TX %tx|RX %rx|at baud rate %rate"
|
||||
//% blockExternalInputs=1 shim=serial::redirect
|
||||
function redirect(tx: SerialPin, rx: SerialPin, rate: BaudRate): void;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//% indexerGet=BufferMethods::getByte indexerSet=BufferMethods::setByte
|
||||
declare interface Buffer {
|
||||
/**
|
||||
* Write a number in specified format in the buffer.
|
||||
*/
|
||||
//% shim=BufferMethods::setNumber
|
||||
setNumber(format: NumberFormat, offset: number, value: number): void;
|
||||
|
||||
/**
|
||||
* Read a number in specified format from the buffer.
|
||||
*/
|
||||
//% shim=BufferMethods::getNumber
|
||||
getNumber(format: NumberFormat, offset: number): number;
|
||||
|
||||
/** Returns the length of a Buffer object. */
|
||||
//% property shim=BufferMethods::length
|
||||
length: number;
|
||||
|
||||
/**
|
||||
* Fill (a fragment) of the buffer with given value.
|
||||
*/
|
||||
//% offset.defl=0 length.defl=-1 shim=BufferMethods::fill
|
||||
fill(value: number, offset?: number, length?: number): void;
|
||||
|
||||
/**
|
||||
* Return a copy of a fragment of a buffer.
|
||||
*/
|
||||
//% offset.defl=0 length.defl=-1 shim=BufferMethods::slice
|
||||
slice(offset?: number, length?: number): Buffer;
|
||||
|
||||
/**
|
||||
* Shift buffer left in place, with zero padding.
|
||||
* @param offset number of bytes to shift; use negative value to shift right
|
||||
* @param start start offset in buffer. Default is 0.
|
||||
* @param length number of elements in buffer. If negative, length is set as the buffer length minus start. eg: -1
|
||||
*/
|
||||
//% start.defl=0 length.defl=-1 shim=BufferMethods::shift
|
||||
shift(offset: number, start?: number, length?: number): void;
|
||||
|
||||
/**
|
||||
* Rotate buffer left in place.
|
||||
* @param offset number of bytes to shift; use negative value to shift right
|
||||
* @param start start offset in buffer. Default is 0.
|
||||
* @param length number of elements in buffer. If negative, length is set as the buffer length minus start. eg: -1
|
||||
*/
|
||||
//% start.defl=0 length.defl=-1 shim=BufferMethods::rotate
|
||||
rotate(offset: number, start?: number, length?: number): void;
|
||||
|
||||
/**
|
||||
* Write contents of `src` at `dstOffset` in current buffer.
|
||||
*/
|
||||
//% shim=BufferMethods::write
|
||||
write(dstOffset: number, src: Buffer): void;
|
||||
}
|
||||
|
||||
// Auto-generated. Do not edit. Really.
|
Reference in New Issue
Block a user