You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've copied and slightly modified some code and got it to work on small .96 OLED using the ssd1306 library. Then got a larger 1.5in (128x128), ssd1351 OLED. My screen needs to be refreshed and redrawn (code line 124) but it fails and gives me an "'class Adafruit_SSD1351' has no member named 'display' " and display.clear(); also errors out.
How do I clear without flickering? I read that "The Adafruit library doesn't clear areas that have not changed, it rewrites these areas with the same data."
// This program is for drawing a chart and moving dots (illusion of moving wave) to display voltages or current levels
// Arduino UNO and SSD1351 128X128 OLED display
// 6/17/2020
// You can use any (4 or) 5 pins
#define SCLK_PIN 13
#define MOSI_PIN 11
#define DC_PIN 9
#define CS_PIN 8
#define RST_PIN 7
// 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 <SPI.h>
#include <Wire.h>
#include "SPI.h" // YT Includes library for SPI communication of display
#include <Adafruit_GFX.h> //Includes core graphics library
#include <Adafruit_SSD1351.h> //Includes hardware specific library
char filled = 'D'; //decide either filled or dot display (F or D = dot, any else filled)
char drawDirection = 'R'; //decide drawing direction, from right or from left (L=from left to right, any else from right to left)
char slope = 'W'; //slope colour of filled mode white or black slope (W=white, any else black. Well, white is blue in this dispay but you get the point)
void loop() {
//This section puts moving dots on chart (voltage or current levels)
drawHeight = map(analogRead(A0), 0, 1023, 4, 64 ); // 0Min/1023Max (on chart), 4Min/64Max (limits of moving dots)
sensorArray[0] = drawHeight; //vertical limit of moving dots
for (count = 1; count <= 80; count++ ) //80 Position of moving chart start
{
if (filled == 'D' || filled == 'd')
{
if (drawDirection == 'L' || drawDirection == 'l')
{
display.drawPixel(count, 64 - sensorArray[count - 1], BLUE); // BLACK,BLUE,RED,GREEN,CYAN,MAGENTA,YELLOW,WHITE
}
else //else, draw dots from right to left
{
display.drawPixel(80 - count, 64 - sensorArray[count - 1], CYAN); // <--- active BLACK,BLUE,RED,GREEN,CYAN,MAGENTA,YELLOW,WHITE
}
}
//********* PROBLEM AREA PROBLEM AREA PROBLEM AREA
display.display(); //exit status 1 'class Adafruit_SSD1351' has no member named 'display'
display.clearDisplay(); //error: 'class Adafruit_SSD1351' has no member named 'clearDisplay'; did you mean 'invertDisplay'?
//********* PROBLEM AREA PROBLEM AREA PROBLEM AREA
//display.display(); //needed before anything is displayed.. from <Adafruit_SSD1306.h> library //this works on smaller OLED
//display.clearDisplay(); //clear before new drawing.. from <Adafruit_SSD1306.h> library //this works on smaller OLED
/* Clearing the entire display causes flickering.
This is why the Adafruit library has less flicker.
The Adafruit library doesn't clear areas that have not changed,
it rewrites these areas with the same data.
If you selectively rewrite only areas that are modified there will be less flickering.-
Bill Greiman fat16lib@sbcglobal.net
*/
//----- trying to "clear" screen without causing graph to flicker --------
//tft.fillScreen(0x0000); //Attempt 1: blacks out graph...still flickers
//tft.fillRect(0, 0, 128, 128, BLACK); //Attempts2: blacks out graph...still flickers
for (count = 80; count >= 2; count--) // count down from 160 to 2
{
sensorArray[count - 1] = sensorArray[count - 2];
}
}
void draw_Chart_Axis() // Draws chart
{
display.setCursor(90, 0); // changing all display. to tft.
display.setTextSize(1);
display.setTextColor(WHITE); // BLACK,BLUE,RED,GREEN,CYAN,MAGENTA,YELLOW,WHITE
display.drawLine( 0, 0, 0, 60, WHITE); // 64//32 ); // Left Vert line on graph Horiz/Vertical
display.drawLine(80, 0, 80, 60, WHITE); // 64//32 ); // Right Vert line on graph
for (count = 0; count < 70; count += 10) //40-> 60 //Number of horiz marks
{
display.drawLine(80, count, 75, count, WHITE); //Length / Position of RIGHT horiz marks,
display.drawLine( 5, count, 0, count, WHITE); //Length / Position of LEFT horiz marks,
}
for (count = 10; count < 80; count += 10) //80 Num of Horiz Pixels
{
display.drawPixel(count, 0 , WHITE); // Horizontal dots on graph
display.drawPixel(count, 30 , WHITE); //30
display.drawPixel(count, 60 , WHITE); //60
}
}
The text was updated successfully, but these errors were encountered:
Hello good people, I am somewhat a newbie here... making a solar-powered bike computer here for a trip around the Okefenokee swamp. https://en.wikipedia.org/wiki/Okefenokee_Swamp
I've copied and slightly modified some code and got it to work on small .96 OLED using the ssd1306 library. Then got a larger 1.5in (128x128), ssd1351 OLED. My screen needs to be refreshed and redrawn (code line 124) but it fails and gives me an "'class Adafruit_SSD1351' has no member named 'display' " and display.clear(); also errors out.
How do I clear without flickering? I read that "The Adafruit library doesn't clear areas that have not changed, it rewrites these areas with the same data."
// This program is for drawing a chart and moving dots (illusion of moving wave) to display voltages or current levels
// Arduino UNO and SSD1351 128X128 OLED display
// 6/17/2020
// Screen dimensions
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 128
// U8GLIB_SSD1351_128X128_332 u8g( 13, 11, 8, 9, 7);
// Arduino UNO: SW SPI Com: SCK = 13, MOSI = 11, CS = 8, A0 = 9, RESET = 7
// You can use any (4 or) 5 pins
#define SCLK_PIN 13
#define MOSI_PIN 11
#define DC_PIN 9
#define CS_PIN 8
#define RST_PIN 7
// 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 <SPI.h>
#include <Wire.h>
#include "SPI.h" // YT Includes library for SPI communication of display
#include <Adafruit_GFX.h> //Includes core graphics library
#include <Adafruit_SSD1351.h> //Includes hardware specific library
Adafruit_SSD1351 display = Adafruit_SSD1351(SCREEN_WIDTH, SCREEN_HEIGHT, &SPI, CS_PIN, DC_PIN, RST_PIN);
byte count;
byte sensorArray[128];
byte drawHeight;
char filled = 'D'; //decide either filled or dot display (F or D = dot, any else filled)
char drawDirection = 'R'; //decide drawing direction, from right or from left (L=from left to right, any else from right to left)
char slope = 'W'; //slope colour of filled mode white or black slope (W=white, any else black. Well, white is blue in this dispay but you get the point)
void setup(void)
{
Serial.begin(9600);
//Serial.print("InSETUP");
display.begin();
display.fillScreen(0x0000); // This clears entire screen (BLACK)
}
void loop() {
//This section puts moving dots on chart (voltage or current levels)
drawHeight = map(analogRead(A0), 0, 1023, 4, 64 ); // 0Min/1023Max (on chart), 4Min/64Max (limits of moving dots)
sensorArray[0] = drawHeight; //vertical limit of moving dots
for (count = 1; count <= 80; count++ ) //80 Position of moving chart start
{
if (filled == 'D' || filled == 'd')
{
if (drawDirection == 'L' || drawDirection == 'l')
{
display.drawPixel(count, 64 - sensorArray[count - 1], BLUE); // BLACK,BLUE,RED,GREEN,CYAN,MAGENTA,YELLOW,WHITE
}
else //else, draw dots from right to left
{
display.drawPixel(80 - count, 64 - sensorArray[count - 1], CYAN); // <--- active BLACK,BLUE,RED,GREEN,CYAN,MAGENTA,YELLOW,WHITE
}
}
else
{
if (drawDirection == 'L' || drawDirection == 'l')
{
if (slope == 'W' || slope == 'w')
{
display.drawLine(count, 64, count, 64 - sensorArray[count - 1], WHITE); // BLACK,BLUE,RED,GREEN,CYAN,MAGENTA,YELLOW,WHITE
}
else
{
display.drawLine(count, 1, count, 64 - sensorArray[count - 1], WHITE);
}
else
{
if (slope == 'W' || slope == 'w')
{
display.drawLine(80 - count, 64, 80 - count, 64 - sensorArray[count - 1], WHITE); // BLACK,BLUE,RED,GREEN,CYAN,MAGENTA,YELLOW,WHITE
}
else
{
display.drawLine(80 - count, 1, 80 - count, 64 - sensorArray[count - 1], WHITE);
}
}
}
}
draw_Chart_Axis(); //Draws chart borders & tickmarks
//********* PROBLEM AREA PROBLEM AREA PROBLEM AREA
display.display(); //exit status 1 'class Adafruit_SSD1351' has no member named 'display'
display.clearDisplay(); //error: 'class Adafruit_SSD1351' has no member named 'clearDisplay'; did you mean 'invertDisplay'?
//********* PROBLEM AREA PROBLEM AREA PROBLEM AREA
//display.display(); //needed before anything is displayed.. from <Adafruit_SSD1306.h> library //this works on smaller OLED
//display.clearDisplay(); //clear before new drawing.. from <Adafruit_SSD1306.h> library //this works on smaller OLED
//----- trying to "clear" screen without causing graph to flicker --------
//tft.fillScreen(0x0000); //Attempt 1: blacks out graph...still flickers
//tft.fillRect(0, 0, 128, 128, BLACK); //Attempts2: blacks out graph...still flickers
for (count = 80; count >= 2; count--) // count down from 160 to 2
{
sensorArray[count - 1] = sensorArray[count - 2];
}
}
void draw_Chart_Axis() // Draws chart
{
display.setCursor(90, 0); // changing all display. to tft.
display.setTextSize(1);
display.setTextColor(WHITE); // BLACK,BLUE,RED,GREEN,CYAN,MAGENTA,YELLOW,WHITE
display.print(drawHeight-4); // Numerical value
display.setCursor(90, 8);
display.setTextSize(1);
display.setTextColor(WHITE); // BLACK,BLUE,RED,GREEN,CYAN,MAGENTA,YELLOW,WHITE
display.print("KM/h"); // Label
display.drawLine( 0, 0, 0, 60, WHITE); // 64//32 ); // Left Vert line on graph Horiz/Vertical
display.drawLine(80, 0, 80, 60, WHITE); // 64//32 ); // Right Vert line on graph
for (count = 0; count < 70; count += 10) //40-> 60 //Number of horiz marks
{
display.drawLine(80, count, 75, count, WHITE); //Length / Position of RIGHT horiz marks,
display.drawLine( 5, count, 0, count, WHITE); //Length / Position of LEFT horiz marks,
}
for (count = 10; count < 80; count += 10) //80 Num of Horiz Pixels
{
display.drawPixel(count, 0 , WHITE); // Horizontal dots on graph
display.drawPixel(count, 30 , WHITE); //30
display.drawPixel(count, 60 , WHITE); //60
}
}
The text was updated successfully, but these errors were encountered: