diff --git a/.gitignore b/.gitignore index 62da403..f5861ba 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ /bin/ /curses/ /info/ +temp_sensor \ No newline at end of file diff --git a/demo/screen_record.low.gif b/demo/screen_record.low.gif deleted file mode 100644 index 85c5b14..0000000 Binary files a/demo/screen_record.low.gif and /dev/null differ diff --git a/demo/screen_record.mov b/demo/screen_record.mov deleted file mode 100644 index b069f4e..0000000 Binary files a/demo/screen_record.mov and /dev/null differ diff --git a/demo/screen_shot.png b/demo/screen_shot.png deleted file mode 100644 index 3455450..0000000 Binary files a/demo/screen_shot.png and /dev/null differ diff --git a/monitor.cpp b/monitor.cpp deleted file mode 100644 index e59fc72..0000000 --- a/monitor.cpp +++ /dev/null @@ -1,114 +0,0 @@ -#include -#include -#include -#include - -#include -#include - -#include -#include - -using namespace std; - -const string WHITESPACE = " \n\r\t\f\v"; -string ltrim(const string& s) { - size_t start = s.find_first_not_of(WHITESPACE); - return (start == string::npos) ? "" : s.substr(start); -} -string rtrim(const string& s) { - size_t end = s.find_last_not_of(WHITESPACE); - return (end == string::npos) ? "" : s.substr(0, end + 1); -} -string trim(const string& s) { return rtrim(ltrim(s)); } - -void split_comma(string &s, vector &l); -void sort_names(vector &l, vector &order, int &num); -int max_len(vector &l); - -int main(int argc,char *argv[]) { - string name_line, value_line; - getline(cin, name_line); - // cout< orders; - vector names, values; - vector raw_values; - - split_comma(name_line, names); - num = names.size(); - sort_names(names, orders, num); - name_length_max = max_len(names); - - for(int i=0;i &l) { - l.clear(); - stringstream s_stream(s); - while(s_stream.good()) { - string w; - getline(s_stream, w, ','); //get first string delimited by comma - w=trim(w); - if(!w.empty()) - l.push_back(w); - } -} - -void sort_names(vector &l, vector &order, int &num) { - vector< pair > l_id; - for(int i=0;i &l) { - int res = 0; - for(int i=0;i res) - res = l[i].size(); - return res; -} - - - - - -/* - cout << "\r%1"<=80 and ny>=34 - if not (nx>=80 and ny>=34): - stdscr.addnstr(0,0, 'enlarge the size of this terminal...', 50, curses.A_REVERSE) - stdscr.addnstr(1,0, f'requires min 32x80, now {ny}x{nx} (row x col)', 50) - stdscr.refresh() - time.sleep(0.2) - continue - - stdscr.box() - stdscr.addnstr(0,5, f' {sys_info}, {n} sensors ', 80) # (max_name_length={max_name_length}) - stdscr.addnstr(ny-1,5, f' Press Ctrl+C to exit ', 80) - - xmid = nx//2 # //ncol - # __|__ - # xmid - # xmid+3 - - sorted_nums = get_sorted_nums(ordered_list) - if max_nums is not None: - max_nums = [max(x,y) for x,y in zip(sorted_nums, max_nums)] - else: - max_nums = sorted_nums - - # for y in range(-1, nrow1): - # stdscr.addnstr(nrow0+y,xmid, '|', 1) - stdscr.vline(nrow0-1, xmid, curses.ACS_VLINE, nrow1+1) - - curses.init_pair(1, 14, -1) - titles = ['Sensor Name','now /max˚C'] - stdscr.addnstr(nrow0-1, 2, f'{titles[0]:{max_name_length+3}} {titles[1]}', 37, curses.color_pair(1)) - stdscr.addnstr(nrow0-1,xmid+3, f'{titles[0]:{max_name_length+3}} {titles[1]}', 37, curses.color_pair(1)) - - i = 0; - for y in range(0, nrow1): - if i - - - diff --git a/temp_sensor.m b/temp_sensor.m index fda7d58..aa419d1 100644 --- a/temp_sensor.m +++ b/temp_sensor.m @@ -145,16 +145,34 @@ CFArrayRef getThermalValues(CFDictionaryRef sensors) { return array; } +double getTempValue(CFArrayRef values, int index) { + CFNumberRef value = CFArrayGetValueAtIndex(values, index); + double temp = 0.0; + CFNumberGetValue(value, kCFNumberDoubleType, &temp); + return temp; +} + +void printCPUGPUTemps(CFArrayRef values) { + printf("CPU %0.1lf GPU %0.1lf, ", getTempValue(values,0), getTempValue(values,2)); + +} + void dumpValues(CFArrayRef values) { long count = CFArrayGetCount(values); + + double accumTemp = 0.0; + for (int i = 0; i < count; i++) { CFNumberRef value = CFArrayGetValueAtIndex(values, i); double temp = 0.0; CFNumberGetValue(value, kCFNumberDoubleType, &temp); // NSLog(@"value = %lf\n", temp); - printf("%0.1lf, ", temp); + //printf("%0.1lf, ", temp); + if(temp > 0) + accumTemp+=temp; } + printf("%0.0lf", accumTemp/count); } void dumpNames(CFArrayRef names, char *cat) @@ -230,10 +248,10 @@ int main () { // printf("freq, v_bat, a_bat, temp_bat"); // dumpNames(voltageNames, "V"); // dumpNames(currentNames, "A"); - dumpNames(thermalNames, "C"); - printf("\n"); fflush(stdout); + //dumpNames(thermalNames, "C"); + //printf("\n"); fflush(stdout); - while (1) { + //while (1) { CFArrayRef currentValues = getPowerValues(currentSensors); CFArrayRef voltageValues = getPowerValues(voltageSensors); CFArrayRef thermalValues = getThermalValues(thermalSensors); @@ -248,7 +266,7 @@ int main () { CFRelease(currentValues); CFRelease(voltageValues); CFRelease(thermalValues); - } + //} #if 0 NSLog(@"%@\n", CFArrayGetValueAtIndex(currentNames, 0));