I've successfully connected two optical encoders to my teensy 3.5, as well as a oLED, 32x128 display, all is working great.
That said, the font size I have to use is quite small, for these 65 year old eye.
The simple fix is use a single display for my x and y data output, but alas, it seems that the two oleds, I'm using, have the same address, so the adafruit library that I'm using can't distinguish between the two.
I see teensy has a number of the SCL and SCA pins. Is there a library that allows me to use these same addressed displays, but have date sent to the SCA1 and SCL1 pins.
seems like a pretty simple thing to do, but not sure how to go about it.
Below is my current code, that is working quite well, but again, the x and y data is being displayed on a single oled... if somw code give me some example code for the new method, I would be most grateful.
be gentle boy and girls....
/* Encoder Library - TwoKnobs Example
* http://www.pjrc.com/teensy/td_libs_Encoder.html
*
* This example code is in the public domain.
*/
#include <Adafruit_SSD1306.h>
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);
#if (SSD1306_LCDHEIGHT != 32)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif
double myX, myY;
#define ENCODER_OPTIMIZE_INTERRUPTS
#include <Encoder.h>
Encoder xEncoder(5,6);
Encoder yEncoder(2,3);
void setup() {
// Serial.begin(115200);
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3C (for the 128x32)
//Serial.println("Two Encoder Test:");
display.clearDisplay();
// text display tests
display.setTextSize(2);
display.setTextColor(WHITE);
}
long xposition;
long yposition;
long newx, newy;
void loop() {
newx= xEncoder.read();
newy = yEncoder.read();
if (newx !=xposition || newy != yposition) {
display.setCursor(10,0);
display.print("X=");
display.println(newx/5.08/2400.0*25.4, 2);
display.setCursor(10,19);
display.print("Y=");
display.println(newy/5.08/2400.0*25.4, 2);
display.display();
display.clearDisplay();
xposition = newx;
yposition = newy;
}
}
That said, the font size I have to use is quite small, for these 65 year old eye.
The simple fix is use a single display for my x and y data output, but alas, it seems that the two oleds, I'm using, have the same address, so the adafruit library that I'm using can't distinguish between the two.
I see teensy has a number of the SCL and SCA pins. Is there a library that allows me to use these same addressed displays, but have date sent to the SCA1 and SCL1 pins.
seems like a pretty simple thing to do, but not sure how to go about it.
Below is my current code, that is working quite well, but again, the x and y data is being displayed on a single oled... if somw code give me some example code for the new method, I would be most grateful.
be gentle boy and girls....
/* Encoder Library - TwoKnobs Example
* http://www.pjrc.com/teensy/td_libs_Encoder.html
*
* This example code is in the public domain.
*/
#include <Adafruit_SSD1306.h>
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);
#if (SSD1306_LCDHEIGHT != 32)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif
double myX, myY;
#define ENCODER_OPTIMIZE_INTERRUPTS
#include <Encoder.h>
Encoder xEncoder(5,6);
Encoder yEncoder(2,3);
void setup() {
// Serial.begin(115200);
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3C (for the 128x32)
//Serial.println("Two Encoder Test:");
display.clearDisplay();
// text display tests
display.setTextSize(2);
display.setTextColor(WHITE);
}
long xposition;
long yposition;
long newx, newy;
void loop() {
newx= xEncoder.read();
newy = yEncoder.read();
if (newx !=xposition || newy != yposition) {
display.setCursor(10,0);
display.print("X=");
display.println(newx/5.08/2400.0*25.4, 2);
display.setCursor(10,19);
display.print("Y=");
display.println(newy/5.08/2400.0*25.4, 2);
display.display();
display.clearDisplay();
xposition = newx;
yposition = newy;
}
}