Jump to content

Middlefart’s A-10 build


Middlefart
 Share

Recommended Posts

I have to say that you are going to be doing exactly what I planned to do, so I am pulling up a chair! After the success with the 5" CDU, little details like this make all the difference. I have three different OLED displays, for the altitude and pressure, like you have, plus the fuel quantity indication.

 

I don’t suppose you could share the altimeter OLED sketch could you?

 

Cheers, and nice job!

 

 

 

Les


Edited by lesthegrngo
Link to comment
Share on other sites

  • 2 weeks later...

I couldn't go to sleep before I fixed the problem :)

Finally got it working!

 

To create the characters i wrote a C# program that analysed a bitmap of the digits with font MS 33558 and generated the char array in characters.h :thumbup:

 

Below are the two files needed for the sketch.

There are some comments in it but most of it is uncommented. Sorry :music_whistling:

 

characters.h

static const unsigned char PROGMEM c24_0[] =
{ B00000000, B00111100, B00000000,
 B00000000, B11111111, B00000000,
 B00000001, B11111111, B10000000,
 B00000011, B11111111, B11000000,
 B00000111, B11111111, B11100000,
 B00000111, B11000011, B11100000,
 B00001111, B10000001, B11110000,
 B00001111, B10000001, B11110000,
 B00011111, B00000000, B11111000,
 B00011111, B00000000, B11111000,
 B00011110, B00000000, B01111000,
 B00011110, B00000000, B01111000,
 B00111110, B00000000, B01111100,
 B00111110, B00000000, B01111100,
 B00111110, B00000000, B01111100,
 B00111110, B00000000, B01111100,
 B00111110, B00000000, B01111100,
 B00111110, B00000000, B01111100,
 B00111110, B00000000, B01111100,
 B00111110, B00000000, B01111100,
 B00011110, B00000000, B01111000,
 B00011110, B00000000, B01111000,
 B00011111, B00000000, B11111000,
 B00011111, B00000000, B11111000,
 B00001111, B10000001, B11110000,
 B00001111, B10000001, B11110000,
 B00000111, B11000011, B11100000,
 B00000111, B11111111, B11100000,
 B00000011, B11111111, B11000000,
 B00000001, B11111111, B10000000,
 B00000000, B11111111, B00000000,
 B00000000, B00111100, B00000000};

static const unsigned char PROGMEM c24_1[] =
{ B00000000, B00111000, B00000000,
 B00000000, B01111100, B00000000,
 B00000000, B01111100, B00000000,
 B00000000, B01111100, B00000000,
 B00000000, B01111100, B00000000,
 B00000000, B01111100, B00000000,
 B00000000, B01111100, B00000000,
 B00000000, B01111100, B00000000,
 B00000000, B01111100, B00000000,
 B00000000, B01111100, B00000000,
 B00000000, B01111100, B00000000,
 B00000000, B01111100, B00000000,
 B00000000, B01111100, B00000000,
 B00000000, B01111100, B00000000,
 B00000000, B01111100, B00000000,
 B00000000, B01111100, B00000000,
 B00000000, B01111100, B00000000,
 B00000000, B01111100, B00000000,
 B00000000, B01111100, B00000000,
 B00000000, B01111100, B00000000,
 B00000000, B01111100, B00000000,
 B00000000, B01111100, B00000000,
 B00000000, B01111100, B00000000,
 B00000000, B01111100, B00000000,
 B00000000, B01111100, B00000000,
 B00000000, B01111100, B00000000,
 B00000000, B01111100, B00000000,
 B00000000, B01111100, B00000000,
 B00000000, B01111100, B00000000,
 B00000000, B01111100, B00000000,
 B00000000, B01111100, B00000000,
 B00000000, B00111000, B00000000};

static const unsigned char PROGMEM c24_2[] =
{ B00000000, B01111111, B10000000,
 B00000001, B11111111, B11100000,
 B00000011, B11111111, B11110000,
 B00000111, B11111111, B11111000,
 B00000111, B11110011, B11111000,
 B00001111, B11000000, B11111000,
 B00001111, B10000000, B01111100,
 B00001111, B10000000, B01111100,
 B00001111, B10000000, B01111100,
 B00001111, B10000000, B01111100,
 B00000111, B00000000, B01111100,
 B00000000, B00000000, B11111000,
 B00000000, B00000001, B11111000,
 B00000000, B00000011, B11110000,
 B00000000, B00001111, B11100000,
 B00000000, B00111111, B11000000,
 B00000000, B01111111, B10000000,
 B00000000, B11111111, B00000000,
 B00000001, B11111100, B00000000,
 B00000011, B11110000, B00000000,
 B00000111, B11100000, B00000000,
 B00000111, B11000000, B00000000,
 B00001111, B11000000, B00000000,
 B00001111, B10000000, B00000000,
 B00011111, B00000000, B00000000,
 B00011111, B00000000, B00000000,
 B00011110, B00000000, B00000000,
 B00111111, B11111111, B11111000,
 B00111111, B11111111, B11111100,
 B00111111, B11111111, B11111100,
 B00111111, B11111111, B11111100,
 B00011111, B11111111, B11111000};

