orangepiZero2 最简单的oled开发

#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <stdint.h>

#include "oled.h"
#include "font.h"

int oled_show(struct display_info *disp) {
        int i;
        char buf[100];

        //putstrto(disp, 0, 0, "Spnd spd  2468 rpm");
        //      oled_putstrto(disp, 0, 9+1, "Spnd cur  0.46 A");
        oled_putstrto(disp, 0, 9+1, "Welcome       to");//把字符存入disp结构体中
        disp->font = font1;//设置字体

        oled_putstrto(disp,0,20,"-----MR.YU-----");
        disp->font=font1;
        oled_send_buffer(disp);//把缓存拷贝到oled屏幕
        //oled_putpixel(disp, 60, 45);
        //oled_putstr(disp, 1, "hello");

        return 0;
}

void show_error(int err, int add) {//在运行时必须打开相关的设备驱动  否则出错
        //const gchar* errmsg;
        //errmsg = g_strerror(errno);
        printf("\nERROR: %i, %i\n\n", err, add);
        //printf("\nERROR\n");
}

void show_usage(char *progname) {
        printf("\nUsage:\n%s <I2C bus device node >\n", progname);
}

int main(int argc, char **argv) {
        int e;
        char filename[32];
        struct display_info disp;

        if (argc < 2) {
                show_usage(argv[0]);

                return -1;
        }

        memset(&disp, 0, sizeof(disp));
        sprintf(filename, "%s", argv[1]);
        disp.address = OLED_I2C_ADDR;//设备地址
        disp.font = font2;

        e = oled_open(&disp, filename);//打开设备驱动

        e = oled_init(&disp);//初始化oled
        oled_show(&disp);//显示
        return 0;
}

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值