You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
721 B
45 lines
721 B
// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- |
|
|
|
/* |
|
* AP_Relay.cpp |
|
* |
|
* Created on: Oct 2, 2011 |
|
* Author: Amilcar Lucas |
|
*/ |
|
|
|
#include <AP_HAL.h> |
|
#include "AP_Relay.h" |
|
|
|
extern const AP_HAL::HAL& hal; |
|
|
|
#define RELAY_PIN 47 |
|
|
|
void AP_Relay::init() { |
|
hal.gpio->pinMode(RELAY_PIN, GPIO_OUTPUT); |
|
} |
|
|
|
void AP_Relay::on() { |
|
hal.gpio->write(RELAY_PIN, 1); |
|
} |
|
|
|
|
|
void AP_Relay::off() { |
|
hal.gpio->write(RELAY_PIN, 0); |
|
} |
|
|
|
|
|
void AP_Relay::toggle() { |
|
bool ison = hal.gpio->read(RELAY_PIN); |
|
if (ison) |
|
off(); |
|
else |
|
on(); |
|
} |
|
|
|
void AP_Relay::set(bool status){ |
|
hal.gpio->write(RELAY_PIN, status); |
|
} |
|
|
|
bool AP_Relay::get() { |
|
return hal.gpio->read(RELAY_PIN); |
|
}
|
|
|