static const unsigned char PROGMEM c24_3[] =
{ B00001111, B11111111, B11100000,
 B00011111, B11111111, B11110000,
 B00011111, B11111111, B11110000,
 B00001111, B11111111, B11100000,
 B00000000, B00001111, B11100000,
 B00000000, B00001111, B11000000,
 B00000000, B00011111, B10000000,
 B00000000, B00111111, B00000000,
 B00000000, B00111110, B00000000,
 B00000000, B01111110, B00000000,
 B00000000, B11111100, B00000000,
 B00000001, B11111111, B00000000,
 B00000001, B11111111, B10000000,
 B00000001, B11111111, B11100000,
 B00000001, B11111111, B11110000,
 B00000000, B00000011, B11110000,
 B00000000, B00000001, B11111000,
 B00000000, B00000000, B11111000,
 B00000000, B00000000, B01111100,
 B00000000, B00000000, B01111100,
 B00000000, B00000000, B00111100,
 B00111100, B00000000, B00111100,
 B00111100, B00000000, B01111100,
 B00111110, B00000000, B01111100,
 B00111110, B00000000, B01111100,
 B00011111, B00000000, B11111000,
 B00011111, B10000001, B11111000,
 B00001111, B11100111, B11110000,
 B00000111, B11111111, B11100000,
 B00000011, B11111111, B11000000,
 B00000001, B11111111, B10000000,
 B00000000, B01111110, B00000000};

static const unsigned char PROGMEM c24_4[] =
{ B00000000, B01110000, B00000000,
 B00000000, B11111000, B00000000,
 B00000000, B11111000, B00000000,
 B00000001, B11111000, B00000000,
 B00000001, B11111000, B00000000,
 B00000001, B11110000, B00000000,
 B00000011, B11110000, B00000000,
 B00000011, B11110000, B00000000,
 B00000011, B11100000, B00000000,
 B00000111, B11100000, B00000000,
 B00000111, B11100000, B00000000,
 B00000111, B11000000, B00000000,
 B00000111, B11000000, B00000000,
 B00001111, B11000011, B10000000,
 B00001111, B10000111, B11000000,
 B00001111, B10000111, B11000000,
 B00011111, B10000111, B11000000,
 B00011111, B00000111, B11000000,
 B00011111, B00000111, B11000000,
 B00111111, B00000111, B11000000,
 B00111110, B00000111, B11000000,
 B00111110, B00000111, B11000000,
 B01111111, B11111111, B11111100,
 B01111111, B11111111, B11111110,
 B01111111, B11111111, B11111110,
 B01111111, B11111111, B11111110,
 B00111111, B11111111, B11111100,
 B00000000, B00000111, B11000000,
 B00000000, B00000111, B11000000,
 B00000000, B00000111, B11000000,
 B00000000, B00000111, B11000000,
 B00000000, B00000011, B10000000};
 
static const unsigned char PROGMEM c24_5[] =
{ B00001111, B11111111, B10000000,
 B00011111, B11111111, B11000000,
 B00011111, B11111111, B11000000,
 B00011111, B11111111, B11000000,
 B00011111, B11111111, B10000000,
 B00011111, B00000000, B00000000,
 B00011111, B00000000, B00000000,
 B00011111, B00000000, B00000000,
 B00011111, B00000000, B00000000,
 B00011111, B00000000, B00000000,
 B00011111, B00000000, B00000000,
 B00011111, B11111110, B00000000,
 B00011111, B11111111, B10000000,
 B00011111, B11111111, B11000000,
 B00011111, B11111111, B11100000,
 B00011111, B10000111, B11110000,
 B00001110, B00000001, B11111000,
 B00000000, B00000000, B11111000,
 B00000000, B00000000, B01111100,
 B00000000, B00000000, B01111100,
 B00000000, B00000000, B00111100,
 B00000000, B00000000, B00111100,
 B00000000, B00000000, B00111100,
 B00000000, B00000000, B01111100,
 B00011000, B00000000, B01111100,
 B00111100, B00000000, B11111000,
 B00111111, B00000001, B11111000,
 B00111111, B11000111, B11110000,
 B00011111, B11111111, B11100000,
 B00001111, B11111111, B11000000,
 B00000011, B11111111, B10000000,
 B00000000, B11111110, B00000000};
 
