当前位置: 首页>>代码示例>>Java>>正文


Java PebbleDictionary.addUint16方法代码示例

本文整理汇总了Java中com.getpebble.android.kit.util.PebbleDictionary.addUint16方法的典型用法代码示例。如果您正苦于以下问题:Java PebbleDictionary.addUint16方法的具体用法?Java PebbleDictionary.addUint16怎么用?Java PebbleDictionary.addUint16使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.getpebble.android.kit.util.PebbleDictionary的用法示例。


在下文中一共展示了PebbleDictionary.addUint16方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sendImagePacket

import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的package包/类
private void sendImagePacket()
{
    PebbleDictionary data = new PebbleDictionary();

    data.addUint8(0, (byte) 1);
    data.addUint8(1, (byte) 2);
    data.addUint16(2, (short) 0); //Image size placeholder

    int maxBytesToSend = PebbleUtil.getBytesLeft(data, getService().getPebbleCommunication().getConnectedWatchCapabilities());

    int bytesToSend = Math.min(callerImageBytes.length - callerImageNextByte, maxBytesToSend);
    byte[] bytes = new byte[bytesToSend];
    System.arraycopy(callerImageBytes, callerImageNextByte, bytes, 0, bytesToSend);

    data.addUint16(2, (short) bytesToSend); //Image size placeholder
    data.addBytes(3, bytes);

    getService().getPebbleCommunication().sendToPebble(data);
    Timber.d("Sent image packet %d / %d", callerImageNextByte, callerImageBytes.length);

    callerNameUpdateRequired = false;

    callerImageNextByte += bytesToSend;
    if (callerImageNextByte >= callerImageBytes.length)
        callerImageNextByte = -1;
}
 
开发者ID:matejdro,项目名称:PebbleDialer-Android,代码行数:27,代码来源:CallModule.java

示例2: sendContacts

import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的package包/类
private void sendContacts(int offset)
{
	PebbleDictionary data = new PebbleDictionary();

	data.addUint8(0, (byte) 3);
       data.addUint8(1, (byte) 0);

       data.addUint16(2, (short) offset);
	data.addUint16(3, (short) names.size());

	for (int i = 0; i < 3; i++)
	{
		int listPos = offset + i;
		if (listPos >= names.size())
			break;

		data.addString(i + 4, names.get(i + offset));
	}

       getService().getPebbleCommunication().sendToPebble(data);
}
 
开发者ID:matejdro,项目名称:PebbleDialer-Android,代码行数:22,代码来源:ContactsModule.java

示例3: sendPebbleSdSettings

import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的package包/类
/**
 * Send the pebble watch settings that are stored as class member
 * variables to the watch.
 */
public void sendPebbleSdSettings() {
    Log.v(TAG, "sendPebblSdSettings() - preparing settings dictionary.. mSampleFreq=" + mSampleFreq);
    mUtil.writeToSysLogFile("SdDataSourcePebble.sendPebbleSdSettings()");

    // Watch Settings
    final PebbleDictionary setDict = new PebbleDictionary();
    setDict.addInt16(KEY_DEBUG, mDebug);
    setDict.addInt16(KEY_DISPLAY_SPECTRUM, mDisplaySpectrum);
    setDict.addInt16(KEY_DATA_UPDATE_PERIOD, mDataUpdatePeriod);
    setDict.addInt16(KEY_MUTE_PERIOD, mMutePeriod);
    setDict.addInt16(KEY_MAN_ALARM_PERIOD, mManAlarmPeriod);
    setDict.addInt16(KEY_SD_MODE, mPebbleSdMode);
    setDict.addInt16(KEY_SAMPLE_FREQ, mSampleFreq);
    setDict.addInt16(KEY_SAMPLE_PERIOD, mSamplePeriod);
    setDict.addInt16(KEY_ALARM_FREQ_MIN, mAlarmFreqMin);
    setDict.addInt16(KEY_ALARM_FREQ_MAX, mAlarmFreqMax);
    setDict.addUint16(KEY_WARN_TIME, mWarnTime);
    setDict.addUint16(KEY_ALARM_TIME, mAlarmTime);
    setDict.addUint16(KEY_ALARM_THRESH, mAlarmThresh);
    setDict.addUint16(KEY_ALARM_RATIO_THRESH, mAlarmRatioThresh);
    if (mFallActive)
        setDict.addUint16(KEY_FALL_ACTIVE, (short) 1);
    else
        setDict.addUint16(KEY_FALL_ACTIVE, (short) 0);
    setDict.addUint16(KEY_FALL_THRESH_MIN, mFallThreshMin);
    setDict.addUint16(KEY_FALL_THRESH_MAX, mFallThreshMax);
    setDict.addUint16(KEY_FALL_WINDOW, mFallWindow);

    // Send Watch Settings to Pebble
    Log.v(TAG, "sendPebbleSdSettings() - setDict = " + setDict.toJsonString());
    PebbleKit.sendDataToPebble(mContext, SD_UUID, setDict);
}
 
