I'm trying to interface processing with a display with a very simple protocol. The values that the display receives have to be hex, and all writes to the display need to have a 0x prefix to tell the display to expect hex. I've got various tests running on the display when hardcoding it, for example -
myPort.write(0x00); // turns one line to all black
I'm now looking to be able to display images onto the display with a pixel array, I've used a version of ladyadas thermal printer bitmap (only runs on processing 1.5.1) converter sketch to take pixel data and create hex calls for each vertical column on the display. See original sketch below.
// Convert image to a C header file suitable for the Adafruit_Thermal library.
// This is NOT an Arduino sketch. Runs in Processing IDE (www.processing.org)
void setup() {
String filename, basename;
PImage img;
PrintWriter output;
int i, x, y, b, rowBytes, totalBytes, lastBit, sum, n;
// Select and load image
filename = selectInput("Select image file to convert:");
println("Loading image...");
img = loadImage(filename);
// Morph filename into output filename and base name for data
This line shows up as a random pattern on the display and not what I need, however printing this serially - it looks like the correct format. I think the byte is being converted to an int when I add the 0x to it so I've tried to add the 0x in various ways and convert it to a byte after this, but without any luck.
Does anyone have advice for how to use twitter 4J and access the XML core functionality in the same sketch?
I'm using processing 2.0b8 and I have the small block of code below working in a separate sketch that pulls in and parses a BBC xml weather feed but as soon as I add these lines to a sketch that also pulls in searches twitters API for images I get a "The type XML is ambiguous" error. The twitter sketch is based on this one
https://github.com/neufuture/SimpleTwitterStream/ and anywhere I put the XML block below it makes the type ambiguous.
XML feed = loadXML("http://open.live.bbc.co.uk/weather/feeds/en/2644210/observations.rss");
Modified twitter image search with Oauth credentials below: Also has some twitter 4j files in the code folder of the sketch - as per the github example link above.
I'm new to processing and have had some success so far stumbling around but I'm at a point now where I am unsure how to proceed.
I'm trying to count the difference in followers on a twitter profile, ideally to query the number regularly and each time there is a new follower I want to move a servo 1 step with firmata and an arduino uno.
I can access the data from twitters API and display a bundle of follower user ID's (8 digit numbers) in the console box using the println command however I can't work out how to count the total number and display it as an int or something useful that I can create motor outputs from.
This is my attempt: if anyone has worked on similar problems or has suggestions for things to try I would very much appreciate comments and feedback.
import twitter4j library
String consumer_key = "xxxx";
String consumer_secret = "xxxx";
String oauth_token = "xxxx";
String oauth_token_secret = "xxxx";
AccessToken token;
String getFollowersIDs;
color bgcolor = color(255);
long timer;
PFont f; //declaring Pfont variable - not sure if this is in right place
void setup() {
size(300,300);
f = loadFont ("ArialBlack20.vlw"); // loading font
//size(640,480);
}
void draw() {
background(#ff3300);
if (millis()-timer > 2000) bgcolor = color(255);
textFont (f,20); // specifying font to be used
fill (#CCCCCC); // specifying font colour
text ("counting followers", 10,100); //display text
}
void mousePressed() {
Twitter twitter = new TwitterFactory().getInstance();