static const unsigned char PROGMEM c24_6[] =
{ B00000000, B00000111, B00000000,
 B00000000, B00001111, B10000000,
 B00000000, B00011111, B10000000,
 B00000000, B00111111, B00000000,
 B00000000, B01111110, B00000000,
 B00000000, B11111100, B00000000,
 B00000001, B11111000, B00000000,
 B00000011, B11110000, B00000000,
 B00000111, B11100000, B00000000,
 B00000111, B11000000, B00000000,
 B00001111, B10000000, B00000000,
 B00001111, B11111110, B00000000,
 B00011111, B11111111, B10000000,
 B00011111, B11111111, B11000000,
 B00111111, B11111111, B11100000,
 B00111111, B11000111, B11110000,
 B00111111, B00000001, B11111000,
 B01111110, B00000000, B11111000,
 B01111100, B00000000, B01111100,
 B01111100, B00000000, B01111100,
 B01111000, B00000000, B00111100,
 B01111000, B00000000, B00111100,
 B01111000, B00000000, B00111100,
 B01111100, B00000000, B01111100,
 B01111100, B00000000, B01111100,
 B00111110, B00000000, B11111000,
 B00111111, B00000001, B11111000,
 B00011111, B11000111, B11110000,
 B00001111, B11111111, B11100000,
 B00000111, B11111111, B11000000,
 B00000011, B11111111, B10000000,
 B00000000, B11111110, B00000000};

static const unsigned char PROGMEM c24_7[] =
{ B00001111, B11111111, B11110000,
 B00011111, B11111111, B11111000,
 B00011111, B11111111, B11111000,
 B00011111, B11111111, B11111000,
 B00001111, B11111111, B11111000,
 B00000000, B00000001, B11110000,
 B00000000, B00000001, B11110000,
 B00000000, B00000011, B11110000,
 B00000000, B00000011, B11100000,
 B00000000, B00000011, B11100000,
 B00000000, B00000111, B11100000,
 B00000000, B00000111, B11000000,
 B00000000, B00000111, B11000000,
 B00000000, B00001111, B11000000,
 B00000000, B00001111, B10000000,
 B00000000, B00001111, B10000000,
 B00000000, B00011111, B10000000,
 B00000000, B00011111, B00000000,
 B00000000, B00011111, B00000000,
 B00000000, B00111111, B00000000,
 B00000000, B00111110, B00000000,
 B00000000, B00111110, B00000000,
 B00000000, B01111110, B00000000,
 B00000000, B01111100, B00000000,
 B00000000, B01111100, B00000000,
 B00000000, B11111100, B00000000,
 B00000000, B11111000, B00000000,
 B00000000, B11111000, B00000000,
 B00000001, B11111000, B00000000,
 B00000001, B11110000, B00000000,
 B00000001, B11110000, B00000000,
 B00000000, B11100000, B00000000};

static const unsigned char PROGMEM c24_8[] =
{ B00000000, B01111110, B00000000,
 B00000001, B11111111, B10000000,
 B00000011, B11111111, B11000000,
 B00000111, B11111111, B11100000,
 B00001111, B11100111, B11110000,
 B00001111, B10000001, B11110000,
 B00011111, B00000000, B11111000,
 B00011111, B00000000, B11111000,
 B00011110, B00000000, B01111000,
 B00011110, B00000000, B01111000,
 B00011111, B00000000, B11111000,
 B00011111, B00000000, B11111000,
 B00001111, B10000001, B11110000,
 B00001111, B11100111, B11110000,
 B00000111, B11111111, B11100000,
 B00000011, B11111111, B11000000,
 B00000011, B11111111, B11000000,
 B00000111, B11111111, B11100000,
 B00001111, B11100111, B11110000,
 B00001111, B10000001, B11110000,
 B00011111, B00000000, B11111000,
 B00011111, B00000000, B11111000,
 B00011110, B00000000, B01111000,
 B00011110, B00000000, B01111000,
 B00011111, B00000000, B11111000,
 B00011111, B00000000, B11111000,
 B00001111, B10000001, B11110000,
 B00001111, B11100111, B11110000,
 B00000111, B11111111, B11100000,
 B00000011, B11111111, B11000000,
 B00000001, B11111111, B10000000,
 B00000000, B01111110, B00000000};