开发者ID:OpenSeizureDetector,项目名称:Android_Pebble_SD,代码行数:37,代码来源:SdDataSourcePebble.java

示例4: discover

import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的package包/类
public void discover() {
	localNetworkContext = LFXClient.getSharedInstance(getApplicationContext()).getLocalNetworkContext();
    localNetworkContext.connect();
    bulbList = localNetworkContext.getAllLightsCollection().getLights();
    Log.i("PebbLIFXService", "Bulb List: " + bulbList.toString());
	if (bulbList == null) {
		Log.e("PebbLIFXService","Nothing returned. No network found.");
		sendMessage(0);
	} else {
		Log.i("PebbLIFXService", "Search has completed.");
		int numberOfBulbs = bulbList.size();
		Log.i("PebbLIFXService", "Bulb List Size:" + numberOfBulbs);
		if (PebbleKit.areAppMessagesSupported(getApplicationContext())) {
			PebbleDictionary bulbData = new PebbleDictionary();
			bulbData.addUint8(0, (byte) 1);
			bulbData.addUint8(1, (byte) numberOfBulbs); // Will only allow 255 bulbs to be passed.
			int j = 2;
			for (int i = 0; i < numberOfBulbs; i++) {
				// First get the bulb name.
				bulbData.addString(j++, bulbList.get(i).getLabel());
				// Find out whether bulbs are on or off.
				LFXPowerState a = bulbList.get(i).getPowerState();
				if (a == LFXPowerState.ON) {
					bulbData.addUint8(j++, (byte)1);
				} else {
					bulbData.addUint8(j++, (byte)0);
				}
				//	TODO Fix brightness and hue getting. Returning nothing.
				bulbData.addUint16(j++, (short)getUnsignedInt(bulbList.get(i).getColor().getBrightness()));
				bulbData.addUint16(j++, (short)getUnsignedInt(bulbList.get(i).getColor().getHue()));
			}
			Log.i("PebbLIFXService", "Dictionary -> " + bulbData.toJsonString());
			Log.i("PebbLIFXService", "Dictionary Size = " + bulbData.size());
			PebbleKit.sendDataToPebble(getApplicationContext(), PEBBLE_APP_UUID, bulbData);
			Log.i("PebbLIFXService", "Data sent.");
		}
	}
}
 
开发者ID:jadengore,项目名称:PebbLIFX,代码行数:39,代码来源:PebbLIFXService.java

示例5: sendEntriesPacket

import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的package包/类
public void sendEntriesPacket(int offset)
{
       if (entries.size() <= offset)
           return;

       CallLogEntry callLogEntry = entries.get(offset);

	PebbleDictionary data = new PebbleDictionary();

	data.addUint8(0, (byte) 2);
       data.addUint8(1, (byte) 0);
       data.addUint16(2, (short) offset);
	data.addUint16(3, (short) entries.size());

	data.addUint8(4, (byte) callLogEntry.eventType);
	data.addString(6, callLogEntry.date);

	if (callLogEntry.name == null)
           callLogEntry.name = TextUtil.prepareString(callLogEntry.number);

	data.addString(5, callLogEntry.name);

	if (callLogEntry.numberType == null)
           callLogEntry.numberType = "";
	data.addString(7, callLogEntry.numberType);

       if (openWindow)
           data.addUint8(999, (byte) 1);

       getService().getPebbleCommunication().sendToPebble(data);
}
 
开发者ID:matejdro,项目名称:PebbleDialer-Android,代码行数:32,代码来源:CallLogModule.java

示例6: sendFakeCall

import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的package包/类
/**
 * Pre 2.2 watchapp does not have update screen so we display fake call screen
 */
private void sendFakeCall()
{
    PebbleDictionary data = new PebbleDictionary();

    data.addUint8(0, (byte) 5);

    data.addString(1, "Old PebbleDialer");
    data.addString(2, "");

    data.addString(3, "Check phone");

    byte[] parameters = new byte[4];
    parameters[0] = 1;
    parameters[3] = 1;

    data.addBytes(4, parameters);

    data.addUint16(5, (short) 0);

    getService().getPebbleCommunication().sendToPebble(data);

    runOnNext = new Callable<Boolean>()
    {
        @Override
        public Boolean call() throws Exception
        {
            //Pretend that I sent new message to prevent other modules sending potentially unsupported messages
            return true;
        }
    };

    WatchappHandler.showUpdateNotification(getService());
}
 
