Обтекание текстом в C на Thermo Mini Printer
Мне бы очень хотелось помочь с одним из моих проектов. Я студент графического дизайна и практически не имею опыта программирования. Я создал программу для термо-мини-принтера, которая идентифицирует твиты, сделанные в твиттере, на основе определенных используемых хэштегов и печатает их автоматически.
Тем не менее, это 's, основанный на длине строки 32 символа и будет разбивать слова пополам вместо перемещения всего слова в другую строку. Мой друг предложил использовать перенос слов, но я могуя не могу найти что-нибудь в Интернете, чтобы помочь мне, и большинство кода янайдено, как правило, для c ++ или c #.
Код пока можно найти ниже:
// Build an ArrayList to hold all of the words that
// we get from the imported tweets
ArrayList words = new ArrayList();
Twitter twitter;
import processing.serial.*;
Serial myPort; // Create object from Serial class
int val; // Data received from the serial port
void setup() {
String portName = Serial.list()[0];
myPort = new Serial(this, portName, 9600);
//Set the size of the stage, and the background to black.
size(550,550);
background(0);
smooth();
//Make the twitter object and prepare the query
twitter = new TwitterFactory(cb.build()).getInstance();
}
void draw() {
Query query = new Query("#R.I.P");
query.setRpp(1);
//Try making the query request.
try {
QueryResult result = twitter.search(query);
ArrayList tweets = (ArrayList) result.getTweets();
for (int i = 0; i < tweets.size(); i++) {
Tweet t = (Tweet) tweets.get(i);
String user = t.getFromUser();
String msg = t.getText();
Date d = t.getCreatedAt();
println("Tweet by " + user + " at " + d + ": " + msg);
msg = msg.replace("\n"," ");
myPort.write(msg+"\n");
};
}
catch (TwitterException te) {
println("Couldn't connect: " + te);
};
println("------------------------------------------------------");
delay(20000);
}