static const unsigned char PROGMEM c24_9[] =
{ B00000000, B11111110, B00000000,
 B00000011, B11111111, B10000000,
 B00000111, B11111111, B11000000,
 B00001111, B11111111, B11100000,
 B00011111, B11000111, B11110000,
 B00111111, B00000001, B11111000,
 B00111110, B00000000, B11111000,
 B01111100, B00000000, B01111100,
 B01111100, B00000000, B01111100,
 B01111000, B00000000, B00111100,
 B01111000, B00000000, B00111100,
 B01111000, B00000000, B00111100,
 B01111100, B00000000, B01111100,
 B01111100, B00000000, B01111100,
 B00111110, B00000000, B11111100,
 B00111111, B00000001, B11111000,
 B00011111, B11000111, B11111000,
 B00001111, B11111111, B11110000,
 B00000111, B11111111, B11110000,
 B00000011, B11111111, B11100000,
 B00000000, B11111111, B11100000,
 B00000000, B00001111, B11000000,
 B00000000, B00001111, B10000000,
 B00000000, B00011111, B10000000,
 B00000000, B00111111, B00000000,
 B00000000, B11111110, B00000000,
 B00000001, B11111100, B00000000,
 B00000111, B11111000, B00000000,
 B00001111, B11110000, B00000000,
 B00011111, B11000000, B00000000,
 B00011111, B10000000, B00000000,
 B00001110, B00000000, B00000000};

static const unsigned char PROGMEM c24_Empty[] =
{ B00111000, B00001111, B11000000,
B00111100, B00000111, B11100000,
B00111110, B00000011, B11110000,
B00111111, B00000001, B11111000,
B00011111, B10000000, B11111100,
B00001111, B11000000, B01111100,
B00000111, B11100000, B00111100,
B00000011, B11110000, B00011100,
B00000001, B11111000, B00001100,
B00000000, B11111100, B00000100,
B00000000, B01111110, B00000000,
B00100000, B00111111, B00000000,
B00110000, B00011111, B10000000,
B00111000, B00001111, B11000000,
B00111100, B00000111, B11100000,
B00111110, B00000011, B11110000,
B00111111, B00000001, B11111000,
B00011111, B10000000, B11111100,
B00001111, B11000000, B01111100,
B00000111, B11100000, B00111100,
B00000011, B11110000, B00011100,
B00000001, B11111000, B00001100,
B00000000, B11111100, B00000100,
B00000000, B01111110, B00000000,
B00100000, B00111111, B00000000,
B00110000, B00011111, B10000000,
B00111000, B00001111, B11000000,
B00111100, B00000111, B11100000,
B00111110, B00000011, B11110000,
B00111111, B00000001, B11111000,
B00011111, B10000000, B11111100,
B00001111, B11000000, B01111100 };

static const unsigned char PROGMEM c16_0[] =
{ B00000011, B11000000,
B00000111, B11100000,
B00001111, B11110000,
B00011111, B11111000,
B00011110, B01111000,
B00111100, B00111100,
B00111000, B00011100,
B01111000, B00011110,
B01110000, B00001110,
B01110000, B00001110,
B01110000, B00001110,
B01110000, B00001110,
B01110000, B00001110,
B01110000, B00001110,
B01110000, B00001110,
B01110000, B00001110,
B01111000, B00011110,
B00111000, B00011100,
B00111100, B00111100,
B00011110, B01111000,
B00011111, B11111000,
B00001111, B11110000,
B00000111, B11100000,
B00000011, B11000000 };

static const unsigned char PROGMEM c16_1[] =
{ B00000001, B10000000,
B00000011, B11000000,
B00000011, B11000000,
B00000011, B11000000,
B00000011, B11000000,
B00000011, B11000000,
B00000011, B11000000,
B00000011, B11000000,
B00000011, B11000000,
B00000011, B11000000,
B00000011, B11000000,
B00000011, B11000000,
B00000011, B11000000,
B00000011, B11000000,
B00000011, B11000000,
B00000011, B11000000,
B00000011, B11000000,
B00000011, B11000000,
B00000011, B11000000,
B00000011, B11000000,
B00000011, B11000000,
B00000011, B11000000,
B00000011, B11000000,
B00000001, B10000000 };

static const unsigned char PROGMEM c16_2[] =
{ B00000011, B11110000,
B00001111, B11111000,
B00011111, B11111100,
B00011110, B00111110,
B00111100, B00011110,
B00111000, B00001111,
B00111000, B00001111,
B00010000, B00001111,
B00000000, B00011110,
B00000000, B00111110,
B00000000, B01111100,
B00000001, B11111000,
B00000011, B11110000,
B00000111, B11100000,
B00001111, B10000000,
B00011111, B00000000,
B00111110, B00000000,
B00111100, B00000000,
B01111100, B00000000,
B01111000, B00000000,
B11111111, B11111100,
B11111111, B11111110,
B11111111, B11111110,
B01111111, B11111100 };

static const unsigned char PROGMEM c16_3[] =
{ B00111111, B11111000,
B01111111, B11111100,
B01111111, B11111000,
B00111111, B11111000,
B00000000, B11110000,
B00000001, B11100000,
B00000011, B11000000,
B00000111, B10000000,
B00001111, B11100000,
B00001111, B11110000,
B00001111, B11111000,
B00000000, B01111100,
B00000000, B00111100,
B00000000, B00011110,
B00000000, B00011110,
B00000000, B00001110,
B11100000, B00001110,
B11110000, B00001110,
B11110000, B00011110,
B01111000, B00111100,
B01111100, B01111100,
B00111111, B11111000,
B00011111, B11110000,
B00001111, B11100000 };

