一、首先采集摄像头图像,由于硬件不同采集方式也不一样,我就不多做说明

二、将采集到的图像进行二值化

三、下面为完整显示函数

备注:大家主需要修改对应的引脚就行(修改初始化和宏定义)

led.c文件

#include  "common.h"
#include "lcd.h"
#include "MK60_gpio.h"#define XLevelL     0x00
#define XLevelH     0x10
#define XLevel      ((XLevelH&0x0F)*16+XLevelL)
#define Max_Column  128
#define Max_Row       64
#define Brightness  0xCF #define X_WIDTH 128
#define Y_WIDTH 64
//======================================
const byte F6x8[][6] =
{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   // sp{ 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00 },   // !{ 0x00, 0x00, 0x07, 0x00, 0x07, 0x00 },   // "{ 0x00, 0x14, 0x7f, 0x14, 0x7f, 0x14 },   // #{ 0x00, 0x24, 0x2a, 0x7f, 0x2a, 0x12 },   // ${ 0x00, 0x62, 0x64, 0x08, 0x13, 0x23 },   // %{ 0x00, 0x36, 0x49, 0x55, 0x22, 0x50 },   // &{ 0x00, 0x00, 0x05, 0x03, 0x00, 0x00 },   // '{ 0x00, 0x00, 0x1c, 0x22, 0x41, 0x00 },   // ({ 0x00, 0x00, 0x41, 0x22, 0x1c, 0x00 },   // ){ 0x00, 0x14, 0x08, 0x3E, 0x08, 0x14 },   // *{ 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08 },   // +{ 0x00, 0x00, 0x00, 0xA0, 0x60, 0x00 },   // ,{ 0x00, 0x08, 0x08, 0x08, 0x08, 0x08 },   // -{ 0x00, 0x00, 0x60, 0x60, 0x00, 0x00 },   // .{ 0x00, 0x20, 0x10, 0x08, 0x04, 0x02 },   // /{ 0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E },   // 0{ 0x00, 0x00, 0x42, 0x7F, 0x40, 0x00 },   // 1{ 0x00, 0x42, 0x61, 0x51, 0x49, 0x46 },   // 2{ 0x00, 0x21, 0x41, 0x45, 0x4B, 0x31 },   // 3{ 0x00, 0x18, 0x14, 0x12, 0x7F, 0x10 },   // 4{ 0x00, 0x27, 0x45, 0x45, 0x45, 0x39 },   // 5{ 0x00, 0x3C, 0x4A, 0x49, 0x49, 0x30 },   // 6{ 0x00, 0x01, 0x71, 0x09, 0x05, 0x03 },   // 7{ 0x00, 0x36, 0x49, 0x49, 0x49, 0x36 },   // 8{ 0x00, 0x06, 0x49, 0x49, 0x29, 0x1E },   // 9{ 0x00, 0x00, 0x36, 0x36, 0x00, 0x00 },   // :{ 0x00, 0x00, 0x56, 0x36, 0x00, 0x00 },   // ;{ 0x00, 0x08, 0x14, 0x22, 0x41, 0x00 },   // <{ 0x00, 0x14, 0x14, 0x14, 0x14, 0x14 },   // ={ 0x00, 0x00, 0x41, 0x22, 0x14, 0x08 },   // >{ 0x00, 0x02, 0x01, 0x51, 0x09, 0x06 },   // ?{ 0x00, 0x32, 0x49, 0x59, 0x51, 0x3E },   // @{ 0x00, 0x7C, 0x12, 0x11, 0x12, 0x7C },   // A{ 0x00, 0x7F, 0x49, 0x49, 0x49, 0x36 },   // B{ 0x00, 0x3E, 0x41, 0x41, 0x41, 0x22 },   // C{ 0x00, 0x7F, 0x41, 0x41, 0x22, 0x1C },   // D{ 0x00, 0x7F, 0x49, 0x49, 0x49, 0x41 },   // E{ 0x00, 0x7F, 0x09, 0x09, 0x09, 0x01 },   // F{ 0x00, 0x3E, 0x41, 0x49, 0x49, 0x7A },   // G{ 0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F },   // H{ 0x00, 0x00, 0x41, 0x7F, 0x41, 0x00 },   // I{ 0x00, 0x20, 0x40, 0x41, 0x3F, 0x01 },   // J{ 0x00, 0x7F, 0x08, 0x14, 0x22, 0x41 },   // K{ 0x00, 0x7F, 0x40, 0x40, 0x40, 0x40 },   // L{ 0x00, 0x7F, 0x02, 0x0C, 0x02, 0x7F },   // M{ 0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F },   // N{ 0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E },   // O{ 0x00, 0x7F, 0x09, 0x09, 0x09, 0x06 },   // P{ 0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E },   // Q{ 0x00, 0x7F, 0x09, 0x19, 0x29, 0x46 },   // R{ 0x00, 0x46, 0x49, 0x49, 0x49, 0x31 },   // S{ 0x00, 0x01, 0x01, 0x7F, 0x01, 0x01 },   // T{ 0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F },   // U{ 0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F },   // V{ 0x00, 0x3F, 0x40, 0x38, 0x40, 0x3F },   // W{ 0x00, 0x63, 0x14, 0x08, 0x14, 0x63 },   // X{ 0x00, 0x07, 0x08, 0x70, 0x08, 0x07 },   // Y{ 0x00, 0x61, 0x51, 0x49, 0x45, 0x43 },   // Z{ 0x00, 0x00, 0x7F, 0x41, 0x41, 0x00 },   // [{ 0x00, 0x55, 0x2A, 0x55, 0x2A, 0x55 },   // 55{ 0x00, 0x00, 0x41, 0x41, 0x7F, 0x00 },   // ]{ 0x00, 0x04, 0x02, 0x01, 0x02, 0x04 },   // ^{ 0x00, 0x40, 0x40, 0x40, 0x40, 0x40 },   // _{ 0x00, 0x00, 0x01, 0x02, 0x04, 0x00 },   // '{ 0x00, 0x20, 0x54, 0x54, 0x54, 0x78 },   // a{ 0x00, 0x7F, 0x48, 0x44, 0x44, 0x38 },   // b{ 0x00, 0x38, 0x44, 0x44, 0x44, 0x20 },   // c{ 0x00, 0x38, 0x44, 0x44, 0x48, 0x7F },   // d{ 0x00, 0x38, 0x54, 0x54, 0x54, 0x18 },   // e{ 0x00, 0x08, 0x7E, 0x09, 0x01, 0x02 },   // f{ 0x00, 0x18, 0xA4, 0xA4, 0xA4, 0x7C },   // g{ 0x00, 0x7F, 0x08, 0x04, 0x04, 0x78 },   // h{ 0x00, 0x00, 0x44, 0x7D, 0x40, 0x00 },   // i{ 0x00, 0x40, 0x80, 0x84, 0x7D, 0x00 },   // j{ 0x00, 0x7F, 0x10, 0x28, 0x44, 0x00 },   // k{ 0x00, 0x00, 0x41, 0x7F, 0x40, 0x00 },   // l{ 0x00, 0x7C, 0x04, 0x18, 0x04, 0x78 },   // m{ 0x00, 0x7C, 0x08, 0x04, 0x04, 0x78 },   // n{ 0x00, 0x38, 0x44, 0x44, 0x44, 0x38 },   // o{ 0x00, 0xFC, 0x24, 0x24, 0x24, 0x18 },   // p{ 0x00, 0x18, 0x24, 0x24, 0x18, 0xFC },   // q{ 0x00, 0x7C, 0x08, 0x04, 0x04, 0x08 },   // r{ 0x00, 0x48, 0x54, 0x54, 0x54, 0x20 },   // s{ 0x00, 0x04, 0x3F, 0x44, 0x40, 0x20 },   // t{ 0x00, 0x3C, 0x40, 0x40, 0x20, 0x7C },   // u{ 0x00, 0x1C, 0x20, 0x40, 0x20, 0x1C },   // v{ 0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C },   // w{ 0x00, 0x44, 0x28, 0x10, 0x28, 0x44 },   // x{ 0x00, 0x1C, 0xA0, 0xA0, 0xA0, 0x7C },   // y{ 0x00, 0x44, 0x64, 0x54, 0x4C, 0x44 },   // z{ 0x14, 0x14, 0x14, 0x14, 0x14, 0x14 }    // horiz lines
};
const byte F14x16_Idx[] =
{"陇东学院劲速队"
};
const byte F14x16[] = {
0x00,0xFC,0x44,0xA4,0x1C,0x10,0x10,0xFE,0x10,0x12,0x1C,0x90,0x10,0x00,
0x00,0x3F,0x04,0x24,0x13,0x0C,0x23,0x10,0x1F,0x24,0x22,0x21,0x18,0x00,//陇0
0x08,0x88,0x88,0xE8,0x98,0x8E,0xE8,0x88,0x88,0x88,0x88,0x08,0x08,0x00,
0x20,0x10,0x08,0x06,0x20,0x20,0x1F,0x00,0x02,0x04,0x18,0x30,0x00,0x00,//东1
0x70,0x12,0x54,0x50,0x50,0x52,0x54,0x50,0xD8,0x54,0x12,0x10,0x70,0x00,
0x02,0x02,0x02,0x02,0x22,0x22,0x3E,0x03,0x02,0x02,0x02,0x02,0x02,0x00,//学2
0xFE,0x22,0x5A,0x86,0x9C,0xA4,0xA4,0xA4,0xA6,0xA4,0xA4,0xA4,0x9C,0x00,
0x3F,0x02,0x04,0x23,0x20,0x10,0x0C,0x03,0x00,0x1F,0x20,0x20,0x38,0x00,//院3
0x80,0x42,0xA2,0x92,0x9A,0xA6,0x50,0x10,0xFE,0x10,0x10,0xF0,0x00,0x00,
0x10,0x10,0x10,0x0F,0x08,0x28,0x10,0x0E,0x11,0x20,0x20,0x1F,0x00,0x00,//劲4
0x42,0x44,0xCC,0x00,0xE8,0x28,0x28,0xFE,0x28,0x28,0xE8,0x08,0x00,0x00,
0x20,0x10,0x0F,0x10,0x29,0x25,0x23,0x3F,0x23,0x25,0x2D,0x20,0x20,0x00,//速5
0xFE,0x02,0x22,0x5A,0x86,0x00,0x00,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,
0x3F,0x04,0x08,0x04,0x23,0x10,0x0C,0x03,0x00,0x03,0x0C,0x10,0x20,0x00,//队6
};//======================================================
// 128X64I液晶底层驱动[8X16]字体库
// 设计者: 小灰灰
// 描  述: [8X16]西文字符的字模数据 (纵向取模,字节倒序)
// !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
//======================================================
const byte F8X16[]=
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 00x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x30,0x00,0x00,0x00,//!10x00,0x10,0x0C,0x06,0x10,0x0C,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//"20x40,0xC0,0x78,0x40,0xC0,0x78,0x40,0x00,0x04,0x3F,0x04,0x04,0x3F,0x04,0x04,0x00,//#30x00,0x70,0x88,0xFC,0x08,0x30,0x00,0x00,0x00,0x18,0x20,0xFF,0x21,0x1E,0x00,0x00,//$40xF0,0x08,0xF0,0x00,0xE0,0x18,0x00,0x00,0x00,0x21,0x1C,0x03,0x1E,0x21,0x1E,0x00,//%50x00,0xF0,0x08,0x88,0x70,0x00,0x00,0x00,0x1E,0x21,0x23,0x24,0x19,0x27,0x21,0x10,//&60x10,0x16,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//'70x00,0x00,0x00,0xE0,0x18,0x04,0x02,0x00,0x00,0x00,0x00,0x07,0x18,0x20,0x40,0x00,//(80x00,0x02,0x04,0x18,0xE0,0x00,0x00,0x00,0x00,0x40,0x20,0x18,0x07,0x00,0x00,0x00,//)90x40,0x40,0x80,0xF0,0x80,0x40,0x40,0x00,0x02,0x02,0x01,0x0F,0x01,0x02,0x02,0x00,//*100x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x1F,0x01,0x01,0x01,0x00,//+110x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xB0,0x70,0x00,0x00,0x00,0x00,0x00,//,120x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,//-130x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00,//.140x00,0x00,0x00,0x00,0x80,0x60,0x18,0x04,0x00,0x60,0x18,0x06,0x01,0x00,0x00,0x00,///150x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,//0160x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//1170x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,//2180x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00,//3190x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,//4200x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00,//5210x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00,//6220x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,//7230x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,//8240x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00,//9250x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,//:260x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x60,0x00,0x00,0x00,0x00,//;270x00,0x00,0x80,0x40,0x20,0x10,0x08,0x00,0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x00,//<280x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00,//=290x00,0x08,0x10,0x20,0x40,0x80,0x00,0x00,0x00,0x20,0x10,0x08,0x04,0x02,0x01,0x00,//>300x00,0x70,0x48,0x08,0x08,0x08,0xF0,0x00,0x00,0x00,0x00,0x30,0x36,0x01,0x00,0x00,//?310xC0,0x30,0xC8,0x28,0xE8,0x10,0xE0,0x00,0x07,0x18,0x27,0x24,0x23,0x14,0x0B,0x00,//@320x00,0x00,0xC0,0x38,0xE0,0x00,0x00,0x00,0x20,0x3C,0x23,0x02,0x02,0x27,0x38,0x20,//A330x08,0xF8,0x88,0x88,0x88,0x70,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x11,0x0E,0x00,//B340xC0,0x30,0x08,0x08,0x08,0x08,0x38,0x00,0x07,0x18,0x20,0x20,0x20,0x10,0x08,0x00,//C350x08,0xF8,0x08,0x08,0x08,0x10,0xE0,0x00,0x20,0x3F,0x20,0x20,0x20,0x10,0x0F,0x00,//D360x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x20,0x23,0x20,0x18,0x00,//E370x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x00,0x03,0x00,0x00,0x00,//F380xC0,0x30,0x08,0x08,0x08,0x38,0x00,0x00,0x07,0x18,0x20,0x20,0x22,0x1E,0x02,0x00,//G390x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x20,0x3F,0x21,0x01,0x01,0x21,0x3F,0x20,//H400x00,0x08,0x08,0xF8,0x08,0x08,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//I410x00,0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,0x00,//J420x08,0xF8,0x88,0xC0,0x28,0x18,0x08,0x00,0x20,0x3F,0x20,0x01,0x26,0x38,0x20,0x00,//K430x08,0xF8,0x08,0x00,0x00,0x00,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x20,0x30,0x00,//L440x08,0xF8,0xF8,0x00,0xF8,0xF8,0x08,0x00,0x20,0x3F,0x00,0x3F,0x00,0x3F,0x20,0x00,//M450x08,0xF8,0x30,0xC0,0x00,0x08,0xF8,0x08,0x20,0x3F,0x20,0x00,0x07,0x18,0x3F,0x00,//N460xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x10,0x20,0x20,0x20,0x10,0x0F,0x00,//O470x08,0xF8,0x08,0x08,0x08,0x08,0xF0,0x00,0x20,0x3F,0x21,0x01,0x01,0x01,0x00,0x00,//P480xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x18,0x24,0x24,0x38,0x50,0x4F,0x00,//Q490x08,0xF8,0x88,0x88,0x88,0x88,0x70,0x00,0x20,0x3F,0x20,0x00,0x03,0x0C,0x30,0x20,//R500x00,0x70,0x88,0x08,0x08,0x08,0x38,0x00,0x00,0x38,0x20,0x21,0x21,0x22,0x1C,0x00,//S510x18,0x08,0x08,0xF8,0x08,0x08,0x18,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,//T520x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,//U530x08,0x78,0x88,0x00,0x00,0xC8,0x38,0x08,0x00,0x00,0x07,0x38,0x0E,0x01,0x00,0x00,//V540xF8,0x08,0x00,0xF8,0x00,0x08,0xF8,0x00,0x03,0x3C,0x07,0x00,0x07,0x3C,0x03,0x00,//W550x08,0x18,0x68,0x80,0x80,0x68,0x18,0x08,0x20,0x30,0x2C,0x03,0x03,0x2C,0x30,0x20,//X560x08,0x38,0xC8,0x00,0xC8,0x38,0x08,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,//Y570x10,0x08,0x08,0x08,0xC8,0x38,0x08,0x00,0x20,0x38,0x26,0x21,0x20,0x20,0x18,0x00,//Z580x00,0x00,0x00,0xFE,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x7F,0x40,0x40,0x40,0x00,//[590x00,0x0C,0x30,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x06,0x38,0xC0,0x00,//\600x00,0x02,0x02,0x02,0xFE,0x00,0x00,0x00,0x00,0x40,0x40,0x40,0x7F,0x00,0x00,0x00,//]610x00,0x00,0x04,0x02,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//^620x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,//_630x00,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//`640x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x19,0x24,0x22,0x22,0x22,0x3F,0x20,//a650x08,0xF8,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x3F,0x11,0x20,0x20,0x11,0x0E,0x00,//b660x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x0E,0x11,0x20,0x20,0x20,0x11,0x00,//c670x00,0x00,0x00,0x80,0x80,0x88,0xF8,0x00,0x00,0x0E,0x11,0x20,0x20,0x10,0x3F,0x20,//d680x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x22,0x22,0x22,0x22,0x13,0x00,//e690x00,0x80,0x80,0xF0,0x88,0x88,0x88,0x18,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//f700x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x6B,0x94,0x94,0x94,0x93,0x60,0x00,//g710x08,0xF8,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,//h720x00,0x80,0x98,0x98,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//i730x00,0x00,0x00,0x80,0x98,0x98,0x00,0x00,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,//j740x08,0xF8,0x00,0x00,0x80,0x80,0x80,0x00,0x20,0x3F,0x24,0x02,0x2D,0x30,0x20,0x00,//k750x00,0x08,0x08,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//l760x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x20,0x3F,0x20,0x00,0x3F,0x20,0x00,0x3F,//m770x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,//n780x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,//o790x80,0x80,0x00,0x80,0x80,0x00,0x00,0x00,0x80,0xFF,0xA1,0x20,0x20,0x11,0x0E,0x00,//p800x00,0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x0E,0x11,0x20,0x20,0xA0,0xFF,0x80,//q810x80,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x20,0x20,0x3F,0x21,0x20,0x00,0x01,0x00,//r820x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x33,0x24,0x24,0x24,0x24,0x19,0x00,//s830x00,0x80,0x80,0xE0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x1F,0x20,0x20,0x00,0x00,//t840x80,0x80,0x00,0x00,0x00,0x80,0x80,0x00,0x00,0x1F,0x20,0x20,0x20,0x10,0x3F,0x20,//u850x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x00,0x01,0x0E,0x30,0x08,0x06,0x01,0x00,//v860x80,0x80,0x00,0x80,0x00,0x80,0x80,0x80,0x0F,0x30,0x0C,0x03,0x0C,0x30,0x0F,0x00,//w870x00,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x31,0x2E,0x0E,0x31,0x20,0x00,//x880x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x80,0x81,0x8E,0x70,0x18,0x06,0x01,0x00,//y890x00,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x21,0x30,0x2C,0x22,0x21,0x30,0x00,//z900x00,0x00,0x00,0x00,0x80,0x7C,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x3F,0x40,0x40,//{910x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,//|920x00,0x02,0x02,0x7C,0x80,0x00,0x00,0x00,0x00,0x40,0x40,0x3F,0x00,0x00,0x00,0x00,//}930x00,0x06,0x01,0x01,0x02,0x02,0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//~94};void LCD_WrDat(uint8 data)
{byte i=8; DC=1;asm("nop"); D0=0;asm("nop");    while(i--){if(data&0x80){D1=1;}else{D1=0;}D0=1;asm("nop");  D0=0;  data<<=1;    }
}
void LCD_WrCmd(byte cmd)
{byte i=8;DC=0;D0=0;   while(i--){if(cmd&0x80){D1=1;}else{D1=0; }D0=1;asm("nop");   D0=0;  cmd<<=1;   }
}
void LCD_Set_Pos(byte x, byte y)
{ LCD_WrCmd(0xb0+y);LCD_WrCmd(((x&0xf0)>>4)|0x10);LCD_WrCmd(x&0x0f);//|0x01);
}
void LCD_Fill(byte bmp_data)
{byte y,x;for(y=0;y<8;y++){LCD_WrCmd(0xb0+y);LCD_WrCmd(0x01);LCD_WrCmd(0x10);for(x=0;x<X_WIDTH;x++)LCD_WrDat(bmp_data);}
}
void LCD_CLS(void)
{byte y,x;  for(y=0;y<8;y++){LCD_WrCmd(0xb0+y);LCD_WrCmd(0x01);LCD_WrCmd(0x10); for(x=0;x<X_WIDTH;x++)LCD_WrDat(0);}
}
void LCD_DLY_ms(word ms)
{                         word a;while(ms){a=13350;while(a--);ms--;}return;
}void LCD_Init(void)
{gpio_init (PTB16, GPO,0);gpio_init (PTB18, GPO,0);gpio_init (PTB17, GPO,1);gpio_init (PTB19, GPO,0);gpio_init (PTB20, GPO,0);RESET=0;LCD_DLY_ms(50);RESET=1;LCD_WrCmd(0xae);//--turn off oled panelLCD_WrCmd(0x00);//---set low column addressLCD_WrCmd(0x10);//---set high column addressLCD_WrCmd(0x40);//--set start line address  Set Mapping RAM Display Start Line (0x00~0x3F)LCD_WrCmd(0x81);//--set contrast control registerLCD_WrCmd(0xcf); // Set SEG Output Current BrightnessLCD_WrCmd(0xa1);//--Set SEG/Column Mapping     0xa0左右反置 0xa1正常LCD_WrCmd(0xc8);//Set COM/Row Scan Direction   0xc0上下反置 0xc8正常LCD_WrCmd(0xa6);//--set normal displayLCD_WrCmd(0xa8);//--set multiplex ratio(1 to 64)LCD_WrCmd(0x3f);//--1/64 dutyLCD_WrCmd(0xd3);//-set display offset   Shift Mapping RAM Counter (0x00~0x3F)LCD_WrCmd(0x00);//-not offsetLCD_WrCmd(0xd5);//--set display clock divide ratio/oscillator frequencyLCD_WrCmd(0x80);//--set divide ratio, Set Clock as 100 Frames/SecLCD_WrCmd(0xd9);//--set pre-charge periodLCD_WrCmd(0xf1);//Set Pre-Charge as 15 Clocks & Discharge as 1 ClockLCD_WrCmd(0xda);//--set com pins hardware configurationLCD_WrCmd(0x12);LCD_WrCmd(0xdb);//--set vcomhLCD_WrCmd(0x40);//Set VCOM Deselect LevelLCD_WrCmd(0x20);//-Set Page Addressing Mode (0x00/0x01/0x02)LCD_WrCmd(0x02);//LCD_WrCmd(0x8d);//--set Charge Pump enable/disableLCD_WrCmd(0x14);//--set(0x10) disableLCD_WrCmd(0xa4);// Disable Entire Display On (0xa4/0xa5)LCD_WrCmd(0xa6);// Disable Inverse Display On (0xa6/a7) LCD_WrCmd(0xaf);//--turn on oled panelLCD_Fill(0x00);  //初始清屏LCD_Set_Pos(0,0);  }
//==============================================================
//函数名: void LCD_PutPixel(byte x,byte y)
//功能描述:绘制一个点(x,y)
//参数:真实坐标值(x,y),x的范围0~127,y的范围0~64
//返回:无
//==============================================================
void LCD_PutPixel(byte x,byte y)
{byte data1;  //data1当前点的数据 LCD_Set_Pos(x,y); data1 = 0x01<<(y%8);   LCD_WrCmd(0xb0+(y>>3));LCD_WrCmd(((x&0xf0)>>4)|0x10);LCD_WrCmd((x&0x0f)|0x00);LCD_WrDat(data1);
}
//==============================================================
//函数名: void LCD_Rectangle(byte x1,byte y1,
//                   byte x2,byte y2,byte color,byte gif)
//功能描述:绘制一个实心矩形
//参数:左上角坐标(x1,y1),右下角坐标(x2,y2)
//      其中x1、x2的范围0~127,y1,y2的范围0~63,即真实坐标值
//返回:无
//==============================================================
void LCD_Rectangle(byte x1,byte y1,byte x2,byte y2,byte gif)
{byte n; LCD_Set_Pos(x1,y1>>3);for(n=x1;n<=x2;n++){LCD_WrDat(0x01<<(y1%8));          if(gif == 1)  LCD_DLY_ms(50);}  LCD_Set_Pos(x1,y2>>3);for(n=x1;n<=x2;n++){LCD_WrDat(0x01<<(y2%8));             if(gif == 1)  LCD_DLY_ms(5);}}
//==============================================================
//函数名:LCD_P6x8Str(byte x,byte y,byte *p)
//功能描述:写入一组标准ASCII字符串
//参数:显示的位置(x,y),y为页范围0~7,要显示的字符串
//返回:无
//==============================================================
void LCD_P6x8Str(byte x,byte y,byte ch[])
{byte c=0,i=0,j=0;      while (ch[j]!='\0'){    c =ch[j]-32;if(x>126){x=0;y++;}LCD_Set_Pos(x,y);    for(i=0;i<6;i++)     LCD_WrDat(F6x8[c][i]);  x+=6;j++;}
}
//==============================================================
//函数名:LCD_P8x16Str(byte x,byte y,byte *p)
//功能描述:写入一组标准ASCII字符串
//参数:显示的位置(x,y),y为页范围0~7,要显示的字符串
//返回:无
//==============================================================
void LCD_P8x16Str(byte x,byte y,byte ch[])
{byte c=0,i=0,j=0;while (ch[j]!='\0'){    c =ch[j]-32;if(x>120){x=0;y++;}LCD_Set_Pos(x,y);    for(i=0;i<8;i++)     LCD_WrDat(F8X16[c*16+i]);LCD_Set_Pos(x,y+1);    for(i=0;i<8;i++)     LCD_WrDat(F8X16[c*16+i+8]);  x+=8;j++;}
}
//输出汉字字符串
void LCD_P14x16Str(byte x,byte y,byte ch[])
{byte wm=0,ii = 0;word adder=1; while(ch[ii] != '\0'){wm = 0;adder = 1;while(F14x16_Idx[wm] > 127){if(F14x16_Idx[wm] == ch[ii]){if(F14x16_Idx[wm + 1] == ch[ii + 1]){adder = wm * 14;break;}}wm += 2;           }if(x>118){x=0;y++;}LCD_Set_Pos(x , y); if(adder != 1)// 显示汉字                    {LCD_Set_Pos(x , y);for(wm = 0;wm < 14;wm++)               {LCD_WrDat(F14x16[adder]); adder += 1;}      LCD_Set_Pos(x,y + 1); for(wm = 0;wm < 14;wm++)          {LCD_WrDat(F14x16[adder]);adder += 1;}         }else             //显示空白字符          {ii += 1;LCD_Set_Pos(x,y);for(wm = 0;wm < 16;wm++){LCD_WrDat(0);}LCD_Set_Pos(x,y + 1);for(wm = 0;wm < 16;wm++){          LCD_WrDat(0);   }}x += 14;ii += 2;}
}
//输出汉字和字符混合字符串
void LCD_Print(byte x, byte y, byte ch[])
{byte ch2[3];byte ii=0;        while(ch[ii] != '\0'){if(ch[ii] > 127){ch2[0] = ch[ii];ch2[1] = ch[ii + 1];ch2[2] = '\0';           //汉字为两个字节LCD_P14x16Str(x , y, ch2); //显示汉字x += 14;ii += 2;}else{ch2[0] = ch[ii];   ch2[1] = '\0';           //字母占一个字节LCD_P8x16Str(x , y , ch2); //显示字母x += 8;ii+= 1;}}
} //==============================================================
//函数名: void Draw_BMP(byte x,byte y)
//功能描述:显示BMP图片128×64
//参数:起始点坐标(x,y),x的范围0~127,y为页的范围0~7
//返回:无
//==============================================================
void Draw_BMP(byte x0,byte y0,byte x1,byte y1,uint8 bmp[])
{   word ii=0;byte x,y;if(y1%8==0) y=y1/8;      else y=y1/8+1;for(y=y0;y<=y1;y++){LCD_Set_Pos(x0,y);               for(x=x0;x<=x1;x++){      LCD_WrDat(bmp[ii++]);            }}
}
//==============================================================
//函数名:void Display(int16 i,uint8 x,uint8 y)
//功能描述:显示动态数字
//参数:起始点坐标(x,y),x的范围0~127,y为页的范围0~7
//返回:无
//==============================================================
void Display(int16 i,uint8 x,uint8 y)
{int8 a[6]={0}; if(i<0){a[0]='-';i=-i;}elsea[0]='+';a[1]=i/10000;a[2]=i%10000/1000;a[3]=i%1000/100;a[4]=i%100/10;a[5]=i%10;for(uint8 j=0;j<6;j++){switch(a[j]){case 0:{LCD_Print(x,y,"0");}break;case 1:{LCD_Print(x,y,"1");}break;case 2:{LCD_Print(x,y,"2");}break;case 3:{LCD_Print(x,y,"3");}break;case 4:{LCD_Print(x,y,"4");}break;case 5:{LCD_Print(x,y,"5");}break;case 6:{LCD_Print(x,y,"6");}break;case 7:{LCD_Print(x,y,"7");}break;case 8:{LCD_Print(x,y,"8");}break;case 9:{LCD_Print(x,y,"9");}break; case '-':{LCD_Print(x,y,"-");}break;case '+':{LCD_Print(x,y,"+");}break;default:break;}x+=10;if(x==80)x=20;}
}//==============================================================
//函数名:void DisplayFloat(int16 i,uint8 x,uint8 y)
//功能描述:显示动态数字
//参数:起始点坐标(x,y),x的范围0~127,y为页的范围0~7
//返回:无
//==============================================================
void DisplayFloat(int16 i,uint8 x,uint8 y)
{int8 a[6]={0}; if(i<0){a[0]='-';i=-i;}elsea[0]='+';a[1]=i/10000;a[2]=i%10000/1000;a[3]='.';a[4]=i%1000/100;a[5]=i%100/10;for(uint8 j=0;j<6;j++){switch(a[j]){case 0:{LCD_Print(x,y,"0");}break;case 1:{LCD_Print(x,y,"1");}break;case 2:{LCD_Print(x,y,"2");}break;case 3:{LCD_Print(x,y,"3");}break;case 4:{LCD_Print(x,y,"4");}break;case 5:{LCD_Print(x,y,"5");}break;case 6:{LCD_Print(x,y,"6");}break;case 7:{LCD_Print(x,y,"7");}break;case 8:{LCD_Print(x,y,"8");}break;case 9:{LCD_Print(x,y,"9");}break; case '-':{LCD_Print(x,y,"-");}break;case '+':{LCD_Print(x,y,"+");}break;case '.':{LCD_Print(x,y,".");}break;default:break;}x+=10;if(x==90)x=20;}
}
/*****************************************************************************函 数 名  : LED_PrintImage功能描述  : 将图像显示出来输入参数  : UCHAR8 *pucTable     二维图像数组的地址USHORT16 usRowNum    二维图像的行数1~64USHORT16 usColumnNum 二维图像的列数1~128输出参数  : none返 回 值  : none
*****************************************************************************/
void LCD_PrintImage(uint8 *pucTable, uint16 usRowNum, uint16 usColumnNum)
{uint8 ucData;uint16 i,j,k,m,n;uint16 usRowTmp;m = usRowNum >> 3;   //计算图片行数以8位为一组完整的组数n = usRowNum % 8;    //计算分完组后剩下的行数for(i = 0; i < m; i++) //完整组行扫描{LCD_Set_Pos(0,(uint8)i);usRowTmp = i << 3;    //计算当前所在行的下标                  for(j = 0; j < usColumnNum; j++) //列扫描        {ucData = 0;for(k = 0; k < 8; k++) //在i组中对这8行扫描{ucData = ucData >> 1;if((pucTable + (usRowTmp + k) * usColumnNum)[j] == 0){ucData = ucData | 0x80;}}LCD_WrDat(ucData);}}LCD_Set_Pos(0,(uint8)i); //设置剩下的行显示的起始坐标usRowTmp = i << 3;       //计算当前所在行的下标                  for(j = 0; j < usColumnNum; j++) //列扫描        {ucData = 0;for(k = 0; k < n; k++) //对剩下的行扫描{ucData = ucData >> 1;if((pucTable + (usRowTmp + k) * usColumnNum)[j] == 1){ucData = ucData | 0x80;}}ucData = ucData >> (8 - n);LCD_WrDat(ucData);}return;
}

LCD.h文件

#ifndef  _LCD_H_
#define _LCD_H_#define RESET  PTB18_OUT
#define DC     PTB19_OUT
#define D1     PTB17_OUT
#define D0     PTB16_OUTtypedef unsigned char byte;typedef unsigned int word;extern byte beyond96x64[512];void LCD_WrDat(uint8 data);void LCD_Set_Pos(byte x, byte y);void LCD_Init(void);void LCD_CLS(void);void LCD_P6x8Str(byte x,byte y,byte ch[]);void LCD_P8x16Str(byte x,byte y,byte ch[]);void LCD_P14x16Str(byte x,byte y,byte ch[]);void LCD_Print(byte x, byte y, byte ch[]);void LCD_PutPixel(byte x,byte y);void LCD_Rectangle(byte x1,byte y1,byte x2,byte y2,byte gif);void Draw_BMP(byte x0,byte y0,byte x1,byte y1,byte bmp[]); void LCD_Fill(byte dat);void Display(int16 i,uint8 x,uint8 y);void DisplayFloat(int16 i,uint8 x,uint8 y);void LCD_PrintImage(uint8 *pucTable, uint16 usRowNum, uint16 usColumnNum);
#endif

飞思卡尔比赛K60驱动OLED12864显示摄像头采集的赛道图像,完整代码分享相关推荐

  1. 飞思卡尔MC9S12X Flash驱动

    今天带着大家学习下飞思卡尔MC9S12  Flash驱动 在现今的经济社会,比拼的"快"不仅仅是速度快,更是效率高.身处社会分工细致的今天,让自己更快效率更高是有方法的. 每一家M ...

  2. 飞思卡尔MC9S12X PWM驱动

    今天带着大家学习飞思卡尔MC9S12X PWM驱动 首先什么是PWM及应用 脉冲宽度调制(PWM)是产生精确脉冲序列输出和实现D/A转换的有效方法,微控制器的脉宽调制模块被广泛应用于工业控制和新型消费 ...

  3. USB摄像头驱动--LCD显示摄像头图像(附Makefile分析)

    对于一个应用程序,最重要的是明白目的是什么:将摄像头的数据解析出来,按一帧一个图片的方式将数据传到LCD的Framebuffer中去(如果LCD没有自动将Framebuffer中的数据刷到LCD上还需 ...

  4. 飞思卡尔S12系列(基于MC9S12XET256MAA和/MC9S12XEP100)锁存器资料总结和分享

    最近在公司做项目,用到飞思卡尔S12系列芯片,为了让自己养成良好习惯,以后每做一部分,都会总结出来,方便自己和他人. 今天讲讲飞思卡尔锁存器部分. CRG时钟合成寄存器(SYNR) 读:任何时刻:写: ...

  5. 飞思卡尔MC9S12X CAN驱动

    今天带着大家学习下MC9S12XS  CAN驱动模块开发.首先先了解下什么CAN,用途. CAN总线的概念: CAN是控制器局域网络(Controller Area Network)的简称,是由研发和 ...

  6. mfc调取摄像头显示并截图_用OpenCV在MFC Dialog中Picture控件上显示摄像头采集实时视频...

    OpenCV之所以能在MFC Dialog的Picture控件上绘图,全靠了CvvImage::DrawToHDC()方法.这就是下文为出现CvvImage和HDC的原因.下面是具体过程,用OpenC ...

  7. DSP28335驱动Lcd12864显示Ds18b20采集到的温度,并通过Sci方式传输至PC,使用Matlab制作上位机软件进行数据保存与显示

    这一篇文章是我前一篇文章的续集,主要是为了弥补 CCS无法实时捕捉数据至上位机的缺陷(可能CCS有,但是我却没找到,如果有读者知道具体答案,请留言告诉我.).当然串口传输来的数据也有不足的地方,就是这 ...

  8. OpenCV显示copyMakeBorder功能的实例(附完整代码)

    OpenCV显示copyMakeBorder功能的实例 OpenCV显示copyMakeBorder功能的实例 OpenCV显示copyMakeBorder功能的实例 #include "o ...

  9. 飞思卡尔 I.MX6Q-高分辨率(1080P)视频采集编码

    专栏说明 本专栏针对飞思卡尔I.MX6Q芯片产品开发,主要为视频的采集(V4L2).视频编解码(VPU).视频格式转化(IPU).H264封装为MP4.QT5的移植和显示.         飞思卡尔I ...

最新文章

  1. Linux下同步工具inotify+rsync使用详解
  2. SDN教育城域网解决方案
  3. 谷歌浏览器中文版_GitHub上最励志的计算机自学教程:8个月,从中年Web前端到亚马逊百万年薪软件工程师 | 中文版...
  4. 面试必会系列 - 5.3 LVS负载均衡
  5. 2018年五大最佳前端框架比较,程序员会怎么选?
  6. python定位文件位置_在Python中定位文件位置
  7. python封装成exe后运行失败_python 在编译成EXE 文件后报错 我实在是找不出原因
  8. 什么是RS-232-C接口与什么是RS-485接口?
  9. android 飞行模式 wifi,解决飞行模式下手机用wifi的问题
  10. element-ui图片上传组件之限制每次5张上传(或者自定义每次几张上传)
  11. 微信小程序分析送积分功能如何实现_微信小程序积分商城解决方案(一)
  12. python中字符串输出乱码怎么解决_python字符乱码的解决小结
  13. 偏态分布学习笔记(期望,中位数,众数)
  14. Service Mesh是什么?
  15. Twitter的推荐系统开源了,Twitter的推荐系统是什么样的呢?Twitter推荐系统的架构说明
  16. python通过ip获取mac地址_Python3根据IP地址获取MAC地址
  17. android查看轨迹,一种提取并分析Android手机行踪轨迹的方法
  18. java过滤.txt_关键词过滤实现(JAVA TXT)
  19. java通过HtmlUnit工具和J4L实现模拟带验证码登录
  20. device-mapper 块级重删(dm dedup) 3代码结构(4)

热门文章

  1. MOS管如何检测好坏
  2. C++:团体程序设计天梯赛(正整数A+B)
  3. 《Linux/UNIX OpenLDAP实战指南》——2.4 OpenLDAP配置
  4. pll制作分频器_教你如何制作一个音响分频器,让你的音响重获新生,发挥最佳效果...
  5. 应广单片机休眠和按键唤醒
  6. 用 C# 写个人住房贷款计算器
  7. android中获取mac地址8.0,华为Mate10手机emui8.0系统怎么查看IP地址和mac地址?
  8. Matrix源码分析————IO Canary
  9. 端口号与ip、网关的作用?
  10. 短视频程序的魅力,你为什么喜欢抖音?知乎大神的回答