aboutsummaryrefslogtreecommitdiff
path: root/brightness_ctrl.hpp
blob: fce960dcf19edda272eee0728ba65b951b22b82b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//Chris Xiong 2018
//3-Clause BSD License
#ifndef BRIGHTNESS_CTRL_HPP
#define BRIGHTNESS_CTRL_HPP
#include <chrono>
#include <condition_variable>
#include <filesystem>
#include <thread>
#include <mutex>
#include <vector>
#include "sensor_als.hpp"
class BrightnessControl
{
private:
	filesystem::path cpath,brpath,maxbrpath;
	std::vector<int> thresh,value;
	int delay,direction,br,maxbr,minabr,tr,offset;
	int doffset;
	size_t cur;
	SensorALS *als;
	std::mutex interrupt_m,threshnotify_m,adjust_m;
	std::condition_variable interrupt,threshnotify;
	void _brightness_slide(int p);
public:
	void init(float initv,SensorALS *s);
	void set_path(filesystem::path p);
	void set_thresh(const std::vector<int> &_th);
	void set_value(const std::vector<int> &_v);
	void set_delay(int _d);
	void set_trigrange(int _tr);
	void set_minabr(int _mbr);
	
	void set_offset(int rel,int off);
	void set_frozen(bool frozen);
	int get_offset();
	int get_brightness();

	void force_adjust();
	void on_sensor_report(float v);
	void brightness_slide(int p);
	void worker();
};
#endif