static const unsigned char PROGMEM c16_4[] =
{ B00000001, B10000000,
B00000011, B11000000,
B00000011, B11000000,
B00000111, B11000000,
B00000111, B10000000,
B00000111, B10000000,
B00001111, B10000000,
B00001111, B00000000,
B00001111, B00000000,
B00011111, B00000000,
B00011110, B00110000,
B00011110, B01111000,
B00111110, B01111000,
B00111100, B01111000,
B00111100, B01111000,
B01111100, B01111000,
B01111111, B11111110,
B01111111, B11111111,
B01111111, B11111111,
B00111111, B11111110,
B00000000, B01111000,
B00000000, B01111000,
B00000000, B01111000,
B00000000, B00110000 };

static const unsigned char PROGMEM c16_5[] =
{ B00111111, B11100000,
B01111111, B11110000,
B01111111, B11110000,
B01111111, B11100000,
B01110000, B00000000,
B01110000, B00000000,
B01110000, B00000000,
B01110000, B00000000,
B01111111, B11100000,
B01111111, B11110000,
B01111111, B11111000,
B01111000, B01111100,
B00110000, B00111110,
B00000000, B00011110,
B00000000, B00001110,
B00000000, B00001110,
B00000000, B00001110,
B00000000, B00001110,
B01110000, B00011110,
B01111000, B00111100,
B01111100, B01111100,
B00111111, B11111000,
B00011111, B11110000,
B00001111, B11100000 };

static const unsigned char PROGMEM c16_6[] =
{ B00000000, B11100000,
B00000001, B11110000,
B00000011, B11100000,
B00000111, B11000000,
B00001111, B10000000,
B00011111, B00000000,
B00011110, B00000000,
B00111100, B00000000,
B00111111, B11000000,
B01111111, B11110000,
B01111111, B11111000,
B11111100, B01111100,
B11111000, B00111100,
B11110000, B00011110,
B11100000, B00001110,
B11100000, B00001110,
B11100000, B00001110,
B11100000, B00001110,
B11110000, B00011110,
B01111000, B00111100,
B01111100, B01111100,
B00111111, B11111000,
B00011111, B11110000,
B00000111, B11000000 };

static const unsigned char PROGMEM c16_7[] =
{ B00111111, B11111100,
B01111111, B11111110,
B01111111, B11111110,
B00111111, B11111100,
B00000000, B00111100,
B00000000, B00111100,
B00000000, B01111000,
B00000000, B01111000,
B00000000, B01111000,
B00000000, B11110000,
B00000000, B11110000,
B00000000, B11110000,
B00000001, B11100000,
B00000001, B11100000,
B00000001, B11100000,
B00000011, B11000000,
B00000011, B11000000,
B00000011, B11000000,
B00000111, B10000000,
B00000111, B10000000,
B00000111, B10000000,
B00001111, B00000000,
B00001111, B00000000,
B00000110, B00000000 };

static const unsigned char PROGMEM c16_8[] =
{ B00000111, B11100000,
B00001111, B11110000,
B00011111, B11111000,
B00111110, B01111100,
B01111000, B00011110,
B01111000, B00011110,
B01110000, B00001110,
B01110000, B00001110,
B01111000, B00011110,
B00111000, B00011100,
B00111110, B01111100,
B00011111, B11111000,
B00011111, B11111000,
B00111110, B01111100,
B00111000, B00011100,
B01111000, B00011110,
B01110000, B00001110,
B01110000, B00001110,
B01111000, B00011110,
B01111000, B00011110,
B00111110, B01111100,
B00011111, B11111000,
B00001111, B11110000,
B00000111, B11100000 };

static const unsigned char PROGMEM c16_9[] =
{ B00000111, B11000000,
B00011111, B11110000,
B00111111, B11111000,
B01111100, B01111100,
B01111000, B00111100,
B11110000, B00011110,
B11100000, B00001110,
B11100000, B00001110,
B11100000, B00001110,
B11100000, B00001110,
B11110000, B00011110,
B01111000, B00111110,
B01111100, B01111100,
B00111111, B11111100,
B00011111, B11111000,
B00000111, B11111000,
B00000000, B11110000,
B00000001, B11110000,
B00000011, B11100000,
B00000111, B11000000,
B00001111, B10000000,
B00011111, B00000000,
B00111110, B00000000,
B00111100, B00000000 };

