B4R Question rAdafruitSSD1306 display icon

Mostez

Well-Known Member
Licensed User
Longtime User
I need to display blue tooth icon to indicate the BT connection status for ESP32S board, I use the rAdafruitSSD306 lib to display other text info. it there any method to display the BT icon as bitmap or user defined char or ASCII symbol?
 

Cableguy

Expert
Licensed User
Longtime User
I know this is not a 1306 disply, but maybe the same principle can apply...
I also recall seeing a "custom font" article somewhere "on the net"

 
Upvote 0

Mark Read

Well-Known Member
Licensed User
Longtime User
No idea if this helps but I defined the Wlan symbol in the Arduino IDE as follows:

B4X:
//wlan logo
// delete PROGMEM if required
// LCD Assistant - output horizontal!!
const unsigned char PROGMEM wlan [] = {
0x7F, 0xC0, 0x20, 0x84, 0x11, 0x04, 0x0A, 0x14, 0x04, 0x14, 0x04, 0x54, 0x04, 0x54, 0x05, 0x54
};

and called it with:

B4X:
 //draw Wlan symbol
  display.drawBitmap(112,0, wlan, 16, 8, WHITE);

With the help of this link. you should be able to use inline C: Link

Regards
Mark
 
Upvote 0

Mark Read

Well-Known Member
Licensed User
Longtime User
Does this help?

B4X:
byte name0x0[] = { B10110, B01101, B00101, B00110, B00110, B00101, B01101, B10110 };

void setup() {
  lcd.begin(16, 2);
 
  lcd.createChar(0, name0x0);
  lcd.write(0);

Should give this:

1611160176299.png


Made here: Link

And called via inline C, have to leave something for you :)
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
Since the 1306 is a graphic display, the "icon" can be better drawn, but this is pointing in the right direction for the OP.
 
Upvote 0

moty22

Active Member
Licensed User
it there any method to display the BT icon as bitmap or user defined char or ASCII symbol?
I have a project that shows how to add bitmap on oled SSD1306, you don't need any library but it's written in Arduino and C http://www.moty22.co.uk/egg_timer.php
Edited:
To convert image to code:
On a PC (MS Paint) resize image to 48x48 pixels and save as monochrom bmp.
Download LCD Assistant app from http://en.radzio.dxp.pl/bitmap_converter/
Set it to Byte Orientation - Vertical, Pixels/byte - 8. Save file as text file and copy the bitmap array to the code page.

This is how it looks on B4R
B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'Public variables can be accessed from all modules.
    'Public Serial1 As Serial
End Sub

Private Sub AppStart
    RunNative ("start_oled",Null)
End Sub

#if C
#include <Wire.h>

