首页 > 解决方案 > Adafruit 羽毛 BLE 32U4

问题描述

一段时间以来一直在玩arduino,但我对bluefruit/蓝牙设备相当陌生。

我目前正在将 PS/2 球鼠标从 PS2 转换为 USB/蓝牙。我的 USB 部分工作得很好,我的鼠标点击在蓝牙上工作得很好,但对于我的生活,我可以让我的鼠标移动在蓝牙上工作。有人可以帮忙吗??

请记住底部鼠标点击有效。只是不是运动。连接到 USB 时,data.position 类可以正常工作

void controlWired(MouseData data) {
  // Mouve Mouse  
  Mouse.move(data.position.x, (data.position.y * -1), (data.wheel * -1));
  // Mouse Click
  (data.lClick) ? Mouse.press(MOUSE_LEFT) : Mouse.release(MOUSE_LEFT);
  (data.rClick) ? Mouse.press(MOUSE_RIGHT) : Mouse.release(MOUSE_RIGHT);
  (data.wClick) ? Mouse.press(MOUSE_MIDDLE) : Mouse.release(MOUSE_MIDDLE);
}

void controlBLE(MouseData data) {
  // Mouve Mouse  
  if (data.position.x != 0 or data.position.y != 0  or data.wheel != 0){
      //String mouvement = String(data.position.x) + "," + String((data.position.y * -1)) + "," + String((data.wheel * -1));
      ble.print(F("AT+BleHidMouseMove="));
      ble.print(data.position.x);
      ble.print(",");
      ble.print((data.position.y * -1));
      ble.print(",");
      ble.print((data.wheel * -1));
      ble.print(",0");
  }
  // Mouse Click
  (data.lClick) ? ble.sendCommandCheckOK(F("AT+BleHidMouseButton=L,press")) : ble.sendCommandCheckOK(F("AT+BleHidMouseButton=0"));
  (data.rClick) ? ble.sendCommandCheckOK(F("AT+BleHidMouseButton=R,press")) : ble.sendCommandCheckOK(F("AT+BleHidMouseButton=0"));
  (data.wClick) ? ble.sendCommandCheckOK(F("AT+BleHidMouseButton=C,press")) : ble.sendCommandCheckOK(F("AT+BleHidMouseButton=0"));
}

标签: arduinobluetooth-lowenergymouseadafruit

解决方案


没关系,找到我的问题 ble.print(",0"); 应该是 ble.println(",0");


推荐阅读