version 1.0
Start : Nov 2019
rev : 08/12/2024
Mini OLED 128x32 (25x10mm)
* Version
minimale affichage fonte texte sur Mini_OLED 128x32 avec RTC ( MikroC
2020 )
* Version
plus élaborée avec fonctions grafiques Mini_Oled (mais sans RTC)
( MikroC
2024 )
* Version de
test Mini OLED 128x32 ( avec MikroBasic Pro 7.50 version
limitée à 2K )
LCD
Mini OLED grafique 128x32 (25x10mm)
avec PIC 18F26K22
(2020)
L'afficheur :
OLED LCD Display Module IIC I2C 0.91"128x32 Bleu alim.3.3 V
5 V coût < 2,50 !
Description :
OLED display, no need backlight, self-illumination, the display
performance is better than the traditional LCD display, also
lower consumption.
Driver IC: SSD1306
Size: 0.91 inch OLED
Resolution: 128 x 32
Dimensions: board=40mmx12mm, mais Display=25 mm x 10 mm ONLY !
IIC interface , Device Adresse fixe= 0x3C Malheureusement
immuable !
Display Color: Blue
Pin Description:
GND: Power Ground
VCC: Power + (DC 3.3 à 5v)
SCL: Clock Line
SDA: Data Line
Nota :
pas de pins pour configurer une
autre adresse I2C que 0x78 !
dommage, on ne peut pas en mettre plusieurs sur le meme bus I2C
Hardware :
Base
18F26K22 --- liaison I2C1 SDA SCL
Base 18F26K22 -- liaison UART1 ---TX,RX ---prolific cable _USB--
YAT terminal PC
Alimentation via un bloc secteur 9V DC -- Regulateur DC/DC LM2906--ajustable
2,2V à 5V
Le controleur LCD est basé sur un SSD1306 .
La librairie :
OLED_132x28_I2C1_1911.mcl
rassemble les fonctions suivante :
// 25-11-2019
#define OLED_ADDRESS 0x78 // soit 120 adresse 8 bits , nota:
device adresse (7bits)= 0x3C
void WriteCmd(unsigned char I2C_Command);
void WriteDat(unsigned char I2C_Data);
void OLED_Init(void);
void OLED_SetPos(unsigned char x, unsigned char y);
void OLED_Fill(unsigned char fill_Data);
void OLED_CLS(void);
void OLED_ON(void);
void OLED_OFF(void);
void OLED_ShowStr(unsigned char x, unsigned char y, unsigned char
*c, unsigned char TextSize);
void OLED_ShowCN(unsigned char x, unsigned char y, unsigned char
N); // chinese Carac
void init_OLED(void);
void Write_Char_At(unsigned char X,unsigned char Y, unsigned char
C);
void OLED_DrawBMP(unsigned char x0,unsigned char y0,unsigned char
x1,unsigned char y1,const unsigned char *PP);
void printBigNumber(char st, int X, int Y);
void Decompile_byte(unsigned char un);
void OLED_pixel(short x, short y, char color);
void Refresh_OLED(void) ;
void ShowBigNumber(unsigned char x, unsigned char y, unsigned
char N);
void Big_affichage( unsigned char posX,unsigned char N);
void Affiche_Car_8x8 ( unsigned char posX, unsigned char PosY,unsigned
char N );
Le point clé est l'INITIALISATION correcte du
LCD
void OLED_Init(void)
{
//voir SSD1306.pdf
//Software Configuration
WriteCmd(0xAE); //display off
Delay_ms(200);
WriteCmd(0xAF); //display on
Delay_ms(100);
WriteCmd(0xB0);// Set GDDRAM Page start adresse [2:0] 0 à 7
WriteCmd(0x00); // mini 0
WriteCmd(0x03); // maxi pour Ymax=32
// WriteCmd(0x07); // maxi pour 1Ymax=64
WriteCmd(0x20); //Set Horizontal Memory Addressing Mode
//A[1:0] = 00b, Horizontal Addressing Mode
//A[1:0] = 01b, Vertical Addressing Mode
//A[1:0] = 10b, Page Addressing Mode (RESET)
//A[1:0] = 11b, Invalid
WriteCmd(0x02); // Page Addressing Mode (RESET)
WriteCmd(0x21); // Setup column start and end address
WriteCmd(0); //A[6:0] : Column start address, range : 0-127d,(RESET=0d)
WriteCmd(0x7F); // B[6:0]: Column end address, range : 0-127d,(RESET
=127d)
WriteCmd(0x22);// Setup page start and end address
// A[2:0] : Page start Address, range : 0-7d,
// (RESET = 0d)
// B[2:0] : Page end Address, range : 0-7d,
// (RESET = 7d)
WriteCmd(0x00);
WriteCmd(0x03); //was 0x07
WriteCmd(0xA1); //--set segment re-map to 127 de gauche ->
droite
WriteCmd(0xA4);//command enable display outputs according to the
GDDRAM contents.
WriteCmd(0xA6);//normal display
// WriteCmd(0xA7);//reverse display
WriteCmd(0xC8); //Set COM Output Scan Direction
WriteCmd(0xD3); //--set start line address 40h = set to 0
WriteCmd(0x40); // ou 0x3F
WriteCmd(0xD5); //--set display clock divide ratio/oscillator
frequency
WriteCmd(0x80); //--set divide ratio 80h
WriteCmd(0xA8); //--set multiplex ratio to 63
WriteCmd(0x3F); // was 3F
WriteCmd(0xD6); //-- This command is to set the vcommon signals
padconfiguration.
WriteCmd(0x80); // --set divide ratio 80h
WriteCmd(0xD9); //--set display clock divide ratio/oscillator
frequency
WriteCmd(0x1F); // 22h --reset values 22h
WriteCmd(0xDA); //--set com pins hardware configuration
WriteCmd(0x20); // was 0x02 32
WriteCmd(0xEE); // Read-Modify-Write end.
WriteCmd(0x81); //--set contrast control register
WriteCmd(0x7F); // 0x00~0xff
WriteCmd(0x2E); // no scrolling
WriteCmd(0xDB); //--set VComH deselect level
WriteCmd(0x40); // 20H => 0.77x Vcc (Reset value)
WriteCmd(0x8D); //--set DC-DC enable Charge Pump Setting
WriteCmd(0x14); // 0x14 Enable Charge Pump
WriteCmd(0xAF); //--turn on oled panel
}
Au demarrage du programme ... option recherche de l'adresse du
device (LCD OLED)
ici adresse I2C device trouvé = 120 soit 0x78
Test des differents modes d'affichages :
jusqu' à 4 lignes de 21 caracteres en taille 0
(minimum)
2 lignes de car double taille 16x16.
7 caracteres en taille maximale. pour ascii numerique 0123456789,point
et espace.
affichage image ou logo N&B BMP 1 bit taille 128x32
Déroulement du programme (Tx
sur sortie UART1 RC6)
Presentation :
Mikroc 7.6.0 18F26K22
Directory : C:\_MikroC\_18F26K22_Test_Mini_OLED_I2C_20x10mm_I2C_2021
Projet : Mini_OLED_128x32_25x10mm_I2C1_HW_MC_18F26K22_2021.mcppi
Source : TEST_Mini_OLED_SSD1306_128x32_with_I2C1_HW_MikroC_18F26K22_2021_01_30.c
DEVICE : Mini OLED DISPLAY IIC I2C 0.91 128x32 25x10mm
I2C1 HW avec MC Library , Terminal pour debug et Visu programme
Alim = 3.6 V
FOSC= Interne 16 MHz
Autres : BMP_images_128x32_2021.inc
OLED_128x32_I2C1_HW_2021.c et *.h
OLED_128x32_Tables_2021.h
....etc
boucle infinie :
Temp.Exterieur DS18B20 : 22.25
Affiche Temp DS18B20 en Taille 2 at x=0, ligne 1
Affichage taille 3 de DS18B20
... Waiting Keyboard Touch for < 3,0 Sec >
Test consommation du LCD OLED
multimetre FI515X (mA) en serie sur l'alim +Vcc du module OLED
Nota: Le parametrage du LCD reste inchangé pendant ce test
alim 2.2V 3.3V 5.0V LCD + 18F ( 2,2V) Eteint 0% 1.48 1.53 0.62 mA 3.80 mA Allumé 100% 8.40 13.71 12.96 mA 11.30 mA 0123456 3.44 4.69 3.79 mA 5.89 mA La conso mini est obtenue sous 2,2V (sauf LCD eteint !)
La conso n'augmente pas proportionellement, voir inversement dans le cas alim =5,00V
Le rendement du convertisseur "Pump de charge" interne doit y etre pour quelque chose.
OLED_init
OLED CLS
Test consommation du LCD OLED ETEINT (1.53mA sous 3.3V)
... Waiting Keyboard Touch for < 6,0 Sec >
Test consommation du LCD OLED Allumé 100% ON (13.6mA sous 3.3V)
... Waiting Keyboard Touch for < 6,0 Sec >
Differentes tailles de polices
Write_Char_At(X en pixel (0 à 127), ligne Y (0 à 3),code ascii char)
Write 21 cars (Taille 1) : ABCDEFGHIJKLMNOPQRSTU
... Waiting Keyboard Touch for < 4,0 Sec >
Write 8 cars (Taille 2) :01234567 at x=0, ligne 1
Write 8 cars (Taille 2)01234567 at x=64, ligne 1
... Waiting Keyboard Touch for < 4,0 Sec >
Write 8 cars (Taille 2) HELLO ,are you ?. at x=0, ligne 3
... Waiting Keyboard Touch for < 4,0 Sec >
Write 8 cars (Taille 2) :01234567 at x=0, ligne 1
... Waiting Keyboard Touch for < 3,0 Sec >
Write 8 cars (Taille 2)01234567 at x=64, ligne 1
... Waiting Keyboard Touch for < 3,0 Sec >
Big_affichage( unsigned char posX, unsigned char N )
... Waiting Keyboard Touch for < 4,0 Sec >
Affichage taille 3 de : 19.8°C
... Waiting Keyboard Touch for < 2,0 Sec >
Affichage Image paulfjujo
... Waiting Keyboard Touch for < 5,0 Sec >
Programme:
Projet Mikro C :
_Lib_Math.mcl" "
_Lib_MathDouble.mcl" "
_Lib_System.mcl" "
_Lib_Delays.mcl" "
_Lib_CType.mcl" "
_Lib_CString.mcl" "
_Lib_CStdlib.mcl" "
_Lib_Conversions.mcl" "
_Lib_I2C_c34b12.mcl" "
_Lib_UART_c67b67.mcl"
* Available RAM: 3875 [bytes], Available ROM: 65536 [bytes]
* Used RAM (bytes): 1084 (28%) Free RAM (bytes): 2791 (72%)
* Used ROM (bytes): 15632 (24%) Free ROM (bytes): 49904 (76%)
projet (avec RTC):
lversion 26 aout 2020
PIC18F26K22_Test_BASE_CI_mini_OLED_128x32_RTC_DS3231_2xDS18B20_2020_0826.zip
executable : Base_18F26K22_mini_Oled_128x32_RTC_2xDS18B20_2020_0826.hex
Librairies :
Tiny_RTC_DS3231_for_AI2_2020_0826.mcl
OLED_128x32_I2C1_2020_0826.mcl
Headers :
Tiny_RTC_DS3231_for_AI2_2020_0826.h
OLED_128x32_I2C1_2020_0826.h
oled_128x32_tables_2020_0826.h
Version 2024 (sans RTC)
Projet MikroC complet ; _18F26K22_Test_Mini_OLED_I2C_20x10mm_I2C_20241208.zip
Source MikroC 7.60 : TEST_Mini_OLED_SSD1306_128x32_with_I2C1_HW_MikroC_18F26K22_2024_1208.c
log lancement programme sur YAT terminal
compilé : Mini_OLED_128x32_25x10mm_I2C1_HW_MC_18F26K22_2024-1208.hex
Nota : OK avec alim 2 piles 1.5V (..Vcc mesuré: 3,1V)
Projet MikroC 7.60 :
update 03/02/2021
Mini_OLED_128x32_25x10mm_I2C1_HW_MC_18F26K22_2021.mcppi
TEST_Mini_OLED_SSD1306_128x32_with_I2C1_HW_MikroC_18F26K22_2021_02_03.zip
Source principal : TEST_Mini_OLED_SSD1306_128x32_with_I2C1_HW_MikroC_18F26K22_2021_02_03.c
Oled source : OLED_128x32_I2C1_2021_02.c
Oled Header : OLED_128x32_I2C1_2021_02.h
Oled semi compile : OLED_128x32_I2C1_2021_02.mcl
images BMP : BMP_images_128x32_2021.inc
Config : Mini_OLED_128x32_25x10mm_I2C1_HW_MC_18F26K22_2021.cfg
Chargeur : Mini_OLED_128x32_25x10mm_I2C1_HW_MC_18F26K22_2021.hex
last upgrade:
Affichage Pixel, Ligne, Rectangle et cercle
copie , aussi, du texte dans RamBuffer , pour mélange texte (6x8) et grafique
Déroulement du Programme :
à rajouter ou peaufiner :
fonction XOR et AND grafiques,
melange Text taille 2 et 3 avec grafique
mélange Texte et BMP
Lien interessant :
Image to Adafruit OLED Bitmap Converter
les BMP 128x32 convertis , sont dans le fichier "BMP_images_128x32_1911.inc"
autre lien : // http://www.majer.ch/lcd/adf_bitmap.php
exemple : BMP_Paulfjujo_for_OLED_128x32.inc
Video :
Test_mini_Oled_128x32_191126.webm
Projet MikroBasic 7.50.
update 21/02/2023
SOFTWARE ;
Hardware :
Alim 3,5V
OLED sur I2C RC3=SCL et RC4 = SDA
UART1 sur RC7 =RX et RC6=TX
Led sur RA4 , avec R de rappel au +VCC
Version MikroBasic limitée ....
Affichage uniquement d'un caractere spécial ( Degré C)
en differentes positions de l'ecran mini OLED
Le programme :
Init FOSC interne à 16Mhz
Led clignotante sur RA4 .. Yes ! le programme tourne !
Init UART1 19200bds .. pour renseigner un peu ...
Const DegreC as byte[8]=($0F,$09,$0F,$00,$F8,$88,$88,$88)
Init complète de l'OLED
Effacement de l'écran (par remplissage)
Affichage lettre Degré C sur 4 positions
nota :
Affiche_Degre_Car_8x8(x,y)
X de 0 à 120
y de 0 à 3 (page ou ligne )
Affiche_Degre_Car_8x8(10,0)
Affiche_Degre_Car_8x8(40,1)
Affiche_Degre_Car_8x8(80,2)
Affiche_Degre_Car_8x8(110,3)
Projet: Test_Oled2.mbppi
TestOled_PSPIC.zip 21-02-2023
Source principale : test_Oled2.mbas
Chargeur :Test_Oled2.hex
voir discussions sur forum Fantaspic