2017-11-30 15 views
2

온라인 Mbed C/C++ 컴파일러에서 BBC Micro : bit로 config.json 파일을 사용하는 사람이 있습니까? 그렇다면 파일 시스템에서 config.json 파일을 어디에 두었습니까?BBC Micro에서 config.json 파일 사용 : 비트 Mbed 온라인 컴파일러

Mbed 온라인 C/C++ 컴파일러를 사용하여 microbit-simple-radio-rx 및 microbit-simple-radio-tx라는 예제 라디오 프로그램을 빌드 할 때 Micro : bits에서 응답을받지 못했습니다. 16 진수 파일 그러나 오프라인 yotta 명령 줄을 사용하여 동일한 config.json 파일로 Micro : bit에 대해 동일한 예제를 컴파일하고 16 진수 파일을로드하면 예제가 올바르게 실행됩니다.

config.json 파일이 Mbed 온라인 컴파일러에서 무시되는 것처럼 보입니다. 이 파일의 내용은 Bluetooth를 끄지 만 Micro : bit 라디오는 Bluetooth와 동시에 실행할 수없는 사용자 정의 스택을 사용합니다. 나는 또한 MicroBit.h 라이브러리에이 라인을 추가하여 블루투스 라이브러리를 해제 할 수 있습니다

#define MICROBIT_BLE_ENABLED 0 

이 다음 컴파일하고 온라인 Mbed 컴파일러 제대로 실행 예제를 할 수 있습니다.

config.json 파일 :

{ 
    microbit-dal:{ 
     bluetooth:{ 
      enabled: 0 
     } 
    } 
} 

microbit_simple_radio_rx :

#include "MicroBit.h" 

MicroBit uBit; 

void onData(MicroBitEvent) 
{ 
    ManagedString s = uBit.radio.datagram.recv(); 

    if (s == "1") 
     uBit.display.print("A"); 

    if (s == "2") 
     Bit.display.print("B"); 
} 

int main() 
{ 
    // Initialise the micro:bit runtime. 
    uBit.init(); 

    uBit.messageBus.listen(MICROBIT_ID_RADIO, 
     MICROBIT_RADIO_EVT_DATAGRAM, onData); 
    uBit.radio.enable(); 

    while(1) 
     uBit.sleep(1000); 
} 

microbit_simple_radio_tx 다음 Mbed 온라인 컴파일러 대신 config.json의, mbed_app.json를 사용

#include "MicroBit.h" 

MicroBit uBit; 

int main() 
{ 
    // Initialise the micro:bit runtime. 
    uBit.init(); 
    uBit.radio.enable(); 

    while(1) 
    { 
     uBit.display.print("t"); 
     if (uBit.buttonA.isPressed()) 
     { 
      uBit.radio.datagram.send("1"); 
      uBit.display.print("1"); 
     } 
     else if (uBit.buttonB.isPressed()) 
     { 
      uBit.radio.datagram.send("2"); 
      uBit.display.print("2"); 
     } 
     uBit.sleep(200);  
    } 
} 
+0

C! = C++. 둘 다 실제로 관련이없는 한 사용중인 언어로만 태그하십시오. – tambre

답변

3

. 그냥 프로젝트의 루트에 mbed_app.json과 장소에 그것을 넣어

{ 
    "macros": [ "MICROBIT_BLE_ENABLED=0" ] 
} 

: 당신을 통해 지금하려는 같이 동일한 기능을 수행 할 수 있습니다.

+0

감사합니다. – oppy