Commit 8d65ebf1 authored by Giacomo Lavermicocca's avatar Giacomo Lavermicocca

Dispaly paramters show

parent c5f0ff69
......@@ -37,6 +37,7 @@ String str;
int addr = 0;
#define EEPROM_SIZE 1
int eValue = 0;
int eeValue = 0;
void setup() {
......@@ -51,13 +52,16 @@ void setup() {
display.setFont(ArialMT_Plain_10);
//------------------------------------------------------------------------
Serial.begin(115200);
while (!Serial);
if (!EEPROM.begin(EEPROM_SIZE))
{
Serial.println("failed to initialise EEPROM"); delay(1000000);
}
Serial.begin(115200);
while (!Serial);
eeValue = (EEPROM.read(addr));
Serial.println(String(eeValue));
Serial.println("LoRa Receiver Callback");
SPI.begin(SCK,MISO,MOSI,SS);
......@@ -87,8 +91,14 @@ void loop() {
//Reset rele
digitalWrite(RELE_1, LOW);
digitalWrite(RELE_2, LOW);
eeValue = (EEPROM.read(addr));
Serial.println(String(eeValue));
} else {
Serial.println(eeValue);
eeValue = genNextPrime(eeValue);
// EEPROM.write(addr, eeValue);
// EEPROM.commit();
}
drawTextOLED(str);
......@@ -132,11 +142,6 @@ void onReceive(int packetSize)
String r1 = String(RELE_1, DEC);
String r2 = String(RELE_2, DEC);
eeValue = 1234;
EEPROM.write(addr, eeValue);
EEPROM.commit();
if(extraParam == 111)
{
......@@ -158,7 +163,7 @@ void onReceive(int packetSize)
LoRa.endPacket();
// put the radio into receive mode
LoRa.receive();
LoRa.receive();
}
// print RSSI of packet
Serial.print("' with RSSI ");
......@@ -183,7 +188,15 @@ void setRele2()
long i = 2; // Start at 2
int is_prime(long num) {
long genNextPrime(const long currentPrime) {
long i = currentPrime + 1;
while (!isPrime(i)) {
i++;
}
return i;
}
int isPrime(long num) {
// Only have to check for divisible for the sqrt(number)
int upper = sqrt(num);
......@@ -198,4 +211,3 @@ int is_prime(long num) {
return 1; // If you get this far it's prime
}
......@@ -23,6 +23,8 @@
#include <ESPmDNS.h>
#include "SSD1306.h" // alias for `#include "SSD1306Wire.h"`
const char* ssid = "Thomas";
const char* password = "viapiccardi47!!thomas";
......@@ -41,8 +43,13 @@ WiFiServer server(80);
#define BAND 868E6 //you can set band here directly,e.g. 868E6,915E6
#define PABOOST true
SSD1306 display(0x3c, 4, 15);
String ipAddr = "";
String lastCommand = "";
void setup(void)
{
{
pinMode(25,OUTPUT);
Serial.begin(115200);
......@@ -72,8 +79,9 @@ void setup(void)
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
ipAddr = WiFi.localIP().toString();
Serial.println(ipAddr);
// Set up mDNS responder:
// - first argument is the domain name, in this example
// the fully-qualified domain name is "esp8266.local"
......@@ -93,6 +101,34 @@ void setup(void)
// Add service to MDNS-SD
MDNS.addService("http", "tcp", 80);
//-------- DISPLAY INIT --------------
pinMode(16,OUTPUT);
digitalWrite(16, LOW); // set GPIO16 low to reset OLED
delay(50);
digitalWrite(16, HIGH); // while OLED is running, must set GPIO16 in high
// Initialising the UI will init the display too.
display.init();
display.flipScreenVertically();
display.setFont(ArialMT_Plain_10);
}
void drawTextOLED(String text, String ttext) {
display.clear();
display.setTextAlignment(TEXT_ALIGN_LEFT);
display.setFont(ArialMT_Plain_10);
display.drawString(0, 0, "Last command : " + text);
display.setFont(ArialMT_Plain_10);
display.drawString(0, 20, "IP addr : " + ttext);
display.setFont(ArialMT_Plain_10);
display.drawString(0, 40, "Giacomo Lavermicocca");
display.display();
}
String s;
......@@ -101,6 +137,8 @@ const long interval = 10000;
void loop(void)
{
drawTextOLED(lastCommand, ipAddr);
// Check if a client has connected
WiFiClient client = server.available();
if (!client) {
......@@ -144,8 +182,9 @@ void loop(void)
s += "</html>\r\n\r\n";
} else if(req.indexOf('/pin') > 0) {
pinRequest(req);
lastCommand = req;
s = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n<!DOCTYPE HTML>\r\n<html>Hello from ESP32 at pin : ";
s += req.substring(req.lastIndexOf('/')+1);
s += lastCommand;
s += "</html>\r\n\r\n";
previousMillis = currentMillis;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment