„wt32pamon.ino“ ändern
This commit is contained in:
parent
d66858d99d
commit
3dda494e45
@ -25,6 +25,8 @@
|
||||
#include "FS.h"
|
||||
#include "SPIFFS.h"
|
||||
|
||||
String version = "0.9";
|
||||
|
||||
Preferences config;
|
||||
|
||||
String config_items[] = { "show_mV", "show_dBm", "show_watt", "vswr_threshold", "vswr_beep", "selected_band", "antenna_name", "max_led_pwr_fwd", "max_led_pwr_ref", "max_led_vswr", "show_led_fwd", "show_led_ref", "show_led_vswr" };
|
||||
@ -147,8 +149,7 @@ bool is_val_out_of_bounds(int mv, bool fwd){
|
||||
|
||||
// takes a voltage value and translates it
|
||||
// to dBm based on the corresponding lookup table
|
||||
double millivolt_to_dbm(int mv, bool fwd)
|
||||
{
|
||||
double millivolt_to_dbm(int mv, bool fwd) {
|
||||
double lastval = 0;
|
||||
double nextval = 0;
|
||||
int lastkey = 0;
|
||||
@ -250,14 +251,13 @@ double millivolt_to_dbm(int mv, bool fwd)
|
||||
|
||||
// read voltages from both input pins
|
||||
// calculates avaerage value of 50 measurements
|
||||
void read_directional_couplers()
|
||||
{
|
||||
void read_directional_couplers() {
|
||||
int voltage_sum_fwd = 0;
|
||||
int voltage_sum_ref = 0;
|
||||
|
||||
// Takes 50 samples and sums them up
|
||||
for(iii=0; iii<50; iii++)
|
||||
{ voltage_sum_fwd += analogReadMilliVolts(IO2_FWD);
|
||||
for (iii = 0; iii < 50; iii++) {
|
||||
voltage_sum_fwd += analogReadMilliVolts(IO2_FWD);
|
||||
voltage_sum_ref += analogReadMilliVolts(IO4_REF);
|
||||
}
|
||||
|
||||
@ -272,20 +272,17 @@ void read_directional_couplers()
|
||||
// calculate watt from dBm
|
||||
fwd_watt = dbm_to_watt(fwd_dbm);
|
||||
ref_watt = dbm_to_watt(ref_dbm);
|
||||
|
||||
}
|
||||
|
||||
// delivers the dashboard page in "index.h"
|
||||
void handleRoot()
|
||||
{
|
||||
void handleRoot() {
|
||||
String s = MAIN_page;
|
||||
server.send(200, "text/html", s);
|
||||
}
|
||||
|
||||
|
||||
// delivers a 404 page if a non-existant resouurce is requested
|
||||
void handleNotFound()
|
||||
{
|
||||
void handleNotFound() {
|
||||
String message = F("File Not Found\n\n");
|
||||
|
||||
message += F("URI: ");
|
||||
@ -296,8 +293,7 @@ void handleNotFound()
|
||||
message += server.args();
|
||||
message += F("\n");
|
||||
|
||||
for (uint8_t i = 0; i < server.args(); i++)
|
||||
{
|
||||
for (uint8_t i = 0; i < server.args(); i++) {
|
||||
message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
|
||||
}
|
||||
|
||||
@ -424,6 +420,7 @@ void handleCONFIG() {
|
||||
conf_content += "<p>";
|
||||
conf_content += conf_config_table;
|
||||
conf_content += "<p><form method='POST' action='/'><button class='button' value='back' name='back' type='submit'>Back to Dashboard</button></form>";
|
||||
conf_content += "<p><p>Version " + version;
|
||||
conf_content += "</html>";
|
||||
server.send(200, "text/html", conf_content);
|
||||
}
|
||||
@ -480,7 +477,13 @@ void build_config_table() {
|
||||
conf_config_table += "<tr><td>";
|
||||
conf_config_table += config_items[i];
|
||||
conf_config_table += "</td><td>";
|
||||
//if (String(stored_val).equalsIgnoreCase("true")) {
|
||||
// conf_config_table += "<input type='checkbox' name=" + config_items[i] + " value=" + config_items[i]+ " checked>";
|
||||
//} else if (String(stored_val).equalsIgnoreCase("false")) {
|
||||
// conf_config_table += "<input type='checkbox' name=" + config_items[i] + " value=" + config_items[i]+ ">";
|
||||
//} else {
|
||||
conf_config_table += String(stored_val);
|
||||
//}
|
||||
conf_config_table += "</td><td>";
|
||||
conf_config_table += "</td></tr>";
|
||||
}
|
||||
@ -520,8 +523,7 @@ void handleMODTRANS() {
|
||||
|
||||
// resets all vlaues in the FWD and REF array
|
||||
void clear_fwd_ref_array() {
|
||||
for (int x = 0; x < sizeof(fwd_array) / sizeof(fwd_array[0]); x++)
|
||||
{
|
||||
for (int x = 0; x < sizeof(fwd_array) / sizeof(fwd_array[0]); x++) {
|
||||
fwd_array[x] = 0;
|
||||
ref_array[x] = 0;
|
||||
}
|
||||
@ -532,21 +534,15 @@ void clear_fwd_ref_array(){
|
||||
// writes all rows into an array
|
||||
void save_string_to_array(String table_data, double arr[]) {
|
||||
int r = 0, t = 0;
|
||||
for(int i=0;i<table_data.length();i++)
|
||||
{
|
||||
if(table_data[i] == '\n' || i==table_data.length())
|
||||
{
|
||||
if (i-r > 1)
|
||||
{
|
||||
for (int i = 0; i < table_data.length(); i++) {
|
||||
if (table_data[i] == '\n' || i == table_data.length()) {
|
||||
if (i - r > 1) {
|
||||
String row = table_data.substring(r, i);
|
||||
t++;
|
||||
int r2 = 0, t2 = 0;
|
||||
for(int j=0;j<row.length();j++)
|
||||
{
|
||||
if(row[j] == ':' || row[j] == '\n')
|
||||
{
|
||||
if (j-r2 > 1)
|
||||
{
|
||||
for (int j = 0; j < row.length(); j++) {
|
||||
if (row[j] == ':' || row[j] == '\n') {
|
||||
if (j - r2 > 1) {
|
||||
int key = row.substring(r2, j).toInt();
|
||||
double val = row.substring(j + 1).toDouble();
|
||||
arr[key] = val;
|
||||
@ -595,8 +591,7 @@ void handleBAND() {
|
||||
}
|
||||
|
||||
// initialization routine
|
||||
void setup()
|
||||
{
|
||||
void setup() {
|
||||
// DELETEME: Cleanup from old ver
|
||||
config.remove(String("show_fwd").c_str());
|
||||
config.remove(String("show_ref").c_str());
|
||||
@ -604,7 +599,8 @@ void setup()
|
||||
|
||||
Serial.begin(115200);
|
||||
|
||||
while (!Serial);
|
||||
while (!Serial)
|
||||
;
|
||||
|
||||
// Using this if Serial debugging is not necessary or not using Serial port
|
||||
//while (!Serial && (millis() < 3000));
|
||||
@ -655,7 +651,6 @@ void setup()
|
||||
build_textareas();
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
void loop() {
|
||||
server.handleClient();
|
||||
}
|
Loading…
Reference in New Issue
Block a user