iOS AILinkBleSDK - 蓝牙SDK
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ELUnitConvertTool.h 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. //
  2. // ELUnitChangeTool.h
  3. // Elink
  4. //
  5. // Created by steven wu on 2019/9/21.
  6. // Copyright © 2019 iot_iMac. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import "ELSDKHeader.h"
  10. #define StLbSymbol @":"
  11. #define FeetSymbol @"′"
  12. #define InchSymbol @"″"
  13. #define KG_LB_CONST 2.2046226f
  14. #define ST_LB_CONST 14.0f
  15. #define INCH_CM_CONST 2.54f
  16. #define FEET_INCH_CONST 12.0f
  17. @interface ELUnitConvertTool : NSObject
  18. /**
  19. Convert the integer returned by Bluetooth to the character string required for interface display, the display unit is the current user unit
  20.   @param weightInt AILink protocol integer returned by Bluetooth
  21.   @param unit kg / lb / st: lb / jin
  22.   @param point 1,2
  23.   @return The weight displayed on the interface, such as 5: 6.5 st: lb
  24. 将蓝牙返回的整数,转换为界面显示所需要的字符串,显示单位为当前用户单位
  25. // weightInt AILink协议蓝牙返回的整数
  26. // unit kg/lb/st:lb/jin
  27. // point 1,2
  28. // 界面显示的体重,如 5:6.5 st:lb
  29. */
  30. + (NSString *)getWeightShowStrWithTargetUnit:(ELDeviceWeightUnit)targetUnit bleWeightInt:(NSUInteger)weightInt bleWeightUnit:(ELDeviceWeightUnit)unit bleWeightPoint:(NSUInteger)point;
  31. + (NSString *)getHeightShowStrWithTargetUnit:(ELDeviceHeightUnit)targetUnit origHeightShow:(NSString *)origHeightShow origHeightUnit:(ELDeviceHeightUnit)origHeightUnit origHeightPoint:(NSUInteger)origHeightPoint;
  32. /**
  33. Display data returned from the server or converted from the original Bluetooth data: such as 5: 6.5, 56.2, etc., converted to kg for drawing or conversion
  34.   @param weightShow The data read directly from the database, or the AILink protocol Bluetooth returns to the interface 68.56 (kg) 120.6 (lb)
  35.   @param unit kg / lb / st: lb / jin
  36.   @param point 1,2
  37.   @return is converted to the value of kg (the number of kg used for drawing or conversion, rounded to 2 decimal places)
  38. 将服务器返回或者蓝牙原始数据转换来的显示数据:如5:6.5、56.2等数据转换为kg,用来画图或者换算
  39. // weightShow 从数据库中直接读出来的,或者AILink协议蓝牙返给界面的数据 68.56(kg) 120.6(lb)
  40. // unit kg/lb/st:lb/jin
  41. // point 1,2
  42. // 转换为kg的值(用于绘图或换算的kg数,一律四舍五入保留2位小数)
  43. */
  44. + (NSString *)getKgWithWeightShowStr:(NSString *)weightShow weightUnit:(ELDeviceWeightUnit)unit weightPoint:(NSUInteger)point;
  45. + (NSString *)getCmWithHeightShowStr:(NSString *)heightShow heightUnit:(ELDeviceHeightUnit)unit heightPoint:(NSUInteger)point;
  46. @end