import http.requests.*; import java.io.FileWriter; import java.io.IOException; String filename = "ondo_shitudo.csv"; PFont font; String data,data0; Float ondo,shitudo; Float ondo_sum,shitudo_sum; int count; void setup(){ size(420,280); scale(100,100); font = createFont("ipaexm.ttf", 16); // IPAex明朝 textFont(font); count = 0; ondo_sum = 0.0; shitudo_sum = 0.0; frameRate(1); } void draw(){ count ++; background(0); textSize(16); text("室温151", 340, 20); textSize(128); GetRequest get = new GetRequest("http://192.168.***.***"); get.send(); data = get.getContent().substring(0,23); ondo = float(data.substring(5, 8)); text(nf(ondo,2,0) +" C", 50, 120); shitudo = float(data.substring(18,21)); text(nf(shitudo,2,0) +" %", 50, 250); ondo_sum = ondo_sum + ondo; shitudo_sum = shitudo_sum + shitudo; if(count == 600){ count =0; ondo_sum = ondo_sum / 600.0; shitudo_sum = shitudo_sum /600.0; try { FileWriter writer = new FileWriter(filename, true); writer.write(ondo_sum+","+shitudo_sum+","+year()+","+month()+","+day()+","+hour()+","+minute()+System.lineSeparator()); writer.close(); ondo_sum = 0.0; shitudo_sum =0.0; } catch (IOException e) { println("エラーが発生しました: " + e.getMessage()); } } }