Jump to content
View in the app

A better way to browse. Learn more.

Tinkerunity

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Geschrieben

Hallo, kann jemand mir sagen, wie ich ContinuousAcceleration16BitCallback für Accelerometer Bricklet 2.0 nutzen. Wie so ich programmieren? Vielen dank.

Geschrieben

Geht das etwas präziser?

- den Callback gibt es nicht?? Bzw. ich habe ihn nicht gefunden

- in welcher Progrmmiersprache?

 

Oder meinst Du sowas:

https://www.tinkerforge.com/de/doc/Software/Bricklets/AccelerometerV2_Bricklet_C.html#c.ACCELEROMETER_V2_CALLBACK_CONTINUOUS_ACCELERATION_16_BIT

 

Da sind eigentlich Beispiele pro Sprache in der Doku drin?

Was fehlt?

Geschrieben
  • Autor

Vielen Dank für ihre Antwort. Meine Progrmmiersprache ist Matlab. Die Beschreibung in der Doku ist nicht ausführlich ,und ich kann nicht sehr gut verstehen.Es gibt auch kein Beispiel für ContinuousAcceleration16BitCallback.

 

Geschrieben
  • Autor

Aber das ist nur ein Beispiel für AccelerationCallback, ich brauche ein Beispiel

fÜr ContinuousAcceleration16BitCallback.

Geschrieben

Anbei ein Beispiel:

 

function matlab_example_continuous_callback()
    import com.tinkerforge.IPConnection;
    import com.tinkerforge.BrickletAccelerometerV2;

    HOST = 'localhost';
    PORT = 4223;
    UID = 'XYZ'; % Change XYZ to the UID of your Accelerometer Bricklet 2.0

    ipcon = IPConnection(); % Create IP connection
    a = handle(BrickletAccelerometerV2(UID, ipcon), 'CallbackProperties'); % Create device object

    ipcon.connect(HOST, PORT); % Connect to brickd
    % Don't use device before ipcon is connected

    % Register acceleration callback to function cb_acceleration
    set(a, 'ContinuousAcceleration16BitCallback', @(h, e) cb_continuous_acceleration(e));

    % Get X, Y and Z axis continuous acceleration with 16-bit resolution
    a.setContinuousAccelerationConfiguration(true, true, true, BrickletAccelerometerV2.RESOLUTION_16BIT);

    input('Press key to exit\n', 's');
    ipcon.disconnect();
end

% Callback function for continuous acceleration callback
function cb_continuous_acceleration(e)
    data_all = [];
    data_axis = [];

    for i = 1:length(e.acceleration)
        if mod(i, 3) ~= 0
            data_axis = [data_axis double(e.acceleration(i)) / 10000.0];
        else
            data_axis = [data_axis double(e.acceleration(i)) / 10000.0];
            data_all = [data_all; data_axis];
            data_axis = [];
        end
    end

    for i = 1:length(data_all)
        data_axis = data_all(i,;

        for j = 1:length(data_axis)
            if j == 1
                fprintf('Acceleration [X]: %g g\n', data_axis(j));
            elseif j == 2
                fprintf('Acceleration [Y]: %g g\n', data_axis(j));
            else
                fprintf('Acceleration [Z]: %g g\n\n', data_axis(j));
            end
        end
    end

    fprintf('\n');
end

Geschrieben
  • Autor

Vielen Dank für ihr Progamm. Ich habe noch eine Frage, wie ich die Periode von ContinuousAcceleration16BitCallback vorgebe?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Gast
Reply to this topic...

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.