bitbank2 / ssd1327

SSD1327 and SSD1322 OLED display library for Arduino+Linux
26 stars 5 forks source link

writing 'byte' #1

Closed 5B4ALR closed 4 years ago

5B4ALR commented 4 years ago

Nice little library!

I'm trying to write "byte" on OLED, but seems that my syntax is wrong.. is it possible to get some help?

//How to print "byte" on SSD1327 OLED, using ssd1327 library byte packethour; byte packetminute; void printTimestamp() {

if (packethour < 10) { ssd1327WriteString(88, 0, (char )"0", FONT_NORMAL, 15, 0);} // (x, y, 'what to write', font type, char brightness, backround brightness) ssd1327WriteString(96, 0, (char )packethour, FONT_NORMAL, 15, 0); //packethour is a "byte" type ssd1327WriteString(104, 0, (char )":", FONT_NORMAL, 15, 0); //8x8 if (packetminute < 10) { ssd1327WriteString(112, 0, (char )"0", FONT_NORMAL, 15, 0);} ssd1327WriteString(120, 0, (packetminute), FONT_NORMAL, 15, 0);

} // if packethour = 3 and packetminute = 4, it should show 03:04

bitbank2 commented 4 years ago

My WriteString() functions (in all my libraries) are C, not C++ and don't have multiple versions for different parameter types. The 3rd parameter must be a string. You'll need to explicitly convert the byte value to a C string (zero terminated array of characters).