bitbank2/OneBitDisplay

Simple print with text wrap, and scroll?

Sarah-C opened this issue · 1 comments

I see there's a LINUX option that provides printing with text wrap, and scroll... I can't get it working on my ESP32 - though the std libraries are in the build as far as I know.

obdWriteString(&obd, 0,-1,-1,"Hello", FONT_8x8, 0, 1); ... when supplied with -1 for X and Y it wraps around to the line below.

I'm checking before I re-invent the wheel, just in case I'm missing a simple print command that scrolls the text up when the screen fills?

Great library !


#include <Arduino.h>
#include <OneBitDisplay.h>
#include <Adafruit_NeoPixel.h>

#define LED_PIN 2
#define SDA_PIN 5
#define SCL_PIN 6

#define RESET_PIN -1
#define OLED_ADDR -1
#define FLIP180 0
#define INVERT 0
#define USE_HW_I2C 1
#define MY_OLED OLED_72x40
uint8_t ucBackBuffer[1024];

OBDISP obd;
Adafruit_NeoPixel led = Adafruit_NeoPixel(1, LED_PIN, NEO_GRB + NEO_KHZ800);

void setup(void) {
  int rc = obdI2CInit(&obd, MY_OLED, OLED_ADDR, FLIP180, INVERT, USE_HW_I2C, SDA_PIN, SCL_PIN, RESET_PIN, 800000L);
  obdSetBackBuffer(&obd, ucBackBuffer);
  obdSetTextWrap(&obd, 1);
  obdSetContrast(&obd, 1);
  //if (rc != OLED_NOT_FOUND) {
  obdFill(&obd, 0, 0);
  //obdWriteString(OBDISP *pOBD, int iScrollX, int x, int y, char *szMsg, int iSize, int bInvert, int bRender);
  obdWriteString(&obd, 0, 5, 20, (char *)"01Space", FONT_8x8, 0, 0);
  obdDumpBuffer(&obd, ucBackBuffer);
  led.begin();
  led.setPixelColor(0, 10, 0, 0);
  led.show();
  delay(334);
  led.setPixelColor(0, 0, 10, 0);
  led.show();
  delay(334);
  led.setPixelColor(0, 0, 0, 10);
  led.show();
  delay(334);
  led.clear();
  led.show();
  obdFill(&obd, 0, 0);
  obdDumpBuffer(&obd, ucBackBuffer);

  obdWriteString(&obd, 0, 0, 0, (char *)"Testing...", FONT_6x8, 0, 0);
}

//The text eventually runs off the bottom of the display and does not scroll up.
void loop(void) {
  obdWriteString(&obd, 0, -1, -1, (char *)"Testing...", FONT_6x8, 0, 0);
  obdDumpBuffer(&obd, ucBackBuffer);
  delay(250);
}

Sorry for the delay and confusion about this feature. Currently the vertical scrolling with print/println only works from the C++ API. I suppose I should update the C API to have it too. This has nothing to do with Linux. The LINUX macro is to disable all references to Arduino APIs such as for I2C/SPI and instead use ones suitable for Linux.