Developing Sensor Project - Log in window?
in
Contributed Library Questions
•
4 months ago
Hi friends! again with some troubles developing an interface for a personal project.
- ControlP5 cp5;
- controlP5.Button b1,b2,b3;
- //(Button A)
- controlP5.Range r1,r2,r3,r4;
- controlP5.Group g1;
- controlP5.Group g2;
- controlP5.Group g3;
- controlP5.Group g4;
- //(Button B)
- controlP5.Slider s1;
- controlP5.Knob k1;
- controlP5.Slider s2;
- controlP5.Slider s3;
- controlP5.Group g5;
- controlP5.Group g6;
- controlP5.Group g7;
- controlP5.Group g8;
- int w_barra = 37;
- int h,w;
- int k_x,k_y,c1,c2,f1,f2,g_w,g_h,r_x,r_y,t_x,t_y,h_size;
- void setup() {
- size(displayWidth, displayHeight);
- //define heights and positions
- h = (height - w_barra);
- w = width;
- c1 = 6*w/24; //Posicion columna izquierda en x
- c2 = 16*w/24; // '' columna derecha en x
- f1 = (h/2+w_barra)/2-w/12; // '' fila 1 en y
- f2 = (h/2+w_barra)+w/24; // '' fila 2 en y
- g_w = w/4; //Ancho de los grupos
- g_h = 5*w/24; //Alto de los grupos
- r_x = 55; r_y = g_h/2-w/48; t_x = 315; t_y = 40; h_size = 20;
- PImage[] imgs = {loadImage("botona.png"),loadImage("botonb.png"),loadImage("botonc.png")};
- cp5 = new ControlP5(this);
- // SETTING page
- g1 = makeGroup("Seteo de Temperatura", c1 , f1 , g_w , g_h , w_barra);
- g2 = makeGroup("Seteo de Humedad", c2 , f1 , g_w , g_h , w_barra);
- g3 = makeGroup("Seteo de Dioxido de Carbono", c1 , f2 , g_w , g_h , w_barra);
- g4 = makeGroup("Seteo de Luminosidad", c2 , f2 , g_w , g_h , w_barra);
- r1 = makeRange("Rango de Temperatura deseada", r_x , r_y , t_x , t_y , h_size , -55 , 150 , 55 , 55 , g1 );
- r2 = makeRange("Rango de Humedad deseada", r_x , r_y , t_x , t_y , h_size , 0 , 100 , 50 , 50 , g2 );
- r3 = makeRange("Rango de Dioxido de Carbono deseado", r_x , r_y , t_x , t_y , h_size , 350 , 10000 , 4825 , 4825 , g3 );
- r4 = makeRange("Rango de Luminosidad deseado", r_x , r_y , t_x , t_y , h_size , 0 , 40000 , 20000 , 20000 , g4);
- // SHOWING page
- g5 = makeGroup("Medicion de Temperatura", c1 , f1 , g_w , g_h , w_barra);
- g6 = makeGroup("Medicion de Humedad", c2 , f1 , g_w , g_h , w_barra);
- g7 = makeGroup("Medicion de Dioxido de Carbono", c1 , f2 , g_w , g_h , w_barra);
- g8 = makeGroup("Medicion de Luminosidad", c2 , f2 , g_w , g_h , w_barra);
- s1 = makeSlider("Temperatura", -55 , 150 , 0 , r_y , r_x , t_y , t_x , g5 , 0 , 0);
- s2 = makeSlider("Dioxido de Carbono", 350 , 10000 , 0 , r_x , r_y , t_x , t_y , g7 , -210 , -40);
- s3 = makeSlider("Luminosidad", 0 , 40000 , 0 , r_x , r_y , t_x , t_y , g8 , -210 , -40);
- k1 = cp5.addKnob("Humedad", 0 , 100 , 0 , r_x , r_y , 200)
- .setGroup(g6)
- .setDragDirection(Knob.VERTICAL);
- // Control pannel button
- b1 = makeButton("colorA", 0 , w_barra , displayWidth/6 , h/3 , 0 , imgs ); //Menu seteo de valores
- b2 = makeButton("colorB", 0 , w_barra+h/3 , displayWidth/6 , h/3 , 0 , imgs ); //Menu muestra valores
- b3 = makeButton("colorC", 0, w_barra+2*h/3 , displayWidth/6, h/3 , 0 , imgs ); //Menu grafica valores
- }
- void draw() {
- background(0);
- fill(255);
- rect(0,0,displayWidth,w_barra);
- String f = getFechaActual();
- String h = getHoraActual();
- fill(0);
- text("Día del sistema: " + f,19*w/24,0.35*w_barra);
- text("Hora del sistema: " + h,19*w/24,0.8*w_barra);
- textAlign(CENTER, LEFT);
- }
- void controlEvent(ControlEvent theEvent) {
- if (theEvent.isController()) {
- if (theEvent.controller().name() == "colorA") {
- g1.show(); g2.show(); g3.show(); g4.show();
- g5.hide(); g6.hide(); g7.hide(); g8.hide();
- }
- if (theEvent.controller().name() == "colorB") {
- g1.hide(); g2.hide(); g3.hide(); g4.hide();
- g5.show(); g6.show(); g7.show(); g8.show();
- }
- // if (theEvent.controller().name() == "colorC") {
- // }
- }
- }
The project is about controlling temperature, co2, luminosity and humidity inside a room.
I will explain the idea. It is like a control pannel, with 3 buttons:
A) Show te page where we can stablish the requires ranges.
B) Show the page, where we can read the sensors trough an Arduino.
C) I want to add graphs about the evolution of the different measures of the sensors.
Now i tell you about my problems. I have 2 problems.
1) I want to add like a Log In page, with the name of the project and an username field. But it is impossible to make another window. I see libraries like g4p, gicentre (slides)..bu i cant make exactly like i want. What is the easiest way to add a window that when i ''click'' in log in button, dissappear the page and appear the other detail before?
2) I have a problem with button C. The thing is the other 2 buttons, is easy because i only have to show or hide some of the knobd, slides and ranges. But with this is different because it have another configuration. So, how ca i fix it? using Extend?? or PAplet??
OK, i hope someone can help me...and sorry for disturb!
I send an image of the idea..
1