Jump to content

Recommended Posts

Posted (edited)

Hi all

I have been at this for a while now, trying different codes but am having to hold my hands up. I have one of these https://www.ebay.com/itm/125463195502?var=426488515340 which in spite of the description saying a 4 wire SPI connection is actually a 7 pin connector

Despite defining the correct pins, and the sketch compiling and loading OK nothing is being displayed 

#define DCSBIOS_DEFAULT_SERIAL

#include <DcsBios.h>

#include <Arduino.h>
#include <U8g2lib.h>
#include <Wire.h>

#define PIN_MOSI   18
#define PIN_CLK   19
#define PIN_DC    17
#define PIN_CS    16
#define PIN_RST 13
U8G2_SH1122_256X64_2_4W_HW_SPI u8g2(U8G2_R3, PIN_SPI_SS, PIN_DC, PIN_RST);  // All Boards without Reset of the Display R3 refers to 270 deg text rotation

void setup(void) {
  u8g2.begin();
  DcsBios::setup();
}
unsigned int vhfamFreq3 = 0;




void onVhfamFreq3Change(unsigned int newValue) {
  vhfamFreq3 = newValue;
  u8g2.clearBuffer();
  //u8g2.setFont(u8g2_font_logisoso38_tr);
  u8g2.setFont(u8g2_font_ncenB08_tr);
  u8g2.drawStr(20, 50, vhfamFreq3);  // 0 left, 0 top bottom appx 100

  u8g2.sendBuffer();
  delay(1000);
}
DcsBios::IntegerBuffer vhfamFreq3Buffer(0x118e, 0x0f00, 8, onVhfamFreq3Change);



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

I suspect that the problem lies in the board setup line "

U8G2_SH1122_256X64_2_4W_HW_SPI u8g2(U8G2_R3, PIN_SPI_SS, PIN_DC, PIN_RST);"
 
I tried "
U8G2_SH1122_256X64_2_HW_I2C u8g2(U8G2_R3, PIN_SPI_SS, PIN_DC, PIN_RST);"
 
but that doesn't work either. Looking at the library online I can't see any more relevant ones. 
 
Can anyone see the issue?
 
Cheers
 
Les
 
 
Edited by lesthegrngo
Posted

Hi Les,

what processor board are you using?

I had similar issues when connecting to an Arduino Nano with the constructor: U8G2_SH1122_256X64_F_4W_HW_SPI

That chip does not have enough memory for a 256x64 pixel display.

Changin it into a reduced version, like U8G2_SH1122_256X64_2_4W_HW_SPI only brings half of the display to life.

Solution is to use an ESP32 board with similar connections like below

/* ----- Harware SPI (SCL=18, SDA=23, SS=5) -----
OLED   =>    ESP32
GND    ->    GND
VCC    ->    3V3
SCL    ->    18 (CLK / SCL / SCLK)
SDA    ->    23 (MOSI / DIN / SDA)
RST     ->   22 (RST / RES/ Reset)
 DC    ->    21 (DC)
 CS     ->   5  (CS / SS)
*/

U8G2_SH1122_256X64_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 5, /* dc=*/ 21, /* reset=*/ 22);				// Enable U8G2_16BIT in u8g2.h

with following libraries

#include "analogWrite.h"  // PWM functionality to be used with the ESP32 chip   https://www.arduino.cc/reference/en/libraries/esp32-analogwrite/
#include "DcsBios.h"

#include <SPI.h>
#include <U8g2lib.h>

 

Regards, Vinc

Regards, Vinc

real life: Royal Bavarian Airforce

online: VJS-GermanKnights.de

[sIGPIC][/sIGPIC]

Posted

Thanks Vinc - This is a 328 Arduino Nano. I do have a board I can use, but it will complicate the process due to not being able to use RS485, and so having to port USB to it.

For the 'F' versus '2', I thought that was only half the available display buffer rather than full - I have used it to reduce the size of sketches on my arduinos to get U8G2 sketches onto 168 devices, and they work fine, although none are fast changing displays 

I do have a spare Uno I can try, but wonder if the issue will be the same

Les

Posted

You can try to disable the 16bit feature within the u9g2.h file. I did so but had no sucess with the Nano.

Regards, Vinc

Regards, Vinc

real life: Royal Bavarian Airforce

online: VJS-GermanKnights.de

