Conflict

Hi,

I tried this simple program. The Oled display works if I remove DCCPacketscheduler, When I use this command, the Oled gives no picture. There is no Error by compiling.
Does anyone know why?

#include <DCCPacket.h>
#include <DCCPacketQueue.h>
#include <DCCPacketScheduler.h>

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

DCCPacketScheduler dps;

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

#define OLED_RESET     4 
#define UITIR          5 // Out IR
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

int dccadres = 6;
int teller = 0;

void setup() {
    Serial.begin(9600);

    Serial.println(F("start"));
    display.display();
}

void loop() {

    Serial.print("F"); 
    Serial.println(teller);
    teller++ ;
    delay (20000); 
}

The display is not intialized with “display.begin(…)” and you are not displaying anything on it. Did you mind to look at one of the examples for the display?

Trebbie:

void setup() {

Serial.begin(9600);

Serial.println(F("start"));
   display.display();
}

you should put display.begin("address of the oled or something like that")

Okay sorry, I made the Programm to simple
The real program is thisone.

The problem remains. If I use DCCPacketScheduler dps; the OLED does not work.
If I remove it (and all the dps components) The OLED works.

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

#include <DCCPacket.h>
#include <DCCPacketQueue.h>
#include <DCCPacketScheduler.h>

 DCCPacketScheduler dps;

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

// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET     4 // Reset pin # (or -1 if sharing Arduino reset pin)
#define UITIR          5 // Uitgang van IR
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

int dccadres = 6;
int teller = 0;
byte stat[16] = {1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1};

void setup() {
    Serial.begin(9600);

  // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64
    Serial.println(F("SSD1306 allocation failed"));
    for(;;); // Don't proceed, loop forever
  }

  display.display();
  delay(2000); // Pause for 2 seconds

  // Clear the buffer
  display.clearDisplay();

//  dps.setup(UITIR);// ************ pinout  ******
//  dps.setpower(true);
}


void textdecoder(void) {
  display.setTextSize(2); // Draw 2X-scale text
  display.setTextColor(SSD1306_WHITE);
  display.setCursor(20, 0);
  display.println(F("decoder"));
  display.display();      // Show initial text
}

void textadres(void) {  
  display.setTextSize(2); // Draw 2X-scale text
  display.setTextColor(SSD1306_WHITE);
  display.setCursor(15, 18);
  display.print(F("adres "));
  display.println(dccadres);
  display.display();      // Show initial text 
}

void textstatus(void) {
  display.setTextSize(1); // Draw 2X-scale text
  display.setTextColor(SSD1306_WHITE);
  display.setCursor(10, 40);
  for(int i=1; i<9 ;i++) {
    if (stat[i-1]==0) display.print("O ") ;
    else display.print("X ") ;
  }
  display.setCursor(17.5, 50);
  for(int i=9; i<17 ;i++) {
    if (stat[i-1]==0) display.print("O ") ;
    else display.print("X ") ;
  }
  display.display();      // Show initial text 
}

void textteller(void) {  
  display.setTextSize(4); // Draw 2X-scale text
  display.setTextColor(SSD1306_WHITE);
  display.setCursor(15, 18);
  display.print(F("F"));
  display.println(teller);
  display.display();      // Show initial text 
}

void loop() {
  display.clearDisplay();
  textdecoder();
  textadres();
  textstatus();
//  textteller();
//  dps.setLocoFunc(dccadres, 1, teller);
//  dps.update();
  teller++ ;
  delay(40000);
}

Hello,

I'm doing trail and error and found that functions who calls INTERRUPS are causing the problems.

In the libary DCC_Decoder.h the OLED with is getting his information trough I2C will not work when I call

DCC.SetupDecoder( 0x00, 0x00, DCC_INTERRUPT )

With the Libary DCCPacket.h it is the function DCCPacketScheduler dps;

The function are called by INTERRUPT.

Is there a solution that I2C works with an INTERRUPT handler?