Created
August 30, 2016 03:39
-
-
Save leoforney/d28e9ae10db1558469c63f429726a776 to your computer and use it in GitHub Desktop.
FTC Sensor help
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
package com.qualcomm.ftcrobotcontroller.library.devices; | |
import com.qualcomm.ftcrobotcontroller.library.Wire; | |
import com.qualcomm.robotcore.hardware.HardwareMap; | |
/** | |
* Created by Leo on 2/15/2016. | |
*/ | |
public class VCNL4010 { | |
Wire pr; | |
int data; | |
int hb; | |
int lb; | |
int distance; | |
int prox; | |
public VCNL4010(HardwareMap hardwareMap, String devName) { | |
pr = new Wire(hardwareMap, devName, 2 * VCNL4010_Addresses.I2CADDR_DEFAULT); | |
} | |
public VCNL4010(HardwareMap hardwareMap, String devName, int address) { | |
pr = new Wire(hardwareMap, devName, address); | |
} | |
public int getHb() { | |
return hb; | |
} | |
public int getLb() { | |
return lb; | |
} | |
public void refreshData() { | |
pr.beginWrite(VCNL4010_Addresses.COMMAND); | |
pr.write(VCNL4010_Addresses.MEASUREPROXIMITY); | |
pr.endWrite(); | |
pr.requestFrom(VCNL4010_Addresses.PROXIMITYDATA, 2); | |
if (pr.responseCount() > 0) { | |
pr.getResponse(); | |
if (pr.isRead()) { | |
hb = pr.read(); | |
lb = pr.read(); | |
} | |
} | |
} | |
public void setProxRate(int proxRate) { | |
pr.beginWrite(VCNL4010_Addresses.PROXRATE); | |
pr.write(proxRate); | |
pr.endWrite(); | |
} | |
public void setLEDSensitivity(int ledSensitivity) { | |
pr.beginWrite(VCNL4010_Addresses.IRLED); | |
pr.write(ledSensitivity); | |
pr.endWrite(); | |
} | |
public void close() { | |
pr.close(); | |
} | |
public void beginWrite(int command) { | |
} | |
} |
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
package com.qualcomm.ftcrobotcontroller.library.devices; | |
/** | |
* Created by Leo on 2/8/2016. | |
*/ | |
public final class VCNL4010_Addresses { | |
public final static int I2CADDR_DEFAULT = 0x13; | |
public final static int COMMAND = 0x80; | |
public final static int PRODUCTID = 0x81; | |
public final static int PROXRATE = 0x82; | |
public final static int IRLED = 0x83; | |
public final static int AMBIENTPARAMETER = 0x84; | |
public final static int AMBIENTDATA = 0x85; | |
public final static int AMBIENTDATA2 = 0x86; | |
public final static int PROXIMITYDATA = 0x87; | |
public final static int PROXIMITYDATALOW = 0x88; | |
public final static int INTCONTROL = 0x89; | |
public final static int PROXINITYADJUST = 0x8A; | |
public final static int INTSTAT = 0x8E; | |
public final static int MODTIMING = 0x8F; | |
public final static int MEASUREAMBIENT = 0x10; | |
public final static int MEASUREPROXIMITY = 0x08; | |
public final static int AMBIENTREADY = 0x40; | |
public final static int PROXIMITYREADY = 0x20; | |
public final static int dx = 5250; | |
public final static int dy = 2370; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment