本文整理汇总了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;
}
}
示例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);
}
示例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;
}
}
}
}
示例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;
}
}
示例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();
}
}
}
示例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);
}
示例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);
}
示例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;
}
}
}
示例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);
}
示例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;
}
示例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;
}
}
示例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);
}
}
示例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);
}
}
});
}
}
示例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;
}
}
}
示例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);
}