Hi
I have an ATmega328p IC, programmed using UNO as the processor.
I have an 0.96" Oled on the I2C bus.
I want to use a DMX library with it, but if I use any DMX library (DMXsimple, DMXserial or DMXserial2) it stops the screen working and I cannot work out why.
The code is horrible, as I have commented out bits to try and narrow down the culprit.
Using USBasp to upload, so no serial debug. But it doesn't throw up an error when loaded.
Screen loads text when the DMX library's are commented out
//#include <Wire.h> // I2C comms
//#include <SPI.h> // Serial comms
//#include <DMXSerial.h> // DMX library.
#include <DMXSerial2.h>
//#include <Bounce2.h> // Button bouce library
#include <Adafruit_GFX.h> // Graphics library
#include <Adafruit_SSD1306.h> // Oled screen
// include <EEPROM.h> // EEPROM --- Already included in the DMXserial library?
// include <Servo.h> // Servo library
//Bounce enterbutton = Bounce();
//Bounce selectbutton = Bounce();
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
//#define enterbutton A7
#define pin1 2
#define pin3 3
#define pin4 4
#define pin5 5
#define pin6 6
#define pin7 7
#define pin8 8
#define pin9 9
#define pin10 10
// Pin 11 = Mosi
// Pin 12 = Miso
// Pin 13 = SCK
//#define selectbutton 14
#define heartbeat 15
#define pin2 16
#define DMXdirection 17
// Pin 18 SDA
// Pin 19 SCL
unsigned long currentMillis; // Timing variables
unsigned long heartbeatMillis;
byte h; // BMP display variables
byte w;
byte row;
byte col;
int buffidx = 0;
int RXDMXaddress = 0; // DMX variables
int TXDMXaddress = 0;
int TXDMXvalue = 0;
int RXDMXvalue = 0;
int OldRXDMXvalue = 0;
//----------------------------------------------------------------------------------------------------------------------------------------------------------------
void setup() {
pinMode (heartbeat, OUTPUT);
pinMode (DMXdirection, OUTPUT);
//pinMode (enterbutton, INPUT);
//pinMode (selectbutton, INPUT);
pinMode (pin1, INPUT);
pinMode (pin2, INPUT);
pinMode (pin3, INPUT);
pinMode (pin4, INPUT);
pinMode (pin5, INPUT);
pinMode (pin6, INPUT);
pinMode (pin7, INPUT);
pinMode (pin8, INPUT);
pinMode (pin9, INPUT);
pinMode (pin10, INPUT);
Wire.begin();
//DMXSerial.init(DMXReceiver);
//DMXSerial.init(DMXController);
//enterbutton.attach(A7, INPUT);
//selectbutton.attach(14, INPUT);
//enterbutton.interval(5); // interval in ms
//selectbutton.interval(5); // interval in ms
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
digitalWrite(DMXdirection, HIGH);
//----------- Set the display up-------------
// Clear the buffer.
display.clearDisplay();
display.drawRoundRect(0, 0, 128, 64, 4, WHITE); // Draws a rectangle with rounded corners. Starts at 0,0 (top left) and then 128 wide x 64 high with corners rounded to radius 4
display.drawRoundRect(2, 2, 124, 60, 4, WHITE);
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(24, 8);
display.println(F("DMX CONTROLLER"));
display.display();
delay(1000);
}
//#####################################################################################################################
void loop() {
currentMillis = millis();
if (currentMillis - heartbeatMillis == 1000) {
digitalWrite(heartbeat, HIGH);
}
if (currentMillis - heartbeatMillis > 2000) {
heartbeatMillis = currentMillis;
digitalWrite(heartbeat, LOW);
}
// DMXSerial.write(TXDMXaddress, TXDMXvalue); // Send a DMX value
/*
unsigned long lastPacket = DMXSerial.noDataSince(); // Calculate how long no data packet was received
if (lastPacket < 5000) { // Read DMX value
RXDMXvalue = DMXSerial.read(RXDMXaddress);
if (RXDMXvalue != OldRXDMXvalue) {
//display.fillRect(100, 45, 20, 12, BLACK);
//display.setCursor(102, 47);
//display.println(RXDMXvalue);
//display.display();
}
OldRXDMXvalue = RXDMXvalue;
} else { // Display DMX Receive error
//display.fillRect(100, 45, 20, 12, BLACK);
//display.setCursor(102, 47);
//display.println("ERR");
//display.display();
}
*/
}
//#####################################################################################################################