Processing版作りかけ
ずーっとP2Dで日本語表示できないできないって思ってたら、CreateFontでAll Charactersにチェック入れないと駄目な事に1時間ぐらいして気がついた・・・。まぁ後々消すんだけど。。。
そしてフォントの量が増えた分だけメモリをすげー食らう様になった。。。後に修正する事にしよう。。。。
import processing.serial.*;
Serial port;
PFont font;
String feed = "http://rss.weather.yahoo.co.jp/rss/days/13.xml";
XMLElement rss = new XMLElement(this, feed);
XMLElement[] titleXMLElements = rss.getChildren("channel/item/title");
XMLElement[] descriptionXMLElements = rss.getChildren("channel/item/description");
String title = "";
String weather = "";
void setup() {
font = loadFont("HiraMaruPro-W4-15.vlw");
textFont(font, 16);
size(640,480);
frameRate(10);
smooth();
String arduinoPort = Serial.list()[0];
port = new Serial(this, arduinoPort, 9600);
port.clear();
fetchData();
}
void draw(){
background(0);
text("Cloud Networked Lamp", 10, 40);
text("feed: " + feed, 10, 100);
text(title, 10, 140);
text(weather, 10, 180);
if (port.available() > 0) { //check for taking data
}
}
void fetchData(){
try {
title = titleXMLElements[0].getContent();
String[] list = split(title, ' ');
weather = list[4];
String[] sunny = match(weather, "晴");
String[] cloudy = match(weather, "曇");
String[] rainy = match(weather, "雨");
if (sunny != null){
println("Sunny : Found a match in '" + weather + "'");
}else{
println("Sunny : No match found in '" + weather + "'");
}
if (cloudy != null){
println("Cloudy : Found a match in '" + weather + "'");
}else{
println("Cloudy : No match found in '" + weather + "'");
}
if (rainy != null){
println("Rainy : Found a match in '" + weather + "'");
}else{
println("Rainy : No match found in '" + weather + "'");
}
}
catch (Exception ex) {
ex.printStackTrace();
System.out.println("ERROR: "+ex.getMessage());
}
}
0 件のコメント:
コメントを投稿