Beispiel #1
0
void dcfanCmnd::slew_fan() { // limit fan speed increases
  if( target < current ) { // no limit if slowing down
    set_fan( target );
  }
  else if( target > current ) {  // ramping up, so check rate
    uint8_t delta = target - current;
    if( delta > SLEW_STEP ) // limit the step size
      delta = SLEW_STEP;
    uint32_t delta_ms = millis() - last_fan_change; // how long since last step?
    if( delta_ms > SLEW_STEP_TIME ) { // do only if enough time has gone by
      set_fan( current + delta ); // increase the output level
    }  
  }
}
void RseObtainSocialUserInfo::MergeFrom(const RseObtainSocialUserInfo& from) {
  GOOGLE_CHECK_NE(&from, this);
  socialuserinfo_.MergeFrom(from.socialuserinfo_);
  if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
    if (from._has_bit(0)) {
      set_name(from.name());
    }
    if (from._has_bit(1)) {
      set_photourl(from.photourl());
    }
    if (from._has_bit(2)) {
      set_fan(from.fan());
    }
  }
  mutable_unknown_fields()->MergeFrom(from.unknown_fields());
}
Beispiel #3
0
void stop_fan(void) {
    set_fan(0x1f);
    fan_state = FAN_OFF;
}
Beispiel #4
0
void start_fan(void) {
    set_fan(speed);
    fan_state = FAN_ON;
}
Beispiel #5
0
int main (int argc, char **argv) {

	int res, c, verbose=FALSE;
	int fan, temp, newpwm, oldpwm=0;
	pid_t pid;
	uid_t uid;

	printf("eeepc-fanctld v%s - (c)2012 Pau Oliva Fora <*****@*****.**>\n",VERSION);

	while ((c = getopt(argc, argv, "vh?")) != EOF) {
		switch(c) {
			case 'v':
				verbose=TRUE;
				break;
			case 'h':
				printf("usage: eeepc-fanctld [-v]\n");
				return 0;
				break;
			default:
				fprintf(stderr,"usage: eeepc-fanctld [-v]\n");
				return 1;
				break;
		}
	}


	uid = getuid();
	if (uid != 0) {
		fprintf(stderr, "Error: this daemon must be run as root user.\n");
		return 1;
	}

	find_eeepc();

	sensors_init(NULL);
	if (!init_sensor_data()) {
		fprintf(stderr, "Error: Could not find needed sensors\n");
		return 1;
	}

	if (!pwm_enable(1)) {
		fprintf(stderr, "Error: could not enable pwm\n");
		return 1;
	}

	if (!verbose) {
		if ((pid = fork()) < 0) exit(1);
		else if (pid != 0) exit(0);
		/* daemon running here */
		setsid();
		res=chdir("/");
		if (res != 0) {
			perror("Error: Could not chdir");
			exit(1);
		}
		umask(0);
	} 

	signal_installer();

	while(1) {

		temp=get_temp();

		if (verbose) {
			fan=get_fan();
			printf("FAN: %d RPM, TEMP: %dºC\n", fan, temp);
		}

		if (temp < 55) newpwm=0;
		else if(temp < 60) newpwm=(10*255)/100;
		else if(temp < 65) newpwm=(20*255)/100;
		else if(temp < 67) newpwm=(30*255)/100;
		else if(temp < 69) newpwm=(40*255)/100;
		else if(temp < 74) newpwm=(50*255)/100;
		else if(temp < 77) newpwm=(60*255)/100;
		else if(temp < 81) newpwm=(65*255)/100;
		else if(temp < 85) newpwm=(70*255)/100;
		else if(temp < 91) newpwm=(80*255)/100;
		else newpwm=255;

		if (newpwm != oldpwm) {
			if(verbose) printf("Changing fan speed from: %d to %d\n", oldpwm, newpwm);
			set_fan(newpwm);
			oldpwm=newpwm;
		}

		usleep(POLLTIME*1000000);

	}

	return 0;
}
Beispiel #6
0
void adjust()
{
	read_sensors();
	calc_fan();
	set_fan();
}
Beispiel #7
0
int main(int argc, char **argv)
{
	static const struct option options[] = {
		{ "help",		no_argument,	 	0, 'h' },
		{ "version",		no_argument,	 	0, 'v' },
		{ "reattach",		no_argument, 		0, 'r' },
		{ "fan-off",		no_argument, 		0, 'f' },
		{ "fan-on",		no_argument,		0, 'F' },
		{ "brightness-low",	no_argument,		0, 'b' },
		{ "brightness-high",	no_argument,	 	0, 'B' },
		{ "led",		required_argument,	0, 'l' },
		{ 0, 0, 0, 0 }
	};
	int c;

	if (argc == 1)
		usage();
	else do {
		c = getopt_long(argc, argv, "hvrfFbBl:", options, 0);

		switch (c) {
		case 'v':
			printf("atvtool version " VERSION ", (C) 2008 "
			       "Peter Korsgaard <*****@*****.**>\n");
			exit(0);
			break;

		case 'r':
			reattach();
			break;

		case 'f':
		case 'F':
			set_fan(c == 'F');
			break;

		case 'b':
		case 'B':
			set_led_brightness(c == 'B');
			break;

		case 'l':
		{
			int val;
			char *endp;

			val = strtol(optarg, &endp, 0);
			if ((*endp) || (val > LEDMODE_MAX) || (val < 0)) {
				fprintf(stderr,
					"invalid led mode '%s'\n", optarg);
				usage();
				exit(1);
			}
			set_led(val);
		}
		break;

		case -1:
			break;

		default:
			usage();
			break;
		}

	} while (c != -1);

	return 0;
}