• I might be a giant AssHat(tm) as it has been forever since I last did C++ but I can't seem to get the accelerometer code to work.

    If added the mono::sensor namespace, but when I try to declare an accelerometer (MMAAccelerometer Accel;) in my AppController header I get
    app_controller.h:21:2: error: 'MMAAccelerometer' does not name a type
    MMAAccelerometer Accel;

  • Hi @bo-vejgaard, use can use this code:


    class AppController : public mono::IApplication {
        sensor::MMAAccelerometer accel;
       // of AppController.h...


    void AppController::monoWakeFromReset()
        // start accelerometer sampling
        // set the text label to be shown;
        // sample the accelerometers X axis
        int16_t x = accel.rawXAxis();
        // display the raw sample on the screen
        mono::String text = mono::String::Format("x axis: %i",x);

    I still need to add methods for Y and Z axis, but you can lure the code at:

  • Thank you! I'll try.

  • @stoffera Sorry, I still get the same error:

    app_controller.h:20:10: error: 'MMAAccelerometer' in namespace 'mono::sensor' does not name a type
    sensor::MMAAccelerometer accel;

  • @bo.vejgaard said in Accelerometer?:

    error: 'MMAAccelerometer' in namespace 'mono::sensor' does not name a type

    My bad, there is an include missing, add this to your header file: #include <mono_accelerometer.h>

  • @stoffera said in Accelerometer?:

    #include <mono_accelerometer.h>

    Thank you that solved the issue.

Log in to reply