Skip to content

Commit

Permalink
Doc
Browse files Browse the repository at this point in the history
  • Loading branch information
pu2clr committed Oct 26, 2024
1 parent 0c00e88 commit ef6ea11
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ uint8_t currentPower = 0;

//
char ps[9] = "QN8066 \r";
char rt[33] = "NANO33 IOT FM TX REMOTE CONTROL\r";
char rt[33] = "Nano33IoT_QN8066 PASS:12345678\r";

// WI-FI Setup
char ssid[] = "Nano33IoT_QN8066"; // Wi-Fi network name
Expand Down Expand Up @@ -102,7 +102,8 @@ void setup() {
tx.setup();
tx.setTX(currentFrequency); // Sets frequency to 106.9 MHz
delay(500);
startRDS();
startRDS();
sendRDS();

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,24 +77,25 @@ void setup() {
void doFormParameters() {
String htmlPage = "<html><head>";
htmlPage += "<style>";
htmlPage += "body { font-family: Arial, sans-serif; background-color: #006400; color: yellow;"; // Amazon green background (#006400) and yellow text
htmlPage += "body { font-family: Arial, sans-serif; background-color: #006400; color: yellow;"; // Fundo verde Amazonas (#006400) e texto amarelo
htmlPage += " display: flex; flex-direction: column; justify-content: center; align-items: center; height: 100vh; margin: 0; }";
htmlPage += "h1 { text-align: center; margin-bottom: 20px; color: yellow; }"; // Title with yellow font
htmlPage += "h1 { text-align: center; margin-bottom: 20px; color: yellow; }"; // Título com fonte amarela
htmlPage += "table { border-collapse: collapse; width: auto; margin-top: 20px; }";
htmlPage += "td, th { border: 1px solid black; padding: 8px; color: yellow; }"; // Table text yellow
htmlPage += "td input[type='text'], td select { width: 32ch; color: yellow; background-color: #004d00; border: 1px solid yellow; }"; // Fields with dark green background and yellow border
htmlPage += "td:nth-child(1) { text-align: right; }"; // Align labels to the right
htmlPage += "td, th { border: 1px solid black; padding: 8px; color: yellow; }";
htmlPage += "td input[type='text'], td select { width: 32ch; color: yellow; background-color: #004d00; border: 1px solid yellow; }";
htmlPage += "td:nth-child(1) { text-align: right; }";
htmlPage += "</style>";

htmlPage += "</head><body>";

htmlPage += "<h1>PU2CLR QN8066 Arduino Library</h1>";
htmlPage += "<h2>Arduino NANO 33 IoT - FM Transmitter Controller</h2>";
htmlPage += "<h1>PU2CLR - QN8066 Arduino Library</h1>";
htmlPage += "<h2>FM Transmitter Controlled by ESP8266 via Wi-Fi</h2>";

// Form with Ajax and traditional solution

// Formulário com Ajax e solução tradicional
htmlPage += "<form method='POST' action='/setParameters'>";

// Table to align fields and buttons
// Tabela para alinhar campos e botões
htmlPage += "<table>";

// Frequency
Expand Down Expand Up @@ -151,7 +152,7 @@ void doFormParameters() {
htmlPage += "<td><button type='button' onclick='sendData(\"rds_pty\")'>Set</button></td>";
htmlPage += "</tr>";

// RDS Program Station (PS)
// RDS Programa Station (PS)
htmlPage += "<tr>";
htmlPage += "<td>RDS PS:</td>";
htmlPage += "<td><input type='text' id='rds_ps' name='rds_ps' maxlength='8'></td>";
Expand All @@ -165,14 +166,13 @@ void doFormParameters() {
htmlPage += "<td><button type='button' onclick='sendData(\"rds_rt\")'>Set</button></td>";
htmlPage += "</tr>";

// RDS DT line
// Linha do RDS DT
htmlPage += "<tr>";
htmlPage += "<td>RDS DT:</td>";
htmlPage += "<td><input type='text' id='rds_dt' name='rds_dt' maxlength='32'></td>";
htmlPage += "<td><button type='button' onclick='sendData(\"rds_dt\")'>Set</button></td>";
htmlPage += "<td>RDS DT (yyyy/mm/dd hh:mm):</td>";
htmlPage += "<td><input type='text' id='datetime' name='datetime' maxlength='32'></td>";
htmlPage += "<td><button type='button' onclick='sendData(\"datetime\")'>Set</button></td>";
htmlPage += "</tr>";


// Frequency Derivation list
htmlPage += "<tr>";
htmlPage += "<td>Frequency Derivation:</td>";
Expand Down Expand Up @@ -213,7 +213,6 @@ void doFormParameters() {
htmlPage += "<td><button type='button' onclick='sendData(\"buffer_gain\")'>Set</button></td>";
htmlPage += "</tr>";


// Soft Clip
htmlPage += "<tr>";
htmlPage += "<td>Soft Clip:</td>";
Expand All @@ -224,19 +223,19 @@ void doFormParameters() {
htmlPage += "<td><button type='button' onclick='sendData(\"soft_clip\")'>Set</button></td>";
htmlPage += "</tr>";

// Close table and submit button for the complete form (traditional solution)
htmlPage += "</table><br>";

// Fechar tabela e botão de enviar o formulário completo (solução tradicional)
// htmlPage += "</table><br>";
// htmlPage += "<input type='submit' value='Submit All Parameters'>";

// Close the form definition
htmlPage += "</form>";

// Script to send data via Ajax (individual submission)
// Script para enviar dados via Ajax (envio individual)
htmlPage += "<script>";
htmlPage += "function sendData(fieldId) {";
htmlPage += " var value = document.getElementById(fieldId).value;";
htmlPage += " var xhr = new XMLHttpRequest();";
htmlPage += " xhr.open('POST', '/setParameters', true);";
htmlPage += " xhr.open('POST', '/update', true);";
htmlPage += " xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');";
htmlPage += " xhr.onreadystatechange = function() {";
htmlPage += " if (xhr.readyState == 4 && xhr.status == 200) {";
Expand All @@ -247,9 +246,13 @@ void doFormParameters() {
htmlPage += "}";
htmlPage += "</script>";

// Fechar corpo e HTML
htmlPage += "</body></html>";
client.println(htmlPage);

client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
client.println(htmlPage);
}

// Function to process POST requests
Expand Down Expand Up @@ -316,12 +319,15 @@ void loop() {

// Process the request manually based on URL
if (request.indexOf("GET / ") >= 0) {
Serial.println("---- 1");
doFormParameters(); // Route for the root page
}
else if (request.indexOf("POST /setParameters") >= 0) {
Serial.println("---- 2");
doFormParameters(); // Route for handling form submission
}
else if (request.indexOf("POST /update") >= 0) {
Serial.println("---- 3");
processPostRequest(); // Route for handling AJAX updates
}
else {
Expand Down

0 comments on commit ef6ea11

Please sign in to comment.