Zawijanie tekstu w C na drukarce termicznej Mini
Naprawdę chciałbym uzyskać pomoc przy jednym z moich projektów. Jestem studentem projektowania graficznego i mam niewielkie doświadczenie programistyczne. Stworzyłem program do drukarki termo mini, która identyfikuje tweety wykonane na Twitterze na podstawie określonych hashtagów i drukuje je automatycznie.
Opiera się jednak na długości linii 32 znaków i rozdziela słowa na pół, zamiast przenosić całe słowo do innej linii. Mój przyjaciel zasugerował zawijanie słów, ale nie mogę znaleźć niczego online, żeby mi pomóc, a większość kodu, który znalazłem, ma tendencję do bycia c ++ lub c #.
Kod do tej pory można znaleźć poniżej:
// Build an ArrayList to hold all of the words that
// we get from the imported tweets
ArrayList<String> 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);
}