ThermodoSDK 1.1.1

ThermodoSDK 1.1.1

测试已测试
语言语言 Obj-CObjective C
许可证 商业
发布最后发布2014年12月

Simon Støvring 维护。



  • 作者
  • Robocat

ThermodoSDK 允许您将 Thermodo 集成到您的 iOS 和 OS X 应用程序中。ThermodoSDK 为与 Thermodo 交互和获取温度读数提供了简单的接口。

Thermodo 是一款为您的移动设备设计的小型电热计,让您可以立即测量您所在的位置的温度。有关 Thermodo 的更多信息,请访问我们的 网站 或观看 Kickstarter 视频

手动安装

我们强烈建议您使用 CocoaPods 进行安装,以确保您始终使用最新版本。如果您不想使用 CocoaPods,当然您仍然可以手动安装 ThermodoSDK。

  1. 下载最新版本 版本
  2. 将所有 .h 和相应的框架(iOS 的 ThermodoSDK.framework 和 OS X 的 ThermodoSDKMac.framework)文件拖入您的 Xcode 项目。
  3. 确保您放置框架的位置位于“Framework 搜索路径”(在您的目标构建设置下)中。
  4. 如果您针对 OS X,您应该添加一个 Copy Files 构建阶段,将目标设置为 Frameworks,没有子路径,然后添加框架到这个构建阶段。如果您针对 iOS,您可以跳过此步骤。
  5. 就是这样!

用法

要开始,您需要注册一个委托,以便您的应用程序可以从设备开始和停止测量并获取温度读数。您的委托必须实现 THMThermodoDelegate 协议。

@protocol THMThermodoDelegate <NSObject>

@optional

/*!
 * If this method is implemented, it will get called after -start has been called and
 * whenever something is plugged into or out of the headphone jack.
 * @param thermodo The shared THMThermodo instance
 */
- (BOOL)thermodoShouldUseAudioInputAsThermodoDevice:(THMThermodo *)thermodo;

/**
 * This method is called when an input was detected.
 * @param thermodo The shared THMThermodo instance
 */
- (void)thermodoInputPluggedIn:(THMThermodo *)thermodo;

/**
 * This method is called when an input was unplugged.
 * @param thermodo The shared THMThermodo instance
 */
- (void)thermodoInputWasUnplugged:(THMThermodo *)thermodo;

/**
 * This method is called when the input was rejected as not being a Thermodo.
 * @param thermodo The shared THMThermodo instance
 */
- (void)thermodoDidRejectInput:(THMThermodo *)thermodo NS_AVAILABLE_IOS(6_0);

/*!
 * This method will be called when -start is called on TMThermodo while the device is plugged in
 * or once the device has been plugged in after -start has been called.
 * @param thermodo The shared THMThermodo instance
 */
- (void)thermodoDidStartMeasuring:(THMThermodo *)thermodo;

/*!
 * This method will be called when -stop is called on TMThermodo or when the device is unplugged.
 * @param thermodo The shared THMThermodo instance
 */
- (void)thermodoDidStopMeasuring:(THMThermodo *)thermodo;

/*!
 * This method will be called every time the Thermodo device returns a new temperature reading.
 * @param thermodo The shared THMThermodo instance
 * @param temperature The measured temperature in celcius
 */
- (void)thermodo:(THMThermodo *)thermodo didGetTemperature:(float)temperature;

/*!
 * This method will be called when a failure occurs.
 * @param thermodo The shared THMThermodo instance
 * @param error The error describing why the failure occurred.
 */
- (void)thermodo:(THMThermodo *)thermodo didFailWithError:(NSError *)error NS_AVAILABLE_IOS(6_0);

@end

要开始测量,只需注册您的委托并要求 THMThermodo 实例开始测量

@interface MyViewController () <THMThermodoDelegate>
@end

@implementation MyViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    [[THMThermodo sharedThermodo] setDelegate:self];
    [[THMThermodo sharedThermodo] start];
}

- (void)thermodo:(THMThermodo *)thermodo didGetTemperature:(CGFloat)temperature {
    // Display the temperature reading
}

@end

在这个例子中,我们简单地将我们的视图控制器用作 Thermodo 的委托。虽然这可以完美工作,但如果您需要从多个位置访问 Thermodo 读数,您可能想要将您的委托与视图控制器解耦,因为 Thermodo 设备只能有一个委托。

检测

您可以通过将 detectionEnabled 设置为 true 来启用检测。请注意,检测目前在 OS X 框架中不受支持。

由于检测的工作方式,可能会出现Thermodo无法检测到的场景。这可能会发生在用户使用某些延长线的情况下。因此,我们建议,如果您启用检测,还应为用户提供禁用检测的选项。尽管检测并不覆盖所有场景,但我们强烈建议您在您的应用程序中启用它。否则,如果用户用耳机线插入时打开您的应用程序,他们可能会遇到高频噪音。

当启用检测时,除了thermodoDidStartMeasuring:thermodoDidStopMeasuring:thermodo:didGetTemperature:之外,您可能还想实现以下三个代理方法。

/**
 * This method is called when an input was detected.
 * @param thermodo The shared THMThermodo instance
 */
- (void)thermodoInputPluggedIn:(THMThermodo *)thermodo;

/**
 * This method is called when an input was unplugged.
 * @param thermodo The shared THMThermodo instance
 */
- (void)thermodoInputWasUnplugged:(THMThermodo *)thermodo;

/**
 * This method is called when the input was rejected as not being a Thermodo.
 * @param thermodo The shared THMThermodo instance
 */
- (void)thermodoDidRejectInput:(THMThermodo *)thermodo NS_AVAILABLE_IOS(6_0);

@end

thermodoInplutPluggedIn:会通知您某些硬件已插入音频端口。此时,无法确定输入是Thermodo还是耳机。如果发现输入不是Thermodo,则将调用thermodoDidRejectInput:方法。然而,如果开始测量并且调用thermodoDidStartMeasuring:,则输入是Thermodo。当音频端口的硬件被拔出时,无论是Thermodo还是其他设备,都会调用thermodoInputWasUnplugged:方法。

OS X 测试版

请注意,OS X SDK目前正在测试版。我们发现SDK可能在某些Mac上无法正常工作,并且我们正在不断为更多机器添加支持。如果您发现SDK在某台特定硬件上无法正常工作,请提交一个问题。

常见问题解答(FAQ)

我可以在没有Thermodo设备的情况下尝试/使用ThermodoSDK吗?

不。为了获取设备读数和任何类型的SDK响应,您必须具有Thermodo设备进行测试。您可以从我们的网站购买设备。

设备的读数过高

我们花费了大量时间确保Thermodo提供准确且一致的温度读数。不幸的是,这种精度也意味着Thermodo传感器容易受到您设备(iPhone / iPad / Macbook)或手掌的热量的影响。为了获得最准确的读数,我们建议使用延长线。更多信息请参见这个Kickstarter项目的视频更新

贡献

我们热爱我们的社区和开发者同行。如果您发现改进ThermodoSDK或发现某个地方有错误的方法,请通过开设一个问题的方式告诉我们。