[sIGPIC][/sIGPIC]

Posted

Shouldn’t you #include SPI.h ?

I use that for my oleds

U8G2_SH1106_128X64_NONAME_F_4W_HW_SPI
display1(U8G2_R0,/* cs=*/ 7, /* dc=*/ 6, /* reset=*/ 4);

And where is PIN_SPI_SS defined?

Cheers
/F

Posted

Thanks for the input

I tried your suggestion with the following simple code with three variations, but it still hasn't worked. 


#include <SPI.h>

#include <Arduino.h>
#include <U8g2lib.h>
#include <Wire.h>

#define PIN_MOSI 18
#define PIN_CLK 19
#define PIN_DC 17
#define PIN_CS 16
#define PIN_RST 13

//U8G2_SH1122_256X64_2_HW_I2C u8g2(U8G2_R3, PIN_CS, PIN_DC, PIN_RST);  // All Boards without Reset of the Display R3 refers to 270 deg text rotation

U8G2_SH1106_128X64_NONAME_2_4W_HW_SPI u8g2(U8G2_R0,/* cs=*/ 16, /* dc=*/ 17, /* reset=*/ 13);

//U8G2_SH1122_256X64_1_4W_SW_SPI u8g2(U8G2_R3, 19, 18, 16, 17, 13);

void setup(void) {
  u8g2.begin();
  u8g2.clearBuffer();
  u8g2.setFont(u8g2_font_ncenB08_tr);
  u8g2.drawStr(20, 50, "hello");  // 0 left, 0 top bottom appx 100
  u8g2.sendBuffer();
  delay(1000);
}

void loop() {
}

I am now going for the least palatable option, I am going to ask the Arduino forum to see if someone has a solution, or whether they will just look down on me as usual! 

Cheers

Les

Posted

Well, I managed to fix it myself. It seems that the OLED I have is fussy which pins it uses, when I changed over to use pins 9 through 12 for the CS, DC, SDA and SLC, it just worked

Here's the code for reference

 

#include <SPI.h>

#include <Arduino.h>
#include <U8g2lib.h>
#include <Wire.h>

/*#define PIN_MOSI 18
#define PIN_CLK 19
#define PIN_DC 17
#define PIN_CS 16
#define PIN_RST 13*/



U8G2_SH1122_256X64_2_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 12, /* data=*/ 11, /* cs=*/ 9, /* dc=*/ 10, /* reset=*/ 15);        // Enable U8G2_16BIT in u8g2.h



void setup(void) {
  u8g2.begin();
  u8g2.firstPage();
  do {
    u8g2.clearBuffer();
    u8g2.setFont(u8g2_font_ncenB08_tr);
    u8g2.drawStr(180, 20, "hello");  // 0 left, 0 top bottom appx 100
  } while(u8g2.nextPage());
  delay(1000);
}

void loop() {
}

So you cannot use the pins that are used by I2C 4 pin connections on SPI devices apparently

Cheers

Les

Posted
Does anyone know if there are any u8g2 fonts that resemble 14 segment LCD displays?
Cheers
 
Les

I made my own fonts using the apps that olikraus provided, Fony to draw the font and save to .bdf, then convert to .c and put it in the arduino sketch.
Took a good while for me to do it but it was worth it.

/F
Posted

Thanks guys - I was looking at doing the fonts myself, they are available as files for use in things like inkscape so that may shorten the process

I am still battling the OLED, if I use a simple sketch like the one above, the whole display is available, however once I put a simple BIOS sketch in it, anything below a third of the screen height gets blanked. Not sure what is going on

Les

 

Posted

Hi Les,

you are using only half of the display buffer.

Regards, Vinc

Regards, Vinc

real life: Royal Bavarian Airforce

online: VJS-GermanKnights.de

[sIGPIC][/sIGPIC]

Posted

The puzzling thing is the simple sketch is also only using half the display buffer, but can be shown anywhere on the display, so the behaviour is not the same. Both sketches have this line

 
U8G2_SH1122_256X64_2_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 12, /* data=*/ 11, /* cs=*/ 9, /* dc=*/ 10, /* reset=*/ 15);

but only the DCS Bios sketch limits where you can put the text

Les

Posted

I am going to try and use the ‘do… while’ loop, and the U8X8 variations to see if that helps, as all I am trying to do is display text