void start_oled(B4R::Object* o)
{
    Wire.begin();        // init i2c bus
    Wire.setClock(400000);  //400khz
    
    //oled init.
     unsigned char addr=0x3C;

    Wire.beginTransmission(addr);
    Wire.write(0x00);   
    Wire.write(0xAE);
    Wire.endTransmission();
    Wire.beginTransmission(addr);
    Wire.write(0x00);   
    Wire.write(0x8D);
    Wire.endTransmission();
    Wire.beginTransmission(addr);
    Wire.write(0x00);   
    Wire.write(0x14);
    Wire.endTransmission();     
    Wire.beginTransmission(addr);
    Wire.write(0x00);   
    Wire.write(0x20);
    Wire.endTransmission();     
    Wire.beginTransmission(addr);
    Wire.write(0x00);   
    Wire.write(0x00);
    Wire.endTransmission();     
    Wire.beginTransmission(addr);
    Wire.write(0x00);   
    Wire.write(0xA1);
    Wire.endTransmission();
    Wire.beginTransmission(addr);
    Wire.write(0x00);   
    Wire.write(0xC8);
    Wire.endTransmission();
    Wire.beginTransmission(addr);
    Wire.write(0x00);   
    Wire.write(0xDA);
    Wire.endTransmission();     
    Wire.beginTransmission(addr);
    Wire.write(0x00);   
    Wire.write(0x12);
    Wire.endTransmission();     
    Wire.beginTransmission(addr);
    Wire.write(0x00);   
    Wire.write(0x81);
    Wire.endTransmission();
    Wire.beginTransmission(addr);
    Wire.write(0x00);   
    Wire.write(0x9F);
    Wire.endTransmission();   
    
    Wire.beginTransmission(addr);     //on
    Wire.write(0x00);   
    Wire.write(0xAF);
    Wire.endTransmission();   
    
    //clear scrn
    unsigned char y, x;
 
    for ( y = 0; y < 8; y++ ) {
      for (x = 0; x < 17; x++){
        Wire.beginTransmission(addr);
        Wire.write(0x00);   
        Wire.write(0x21);
        Wire.endTransmission();
        Wire.beginTransmission(addr);
        Wire.write(0x00);   
        Wire.write(8*x);
        Wire.endTransmission();
        Wire.beginTransmission(addr);
        Wire.write(0x00);   
        Wire.write(8*x+7);
        Wire.endTransmission();     
        Wire.beginTransmission(addr);
        Wire.write(0x00);   
        Wire.write(0x22);
        Wire.endTransmission();     
        Wire.beginTransmission(addr);
        Wire.write(0x00);   
        Wire.write(y);
        Wire.endTransmission();     
        Wire.beginTransmission(addr);
        Wire.write(0x00);   
        Wire.write(y);
        Wire.endTransmission();

          Wire.beginTransmission(addr);
          Wire.write(0x40);
          for (unsigned char i = 0; i < 8; i++){
               Wire.write(0x00);         
          }
          Wire.endTransmission();         
      }
    
    }
    //draw bitmap
    
    const unsigned char bmp[] = {  //toothwheel
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFE,
    0xFE, 0xFE, 0xFF, 0xFF, 0xFC, 0xF8, 0xF0, 0xE0, 0xF0, 0xF8, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE,
    0xFE, 0x80, 0x80, 0x80, 0x80, 0xC0, 0xE0, 0xE0, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x0E, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x1F,
    0x1F, 0x0F, 0x07, 0x07, 0x07, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07, 0x07, 0x07, 0x0F, 0x0F,
    0x1F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x9F, 0x07, 0x02, 0x00, 0x00, 0x00, 0x00,
    0xF8, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x07, 0x01, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x01, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x3F,
    0x00, 0x01, 0x81, 0xC1, 0xC3, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xE0, 0x80, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0xC0, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8, 0xF8, 0xF0, 0xE0,
    0x00, 0x00, 0x07, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x0F, 0x0F, 0x3F, 0xFF, 0xFF, 0xFE, 0xFC, 0xF8,
    0xF8, 0xF0, 0xF0, 0xE0, 0xE0, 0xE0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xE0, 0xE0, 0xE0, 0xF0, 0xF0,
    0xF8, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xEF, 0x87, 0x03, 0x03, 0x07, 0x07, 0x07, 0x07, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x1F, 0x1F, 0x3F, 0x3F, 0x3F,
    0x1F, 0x0F, 0x07, 0x07, 0x07, 0x07, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0x03, 0x03,
    0x03, 0x03, 0x07, 0x0F, 0x1F, 0x1F, 0x0F, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
    };   
    
        unsigned char v, h, c;
    
        for (h = 0; h < 6;++h){
           for (c = 0; c < 3;++c){
                Wire.beginTransmission(addr);
                Wire.write(0x00);   
                Wire.write(0x21);
                Wire.endTransmission();
                Wire.beginTransmission(addr);
                Wire.write(0x00);   
                Wire.write(c*16);
                Wire.endTransmission();
                Wire.beginTransmission(addr);
                Wire.write(0x00);   
                Wire.write(16+c*16);
                Wire.endTransmission();     
                Wire.beginTransmission(addr);
                Wire.write(0x00);   
                Wire.write(0x22);
                Wire.endTransmission();     
                Wire.beginTransmission(addr);
                Wire.write(0x00);   
                Wire.write(h);
                Wire.endTransmission();     
                Wire.beginTransmission(addr);
                Wire.write(0x00);   
                Wire.write(h+1);
                Wire.endTransmission();           
          
              Wire.beginTransmission(addr);
              Wire.write(0x40);
              for (v = 0+c*16; v < 16+c*16; ++v){
                 Wire.write(bmp[v+48*h]);
              }
              Wire.endTransmission();     
           }
        }       

}
#End if
 
Last edited:
Upvote 0

Mostez

Well-Known Member
Licensed User
Longtime User
I tried your example it works OK, but the image flickers!
EDIT: it works ok now
 
Last edited:
Upvote 0
Top