當前位置: 首頁>>代碼示例>>Java>>正文


Java ShieldFrame類代碼示例

本文整理匯總了Java中com.integreight.onesheeld.sdk.ShieldFrame的典型用法代碼示例。如果您正苦於以下問題:Java ShieldFrame類的具體用法?Java ShieldFrame怎麽用?Java ShieldFrame使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ShieldFrame類屬於com.integreight.onesheeld.sdk包,在下文中一共展示了ShieldFrame類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onSensorChanged

import com.integreight.onesheeld.sdk.ShieldFrame; //導入依賴的package包/類
@Override
public void onSensorChanged(SensorEvent event) {

    if (flag && (oldInput != event.values[0] || isFirstTime)) {
        isFirstTime = false;
        frame = new ShieldFrame(UIShield.TEMPERATURE_SHIELD.getId(),
                TEMPERATURE_VALUE);
        oldInput = event.values[0];
        frame.addArgument((byte) Math.round(event.values[0]));
        sendShieldFrame(frame);
        Log.d("Sensor Data of X", event.values[0] + "");
        if (eventHandler != null)
            eventHandler.onSensorValueChangedFloat(event.values[0] + "");
        //
        flag = false;
    }

}
 
開發者ID:Dnet3,項目名稱:CustomAndroidOneSheeld,代碼行數:19,代碼來源:TemperatureShield.java

示例2: run

import com.integreight.onesheeld.sdk.ShieldFrame; //導入依賴的package包/類
@Override
public void run() {
    // Do work
    ShieldFrame frame = new ShieldFrame(UIShield.CLOCK_SHIELD.getId(), CLOCK_VALUE);
    calendar = Calendar.getInstance();

    if (frame != null && calendar != null) {
        if (isClockBegin) {
            frame.addArgument((byte) calendar.get(Calendar.SECOND));
            sendShieldFrame(frame);
        }
        String hour = calendar.get(Calendar.HOUR_OF_DAY) + "";
        String min = calendar.get(Calendar.MINUTE) + "";
        String sec = calendar.get(Calendar.SECOND) + "";
        if (eventHandler != null)
            eventHandler.onTimeChanged(""
                            + (hour.length() == 1 ? "0" + hour : hour) + ":"
                            + (min.length() == 1 ? "0" + min : min) + ":"
                            + (sec.length() == 1 ? "0" + sec : sec) + "",
                    calendar.get(Calendar.AM_PM) == Calendar.AM);
    }
    if (handler != null)
        handler.postDelayed(this, PERIOD);

}
 
開發者ID:Dnet3,項目名稱:CustomAndroidOneSheeld,代碼行數:26,代碼來源:ClockShield.java

示例3: sendNewEmptyTagFrame

import com.integreight.onesheeld.sdk.ShieldFrame; //導入依賴的package包/類
private void sendNewEmptyTagFrame() {
    if (currentTag != null) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD_MR1) {
            DataReply tagId = getTagId();
            DataReply maxSize = getNdefMaxSize();
            if (!tagId.hasError() && !maxSize.hasError()) {
                ShieldFrame sf = new ShieldFrame(SHIELD_ID, NEW_TAG_FRAME);
                sf.addArgument(tagId.getBytesData());
                sf.addArgument(2, maxSize.getIntegerData());
                sf.addArgument(1, 0);
                sf.addArgument(2, 0);
                sendShieldFrame(sf, true);
            }else {
                sendError(TAG_READING_ERROR);
                return;
            }
        }
    }
}
 
開發者ID:Dnet3,項目名稱:CustomAndroidOneSheeld,代碼行數:20,代碼來源:NfcShield.java

示例4: onSensorChanged

