/// 设置CPI
- (void)setCPI:(NSInteger)value completation:(void (^)(BOOL isSuccess,NSError *error))finished{
if (self.productType == AiMouseProductType_tlw) {
- NSDictionary *dict = @{
- @"800":@"0",
- @"1200":@"1",
- @"1600":@"2",
- @"2400":@"3",
- };
-
- if (dict[[NSString stringWithFormat:@"%ld",value]]) {
- int num = [dict[[NSString stringWithFormat:@"%ld",value]] intValue];
- [self.tlwSdk setDPI:num completation:finished];
- }
- else{
- [self showLog:[NSString stringWithFormat:@"CPI值设置错误 %ld",value]];
- [self.tlwSdk setDPI:0 completation:finished];
- }
+ [self.tlwSdk setDPI:value completation:finished];
}
else{
[self.frkSdk setCPI:value completation:finished];
#import "AiMouseSdk.h"
@interface TlwDeviceInfo : NSObject
-@property (nonatomic, assign) int DPI;/// DPI值 数值1 ~ 4 (分别对应 800 1200 1800 2400)
+@property (nonatomic, assign) int DPI;/// DPI值 数值1 ~ 4 (分别对应1200,1600,2400,4800)
@property (nonatomic, assign) int version;///软件版本
@property (nonatomic, assign) int batteryState;/// 电池状态
@property (nonatomic, assign) int batteryValue;/// 电池百分百电量,0-100
/// 设置DPI
/// - Parameters:
-/// - value: 数值1 ~ 4 (分别对应 800 1200 1800 2400)
/// - finished: 设置结果回调
-- (void)setDPI:(uint8_t)value completation:(void (^)(BOOL isSuccess,NSError *error))finished;
+- (void)setDPI:(NSInteger)value completation:(void (^)(BOOL isSuccess,NSError *error))finished;
/// 打开录音
/// - finished: 执行结果回调
}
-- (void)setDPI:(uint8_t)value completation:(void (^)(BOOL isSuccess,NSError *error))finished{
+- (void)setDPI:(NSInteger)num completation:(void (^)(BOOL isSuccess,NSError *error))finished{
+ NSDictionary *dict = @{
+ @"1200":@"1",
+ @"1600":@"2",
+ @"2400":@"3",
+ @"4800":@"4",
+ };
+ NSString *valueString = dict[[NSString stringWithFormat:@"%ld",num]];
+ if (valueString == nil) {
+ valueString = @"1";
+ [self showLog:[NSString stringWithFormat:@"CPI值设置错误 %ld",num]];
+ }
+ uint8_t value = [valueString intValue];
+ if (value < 1 || value > 4) {
+ value = 1;
+ }
+
if(self.connectType == AiMouseConnectType_hid){
self.setDpiCallBack = finished;
uint8_t type = 0x06;
__weak typeof(self) ws = self;
[self getDeviceInfo:^(TlwDeviceInfo *deviceInfo, NSError *error) {
if(deviceInfo != nil){
- NSString *CPI_list = @"800,1200,1600,2400";// 0-3,800 1200 1600 2400
- NSString *cpi = @"0";
+ NSDictionary *dict = @{
+ @"1200":@"1",
+ @"1600":@"2",
+ @"2400":@"3",
+ @"4800":@"4",
+ };
- if ([CPI_list componentsSeparatedByString:@","].count - 1 >= deviceInfo.DPI) {
- cpi = [[CPI_list componentsSeparatedByString:@","] objectAtIndex:deviceInfo.DPI];
+ NSString *CPI_list = [[dict allKeys] componentsJoinedByString:@","];
+ NSString *level = [NSString stringWithFormat:@"%d",deviceInfo.DPI];
+ NSString *dpiValue = @"1200";
+
+ for (NSString *key in dict) {
+ if ([dict[key] isEqualToString:level]) {
+ dpiValue = key;
+ break;;
+ }
}
AiMouseDeviceInfo *info = [[AiMouseDeviceInfo alloc] init];
info.battery_power = [NSString stringWithFormat:@"%d",deviceInfo.batteryValue] ;
info.version = [NSString stringWithFormat:@"%d",deviceInfo.version];
info.CPI_list = CPI_list;
- info.CPI = cpi;
+ info.CPI = dpiValue;
ws.fullInfo = info;
[ws getSnInfo:^(TlwSnInfo *snInfo, NSError *error) {
#import "ViewController.h"
#import "ScanVC.h"
#import "DeviceManger.h"
+#import "Config.h"
@interface ViewController ()
@property(nonatomic,strong)NSTextField *typeLabel;///当前模式状态
@property(nonatomic,strong)NSTextField *connectLabel;///连接状态
// [AiHidManager shared];
DeviceManger *manager = [DeviceManger shared];
__weak typeof(self) ws = self;
+ manager.aiMouseAddLogCallBack = ^(NSString * _Nonnull log) {
+ NSLog(@"%@",log);
+ };
manager.authCallBack = ^(BOOL isSuccess) {
dispatch_async(dispatch_get_main_queue(), ^{
ws.authLabel.stringValue = isSuccess?@"鉴权状态:鉴权成功":@"鉴权状态:鉴权失败";
}];
}
- (void)setDPI:(NSMenuItem*)sender {
- [[DeviceManger shared] setCPI:800 completation:^(BOOL isSuccess, NSError * _Nonnull error) {
+ [[DeviceManger shared] setCPI:1600 completation:^(BOOL isSuccess, NSError * _Nonnull error) {
}];
}