예제 #1
0
uint8_t ds18x20Process(void)
{
	ds18x20GetAllTemps();

	// Convert temperature
	if (ds18x20IsOnBus())
		ds18x20ConvertTemp();

	return devCount;
}
예제 #2
0
파일: main.c 프로젝트: devttys1/ampcontrol
int main(void)
{
	int8_t encCnt = 0;
	uint8_t action = ACTION_NOACTION;

	/* Init hardware */
	hwInit();
	#if 0
	if (extFunc == USE_DS18B20) {
		ds18x20ConvertTemp();
		setSensTimer(TEMP_MEASURE_TIME);
	}
	#endif
	while (1) {
		#if 0
		/* Control temperature */
		if (extFunc == USE_DS18B20) {
			if (getSensTimer() == 0) {
				ds18x20GetAllTemps();
				ds18x20ConvertTemp();
				setSensTimer(SENSOR_POLL_INTERVAL);
			}
			tempControlProcess();
		}
		#endif
		/* Emulate poweroff if any of timers expired */
		if (getStbyTimer() == 0 || getSilenceTimer() == 0)
			action = CMD_RC_STBY;

		/* Check alarm and update time */
		if (action == ACTION_NOACTION)
			action = checkAlarmAndTime();

		/* Convert input command to action */
		if (action == ACTION_NOACTION)
			action = getAction();

		/* Handle action */
		handleAction(action);

		/* Handle encoder */
		encCnt = getEncoder();				/* Get value from encoder */
		if (action == CMD_RC_VOL_UP)		/* Emulate VOLUME_UP action as encoder action */
			encCnt++;
		if (action == CMD_RC_VOL_DOWN)	/* Emulate VOLUME_DOWN action as encoder action */
			encCnt--;
		handleEncoder(encCnt);

		/* Reset silence timer on any action */
		if (encCnt || (action != ACTION_NOACTION && action != ACTION_EXIT_STANDBY))
			enableSilenceTimer();

		/* Reset handled action */
		action = ACTION_NOACTION;

		/* Check if we need exit to default mode*/
		handleExitDefaultMode();

		/* Switch to timer mode if it expires */
		handleTimers();

		/* Clear screen if mode has changed */
		handleModeChange();

		/* Show things */
		showScreen();
	}

	return 0;
}