Tnx for the Kong’Grats
I’m presently coding (arduino IDE) the main functions of the board. A lot of code is not yet written( I’m not too good at coding in arduino IDE)
I planed to use a MESH protocole
/***************************************************
This is our GFX example for the Adafruit ILI9341 Breakout and Shield
----> http://www.adafruit.com/products/1651
Check out the links above for our tutorials and wiring diagrams
These displays use SPI to communicate, 4 or 5 pins are required to
interface (RST is optional)
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries.
MIT license, all text above must be included in any redistribution
****************************************************/
#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
#include <LoRa.h> // this is the one by Sandeep Mistry
#include "FastLED.h"
#define _cs 12 // 3 goes to TFT CS
#define _dc 27 // 4 goes to TFT DC
#define _mosi 23 // 5 goes to TFT MOSI
#define _sclk 18 // 6 goes to TFT SCK/CLK
#define _rst 13 // ESP RST to TFT RESET
#define _miso // Not connected
// 3.3V // Goes to TFT LED
// 5v // Goes to TFT Vcc
// Gnd // Goes to TFT Gnd
// LoRa Settings
#define BAND 868500000.00
#define spreadingFactor 9
// #define SignalBandwidth 62.5E3
#define SignalBandwidth 31.25E3
#define codingRateDenominator 8
#define preambleLength 8
// SPI RFM95 PINS
//SPI defs for screen
#define SS 5
#define RST 14
#define DI0 26
// Buzzer information
int channel = 0;
int frequence = 2000;
int resolution = 10;
unsigned long timer = millis();
int buzzer_pin = 15;
TaskHandle_t dobitaobyte;
eTaskState statusOf;
//LEDS
// SNAPONAIR RGB LED TEST CODE
#define NUM_LEDS 1
#define DATA_PIN 22
#define BRIGHTNESS 40 // From 0 to 255
CRGB leds[NUM_LEDS];
// misc vars
String msg;
String displayName;
String sendMsg;
char chr;
int i=0;
// Use hardware SPI (on ESP D4 and D8 as above)
//Adafruit_ILI9341 tft = Adafruit_ILI9341(_CS, _DC);
// If using the breakout, change pins as desired
Adafruit_ILI9341 tft = Adafruit_ILI9341(_cs, _dc, _mosi, _sclk, _rst);
void setup() {
Serial.begin(115200);
Serial.println("ILI9341 Test!");
// Set LEDS
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
LEDS.setBrightness(BRIGHTNESS);
// Setup GPIO4 on
pinMode(4, OUTPUT); // sets the digital pin 4 as output to power the backgrnd led
digitalWrite(4, HIGH);
tft.begin();
// read diagnostics (optional but can help debug problems)
uint8_t x = tft.readcommand8(ILI9341_RDMODE);
Serial.print("Display Power Mode: 0x"); Serial.println(x, HEX);
x = tft.readcommand8(ILI9341_RDMADCTL);
Serial.print("MADCTL Mode: 0x"); Serial.println(x, HEX);
x = tft.readcommand8(ILI9341_RDPIXFMT);
Serial.print("Pixel Format: 0x"); Serial.println(x, HEX);
x = tft.readcommand8(ILI9341_RDIMGFMT);
Serial.print("Image Format: 0x"); Serial.println(x, HEX);
x = tft.readcommand8(ILI9341_RDSELFDIAG);
Serial.print("Self Diagnostic: 0x"); Serial.println(x, HEX);
// We set the ID of the pager
displayName = "SoA001";
tft.setRotation(3);
testText();
tft.setRotation(3);
delay(1000);
testText();
delay(1000);
/*
// Send packet
msg="First txt message in chat";
// Receive a message first...
sendMsg += displayName;
sendMsg += msg;
// send message
LoRa.beginPacket();
LoRa.print(sendMsg);
LoRa.endPacket();
Serial.println(sendMsg);
// tft.setTextColor(ILI9341_RED); tft.setTextSize(1);
// tft.println(sendMsg);
// clear the strings and start again :D
msg = "";
sendMsg = "";
*/
}
void loop(void) {
// tft.setRotation(3);
// testText();
// delay(1000);
}
unsigned long testText() {
tft.fillScreen(ILI9341_BLACK);
// Draw the screen cells
tft.drawRect(1,1, 319, 239, ILI9341_RED);
// First line separator
tft.drawLine( 1, 20, 319, 20, ILI9341_RED);
// 2nd line separator
tft.drawLine( 1, 40, 319, 40, ILI9341_RED);
// keyboard line 1
tft.drawLine( 1, 239-(5*20), 319, 239-(5*20), ILI9341_RED);
tft.drawLine( 1, 239-(4*20), 319, 239-(4*20), ILI9341_RED);
tft.drawLine( 1, 239-(3*20), 319, 239-(3*20), ILI9341_RED);
tft.drawLine( 1, 239-(2*20), 319, 239-(2*20), ILI9341_RED);
tft.drawLine( 1, 239-(1*20), 319, 239-(1*20), ILI9341_RED);
// kb first line
tft.setCursor(6, 245-(5*20));
tft.setTextColor(ILI9341_WHITE); tft.setTextSize(1);
tft.print("~ 1 2 3 4 5 6 7 8 9 _ = Bksp");
// kb 2nd line
tft.setCursor(6, 245-(4*20));
tft.setTextColor(ILI9341_WHITE); tft.setTextSize(1);
tft.print(" Q W E R T Y U I O P [ ]");
// kb 3RD line
tft.setCursor(6, 245-(3*20));
tft.setTextColor(ILI9341_WHITE); tft.setTextSize(1);
tft.print("Tab A S D F G H J K L ; ' Ent");
// kb 4th line
tft.setCursor(6, 245-(2*20));
tft.setTextColor(ILI9341_WHITE); tft.setTextSize(1);
tft.print("Shift Z X C V N B N M , . /");
// kb (th line
tft.setCursor(6, 245-(1*20));
tft.setTextColor(ILI9341_WHITE); tft.setTextSize(1);
tft.print(" Ctrl Alt <SPACE>");
// Separation
for(int x = 0; x < 12; x++){
tft.drawLine( 24*x+20, 239-(5*20), 24*x+20, 239-(4*20), ILI9341_RED);
}
for(int x = 0; x < 13; x++){
tft.drawLine( 24*x+15, 239-(4*20), 24*x+15, 239-(3*20), ILI9341_RED);
}
for(int x = 0; x < 12; x++){
tft.drawLine( 24*x+32, 239-(3*20), 24*x+32, 239-(2*20), ILI9341_RED);
}
for(int x = 0; x < 12; x++){
tft.drawLine( 24*x+45, 239-(2*20), 24*x+45, 239-(1*20), ILI9341_RED);
}
for(int x = 0; x < 2; x++){
tft.drawLine( 34*x+40, 239-(1*20), 34*x+40, 239, ILI9341_RED);
}
tft.drawLine( 34*6+40, 239-(1*20), 34*6+40, 239, ILI9341_RED);
unsigned long start = micros();
tft.setCursor(6, 8);
tft.setTextColor(ILI9341_RED); tft.setTextSize(1);
tft.println("www.SnapOnAir.com");
// print GPS coordinates
tft.setCursor(6, 28);
tft.setTextColor(ILI9341_RED); tft.setTextSize(1);
tft.print("GPS:");
tft.setTextColor(ILI9341_WHITE); tft.setTextSize(1); // 47.86944,1.837931000000026
tft.print("47.86944,1.837931000000026 ");
tft.setTextColor(ILI9341_RED); tft.setTextSize(1);
tft.print("Freq:");
tft.setTextColor(ILI9341_WHITE); tft.setTextSize(1);
tft.println("868.500 Mhz");
// SET LED
SetRGBLED(5);
// delay so you have time to
delay(1000);
// Turn the LED OFF
SetRGBLEDOFF();
return micros() - start;
}
int SetRGBLEDOFF(){
// Turn off LED
leds[0] = CRGB::Black;
FastLED.show();
}
int SetRGBLED(int ledcolor){
if (ledcolor == 1) {
// turn LED on BLUE:
leds[0] = CRGB::Blue;
}
if (ledcolor == 2) {
// turn LED on : Yellow
leds[0] = CRGB::Yellow;
}
if (ledcolor == 3) {
// turn LED on RED:
leds[0] = CRGB::Red;
}
if (ledcolor == 4) {
// turn LED on ORANGE:
leds[0] = CRGB::Orange;
}
if (ledcolor == 5) {
// turn LED on Pink:
leds[0] = CRGB::Pink;
}
FastLED.show();
}
// Buzzer Function
void sirene(void *pvParameters){
float sinVal;
int toneVal;
for (byte t = 0; t<10;t++){
for (byte x=0;x<180;x++){
//converte graus em radianos
sinVal = (sin(x*(3.1412/180)));
//agora gera uma frequencia
toneVal = 2000+(int(sinVal*100));
//toca o valor no buzzer
ledcWriteTone(channel,toneVal);
//Serial.print("*");
//atraso de 2ms e gera novo tom
delay(4);
}
}
ledcWriteTone(channel, 0);
vTaskDelete(NULL);
}