hopefully it will resolve this

Les

Posted (edited)

The 'do....while' loop has fixed it. I can now render the output over the whole display

On to make the bespoke font

***EDIT***

Ok, this is where my lack of in-depth understanding of things like Python and C let me down. I was able to convert the font to .dbf, I installed python, I copied the bdf_to_h.py and bdf_to_combined.py into the folder with the dbf font in it and double-clicked on the .py files per the instructions below.

"3) Now double-click either of these two files, depending on what you want:
    - `bdf_to_h.py` - this will create a seperate .h file for each BDF file
    - `bdf_to_h_combined.py` - all BDF fonts with the same name combined into the same .h file (with multiple sizes) "

Unfortunately, nothing happens other than a brief opening of the CMD window, no .h file is generated.

Any Ideas?

 

Cheers


Les

Edited by lesthegrngo
Posted

Guys, I have tried to find the cause and have managed through the Python console to get this

"= RESTART: D:\Downloads\fonts-DSEG_v046\fonts-DSEG_v046\DSEG14-Classic\bdf_to_h.py
Traceback (most recent call last):
  File "D:\Downloads\fonts-DSEG_v046\fonts-DSEG_v046\DSEG14-Classic\bdf_to_h.py", line 3, in <module>
    from PIL import Image
ModuleNotFoundError: No module named 'PIL'"

So it looks like there is a missing module, but I cannot work out how to get that missing module back in in Win 10 installations. I used this page to try https://www.pythonpool.com/solved-no-module-named-pil/ but nothing is reflected in my installation - I just get invalid syntax messages

I tried looking at something called Pixelmatics in Github, but have absolutely no idea how to use that either

Can anyone who is familiar with this help?

Cheers

Les 

Posted

I just use Fony to draw the font, save to bdf and then use convertbdf to make a .c
Then i open the .c in a text editor and copy the text to the arduino sketch.

I’m almost sure all the things you need is in the u8g2 library, or on olikraus GitHub.

/F

Posted (edited)

I just tried that convertbdf, but the 'white area for for choose a file' is nowhere to be seen - is there any special extension that I need to run this?

***EDIT***

I resolved the "no module named PIL" error, after watching a load of videos on how to correct it on Youtube - shame most of them forget to metion the syntax errors that will keep on appearing unless you type "exit()", that would have saved me some head bashing.

However when I ran the python code I got a "can only concatenate str (not "int") to str" message, which when I look at the solution makes me want to go and drown myself. 

I give up on python......

Cheers

Les

Edited by lesthegrngo
Posted
I just tried that convertbdf, but the 'white area for for choose a file' is nowhere to be seen - is there any special extension that I need to run this?
***EDIT***
I resolved the "no module named PIL" error, after watching a load of videos on how to correct it on Youtube - shame most of them forget to metion the syntax errors that will keep on appearing unless you type "exit()", that would have saved me some head bashing.
However when I ran the python code I got a "can only concatenate str (not "int") to str" message, which when I look at the solution makes me want to go and drown myself. 
I give up on python......
Cheers
Les

You need to open a cmd in the folder you have bdfconv, just type cmd in the folder location bar and hit enter.
If you then type bdfconv you will see the options.
Mine look like this:

bdfconv -f 1 -m "32,45,48-57" -n AJSDATA -o AJSDATA.c AJS_DATA38.bdf

-f 1 mean that it’s for u8g2
-m “ “ mean that I only want to convert those glyphs
-n is the name of the font in the .c that will be referred to in the sketch
-o is the name of the .c
AJS_DATA38.bdf is the name of my .bdf

/F
Posted (edited)

Ok, I have bdfconv in my D:\Downloads folder, and I also have a copy of DSEG14Classic-Bold-54.bdf in that same folder

I have opened CMD, typed bdfconv, and the list of the options appears.

I typed bdfconv f 1 -n SEG14.c DESG14Classic-Bold-54.bdf and pressed enter. Nothing happens, no file is generated, although neither are any error messages. Have I got the syntax correct?

I also tried bdfconv f 1 -m "1-38" -n SEG14.c DESG14Classic-Bold-54.bdf, with no results

****EDIT***

Got it - forgot to specify the -o output file

 

 

Cheers

Les

Edited by lesthegrngo
Posted

Last post for today as I am running out of time and braincells!

