Menu: menu - pierwsza strona
This commit is contained in:
@@ -53,7 +53,11 @@ Adafruit_SSD1306 display(4);
|
||||
int HeightViolet = 0;
|
||||
|
||||
byte gain = 3; // values: 0,1,2,3
|
||||
int menu_number = 3; // values:0 menu 1,2,3 bez led, 4,5,6 z LED
|
||||
float gainValue = 64;
|
||||
|
||||
|
||||
int menu_number = 0; // values:0 menu 1,2,3 bez led, 4,5,6 z LED
|
||||
|
||||
|
||||
int LedPower = 0;
|
||||
int GraphHeight = 32;
|
||||
@@ -62,25 +66,19 @@ Adafruit_SSD1306 display(4);
|
||||
float maxValue = 0.0;
|
||||
|
||||
void setup() {
|
||||
//DIPLAY settings
|
||||
// if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
|
||||
// Serial.println(F("SSD1306 allocation failed"));
|
||||
// for (;;); // Don't proceed, loop forever
|
||||
// }
|
||||
// display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS);
|
||||
// display.clearDisplay();
|
||||
// display.setTextColor(WHITE);
|
||||
// display.setRotation(0);
|
||||
// display.setTextSize(3);
|
||||
// display.setCursor(0, 0);
|
||||
// display.println("Version:");
|
||||
// display.setCursor(0, 25);
|
||||
// display.println(Version);
|
||||
// display.display();
|
||||
// delay(500);
|
||||
Wire.begin();
|
||||
Serial.begin(115200);
|
||||
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
|
||||
display.clearDisplay();
|
||||
display.setTextSize(1);
|
||||
display.setTextColor(WHITE);
|
||||
display.setCursor(0, 0);
|
||||
display.println("Version:");
|
||||
display.setCursor(0, 10);
|
||||
display.println(Version);
|
||||
display.display();
|
||||
delay(1500);
|
||||
// Wire.begin();
|
||||
// Serial.begin(115200);
|
||||
|
||||
display.clearDisplay();
|
||||
sensor.begin();
|
||||
pinMode(Btn1, INPUT_PULLUP);
|
||||
@@ -91,13 +89,18 @@ void loop() {
|
||||
display.clearDisplay();
|
||||
display.setTextSize(1);
|
||||
display.setTextColor(WHITE);
|
||||
//data haverest
|
||||
sensor.setGain(gain);
|
||||
if (menu_number > 3 ){
|
||||
|
||||
//rotation 0 default, pod wyswitlanie grafów
|
||||
//roration 1 -tego nie, wyswietlacz pionowy w zla strone
|
||||
//roation 2 -tego nie do gory nogami
|
||||
//rotation 3 pod wyswietlanie listy wartosci
|
||||
|
||||
|
||||
// data haverest
|
||||
if (menu_number > 4 ){
|
||||
LedPower = 1;
|
||||
} else {
|
||||
LedPower = 0;
|
||||
|
||||
}
|
||||
|
||||
if (LedPower == 1) {
|
||||
@@ -128,184 +131,226 @@ void loop() {
|
||||
ReadValues[3] = CalcGreen;
|
||||
ReadValues[4] = CalcBlue;
|
||||
ReadValues[5] = CalcViolet;
|
||||
|
||||
//testowa linia
|
||||
//void drawLine(64, 32, 1, 32, uint16_t color);
|
||||
//
|
||||
////testowa linia
|
||||
////void drawLine(64, 32, 1, 32, uint16_t color);
|
||||
//
|
||||
////linia 2 pix per 1 gin suma: 12 pix
|
||||
////linia 3 linia 5pix dla led+kropka kolo niej 6 pix
|
||||
//
|
||||
|
||||
//linia 2 pix per 1 gin suma: 12 pix
|
||||
//linia 3 linia 5pix dla led+kropka kolo niej 6 pix
|
||||
if (digitalRead(Btn1) == 0){
|
||||
if (gain < 3){
|
||||
gain = gain+1;
|
||||
sensor.setGain(gain);
|
||||
|
||||
if (menu_number == 0 ) {//pokaż menu konfiguracyjne
|
||||
display.setRotation(1);
|
||||
} else {
|
||||
gain = 0;
|
||||
sensor.setGain(gain);
|
||||
}
|
||||
}
|
||||
|
||||
if (gain == 0 ){
|
||||
gainValue = 1;
|
||||
}else if (gain == 1) {
|
||||
gainValue = 3.7;
|
||||
}else if (gain == 2){
|
||||
gainValue = 16;
|
||||
}else {
|
||||
gainValue = 64;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (digitalRead(Btn2) == 0){
|
||||
if (menu_number < 8){
|
||||
menu_number = menu_number+1;
|
||||
} else {
|
||||
menu_number = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (menu_number == 0 || 1==1 ) {//pokaż menu konfiguracyjne
|
||||
display.clearDisplay();
|
||||
display.setRotation(0);
|
||||
display.setCursor(0, 0);
|
||||
display.println("GAIN:");
|
||||
display.setCursor(0, 10);
|
||||
display.println(gain);
|
||||
display.println("GAIN");
|
||||
display.setCursor(3, 8);
|
||||
display.println(gainValue,1);
|
||||
|
||||
display.setCursor(30, 0);
|
||||
display.println("LED:");
|
||||
display.setCursor(30,10);
|
||||
display.setCursor(32, 0);
|
||||
display.println("LED");
|
||||
display.setCursor(33,8);
|
||||
display.println(LedPower);
|
||||
|
||||
display.setCursor(40, 0);
|
||||
display.println("BTN1:");
|
||||
display.setCursor(40, 10);
|
||||
display.setCursor(60, 0);
|
||||
display.println("BTN1");
|
||||
display.setCursor(63, 8);
|
||||
display.println(digitalRead(Btn1));
|
||||
|
||||
display.setCursor(50, 0);
|
||||
display.println("BTN2:");
|
||||
display.setCursor(50, 10);
|
||||
display.setCursor(90, 0);
|
||||
display.println("BTN2");
|
||||
display.setCursor(93, 8);
|
||||
display.println(digitalRead(Btn2));
|
||||
|
||||
display.setCursor(110, 8);
|
||||
display.println(menu_number);
|
||||
|
||||
//
|
||||
//display.fillCircle(75, 10, 10, SSD1306_WHITE);
|
||||
|
||||
display.setCursor(0,20);
|
||||
display.println("menu, calculated, raw, relative graph, calc graph");
|
||||
display.setCursor(0,16);
|
||||
display.println("menu; calc; raw");
|
||||
display.setCursor(0,24);
|
||||
display.println("rltive grph;calc grph");
|
||||
|
||||
}
|
||||
|
||||
if (menu_number == 1 || menu_number == 4 ) {//pokaż wartości przeliczone
|
||||
display.setRotation(2);
|
||||
|
||||
display.setCursor(GrapWidth, 0);
|
||||
display.println("R:");
|
||||
display.setCursor(GrapWidth, 10);
|
||||
display.println(CalcRed, 1);
|
||||
|
||||
display.setCursor(GrapWidth * 2, 0);
|
||||
display.println("O:");
|
||||
display.setCursor(GrapWidth * 2, 10);
|
||||
display.println(CalcOrange, 1);
|
||||
|
||||
display.setCursor(GrapWidth * 3,0);
|
||||
display.println("Y:");
|
||||
display.setCursor(GrapWidth * 3, 10);
|
||||
display.println(CalcYellow, 1);
|
||||
|
||||
display.setCursor(GrapWidth * 4, 0);
|
||||
display.println("G:");
|
||||
display.setCursor(GrapWidth * 4, 10);
|
||||
display.println(CalcGreen, 1);
|
||||
|
||||
display.setCursor(GrapWidth * 5, 0);
|
||||
display.println("B:");
|
||||
display.setCursor(GrapWidth * 5, 20);
|
||||
display.println(CalcBlue, 1);
|
||||
|
||||
display.setCursor(GrapWidth * 6, 0);
|
||||
display.println("V:");
|
||||
display.setCursor(GrapWidth * 6, 10);
|
||||
display.println(CalcViolet, 1);
|
||||
}
|
||||
display.setRotation(1);
|
||||
|
||||
if (menu_number == 2 || menu_number == 5) { //pokaż wartości bezpośrednie
|
||||
display.setRotation(2);
|
||||
|
||||
display.setCursor(GrapWidth, 0);
|
||||
display.println("rR:");
|
||||
display.setCursor(GrapWidth, 10);
|
||||
display.println(RawRed, 1);
|
||||
|
||||
display.setCursor(GrapWidth * 2, 0);
|
||||
display.println("rO:");
|
||||
display.setCursor(GrapWidth * 2, 10);
|
||||
display.println(RawOrange, 1);
|
||||
|
||||
display.setCursor(GrapWidth * 3, 0);
|
||||
display.println("rY:");
|
||||
display.setCursor(GrapWidth * 3, 10);
|
||||
display.println(RawYellow, 1);
|
||||
display.setCursor(0, 20);
|
||||
|
||||
display.setCursor(GrapWidth * 4, 0);
|
||||
display.println("rG:");
|
||||
display.setCursor(GrapWidth * 4, 10);
|
||||
display.println(RawGreen, 1);
|
||||
|
||||
display.setCursor(GrapWidth * 5, 0);
|
||||
display.println("rB:");
|
||||
display.setCursor(GrapWidth * 5, 10);
|
||||
display.println(RawBlue, 1);
|
||||
|
||||
display.setCursor(GrapWidth * 6, 0);
|
||||
display.println("rV:");
|
||||
display.setCursor(GrapWidth * 6, 10);
|
||||
display.println(RawYellow, 1);
|
||||
}
|
||||
display.setRotation(1);
|
||||
|
||||
if (menu_number == 3 || menu_number == 6 ){ //pokaż grafy
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
maxValue = max(maxValue, ReadValues[i]);
|
||||
}
|
||||
HeightRed = int((CalcRed / maxValue) * GraphHeight);
|
||||
HeightOrange = int((CalcOrange / maxValue) * GraphHeight);
|
||||
HeightYellow = int((CalcYellow / maxValue) * GraphHeight);
|
||||
HeightGreen = int((CalcGreen / maxValue) * GraphHeight);
|
||||
HeightBlue = int((CalcBlue / maxValue) * GraphHeight);
|
||||
HeightViolet = int((CalcViolet / maxValue) * GraphHeight);
|
||||
|
||||
|
||||
display.setCursor(1 * GrapWidth -10, 10);
|
||||
if (HeightRed >25){
|
||||
display.setTextColor(BLACK);
|
||||
}
|
||||
|
||||
display.fillRect(0 * GrapWidth, GraphHeight - HeightRed, GrapWidth, HeightRed, SSD1306_WHITE);
|
||||
display.fillRect(1 * GrapWidth + 1, GraphHeight - HeightOrange, GrapWidth, HeightOrange, SSD1306_WHITE);
|
||||
display.fillRect(2 * GrapWidth + 2, GraphHeight - HeightYellow, GrapWidth, HeightYellow, SSD1306_WHITE);
|
||||
display.fillRect(3 * GrapWidth + 3, GraphHeight - HeightGreen, GrapWidth, HeightGreen, SSD1306_WHITE);
|
||||
display.fillRect(4 * GrapWidth + 4, GraphHeight - HeightBlue, GrapWidth, HeightBlue, SSD1306_WHITE);
|
||||
display.fillRect(5 * GrapWidth + 5, GraphHeight - HeightViolet, GrapWidth, HeightViolet, SSD1306_WHITE);
|
||||
display.setCursor(1 * GrapWidth -10, 0);
|
||||
if (HeightRed > 28){
|
||||
display.setTextColor(BLACK);
|
||||
}else {
|
||||
display.setTextColor(WHITE);
|
||||
}
|
||||
display.println("R:");
|
||||
display.setCursor(2 * GrapWidth -10, 0);
|
||||
if (HeightOrange > 28){
|
||||
display.setTextColor(BLACK);
|
||||
}else {
|
||||
display.setTextColor(WHITE);
|
||||
}
|
||||
display.println("O:");
|
||||
display.setCursor(3 * GrapWidth -10, 0);
|
||||
if (HeightYellow > 28){
|
||||
display.setTextColor(BLACK);
|
||||
}else {
|
||||
display.setTextColor(WHITE);
|
||||
}
|
||||
display.println("Y:");
|
||||
display.setCursor(4 * GrapWidth -10, 0);
|
||||
if (HeightGreen > 28){
|
||||
display.setTextColor(BLACK);
|
||||
}else {
|
||||
display.setTextColor(WHITE);
|
||||
}
|
||||
display.println("G:");
|
||||
display.setCursor(5 * GrapWidth -10, 0);
|
||||
if (HeightBlue > 28){
|
||||
display.setTextColor(BLACK);
|
||||
}else {
|
||||
display.setTextColor(WHITE);
|
||||
}
|
||||
display.println("B:");
|
||||
display.setCursor(6 * GrapWidth -10, 0);
|
||||
if (HeightViolet > 28){
|
||||
display.setTextColor(BLACK);
|
||||
}else {
|
||||
display.setTextColor(WHITE);
|
||||
}
|
||||
display.println("V:");
|
||||
|
||||
maxValue = 0.0;
|
||||
}
|
||||
|
||||
//
|
||||
// if (menu_number == 1 || menu_number == 4 ) {//pokaż wartości przeliczone
|
||||
//// display.setRotation(2);
|
||||
//
|
||||
// display.setCursor(GrapWidth, 0);
|
||||
// display.println("R:");
|
||||
// display.setCursor(GrapWidth, 10);
|
||||
// display.println(CalcRed, 1);
|
||||
//
|
||||
// display.setCursor(GrapWidth * 2, 0);
|
||||
// display.println("O:");
|
||||
// display.setCursor(GrapWidth * 2, 10);
|
||||
// display.println(CalcOrange, 1);
|
||||
//
|
||||
// display.setCursor(GrapWidth * 3,0);
|
||||
// display.println("Y:");
|
||||
// display.setCursor(GrapWidth * 3, 10);
|
||||
// display.println(CalcYellow, 1);
|
||||
//
|
||||
// display.setCursor(GrapWidth * 4, 0);
|
||||
// display.println("G:");
|
||||
// display.setCursor(GrapWidth * 4, 10);
|
||||
// display.println(CalcGreen, 1);
|
||||
//
|
||||
// display.setCursor(GrapWidth * 5, 0);
|
||||
// display.println("B:");
|
||||
// display.setCursor(GrapWidth * 5, 20);
|
||||
// display.println(CalcBlue, 1);
|
||||
//
|
||||
// display.setCursor(GrapWidth * 6, 0);
|
||||
// display.println("V:");
|
||||
// display.setCursor(GrapWidth * 6, 10);
|
||||
// display.println(CalcViolet, 1);
|
||||
// }
|
||||
//// display.setRotation(1);
|
||||
//
|
||||
// if (menu_number == 2 || menu_number == 5) { //pokaż wartości bezpośrednie
|
||||
//// display.setRotation(2);
|
||||
//
|
||||
// display.setCursor(GrapWidth, 0);
|
||||
// display.println("rR:");
|
||||
// display.setCursor(GrapWidth, 10);
|
||||
// display.println(RawRed, 1);
|
||||
//
|
||||
// display.setCursor(GrapWidth * 2, 0);
|
||||
// display.println("rO:");
|
||||
// display.setCursor(GrapWidth * 2, 10);
|
||||
// display.println(RawOrange, 1);
|
||||
//
|
||||
// display.setCursor(GrapWidth * 3, 0);
|
||||
// display.println("rY:");
|
||||
// display.setCursor(GrapWidth * 3, 10);
|
||||
// display.println(RawYellow, 1);
|
||||
// display.setCursor(0, 20);
|
||||
//
|
||||
// display.setCursor(GrapWidth * 4, 0);
|
||||
// display.println("rG:");
|
||||
// display.setCursor(GrapWidth * 4, 10);
|
||||
// display.println(RawGreen, 1);
|
||||
//
|
||||
// display.setCursor(GrapWidth * 5, 0);
|
||||
// display.println("rB:");
|
||||
// display.setCursor(GrapWidth * 5, 10);
|
||||
// display.println(RawBlue, 1);
|
||||
//
|
||||
// display.setCursor(GrapWidth * 6, 0);
|
||||
// display.println("rV:");
|
||||
// display.setCursor(GrapWidth * 6, 10);
|
||||
// display.println(RawYellow, 1);
|
||||
// }
|
||||
//// display.setRotation(0);
|
||||
//
|
||||
// if (menu_number == 3 || menu_number == 6 ){ //pokaż grafy
|
||||
//// display.setRotation(0);
|
||||
//
|
||||
// for (int i = 0; i < 5; i++) {
|
||||
// maxValue = max(maxValue, ReadValues[i]);
|
||||
// }
|
||||
// HeightRed = int((CalcRed / maxValue) * GraphHeight);
|
||||
// HeightOrange = int((CalcOrange / maxValue) * GraphHeight);
|
||||
// HeightYellow = int((CalcYellow / maxValue) * GraphHeight);
|
||||
// HeightGreen = int((CalcGreen / maxValue) * GraphHeight);
|
||||
// HeightBlue = int((CalcBlue / maxValue) * GraphHeight);
|
||||
// HeightViolet = int((CalcViolet / maxValue) * GraphHeight);
|
||||
//
|
||||
//
|
||||
// display.setCursor(1 * GrapWidth -10, 10);
|
||||
// if (HeightRed >25){
|
||||
// display.setTextColor(BLACK);
|
||||
// }
|
||||
//
|
||||
// display.fillRect(0 * GrapWidth, GraphHeight - HeightRed, GrapWidth, HeightRed, SSD1306_WHITE);
|
||||
// display.fillRect(1 * GrapWidth + 1, GraphHeight - HeightOrange, GrapWidth, HeightOrange, SSD1306_WHITE);
|
||||
// display.fillRect(2 * GrapWidth + 2, GraphHeight - HeightYellow, GrapWidth, HeightYellow, SSD1306_WHITE);
|
||||
// display.fillRect(3 * GrapWidth + 3, GraphHeight - HeightGreen, GrapWidth, HeightGreen, SSD1306_WHITE);
|
||||
// display.fillRect(4 * GrapWidth + 4, GraphHeight - HeightBlue, GrapWidth, HeightBlue, SSD1306_WHITE);
|
||||
// display.fillRect(5 * GrapWidth + 5, GraphHeight - HeightViolet, GrapWidth, HeightViolet, SSD1306_WHITE);
|
||||
// display.setCursor(1 * GrapWidth -10, 0);
|
||||
// if (HeightRed > 28){
|
||||
// display.setTextColor(BLACK);
|
||||
// }else {
|
||||
// display.setTextColor(WHITE);
|
||||
// }
|
||||
// display.println("R:");
|
||||
// display.setCursor(2 * GrapWidth -10, 0);
|
||||
// if (HeightOrange > 28){
|
||||
// display.setTextColor(BLACK);
|
||||
// }else {
|
||||
// display.setTextColor(WHITE);
|
||||
// }
|
||||
// display.println("O:");
|
||||
// display.setCursor(3 * GrapWidth -10, 0);
|
||||
// if (HeightYellow > 28){
|
||||
// display.setTextColor(BLACK);
|
||||
// }else {
|
||||
// display.setTextColor(WHITE);
|
||||
// }
|
||||
// display.println("Y:");
|
||||
// display.setCursor(4 * GrapWidth -10, 0);
|
||||
// if (HeightGreen > 28){
|
||||
// display.setTextColor(BLACK);
|
||||
// }else {
|
||||
// display.setTextColor(WHITE);
|
||||
// }
|
||||
// display.println("G:");
|
||||
// display.setCursor(5 * GrapWidth -10, 0);
|
||||
// if (HeightBlue > 28){
|
||||
// display.setTextColor(BLACK);
|
||||
// }else {
|
||||
// display.setTextColor(WHITE);
|
||||
// }
|
||||
// display.println("B:");
|
||||
// display.setCursor(6 * GrapWidth -10, 0);
|
||||
// if (HeightViolet > 28){
|
||||
// display.setTextColor(BLACK);
|
||||
// }else {
|
||||
// display.setTextColor(WHITE);
|
||||
// }
|
||||
// display.println("V:");
|
||||
//
|
||||
// maxValue = 0.0;
|
||||
// }
|
||||
//
|
||||
display.display();
|
||||
delay(1000);
|
||||
delay(50);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user