128x128 1.5" OLED display

For other supported Arduino products from Adafruit: Shields, accessories, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
blenheim
 
Posts: 4
Joined: Tue Sep 02, 2014 5:47 am

128x128 1.5" OLED display

Post by blenheim »

Hello, I have purchased a 128x128 OLED color display from Adafruit and I'm going through some functional tests. I've followed the Adafruit tutorial for the display and after few minutes I was able to run the test sketch succesfully.
Now I would like to go further with other test. For instance I would like to show the value of an analog input of the Arduino on the display. So starting from the test sketch, I have started to remove what is not needed and to add the code for the analogue input. After some debug, I was able upload and run my custom made sketch. Is possible to see the value of the analog input on the display just for few moments; every time the task is repeated the value is overwritten and in few seconds the values became unreadable. The only way I have found to make the value readable is by putting "tft.fillScreen(BLACK)" command before calling "tft.print" but the visual result is not good because the display is now blinking..

Thanks in advance for your help!! :)

I'm attaching below the code that I'm using:

Code: Select all

#define sclk 13
#define mosi 11
#define dc   4
#define cs   5
#define rst  6

// Color definitions
#define	BLACK           0x0000
#define	BLUE            0x001F
#define	RED             0xF800
#define	GREEN           0x07E0
#define CYAN            0x07FF
#define MAGENTA         0xF81F
#define YELLOW          0xFFE0  
#define WHITE           0xFFFF

#include <Adafruit_GFX.h>
#include <Adafruit_SSD1351.h>
#include <SPI.h>
int sensorPin0 = A0;
int sensorPin1 = A1;
int sensorValue0 = 0;  // variable to store the value coming from the sensor
int sensorValue1 = 0;  // variable to store the value coming from the sensor

Adafruit_SSD1351 tft = Adafruit_SSD1351(cs, dc, rst);

void setup(void) {                
tft.begin();
tft.fillScreen(BLACK);
tft.setTextColor(BLUE);
tft.setTextSize(2);

}
void loop() {
sensorValue0 = analogRead(sensorPin0);
sensorValue1 = analogRead(sensorPin1);
//tft.fillScreen(BLACK);
tft.setTextColor(BLUE);
tft.setCursor(0, 0);
tft.print(sensorValue0);
tft.setTextColor(GREEN);
tft.setCursor(0, 15);
tft.print(sensorValue1);
delay(50);
}

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: 128x128 1.5" OLED display

Post by adafruit_support_rick »

We get this question a lot. The short answer is that you have to erase the old display before you write the new display. All computers do this.

"tft.fillScreen(BLACK)" is the most basic way to do it, but also the slowest. Better is to draw a black rectangle over just the area you want to erase, which will be much faster.

You can also re-write the old text in black before writing the new text in some other color.

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Arduino products from Adafruit”