application applet no display
              in 
             Integration and Hardware 
              •  
              1 year ago    
            
 
           
             the following is a simple sketch to display temperature graph by taking value from serial port from an arduino board with temperature sensor..
            
             
            
            
             
            
            
             
              
             
             
              
             
             
              
             
             
              
             
             
               
             
             
               
             
             
               
             
             
               
             
             
               
             
             
               
             
             
               
             
             
               
             
             
               
             
             
               
             
             
              
             
             
              
             
             
              
             
             
               
             
             
              
             
             
              
             
             
           
 
            
           
             however the index.html file as well as the application exported from this sketch do not display anything.
            
            
             i tried after signing the executable jar file in applet folder , however it did not help , is there anything in the program which is preventing the display.
            
            
              import processing.serial.*;
             
             
              String temperature = "0";
             
             
              PFont font;
             
             
              Serial port;
             
             
              int xPos=100;
             
             
              float Maxi=0;
             
             
              float Mini=100;
             
             
              int counter=0;
             
             
              void setup() {
             
             
               String portName = Serial.list()[2];
             
             
               port = new Serial(this, portName, 9600);
             
             
               font = loadFont("Ziggurat-HTF-Black-32.vlw");
             
             
               textFont(font);
             
             
               textAlign(CENTER);
             
             
               size(600, 600);
             
             
               background(0);
             
             
               fill(0);
             
             
               smooth();
             
             
              }
             
             
              void draw() {
             
             
              counter= counter+1;
             
             
              fill(50,100,180);
             
             
               text("time >> " , width/2, height-50);
             
             
               text("temp " ,60,height-250);
             
             
               text("^",60,height-260);
             
             
               text("^",60,height-280);
             
             
               if (port.available()>0) {
             
             
                delay(100);
             
             
                temperature = port.readString();
             
             
               }
             
             
              //background(255); // Set background to dark gray
             
             
               fill(255);
             
             
               rect(0,0,600,200);
             
             
               stroke(20,20,250);
             
             
               for(int i=100; i <601 ; i= i+25)
             
             
               line(i,200,i,500);
             
             
               for(int j=200;j <501; j= j+25)
             
             
               line(100,j,600,j); 
             
             
               fill(0);
             
             
               text("temp : "+temperature+ "Deg. Cel", width/2, height/8);
             
             
               text("Max. "+ Maxi+"Deg. Cel",width/2,140);
             
             
               if(counter>200)
             
             
               text("Min. "+ Mini+"Deg. Cel",width/2,180);
             
             
               //fill(255);
             
             
               //text("time >> " , width/2, height-50);
             
             
               //text("temp " ,80,height-200);
             
             
               if (temperature != null)
             
             
               { // trim off any whitespace
             
             
               temperature = trim(temperature);
             
             
               }
             
             
               //convert to an int and map to the screen height
             
             
               float tempe = float(temperature);
             
             
               print(" aftr string2flt="+tempe+"  "+" string="+temperature);
             
             
               //alarm placing
             
             
               if(Maxi<tempe)
             
             
               Maxi=tempe;
             
             
               if(counter>200)
             
             
               {
             
             
               if(Mini>tempe)
             
             
               Mini=tempe;
             
             
               }
             
             
                if(tempe > 35.0)
             
             
               {stroke(200,10,20);
             
             
               fill(255,10,10);
             
             
               text("Overheating ",width/2,250);
             
             
               }
             
             
               else 
             
             
               stroke(10,200,20);
             
             
               //mapping
             
             
               tempe = map(tempe,0,100,0,(height-300));
             
             
               println("mapped="+tempe+" height="+height+"  ");
             
             
               //draw the line
             
             
               line( xPos , 500 , xPos ,(height-100)-(int)tempe);
             
             
               delay(1000);
             
             
               xPos= xPos+1;
             
             
               if(xPos >=width)
             
             
               {xPos=100;
             
             
               fill(0);
             
             
               rect(100,200,width-100,height-300);
             
             
               }
             
             
              //}
             
             
              }
             
              
              
              1  
            
 
            
 
 
          