You are reading a single comment by @coat and its replies. Click here to read the full conversation.
  • Hi again!
    I'm trying to make a BLE keyboard with micro:bit to send a keystroke when it is tilted to the right, left, front, back.
    This is my code (I've not finish to write all)

    var kb = require("ble_hid_keyboard");
    NRF.setServices(undefined, { hid : kb.report });
    
    var min = -400;
    var max = 400;
    
    
      var x = Microbit.accel().x*1000;
      var y = Microbit.accel().y*1000;
      var z = Microbit.accel().z*1000;
    
    if (x > min && x < max && (y > min && y < max && z < (-800))){
      kb.tap(kb.KEY.A);
    } else {
        if (x > min && x < max && (y > min && y < max && z > 800)) {
          kb.tap(kb.KEY.F);
        } else {
            if (x > min && x < max && (z > min && z < max && y > 800)) {
                kb.tap(kb.KEY.D);
            } else {
                if (x > min && x < max && (z > min && z < max && y < (-800))) {
                    kb.tap(kb.KEY.E);
                } else {
                    if (y > min && y < max && (z > min && z < max && x > 800)) {
                        kb.tap(kb.KEY.B);
                    } else {
                        if (y > min && y < max && (z > min && z < max && x < (-800))) 
                            kb.tap(kb.KEY.C);
                    }
                }
            }
        }
    }
    

    I'm using the example of BLE Keyboard here and I receive this error

    Uncaught TypeError: Expecting a number or something iterable, got undefined
     at line 1 col 104
    ...0,0,0],function(){a&&a()})})
                                  ^
    in function "tap" called from line 16 col 18
      kb.tap(kb.KEY.A);
                     ^
    

    or this one

    >New interpreter error: UART_OVERFLOW
    >Uncaught ReferenceError: "requirerage" is not defined
     at line 2 col 1
    requirerage").write(".bootcde","85,\nPAD_MINUS:86,PAD_PLUS:8...
    ^
    Uncaught SyntaxError: Got '}' expected ','
     at line 11 col 5
        }
        ^
    

    If I make a test with just

    print("A");
    

    instead of

    kb.tap(kb.KEY.A);
    

    I've no error and the code works as I want.

    What it can be?

  • What it can be?

    UART_OVERFLOW

    The code is probably sent too fast to the device. As a workaround you can try to check Settings->Communication->Throttle Send. Then uploading will be slower.

About

Avatar for coat @coat started