Jump to content

Recommended Posts

Posted (edited)

Hi all, I am trying to update my ILS panel with a 2.23 SSD1305 128X32 OLED panel. I have the following simple sketch but it is generating the errors below


#define DCSBIOS_IRQ_SERIAL

#include <DcsBios.h>
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1305.h>

// Used for software SPI
#define OLED_CLK 8
#define OLED_MOSI 9

// Used for software or hardware SPI
#define OLED_CS 12
#define OLED_DC 11

// Used for I2C or SPI
#define OLED_RESET 10

// software SPI
//Adafruit_SSD1305 display(128, 32, OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);
// hardware SPI - use 7Mhz (7000000UL) or lower because the screen is rated for 4MHz, or it will remain blank!
Adafruit_SSD1305 display(128, 32, &SPI, OLED_DC, OLED_RESET, OLED_CS, 6000000UL);

// I2C
//Adafruit_SSD1305 display(128, 64, &Wire, OLED_RESET);


void setup() {
  Serial.begin(9600);
  DcsBios::setup();
}

void onIlsMhzChange(char* newValue) {
  display.setCursor(0, 0);
  display.print(newValue);
}
DcsBios::StringBuffer<3> ilsMhzStrBuffer(0x116e, onIlsMhzChange);

void onIlsKhzChange(char* newValue) {
  display.setCursor(50, 0);
  display.print(newValue);
}
DcsBios::StringBuffer<2> ilsKhzStrBuffer(0x1172, onIlsKhzChange);



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

 

These are the errors

HardwareSerial0.cpp.o (symbol from plugin): In function `Serial':
(.text+0x0): multiple definition of `__vector_18'
C:\Users\LES\AppData\Local\Temp\arduino\sketches\A037ED41BCCC8E76B075F474E42FD7AF\sketch\ssd1305testILS_copy_20230603100723.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
Multiple libraries were found for "Adafruit_GFX.h"
  Used: F:\Users\LES\Documents\Arduino\libraries\Adafruit_GFX_Library
  Not used: F:\Users\LES\Documents\Arduino\libraries\arduino_196778
exit status 1

Compilation error: exit status 1

I tried it with the hardware SPI constructor and it gives the same error message

Can anyone advise on this? I have restarted the PC in order to flush any temporary files, although not sure that guarantees it. This should be a simple one, but it is the first time I have used the SSD1305 library

Cheers

 

Les

 

Edited by lesthegrngo
Posted (edited)

Hi Les,

why don't you use the standard hardware SPI pins?

For the NANO they are as follows:

10 CS, 11 MOSI, 12 MISO, 13 CLK

DC may be set to 9 and Reset to 8 or so.

 

Regards, Vinc

Edited by Vinc_Vega

Regards, Vinc

real life: Royal Bavarian Airforce

online: VJS-GermanKnights.de

[sIGPIC][/sIGPIC]

Posted (edited)

the pin selection was just for ease of test connections, using a straight JST header, so I can certainly redo the pins in line with that

Just tried it, still generates the same error

Cheers

Les

Edited by lesthegrngo
Posted

Hi Vinc, yes, and that was with the first wiring setup - it worked fine for the both the hardware and software modes, including with the rearranged pins. There's obviously something injected by the DCS Bios part that it doesn't like 

 

Cheers

 

Les

Posted (edited)

...

Edit: And don't forget to remove the Serial statement from the setup section 😉

Regards, Vinc

Edited by Vinc_Vega

Regards, Vinc

real life: Royal Bavarian Airforce

online: VJS-GermanKnights.de

[sIGPIC][/sIGPIC]

  • 2 weeks later...
Posted

I've got my ILS panel working with this OLED, however with a bug; it will correctly display the MHz and KHz values, but when you then use the rotary encoders to change the values, instead of clearing the previous value and displaying the new one, it adds the new value to the old one.

I tried using the clearDisplay function, but all that ends up doing is clearing the display completely, then displaying just the KHz value; when either the MHz or the KHz RE's are moved, it will display just the new value, and then after a second just display the KHz value. Clearly my use of the clearDisplay is not right . The sketch is included below with the clearDisplay instances commented out. I tried both in the setup and loop areas and it seems to be the same

 


#define DCSBIOS_IRQ_SERIAL

