-
-
={ "VERSION": "1v96.43", "GIT_COMMIT": "c975a9a", "BOARD": "ISKRAJS", "FLASH": 1048576, "RAM": 196608, "SERIAL": "3b004900-07513535-31393131", "CONSOLE": "USB", "MODULES": "Flash,Storage,fs," ... "t,crypto,neopixel", "EXPORTS": { "jsvLockAgainSafe": 105081, "jsvUnLock": 105055, "jsvSkipName": 111873, "jsvMathsOp": 91429, "jsvNewWithFlags": 105193, "jsvNewFromFloat": 105361, "jsvNewFromInteger": 105397, "jsvNewFromString": 110413, "jsvNewFromBool": 105381, "jsvGetFloat": 112097, "jsvGetInteger": 111285, "jsvGetBool": 112657, "jspReplaceWith": 29177, "jspeFunctionCall": 80681, "jspGetNamedVariable": 80505, "jspGetNamedField": 85101, "jspGetVarNamedField": 84825 }, "EXPTR": 536871104 }
-
Hi,
The reason is clearly established, it is in firmware 1v96.43,
it doesn't work in her.
To change the firmware at the moment I can not, the Board is not original (Amperka). Checked it on the original Board version 2v01
there the code is executed correctly.
I will wait for the firmware update.
Thanks everyone ! -
-
Console conclusion at implementation of your code:
____ __ / _/_____ / /__ _____ ____ _ / / / ___// //_// ___// __ `/ _/ / (__ )/ ,< / / / /_/ / /___//____//_/|_|/_/ \__,_/ Based on Espruino 1v96.43 (c) 2018 G.Williams, Amperka LLC Support the work of core developers: http://espruino.com/Donate > =undefined Uncaught Error: Function "asyncFuncA" not found! at line 1 col 7 _this.asyncFuncA(); ^ in function called from system
-
@allObjects Does not work:
one is to define a local variable var _this = this; before the setInterval() and use it - _this in its function... (sometimes I just use var _ = this; to be short).
another one is to pass this as variable by passing it as 2nd+ parameter when setting up the interval: setInterval(function(_){ _.xyz(); },1000,this);. -
I studied Gordon's article and found no contradictions in his code.
Article - "How ES6 classes work"
http://forum.espruino.com/conversations/327037/ -
-
Hi !
class A { constructor(x, y){ //class field... } AsyncFuncA(){ //code... } run(){ //call async code setInterval(() => { this.AsyncFuncA(); }, 1000) } } class B { constructor(x, y){ super(x,y); } AsyncFuncB(){ //code... } run(){ //call async code super.run(); setInterval(() => { // Todo... this.AsyncFuncB(); }, 2000); } } /**********************************************/ let ob = new B(x, y); ob.run();
an error occurs when you call run() -> this.AsyncFuncA()
Web IDE:"Uncaught Error: Function "AsyncFuncA" not found!
at line 248 col 6
this.AsyncFuncA();^
in function called from system"
how can this be fought ?
-
-
Thank you all for the advice !
function myclassA() { this.A = 1; this.TimerID = null; } myclassA.prototype.func_1 = function() { /* here some code */ this.TimerID = setInterval(this.func_2.bind(this), 50); } myclassA.prototype.func_2 = function() { /* There was an error ! )) */ } function myclassB(_object) { this.B = 1; this.Obj = _object; } myclassB.prototype.func_1 = function() { /* here some code */ this.Obj.func_1(); }
-
-
-
-
In the code there are no syntax errors it builds and runs fine, below part of code:
function TObj_1(_pin) { /*** константы класса ***/ this.MinPulse = 453.0; //минимальная длительность импульса которая соответствует крайнему "меньшему" положения ротора this.MaxPulse = 2050.0; //макисмальная длительность импульса которая соответствует крайнему "меньшему" положения ротора this.Ks = 8.7; //коэффициент преобразования в ф-ции Y=kA+B (линейная кривая самого сервопривода /*** поля класса ***/ this.Pin = null; //пин микропроцессора на котором "сидит" сервопривод this.Value = 0.0; //конечное значение яркости свечения this.CurValue = 0.0; //текущее значение яркости свечения this.Speed = 0.0; //текущая скорость процесса this.Pin = _pin; //задать пин к которому привязан сервопривод } TObj_1.prototype.BunRunAnimation = function() { this.FlagBunAnimation = true; //запретить "ручной" запуск Animation(...) this.StopAnimation(); //остановить текущую анимацию }; function TObj_2(_tobj_1) { this.PHASE_ARR = [ "START_MOVE", "START_WAIT", "DOWN_MOVE", "DOWN_WAIT", "UP_MOVE", "UP_WAIT" ]; this.ANGLE_START = 30; //конечный угол ротора фазы START_MOVE this.ANGLE_UP = 20; //конечный угол ротора фазы UP_MOVE this.ANGLE_DOWN = 0; //конечный угол ротора фазы DOWN_MOVE this.TIME_START = 15; //время нахождения в позиции START_WAIT, секунд this.TIME_UP = 0.5; //время нахождения в позиции UP_MOVE, секунд this.TIME_DOWN = 0.7; //время нахождения в позиции UP_WAIT, секунд this.SPEED_START = 25; //скорось движения ротора в фазе START_MOVE, %/s this.SPEED_UP = 40; //скорось движения ротора в фазе UP_MOVE, %/s this.SPEED_DOWN = 25; //скорось движения ротора в фазе DOWN_MOVE, %/s this.INTERVAL_PLAY = 60.0; //определяет период в ms запуска внутренней ф-и setTimeout this.Obj1 = _tobj_1; //инициируем поле объектом класса Servo }; TObj_2.prototype.TaskRun = function() { let _this = this; if( !_this.FlagTaskRun ) { _this.FlagTaskRun = true; _this.Obj1.BunRunAnimation(); //Error ! _this.CurPhase = _this.PHASE_ARR[0]; } switch(_this.CurPhase) { case "START_MOVE": if( !_this.FlagSTART_MOVE ) { _this.Obj1.AnimationTask(_this.ANGLE_START, _this.SPEED_START); _this.FlagSTART_MOVE = true; } else { if ( !_this.Obj1.GetStatusRunAnimation() ) //Error ! { _this.CurPhase = _this.PHASE_ARR[1]; _this.FlagSTART_MOVE = false; } } break; };
-
Thank you for such a quick response !
I use the cost of production of Amperka (http://amperka.ru/) - "IskraJS" based on Espruino 1v92.194 -
There is an object created via new:
function class_1() { this.A_1; this.B_1; } class_1.prototype.func_class_1 = function() { /* here are some actions with variables this.A_1, this.B_1 */ } function class_2 (_obj /*object of type class_1*/) { this.A_2; this.B_2; this.Obj_2 = _obj; } class_2.prototype.func_class_2 = function() { //function call problem !!! this.Obj_2.func_class_1(); } var o1 = new class_1(); var o2 = new class_2(o1); o2.func_class_2(); //Uncaught Error: Field or method "func_class_1()" does not already exist, and can't create it on undefined
Help !
I tried various options with this, call and bind, nothing helped. How to organize a call to "this.Obj_2.func_Class_1()" ?
Hi,
doesn't anyone know? or is there no such possibility ?