import com.integreight.onesheeld.sdk.ShieldFrame; //導入依賴的package包/類
@Override
public void onSensorChanged(SensorEvent event) {

    if (flag && (oldInput != event.values[0] || isFirstTime)) {
        isFirstTime = false;
        frame = new ShieldFrame(UIShield.PRESSURE_SHIELD.getId(),
                PRESSURE_VALUE);
        oldInput = event.values[0];
        // frame.addByteArgument((byte) Math.round(event.values[0]));
        frame.addArgument(2, Math.round(event.values[0]));
        sendShieldFrame(frame);
        Log.d("Sensor Data of X", event.values[0] + "");
        if (eventHandler != null)
            eventHandler.onSensorValueChangedFloat(event.values[0] + "");
        //
        flag = false;
    }

}
 
開發者ID:Dnet3,項目名稱:CustomAndroidOneSheeld,代碼行數:20,代碼來源:PressureShield.java

示例5: onNewShieldFrameReceived

import com.integreight.onesheeld.sdk.ShieldFrame; //導入依賴的package包/類
@Override
public void onNewShieldFrameReceived(ShieldFrame frame) {
    // TODO Auto-generated method stub
    if (frame.getShieldId() == UIShield.FOURSQUARE_SHIELD.getId()) {
        if (isFoursquareLoggedInAlready())
            if (frame.getFunctionId() == CHECKIN_METHOD_ID) {
                placeID = frame.getArgumentAsString(0);
                message = frame.getArgumentAsString(1);
                if (ConnectionDetector
                        .isConnectingToInternet(getApplication()
                                .getApplicationContext())) {
                    ConnectFour connectFour = new ConnectFour();
                    connectFour.execute("");
                } else
                    Toast.makeText(
                            getApplication().getApplicationContext(),
                            R.string.general_toasts_please_check_your_internet_connection_and_try_again_toast,
                            Toast.LENGTH_SHORT).show();
            }
    }
}
 
開發者ID:Dnet3,項目名稱:CustomAndroidOneSheeld,代碼行數:22,代碼來源:FoursquareShield.java

示例6: setRowAndColumn

import com.integreight.onesheeld.sdk.ShieldFrame; //導入依賴的package包/類
public void setRowAndColumn(int row, int column) {
    ArduinoPin columnPin = matchedShieldPins.get(activity.getString(R.string.keypad_column)+" " + column);
    if (columnPin != null) {
        digitalWrite(columnPin.microHardwarePin, true);
    }
    columnByte = BitsUtils.setBit(columnByte, column);
    ArduinoPin rowPin = matchedShieldPins.get(activity.getString(R.string.keypad_row)+" " + row);
    if (rowPin != null) {
        digitalWrite(rowPin.microHardwarePin, true);
    }
    rowByte = BitsUtils.setBit(rowByte, row);
    sf = new ShieldFrame(UIShield.KEYPAD_SHIELD.getId(), DATA_IN);
    sf.addArgument(rowByte);
    sf.addArgument(columnByte);
    sendShieldFrame(sf);
}
 
開發者ID:Dnet3,項目名稱:CustomAndroidOneSheeld,代碼行數:17,代碼來源:KeypadShield.java

示例7: resetRowAndColumn

import com.integreight.onesheeld.sdk.ShieldFrame; //導入依賴的package包/類
public void resetRowAndColumn(int row, int column) {
    ArduinoPin columnPin = matchedShieldPins.get(activity.getString(R.string.keypad_column)+" " + column);
    if (columnPin != null) {
        digitalWrite(columnPin.microHardwarePin, false);
    }
    columnByte = BitsUtils.resetBit(columnByte, column);
    ArduinoPin rowPin = matchedShieldPins.get(activity.getString(R.string.keypad_row)+" " + row);
    if (rowPin != null) {
        digitalWrite(rowPin.microHardwarePin, false);
    }
    rowByte = BitsUtils.resetBit(rowByte, row);
    sf = new ShieldFrame(UIShield.KEYPAD_SHIELD.getId(), DATA_IN);
    sf.addArgument(rowByte);
    sf.addArgument(columnByte);
    sendShieldFrame(sf);

}
 
開發者ID:Dnet3,項目名稱:CustomAndroidOneSheeld,代碼行數:18,代碼來源:KeypadShield.java

示例8: onNewShieldFrameReceived

