commit - 26605ab9097d73c1f0927852daef14fcb28209f7
commit + 1d606547d37dfe5cd3efd894322719fcdcb8aae3
blob - 749bacd7c68d021690d5e47cd05957f6f0493f53 (mode 644)
blob + /dev/null
--- Club_Rabbit.ino
+++ /dev/null
-/*
- * Copyright (c) 2021, 2022 Tracey Emery K7TLE
-*
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-/*
- * Watch the order of pins on the board!
- *
- * D14 - Red LED Power/AR #Solid/cw
- * D12 - Green LED Transmitting Voice/cw/Off #Solid/Blink/Off
- * D13 - Blue LED Transmitting #On during transmit
- *
- * D5 - Transmit optical relay
- * D18 - Transmitter POWER relay
- * D25 - Audio out
- * D33 - Audio in
- * D26 - Morse out
- *
- * # If we have enough memory leftover
- * CLUB/R OFF # Power Transmitter Off
- * CLUB/R ON # Power Transmitter On
- * CLUB/R START # Start Transmitting Audio
- * CLUB/R STOP # Stop Transmitting Audio
- */
-#include <soc/soc.h>
-#include <soc/rtc_cntl_reg.h>
-
-#include <WiFi.h>
-#include <AsyncTCP.h>
-#include <ESPAsyncWebServer.h>
-#include <XT_DAC_Audio.h>
-#include <Morse.h>
-
-#include "audio_call.h"
-#include "html.h"
-
-#define DEBUG 0
-#define TIMER 0 /* save some power */
-
-#define MAX_CLIENTS 8
-
-#define RED_LED 14
-#define GREEN_LED 12
-#define BLUE_LED 13
-
-#define TRANSMIT 5
-#define TRANSMIT_PWR 18 /* LOW - OFF, HIGH - ON (switch LOW - ON) */
-/* #define OPTIONAL 21 */
-#define TRANSMIT_DELAY 10 /* seconds */
-#define TRANSMIT_MIN 10 /* seconds */
-#define TRANSMIT_MAX 30 /* seconds */
-
-#define ONE_SECOND 1000
-
-#define MORSE_OUT 26
-#define AUDIO_OUT 25
-#define AUDIO_IN 33
-
-#define DPRINTF(x,y) do { if (DEBUG) { Serial.println(x); \
- Serial2.println(x); sleep(y); }} while(0)
-
-#define WPM 15
-
-/* Morse */
-Morse morse_led(M_GPIO, RED_LED, WPM);
-Morse morse_dac(M_DAC, MORSE_OUT, WPM);
-
-String led_morse = "`ar`";
-String dac_morse = "de the clubcall rabbit";
-
-/* my_ssid will be used for the web interface header */
-const char *my_ssid = "Club Rabbit 1";
-const char *my_pass = "Pass1234";
-IPAddress my_ip(192, 168, 5, 1);
-IPAddress my_gw(192, 168, 5, 1);
-IPAddress my_net(255, 255, 255, 0);
-
-AsyncWebServer server(80);
-AsyncEventSource events("/event");
-
-XT_Wav_Class Sound(audio);
-XT_DAC_Audio_Class DacAudio(AUDIO_OUT, 0);
-
-void setup(void);
-void loop(void);
-void set_green(void);
-void set_red(void);
-void handle_transmission(void);
-
-String handle_connect(const String&);
-
-unsigned long transmit_start_millis, green_start_millis;
-unsigned long tx_current_millis, countdown_timer_millis;
-unsigned long countdown_millis, red_start_millis;
-
-int transmit_now = 0; /* don't delay first */
-int hunting = 0, playing = 0, play = 0, voice = 1;
-int transmit_end = 0, powered = 1, rand_num = 1, cw = 1;
-int send_handle_events = 0, transmit_new, alt_cw = 1;
-
-uint8_t channel = 3;
-
-void
-setup()
-{
- /* disable brownout for startup */
- WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0);
- delay(1000);
-
- /* immediate pin setup, transmitter shouldn't be on */
- pinMode(TRANSMIT, OUTPUT);
- pinMode(TRANSMIT_PWR, OUTPUT);
- digitalWrite(TRANSMIT, LOW);
- digitalWrite(TRANSMIT_PWR, LOW);
-
-#ifdef DEBUG
- /* setup serial */
- Serial.begin(115200);
- Serial2.begin(115200);
- sleep(1);
-#endif
-
- DPRINTF("", 1);
- DPRINTF("Setup serial", 0);
- DPRINTF("Setup transmitter", 0);
-
- /* setup LEDs */
- pinMode(RED_LED, OUTPUT);
- pinMode(GREEN_LED, OUTPUT);
- pinMode(BLUE_LED, OUTPUT);
- digitalWrite(RED_LED, LOW);
- digitalWrite(GREEN_LED, LOW);
- digitalWrite(BLUE_LED, LOW);
- DPRINTF("Setup LEDs", 0);
-
- /* audio setup */
- pinMode(AUDIO_OUT, OUTPUT);
- pinMode(AUDIO_IN, INPUT);
- DPRINTF("Setup audio", 0);
- /* DacAudio.DacVolume = 35; */
-
- /* setup our AP */
- /*
- * Had to disable these in sdkconfig.h and use simple WiFi to keep
- * Android 10 connected. What a PIA
- *
- * #define CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED 0
- * #define CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED 0
- */
-
- /* WiFi.mode(WIFI_AP); */
- /* WiFi.softAP(my_ssid, my_pass); */
-
- WiFi.mode(WIFI_AP);
- WiFi.softAPConfig(my_ip, my_gw, my_net);
- WiFi.setTxPower(WIFI_POWER_19_5dBm);
- WiFi.softAP(my_ssid, my_pass, channel, false, MAX_CLIENTS);
-
- DPRINTF("Setup AP", 0);
-
- /* setup our web server */
- server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) {
- request->send_P(200, "text/html", index_html, handle_connect);
- });
- server.on("/update", HTTP_GET, [](AsyncWebServerRequest *request) {
- String input_message;
-
- if (request->hasParam("hunting") && powered) {
- DPRINTF("Hunting toggled", 0);
- input_message = request->getParam("hunting")->value();
- hunting = input_message.toInt();
- transmit_start_millis = tx_current_millis;
- if (hunting)
- digitalWrite(GREEN_LED, HIGH);
- else {
- morse_led.gpio_tx_stop();
- morse_dac.dac_tx_stop();
- digitalWrite(GREEN_LED, LOW);
- }
- countdown_millis = millis();
- }
- if (request->hasParam("power")) {
- DPRINTF("Power toggled", 0);
- input_message = request->getParam("power")->value();
- powered = input_message.toInt();
- if (!powered) {
- morse_led.gpio_tx_stop();
- morse_dac.dac_tx_stop();
- digitalWrite(RED_LED, LOW);
- digitalWrite(GREEN_LED, LOW);
- } else {
- digitalWrite(RED_LED, HIGH);
- digitalWrite(GREEN_LED, LOW);
- }
-
- }
- if (request->hasParam("delay")) {
- DPRINTF("Delay changed", 0);
- input_message = request->getParam("delay")->value();
- if (input_message.toInt() >= TRANSMIT_MIN &&
- input_message.toInt() <= TRANSMIT_MAX)
- transmit_new = input_message.toInt();
- }
- if (request->hasParam("rand")) {
- DPRINTF("Random delay toggled", 0);
- input_message = request->getParam("rand")->value();
- rand_num = input_message.toInt();
- }
- if (request->hasParam("altcw")) {
- DPRINTF("Random cw toggled", 0);
- input_message = request->getParam("altcw")->value();
- alt_cw = input_message.toInt();
- }
- if (request->hasParam("cw")) {
- digitalWrite(GREEN_LED, HIGH);
- DPRINTF("CW toggled", 0);
- input_message = request->getParam("cw")->value();
- cw = input_message.toInt();
- }
- if (request->hasParam("trans_now")) {
- DPRINTF("PTT pressed", 0);
- input_message = request->getParam("trans_now")->value();
- transmit_now = 0;
- }
-
- request->send_P(200, "text/plain", "OK");
- });
- server.addHandler(&events);
- server.begin();
- DPRINTF("Setup web server", 0);
-
- /* turning on the tranmitter is the final step */
- digitalWrite(TRANSMIT_PWR, HIGH);
- digitalWrite(RED_LED, HIGH);
- DPRINTF("", 0);
- DPRINTF("Transmitter powered on", 1);
- DPRINTF("", 0);
- DPRINTF("The rabbit is ready to run!", 0);
- DPRINTF("", 0);
-
- /* setup millis timers */
- transmit_start_millis = millis();
- green_start_millis = millis();
- red_start_millis = millis();
-
- /* re-enable brownout */
- delay(1000);
- WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 1);
-}
-
-void
-loop()
-{
- tx_current_millis = millis();
-
- if (cw)
- playing = morse_dac.dac_transmitting();
- else
- playing = Sound.Playing;
-
- handle_transmission();
-
- if (hunting && powered)
- set_green();
-
- if (!powered) {
- set_red();
- digitalWrite(TRANSMIT_PWR, LOW);
- }
-
- if (powered)
- digitalWrite(TRANSMIT_PWR, HIGH);
-}
-
-void
-handle_transmission(void)
-{
- if (hunting && !play && !playing && transmit_now > 0 && powered &&
- tx_current_millis - countdown_timer_millis >= ONE_SECOND &&
- TIMER) {
- events.send(String((transmit_now - (millis() -
- countdown_millis)) / 1000).c_str(), "count", millis());
- countdown_timer_millis = tx_current_millis;
- }
-
- if (cw)
- morse_dac.dac_watchdog();
- else
- DacAudio.FillBuffer();
-
- if (hunting && !play && !playing && powered &&
- (tx_current_millis - transmit_start_millis >= transmit_now)) {
- digitalWrite(BLUE_LED, HIGH);
- digitalWrite(TRANSMIT, HIGH);
- DPRINTF("Transmitting", 0);
- transmit_start_millis = tx_current_millis;
- events.send("disable", "tnbutton", millis());
- events.send("disable", "cwbox", millis());
- events.send("disable", "altcwbox", millis());
- if (TIMER)
- events.send("TX", "count", millis());
- if (rand_num) {
- transmit_now = random(TRANSMIT_MIN,
- TRANSMIT_MAX) * ONE_SECOND;
- events.send(String(transmit_now / ONE_SECOND).c_str(),
- "rand", millis());
- } else {
- /* setup our transmit delay now */
- if (transmit_new)
- transmit_now = transmit_new * ONE_SECOND;
- else
- transmit_now = TRANSMIT_DELAY * ONE_SECOND;
- events.send(String(transmit_now / ONE_SECOND).c_str(),
- "rand", millis());
- }
- play = 1;
- }
-
- if (hunting && play && !playing && !cw) {
- if (tx_current_millis - transmit_start_millis >= ONE_SECOND) {
- DPRINTF("Play audio", 0);
- DacAudio.Play(&Sound);
- play = 0;
- transmit_end = 1;
- }
- } else if (hunting && play && !playing && cw) {
- if (tx_current_millis - transmit_start_millis >= ONE_SECOND) {
- DPRINTF("Send CW", 0);
- morse_dac.dac_tx(dac_morse);
- play = 0;
- transmit_end = 1;
- }
- }
-
- if (transmit_end && playing) {
- transmit_start_millis = tx_current_millis;
- countdown_timer_millis = tx_current_millis;
- countdown_millis = tx_current_millis;
- transmit_end = 2;
- }
-
- if (!playing && transmit_end == 2) {
- if (tx_current_millis - transmit_start_millis >= ONE_SECOND) {
- events.send("enable", "tnbutton", millis());
- events.send("enable", "altcwbox", millis());
- if (!alt_cw)
- events.send("enable", "cwbox", millis());
- else
- cw = !cw;
- DPRINTF("End transmission", 0);
- DPRINTF("", 0);
- digitalWrite(BLUE_LED, LOW);
- digitalWrite(TRANSMIT, LOW);
- transmit_start_millis = tx_current_millis;
- playing = 0;
- transmit_end = 0;
- }
- }
-}
-
-String
-handle_connect(const String& var)
-{
- int power = digitalRead(TRANSMIT_PWR);
-
- String button1 = "<button id=\"time_b\" onclick=\"set_time()\"";
- if (rand_num)
- button1 += " disabled";
- button1 += ">Update Transmission Delay</button>";
-
- String button2 = "<button id=\"start\" onclick=\"start_hunt(this)\"";
- if (hunting || !power)
- button2 += " disabled";
- button2 += ">Start Hunt</button>";
-
- String button3 = "<button id=\"stop\" onclick=\"stop_hunt(this)\"";
- if (!hunting || !power)
- button3 += " disabled";
- button3 += ">Stop Hunt</button>";
-
- String button4 = "<button id=\"on\" onclick=\"power_on(this)\"";
- if (power)
- button4 += " disabled";
- button4 += ">Power On Radio</button>";
-
- String button5 = "<button id=\"off\" onclick=\"power_off(this)\"";
- if (!power)
- button5 += " disabled";
- button5 += ">Power Off Radio</button>";
-
- String button6 = "<button id=\"trans_now\" onclick=\"trans_now(this)\"";
- if (!hunting || !power)
- button6 += " disabled";
- button6 += ">Transmit Now</button>";
-
- String box1 = "<input id=\"randbox\" type=\"checkbox\"";
- if (rand_num)
- box1 += " checked";
- box1 += " onchange=\"toggle_random(this)\" />";
-
- String box2 = "<input id=\"cwbox\" type=\"checkbox\"";
- if (cw)
- box2 += " checked";
- if (alt_cw)
- box2 += " disabled";
- box2 += " onchange=\"toggle_cw(this)\" />";
-
- String box3 = "<input id=\"altcwbox\" type=\"checkbox\"";
- if (alt_cw)
- box3 += " checked";
- box3 += " onchange=\"toggle_alt_cw(this)\" />";
-
- if (var == "HUNTING") {
- if (hunting)
- return "Hunt is on";
- else
- return "Hunt is off";
- }
- if (var == "POWER") {
- if (digitalRead(TRANSMIT_PWR))
- return "Powered On";
- else {
- transmit_now = 0;
- return "Powered Off";
- }
- }
- if (var == "BUTTON1")
- return button1;
- if (var == "BUTTON2")
- return button2;
- if (var == "BUTTON3")
- return button3;
- if (var == "BUTTON4")
- return button4;
- if (var == "BUTTON5")
- return button5;
- if (var == "BUTTON6")
- return button6;
- if (var == "DELAY") {
- if (transmit_now)
- return String(transmit_now / ONE_SECOND);
- else if (transmit_new)
- return String(transmit_new);
- else
- return String(TRANSMIT_DELAY);
- }
- if (var == "TRANSMIT_MIN")
- return String(TRANSMIT_MIN);
- if (var == "TRANSMIT_MAX")
- return String(TRANSMIT_MAX);
- if (var == "SSID")
- return String(my_ssid);
- if (var == "RANDSTAT") {
- if (rand_num)
- return "On";
- else
- return "Off";
- }
- if (var == "RANDBOX")
- return box1;
- if (var == "ALTCWSTAT") {
- if (alt_cw)
- return "On";
- else
- return "Off";
- }
- if (var == "ALTCWBOX")
- return box3;
- if (var == "CWSTAT") {
- if (cw)
- return "Yes";
- else
- return "No";
- }
- if (var == "CWBOX")
- return box2;
- if (var == "TX") {
- if (TIMER)
- return "---";
- else
- return "TX OFF";
- }
-
- return String();
-}
-
-void
-set_green(void)
-{
- if (cw && tx_current_millis - green_start_millis >= ONE_SECOND) {
- digitalWrite(GREEN_LED, !digitalRead(GREEN_LED));
- green_start_millis = millis();
- }
-}
-
-void
-set_red(void)
-{
- morse_led.gpio_watchdog();
- if (morse_led.gpio_transmitting())
- red_start_millis = millis();
-
- if (!morse_led.gpio_transmitting() && tx_current_millis -
- red_start_millis >= ONE_SECOND * 2) {
- morse_led.gpio_tx(led_morse);
- }
-}
blob - a086b609c6d88d12495a40d2eb4bc595900e6610 (mode 644)
blob + /dev/null
--- LICENSE
+++ /dev/null
-BSD 2-Clause License
-
-Copyright (c) 2021, Tracey Emery K7TLE
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-1. Redistributions of source code must retain the above copyright notice, this
- list of conditions and the following disclaimer.
-
-2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
blob - 951f46cd60f0109de17a48dd4cf17feecc87b04d (mode 644)
blob + /dev/null
--- README.md
+++ /dev/null
-# Club_Rabbit
-ESP32 software for building a Foxhunt rabbit.
-
-# Library Requirements
-XT_DAC_Audio: https://www.xtronical.com/the-dacaudio-library-download-and-installation/
-
-Morse: https://github.com/basepr1me/Morse
-
-AsyncTCP: https://github.com/me-no-dev/AsyncTCP
-
-ESPAsyncWebServer: https://github.com/me-no-dev/ESPAsyncWebServer
-
-# audio_call.h information
-A file called audio_call.h is required for this to run. Obviously, I'm not going
-to upload my club's audio file, because it is only legal for club members to
-use it.
-
-To create your own file, the following website has the information you need: https://circuitdigest.com/microcontroller-projects/esp32-based-audio-player
-
-However, I modified XT_DAC_Audio and the audio_call.h instructions to place the
-large file in PROGMEM. The author of the blog states that the ESP32 memory space
-is small, but that's not true. They simply aren't putting the audio in the right
-chunks. Constify the WavData and set audio in audio_call.h to:
-
-const unsigned char audio[######] PROGMEM
-
-I'm not certain the XT_DAC_Audio writer knows this either.
-
-# WIP
-This shouldn't be used by anybody yet. It is still highly experimental and
-subject to large changes.
-
-This style is OpenBSD style and may not look right in the Arduino IDE, since I don't use it.
blob - 334ff826b9dbb247a7f5b330edca705ef32fd20a (mode 644)
blob + /dev/null
Binary files club_rabbit.pdf and /dev/null differ
blob - 456bd6262d1a19c6c5f7108f88b58b5e0a3200d3 (mode 644)
blob + /dev/null
--- html.h
+++ /dev/null
-/*
- * Copyright (c) 2021, 2022 Tracey Emery K7TLE
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-const char index_html[] PROGMEM = R"rawliteral(
-<!doctype html><html>
-<head>
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <style>
- html {
- font-family:Helvetica;
- display: inline-block;
- margin: 0px auto;
- text-align: center;
- }
- p {
- font-size: 1.2rem;
- }
- body {
- margin: 0;
- }
- .topbar {
- overflow: hidden;
- background-color: #000077;
- color: white;
- font-size: 1rem;
- }
- .content {
- padding: 20px;
- }
- .card {
- background-color: white;
- box-shadow: 2px 2px 12px 1px rgba(140,140,140,.5);
- }
- .cards {
- max-width: 300px;
- margin: 0 auto;
- display: grid;
- grid-gap: 2rem;
- grid-template-columns: repeat(auto-fit,
- minmax(200px, 1fr));
- }
- .status {
- font-size: 1.4rem;
- }
- button {
- border: 1px solid #0066cc;
- background-color: #0099cc;
- color: #ffffff;
- padding: 5px 10px;
- }
- button:hover {
- border: 1px solid #0099cc;
- background-color: #00aacc;
- color: #ffffff;
- padding: 5px 10px;
- }
- button:onpress {
- border: 1px solid #0099cc;
- background-color: #ff0000;
- color: #ffffff;
- padding: 5px 10px;
- }
- button:disabled,
- button[disabled] {
- border: 1px solid #999999;
- background-color: #cccccc;
- color: #666666;
- }
- </style>
- <script>
- var xhr;
-
- if (!!window.EventSource) {
- var source = new EventSource("/event");
- source.addEventListener("rand", function (e) {
- document.getElementById("delay").innerHTML = e.data;
- }, false);
- source.addEventListener("count", function (e) {
- document.getElementById("transmit").innerHTML = e.data;
- }, false);
- source.addEventListener("tnbutton", function (e) {
- if (e.data == "enable")
- document.getElementById("trans_now").removeAttribute("disabled");
- else if (e.data == "disable")
- document.getElementById("trans_now").setAttribute("disabled", "disabled");
- }, false);
- source.addEventListener("altcwbox", function (e) {
- if (e.data == "enable")
- document.getElementById("altcwbox").removeAttribute("disabled");
- else if (e.data == "disable")
- document.getElementById("altcwbox").setAttribute("disabled", "disabled");
- }, false);
- source.addEventListener("cwbox", function (e) {
- if (e.data == "enable")
- document.getElementById("cwbox").removeAttribute("disabled");
- else if (e.data == "disable")
- document.getElementById("cwbox").setAttribute("disabled", "disabled");
- }, false);
- }
-
- function start_hunt(element) {
- xhr = new XMLHttpRequest();
- xhr.open("GET", "/update?hunting=1", false);
- xhr.send();
- element.setAttribute("disabled", "disabled");
- document.getElementById("stop").removeAttribute("disabled");
- document.getElementById("hunting").innerHTML = "Hunt is on";
- document.getElementById("trans_now").removeAttribute("disabled");
- }
-
- function stop_hunt(element) {
- xhr = new XMLHttpRequest();
- xhr.open("GET", "/update?hunting=0", false);
- xhr.send();
- element.setAttribute("disabled" ,"disabled");
- document.getElementById("start").removeAttribute("disabled");
- document.getElementById("hunting").innerHTML = "Hunt is off";
- document.getElementById("transmit").innerHTML = "---";
- document.getElementById("trans_now").setAttribute("disabled", "disabled");
- }
-
- function power_on(element) {
- xhr = new XMLHttpRequest();
- xhr.open("GET", "/update?power=1", false);
- xhr.send();
- element.setAttribute("disabled", "disabled");
- document.getElementById("off").removeAttribute("disabled");
- document.getElementById("power").innerHTML = "Powered on";
- document.getElementById("start").removeAttribute("disabled");
- }
-
- function power_off(element) {
- xhr = new XMLHttpRequest();
- xhr.open("GET", "/update?power=0&hunting=0", false);
- xhr.send();
- element.setAttribute("disabled", "disabled");
- document.getElementById("on").removeAttribute("disabled");
- document.getElementById("power").innerHTML = "Powered off";
- document.getElementById("start").setAttribute("disabled", "disabled");
- document.getElementById("stop").setAttribute("disabled", "disabled");
- document.getElementById("hunting").innerHTML = "Hunt is off";
- document.getElementById("transmit").innerHTML = "---";
- document.getElementById("trans_now").setAttribute("disabled", "disabled");
- }
-
- function set_time() {
- var delay_t = parseInt(document.getElementById("time").value);
- if (isNaN(delay_t)) {
- alert("That is not a number!");
- document.getElementById("time").value = "";
- } else if (delay_t < %TRANSMIT_MIN% || delay_t > %TRANSMIT_MAX%) {
- alert("Number not within allotted range (" +
- %TRANSMIT_MIN% + "-" + %TRANSMIT_MAX% + ")");
- } else {
- xhr = new XMLHttpRequest();
- xhr.open("GET", "/update?delay=" + delay_t);
- xhr.send();
- document.getElementById("delay").innerHTML = delay_t;
- }
- }
-
- function trans_now(element) {
- xhr = new XMLHttpRequest();
- xhr.open("GET", "/update?trans_now=1", false);
- xhr.send();
- element.setAttribute("disabled", "disabled");
- }
-
- function toggle_random(element) {
- if (element.checked) {
- xhr = new XMLHttpRequest();
- xhr.open("GET", "/update?rand=1", false);
- xhr.send();
- document.getElementById("rand").innerHTML = "On";
- document.getElementById("time").setAttribute("disabled", "disabled");
- document.getElementById("time_b").setAttribute("disabled", "disabled");
- } else {
- xhr = new XMLHttpRequest();
- xhr.open("GET", "/update?rand=0", false);
- xhr.send();
- document.getElementById("rand").innerHTML = "Off";
- document.getElementById("time").removeAttribute("disabled");
- document.getElementById("time_b").removeAttribute("disabled");
- }
- }
-
- function toggle_alt_cw(element) {
- var cwc = 0;
- if (document.getElementById("cwbox").checked)
- cwc = 1;
- if (element.checked) {
- xhr = new XMLHttpRequest();
- xhr.open("GET", "/update?altcw=1&cw="+cwc, false);
- xhr.send();
- document.getElementById("alt_cw").innerHTML = "On";
- document.getElementById("cwbox").setAttribute("disabled", "disabled");
- document.getElementById("cwbox").setAttribute("disabled", "disabled");
- } else {
- xhr = new XMLHttpRequest();
- xhr.open("GET", "/update?altcw=0&cw="+cwc, false);
- xhr.send();
- document.getElementById("alt_cw").innerHTML = "Off";
- document.getElementById("cwbox").removeAttribute("disabled");
- document.getElementById("cwbox").removeAttribute("disabled");
- }
- }
-
- function toggle_cw(element) {
- if (element.checked) {
- xhr = new XMLHttpRequest();
- xhr.open("GET", "/update?cw=1", false);
- xhr.send();
- document.getElementById("cw").innerHTML = "Yes";
- } else {
- xhr = new XMLHttpRequest();
- xhr.open("GET", "/update?cw=0", false);
- xhr.send();
- document.getElementById("cw").innerHTML = "No";
- }
- }
- </script>
-</head>
-<body>
- <div class="topbar">
- <h1>%SSID%</h1>
- </div>
- <div class="content">
- <div class="cards">
- <div class="card">
- <p>DELAY</p>
- <p><span class="status">
- <span id="delay">%DELAY%</span>
- </span></p>
- <p>
- <input onfocus="this.value=''" name="time" id="time" value="%DELAY%" type="number" />
- %BUTTON1%
- </p>
- </div>
- <div class="card">
- <p>RANDOM DELAY</p>
- <p><span class="status">
- <span id="rand">%RANDSTAT%</span>
- </span></p>
- <p>%RANDBOX%</p>
- </div>
- <div class="card">
- <p>SEND CW</p>
- <p><span class="status">
- <span id="cw">%CWSTAT%</span>
- </span></p>
- <p>%CWBOX%</p>
- </div>
- <div class="card">
- <p>ALTERNATE CW/VOICE</p>
- <p><span class="status">
- <span id="alt_cw">%ALTCWSTAT%</span>
- </span></p>
- <p>%ALTCWBOX%</p>
- </div>
- <div class="card">
- <p>HUNTING</p>
- <p><span class="status">
- <span id="hunting">%HUNTING%</span>
- </span></p>
- <p>%BUTTON2% %BUTTON3%</p>
- </div>
- <div class="card">
- <p>RADIO</p>
- <p><span class="status">
- <span id="power">%POWER%</span>
- </span></p>
- <p>%BUTTON4% %BUTTON5%</p>
- </div>
- <div class="card">
- <p>PTT</p>
- <p><span class="status">
- %BUTTON6%
- </span></p>
- </div>
- <div class="card">
- <p>TRANSMIT IN</p>
- <p><span class="status">
- <span id="transmit">%TX%</span>
- </span></p>
- </div>
- </div>
- </div>
-</body>
-</html>
-)rawliteral";