The SEG14.c file is the following

/*
  Fontname: -FontForge-DSEG14 Classic-Bold-R-Normal--54-410-96-96-P-420-ISO10646-1
  Copyright: Created by Keshikan
  Glyphs: 0/39
  BBX Build Mode: 0
*/
#include "ucg.h"
const ucg_fntpgm_uint8_t SEG14[31] UCG_FONT_SECTION("SEG14") = {
  0,0,2,2,0,0,0,0,0,82,61,87,79,54,0,54,
  0,0,0,0,0,0,2,0,0,0,4,255,255,0,0};

When I copy the text in, predictably it compiles with an error saying no file with the name ucg.h exists, which of course des not at least where the SEG14 file was created. Am I supposed to be looking for it somewhere?

Cheers

 

Les

Posted

Mine look like this:


 /* Fontname: AJS_DATA38Copyright: outbaxx Glyphs: 12/26 BBX Build Mode: 0*/const uint8_t AJSDATA[531] U8G2_FONT_SECTION("AJSDATA") =  "\14\0\4\4\5\6\6\7\7\42%\0\0$\0%\377\0\0\0\0\1


There is more data but there’s no need to copy/past all of it.

Did you have a - before the f ?

Your says ugc but it should say U8G2

Posted

I ran it again today, this time I have this

const uint8_t SEG14[31] U8G2_FONT_SECTION("SEG14") = 
  "\0\0\2\2\0\0\0\0\0R=WO\66\0\66\0\0\0\0\0\0\2\0\0\0\4\377\377\0";

I must have done something wrong last night, but this looks much more like your version

However I am getting compiling errors, so how the sketch calls out the new font is obviously my next issue

Using this sketch

#define DCSBIOS_IRQ_SERIAL

//#define DCSBIOS_RS485_SLAVE 48
//#define TXENABLE_PIN 2

#include "DcsBios.h"
#include <U8g2lib.h>
#include <Wire.h>

const uint8_t SEG14[31] U8G2_FONT_SECTION("SEG14") = 
  "\0\0\2\2\0\0\0\0\0R=WO\66\0\66\0\0\0\0\0\0\2\0\0\0\4\377\377\0";

U8G2_SH1122_256X64_2_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 19, /* data=*/ 18, /* cs=*/ 16, /* dc=*/ 17, /* reset=*/ 15);        // Enable U8G2_16BIT in u8g2.h

void onUhfFrequencyChange(char* newValue) {

  u8g2.firstPage();
  do {

  u8g2.clearBuffer();
  //u8g2.setFont(u8g2_font_inb24_mr );
  u8g2.setFont(U8G2_FONT_SECTION);
  u8g2.setCursor(10, 60);
  u8g2.print(newValue);
   } while(u8g2.nextPage());
  u8g2.sendBuffer();
}
DcsBios::StringBuffer<7> uhfFrequencyBuffer(0x1180, onUhfFrequencyChange);

void setup() {
  u8g2.begin();

  DcsBios::setup();
}

void loop()
{

  DcsBios::loop();
}

I am clearly not using the correct syntax for the callout.  Also, I must be missing some callouts, here are the error messages

F:\Users\LES\Documents\Arduino\208OLEDUHF_with_go_wait_SEG14_font\SEG14.c:7:7: error: unknown type name 'uint8_t'
 const uint8_t SEG14[31] U8G2_FONT_SECTION("SEG14") =
       ^~~~~~~
F:\Users\LES\Documents\Arduino\208OLEDUHF_with_go_wait_SEG14_font\SEG14.c:7:25: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'U8G2_FONT_SECTION'
 const uint8_t SEG14[31] U8G2_FONT_SECTION("SEG14") =
                         ^~~~~~~~~~~~~~~~~
F:\Users\LES\Documents\Arduino\208OLEDUHF_with_go_wait_SEG14_font\208OLEDUHF_with_go_wait_SEG14_font.ino: In function 'void onUhfFrequencyChange(char*)':
F:\Users\LES\Documents\Arduino\208OLEDUHF_with_go_wait_SEG14_font\208OLEDUHF_with_go_wait_SEG14_font.ino:39:16: error: 'U8G2_FONT_SECTION' was not declared in this scope
   u8g2.setFont(U8G2_FONT_SECTION );
                ^~~~~~~~~~~~~~~~~
