Makeblock-official / mBlock

base on scratch offline v2.0 by MIT, Learn more from Makeblock official website
http://www.makeblock.com
GNU General Public License v2.0
319 stars 228 forks source link

Short2array function returns zero value in customized extension #71

Open mahmutakyol opened 7 years ago

mahmutakyol commented 7 years ago

ext.runTone = function(pin, tone, beat) { runPackage(34, 8, short2array(typeof tone == "number" ? tone : tones[tone]), short2array(typeof beat == "number" ? beat : beats[beat])); };

=> readBuffer(7) = 0, readBuffer(8) = 0

I get the value of readBuffer when I give a constant value instead of short2array in this code, but when I use short2array function, the value is zero.

ext.runTone = function(pin, tone, beat) { runPackage(34, 8, 262, 500); };

=> readBuffer(7) = 262, readBuffer(8) = 500

extension.js => console.log(args) => C4, Half

my tones array => var tones = { "C4": 262, "D4": 294, "E4": 330, "F4": 349, "G4": 392, "A4": 440, "B4": 494 };

my beats array => var beats = { "Half": 500, "Quarter": 250, "Eighth": 125, "Whole": 1000, "Double": 2000, "Zero": 0 };