import com.integreight.onesheeld.sdk.ShieldFrame; //導入依賴的package包/類
@Override
public void onNewShieldFrameReceived(ShieldFrame frame) {

    if (frame.getShieldId() == UIShield.BUZZER_SHIELD.getId()) {
        byte argumentValue = frame.getArgument(0)[0];
        switch (argumentValue) {
            case BUZZER_ON:
                // turn on bin
                playSound();
                if (isResumed)
                    if (eventHandler != null)
                        eventHandler.onSpeakerChange(true);
                break;
            case BUZZER_OFF:
                // turn off bin
                stopBuzzer();
                if (eventHandler != null && isResumed)
                    eventHandler.onSpeakerChange(false);
                break;
            default:
                break;
        }

    }
}
 
開發者ID:Dnet3,項目名稱:CustomAndroidOneSheeld,代碼行數:26,代碼來源:SpeakerShield.java

示例9: run

import com.integreight.onesheeld.sdk.ShieldFrame; //導入依賴的package包/類
@Override
        public void run() {
            // Do work with the MIC values.
            double amplitude = MicSoundMeter.getInstance().getAmplitudeEMA();
            if (!Double.isInfinite(amplitude) && amplitude != 0) {
                initialRequest = false;
                ampl = amplitude;
//                Log.d("MIC", "Amp = " + ampl);
                frame = new ShieldFrame(UIShield.MIC_SHIELD.getId(), MIC_VALUE);
                frame.addArgument((byte) Math.round(ampl));
                sendShieldFrame(frame);
                if (isResumed)
                    if (eventHandler != null)
                        eventHandler.getAmplitude(ampl);
            }
            // The Runnable is posted to run again here:
            if (handler != null)
                handler.postDelayed(this, PERIOD);
        }
 
開發者ID:Dnet3,項目名稱:CustomAndroidOneSheeld,代碼行數:20,代碼來源:MicShield.java

示例10: getNodes

import com.integreight.onesheeld.sdk.ShieldFrame; //導入依賴的package包/類
public ArrayList<JsonNode> getNodes(ShieldFrame frame) {
    ArrayList<JsonNode> nodes = new ArrayList<>();
    int dataType = frame.getArgumentAsInteger(1);
    for (int i = 2; i < frame.getArguments().size(); i++) {
        JsonNode node = new JsonNode();
        if (BitsUtils.isBitSet(dataType, i - 2)) {
            node.setDataType(JsonNode.NODE_DATA_TYPE.OBJECT);
            node.setKey(frame.getArgumentAsString(i));
        } else {
            node.setDataType(JsonNode.NODE_DATA_TYPE.ARRAY);
            node.setIndex(frame.getArgumentAsInteger(i));
        }
        nodes.add(node);
    }
    return nodes;
}
 
開發者ID:Dnet3,項目名稱:CustomAndroidOneSheeld,代碼行數:17,代碼來源:InternetResponse.java

示例11: onSensorChanged

import com.integreight.onesheeld.sdk.ShieldFrame; //導入依賴的package包/類
@Override
public void onSensorChanged(SensorEvent event) {
    Sensor sensor = event.sensor;
    android.util.Log.d("Accelerometer", "onSensorChanged: " + sensor.getName());
    frame = new ShieldFrame(UIShield.ACCELEROMETER_SHIELD.getId(),
            ACCELEROMETER_VALUE);
    if (flag
            && (oldInput_x != event.values[0]
            || oldInput_y != event.values[1]
            || oldInput_z != event.values[2] || isFirstTime)) {
        isFirstTime = false;
        oldInput_x = event.values[0];
        oldInput_y = event.values[1];
        oldInput_z = event.values[2];
        // frame.addByteArgument((byte) Math.round(event.values[0]));
        frame.addArgument(event.values[0]);
        frame.addArgument(event.values[1]);
        frame.addArgument(event.values[2]);
        sendShieldFrame(frame);
        if (eventHandler != null)
            eventHandler.onSensorValueChangedFloat(event.values);
        flag = false;
    }
}
 
