Poprawa przycisków
Przebudowa wykresy calc values ogólne poprawki
This commit is contained in:
@@ -11,7 +11,7 @@ TFT_eSPI tft = TFT_eSPI(); // domyślna konfiguracja z User_Setup.h
|
|||||||
// obsługa przycisków zmieniających menu i LED
|
// obsługa przycisków zmieniających menu i LED
|
||||||
//160x128
|
//160x128
|
||||||
|
|
||||||
#define Version "0.0.1"
|
#define Version "0.1.0"
|
||||||
#include <SPI.h>
|
#include <SPI.h>
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
#include <Adafruit_GFX.h>
|
#include <Adafruit_GFX.h>
|
||||||
@@ -20,9 +20,9 @@ TFT_eSPI tft = TFT_eSPI(); // domyślna konfiguracja z User_Setup.h
|
|||||||
// #define TFT_RST 4
|
// #define TFT_RST 4
|
||||||
// #define TFT_DC 2
|
// #define TFT_DC 2
|
||||||
|
|
||||||
#define Btn1 33 //on board: A1 menu
|
#define Btn1 33 //on board: D33 gain
|
||||||
#define Btn2 34 //on board: A2 gain
|
#define Btn2 34 //on board: D34 menu
|
||||||
#define Btn3 35 //on board: A3 ???
|
#define Btn3 35 //on board: D35 LED
|
||||||
|
|
||||||
#define WHITE 0xFFFF
|
#define WHITE 0xFFFF
|
||||||
#define BLACK 0x0000
|
#define BLACK 0x0000
|
||||||
@@ -37,6 +37,7 @@ TFT_eSPI tft = TFT_eSPI(); // domyślna konfiguracja z User_Setup.h
|
|||||||
#define BLUE 0x001F
|
#define BLUE 0x001F
|
||||||
#define MAGENTA 0xF81F
|
#define MAGENTA 0xF81F
|
||||||
#define PINK 0xF8FF
|
#define PINK 0xF8FF
|
||||||
|
#define SPACE_4_TEXT 20
|
||||||
//#define ST7735 NEW 0xD500FF
|
//#define ST7735 NEW 0xD500FF
|
||||||
|
|
||||||
|
|
||||||
@@ -64,12 +65,17 @@ int HeightBlue = 0;
|
|||||||
int HeightViolet = 0;
|
int HeightViolet = 0;
|
||||||
|
|
||||||
byte gain = 3; // values: 0,1,2,3
|
byte gain = 3; // values: 0,1,2,3
|
||||||
|
byte old_gain = 3; // values: 0,1,2,3
|
||||||
float gainValue = 64;
|
float gainValue = 64;
|
||||||
int menu_number = 0; // values:0 menu 1,2,3 bez led, 4,5,6 z LED
|
int menu_number = 0; // values:0 menu 1,2,3
|
||||||
|
int old_menu_number = 0; // values:0 menu 1,2,3
|
||||||
int LedPower = 0;
|
int LedPower = 0;
|
||||||
int GraphHeight = 128;
|
int GraphHeight = 128;
|
||||||
int GrapWidth = 25;
|
int GrapWidth = 25;
|
||||||
float ReadValues[6] = {0, 0, 0, 0, 0, 0};
|
float ReadCalcValues[6] = {0, 0, 0, 0, 0, 0};
|
||||||
|
float ReadRawValues[6] = {0, 0, 0, 0, 0, 0};
|
||||||
|
int CalcHeights[6] = {0, 0, 0, 0, 0, 0};
|
||||||
|
int minHeight = 0 ;
|
||||||
float maxValue = 0.0;
|
float maxValue = 0.0;
|
||||||
float minValue = 0.0;
|
float minValue = 0.0;
|
||||||
float test_vle = 1.0;
|
float test_vle = 1.0;
|
||||||
@@ -78,10 +84,6 @@ char ChValue[20];
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
tft.init();
|
tft.init();
|
||||||
tft.setRotation(1);
|
tft.setRotation(1);
|
||||||
@@ -95,90 +97,62 @@ void setup() {
|
|||||||
sensor.begin();
|
sensor.begin();
|
||||||
pinMode(Btn1, INPUT);
|
pinMode(Btn1, INPUT);
|
||||||
pinMode(Btn2, INPUT);
|
pinMode(Btn2, INPUT);
|
||||||
|
pinMode(Btn3, INPUT);
|
||||||
|
|
||||||
tft.fillRect(0, 0, 240, 240, TFT_BLACK);
|
tft.fillRect(0, 0, 240, 240, TFT_BLACK);
|
||||||
|
|
||||||
}
|
}
|
||||||
void drawControls() {
|
|
||||||
// tft.fillRect(0, 0, 240, 240, TFT_BLACK);
|
|
||||||
|
|
||||||
// ////tft.setRotation(0);
|
|
||||||
// linia pozycyjna LED
|
|
||||||
tft.drawPixel(127, 24, WHITE);
|
|
||||||
if (LedPower == 1) {
|
|
||||||
tft.drawLine(127, 26, 127, 31, WHITE);
|
|
||||||
}
|
|
||||||
//gain:
|
|
||||||
tft.drawPixel(127, 0, WHITE);
|
|
||||||
if (gain >= 1) {
|
|
||||||
tft.drawPixel(127, 2, WHITE);
|
|
||||||
}
|
|
||||||
if (gain >= 2) {
|
|
||||||
tft.drawPixel(127, 4, WHITE);
|
|
||||||
}
|
|
||||||
if (gain >= 3) {
|
|
||||||
tft.drawPixel(127, 6, WHITE);
|
|
||||||
}
|
|
||||||
// menu
|
|
||||||
if (menu_number >= 1 ) {
|
|
||||||
tft.drawPixel(127, 10, WHITE);
|
|
||||||
}
|
|
||||||
if ((menu_number >= 2 && menu_number < 5 ) || menu_number >= 6 ) {
|
|
||||||
tft.drawPixel(127, 12, WHITE);
|
|
||||||
}
|
|
||||||
if ((menu_number >= 3 && menu_number < 5) || menu_number >= 7 ) {
|
|
||||||
tft.drawPixel(127, 14, WHITE);
|
|
||||||
}
|
|
||||||
if ((menu_number >= 4 && menu_number < 5 ) || menu_number >= 8 ) {
|
|
||||||
tft.drawPixel(127, 16, WHITE);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
|
||||||
|
if (digitalRead(Btn1) == HIGH){
|
||||||
|
setGain();
|
||||||
|
}
|
||||||
|
if (digitalRead(Btn2) == HIGH){
|
||||||
|
setMenu();
|
||||||
|
}
|
||||||
|
if (digitalRead(Btn3) == HIGH){
|
||||||
|
setLed();
|
||||||
|
}
|
||||||
|
|
||||||
tft.setTextSize(1);
|
tft.setTextSize(1);
|
||||||
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||||
|
if (old_menu_number != menu_number){
|
||||||
// // //TESTY
|
|
||||||
// tft.setTextColor(TFT_WHITE);
|
|
||||||
// tft.drawString("test",0, 0);
|
|
||||||
// tft.fillRect(0, 64 , 25, 64, TFT_RED);
|
|
||||||
// tft.fillRect(25, 64 , 25, 64, TFT_ORANGE);
|
|
||||||
// tft.fillRect(50, 64 , 25, 64, TFT_YELLOW);
|
|
||||||
// tft.fillRect(75, 64 , 25, 64, TFT_GREEN);
|
|
||||||
// tft.fillRect(100, 64 , 25, 64, TFT_BLUE);
|
|
||||||
// tft.fillRect(125, 64 , 25, 64, TFT_MAGENTA);
|
|
||||||
// tft.fillRect(150, 64 , 25, 64, TFT_WHITE);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//menu change
|
|
||||||
if (digitalRead(Btn2) == HIGH) {
|
|
||||||
tft.fillRect(0, 0, 240, 240, TFT_BLACK);
|
tft.fillRect(0, 0, 240, 240, TFT_BLACK);
|
||||||
if (menu_number < 8) {
|
old_menu_number = menu_number;
|
||||||
menu_number = menu_number + 1;
|
|
||||||
} else {
|
|
||||||
menu_number = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (old_gain != gain){
|
||||||
|
sensor.setGain(gain);
|
||||||
|
old_gain = gain;
|
||||||
|
}
|
||||||
|
|
||||||
if (menu_number == 0 ) {//show menu
|
if (menu_number == 0 ) {//show menu
|
||||||
tft.setTextSize(2);
|
tft.setTextSize(2);
|
||||||
tft.drawString("GAIN:" + String(gainValue),0, 0);
|
tft.drawString("GAIN:" + String(gainValue),0, 0);
|
||||||
tft.drawString("LED: 5-8",0, 16);
|
tft.drawString("LED:",0, 16);
|
||||||
|
if (LedPower == 1){
|
||||||
|
tft.drawString("ON ",45, 16);
|
||||||
|
} else {
|
||||||
|
tft.drawString("OFF ",45, 16);
|
||||||
|
}
|
||||||
tft.drawString("0:Menu",0, 32);
|
tft.drawString("0:Menu",0, 32);
|
||||||
tft.drawString("1:Calc.Values",0, 48);
|
tft.drawString("1:Calc.Values",0, 48);
|
||||||
tft.drawString("2:Raw",0, 64);
|
tft.drawString("2:Raw",0, 64);
|
||||||
tft.drawString("3:Rel. Graph",0, 80);
|
tft.drawString("3:Rel. Graph",0, 80);
|
||||||
tft.drawString("4:Calc. Graph",0, 96);
|
tft.drawString("4:Calc. Graph",0, 96);
|
||||||
drawControls();
|
|
||||||
|
|
||||||
delay(100);
|
|
||||||
}
|
}
|
||||||
// show calculated values
|
// show calculated values
|
||||||
if (menu_number == 1 || menu_number == 5 ) {//show calculated values
|
if (menu_number == 1 ) {//show calculated values
|
||||||
drawControls();
|
tft.drawString("1.Calc Values",0,0);
|
||||||
tft.drawString("Calculated Values",0,0);
|
tft.drawString("Gain: " + String(gainValue) + " LED: ", 0,10);
|
||||||
|
if (LedPower == 1){
|
||||||
|
tft.drawString("ON ",100, 10);
|
||||||
|
} else {
|
||||||
|
tft.drawString("OFF",100, 10);
|
||||||
|
}
|
||||||
tft.drawString("R:" + String(CalcRed),0, 20);
|
tft.drawString("R:" + String(CalcRed),0, 20);
|
||||||
tft.drawString("O:" + String(CalcOrange),0, 39);
|
tft.drawString("O:" + String(CalcOrange),0, 39);
|
||||||
tft.drawString("Y:" + String(CalcYellow),0, 58);
|
tft.drawString("Y:" + String(CalcYellow),0, 58);
|
||||||
@@ -188,8 +162,13 @@ void loop() {
|
|||||||
}
|
}
|
||||||
// //show raw values
|
// //show raw values
|
||||||
if (menu_number == 2 || menu_number == 6) {
|
if (menu_number == 2 || menu_number == 6) {
|
||||||
drawControls();
|
tft.drawString("2.Raw Values",0,0);
|
||||||
tft.drawString("Raw Values",0,0);
|
tft.drawString("Gain: " + String(gainValue) + " LED: ", 0,10);
|
||||||
|
if (LedPower == 1){
|
||||||
|
tft.drawString("ON ",100, 10);
|
||||||
|
} else {
|
||||||
|
tft.drawString("OFF",100, 10);
|
||||||
|
}
|
||||||
tft.drawString("R:" + String(RawRed),0, 20);
|
tft.drawString("R:" + String(RawRed),0, 20);
|
||||||
tft.drawString("O:" + String(RawOrange),0, 39);
|
tft.drawString("O:" + String(RawOrange),0, 39);
|
||||||
tft.drawString("Y:" + String(RawYellow),0, 58);
|
tft.drawString("Y:" + String(RawYellow),0, 58);
|
||||||
@@ -199,39 +178,52 @@ void loop() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
//show relative calculated values graph
|
//show relative calculated values graph
|
||||||
if (menu_number == 3 || menu_number == 7 ){
|
if (menu_number == 3){
|
||||||
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||||
|
|
||||||
maxValue = 0.0;
|
maxValue = 0.0;
|
||||||
minValue = 0.0;
|
minValue = 0.0;
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 6; i++) {
|
||||||
maxValue = max(maxValue, ReadValues[i]);
|
maxValue = max(maxValue, ReadCalcValues[i]);
|
||||||
}
|
}
|
||||||
HeightRed = int((CalcRed / maxValue) * GraphHeight);
|
for (int i = 0; i < 6; i++) {
|
||||||
HeightOrange = int((CalcOrange / maxValue) * GraphHeight);
|
minValue = min(minValue, ReadCalcValues[i]);
|
||||||
HeightYellow = int((CalcYellow / maxValue) * GraphHeight);
|
}
|
||||||
HeightGreen = int((CalcGreen / maxValue) * GraphHeight);
|
|
||||||
HeightBlue = int((CalcBlue / maxValue) * GraphHeight);
|
CalcHeights[0] = HeightRed;
|
||||||
HeightViolet = int((CalcViolet / maxValue) * GraphHeight);
|
CalcHeights[1] = HeightOrange;
|
||||||
for (int i = 0; i < 5; i++) {
|
CalcHeights[2] = HeightYellow;
|
||||||
maxValue = min(maxValue, ReadValues[i]);
|
CalcHeights[3] = HeightGreen;
|
||||||
|
CalcHeights[4] = HeightBlue;
|
||||||
|
CalcHeights[5] = HeightViolet;
|
||||||
|
for (int i = 0; i < 6; i++) {
|
||||||
|
minHeight = min(minHeight, CalcHeights[i]);
|
||||||
}
|
}
|
||||||
|
tft.fillRect(0, 20, 160, GraphHeight - minHeight- SPACE_4_TEXT, TFT_BLACK);
|
||||||
|
HeightRed = int((CalcRed / maxValue) * (GraphHeight - SPACE_4_TEXT));
|
||||||
|
HeightOrange = int((CalcOrange / maxValue) * (GraphHeight - SPACE_4_TEXT));
|
||||||
|
HeightYellow = int((CalcYellow / maxValue) * (GraphHeight - SPACE_4_TEXT));
|
||||||
|
HeightGreen = int((CalcGreen / maxValue) * (GraphHeight - SPACE_4_TEXT));
|
||||||
|
HeightBlue = int((CalcBlue / maxValue) * (GraphHeight - SPACE_4_TEXT));
|
||||||
|
HeightViolet = int((CalcViolet / maxValue) * (GraphHeight - SPACE_4_TEXT));
|
||||||
|
|
||||||
tft.fillRect(minValue, 0, 240, maxValue-minValue, TFT_BLACK);
|
|
||||||
drawControls();
|
|
||||||
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
|
||||||
tft.drawString("Relvative Calculated Values",0,0);
|
|
||||||
drawControls();
|
|
||||||
tft.fillRect(0 * GrapWidth, GraphHeight - HeightRed+8, GrapWidth, HeightRed, TFT_RED);
|
|
||||||
tft.fillRect(1 * GrapWidth + 1, GraphHeight - HeightOrange+8, GrapWidth, HeightOrange, TFT_ORANGE);
|
|
||||||
tft.fillRect(2 * GrapWidth + 2, GraphHeight - HeightYellow+8, GrapWidth, HeightYellow, TFT_YELLOW);
|
|
||||||
tft.fillRect(3 * GrapWidth + 3, GraphHeight - HeightGreen+8, GrapWidth, HeightGreen, TFT_GREEN);
|
|
||||||
tft.fillRect(4 * GrapWidth + 4, GraphHeight - HeightBlue+8, GrapWidth, HeightBlue, TFT_BLUE);
|
|
||||||
tft.fillRect(5 * GrapWidth + 5, GraphHeight - HeightViolet+8, GrapWidth, HeightViolet, TFT_MAGENTA);
|
|
||||||
tft.setCursor(1 * GrapWidth -10, 0);
|
|
||||||
|
|
||||||
|
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||||
|
tft.drawString("3.Relvative Calculated Values",0,0);
|
||||||
|
tft.drawString("Gain: " + String(gainValue) + " LED: ", 0,10);
|
||||||
|
if (LedPower == 1){
|
||||||
|
tft.drawString("ON ",100, 10);
|
||||||
|
} else {
|
||||||
|
tft.drawString("OFF",100, 10);
|
||||||
|
}
|
||||||
|
tft.fillRect(0 * GrapWidth, GraphHeight - HeightRed, GrapWidth, HeightRed, TFT_RED);
|
||||||
|
tft.fillRect(1 * GrapWidth + 1, GraphHeight - HeightOrange, GrapWidth, HeightOrange, TFT_ORANGE);
|
||||||
|
tft.fillRect(2 * GrapWidth + 2, GraphHeight - HeightYellow, GrapWidth, HeightYellow, TFT_YELLOW);
|
||||||
|
tft.fillRect(3 * GrapWidth + 3, GraphHeight - HeightGreen, GrapWidth, HeightGreen, TFT_GREEN);
|
||||||
|
tft.fillRect(4 * GrapWidth + 4, GraphHeight - HeightBlue, GrapWidth, HeightBlue, TFT_BLUE);
|
||||||
|
tft.fillRect(5 * GrapWidth + 5, GraphHeight - HeightViolet, GrapWidth, HeightViolet, TFT_MAGENTA);
|
||||||
|
|
||||||
|
// tft.setCursor(1 * GrapWidth -10, 0);
|
||||||
tft.setTextColor(TFT_BLACK, TFT_RED);
|
tft.setTextColor(TFT_BLACK, TFT_RED);
|
||||||
tft.drawString(" R:",1 * GrapWidth -20, 120);
|
tft.drawString(" R:",1 * GrapWidth -20, 120);
|
||||||
tft.setTextColor(TFT_BLACK, TFT_ORANGE);
|
tft.setTextColor(TFT_BLACK, TFT_ORANGE);
|
||||||
@@ -251,33 +243,39 @@ void loop() {
|
|||||||
|
|
||||||
|
|
||||||
// //show relative raw data graph
|
// //show relative raw data graph
|
||||||
if (menu_number == 4 || menu_number == 8 ){
|
if (menu_number == 4){
|
||||||
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||||
maxValue = 0.0;
|
maxValue = 0.0;
|
||||||
minValue = 0.0;
|
minValue = 0.0;
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
maxValue = max(maxValue, ReadValues[i]);
|
maxValue = max(maxValue, ReadRawValues[i]);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
minValue = min(minValue, ReadValues[i]);
|
minValue = min(minValue, ReadRawValues[i]);
|
||||||
}
|
}
|
||||||
HeightRed = int(((RawRed + abs(minValue)) / (maxValue + abs(minValue))) * GraphHeight);
|
|
||||||
HeightOrange = int(((RawOrange + abs(minValue)) / (maxValue + abs(minValue))) * GraphHeight);
|
|
||||||
HeightYellow = int(((RawYellow + abs(minValue)) / (maxValue + abs(minValue))) * GraphHeight);
|
|
||||||
HeightGreen = int(((RawGreen + abs(minValue)) / (maxValue + abs(minValue))) * GraphHeight);
|
|
||||||
HeightBlue = int(((RawBlue + abs(minValue)) / (maxValue + abs(minValue))) * GraphHeight);
|
|
||||||
HeightViolet = int(((RawViolet + abs(minValue)) / (maxValue + abs(minValue))) * GraphHeight);
|
|
||||||
tft.fillRect(minValue, 0, 240, maxValue-minValue, TFT_BLACK);
|
|
||||||
drawControls();
|
|
||||||
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
|
||||||
tft.drawString("Relvative Raw Values",0,0);
|
|
||||||
|
|
||||||
tft.fillRect(0 * GrapWidth, GraphHeight - HeightRed+8, GrapWidth, HeightRed, TFT_RED);
|
// HeightRed = int(((RawRed + abs(minValue)) / (maxValue + abs(minValue))) * GraphHeight);
|
||||||
tft.fillRect(1 * GrapWidth + 1, GraphHeight - HeightOrange+8, GrapWidth, HeightOrange, TFT_ORANGE);
|
// HeightOrange = int(((RawOrange + abs(minValue)) / (maxValue + abs(minValue))) * GraphHeight);
|
||||||
tft.fillRect(2 * GrapWidth + 2, GraphHeight - HeightYellow+8, GrapWidth, HeightYellow, TFT_YELLOW);
|
// HeightYellow = int(((RawYellow + abs(minValue)) / (maxValue + abs(minValue))) * GraphHeight);
|
||||||
tft.fillRect(3 * GrapWidth + 3, GraphHeight - HeightGreen+8, GrapWidth, HeightGreen, TFT_GREEN);
|
// HeightGreen = int(((RawGreen + abs(minValue)) / (maxValue + abs(minValue))) * GraphHeight);
|
||||||
tft.fillRect(4 * GrapWidth + 4, GraphHeight - HeightBlue+8, GrapWidth, HeightBlue, TFT_BLUE);
|
// HeightBlue = int(((RawBlue + abs(minValue)) / (maxValue + abs(minValue))) * GraphHeight);
|
||||||
tft.fillRect(5 * GrapWidth + 5, GraphHeight - HeightViolet+8, GrapWidth, HeightViolet, TFT_MAGENTA);
|
// HeightViolet = int(((RawViolet + abs(minValue)) / (maxValue + abs(minValue))) * GraphHeight);
|
||||||
|
tft.fillRect(minValue, 0, 240, maxValue-minValue, TFT_BLACK);
|
||||||
|
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||||
|
tft.drawString("4.Relvative Raw Values",0,0);
|
||||||
|
tft.drawString("Gain: " + String(gainValue) + " LED: ", 0,10);
|
||||||
|
if (LedPower == 1){
|
||||||
|
tft.drawString("ON ",100, 10);
|
||||||
|
} else {
|
||||||
|
tft.drawString("OFF",100, 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
tft.fillRect(0 * GrapWidth, GraphHeight - HeightRed, GrapWidth, HeightRed + SPACE_4_TEXT, TFT_RED);
|
||||||
|
tft.fillRect(1 * GrapWidth + 1, GraphHeight - HeightOrange, GrapWidth, HeightOrange + SPACE_4_TEXT, TFT_ORANGE);
|
||||||
|
tft.fillRect(2 * GrapWidth + 2, GraphHeight - HeightYellow, GrapWidth, HeightYellow + SPACE_4_TEXT, TFT_YELLOW);
|
||||||
|
tft.fillRect(3 * GrapWidth + 3, GraphHeight - HeightGreen, GrapWidth, HeightGreen + SPACE_4_TEXT, TFT_GREEN);
|
||||||
|
tft.fillRect(4 * GrapWidth + 4, GraphHeight - HeightBlue, GrapWidth, HeightBlue + SPACE_4_TEXT, TFT_BLUE);
|
||||||
|
tft.fillRect(5 * GrapWidth + 5, GraphHeight - HeightViolet, GrapWidth, HeightViolet + SPACE_4_TEXT, TFT_MAGENTA);
|
||||||
tft.setTextColor(TFT_BLACK, TFT_RED);
|
tft.setTextColor(TFT_BLACK, TFT_RED);
|
||||||
tft.drawString(" R:",1 * GrapWidth -20, 120);
|
tft.drawString(" R:",1 * GrapWidth -20, 120);
|
||||||
tft.setTextColor(TFT_BLACK, TFT_ORANGE);
|
tft.setTextColor(TFT_BLACK, TFT_ORANGE);
|
||||||
@@ -293,33 +291,7 @@ void loop() {
|
|||||||
maxValue = 0.0;
|
maxValue = 0.0;
|
||||||
minValue = 0.0;
|
minValue = 0.0;
|
||||||
}
|
}
|
||||||
delay(100);
|
|
||||||
|
|
||||||
if (menu_number > 4 ) {
|
|
||||||
LedPower = 1;
|
|
||||||
} else {
|
|
||||||
LedPower = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (LedPower == 1) {
|
|
||||||
sensor.enableBulb();
|
|
||||||
sensor.takeMeasurementsWithBulb();
|
|
||||||
} else {
|
|
||||||
sensor.disableBulb();
|
|
||||||
sensor.takeMeasurements();
|
|
||||||
}
|
|
||||||
|
|
||||||
//gain change
|
|
||||||
if (digitalRead(Btn1) == HIGH) {
|
|
||||||
if (gain < 3) {
|
|
||||||
gain = gain + 1;
|
|
||||||
sensor.setGain(gain);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
gain = 0;
|
|
||||||
sensor.setGain(gain);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gain == 0 ) {
|
if (gain == 0 ) {
|
||||||
gainValue = 1;
|
gainValue = 1;
|
||||||
@@ -331,27 +303,67 @@ void loop() {
|
|||||||
gainValue = 64;
|
gainValue = 64;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//data haverest
|
//data haverest
|
||||||
RawRed = sensor.getRed();
|
if (menu_number != 0){
|
||||||
RawOrange = sensor.getOrange();
|
if (LedPower == 1) {
|
||||||
RawYellow = sensor.getYellow();
|
sensor.enableBulb();
|
||||||
RawGreen = sensor.getGreen();
|
sensor.takeMeasurementsWithBulb();
|
||||||
RawBlue = sensor.getBlue();
|
} else {
|
||||||
RawViolet = sensor.getViolet();
|
sensor.disableBulb();
|
||||||
|
sensor.takeMeasurements();
|
||||||
|
}
|
||||||
|
|
||||||
CalcRed = sensor.getCalibratedRed();
|
RawRed = sensor.getRed();
|
||||||
CalcOrange = sensor.getCalibratedOrange();
|
RawOrange = sensor.getOrange();
|
||||||
CalcYellow = sensor.getCalibratedYellow();
|
RawYellow = sensor.getYellow();
|
||||||
CalcGreen = sensor.getCalibratedGreen();
|
RawGreen = sensor.getGreen();
|
||||||
CalcBlue = sensor.getCalibratedBlue();
|
RawBlue = sensor.getBlue();
|
||||||
CalcViolet = sensor.getCalibratedViolet();
|
RawViolet = sensor.getViolet();
|
||||||
|
|
||||||
|
CalcRed = sensor.getCalibratedRed();
|
||||||
|
CalcOrange = sensor.getCalibratedOrange();
|
||||||
|
CalcYellow = sensor.getCalibratedYellow();
|
||||||
|
CalcGreen = sensor.getCalibratedGreen();
|
||||||
|
CalcBlue = sensor.getCalibratedBlue();
|
||||||
|
CalcViolet = sensor.getCalibratedViolet();
|
||||||
|
|
||||||
|
ReadRawValues[0] = RawRed;
|
||||||
|
ReadRawValues[1] = RawOrange;
|
||||||
|
ReadRawValues[2] = RawYellow;
|
||||||
|
ReadRawValues[3] = RawGreen;
|
||||||
|
ReadRawValues[4] = RawBlue;
|
||||||
|
ReadRawValues[5] = RawViolet;
|
||||||
|
|
||||||
|
ReadCalcValues[0] = CalcRed;
|
||||||
|
ReadCalcValues[1] = CalcOrange;
|
||||||
|
ReadCalcValues[2] = CalcYellow;
|
||||||
|
ReadCalcValues[3] = CalcGreen;
|
||||||
|
ReadCalcValues[4] = CalcBlue;
|
||||||
|
ReadCalcValues[5] = CalcViolet;
|
||||||
|
} else {
|
||||||
|
delay(100);
|
||||||
|
}
|
||||||
|
|
||||||
ReadValues[0] = CalcRed;
|
|
||||||
ReadValues[1] = CalcOrange;
|
|
||||||
ReadValues[2] = CalcYellow;
|
|
||||||
ReadValues[3] = CalcGreen;
|
|
||||||
ReadValues[4] = CalcBlue;
|
|
||||||
ReadValues[5] = CalcViolet;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setLed() {
|
||||||
|
if (LedPower != 1 ) {
|
||||||
|
LedPower = 1;
|
||||||
|
} else {
|
||||||
|
LedPower = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void setMenu() {
|
||||||
|
if (menu_number < 4) {
|
||||||
|
menu_number = menu_number + 1;
|
||||||
|
} else {
|
||||||
|
menu_number = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void setGain() {
|
||||||
|
if (gain < 3) {
|
||||||
|
gain = gain + 1;
|
||||||
|
} else {
|
||||||
|
gain = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user