static const unsigned char PROGMEM c16_Empty[] =
{ B00110000, B01111100,
B00111000, B00111100,
B00111100, B00011100,
B00111110, B00001100,
B00011111, B00000100,
B00001111, B10000000,
B00000111, B11000000,
B00000011, B11100000,
B00000001, B11110000,
B00100000, B11111000,
B00110000, B01111100,
B00111000, B00111100,
B00111100, B00011100,
B00111110, B00001100,
B00011111, B00000100,
B00001111, B10000000,
B00000111, B11000000,
B00000011, B11100000,
B00000001, B11110000,
B00100000, B11111000,
B00110000, B01111100,
B00111000, B00111100,
B00111100, B00011100,
B00111110, B00001100 };

 

Displays.ino

#define DCSBIOS_DEFAULT_SERIAL

#include "DcsBios.h"

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include "characters.h"

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels
#define OLED_RESET     4 // Reset pin # (or -1 if sharing Arduino reset pin)

//Comment for barometric pressure
#define ALTIMETER

int updateInterval = 100; //the number of milliseconds between updates

struct scrollDigit {
 int digit; //The digit that is displayed
 int y; // The vertical position of the digit
};

struct disp {
 Adafruit_SSD1306 display;
 int width;
 int numberOfDigits;
 scrollDigit digits[5];
};

#ifdef ALTIMETER
 disp oled = {Adafruit_SSD1306(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET), 24, 5, {{0,0},{0,0},{0,0},{0,0},{0,0}}};
#else
 disp oled = {Adafruit_SSD1306(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET), 16, 4, {{0,0},{0,0},{0,0},{0,0},{0,0}}};
#endif

void setup() {
 if(!oled.display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3C for 128x32
   for(;;); // Don't proceed, loop forever
 }

 DcsBios::setup();
}

void UpdateDisplay()
{
 oled.display.clearDisplay();
 for (int i = 0; i < oled.numberOfDigits; i++)
 {
   printScrollingDigit(oled.digits[i].digit, oled.width, oled.digits[i].y, i + 1, &oled);
 }
 //Clear the area below the the numbers if we are using the small font
 if (oled.width == 16)
 {
   oled.display.fillRect(0, 25, 67, 7, BLACK);
 }
 
 oled.display.display();
}

int YPos()
{
 return (oled.width + 9) * -1;
}

void printScrollingDigit(int digit, int width, int y, int pos, disp *oled)
{
 int x = (width * pos) - width + pos;
#ifdef ALTIMETER
   switch (digit)
   {
     case -1: oled->display.drawBitmap(x, y, c24_Empty, 24, 32, 1); oled->display.drawBitmap(x, y+33, c24_1, 24, 32, 1); break;
     case 1: oled->display.drawBitmap(x, y, c24_1, 24, 32, 1); oled->display.drawBitmap(x, y+33, c24_2, 24, 32, 1); break;
     case 2: oled->display.drawBitmap(x, y, c24_2, 24, 32, 1); oled->display.drawBitmap(x, y+33, c24_3, 24, 32, 1); break;
     case 3: oled->display.drawBitmap(x, y, c24_3, 24, 32, 1); oled->display.drawBitmap(x, y+33, c24_4, 24, 32, 1); break;
     case 4: oled->display.drawBitmap(x, y, c24_4, 24, 32, 1); oled->display.drawBitmap(x, y+33, c24_5, 24, 32, 1); break;
     case 5: oled->display.drawBitmap(x, y, c24_5, 24, 32, 1); oled->display.drawBitmap(x, y+33, c24_6, 24, 32, 1); break;
     case 6: oled->display.drawBitmap(x, y, c24_6, 24, 32, 1); oled->display.drawBitmap(x, y+33, c24_7, 24, 32, 1); break;
     case 7: oled->display.drawBitmap(x, y, c24_7, 24, 32, 1); oled->display.drawBitmap(x, y+33, c24_8, 24, 32, 1); break;
     case 8: oled->display.drawBitmap(x, y, c24_8, 24, 32, 1); oled->display.drawBitmap(x, y+33, c24_9, 24, 32, 1); break;
     case 9: oled->display.drawBitmap(x, y, c24_9, 24, 32, 1); oled->display.drawBitmap(x, y+33, c24_0, 24, 32, 1); break;
     default: oled->display.drawBitmap(x, y, c24_0, 24, 32, 1); oled->display.drawBitmap(x, y+33, c24_1, 24, 32, 1); break;
   }
#else
   switch (digit)
   {
     case -1: oled->display.drawBitmap(x, y, c16_Empty, 16, 24, 1); oled->display.drawBitmap(x, y+25, c16_1, 16, 24, 1); break;
     case 1: oled->display.drawBitmap(x, y, c16_1, 16, 24, 1); oled->display.drawBitmap(x, y+25, c16_2, 16, 24, 1); break;
     case 2: oled->display.drawBitmap(x, y, c16_2, 16, 24, 1); oled->display.drawBitmap(x, y+25, c16_3, 16, 24, 1); break;
     case 3: oled->display.drawBitmap(x, y, c16_3, 16, 24, 1); oled->display.drawBitmap(x, y+25, c16_4, 16, 24, 1); break;
     case 4: oled->display.drawBitmap(x, y, c16_4, 16, 24, 1); oled->display.drawBitmap(x, y+25, c16_5, 16, 24, 1); break;
     case 5: oled->display.drawBitmap(x, y, c16_5, 16, 24, 1); oled->display.drawBitmap(x, y+25, c16_6, 16, 24, 1); break;
     case 6: oled->display.drawBitmap(x, y, c16_6, 16, 24, 1); oled->display.drawBitmap(x, y+25, c16_7, 16, 24, 1); break;
     case 7: oled->display.drawBitmap(x, y, c16_7, 16, 24, 1); oled->display.drawBitmap(x, y+25, c16_8, 16, 24, 1); break;
     case 8: oled->display.drawBitmap(x, y, c16_8, 16, 24, 1); oled->display.drawBitmap(x, y+25, c16_9, 16, 24, 1); break;
     case 9: oled->display.drawBitmap(x, y, c16_9, 16, 24, 1); oled->display.drawBitmap(x, y+25, c16_0, 16, 24, 1); break;
     default: oled->display.drawBitmap(x, y, c16_0, 16, 24, 1); oled->display.drawBitmap(x, y+25, c16_1, 16, 24, 1); break;
   }
#endif
}