Multiple libraries were found for "U8g2lib.h"
  Used: F:\Users\LES\Documents\Arduino\libraries\U8g2
  Not used: F:\Users\LES\Documents\Arduino\libraries\U8g2_Arduino-master
  Not used: F:\Users\LES\Documents\Arduino\libraries\U8g2small
exit status 1

Compilation error: unknown type name 'uint8_t'

The instructions I read on the web say 'just drop the .c code into the the sketch....' !! The problem is that there often an expectation that everyone who reads it will have in-depth programming knowledge, as there is obviously more to it

Cheers

Les

Posted

 //Datapanel Diplay//AJS37#include #include #include //#define DCSBIOS_RS485_SLAVE 22#define TXENABLE_PIN 2#include "DcsBios.h"int power_is_on = 0;int CK_LED_ison = 0;int lastCKcheck = 0;int lastPowerCheck = 0;U8G2_SH1106_128X64_NONAME_F_4W_HW_SPI display1(U8G2_R0,/* cs=*/ 7, /* dc=*/ 6, /* reset=*/ 4);U8G2_SH1106_128X64_NONAME_F_4W_HW_SPI display2(U8G2_R0,/* cs=*/ 5, /* dc=*/ 6, /* reset=*/ 8);/* Fontname: AJS_DATA38 Copyright: outbaxx Glyphs: 12/26 BBX Build Mode: 0*/const uint8_t AJSDATA[531] U8G2_FONT_SECTION("AJSDATA") =  "\14\0\4\4\5\6\6\7\7\42%\0\0$\0%\377\0\0\0\0\1\366 \6\0\0\313r-\15\220" "\200\243\362p\361\340\201\10\27\0\60&S|\203\362J\330\352\321\233\7BL\31)W\302\334J\375\377" "\227\353L\224+b\312\310\3\61\217^\65L\5\0\61\27K\234\205r#f\350\14\222\24\17>\30Q" "\254\376\377\177\67\2\0\62\64S|\203\362J\330\352\321\233\7BL\31)W\302\340\302\342\245-\66m" "\330\360a\253\15\33>l\265a\253\15\233.\375 \310\203\21\17F<\30\362 \4\0\63\64S|\205" "\362J\330\352\321\33SF\312\25)W\302\340\302\342U\27/]\62\323\264\311\215\227\7P\274<\200\205" "\273\63Q\256\210)#\17\304  "\224+R\256H\261\62\305\312\24#T\252P)R\205J\25z \342\301\3\24\17\306\26\257\357\1\14" "\2\65\70S|\205\362x\20\344\301\210\7#\36\214x \244x\375\342\330\243\7a\36\10y \344\224" "\11s%\314\225\7P\274\370\302\335\231(W\304\224\221\7b\36\275j\230\12\0\66\67S|\203\362J" "\330\352\321\233\7BL\31)W\302\334\302\235\27\61\366\350A\230\7B\36\10\71e\302\134\11s%J" "\352\313u&\312\25\61e\344\201\230G\257\32\246\2\67,R\204\201r\370\3\326\25\227.\134\272p\351" "\302\245\13\227.\134\272p\351\302\245\13\227.\134\272p\351\302\245\13\227.M\36\200x\0\70\70S|" "\203\362J\330\352\321\33SF\312\25)W\242\244.K\224+R\256L\251R\355\26\256k\365\250T\231" "rE\312\225(\251\227%\312\25)W\304\224\231G\257\32\246\2\71\67S|\203\362J\330\352\321\233\7" "BL\31)W\302\334J}Y\242\234\211r&L\35y \344\201\230\7\201\236\31)\276pw&\312" "\25\61e\344\201\230G\257\32\246\2\0\0\0\4\377\377\0";void setup() { //start displays display1.begin(); display2.begin(); //set contrast display1.setContrast(50); display2.setContrast(50); //font for displays display1.setFont(AJSDATA);  display2.setFont(AJSDATA);//draw 37 (For test purpose) //display1.drawStr(-10,45," 37 "); //display1.sendBuffer(); //display2.drawStr(-10,55," 37"); //display2.sendBuffer();DcsBios::setup();



This is part of my code, I only use 12 glyphs but my font data contains a lot more data than yours.
It’s weird that you get the compile error.

  • Recently Browsing   0 members

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