开发者ID:matejdro,项目名称:PebbleDialer-Android,代码行数:37,代码来源:SystemModule.java

示例7: sendNumbers

import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的package包/类
public void sendNumbers(int offset)
{
    PebbleDictionary data = new PebbleDictionary();


    data.addUint8(0, (byte) 4);
    data.addUint8(1, (byte) 0);

    data.addUint16(2, (short) offset);
    data.addUint16(3, (short) phoneNumbers.size());


    byte[] numberActions = new byte[2];
    for (int i = 0; i < 2; i++)
    {
        int listPos = offset + i;
        if (listPos >= phoneNumbers.size())
            break;

        PebbleNumberEntry numberEntry = phoneNumbers.get(listPos);

        data.addString(i + 4, TextUtil.prepareString(numberEntry.numberType));
        data.addString(i + 6, TextUtil.prepareString(numberEntry.number));
        numberActions[i] = (byte) numberEntry.numberAction;
    }

    data.addBytes(8, numberActions);

    if (openWindow)
        data.addUint8(999, (byte) 1);

    Timber.d("sendNumbers %d", offset);
    getService().getPebbleCommunication().sendToPebble(data);
}
 
开发者ID:matejdro,项目名称:PebbleDialer-Android,代码行数:35,代码来源:NumberPickerModule.java

示例8: sendUpdatePacket

import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的package包/类
private void sendUpdatePacket()
{
    PebbleDictionary data = new PebbleDictionary();

    data.addUint8(0, (byte) 1);
    data.addUint8(1, (byte) 0);

    boolean nameAtBottomWhenImageDisplayed = callerImage != null && getService().getGlobalSettings().getBoolean("bottomCallerName", true);

    if (name != null && type != null)
    {
        data.addString(2, TextUtil.prepareString(type, 30));
        data.addString(3, TextUtil.prepareString(number, 30));
    }
    else
    {
        data.addString(2, "");
        data.addString(3, "");
    }

    List<Byte> vibrationPattern;
    if (vibrating)
    {
        String vibrationPatternString = getService().getGlobalSettings().getString("vibrationPattern", "100, 100, 100, 1000");
        vibrationPattern = PebbleVibrationPattern.parseVibrationPattern(vibrationPatternString);
    }
    else
    {
        vibrationPattern = PebbleVibrationPattern.EMPTY_VIBRATION_PATTERN;
    }


    byte[] parameters = new byte[8 + vibrationPattern.size()];
    parameters[0] = (byte) (callState == CallState.ESTABLISHED ? 1 : 0);
    parameters[1] = (byte) (nameAtBottomWhenImageDisplayed ? 1 : 0);
    parameters[6] = (byte) (identityUpdateRequired ? 1 : 0);

    parameters[2] = (byte) getCallAction(getUserSelectedAction(getExtendedButtonId("Up"))).getIcon();
    parameters[3] = (byte) getCallAction(getUserSelectedAction(getExtendedButtonId("Select"))).getIcon();
    parameters[4] = (byte) getCallAction(getUserSelectedAction(getExtendedButtonId("Down"))).getIcon();

    parameters[7] = (byte) vibrationPattern.size();
    for (int i = 0; i < vibrationPattern.size(); i++)
        parameters[8 + i] = vibrationPattern.get(i);

    data.addBytes(4, parameters);

    if (callState == CallState.ESTABLISHED)
        data.addUint16(5, (short) Math.min(65000, (System.currentTimeMillis() - callStartTime) / 1000));

    data.addUint8(999, (byte) 1);

    callerImageNextByte = -1;
    if (identityUpdateRequired && getService().getPebbleCommunication().getConnectedWatchCapabilities().hasColorScreen())
    {
        int imageSize = 0;

        if (callerImage != null)
        {
            processContactImage();
            imageSize = callerImageBytes.length;
        }

        data.addUint16(7, (short) imageSize);

        if (imageSize != 0)
            callerImageNextByte = 0;

        Timber.d("Image size: %d", imageSize);
    }

    getService().getPebbleCommunication().sendToPebble(data);
    Timber.d("Sent Call update packet. New identity: %b", identityUpdateRequired);

    callerNameUpdateRequired = identityUpdateRequired;
    updateRequired = false;
    identityUpdateRequired = false;
}
 
开发者ID:matejdro,项目名称:PebbleDialer-Android,代码行数:79,代码来源:CallModule.java

示例9: sendListItem

