【跟二叔玩bpi-m1】播放视频bad apple on bpi(spi oled)

作者: 栗叔
上传时间为: 2015-01-08 03:20 PM

标题和图片都说明了这个是适用于BPI-M1的,当让R1也应该可以玩,这个是以前静态玩法的续集

可以自己编译代码,也可以下载打包好的代码玩,

OLED就先玩这么多吧,视频效果蛮流畅的,先上代码,后附视频

#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];

void oled_begin();
void oled_test();

int main(void)
{
	time_t now;
	struct tm *timenow;

	wiringPiSetup();

	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 r;
	FILE *fphzk;
	digitalWrite(5, LOW);
	wiringPiSPIDataRW(0, poscode, 5);
	fphzk=fopen("apple.dat","rb");
	r=fread(buffer,1,BUFFER_SIZE,fphzk);
	while(r>0)
	{
		digitalWrite(5, HIGH);
		wiringPiSPIDataRW(0, buffer, 1024);
		r=fread(buffer,1,BUFFER_SIZE,fphzk);
		delay(66);
	}
	fclose(fphzk);
}

运行代码请用  ./apple

大家都玩起来吧

完整代码包:

http://u.163.com/VXH0Ez7o 提取码: b5P5jSAV

全部评论 ()

创建讨论帖子

登录 后参与评论
系统提示