#ifdef ALTIMETER
 void onAlt10000FtChange(unsigned int newValue)
 {
   if (newValue == 6553)
   {
     oled.digits[0].digit = 1;
     oled.digits[0].y = 0;
   }
   else if (newValue == 0)
   {
     oled.digits[0].digit = -1;
     oled.digits[0].y = 0;
   }
   else
   {
     oled.digits[0].digit = -1;
     oled.digits[0].y = map(newValue, 0, 6553, 0, YPos());
   }
 }
 
 void onAlt1000FtChange(unsigned int newValue)
 {
   unsigned int mappedValue = newValue / 6553;
   unsigned int y = map(newValue, mappedValue * 6553, mappedValue * 6553 + 6553, 0, YPos());
 
   oled.digits[1].digit = mappedValue;
   oled.digits[1].y = y;
 }
 
 void onAlt100FtChange(unsigned int newValue)
 {
   unsigned int mappedValue = newValue / 6553;
   unsigned int y = map(newValue, mappedValue * 6553, mappedValue * 6553 + 6553, 0, YPos());
 
   oled.digits[2].digit = mappedValue;
   oled.digits[2].y = y;
 }
 
 DcsBios::IntegerBuffer Alt10000FtBuffer(0x1080, 0xffff, 0, onAlt10000FtChange);
 DcsBios::IntegerBuffer Alt1000FtBuffer(0x1082, 0xffff, 0, onAlt1000FtChange);
 DcsBios::IntegerBuffer Alt100FtBuffer(0x1084, 0xffff, 0, onAlt100FtChange);
#else
 void onBaro0Change(unsigned int newValue)
 {
   unsigned int mappedValue = newValue / 6554;
   unsigned int y = map(newValue, mappedValue * 6554, mappedValue * 6554 + 6554, 0, YPos());
 
   oled.digits[3].digit = mappedValue;
   oled.digits[3].y = y;
 }
 
 void onBaro1Change(unsigned int newValue)
 {
   unsigned int mappedValue = newValue / 6554;
   unsigned int y = map(newValue, mappedValue * 6554, mappedValue * 6554 + 6554, 0, YPos());
 
   oled.digits[2].digit = mappedValue;
   oled.digits[2].y = y;
 }
 
 void onBaro2Change(unsigned int newValue)
 {
   unsigned int mappedValue = newValue / 6554;
   unsigned int y = map(newValue, mappedValue * 6554, mappedValue * 6554 + 6554, 0, YPos());
 
   oled.digits[1].digit = mappedValue;
   oled.digits[1].y = y;
 }
 
 void onBaro3Change(unsigned int newValue)
 {
   unsigned int mappedValue = newValue / 6554;
   unsigned int y = map(newValue, mappedValue * 6554, mappedValue * 6554 + 6554, 0, YPos());
 
   oled.digits[0].digit = mappedValue;
   oled.digits[0].y = y;
 }

 DcsBios::IntegerBuffer Baro0Buffer(0x1086, 0xffff, 0, onBaro0Change);
 DcsBios::IntegerBuffer Baro1Buffer(0x1088, 0xffff, 0, onBaro1Change);
 DcsBios::IntegerBuffer Baro2Buffer(0x108a, 0xffff, 0, onBaro2Change);
 DcsBios::IntegerBuffer Baro3Buffer(0x108c, 0xffff, 0, onBaro3Change);
