Android Integration
Bring lighthouse to your next Android Project
In just 7 lines of code, you can fully visualize the data from lighthouse.
Get the library
Add the JitPack repository to your root build.gradle at the end of repositories
allprojects { repositories { ... maven { url 'https://jitpack.io' } } }
Add the dependency
dependencies { implementation 'com.github.curio-lighthouse:lighthouse:Tag' }
Don't forget to change the "Tag" placeholder with the build from JitPack.
Time to use it
Create the LiDAR and LidarDisplay Objects
LIDAR myLidar; LidarDisplay lidarDisplay;
Pass the Activity to the LidarDisplay Constructor
lidarDisplay = new LidarDisplay(this);
Pass the Activity and LidarDisplay to the LDAR constructor
myLidar = new LIDAR(this, lidarDisplay);
Connect and Start lighthouse
if (myLidar.connectToLIDAR()) { myLidar.startLIDAR(); }
Boom!
Put all together in the MainActivity
public class MainActivity extends Activity {
// lighthouse device
LIDAR myLidar;
// lighthouse view
LidarDisplay lidarDisplay;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// This is the graphical plotting of the LIDAR data.
lidarDisplay = new LidarDisplay(this);
ConstraintLayout linearLayout = findViewById(R.id.constraint_layout);
linearLayout.addView(lidarDisplay);
myLidar = new LIDAR(this, lidarDisplay);
// Connect to lighthouse.
if (myLidar.connectToLIDAR()) {
// If the connection was successful, then we will start lighthouse.
myLidar.startLIDAR();
}
}
}