查看: 2908|回复: 2

【跟二叔玩bananapi】之八:老邓的SPI-OLED

[复制链接]
  • TA的每日心情
    擦汗
    2015-3-6 13:14
  • 签到天数: 6 天

    连续签到: 1 天

    [LV.2]偶尔看看I

    发表于 2015-1-6 10:19:51 | 显示全部楼层 |阅读模式
    分享到:
    老邓的OLED,包装相当给力,专业电商,给力!http://www.52pi.net


    里三层外三层,照了一张For BPI忘了传了,
    反正大家都照了,就不补了,
           

            使用wiringPi库
    要加载请用gpio load spi命令
    效果如下,显示的是一个叫1024的图片


    下边是程序52pi.c,附件中有程序和1024文件

    view plaincopy to clipboardprint?

    • #include <wiringPi.h>  
    • #include <wiringPiSPI.h>  
    • #include <stdio.h>   
    • #include <stdlib.h>   
    • #include <stdint.h>  
    • #include <string.h>  
    • #include <time.h>  
    •   
    • unsigned char initcode[] = {  
    •     0xAE, 0xA8, 0x3F, 0xD3, 0x00, 0x40, 0xA1, 0xC8,  
    •     0xA6, 0xD5, 0x80, 0xDA, 0x12, 0x81, 0x00, 0xB0,  
    •     0xA4, 0xDB, 0x40, 0x20, 0x00, 0x00, 0x10, 0x8D,  
    •     0x14, 0x2E, 0xA6, 0xAF   
    • };  
    •   
    • unsigned char poscode[] = {  
    •     0x20, 0x00, 0xB0, 0x00, 0x10  
    • };  
    •   
    • #define BUFFER_SIZE 1024  
    • unsigned char buffer[BUFFER_SIZE];  
    • unsigned char buffer_temp[BUFFER_SIZE];  
    •   
    • void oled_begin();  
    • void oled_test();  
    •   
    • int main(void)  
    • {  
    •     FILE *fphzk;  
    •     time_t now;  
    •     struct tm *timenow;  
    •   
    •     wiringPiSetup();  
    •     fphzk=fopen("1024","rb");  
    •     fread(buffer,1,BUFFER_SIZE,fphzk);  
    •     fclose(fphzk);  
    •   
    •     oled_begin();  
    •   
    •     time(&now);     
    •     timenow = localtime(&now);      
    •     printf("Start time is %s/n",asctime(timenow));   
    •   
    •     oled_test();  
    •   
    •     time(&now);     
    •     timenow = localtime(&now);      
    •     printf("End time is %s/n",asctime(timenow));   
    •   
    •     return 0;  
    • }  
    •   
    • void oled_begin()  
    • {         
    •     pinMode (5, OUTPUT) ;  
    •     pinMode (6, OUTPUT) ;  
    •     wiringPiSPISetup(0, 32*1000*1000);  
    •     digitalWrite(6,  LOW) ;  
    •     delay(50);  
    •     digitalWrite(6,  HIGH) ;  
    •     digitalWrite(5, LOW);  
    •     wiringPiSPIDataRW(0, initcode, 28);  
    • }  
    •   
    • void oled_test()  
    • {   
    •     int i,j,k;  
    •     unsigned char temp;  
    •   
    •     for(k=0;k<10000;k++)  
    •     {  
    •         digitalWrite(5, LOW);  
    •         wiringPiSPIDataRW(0, poscode, 5);  
    •         memcpy(buffer_temp, buffer, BUFFER_SIZE);                 
    •         digitalWrite(5, HIGH);  
    •         wiringPiSPIDataRW(0, buffer_temp, 1024);  
    •   
    •         for(i=0;i<BUFFER_SIZE;i+=128)  
    •         {  
    •             for(j=0;j<((i<256)?2:1);j++)  
    •             {  
    •                 temp=buffer;  
    •                 memcpy(&buffer, &buffer[i+1], 127);            
    •                 buffer[i+127]=temp;  
    •             }  
    •         }  
    •         delay(10);  
    •     }  
    • }  

           
    编译请用命令gcc -Wall -o 52pi 52pi.c -lwiringPi
    运行./52pi


    相当富有动感,每秒能刷多少帧?自己测试吧
    程序包下载 http://u.163.com/xII5bPrn  提取码: qzcxEPop
    回复

    使用道具 举报

  • TA的每日心情
    开心
    2016-8-15 09:30
  • 签到天数: 162 天

    连续签到: 1 天

    [LV.7]常住居民III

    发表于 2015-1-6 16:55:20 | 显示全部楼层
    二叔给力!
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    开心
    2019-6-24 16:41
  • 签到天数: 709 天

    连续签到: 1 天

    [LV.9]以坛为家II

    发表于 2015-1-6 21:21:50 | 显示全部楼层
    不错啊,,,,,,,,,,,,
    回复 支持 反对

    使用道具 举报

    您需要登录后才可以回帖 注册/登录

    本版积分规则

    关闭

    站长推荐上一条 /1 下一条



    手机版|小黑屋|与非网

    GMT+8, 2024-6-3 06:00 , Processed in 0.115293 second(s), 19 queries , MemCache On.

    ICP经营许可证 苏B2-20140176  苏ICP备14012660号-2   苏州灵动帧格网络科技有限公司 版权所有.

    苏公网安备 32059002001037号

    Powered by Discuz! X3.4

    Copyright © 2001-2024, Tencent Cloud.