#endif

unsigned long time = 0;

void loop() {
 DcsBios::loop();

 time = millis();
 if (time % updateInterval == 0)
 {
   UpdateDisplay();
 }
}


Edited by Middlefart
Link to comment
Share on other sites

Middlefart’s A-10 build

 

I have to say that you are going to be doing exactly what I planned to do, so I am pulling up a chair! After the success with the 5" CDU, little details like this make all the difference. I have three different OLED displays, for the altitude and pressure, like you have, plus the fuel quantity indication.

 

 

 

I don’t suppose you could share the altimeter OLED sketch could you?

 

 

 

Cheers, and nice job!

 

 

 

 

 

 

 

Les

 

 

 

Sorry about the delay but I've finally have the sketch you asked for if you look in the post prior to his one.


Edited by Middlefart
Link to comment
Share on other sites

Sorry about the delay but I've finally have the sketch you asked for if you look in the post prior to his one.

 

Thanks! I'm currently away from home on a short holiday, but you can bet that this will be one of the first things I get to when I'm back!

 

How's the rest of your rig getting on?

 

Cheers

 

Les

Link to comment
Share on other sites

Its getting along

I’ve started with the left console.

Ordered 2 Leo Bodnar BBI-64 for the inputs but they where broken upon arrival.

They sent me new ones and I managed to repair the 2 first ones so now I have 4

2399936a3ba7f7cd5d5885532705928d.jpg

 

336cb0d310b48e942d133de406b80f62.jpg

 

I've got quite a few Bodnar boards, I got them for the race car sim I built a few years ago, and I was lucky that none ever arrived damaged

 

Having said that, looks like you got lucky in managing to have ones that were repairable, and from my experience with them they will do a great job. It's also heartening to see that their customer support is equally good

 

Cheers

 

Les

Link to comment
Share on other sites

Middlefart’s A-10 build

 

I have gotten some requests for my PCB's.

I've put them up on DropBox. https://www.dropbox.com/sh/mvq1unpin486cq2/AABHh8ZgI4w9O59qV5Jn6Ogya?dl=0

 

They are created in Fritzing, so you need to get that.

It was free when I started using it but now it costs $8

https://fritzing.org/download/

 

Note that the Nano-board is not tested yet.

 

I'll add a list of components later.

But I'ts really not much.

Some RJ45 contacts, MAX487 Chip, 220Ohm resistors and a trim potentiometer of your choice :)

 

In the dropbox folder there is also a RJ45 Pinout. You need to create some sort of main board where you can connect all cards to eachother and provide them with Ground and +5V. +12 V is not being used at the moment but can be provided for future use.

The Nano and the Engline Cluster boards have 2 RJ45 connectors so that they can be daisy chained.


Edited by Middlefart
Link to comment
Share on other sites

  • 2 weeks later...
Sorry about the delay but I've finally have the sketch you asked for if you look in the post prior to his one.

 

Hi there again

 

Finally back with my rig and tried out your sketch, and it works, I can see the text and it scrolls nicely. However the OLED panel I am using must be slightly different, as there is a wrapping effect, presumably where the text size is too big for my OLED

 

I'm using a 128 x 32 pixel display from Buydisplay.

 

Is there a way to reduce the character size within the sketch, or is that set but the Characters.h file?

 

Cheers!

 

Les

Link to comment
Share on other sites

I’m also using 128x32 so that should work.

You need to change characters.h if you want to change the font size but there are also some places (pretty many) in the sketch where the size is hard coded.

 

Could you show a photo of the problem? Maybe it is something I can fix

Link to comment
Share on other sites

Here you go. It looks like the OLED is displaying the characters too wide, so they are overlapping.

 

Maybe by not displaying the last two zeros it will fit, the two missing zeros can be added to the gauge face. I'd still be interested in knowing how to reduce the text width though

 

***Edit****

 

I am convinced that the OLED that I am trying to use is the cause of my errors on this, rather than your code. I can play around with the code and I can improve it, but I have come to the conclusion that the OLED's I have from Buydisplay use a different coding and library set. If nothing else, everything is displayed back to front, mirror style . Can I ask you what the OLED module you have is? Was it purchased from anywhere in particular? I would like to get one to try it out, as I think it will same me a load of hassle. My ones are the 0.91 in versions, the one in the video looks larger (maybe 2.2 inch?)

 

 

Cheers

 

Les

20200304_075949.thumb.jpg.176d4cd8511a4f7b992af035a0376142.jpg


Edited by lesthegrngo
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...