Ejemplo n.º 1
0
void init()
{
    OSCCON = 0b01100010;

    UART_Init();

    initBargraph();

    initSonar();

    initBuzzer();

    song();

    CLRWDT();

    //INIT OLED
    I2C_Close();              // Close the  I2C Bus
    I2C_Init(1);             // I2C 400kHz, 20MHz-CRYSTAL
    Oled_Init();
    Oled_SetFont(Terminal12x16, 12, 16, 32,127);
    Oled_FillScreen(0x00, 0, 0);
    Oled_ConstText("SONAR", 35, 0);
    Oled_Text("!", 110, 0);
    Oled_ConstText("L=", 2, 5);
    Oled_ConstText("cm", 105, 5);
}
Ejemplo n.º 2
0
void ssInitType() {
  switch (SENSOR_TYPE) {
    case SENSOR_TYPE_DIGITAL:
      initDigital();
      break;
    case SENSOR_TYPE_ANALOG_IN:
      initAnalogIn();
      break;
    case SENSOR_TYPE_BUZZER:
      initBuzzer();
      break;
    case SENSOR_TYPE_FLAG:
      initFlag();
      break;
    case SENSOR_TYPE_SERVO:
      initServo();
      break;
    default: break;
    // TODO(cduck): Add more smart sensors types
  }
}
Ejemplo n.º 3
0
Archivo: lma.c Proyecto: shimniok/lma
int main()
{
	cli();
	disableWatchdog();

	slowClock();
	initBuzzer();
	initSwitch();
	initADC();
	
#ifdef DEBUG
	uint16_t v = getVoltage();
	uint16_t i;

	for (i = 0x8000; i != 0; i >>= 1) {
		if (v & i) {
			dit();
		} else {
			dah();
		}
		_delay_ms(1000);
	}
#endif
	
	// Retrieve the current warning timeout from eeprom
	uint8_t warn_min = eeprom_read_byte(&cfg_warn_min);
	if (switchPressed()) {
		number(warn_min);
		// pause between increments
		_delay_ms(3000);
	}

	// If switch is depressed (at power up), begin increasing
	// warning time, in 5-minute increments, max 30 minutes
	// SOS time is 2 x warning time.
	//
	while (switchPressed()) {	
	
		if (switchPressed()) {
			// Increment warning time by 5 minutes
			warn_min += 5;

			// Maximum warning time is 30 minutes
			if (warn_min > 30) warn_min = 5;

			// Save the new warning time
			eeprom_update_byte(&cfg_warn_min, warn_min);
		}
		number(warn_min);

		// pause between increments
		_delay_ms(3000);		
	}

	// Compute the number of seconds for warning and SOS
	warn_sec = warn_min * 60;
	sos_sec = warn_sec * 2;

	if (checkVoltage()) {
		ok();
	} else {
		sos();
	}

	enableWatchdog();
 	sei();

	while (1) {
		set_sleep_mode(SLEEP_MODE_PWR_DOWN);
		sleep_mode();
	}
}