Technology sharing

TB opera] 51 unum chip Proteus

2024-07-12

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

Insert imaginem descriptionis hic

// GND power ground
// VCC coniungitur cum 5V vel 3.3v copiae potestatis
// D0 P1^4(SCL)
// D1 P1^3(SDA)
// RES coniuncta est cum P12
// DC connectit se P11
// CS coniungit P10

OLED ostentationem interface et imperium experimentum report

background

OLED (organicum diode-levis emittens) ostentationes late in variis electronicis machinis adhibitae sunt ob earum altam rationi discrepantiam, vim humilem consummationem et tempus velox responsionis. Hoc experimentum destinatur ad ostentationem OLED interfaciendam et moderandum microcontroller utens. Usus exactoris ostentationis SSD1306 est, quae communis usus est pro tegumentis parvis OLED.

Hardware components

  1. OLED ostentationem: moduli ostentus usus ab SSD1306 moderatoris acti.
  2. Microcontroller: Utere an 8051 microcontroller-substructio ad ostentationem OLED regendam.
  3. potentia copia: A 3.3V vel 5V copia virtutis OLED moduli requiritur.
  4. Connectens linea: coniungere OLED cum microcontroller.

Circuitus nexum

  • GND: coniungo ad virtutem humum.
  • VCC: coniungere ad 3.3V vel 5V copiam virtutis.
  • D0 (SCL): coniunge P1^4 (SCL).
  • D1 (SDA): coniunge P1^3 (SDA).
  • RES: coniungere ad P12.
  • DC: coniungere P11.
  • CS: coniungere P10.

Design principia

Memoria compages

Forma repositionis video memoriam OLED sic se habet:

[0]0 1 2 3 ... 127
[1]0 1 2 3 ... 127
[2]0 1 2 3 ... 127
...
[7]0 1 2 3 ... 127
  • 1
  • 2
  • 3
  • 4
  • 5

munus mora