#include <DcsBios.h>
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1305.h>
#include "Fonts/FreeSans18pt7b.h"

// Used for software SPI
#define OLED_CLK 13
#define OLED_MOSI 11

// Used for software or hardware SPI
#define OLED_CS 8
#define OLED_DC 9

// Used for I2C or SPI
#define OLED_RESET 10

// software SPI
//Adafruit_SSD1305 display(128, 32, OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);
// hardware SPI - use 7Mhz (7000000UL) or lower because the screen is rated for 4MHz, or it will remain blank!
Adafruit_SSD1305 display(128, 32, &SPI, OLED_DC, OLED_RESET, OLED_CS, 6000000UL);

// I2C
//Adafruit_SSD1305 display(128, 64, &Wire, OLED_RESET);


void setup()   {                
   {

  display.begin(0x3C); 
  

  delay(1000);
  display.clearDisplay();   // clears the screen and buffer
  
}
DcsBios::setup();
}

DcsBios::RotaryEncoder ilsVol("ILS_VOL", "-3200", "+3200", 16, 17);

DcsBios::RotaryEncoder ilsKhz("ILS_KHZ", "DEC", "INC", 18, 19);

DcsBios::RotaryEncoder ilsMhz("ILS_MHZ", "DEC", "INC", 15, 14);


void loop() {
  DcsBios::loop();
//display.clearDisplay();

display.setFont(&FreeSans18pt7b);
  display.setTextColor(WHITE);
  display.setCursor(66, 27);
  display.println(".");
  display.display();
}

 void onIlsMhzChange(char* newValue) {
  display.setFont(&FreeSans18pt7b);
  //display.clearDisplay();
  display.setTextColor(WHITE);
  display.setCursor(8, 27);
  display.println(newValue);
  display.display();
 
}
DcsBios::StringBuffer<3> ilsMhzStrBuffer(0x116e, onIlsMhzChange);

void onIlsKhzChange(char* newValue) {
display.setFont(&FreeSans18pt7b);
  //display.clearDisplay();
  display.setTextColor(WHITE);
  display.setCursor(75, 27);
  display.println(newValue);
  display.display();
  
}
DcsBios::StringBuffer<2> ilsKhzStrBuffer(0x1172, onIlsKhzChange);

 

Can anyone advise how I can correctly clean the screen without the text disappearing?

 

Les

Posted (edited)

Hi Les,

what happens if you use print(newValue) instead of println(newValue)?

Furthermore, if using a standard font you may set foreground and background color for the text, e.g. setTextColor(WHITE, BLACK).

So the new text is printed over the old text without the need to clear the screen.

Regards, Vinc

Edited by Vinc_Vega

Regards, Vinc

real life: Royal Bavarian Airforce

online: VJS-GermanKnights.de

[sIGPIC][/sIGPIC]

Posted

How about store the old values and print them in black before printing the new ones in white?
And should you do the "display.setFont" only once in the setup?  Maybe doing it every time is messing something up.

Posted

I tried just calling out the font at the beginning of the sketch, it works the same - if nothing else it will simplify the sketch though. 

I'll have to look into the values in black, but I suspect I am missing something really simple

Cheers

 

Les

Posted (edited)

Could it be because your using the 1305 library, not the 1306 one?
Try this:

#define DCSBIOS_IRQ_SERIAL

#include <DcsBios.h>

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

#include "Fonts/FreeSans18pt7b.h"

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels

// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
// The pins for I2C are defined by the Wire-library.
// On an arduino UNO:       A4(SDA), A5(SCL)
// On an arduino MEGA 2560: 20(SDA), 21(SCL)
// On an arduino LEONARDO:   2(SDA),  3(SCL), ...
#define OLED_RESET     -1 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

char* ILSkhz = "00";  // Set a "blank" frequency to display at startup
char* ILSmhz = "000";

DcsBios::RotaryEncoder ilsKhz("ILS_KHZ", "DEC", "INC", 18, 19);

DcsBios::RotaryEncoder ilsVol("ILS_VOL", "-3200", "+3200", 16, 17);

DcsBios::RotaryEncoder ilsMhz("ILS_MHZ", "DEC", "INC", 15, 14);

