#include <dv-processing/io/camera/davis.hpp>

int main() {
	// Open a Davis346 camera
	dv::io::camera::DAVIS capture{};

	/// Access biases raw value
	// Photoreceptor bias
	auto biasPhotoreceptor = capture.getDavis346BiasCoarseFine(dv::io::camera::DAVIS::Davis346BiasCF::Photoreceptor);
	// Source follower bias
	auto biasPhotoreceptorSourceFollower
		= capture.getDavis346BiasCoarseFine(dv::io::camera::DAVIS::Davis346BiasCF::PhotoreceptorSourceFollower);
	// Differential bias
	auto biasDiff = capture.getDavis346BiasCoarseFine(dv::io::camera::DAVIS::Davis346BiasCF::Diff);
	// On threshold bias
	auto biasOn = capture.getDavis346BiasCoarseFine(dv::io::camera::DAVIS::Davis346BiasCF::On);
	// Off threshold bias
	auto biasOff = capture.getDavis346BiasCoarseFine(dv::io::camera::DAVIS::Davis346BiasCF::Off);
	// Refractory period bias
	auto biasRefractory = capture.getDavis346BiasCoarseFine(dv::io::camera::DAVIS::Davis346BiasCF::Refractory);

	// Add 1 on the log-scale coarse value, i.e. multiply bias value by 8 (approximately)
	biasPhotoreceptor.first               += 1;
	biasPhotoreceptorSourceFollower.first += 1;
	biasDiff.first                        += 1;
	biasOn.first                          += 1;
	biasOff.first                         += 1;
	biasRefractory.first                  += 1;

	/// Set biases raw value
	// Setting photoreceptor bias
	capture.setDavis346BiasCoarseFine(
		dv::io::camera::DAVIS::Davis346BiasCF::Photoreceptor, biasPhotoreceptor.first, biasPhotoreceptor.second);
	// Setting source follower bias
	capture.setDavis346BiasCoarseFine(dv::io::camera::DAVIS::Davis346BiasCF::PhotoreceptorSourceFollower,
		biasPhotoreceptorSourceFollower.first, biasPhotoreceptorSourceFollower.second);
	// Setting differential bias
	capture.setDavis346BiasCoarseFine(dv::io::camera::DAVIS::Davis346BiasCF::Diff, biasDiff.first, biasDiff.second);
	// Setting on threshold bias
	capture.setDavis346BiasCoarseFine(dv::io::camera::DAVIS::Davis346BiasCF::On, biasOn.first, biasOn.second);
	// Setting off threshold bias
	capture.setDavis346BiasCoarseFine(dv::io::camera::DAVIS::Davis346BiasCF::Off, biasOff.first, biasOff.second);
	// Setting refractory period bias
	capture.setDavis346BiasCoarseFine(
		dv::io::camera::DAVIS::Davis346BiasCF::Refractory, biasRefractory.first, biasRefractory.second);

	return 0;
}
