Giter Club home page Giter Club logo

Comments (5)

greiman avatar greiman commented on June 9, 2024

oled.tickerTick() returns how many strings are queued to be displayed. You can add another string when the return value is less than TICKER_QUEUE_DIM by calling oled.tickerText().

When the return value is zero, all strings have been displayed.

from ssd1306ascii.

greiman avatar greiman commented on June 9, 2024
  /**
   * @brief Advance ticker by one pixel.
   *
   * @param[in,out] state Ticker state.
   * @return Number of entries in text pointer queue.
   */
  int8_t tickerTick(TickerState* state);

I should add that return of -1 indicates an error.

from ssd1306ascii.

JonRobert avatar JonRobert commented on June 9, 2024

BG wrote: oled.tickerTick() returns how many strings are queued to be displayed. You can add another string when the return value is less than TICKER_QUEUE_DIM by calling oled.tickerText().
When the return value is zero, all strings have been displayed.

the below never printed.

       Serial.println("                     >>>>>> finished displaying all strings");

I never received a oled.tickerTick() of "0" Perhaps I'm doing something wrong or I misunderstood.

My Code:

// Simple Ticker demo for I2C 128x32 oled.
//
// oled.tickerTick() returns how many strings are queued to be displayed. You can add another string when the return value is less than TICKER_QUEUE_DIM by calling oled.tickerText().
//  When the return value is zero, all strings have been displayed.
//

#include <Wire.h>
#include "SSD1306Ascii.h"
#include "SSD1306AsciiWire.h"

#define I2C_ADDRESS 0x3C

SSD1306AsciiWire oled;

// Ticker display
#define RTN_CHECK   1   // Try values of zero or one for RTN_CHECK.
#define numberLoops 3
#define tickerRate 50   // milliseconds
TickerState state;      // Ticker state. Maintains text pointer queue and current ticker state.
const char* text[] = {
    "Prog:  blah blah v0.02    "   //  26 char  26 x (8 + 3) = 286, close to the 289 we counted in the number of "false" loops.
};    // this is an array of pointers to the text.
uint32_t tickTime = 0;
int n = 0;
// Ticker display end

//  Setup
void setup() {
    Serial.begin(115200);
    delay(1000);
    Wire.begin();
    Wire.setClock(400000L);
    oled.begin(&Adafruit128x32, I2C_ADDRESS);
    // Use <font>, field at row 2, mag2x, columns 16 through 100.
    oled.tickerInit(&state, ZevvPeep8x16, 2, false, 16, 100);
    oled.displayRemap (true);
    // Try this for full screen width with set1X.
    // oled.tickerInit(&state, Adafruit5x7, 2);
    oled.clear();
}

//----------------------------- Main

void loop() {
    if (tickTime <= millis()) {
        tickTime = millis() + tickerRate;

   // Should check for error. rtn < 0 indicates error, rtn of 0 indicates all strings have been displayed.
        uint8_t rtn = oled.tickerTick(&state);

        if (rtn == 0){
            Serial.println("                                         finished displaying all strings");
        }

        if (rtn <= RTN_CHECK) {     // rtb = false every loop except when 1st char of the message reaches the left edge
            // Should check for error. Return of false indicates error.
            oled.tickerText(&state, text[(n++)%3]);
            Serial.println(".........................rtn test true");
        }
        else{
            Serial.println("rtn test false  ");
            return;
        }
    }
}  // -- end loop --
//  -- eof --

from ssd1306ascii.

greiman avatar greiman commented on June 9, 2024

Yes you will never get return zero since you always queue another copy of the string here when rtn == 1.

 if (rtn <= RTN_CHECK) {     // rtb = false every loop except when 1st char of the message reaches the left edge
            // Should check for error. Return of false indicates error.
            oled.tickerText(&state, text[(n++)%3]);  <<------ Causes another copy of your string to be queued when rtn == 1.
            Serial.println(".........................rtn test true");
        } else{
            Serial.println("rtn test false  ");  <<----- This is not false it is more than one copy queued.
            return;
        }

from ssd1306ascii.

JonRobert avatar JonRobert commented on June 9, 2024

Got it :) Thanks

from ssd1306ascii.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.