開發者ID:Integreight,項目名稱:1Sheeld-Android-App,代碼行數:25,代碼來源:AccelerometerShield.java

示例12: onResult

import com.integreight.onesheeld.sdk.ShieldFrame; //導入依賴的package包/類
@Override
public void onResult(List<String> result) {
    if (result != null && result.size() > 0) {
        isWorking = false;
        if (eventHandler != null)
            eventHandler.onResult(result);
        sf = new ShieldFrame(UIShield.SPEECH_RECOGNIZER_SHIELD.getId(),
                SEND_RESULT);
        recognized = result.get(0);
        sf.addArgument(recognized.toLowerCase());
        Log.d("Frame", sf.toString());
        sendShieldFrame(sf, true);
    } else {
        onError(activity.getString(R.string.voice_recognizer_no_matching_result), SpeechRecognizer.ERROR_NO_MATCH);
    }

}
 
開發者ID:Integreight,項目名稱:1Sheeld-Android-App,代碼行數:18,代碼來源:SpeechRecognitionShield.java

示例13: onShieldFrameReceive

import com.integreight.onesheeld.sdk.ShieldFrame; //導入依賴的package包/類
@Override
public void onShieldFrameReceive(OneSheeldDevice device, final ShieldFrame frame) {
    super.onShieldFrameReceive(device, frame);
    if (isALive && frame != null && matchedShieldPins.size() == 0 && isInit)
        if (frame.getShieldId() == getShieldId())
            if (frame.getFunctionId() == IS_SHIELD_SELECTED)
                notifyHardwareOfShieldSelection();
            else if (frame.getFunctionId() == SELECT_SHIELD) {
            } else if (frame.getFunctionId() == DESELECT_SHIELD) {
            } else {
                cachedArduinoCallbackStatus = device.isArduinoInACallback();
                actionHandler.post(new Runnable() {

                    @Override
                    public void run() {
                        try {
                            if (isInteractive)
                                ((T) ControllerParent.this)
                                        .onNewShieldFrameReceived(frame);
                            cachedArduinoCallbackStatus = false;
                        } catch (RuntimeException e) {
                            cachedArduinoCallbackStatus = false;
                            Toast.makeText(getActivity(), R.string.general_toasts_received_an_unexpected_frame_toast, Toast.LENGTH_SHORT).show();
                            CrashlyticsUtils.logException(e);
                        }
                    }
                });
            }
}
 
開發者ID:Dnet3,項目名稱:CustomAndroidOneSheeld,代碼行數:30,代碼來源:ControllerParent.java

示例14: onNewShieldFrameReceived

import com.integreight.onesheeld.sdk.ShieldFrame; //導入依賴的package包/類
@Override
public void onNewShieldFrameReceived(ShieldFrame frame) {
    if (frame.getShieldId() == UIShield.PHONE_SHIELD.getId()) {
        String phone_number = frame.getArgumentAsString(0);

        switch (frame.getFunctionId()) {
            case CALL_METHOD_ID:
                call(phone_number);
                break;
            default:
                break;
        }
    }

}
 
開發者ID:Dnet3,項目名稱:CustomAndroidOneSheeld,代碼行數:16,代碼來源:PhoneShield.java

示例15: sendIncomingNumber

import com.integreight.onesheeld.sdk.ShieldFrame; //導入依賴的package包/類
@Override
public void sendIncomingNumber(String phoneNumber) {
    // send frame contain Incoming Number..
    Log.d("Phone::Controller::SendIncomingNum", phoneNumber);
    frame = new ShieldFrame(UIShield.PHONE_SHIELD.getId(), (byte) 0x02);
    frame.addArgument(phoneNumber);
    sendShieldFrame(frame,true);
    if (eventHandler != null)
        eventHandler.onReceiveACall(phoneNumber);
}
 
開發者ID:Dnet3,項目名稱:CustomAndroidOneSheeld,代碼行數:11,代碼來源:PhoneShield.java


注:本文中的com.integreight.onesheeld.sdk.ShieldFrame類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。