You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					45 lines
				
				1.6 KiB
			
		
		
			
		
	
	
					45 lines
				
				1.6 KiB
			| 
											5 years ago
										 | #pragma once
 | ||
|  | 
 | ||
|  | #include <cstdlib>
 | ||
|  | #include <fstream>
 | ||
|  | 
 | ||
| 
											3 years ago
										 | #include "common/params.h"
 | ||
|  | #include "common/util.h"
 | ||
| 
											3 years ago
										 | #include "system/hardware/base.h"
 | ||
| 
											5 years ago
										 | 
 | ||
|  | class HardwareTici : public HardwareNone {
 | ||
|  | public:
 | ||
| 
											4 years ago
										 |   static constexpr float MAX_VOLUME = 0.9;
 | ||
| 
											4 years ago
										 |   static constexpr float MIN_VOLUME = 0.2;
 | ||
| 
											5 years ago
										 |   static bool TICI() { return true; }
 | ||
| 
											3 years ago
										 |   static bool AGNOS() { return true; }
 | ||
| 
											5 years ago
										 |   static std::string get_os_version() {
 | ||
|  |     return "AGNOS " + util::read_file("/VERSION");
 | ||
|  |   };
 | ||
| 
											3 years ago
										 |   static std::string get_name() { return "tici"; };
 | ||
|  |   static cereal::InitData::DeviceType get_device_type() { return cereal::InitData::DeviceType::TICI; };
 | ||
|  |   static int get_voltage() { return std::atoi(util::read_file("/sys/class/hwmon/hwmon1/in1_input").c_str()); };
 | ||
|  |   static int get_current() { return std::atoi(util::read_file("/sys/class/hwmon/hwmon1/curr1_input").c_str()); };
 | ||
|  | 
 | ||
| 
											5 years ago
										 | 
 | ||
|  |   static void reboot() { std::system("sudo reboot"); };
 | ||
|  |   static void poweroff() { std::system("sudo poweroff"); };
 | ||
|  |   static void set_brightness(int percent) {
 | ||
|  |     std::ofstream brightness_control("/sys/class/backlight/panel0-backlight/brightness");
 | ||
|  |     if (brightness_control.is_open()) {
 | ||
|  |       brightness_control << (percent * (int)(1023/100.)) << "\n";
 | ||
|  |       brightness_control.close();
 | ||
|  |     }
 | ||
|  |   };
 | ||
| 
											4 years ago
										 |   static void set_display_power(bool on) {
 | ||
|  |     std::ofstream bl_power_control("/sys/class/backlight/panel0-backlight/bl_power");
 | ||
|  |     if (bl_power_control.is_open()) {
 | ||
|  |       bl_power_control << (on ? "0" : "4") << "\n";
 | ||
|  |       bl_power_control.close();
 | ||
|  |     }
 | ||
|  |   };
 | ||
| 
											5 years ago
										 | 
 | ||
| 
											5 years ago
										 |   static bool get_ssh_enabled() { return Params().getBool("SshEnabled"); };
 | ||
|  |   static void set_ssh_enabled(bool enabled) { Params().putBool("SshEnabled", enabled); };
 | ||
| 
											5 years ago
										 | };
 |