void setup()   {                
   

  display.begin(0x3C);
  display.setFont(&FreeSans18pt7b);

  delay(1000);
   
  DcsBios::setup();

  ILSdisplay();  // Call the display routine to show the blank frequency at startup

}

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

}

void ILSdisplay(){  // ILS display driver
  display.clearDisplay();   // clears the screen and buffer
  display.setTextColor(WHITE);
 
  display.setCursor(8, 27);
  display.print(ILSmhz);

  display.setCursor(66, 27);
  display.print(".");

  display.setCursor(75, 27);
  display.print(ILSkhz);

  display.display();
}

 void onIlsMhzChange(char* newValue) {

  ILSmhz = newValue;  // Set the ILSmhz variable
  ILSdisplay();       // Call the display driver
 
}
DcsBios::StringBuffer<3> ilsMhzStrBuffer(0x116e, onIlsMhzChange);

void onIlsKhzChange(char* newValue) {

  ILSkhz = newValue;  // Set the ILSkhz variable
  ILSdisplay();       // Call the display driver
 
}
DcsBios::StringBuffer<2> ilsKhzStrBuffer(0x1172, onIlsKhzChange);

You'll need to adjust the screen height information at the start, and may need to install the 1306 library.

What I did was remove the display driver from the loop - there's no need to run it every loop, and it was causing issues.

The display also updates the whole thing at once using variables to hold the frequency values.  This makes clearing the screen easier, and doesn't use a massive overhead as it's only changed when the pilot changes the frequency.

So now, the two onchange routines update the frequency variables, then call the display driver.

The display driver clears the screen, then rewrites the whole display.

I tested it with a 128 x 32 OLED on a cold and dark A-10CII mission.

Edited by No1sonuk
Posted

Thanks

I tried the SSD1306 sketch, didn't want to work at all - the OLED I have really seems fussy, in fact I don't recall any others using SSD1305

However I tried blanking out using filled rectangles, and after a few attempts got it working correctly with the sketch below

 


#define DCSBIOS_IRQ_SERIAL

#include <DcsBios.h>
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1305.h>
#include "Fonts/FreeSans18pt7b.h"

// Used for software SPI
#define OLED_CLK 13
#define OLED_MOSI 11

// Used for software or hardware SPI
#define OLED_CS 8
#define OLED_DC 9

// Used for I2C or SPI
#define OLED_RESET 10

// software SPI
//Adafruit_SSD1305 display(128, 32, OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);
// hardware SPI - use 7Mhz (7000000UL) or lower because the screen is rated for 4MHz, or it will remain blank!
Adafruit_SSD1305 display(128, 32, &SPI, OLED_DC, OLED_RESET, OLED_CS, 6000000UL);

// I2C
//Adafruit_SSD1305 display(128, 64, &Wire, OLED_RESET);


void setup()   {                
   {

  display.begin(0x3C); 
  

//display.display(); // show splashscreen
  delay(1000);
  display.clearDisplay();   // clears the screen and buffer
  display.setFont(&FreeSans18pt7b);
  
}
DcsBios::setup();
}

 

DcsBios::RotaryEncoder ilsVol("ILS_VOL", "-3200", "+3200", 16, 17);

DcsBios::RotaryEncoder ilsKhz("ILS_KHZ", "DEC", "INC", 18, 19);

DcsBios::RotaryEncoder ilsMhz("ILS_MHZ", "DEC", "INC", 15, 14);

 

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

  display.display();
  display.setTextColor(WHITE, BLACK);
  display.setCursor(66, 27);
  display.print(".");
  display.display();
}

 void onIlsMhzChange(char* newValue) {
  display.fillRect(0, 0, 65, 32, BLACK);
  display.setTextColor(WHITE, BLACK);
  display.setCursor(8, 27);
  display.print(newValue);
  display.display();
 
}

void onIlsKhzChange(char* newValue) {
  display.fillRect(75, 0, 50, 32, BLACK);
  display.setTextColor(WHITE, BLACK);
  display.setCursor(75, 27);
  display.print(newValue);
  display.display();
  
}

DcsBios::StringBuffer<2> ilsKhzStrBuffer(0x1172, onIlsKhzChange);
DcsBios::StringBuffer<3> ilsMhzStrBuffer(0x116e, onIlsMhzChange);

Cheers for all the input guys! Another one working

Les

  • Recently Browsing   0 members

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