Add print function for text in library.

Hello,

I would like to add a print function in a library for text. Unfortunately, I know not exactly how. Can anyone help me?

I have in the SSD1306 void print (uint8_t c); inserted, but now bekomm an error message.

Scatch:

#include <Wire.h>
//#include <Adafruit_GFX.h>
#include <SSD1306.h>

#define OLED_CS 2 // CS
#define OLED_DC 3 // DC
#define OLED_RESET 4 // RST
#define OLED_MOSI 5 // D1
#define OLED_CLK 6 // D0
SSD1306 display (OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);

// #define NUMFLAKES 10
// #define XPOS 0
// #define YPOS 1
// #define DELTAY 2

// #define LOGO16_GLCD_HEIGHT 80
// #define LOGO16_GLCD_WIDTH 40 

static PROGMEM prog_uchar logo16_glcd_bmp [] = 
// static unsigned char PROGMEM logo16_glcd_bmp[] =
// static unsigned char __attribute__ ((progmem)) logo16_glcd_bmp[]=
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0x70, 0x98, 0xEC, 0xF6,
0xFA, 0xFA, 0x7A, 0x1A, 0xCA, 0xF2, 0xFA, 0xFA, 0xFA, 0x7A, 0x3A, 0xCA, 0xE2, 0xFA, 0xFA, 0xFA,
0x7A, 0x1A, 0xC2, 0xFA, 0x3E, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0x70, 0x98,
0x8C, 0xA3, 0xB9, 0xBC, 0xBE, 0x3E, 0x1E, 0x0E, 0xB2, 0xB8, 0xBE, 0xBE, 0xBE, 0x3E, 0x8E, 0xA2,
0xB8, 0xBC, 0xBE, 0x3E, 0x1E, 0xCE, 0xE2, 0x78, 0x1E, 0x0F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x78, 0x4E, 0x53, 0x59, 0x5C, 0x5F, 0x5F, 0x5F, 0x5F, 0x4F, 0x47, 0x51, 0x5C, 0x5F, 0x5F,
0x5F, 0x5F, 0x47, 0x51, 0x5C, 0x5F, 0x5F, 0x5F, 0x4F, 0x63, 0x38, 0x1C, 0x07, 0x03, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
};

static unsigned char PROGMEM akku_bmp[] = {
0xF0, 0xF0, 0xF8, 0xFC, 0xFE, 0x07, 0x03, 0xFB, 0xFB, 0xFB, 0xFB, 0xFB, 0x03, 0xFB, 0xFB, 0xFB,
0xFB, 0xFB, 0x03, 0xFB, 0xFB, 0xFB, 0xFB, 0xFB, 0x03, 0xFB, 0xFB, 0xFB, 0xFB, 0xFB, 0x03, 0xFB,
0xFB, 0xFB, 0xFB, 0xFB, 0x03, 0x07, 0xFF, 0xFE, 0x0F, 0x0F, 0x1F, 0x3F, 0x7F, 0xE0, 0xC0, 0xDF,
0xDF, 0xDF, 0xDF, 0xDF, 0xC0, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xC0, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF,
0xC0, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xC0, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xC0, 0xE0, 0xFF, 0xFF
};



#if (SSD1306_LCDHEIGHT != 64)
#error("Height incorrect, please fix SSD1306.h!");
#endif

void setup()
{
 Serial.begin(9600);
 display.begin(SSD1306_SWITCHCAPVCC);
 display.clearDisplay();  
}

void loop()
{ 
  display.clearDisplay();
  display.print("test");
  display.drawBitmap(0, 0,  logo16_glcd_bmp, 40, 24, 1);
  display.drawBitmap(86, 2,  akku_bmp, 40, 16, 1);
  display.display();

}

Error Massage:

Laderegler_TE.ino: In function ‘void loop()’:
Laderegler_TE:59: error: invalid conversion from ‘const char*’ to ‘uint8_t’
Laderegler_TE:59: error: initializing argument 1 of ‘void SSD1306::print(uint8_t)’

SSD1306.cpp (15.4 KB)

SSD1306.h (3.43 KB)

glcdfont.c (8.14 KB)

It's telling you exactly what is wrong.

You are trying to send an 'array of chars' to a function which only accepts a single 'byte'.

Also, "void print (uint8_t c){}" doesn't exist in SSD1306.cpp

  void print(uint8_t c);

If you want this function to print a character, why are you defining it to take a byte? If you want it print a string, why are you defining it to take a byte?

It does not work. Can someone tell me what to void print () me, purely do? There simply is not a blasphemous expressed in text.

Can someone tell me what to void print () me, purely do?

It's hard to tell what you want the print() method to do, Most likely, the signature should be:

void print(char *str);

Then, you can

display.print("Hi there");

(assuming that you implement print() correctly.