Exemplo n.º 1
0
int
main(int argc, char *argv[])
{
	open_relay();
	while (1) {
		relay_on(1);
		sleep(1);
		relay_on(0);
		sleep(1);
	}
	exit(0);
}
Exemplo n.º 2
0
void furnace_timer_start(const uint16_t duration_seconds) {
    // don't allow the timer to be started for a duration that's too long
    if (duration_seconds <= TIMER_MAX) {
        relay_on();
        timer_remaining = duration_seconds;
    }
}
Exemplo n.º 3
0
void radiator_loop_new()
{
  temp_t tab [] = {
    DS18B20_RADIATOR_U,
    DS18B20_RADIATOR_D,
    DS18B20_HOUSE_S_T,
  };
  
  ds18b20_temp_tab_fill(RESOLUTION_11, 7, tab);
  
  CONFIG static temp_t  ambient_temp = TEMP(23);
  CONFIG static uint8_t heating_f    = 4.0 * 0x10;
  CONFIG static temp_t  storage_off  = TEMP(10);

  temp_t goal = CONFIG_GET(ambient_temp);
  goal += (uint32_t)(tab[0] - tab[1]) * CONFIG_GET(heating_f) / 0x10;
  goal = MIN(goal, tab[2] - storage_off);

  valve_state_t amount = VALVE_STATE_MAX * 5 / 100;
  if (goal > tab[1]) valve_open_for (VALVE_RADIATOR, amount);
  else               valve_close_for(VALVE_RADIATOR, amount);
  
  if (valve_closed(VALVE_RADIATOR))
    relay_off(RELAY_PUMP_RADIATOR);
  else
    relay_on (RELAY_PUMP_RADIATOR);
}
Exemplo n.º 4
0
void radiator_loop()
{ 
  temp_t tab [] = {
    DS18B20_COLLECTOR,
    DS18B20_OUTSIDE,
  };

  ds18b20_get_temp_tab(sizeof(tab)/sizeof(temp_t), RESOLUTION_9, 7, tab);
  temp_t outside = MIN(tab[0], tab[1]);

  temp_t read_0 = ds18b20_get_temp(DS18B20_RADIATOR_U, RESOLUTION_11, 7);
  _delay_ms(1000);
  temp_t read_1 = ds18b20_get_temp(DS18B20_RADIATOR_U, RESOLUTION_11, 7);

  temp_t curr = read_1 + (read_1 - read_0) * 16;

  temp_t goal = CONFIG_GET(radiator_goal);
  CONFIG static uint8_t radiator_factor = 24;
  if (outside < goal) goal += (CONFIG_GET(radiator_factor) * ((uint32_t)goal - outside)) >> 4;

  bool dir = curr > goal;
  temp_t diff = dir ? curr - goal : goal - curr;

  valve_state_t amount = (VALVE_STATE_MAX * (uint32_t)diff) >> (8 + 6);
  
  if (dir) valve_close_for(VALVE_RADIATOR, amount);
  else     valve_open_for (VALVE_RADIATOR, amount);
 
  if (valve_closed(VALVE_RADIATOR) || outside > TEMP(15)) // quick dirty hack - father wants radiator in bathroom warm, maybe we can achieve that by heating without pump
    relay_off(RELAY_PUMP_RADIATOR);
  else
    relay_on (RELAY_PUMP_RADIATOR);
}
Exemplo n.º 5
0
void relay_set_status(uint8_t status)
{
	if(status == 0) {
		relay_off();
	} else if (status == 1) {
		relay_on();
	}
}
Exemplo n.º 6
0
void relay_set_status_and_publish(uint8_t status)
{
	if(status == 0) {
		relay_off();
		mjyun_publishstatus("off");
	} else if (status == 1) {
		relay_on();
		mjyun_publishstatus("on");
	}
}
Exemplo n.º 7
0
void
relay_toggle(void)
{
  if (relay_state)
    {
      relay_off();
    }
  else
    {
      relay_on();
    }
}
Exemplo n.º 8
0
void
relay_default(void)
{
  if (relay_default_state)
    {
      relay_on();
    }
  else
    {
      relay_off();
    }
}
void
extrelayon_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{
	static uint8_t status;
    status = 1;
	relay_on();
    PRINTF("Relay [%d]\n", status);
    REST.set_header_content_type(response, REST.type.TEXT_PLAIN);
  	snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "%d",status);

  	REST.set_response_payload(response, buffer, strlen((char *)buffer));
}
Exemplo n.º 10
0
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(hello_world_process, ev, data)
{
  
  static struct etimer timer;
  static int count;
  static int duty_cycle; 
  PROCESS_BEGIN();
  const int pulse_period = 100;
  const int divider = 1000; //checking every 1 ms increase for more granularity

  etimer_set(&timer, (CLOCK_CONF_SECOND / divider ));  // CLOCK_CONF_SECOND = 1000(1s)
  count = 0;
  duty_cycle = 90; //duty cycle in percentage
  relay_enable(PORT_B,LED_RELAY_PIN);
  relay_off(PORT_B,LED_RELAY_PIN);
  //leds_off(LEDS_RED);

   while(1) {

    PROCESS_WAIT_EVENT();

    if(ev == PROCESS_EVENT_TIMER) {
        
     	if(count <= duty_cycle){
		relay_on(PORT_B,LED_RELAY_PIN);
		//leds_on(LEDS_RED);
      	}
      	else {  
		relay_off(PORT_B,LED_RELAY_PIN);
		//relay_on(PORT_D,LED_RELAY_PIN);
		//leds_off(LEDS_RED);
      	} 

	count ++;
	if (count == pulse_period) count = 0;
	etimer_reset(&timer);
    }
  }
  
  
  PROCESS_END();
}
Exemplo n.º 11
0
void wykonaj (int ile_petli, int dlugosc)
{
    int licznik=0;
    char ch_liczba[3];

    pozycjonowanie();
    _delay_ms(500);

    relay_on();
    _delay_ms(50);
    init_LCD();
    init_PWM();
    _delay_ms(200);

    int delay = 370;
    if(dlugosc>MIN_DLUGOSC)
        delay = delay + (dlugosc-MIN_DLUGOSC)*190;


    for (licznik=0; licznik<ile_petli; licznik++)
    {
        int do_konca = ile_petli-licznik;
        gen_char(ch_liczba, &do_konca); //wyswietla ile cykli pozostało do konca naswietlania
        wyswietl_LCD(ch_liczba);

        kierunek(PRZOD);
        _delay_ms(delay); //odleglosc dokad dojadą lampy
	stop();
	_delay_ms(2000);
        pozycjonowanie(); //jezdie do tylu az napotka krancowe
	_delay_ms(2000);
    }
    _delay_ms(1000);
    wyswietl_LCD("KONIEC PRACY");
    _delay_ms(1000);
    relay_off();
    beep();
}
Exemplo n.º 12
0
Host::Host(QWidget *ParentMainWin, USB_VCP *usbObj) :
    QWidget(ParentMainWin)
{

    // Rename obj pointers for convenience
    mainWin = (MainWindow*)ParentMainWin;
    ui = (Ui::MainWindow*)mainWin->ui;
    usb_vcp = (USB_VCP*)usbObj;



    // Comms
    connect(ui->pushButton_comms_open, SIGNAL(clicked()), this, SLOT(comms_open()));
    connect(ui->pushButton_comms_test, SIGNAL(clicked()), this, SLOT(comms_test()));
    //ui->listWidget_comms_list->hide();
    connect(ui->listWidget_comms_list, SIGNAL(itemPressed(QListWidgetItem*)), this, SLOT(comms_open_selected(QListWidgetItem*)));



    // PDP
    connect(ui->pushButton_read_DMA, SIGNAL(clicked()), this, SLOT(read_DMA()));
    ui->pushButton_read_DMA->setVisible(false);


    connect(ui->pushButton_read_AC, SIGNAL(clicked()), this, SLOT(read_channelDMA()));
    ui->pushButton_read_AC->setVisible(false);
    connect(ui->pushButton_read_AC_filtered, SIGNAL(clicked()), this, SLOT(read_channelDMA_filtered()));

    connect(ui->pushButton_write_command, SIGNAL(clicked()), this, SLOT(write_command()));
    connect(ui->pushButton_read_status, SIGNAL(clicked()), this, SLOT(read_status()));


    connect(ui->pushButton_read_relay, SIGNAL(clicked()), this, SLOT(relay_read()));
    connect(ui->radioButton_relayOn, SIGNAL(clicked()), this, SLOT(relay_on()));
    connect(ui->radioButton_relayOff, SIGNAL(clicked()), this, SLOT(relay_off()));





    QGridLayout *gbox = new QGridLayout(ui->groupBox_relaySelect);
    int i = 0;
    for(int x = 0;x < 4; x++)
    {
        for(int y = 0;y < 4; y++)
        {
            relaySelectButton[i] = new QRadioButton(IntToStr(i));
            gbox->addWidget(relaySelectButton[i], y, x);
            connect(relaySelectButton[i], SIGNAL(clicked()), this, SLOT(relay_selected()));
            i++;
        }
    }
    ui->groupBox_relaySelect->setLayout(gbox);
    relayNumberSelected = 0;
    relaySelectButton[relayNumberSelected]->setChecked(true);



    // PDP graph init
    graph_init();



}
Exemplo n.º 13
0
void
Camera::relay_pic()		// basic relay activation
{
	relay_on();
	keep_cam_trigg_active_cycles = 2;	// leave a message that it should be active for two event loop cycles
}