Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Renames and readme

  • Loading branch information...
commit 732b0e70e652b5163773e5574e7e2ec2e6516704 1 parent 7e774b1
@ladyada ladyada authored
View
30 Adafruit_PS2.cpp → Adafruit_PS2_Trackpad.cpp
@@ -1,4 +1,4 @@
-#include <Adafruit_PS2.h>
+#include <Adafruit_PS2_Trackpad.h>
/*
* an arduino sketch to interface with a ps/2 mouse.
* Also uses serial protocol to talk back to the host
@@ -20,21 +20,21 @@ void Adafruit_PS2::constructor(uint8_t c, uint8_t d) {
_data = d;
}
-Adafruit_PS2Mouse::Adafruit_PS2Mouse(void) {
+Adafruit_PS2_Mouse::Adafruit_PS2_Mouse(void) {
}
-Adafruit_PS2Mouse::Adafruit_PS2Mouse(uint8_t c, uint8_t d) {
+Adafruit_PS2_Mouse::Adafruit_PS2_Mouse(uint8_t c, uint8_t d) {
constructor(c, d);
}
-Adafruit_PS2Trackpad::Adafruit_PS2Trackpad(uint8_t c, uint8_t d) {
+Adafruit_PS2_Trackpad::Adafruit_PS2_Trackpad(uint8_t c, uint8_t d) {
constructor(c, d);
}
-boolean Adafruit_PS2Mouse::begin(void) {
+boolean Adafruit_PS2_Mouse::begin(void) {
if (! reset()) return false;
@@ -46,7 +46,7 @@ boolean Adafruit_PS2Mouse::begin(void) {
}
-boolean Adafruit_PS2Mouse::reset(void) {
+boolean Adafruit_PS2_Mouse::reset(void) {
idle();
if (!command(ADAFRUIT_PS2_RESET)) return false;
if (read() != 0xAA) return false;
@@ -57,7 +57,7 @@ boolean Adafruit_PS2Mouse::reset(void) {
}
-boolean Adafruit_PS2Trackpad::begin(void) {
+boolean Adafruit_PS2_Trackpad::begin(void) {
if (! reset()) return false;
@@ -96,7 +96,7 @@ boolean Adafruit_PS2Trackpad::begin(void) {
return true;
}
-uint32_t Adafruit_PS2Trackpad::getStatus(void) {
+uint32_t Adafruit_PS2_Trackpad::getStatus(void) {
uint8_t info[3];
Serial.print("Status: ");
@@ -117,7 +117,7 @@ uint32_t Adafruit_PS2Trackpad::getStatus(void) {
return 1;
}
-boolean Adafruit_PS2Trackpad::tapMode(boolean enable) {
+boolean Adafruit_PS2_Trackpad::tapMode(boolean enable) {
uint8_t cmd, arg;
if (enable) {
cmd = ADAFRUIT_PS2_SETRATE;
@@ -148,7 +148,7 @@ boolean Adafruit_PS2Trackpad::tapMode(boolean enable) {
-uint32_t Adafruit_PS2Trackpad::E6Report(void) {
+uint32_t Adafruit_PS2_Trackpad::E6Report(void) {
write(ADAFRUIT_PS2_SETRES);
write(0x0); // argument for setres
write(ADAFRUIT_PS2_SETSCALE11);
@@ -175,7 +175,7 @@ uint32_t Adafruit_PS2Trackpad::E6Report(void) {
}
-uint32_t Adafruit_PS2Trackpad::E7Report(void) {
+uint32_t Adafruit_PS2_Trackpad::E7Report(void) {
write(ADAFRUIT_PS2_SETRES);
write(0x0); // argument for setres
write(ADAFRUIT_PS2_SETSCALE21);
@@ -204,7 +204,7 @@ uint32_t Adafruit_PS2Trackpad::E7Report(void) {
}
-boolean Adafruit_PS2Trackpad::absoluteMode(void) {
+boolean Adafruit_PS2_Trackpad::absoluteMode(void) {
// alps magic knock, 4 disables before an enable
if (!command(ADAFRUIT_PS2_DISABLE) ||
!command(ADAFRUIT_PS2_DISABLE) ||
@@ -219,7 +219,7 @@ boolean Adafruit_PS2Trackpad::absoluteMode(void) {
}
-boolean Adafruit_PS2Trackpad::readData(void) {
+boolean Adafruit_PS2_Trackpad::readData(void) {
//write(0x0F);
uint8_t packet[6];
for (uint8_t x=0; x<6; x++) {
@@ -250,7 +250,7 @@ boolean Adafruit_PS2Trackpad::readData(void) {
return true;
}
-boolean Adafruit_PS2Mouse::readData(void) {
+boolean Adafruit_PS2_Mouse::readData(void) {
if (!command(ADAFRUIT_PS2_READDATA)) return false;
status = read();
@@ -264,7 +264,7 @@ boolean Adafruit_PS2Mouse::readData(void) {
y = read();
}
-uint8_t Adafruit_PS2Mouse::readID(void) {
+uint8_t Adafruit_PS2_Mouse::readID(void) {
if (!command(ADAFRUIT_PS2_GETDEVICEID)) return -1;
return read();
View
10 Adafruit_PS2.h → Adafruit_PS2_Trackpad.h
@@ -49,10 +49,10 @@ class Adafruit_PS2 {
uint8_t _clk, _data;
};
-class Adafruit_PS2Mouse : public Adafruit_PS2 {
+class Adafruit_PS2_Mouse : public Adafruit_PS2 {
public:
- Adafruit_PS2Mouse(uint8_t c, uint8_t d);
- Adafruit_PS2Mouse();
+ Adafruit_PS2_Mouse(uint8_t c, uint8_t d);
+ Adafruit_PS2_Mouse();
boolean begin(void);
boolean reset(void);
@@ -66,9 +66,9 @@ class Adafruit_PS2Mouse : public Adafruit_PS2 {
};
-class Adafruit_PS2Trackpad : public Adafruit_PS2Mouse {
+class Adafruit_PS2_Trackpad : public Adafruit_PS2_Mouse {
public:
- Adafruit_PS2Trackpad(uint8_t c, uint8_t d);
+ Adafruit_PS2_Trackpad(uint8_t c, uint8_t d);
boolean begin(void);
uint32_t E6Report(void);
View
17 README.txt
@@ -0,0 +1,17 @@
+This is a library for the Adafruit Capacitive Trackpad
+
+ Designed specifically to work with the Adafruit Capacitive Trackpad
+ ----> https://www.adafruit.com/products/837
+
+These devices use PS/2 to communicate, 2 pins are required to
+interface
+Adafruit invests time and resources providing this open source code,
+please support Adafruit and open-source hardware by purchasing
+products from Adafruit!
+
+Written by Limor Fried/Ladyada for Adafruit Industries.
+BSD license, all text above must be included in any redistribution
+
+To download. click the DOWNLOADS button in the top right corner, rename the uncompressed folder Adafruit_PS2_Trackpad. Check that the Adafruit_PS2_Trackpad folder contains Adafruit_PS2_Trackpad.cpp and Adafruit_PS2_Trackpad.h
+
+Place the Adafruit_PS2_Trackpad library folder your <arduinosketchfolder>/libraries/ folder. You may need to create the libraries subfolder if its your first library. Restart the IDE.
View
85 examples/trackpad/trackpad.pde
@@ -0,0 +1,85 @@
+#include <Adafruit_PS2_Trackpad.h>
+
+/***************************************************
+ This is an example for the Adafruit Capacitive Trackpad
+
+ Designed specifically to work with the Adafruit Capacitive Trackpad
+ ----> https://www.adafruit.com/products/837
+
+ These devices use PS/2 to communicate, 2 pins are required to
+ interface
+ Adafruit invests time and resources providing this open source code,
+ please support Adafruit and open-source hardware by purchasing
+ products from Adafruit!
+
+ Written by Limor Fried/Ladyada for Adafruit Industries.
+ BSD license, all text above must be included in any redistribution
+ ****************************************************/
+
+/*
+We suggest using a PS/2 breakout adapter such as this
+https://www.adafruit.com/products/804
+for easy wiring!
+
+PS/2 pin #1 (Brown) - Data
+PS/2 pin #2 (White) - N/C
+PS/2 pin #3 (Black) - Ground
+PS/2 pin #4 (Green) - 5V
+PS/2 pin #5 (Yellow) - Clock
+PS/2 pin #6 (Red) - N/C
+*/
+
+// PS2 uses two digital pins
+#define PS2_DATA 2
+#define PS2_CLK 3
+
+//Adafruit_PS2 ps2(PS2_CLK, PS2_DATA);
+
+// Use thid declaration when you want the trackpad to act like a 'mouse'
+// with relative positioning
+//Adafruit_PS2_Mouse ps2(PS2_CLK, PS2_DATA);
+
+// Use this declaration when you want 'absolute' tablet mode
+Adafruit_PS2_Trackpad ps2(PS2_CLK, PS2_DATA);
+
+void setup() {
+ Serial.begin(9600);
+ if (ps2.begin())
+ Serial.println("Successfully found PS2 mouse device");
+ else
+ Serial.println("Did not find PS2 mouse device");
+
+ Serial.print("PS/2 Mouse with ID 0x");
+ Serial.println(ps2.readID(), HEX);
+
+}
+
+uint16_t lasttap_x = 0, lasttap_y = 0;
+
+void loop() {
+ delay(25);
+
+ if (! ps2.readData()) return;
+
+ //Serial.print("0x");
+ //Serial.print(ps2.status, HEX); Serial.print("\t");
+ Serial.print("X = "); Serial.print(ps2.x, DEC); Serial.print("\t");
+ Serial.print("Y = "); Serial.print(ps2.y, DEC); Serial.print("\t");
+ Serial.print("Z = "); Serial.print(ps2.z);
+ if (ps2.finger) Serial.print("\tFinger");
+ if (ps2.right) Serial.print("\tRight");
+ if (ps2.middle) Serial.print("\tMiddle");
+ if (ps2.left) Serial.print("\tLeft");
+
+ if (ps2.gesture && !ps2.finger) {
+ if ((lasttap_x == ps2.x) && (lasttap_y == ps2.y)) {
+ Serial.print("\tDouble tap!");
+ } else {
+ Serial.print("\tTap");
+ }
+ lasttap_x = ps2.x;
+ lasttap_y = ps2.y;
+ }
+ Serial.println();
+ delay(25);
+}
Please sign in to comment.
Something went wrong with that request. Please try again.