kristopher / PS2-Mouse-Arduino

Arduino/Wiring Library for interfacing with a PS2 mouse.
81 stars 44 forks source link

Can't get past initialize state #8

Open vance opened 7 years ago

vance commented 7 years ago

In initialize, it never gets past write(0xff) only prints "try write". I think the pin never goes low, so it gets stuck in the loop:

while (digitalRead(_clock_pin)) {;}

Any advice?

Also, may want to change to include Arduino.h instead of WConstants or whatever.

void PS2Mouse::initialize() {
  Serial.println("initialize");
  pull_high(_clock_pin);
  pull_high(_data_pin);
  delay(20);
  Serial.println("try write");
  write(0xff); // Send Reset to the mouse
  Serial.println("end write");
  read_byte();  // Read ack byte 
  delay(20); // Not sure why this needs the delay
  read_byte();  // blank 
  read_byte();  // blank
  delay(20); // Not sure why this needs the delay
  if (_mode == REMOTE) {
    set_remote_mode();
  } else {
    enable_data_reporting(); // Tell the mouse to start sending data again
  }
  delayMicroseconds(100);
  _initialized = 1;

  Serial.println("done");
}
kristopher commented 7 years ago

There are some more recent forks that have some fixes in them for more recent adruino version or feel free to fork and make the changes. I don't maintain this library anymore

Cheers, Kris

On Tue, Feb 28, 2017 at 2:32 PM, ForeverScape notifications@github.com wrote:

In initialize, it never gets past write(0xff) only prints "try write".

Also, may want to change to include Arduino.h instead of WConstants or whatever.

void PS2Mouse::initialize() { Serial.println("initialize"); pull_high(_clock_pin); pull_high(_data_pin); delay(20); Serial.println("try write"); write(0xff); // Send Reset to the mouse Serial.println("end write"); read_byte(); // Read ack byte delay(20); // Not sure why this needs the delay read_byte(); // blank read_byte(); // blank delay(20); // Not sure why this needs the delay if (_mode == REMOTE) { set_remote_mode(); } else { enable_data_reporting(); // Tell the mouse to start sending data again } delayMicroseconds(100); _initialized = 1;

Serial.println("done"); }

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/kristopher/PS2-Mouse-Arduino/issues/8, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAROKm7XST7_aAQ6bShf_uPXCwGQQDbks5rhHZCgaJpZM4MOzsN .