import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的package包/类
public void sendListItem(int index)
{
    PebbleDictionary data = new PebbleDictionary();

    if (index >= listAdapter.getNumOfNotifications())
    {
        data.addUint8(0, (byte) 2);
        data.addUint8(1, (byte) 0);
        data.addUint16(2, (short) 0);
        data.addUint16(3, (short) 1);
        data.addUint8(4, (byte) 1);
        data.addString(5, "No notifications");
        data.addString(6, "");
        data.addString(7, "");
        data.addUint16(8, (short) 0);

        if (openListWindow)
            data.addUint8(999, (byte) 1);

        getService().getPebbleCommunication().sendToPebble(data);

        return;
    }

    PebbleNotification notification = listAdapter.getNotificationAt(index);

    data.addUint8(0, (byte) 2);
    data.addUint8(1, (byte) 0);
    data.addUint16(2, (short) index);
    data.addUint16(3, (short) listAdapter.getNumOfNotifications());
    data.addUint8(4, (byte) (notification.isDismissable() ? 0 : 1));
    data.addString(5, TextUtil.prepareString(notification.getTitle()));
    data.addString(6, TextUtil.prepareString(notification.getSubtitle()));
    data.addString(7, getFormattedDate(getService(), notification.getRawPostTime()));
    data.addUint16(8, (short) 0); // Placeholder

    if (openListWindow)
        data.addUint8(999, (byte) 1);

    Bitmap icon = notification.getNotificationIcon();
    if (icon != null)
    {
        PebbleCapabilities connectedWatchCapabilities = getService().getPebbleCommunication().getConnectedWatchCapabilities();
        int iconColor = Color.BLACK;
        int notificationColor = notification.getColor();

        if (connectedWatchCapabilities.hasColorScreen() && notificationColor != Color.TRANSPARENT)
        {
            iconColor = notificationColor;
            //Make sure icon contrasts with white list background
            if (PebbleImageToolkit.getLuminance(iconColor) > 255 * 3 / 2)
                iconColor = PebbleImageToolkit.multiplyBrightness(iconColor, 0.5f);
        }
        byte[] iconData = ImageSendingModule.prepareTintedIcon(icon, getService(), connectedWatchCapabilities, iconColor, false);

        // This feature requires lots of memory on the watch to contain lots of icons for every list item
        // To weed out low memory devices, a device must be able to afford to receive at least 2048 bytes of the appmessage.
        int minAppmessageBufferSize = Math.max(2048, iconData.length);

        if (PebbleUtil.getBytesLeft(data, connectedWatchCapabilities) >= minAppmessageBufferSize)
        {
            data.addUint16(8, (short) iconData.length); // Placeholder
            data.addBytes(9, iconData);
        }
    }

    Timber.i("Sending list entry %d %s", index, data.getString(5));

    getService().getPebbleCommunication().sendToPebble(data);
}
 
开发者ID:matejdro,项目名称:PebbleNotificationCenter-Android,代码行数:71,代码来源:ListModule.java

示例10: sendToPebble

import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的package包/类
public void sendToPebble(String distance, int bearingIndex, int azimuth, int decl) {
	
	boolean hasExtras = checkHasExtras();
	
	PebbleDictionary data = new PebbleDictionary();

    data.addString(DISTANCE_KEY, distance);
    data.addUint8(BEARING_INDEX_KEY, (byte)bearingIndex);
    data.addUint16(AZIMUTH_KEY, (short) azimuth);
    data.addInt16(DECLINATION_KEY, (short) decl);
    data.addUint8(EXTRAS_KEY, (byte)(hasExtras?1:0) );

    Log.i("Nace", String.valueOf( (short)decl ));
    
    if(hasExtras){
    	
    	data.addString(DT_RATING_KEY, "D"+((gc_difficulty == (int)gc_difficulty) ? String.format("%d", (int)gc_difficulty) : String.format("%s", gc_difficulty))+" / T"+
    			((gc_terrain == (int)gc_terrain) ? String.format("%d", (int)gc_terrain) : String.format("%s", gc_terrain)) );
    	
    	data.addString(GC_NAME_KEY, (gc_name.length() > 20) ? gc_name.substring(0, 20) : gc_name);
    	data.addString(GC_CODE_KEY, gc_code);
    	data.addString(GC_SIZE_KEY, gc_size);
    	
    }
    
    PebbleKit.sendDataToPebble(getApplicationContext(), uuid, data);
    
}
 
开发者ID:WebMajstr-,项目名称:pebble-navigation,代码行数:29,代码来源:WatchService.java


注:本文中的com.getpebble.android.kit.util.PebbleDictionary.addUint16方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。