找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 673|回复: 6
收起左侧

请问LCD12232液晶屏如何实现反白显示

[复制链接]
ID:471636 发表于 2023-4-16 11:45 | 显示全部楼层 |阅读模式
看说明书  反白是扩展指令集  于是  发送0x34  指令   发送0X04 反白指令,结果显示字符都没了。
我用的是DM12232液晶屏。
回复

使用道具 举报

ID:220661 发表于 2023-4-16 13:37 | 显示全部楼层
你说的是反显吧?
回复

使用道具 举报

ID:1072104 发表于 2023-4-16 20:30 | 显示全部楼层
#include "stm32f10x.h"
#include "delay.h"

#define LCD_DATA        GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7
#define LCD_DATA_PORT   GPIOA
#define LCD_CMD         GPIO_Pin_8
#define LCD_CMD_PORT    GPIOB
#define LCD_RST         GPIO_Pin_9
#define LCD_RST_PORT    GPIOB
#define LCD_CS          GPIO_Pin_12
#define LCD_CS_PORT     GPIOB

void lcd_cmd(uint8_t cmd)
{
    LCD_CMD_PORT->BRR = LCD_CMD;  // 写命令选择
    LCD_CS_PORT->BRR = LCD_CS;    // 片选使能
    LCD_DATA_PORT->ODR = cmd;     // 写入命令
    Delay_us(10);                 // 延时10us
    LCD_CS_PORT->BSRR = LCD_CS;   // 片选禁止
}

void lcd_data(uint8_t data)
{
    LCD_CMD_PORT->BSRR = LCD_CMD; // 写数据选择
    LCD_CS_PORT->BRR = LCD_CS;    // 片选使能
    LCD_DATA_PORT->ODR = data;    // 写入数据
    Delay_us(10);                 // 延时10us
    LCD_CS_PORT->BSRR = LCD_CS;   // 片选禁止
}

void lcd_init(void)
{
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB, ENABLE);

    GPIO_InitTypeDef GPIO_InitStructure;

    // 配置LCD数据口为推挽输出
    GPIO_InitStructure.GPIO_Pin = LCD_DATA;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
    GPIO_Init(LCD_DATA_PORT, &GPIO_InitStructure);

    // 配置LCD命令口、复位口、片选口为推挽输出
    GPIO_InitStructure.GPIO_Pin = LCD_CMD | LCD_RST | LCD_CS;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
    GPIO_Init(LCD_CMD_PORT, &GPIO_InitStructure);
    GPIO_Init(LCD_RST_PORT, &GPIO_InitStructure);
    GPIO_Init(LCD_CS_PORT, &GPIO_InitStructure);

    // 复位液晶屏
    LCD_RST_PORT->BRR = LCD_RST;
    Delay_ms(10);
    LCD_RST_PORT->BSRR = LCD_RST;
    Delay_ms(10);

    // 扩展指令集设置
    lcd_cmd(0x34);  // 打开扩展指令集
    lcd_cmd(0x04);  // 打开反白显示

    // 显示控制参数设置
    lcd_cmd(0x30);  // 关闭扩展指令集
    lcd_cmd(0x0c);  // 显示开,无游标,不闪烁
    lcd_cmd(0x01);  // 清屏
}

void lcd_putchar(uint8_t ch)
{
    lcd_data(ch);
}

void lcd_puts(const char* str)
{
    while (*str) {
        lcd_data(*str++);
    }
}

void lcd_putnum(uint32_t num)
{
    uint8_t buf[10];
    uint8_t len = 0;
    do {
        buf[len++] = '0' + num % 10;
        num /= 10;
    } while (num > 0);

    for (int i = len - 1; i >= 0; i--) {
        lcd_data(buf[i]);
    }
}

int main(void)
{
    lcd_init();     // 初始化液晶屏
    lcd_puts("Hello, world!");   // 显示字符

    while(1);
}
这是一份基础代码示例,你根据自己实际的需求进行适应和调整。
回复

使用道具 举报

ID:471636 发表于 2023-4-16 22:51 | 显示全部楼层
是的  反显
回复

使用道具 举报

ID:1034262 发表于 2023-4-17 10:30 | 显示全部楼层

如果是用的自激的字库,则将点阵取反即可。
回复

使用道具 举报

ID:584814 发表于 2023-4-17 11:03 | 显示全部楼层
反显,要不用物理方式直接买成品;
要不用将现在打点的地方空、空的地方打点。
回复

使用道具 举报

ID:471636 发表于 2023-4-17 20:28 | 显示全部楼层
反白是不是只支持绘图模式,不支持字符模式?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表