void delay_ms1(unsigned int ms) {
    unsigned int a;
    while (ms) {
        a = 80;
        while (a--);
        ms--;
    }
    return;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

Haec mora functionis instrumentorum millium secundorum graduum moras per ansam simplicem adhibet ut operatio stabilis per initializationem et imperium OLED adhibeatur.

scribentes injustitiam bytes

Secundum modum OLED, bytes ad SSD1306 scripta sunt per interfaciem parallelam seu serialem. Sequens codice demonstrat operationes scribere in modos parallelas et vide:

#if OLED_MODE == 1
// 并行模式
void OLED_WR_Byte(u8 dat, u8 cmd) {
    DATAOUT(dat);
    if (cmd) OLED_DC_Set();
    else OLED_DC_Clr();
    OLED_CS_Clr();
    OLED_WR_Clr();
    OLED_WR_Set();
    OLED_CS_Set();
    OLED_DC_Set();
}
#else
// 串行模式
void OLED_WR_Byte(u8 dat, u8 cmd) {
    u8 i;
    if (cmd) OLED_DC_Set();
    else OLED_DC_Clr();
    OLED_CS_Clr();
    for (i = 0; i < 8; i++) {
        OLED_SCLK_Clr();
        if (dat & 0x80) OLED_SDIN_Set();
        else OLED_SDIN_Clr();
        OLED_SCLK_Set();
        dat <<= 1;
    }
    OLED_CS_Set();
    OLED_DC_Set();
}
#endif
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30

Praecipuum munus implementation

Set cursor situ
void OLED_Set_Pos(unsigned char x, unsigned char y) {
    OLED_WR_Byte(0xb0 + y, OLED_CMD);
    OLED_WR_Byte(((x & 0xf0) >> 4) | 0x10, OLED_CMD);
    OLED_WR_Byte((x & 0x0f) | 0x01, OLED_CMD);
}
  • 1
  • 2
  • 3
  • 4
  • 5
ostentationem imperium

Verte OLED ostentationem interdum;

void OLED_Display_On(void) {
    OLED_WR_Byte(0X8D, OLED_CMD); // SET DCDC命令
    OLED_WR_Byte(0X14, OLED_CMD); // DCDC ON
    OLED_WR_Byte(0XAF, OLED_CMD); // DISPLAY ON
}

void OLED_Display_Off(void) {
    OLED_WR_Byte(0X8D, OLED_CMD); // SET DCDC命令
    OLED_WR_Byte(0X10, OLED_CMD); // DCDC OFF
    OLED_WR_Byte(0XAE, OLED_CMD); // DISPLAY OFF
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
patet screen
void OLED_Clear(void) {
    u8 i, n;
    for (i = 0; i < 8; i++) {
        OLED_WR_Byte(0xb0 + i, OLED_CMD); // 设置页地址(0~7)
        OLED_WR_Byte(0x00, OLED_CMD);     // 设置显示位置—列低地址
        OLED_WR_Byte(0x10, OLED_CMD);     // 设置显示位置—列高地址
        for (n = 0; n < 128; n++) OLED_WR_Byte(0, OLED_DATA);
    }
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
ostentationem characteribus

Mores ad certum locum

void OLED_ShowChar(u8 x, u8 y, u8 chr) {
    unsigned char c = 0, i = 0;
    c = chr - ' ';
    if (x > Max_Column - 1) {
        x = 0; y = y + 2;
    }
    if (SIZE == 16) {
        OLED_Set_Pos(x, y);
        for (i = 0; i < 8; i++) OLED_WR_Byte(F8X16[c * 16 + i], OLED_DATA);
        OLED_Set_Pos(x, y + 1);
        for (i = 0; i < 8; i++) OLED_WR_Byte(F8X16[c * 16 + i + 8], OLED_DATA);
    } else {
        OLED_Set_Pos(x, y + 1);
        for (i = 0; i < 6; i++) OLED_WR_Byte(F6x8[c][i], OLED_DATA);
    }
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
ostentationem filum
void OLED_ShowString(u8 x, u8 y, u8 *chr) {
    unsigned char j = 0;
    while (chr[j] != '0') {
        OLED_ShowChar(x, y, chr[j]);
        x += 8;
        if (x > 120) {
            x = 0; y += 2;
        }
        j++;
    }
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

initialization "

Processus initialization OLED implicat seriem configurationis mandati ut ostentus recte laborat;

void OLED_Init(void) {
    OLED_RST_Set();
    delay_ms1(100);
    OLED_RST_Clr();
    delay_ms1(100);
    OLED_RST_Set();

    OLED_WR_Byte(0xAE, OLED_CMD); // 关闭OLED面板
    OLED_WR_Byte(0x00, OLED_CMD); // 设置低列地址
    OLED_WR_Byte(0x10, OLED_CMD); // 设置高列地址
    OLED_WR_Byte(0x40, OLED_CMD); // 设置起始行地址
    OLED_WR_Byte(0x81, OLED_CMD); // 设置对比度控制寄存器
    OLED_WR_Byte(0xCF, OLED_CMD); // 设置SEG输出电流亮度
    OLED_WR_Byte(0xA1, OLED_CMD); // 设置段/列映射
    OLED_WR_Byte(0xC8, OLED_CMD); // 设置COM/行扫描方向
    OLED_WR_Byte(0xA6, OLED_CMD); // 设置正常显示
    OLED_WR_Byte(0xA8, OLED_CMD); // 设置多路复用比率
    OLED_WR_Byte(0x3f, OLED_CMD); // 1/64 duty
    OLED_WR_Byte(0xD3, OLED_CMD); // 设置显示偏移
    OLED_WR_Byte(0x00, OLED_CMD); // 不偏移
    OLED_WR_Byte(0xd5, OLED_CMD); // 设置显示时钟分频比/振荡频率
    OLED_WR_Byte(0x80, OLED_CMD); // 设置时钟为100帧/秒
    OLED_WR_Byte(0xD9, OLED_CMD); // 设置预充电周期
    OLED_WR_Byte(0xF1, OLED_CMD); // 设置预充电为15时钟和放电为1时钟
    OLED_WR_Byte(0xDA, OLED_CMD); // 设置COM引脚硬件配置
    OLED_WR_Byte(0x12, OLED_CMD);
    OLED_WR_Byte(0xDB, OLED_CMD); // 设置VCOMH
    OLED_WR_Byte(0x40, OLED_CMD); // 设置VCOM解除电平
    OLED_WR_Byte(0x20, OLED_CMD); // 设置页地址模式
    OLED_WR_Byte(0x02, OLED_CMD);
    OLED_WR_Byte(0x8D, OLED_CMD); // 设置电荷泵使能/禁用
    OLED_WR_Byte(0x14, OLED_CMD); // 设置(0x10)禁用
    OLED_WR_Byte(0xA4, OLED_CMD); // 禁用整个显示
    OLED_WR_Byte(0xA6, OLED_CMD); // 禁用反向显示
    OLED_WR_Byte(0xAF, OLED_CMD); // 打开OLED面板
    OLED_Clear();
    OLED_Set_Pos(0, 0);
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38

materia

https://docs.qq.com/sheet/DUEdqZ2lmbmR6UVdU?tab=BB08J2
  • 1