OpenSprinkler › Forums › Hardware Questions › OpenSprinkler Beagle (OSBo) › Unified Firmware and BBB IO › Reply To: Unified Firmware and BBB IO
noski
I got a hint from another user @sakos on how this could be achieved in this post – https://opensprinkler.com/forums/topic/pre-configured-sd-card-image/#post-41383
Quote:
– Control of relay on legacy Opensprinkler Pi boards.
To assign the relay to a station just configure the station as “RF” and set “0” as RF code.
I downloaded their SD card image to try to figure out what changes they made.
They made changes to the function switch_rfstation in OpenSprinkler.cpp
The function has slightly changed in the latest Firmware 2.1.9(9) from what sakos had. So I took what sakos did and tried to make it work.
What I came up with is this:
void OpenSprinkler::switch_rfstation(RFStationData *data, bool turnon) {
ulong on, off;
uint16_t length = parse_rfstation_code(data, &on, &off);
#if defined(ARDUINO)
#if defined(ESP8266)
rfswitch.enableTransmit(PIN_RFTX);
rfswitch.setProtocol(1);
rfswitch.setPulseLength(length);
rfswitch.send(turnon ? on : off, 24);
#else
send_rfsignal(turnon ? on : off, length);
#endif
#else
if (((char*)data)[0]==’0′ && ((char*)data)[1]< ‘0’) {
//Single zero character of RF code
digitalWrite(PIN_RFTX, turnon ? HIGH : LOW);
} else {
// pre-open gpio file to minimize overhead
rf_gpio_fd = gpio_fd_open(PIN_RFTX);
send_rfsignal(turnon ? on : off, length);
gpio_fd_close(rf_gpio_fd);
rf_gpio_fd = -1;
}
#endif
}
… and it works in controlling the mini-relay!
I understand the PIN used by the mini-relay has been repurposed in the code for the RF functionality.
It would be great if @Ray could implement a way to choose if you are using the RF functionality or the mini-relay.
Perhaps it could be handled with the argument to the build.sh script? something like:
sudo ./build.sh osbo_relay (for the relay)
sudo ./build.sh osbo_rf (for RF)
But for now I guess I’ll have to live with my hack.