SpectralSensor ESP32- początki
This commit is contained in:
@@ -1,22 +1,28 @@
|
|||||||
|
#include <TFT_eSPI.h>
|
||||||
|
#include <SPI.h>
|
||||||
|
|
||||||
|
|
||||||
|
// Wymaga konfiguracjie:
|
||||||
|
// C:\Users\siiee\Documents\Arduino\libraries\TFT_eSPI
|
||||||
|
|
||||||
|
TFT_eSPI tft = TFT_eSPI(); // domyślna konfiguracja z User_Setup.h
|
||||||
|
|
||||||
//2DO:
|
//2DO:
|
||||||
// obsługa przycisków zmieniających menu i LED
|
// obsługa przycisków zmieniających menu i LED
|
||||||
|
|
||||||
//160x128
|
//160x128
|
||||||
|
|
||||||
#define Version "0.0.0"
|
#define Version "0.0.0"
|
||||||
#include <SPI.h>
|
#include <SPI.h>
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
#include <Adafruit_GFX.h>
|
#include <Adafruit_GFX.h>
|
||||||
#include <Adafruit_ST7735.h>
|
|
||||||
#include "AS726X.h"
|
#include "AS726X.h"
|
||||||
#define TFT_DC 8
|
// #define TFT_CS 5
|
||||||
#define TFT_CS 9
|
// #define TFT_RST 4
|
||||||
#define TFT_RST 10
|
// #define TFT_DC 2
|
||||||
|
|
||||||
#define Btn1 21 //on board: A1 menu
|
#define Btn1 33 //on board: A1 menu
|
||||||
#define Btn2 20 //on board: A2 gain
|
#define Btn2 34 //on board: A2 gain
|
||||||
#define Btn3 19 //on board: A3 ???
|
#define Btn3 35 //on board: A3 ???
|
||||||
|
|
||||||
#define WHITE 0xFFFF
|
#define WHITE 0xFFFF
|
||||||
#define BLACK 0x0000
|
#define BLACK 0x0000
|
||||||
@@ -37,7 +43,6 @@
|
|||||||
|
|
||||||
|
|
||||||
AS726X sensor;
|
AS726X sensor;
|
||||||
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);
|
|
||||||
|
|
||||||
int RawRed = 0;
|
int RawRed = 0;
|
||||||
int RawOrange = 0;
|
int RawOrange = 0;
|
||||||
@@ -78,25 +83,23 @@ char ChValue[20];
|
|||||||
|
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
tft.initR(INITR_BLACKTAB);
|
tft.init();
|
||||||
tft.fillScreen(BLACK);
|
|
||||||
tft.setRotation(1);
|
tft.setRotation(1);
|
||||||
tft.setTextSize(1);
|
tft.fillScreen(TFT_BLACK);
|
||||||
tft.setTextColor(WHITE);
|
|
||||||
tft.setCursor(0, 0);
|
|
||||||
tft.println("Version:");
|
|
||||||
tft.setCursor(0, 10);
|
|
||||||
tft.println(Version);
|
|
||||||
|
|
||||||
delay(1000);
|
tft.setTextColor(TFT_YELLOW, TFT_BLACK);
|
||||||
|
tft.setTextSize(2);
|
||||||
|
tft.drawString("Version:"+ String(Version), 0, 0);
|
||||||
|
delay(500);
|
||||||
Wire.begin();
|
Wire.begin();
|
||||||
Serial.begin(115200);
|
|
||||||
sensor.begin();
|
sensor.begin();
|
||||||
pinMode(Btn1, INPUT);
|
pinMode(Btn1, INPUT);
|
||||||
pinMode(Btn2, INPUT);
|
pinMode(Btn2, INPUT);
|
||||||
|
tft.fillRect(0, 0, 240, 240, TFT_BLACK);
|
||||||
|
|
||||||
}
|
}
|
||||||
void drawControls() {
|
void drawControls() {
|
||||||
tft.fillScreen(BLACK);
|
// tft.fillRect(0, 0, 240, 240, TFT_BLACK);
|
||||||
|
|
||||||
// ////tft.setRotation(0);
|
// ////tft.setRotation(0);
|
||||||
// linia pozycyjna LED
|
// linia pozycyjna LED
|
||||||
@@ -131,29 +134,26 @@ void drawControls() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
void loop() {
|
void loop() {
|
||||||
tft.fillScreen(ST77XX_BLACK);
|
|
||||||
tft.setTextSize(1);
|
tft.setTextSize(1);
|
||||||
tft.setTextColor(WHITE);
|
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||||
|
|
||||||
// //TESTY
|
// // //TESTY
|
||||||
// tft.setCursor(0, 0);
|
// tft.setTextColor(TFT_WHITE);
|
||||||
// tft.setTextColor(WHITE);
|
// tft.drawString("test",0, 0);
|
||||||
// tft.setTextWrap(true);
|
// tft.fillRect(0, 64 , 25, 64, TFT_RED);
|
||||||
// tft.print("test");
|
// tft.fillRect(25, 64 , 25, 64, TFT_ORANGE);
|
||||||
// delay(500);
|
// tft.fillRect(50, 64 , 25, 64, TFT_YELLOW);
|
||||||
// tft.fillRect(0, 64 , 25, 64, RED);
|
// tft.fillRect(75, 64 , 25, 64, TFT_GREEN);
|
||||||
// tft.fillRect(25, 64 , 25, 64, ORANGE);
|
// tft.fillRect(100, 64 , 25, 64, TFT_BLUE);
|
||||||
// tft.fillRect(50, 64 , 25, 64, YELLOW);
|
// tft.fillRect(125, 64 , 25, 64, TFT_MAGENTA);
|
||||||
// tft.fillRect(75, 64 , 25, 64, GREEN);
|
// tft.fillRect(150, 64 , 25, 64, TFT_WHITE);
|
||||||
// tft.fillRect(100, 64 , 25, 64, BLUE);
|
|
||||||
// tft.fillRect(125, 64 , 25, 64, MAGENTA);
|
|
||||||
// delay(1000);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//menu change
|
//menu change
|
||||||
if (digitalRead(Btn2) == HIGH) {
|
if (digitalRead(Btn2) == HIGH) {
|
||||||
|
tft.fillRect(0, 0, 240, 240, TFT_BLACK);
|
||||||
if (menu_number < 8) {
|
if (menu_number < 8) {
|
||||||
menu_number = menu_number + 1;
|
menu_number = menu_number + 1;
|
||||||
} else {
|
} else {
|
||||||
@@ -165,255 +165,201 @@ void loop() {
|
|||||||
|
|
||||||
|
|
||||||
if (menu_number == 0 ) {//show menu
|
if (menu_number == 0 ) {//show menu
|
||||||
|
tft.setTextSize(2);
|
||||||
|
tft.drawString("GAIN:" + String(gainValue),0, 0);
|
||||||
|
tft.drawString("LED: 5-8",0, 16);
|
||||||
|
tft.drawString("0:Menu",0, 32);
|
||||||
|
tft.drawString("1:Calc.Values",0, 48);
|
||||||
|
tft.drawString("2:Raw",0, 64);
|
||||||
|
tft.drawString("3:Rel. Graph",0, 80);
|
||||||
|
tft.drawString("4:Calc. Graph",0, 96);
|
||||||
drawControls();
|
drawControls();
|
||||||
tft.setCursor(0, 0);
|
|
||||||
tft.println("GAIN");
|
delay(100);
|
||||||
tft.setCursor(32, 0);
|
|
||||||
tft.println(gainValue, 1);
|
|
||||||
tft.setCursor(64, 0);
|
|
||||||
tft.println("LED: 5-8");
|
|
||||||
tft.setCursor(0, 8);
|
|
||||||
tft.println("0:Menu 1:Calculated");
|
|
||||||
tft.setCursor(0, 16);
|
|
||||||
tft.println("2:Raw 3:Reltive Graph");
|
|
||||||
tft.setCursor(0, 24);
|
|
||||||
tft.println("4:Calculated Graph");
|
|
||||||
delay(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
// //
|
||||||
if (menu_number == 1 || menu_number == 5 ) {//show calculated values
|
if (menu_number == 1 || menu_number == 5 ) {//show calculated values
|
||||||
drawControls();
|
drawControls();
|
||||||
//tft.setRotation(0);
|
//tft.setRotation(0);
|
||||||
tft.setCursor(0, 25);
|
tft.drawString("Calculated Values",0,0);
|
||||||
tft.println("R:");
|
tft.drawString("R:" + String(CalcRed),0, 20);
|
||||||
tft.setCursor((GrapWidth), 25);
|
tft.drawString("O:" + String(CalcOrange),0, 39);
|
||||||
tft.println("O:");
|
tft.drawString("Y:" + String(CalcYellow),0, 58);
|
||||||
tft.setCursor((GrapWidth) * 2, 25);
|
tft.drawString("G:" + String(CalcGreen),0, 77);
|
||||||
tft.println("Y:");
|
tft.drawString("B:" + String(CalcBlue),0, 96);
|
||||||
tft.setCursor((GrapWidth) * 3, 25);
|
tft.drawString("V:" + String(CalcViolet),0, 115);
|
||||||
tft.println("G:");
|
|
||||||
tft.setCursor((GrapWidth) * 4, 25);
|
|
||||||
tft.println("B:");
|
|
||||||
tft.setCursor((GrapWidth) * 5, 25);
|
|
||||||
tft.println("V:");
|
|
||||||
////tft.setRotation(3);
|
|
||||||
tft.setCursor(0, 4);
|
|
||||||
dtostrf(CalcRed, 10, 1, FloatInChar);
|
|
||||||
tft.println(FloatInChar);
|
|
||||||
tft.setCursor(0, (GrapWidth * 1) + 5);
|
|
||||||
dtostrf(CalcOrange, 10, 1, FloatInChar);
|
|
||||||
tft.println(FloatInChar);
|
|
||||||
tft.setCursor(0, (GrapWidth * 2) + 5);
|
|
||||||
dtostrf(CalcYellow, 10, 1, FloatInChar);
|
|
||||||
tft.println(FloatInChar);
|
|
||||||
tft.setCursor(0, (GrapWidth * 3) + 5);
|
|
||||||
dtostrf(CalcGreen, 10, 1, FloatInChar);
|
|
||||||
tft.println(FloatInChar);
|
|
||||||
tft.setCursor(0, (GrapWidth * 4) + 5);
|
|
||||||
dtostrf(CalcBlue, 10, 1, FloatInChar);
|
|
||||||
tft.println(FloatInChar);
|
|
||||||
tft.setCursor(0, (GrapWidth * 5) + 5);
|
|
||||||
dtostrf(CalcViolet, 10, 1, FloatInChar);
|
|
||||||
tft.println(FloatInChar);
|
|
||||||
}
|
}
|
||||||
|
// //show raw values
|
||||||
// ////tft.setRotation(0);
|
|
||||||
//show raw values
|
|
||||||
if (menu_number == 2 || menu_number == 6) {
|
if (menu_number == 2 || menu_number == 6) {
|
||||||
drawControls();
|
drawControls();
|
||||||
////tft.setRotation(0);
|
tft.drawString("Raw Values",0,0);
|
||||||
tft.setCursor(0, 25);
|
tft.drawString("R:" + String(RawRed),0, 20);
|
||||||
tft.println("R");
|
tft.drawString("O:" + String(RawOrange),0, 39);
|
||||||
tft.setCursor((GrapWidth), 25);
|
tft.drawString("Y:" + String(RawYellow),0, 58);
|
||||||
tft.println("O");
|
tft.drawString("G:" + String(RawGreen),0, 77);
|
||||||
tft.setCursor((GrapWidth) * 2, 25);
|
tft.drawString("B:" + String(RawBlue),0, 96);
|
||||||
tft.println("Y");
|
tft.drawString("V:" + String(RawViolet),0, 115);
|
||||||
tft.setCursor((GrapWidth) * 3, 25);
|
|
||||||
tft.println("G");
|
|
||||||
tft.setCursor((GrapWidth) * 4, 25);
|
|
||||||
tft.println("B");
|
|
||||||
tft.setCursor((GrapWidth) * 5, 25);
|
|
||||||
tft.println("V");
|
|
||||||
////tft.setRotation(3);
|
|
||||||
|
|
||||||
tft.setCursor(0, 4);
|
|
||||||
dtostrf(RawRed, 10, 0, FloatInChar);
|
|
||||||
tft.println(FloatInChar);
|
|
||||||
tft.setCursor(0, (GrapWidth * 1) + 5);
|
|
||||||
dtostrf(RawOrange, 10, 0, FloatInChar);
|
|
||||||
tft.println(FloatInChar);
|
|
||||||
tft.setCursor(0, (GrapWidth * 2) + 5);
|
|
||||||
dtostrf(RawYellow, 10, 0, FloatInChar);
|
|
||||||
tft.println(FloatInChar);
|
|
||||||
tft.setCursor(0, (GrapWidth * 3) + 5);
|
|
||||||
dtostrf(RawGreen, 10, 0, FloatInChar);
|
|
||||||
tft.println(FloatInChar);
|
|
||||||
tft.setCursor(0, (GrapWidth * 4) + 5);
|
|
||||||
dtostrf(RawBlue, 10, 0, FloatInChar);
|
|
||||||
tft.println(FloatInChar);
|
|
||||||
tft.setCursor(0, (GrapWidth * 5) + 5);
|
|
||||||
dtostrf(RawViolet, 10, 0, FloatInChar);
|
|
||||||
tft.println(FloatInChar);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////tft.setRotation(0);
|
////tft.setRotation(0);
|
||||||
|
|
||||||
//show relative calculated values graph
|
// //show relative calculated values graph
|
||||||
if (menu_number == 3 || menu_number == 7 ){
|
// if (menu_number == 3 || menu_number == 7 ){
|
||||||
maxValue = 0;
|
// maxValue = 0;
|
||||||
drawControls();
|
// drawControls();
|
||||||
////tft.setRotation(0);
|
// ////tft.setRotation(0);
|
||||||
|
|
||||||
for (int i = 0; i < 5; i++) {
|
// for (int i = 0; i < 5; i++) {
|
||||||
maxValue = max(maxValue, ReadValues[i]);
|
// maxValue = max(maxValue, ReadValues[i]);
|
||||||
}
|
// }
|
||||||
HeightRed = int((CalcRed / maxValue) * GraphHeight);
|
// HeightRed = int((CalcRed / maxValue) * GraphHeight);
|
||||||
HeightOrange = int((CalcOrange / maxValue) * GraphHeight);
|
// HeightOrange = int((CalcOrange / maxValue) * GraphHeight);
|
||||||
HeightYellow = int((CalcYellow / maxValue) * GraphHeight);
|
// HeightYellow = int((CalcYellow / maxValue) * GraphHeight);
|
||||||
HeightGreen = int((CalcGreen / maxValue) * GraphHeight);
|
// HeightGreen = int((CalcGreen / maxValue) * GraphHeight);
|
||||||
HeightBlue = int((CalcBlue / maxValue) * GraphHeight);
|
// HeightBlue = int((CalcBlue / maxValue) * GraphHeight);
|
||||||
HeightViolet = int((CalcViolet / maxValue) * GraphHeight);
|
// HeightViolet = int((CalcViolet / maxValue) * GraphHeight);
|
||||||
|
|
||||||
|
|
||||||
tft.setCursor(1 * GrapWidth -10, 10);
|
// tft.setCursor(1 * GrapWidth -10, 10);
|
||||||
if (HeightRed >25){
|
// if (HeightRed >25){
|
||||||
tft.setTextColor(BLACK);
|
// tft.setTextColor(BLACK);
|
||||||
}
|
// }
|
||||||
|
|
||||||
tft.fillRect(0 * GrapWidth, GraphHeight - HeightRed, GrapWidth, HeightRed, RED);
|
// tft.fillRect(0 * GrapWidth, GraphHeight - HeightRed, GrapWidth, HeightRed, RED);
|
||||||
tft.fillRect(1 * GrapWidth + 1, GraphHeight - HeightOrange, GrapWidth, HeightOrange, ORANGE);
|
// tft.fillRect(1 * GrapWidth + 1, GraphHeight - HeightOrange, GrapWidth, HeightOrange, ORANGE);
|
||||||
tft.fillRect(2 * GrapWidth + 2, GraphHeight - HeightYellow, GrapWidth, HeightYellow, YELLOW);
|
// tft.fillRect(2 * GrapWidth + 2, GraphHeight - HeightYellow, GrapWidth, HeightYellow, YELLOW);
|
||||||
tft.fillRect(3 * GrapWidth + 3, GraphHeight - HeightGreen, GrapWidth, HeightGreen, GREEN);
|
// tft.fillRect(3 * GrapWidth + 3, GraphHeight - HeightGreen, GrapWidth, HeightGreen, GREEN);
|
||||||
tft.fillRect(4 * GrapWidth + 4, GraphHeight - HeightBlue, GrapWidth, HeightBlue, BLUE);
|
// tft.fillRect(4 * GrapWidth + 4, GraphHeight - HeightBlue, GrapWidth, HeightBlue, BLUE);
|
||||||
tft.fillRect(5 * GrapWidth + 5, GraphHeight - HeightViolet, GrapWidth, HeightViolet, MAGENTA);
|
// tft.fillRect(5 * GrapWidth + 5, GraphHeight - HeightViolet, GrapWidth, HeightViolet, MAGENTA);
|
||||||
tft.setCursor(1 * GrapWidth -10, 0);
|
// tft.setCursor(1 * GrapWidth -10, 0);
|
||||||
if (HeightRed > 28){
|
// if (HeightRed > 28){
|
||||||
tft.setTextColor(BLACK);
|
// tft.setTextColor(BLACK);
|
||||||
}else {
|
// }else {
|
||||||
tft.setTextColor(WHITE);
|
// tft.setTextColor(WHITE);
|
||||||
}
|
// }
|
||||||
tft.println("R:");
|
// tft.println("R:");
|
||||||
tft.setCursor(2 * GrapWidth -10, 0);
|
// tft.setCursor(2 * GrapWidth -10, 0);
|
||||||
if (HeightOrange > 28){
|
// if (HeightOrange > 28){
|
||||||
tft.setTextColor(BLACK);
|
// tft.setTextColor(BLACK);
|
||||||
}else {
|
// }else {
|
||||||
tft.setTextColor(WHITE);
|
// tft.setTextColor(WHITE);
|
||||||
}
|
// }
|
||||||
tft.println("O:");
|
// tft.println("O:");
|
||||||
tft.setCursor(3 * GrapWidth -10, 0);
|
// tft.setCursor(3 * GrapWidth -10, 0);
|
||||||
if (HeightYellow > 28){
|
// if (HeightYellow > 28){
|
||||||
tft.setTextColor(BLACK);
|
// tft.setTextColor(BLACK);
|
||||||
}else {
|
// }else {
|
||||||
tft.setTextColor(WHITE);
|
// tft.setTextColor(WHITE);
|
||||||
}
|
// }
|
||||||
tft.println("Y:");
|
// tft.println("Y:");
|
||||||
tft.setCursor(4 * GrapWidth -10, 0);
|
// tft.setCursor(4 * GrapWidth -10, 0);
|
||||||
if (HeightGreen > 28){
|
// if (HeightGreen > 28){
|
||||||
tft.setTextColor(BLACK);
|
// tft.setTextColor(BLACK);
|
||||||
}else {
|
// }else {
|
||||||
tft.setTextColor(WHITE);
|
// tft.setTextColor(WHITE);
|
||||||
}
|
// }
|
||||||
tft.println("G:");
|
// tft.println("G:");
|
||||||
tft.setCursor(5 * GrapWidth -10, 0);
|
// tft.setCursor(5 * GrapWidth -10, 0);
|
||||||
if (HeightBlue > 28){
|
// if (HeightBlue > 28){
|
||||||
tft.setTextColor(BLACK);
|
// tft.setTextColor(BLACK);
|
||||||
}else {
|
// }else {
|
||||||
tft.setTextColor(WHITE);
|
// tft.setTextColor(WHITE);
|
||||||
}
|
// }
|
||||||
tft.println("B:");
|
// tft.println("B:");
|
||||||
tft.setCursor(6 * GrapWidth -10, 0);
|
// tft.setCursor(6 * GrapWidth -10, 0);
|
||||||
if (HeightViolet > 28){
|
// if (HeightViolet > 28){
|
||||||
tft.setTextColor(BLACK);
|
// tft.setTextColor(BLACK);
|
||||||
}else {
|
// }else {
|
||||||
tft.setTextColor(WHITE);
|
// tft.setTextColor(WHITE);
|
||||||
}
|
// }
|
||||||
tft.println("V:");
|
// tft.println("V:");
|
||||||
|
|
||||||
maxValue = 0.0;
|
// maxValue = 0.0;
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//show relative raw data graph
|
// //show relative raw data graph
|
||||||
if (menu_number == 4 || menu_number == 8 ){
|
// if (menu_number == 4 || menu_number == 8 ){
|
||||||
maxValue = 0;
|
// maxValue = 0;
|
||||||
drawControls();
|
// drawControls();
|
||||||
////tft.setRotation(0);
|
// ////tft.setRotation(0);
|
||||||
|
|
||||||
for (int i = 0; i < 5; i++) {
|
// for (int i = 0; i < 5; i++) {
|
||||||
maxValue = max(maxValue, ReadValues[i]);
|
// maxValue = max(maxValue, ReadValues[i]);
|
||||||
}
|
// }
|
||||||
for (int i = 0; i < 5; i++) {
|
// for (int i = 0; i < 5; i++) {
|
||||||
minValue = min(minValue, ReadValues[i]);
|
// minValue = min(minValue, ReadValues[i]);
|
||||||
}
|
// }
|
||||||
HeightRed = int(((RawRed + abs(minValue)) / (maxValue + abs(minValue))) * GraphHeight);
|
// HeightRed = int(((RawRed + abs(minValue)) / (maxValue + abs(minValue))) * GraphHeight);
|
||||||
HeightOrange = int(((RawOrange + abs(minValue)) / (maxValue + abs(minValue))) * GraphHeight);
|
// HeightOrange = int(((RawOrange + abs(minValue)) / (maxValue + abs(minValue))) * GraphHeight);
|
||||||
HeightYellow = int(((RawYellow + abs(minValue)) / (maxValue + abs(minValue))) * GraphHeight);
|
// HeightYellow = int(((RawYellow + abs(minValue)) / (maxValue + abs(minValue))) * GraphHeight);
|
||||||
HeightGreen = int(((RawGreen + abs(minValue)) / (maxValue + abs(minValue))) * GraphHeight);
|
// HeightGreen = int(((RawGreen + abs(minValue)) / (maxValue + abs(minValue))) * GraphHeight);
|
||||||
HeightBlue = int(((RawBlue + abs(minValue)) / (maxValue + abs(minValue))) * GraphHeight);
|
// HeightBlue = int(((RawBlue + abs(minValue)) / (maxValue + abs(minValue))) * GraphHeight);
|
||||||
HeightViolet = int(((RawViolet + abs(minValue)) / (maxValue + abs(minValue))) * GraphHeight);
|
// HeightViolet = int(((RawViolet + abs(minValue)) / (maxValue + abs(minValue))) * GraphHeight);
|
||||||
|
|
||||||
|
|
||||||
tft.setCursor(1 * GrapWidth -10, 10);
|
// tft.setCursor(1 * GrapWidth -10, 10);
|
||||||
if (HeightRed >25){
|
// if (HeightRed >25){
|
||||||
tft.setTextColor(BLACK);
|
// tft.setTextColor(BLACK);
|
||||||
}
|
// }
|
||||||
|
|
||||||
tft.fillRect(0 * GrapWidth, GraphHeight - HeightRed, GrapWidth, HeightRed, RED);
|
// tft.fillRect(0 * GrapWidth, GraphHeight - HeightRed, GrapWidth, HeightRed, RED);
|
||||||
tft.fillRect(1 * GrapWidth + 1, GraphHeight - HeightOrange, GrapWidth, HeightOrange, ORANGE);
|
// tft.fillRect(1 * GrapWidth + 1, GraphHeight - HeightOrange, GrapWidth, HeightOrange, ORANGE);
|
||||||
tft.fillRect(2 * GrapWidth + 2, GraphHeight - HeightYellow, GrapWidth, HeightYellow, YELLOW);
|
// tft.fillRect(2 * GrapWidth + 2, GraphHeight - HeightYellow, GrapWidth, HeightYellow, YELLOW);
|
||||||
tft.fillRect(3 * GrapWidth + 3, GraphHeight - HeightGreen, GrapWidth, HeightGreen, GREEN);
|
// tft.fillRect(3 * GrapWidth + 3, GraphHeight - HeightGreen, GrapWidth, HeightGreen, GREEN);
|
||||||
tft.fillRect(4 * GrapWidth + 4, GraphHeight - HeightBlue, GrapWidth, HeightBlue, BLUE);
|
// tft.fillRect(4 * GrapWidth + 4, GraphHeight - HeightBlue, GrapWidth, HeightBlue, BLUE);
|
||||||
tft.fillRect(5 * GrapWidth + 5, GraphHeight - HeightViolet, GrapWidth, HeightViolet, MAGENTA);
|
// tft.fillRect(5 * GrapWidth + 5, GraphHeight - HeightViolet, GrapWidth, HeightViolet, MAGENTA);
|
||||||
tft.setCursor(1 * GrapWidth -10, 0);
|
// tft.setCursor(1 * GrapWidth -10, 0);
|
||||||
if (HeightRed > 28){
|
// if (HeightRed > 28){
|
||||||
tft.setTextColor(BLACK);
|
// tft.setTextColor(BLACK);
|
||||||
}else {
|
// }else {
|
||||||
tft.setTextColor(WHITE);
|
// tft.setTextColor(WHITE);
|
||||||
}
|
// }
|
||||||
tft.println("R");
|
// tft.println("R");
|
||||||
tft.setCursor(2 * GrapWidth -10, 0);
|
// tft.setCursor(2 * GrapWidth -10, 0);
|
||||||
if (HeightOrange > 28){
|
// if (HeightOrange > 28){
|
||||||
tft.setTextColor(BLACK);
|
// tft.setTextColor(BLACK);
|
||||||
}else {
|
// }else {
|
||||||
tft.setTextColor(WHITE);
|
// tft.setTextColor(WHITE);
|
||||||
}
|
// }
|
||||||
tft.println("O");
|
// tft.println("O");
|
||||||
tft.setCursor(3 * GrapWidth -10, 0);
|
// tft.setCursor(3 * GrapWidth -10, 0);
|
||||||
if (HeightYellow > 28){
|
// if (HeightYellow > 28){
|
||||||
tft.setTextColor(BLACK);
|
// tft.setTextColor(BLACK);
|
||||||
}else {
|
// }else {
|
||||||
tft.setTextColor(WHITE);
|
// tft.setTextColor(WHITE);
|
||||||
}
|
// }
|
||||||
tft.println("Y");
|
// tft.println("Y");
|
||||||
tft.setCursor(4 * GrapWidth -10, 0);
|
// tft.setCursor(4 * GrapWidth -10, 0);
|
||||||
if (HeightGreen > 28){
|
// if (HeightGreen > 28){
|
||||||
tft.setTextColor(BLACK);
|
// tft.setTextColor(BLACK);
|
||||||
}else {
|
// }else {
|
||||||
tft.setTextColor(WHITE);
|
// tft.setTextColor(WHITE);
|
||||||
}
|
// }
|
||||||
tft.println("G");
|
// tft.println("G");
|
||||||
tft.setCursor(5 * GrapWidth -10, 0);
|
// tft.setCursor(5 * GrapWidth -10, 0);
|
||||||
if (HeightBlue > 28){
|
// if (HeightBlue > 28){
|
||||||
tft.setTextColor(BLACK);
|
// tft.setTextColor(BLACK);
|
||||||
}else {
|
// }else {
|
||||||
tft.setTextColor(WHITE);
|
// tft.setTextColor(WHITE);
|
||||||
}
|
// }
|
||||||
tft.println("B");
|
// tft.println("B");
|
||||||
|
|
||||||
tft.setCursor(6 * GrapWidth -10, 0);
|
// tft.setCursor(6 * GrapWidth -10, 0);
|
||||||
if (HeightViolet > 28){
|
// if (HeightViolet > 28){
|
||||||
tft.setTextColor(BLACK);
|
// tft.setTextColor(BLACK);
|
||||||
}else {
|
// }else {
|
||||||
tft.setTextColor(WHITE);
|
// tft.setTextColor(WHITE);
|
||||||
}
|
// }
|
||||||
tft.println("V");
|
// tft.println("V");
|
||||||
|
|
||||||
maxValue = 0.0;
|
// maxValue = 0.0;
|
||||||
}
|
// }
|
||||||
delay(1000);
|
delay(100);
|
||||||
|
|
||||||
if (menu_number > 4 ) {
|
if (menu_number > 4 ) {
|
||||||
LedPower = 1;
|
LedPower = 1;
|
||||||
@@ -453,25 +399,25 @@ void loop() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
//data haverest
|
// //data haverest
|
||||||
RawRed = sensor.getRed();
|
// RawRed = sensor.getRed();
|
||||||
RawOrange = sensor.getOrange();
|
// RawOrange = sensor.getOrange();
|
||||||
RawYellow = sensor.getYellow();
|
// RawYellow = sensor.getYellow();
|
||||||
RawGreen = sensor.getGreen();
|
// RawGreen = sensor.getGreen();
|
||||||
RawBlue = sensor.getBlue();
|
// RawBlue = sensor.getBlue();
|
||||||
RawViolet = sensor.getViolet();
|
// RawViolet = sensor.getViolet();
|
||||||
|
|
||||||
CalcRed = sensor.getCalibratedRed();
|
// CalcRed = sensor.getCalibratedRed();
|
||||||
CalcOrange = sensor.getCalibratedOrange();
|
// CalcOrange = sensor.getCalibratedOrange();
|
||||||
CalcYellow = sensor.getCalibratedYellow();
|
// CalcYellow = sensor.getCalibratedYellow();
|
||||||
CalcGreen = sensor.getCalibratedGreen();
|
// CalcGreen = sensor.getCalibratedGreen();
|
||||||
CalcBlue = sensor.getCalibratedBlue();
|
// CalcBlue = sensor.getCalibratedBlue();
|
||||||
CalcViolet = sensor.getCalibratedViolet();
|
// CalcViolet = sensor.getCalibratedViolet();
|
||||||
|
|
||||||
ReadValues[0] = CalcRed;
|
// ReadValues[0] = CalcRed;
|
||||||
ReadValues[1] = CalcOrange;
|
// ReadValues[1] = CalcOrange;
|
||||||
ReadValues[2] = CalcYellow;
|
// ReadValues[2] = CalcYellow;
|
||||||
ReadValues[3] = CalcGreen;
|
// ReadValues[3] = CalcGreen;
|
||||||
ReadValues[4] = CalcBlue;
|
// ReadValues[4] = CalcBlue;
|
||||||
ReadValues[5] = CalcViolet;
|
// ReadValues[5] = CalcViolet;
|
||||||
}
|
}
|
||||||
|
|||||||
22
ESP32/RgbSpectralSensor/User_Setup.h
Normal file
22
ESP32/RgbSpectralSensor/User_Setup.h
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
#define ST7735_DRIVER // sterownik ekranu
|
||||||
|
|
||||||
|
#define TFT_WIDTH 128
|
||||||
|
#define TFT_HEIGHT 160
|
||||||
|
|
||||||
|
#define TFT_RGB_ORDER TFT_RGB // jeśli kolory są dziwne, zamień na TFT_BGR
|
||||||
|
|
||||||
|
#define TFT_CS 5
|
||||||
|
#define TFT_RST 4
|
||||||
|
#define TFT_DC 2
|
||||||
|
|
||||||
|
#define TFT_MOSI 23
|
||||||
|
#define TFT_SCLK 18
|
||||||
|
|
||||||
|
#define LOAD_GLCD // domyślna czcionka 1
|
||||||
|
#define LOAD_FONT2 // mała czcionka
|
||||||
|
#define LOAD_FONT4 // średnia czcionka
|
||||||
|
#define LOAD_FONT6 // duża czcionka cyfrowa
|
||||||
|
#define LOAD_FONT7
|
||||||
|
#define LOAD_FONT8
|
||||||
|
|
||||||
|
#define SPI_FREQUENCY 27000000 // bezpieczna prędkość
|
||||||
Reference in New Issue
Block a user