-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Raw Image (=Camera) read support
- Loading branch information
Showing
7 changed files
with
243 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
#include <PMW3360.h> | ||
/* | ||
Frame capture (=Camera) mode: | ||
This mode disables navigation and overwrites any downloaded firmware. | ||
A hardware reset is required to restore navigation, and the firmware must be reloaded. | ||
# PIN CONNECTION | ||
* MI = MISO | ||
* MO = MOSI | ||
* SS = Slave Select / Chip Select | ||
* SC = SPI Clock | ||
* MT = Motion (active low interrupt line) | ||
* RS = Reset | ||
* GD = Ground | ||
* VI = Voltage in up to +5.5V | ||
Module Arduino | ||
RS --- (NONE) | ||
GD --- GND | ||
MT --- (NONE) | ||
SS --- Pin_10 (use this pin to initialize a PMW3360 instance) | ||
SC --- SCK | ||
MO --- MOSI | ||
MI --- MISO | ||
VI --- 5V | ||
*/ | ||
|
||
#define SS 10 // Slave Select pin. Connect this to SS on the module. | ||
|
||
PMW3360 sensor; | ||
|
||
void setup() { | ||
Serial.begin(9600); | ||
while(!Serial); | ||
|
||
if(sensor.begin(SS)) // 10 is the pin connected to SS of the module. | ||
Serial.println("Sensor initialization successed"); | ||
else | ||
Serial.println("Sensor initialization failed"); | ||
|
||
// wait for 250 ms for frame capture. | ||
delay(250); | ||
} | ||
|
||
void loop() { | ||
// The following routine shoud be alwyas performed together. | ||
// BEGIN ------------------------------------------------- | ||
sensor.prepareImage(); | ||
for(int i=0;i<36*36;i++) | ||
{ | ||
byte pixel = sensor.readImagePixel(); | ||
Serial.print(pixel, DEC); | ||
Serial.print(' '); | ||
} | ||
sensor.endImage(); | ||
// END ---------------------------------------------------- | ||
|
||
delay(50); | ||
|
||
// optional: Surface quality report | ||
int squal = sensor.readReg(REG_SQUAL); | ||
Serial.println(squal); | ||
|
||
delay(10); | ||
} | ||
|
||
/* Processing code for visualization (http://processing.org to downlaod) | ||
import processing.serial.*; | ||
Serial myPort; | ||
int[] val = null; | ||
boolean sync = false; | ||
int lf = 10; | ||
void setup() | ||
{ | ||
size(360, 380); | ||
String[] sList = Serial.list(); | ||
String portName = sList[sList.length - 1]; | ||
myPort = new Serial(this, portName, 9600); | ||
} | ||
void draw() | ||
{ | ||
if(myPort.available() > 0) | ||
{ | ||
String s = myPort.readStringUntil(lf); | ||
if(s != null) | ||
{ | ||
int[] nums = int(split(trim(s), ' ')); | ||
if(nums.length == 36*36+1) | ||
{ | ||
val = nums; | ||
} | ||
} | ||
} | ||
if(val == null) | ||
{ | ||
background(0); | ||
return; | ||
} | ||
background(0); | ||
noStroke(); | ||
for(int i=0;i<36;i++) | ||
{ | ||
for(int j=0;j<36;j++) | ||
{ | ||
int pixel = val[i*36+j]; | ||
fill(pixel); | ||
rect(i*10, (35-j)*10, 10, 10); | ||
} | ||
} | ||
int squal = val[36*36]; | ||
fill(255); | ||
text("SQUAL = "+squal, 10, 375); | ||
} | ||
void keyPressed() | ||
{ | ||
if(key == 's') | ||
save("frame.png"); | ||
} | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
name=PMW3360 Module | ||
version=1.0.1 | ||
version=1.1.0 | ||
author=Sunjun Kim | ||
maintainer=Sunjun Kim <kuaa.net@gmail.com> | ||
sentence=This library allows an Arduino/Genuino board to interface with PixArt PMW3360 module | ||
paragraph=Set parameters and get motion data from PMW3360 motion sensor module | ||
sentence=This library allows an Arduino/Genuino board to interface with PixArt PMW3360 motion sensor module. | ||
paragraph=You can set/get parameters, get motion data, get raw camer image from PMW3360 module. | ||
category=Sensors | ||
url=https://github.com/SunjunKim/PMW3360 | ||
architectures=* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters