So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By teeshq
#93459 Hi i try to use esp8266 nodemcu with dcs bios i tested OLED and its work correctly with graphic test from U8g2 templates when i use this code its work correctly with mega 2560 but when switching to esp8266 its give me some strange artefacts on OLED
Code: Select all#include <Arduino.h>
#include <U8g2lib.h>
#include <Wire.h>
#include <SPI.h>
//#define  DCSBIOS_IRQ_SERIAL // MEGA 2560
#define  DCSBIOS_DEFAULT_SERIAL // ESP8266node mcu
#include "DcsBios.h"



int count;
//U8G2_SH1122_256X64_F_4W_HW_SPI u8g2(U8G2_R2, /* cs=*/ 10, /* dc=*/ 5, /* reset=*/ 4); // Mega 2560 scl pin52, sda pin
 U8G2_SH1122_256X64_F_4W_SW_SPI u8g2(U8G2_R2, /* clock=*/ 14, /* data=*/ 13, /* cs=*/ 15, /* dc=*/ 5, /* reset=*/ 4); // ESP 8266
String comDisplay[3];
void setup()
{
 count = 0;
  u8g2.begin();
  Wire.begin();
  u8g2.clearDisplay();
  u8g2.clearBuffer();
  u8g2.sendBuffer();
  u8g2.setFont(Hornet_UFC);
  u8g2.setBusClock(850000);
  DcsBios::setup();

}
 

void updateComDisplay(int changed,char* newValue) {
 comDisplay[changed] = cleanUpCom(newValue);

u8g2.clearBuffer();          // clear the internal memory
u8g2.setCursor(0, 45);
u8g2.print(comDisplay[0]);
u8g2.setCursor(57, 45);
u8g2.print(comDisplay[1]);
u8g2.setCursor(75, 45);
u8g2.print(comDisplay[2]);
u8g2.sendBuffer();
}


char* cleanUpCom(char* newValue) {
 switch (newValue[0]) {
   case '`':
     newValue[0]='1';
     break;
   case '~':
     newValue[0]='2';
     break;
       
 }
 return newValue; 
}
void onUfcScratchpadNumberDisplayChange(char* newValue) {
    updateComDisplay(2, newValue);
}
DcsBios::StringBuffer<8> ufcScratchpadNumberDisplayBuffer(0x7446, onUfcScratchpadNumberDisplayChange);/// main

void onUfcScratchpadString2DisplayChange(char* newValue) {
    updateComDisplay(1, newValue);
}
DcsBios::StringBuffer<2> ufcScratchpadString2DisplayBuffer(0x7450, onUfcScratchpadString2DisplayChange);///mid

void onUfcScratchpadString1DisplayChange(char* newValue) {
    updateComDisplay(0, newValue);
}
DcsBios::StringBuffer<2> ufcScratchpadString1DisplayBuffer(0x744e, onUfcScratchpadString1DisplayChange);///left
  //// updateComDisplay(2, newValue);
void loop()
{
  DcsBios::loop();
}

ESP8266 glitch
Image
Mega correct display
Image

im quite noob with arduino so maybe some one can pinpoint issue thanks