File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -33,6 +33,10 @@ struct ClapCli {
3333 #[ arg( long) ]
3434 thermal : bool ,
3535
36+ /// Print sensor information (ALS, G-Sensor)
37+ #[ arg( long) ]
38+ sensors : bool ,
39+
3640 /// Show information about USB-C PD ports
3741 #[ arg( long) ]
3842 pdports : bool ,
@@ -196,6 +200,7 @@ pub fn parse(args: &[String]) -> Cli {
196200 esrt : args. esrt ,
197201 power : args. power ,
198202 thermal : args. thermal ,
203+ sensors : args. sensors ,
199204 pdports : args. pdports ,
200205 pd_info : args. pd_info ,
201206 dp_hdmi_info : args. dp_hdmi_info ,
Original file line number Diff line number Diff line change @@ -122,6 +122,7 @@ pub struct Cli {
122122 pub esrt : bool ,
123123 pub power : bool ,
124124 pub thermal : bool ,
125+ pub sensors : bool ,
125126 pub pdports : bool ,
126127 pub privacy : bool ,
127128 pub pd_info : bool ,
@@ -606,6 +607,8 @@ pub fn run_with_args(args: &Cli, _allupdate: bool) -> i32 {
606607 power:: get_and_print_power_info ( & ec) ;
607608 } else if args. thermal {
608609 power:: print_thermal ( & ec) ;
610+ } else if args. sensors {
611+ power:: print_sensors ( & ec) ;
609612 } else if args. pdports {
610613 power:: get_and_print_pd_info ( & ec) ;
611614 } else if args. info {
@@ -784,7 +787,8 @@ Options:
784787 --version Show tool version information (Add -vv for more detailed information)
785788 --esrt Display the UEFI ESRT table
786789 --power Show current power status (battery and AC)
787- --thermal Show current power status (battery and AC)
790+ --thermal Print thermal information (Temperatures and Fan speed)
791+ --sensors Print sensor information (ALS, G-Sensor)
788792 --pdports Show information about USB-C PD ports
789793 --info Show info from SMBIOS (Only on UEFI)
790794 --pd-info Show details about the PD controllers
Original file line number Diff line number Diff line change @@ -60,6 +60,7 @@ pub fn parse(args: &[String]) -> Cli {
6060 esrt : false ,
6161 power : false ,
6262 thermal : false ,
63+ sensors : false ,
6364 pdports : false ,
6465 pd_info : false ,
6566 dp_hdmi_info : false ,
@@ -131,6 +132,9 @@ pub fn parse(args: &[String]) -> Cli {
131132 } else if arg == "--thermal" {
132133 cli. thermal = true ;
133134 found_an_option = true ;
135+ } else if arg == "--sensors" {
136+ cli. sensors = true ;
137+ found_an_option = true ;
134138 } else if arg == "--pdports" {
135139 cli. pdports = true ;
136140 found_an_option = true ;
Original file line number Diff line number Diff line change @@ -52,8 +52,8 @@ const EC_MEMMAP_BATT_MFGR: u16 = 0x60; // Battery Manufacturer String
5252const EC_MEMMAP_BATT_MODEL : u16 = 0x68 ; // Battery Model Number String
5353const EC_MEMMAP_BATT_SERIAL : u16 = 0x70 ; // Battery Serial Number String
5454const EC_MEMMAP_BATT_TYPE : u16 = 0x78 ; // Battery Type String
55- const _EC_MEMMAP_ALS : u16 = 0x80 ; // ALS readings in lux (2 X 16 bits)
56- // Unused 0x84 - 0x8f
55+ const EC_MEMMAP_ALS : u16 = 0x80 ; // ALS readings in lux (2 X 16 bits)
56+ // Unused 0x84 - 0x8f
5757const _EC_MEMMAP_ACC_STATUS: u16 = 0x90 ; // Accelerometer status (8 bits )
5858 // Unused 0x91
5959const _EC_MEMMAP_ACC_DATA: u16 = 0x92 ; // Accelerometers data 0x92 - 0x9f
@@ -191,6 +191,13 @@ pub fn print_memmap_version_info(ec: &CrosEc) {
191191 let _events_ver = ec. read_memory ( EC_MEMMAP_EVENTS_VERSION , 2 ) . unwrap ( ) ;
192192}
193193
194+ pub fn print_sensors ( ec : & CrosEc ) {
195+ let als = ec. read_memory ( EC_MEMMAP_ALS , 0x04 ) . unwrap ( ) ;
196+
197+ let als_int = u32:: from_le_bytes ( [ als[ 0 ] , als[ 1 ] , als[ 2 ] , als[ 3 ] ] ) ;
198+ println ! ( "ALS: {:>4} Lux" , als_int) ;
199+ }
200+
194201pub fn print_thermal ( ec : & CrosEc ) {
195202 let temps = ec. read_memory ( EC_MEMMAP_TEMP_SENSOR , 0x0F ) . unwrap ( ) ;
196203 let fans = ec. read_memory ( EC_MEMMAP_FAN , 0x08 ) . unwrap ( ) ;
You can’t perform that action at this time.
0 commit comments