这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » 活动中心 » 板卡试用 » 【EFM8BB52单片机】用于房车的太阳能充电系统远程显示单元(逆变器界面)

共26条 2/3 1 2 3 跳转至
高工
2021-12-26 09:35:08     打赏
11楼

Blinky示例

    在上一期成功安装完毕IDE后,,本次尝试试用活动必选的第一任务——Blinky实验。

    Blinky实验依托Simplicity Studio来实现显得非常简单了。在打开软件后,选择“BB52”开发板,然后再选择Blinky示例即可。

    在编译的时候,首次会提示申请Keil编译器的lic,按照步骤填写即可。信息内容虚实结合亦可。编译完成后,可以看到左侧与下方编译输出有提示生成Hex文件。——说明编译成功并完成。


    再将开发板通过USB连接接入电脑,提示;jlink找到新设备后,即可点击Debug进入单步调试了。

    总体而言,还是非常简单的。



工程师
2021-12-26 15:34:53     打赏
12楼

感谢楼主的分享,很实用了。


高工
2021-12-26 16:27:24     打赏
13楼

谢谢分享,学习学习


高工
2022-01-09 09:43:47     打赏
14楼

Uart0调试

51单片机不同于STM32系列。51单片机的Uart串口的波特率发生器由Timer完成,而不是自己外设的单独时钟源。阅读手册,BB52的Uart0的波特率发生器为Timer0产生,并需要配置为8-bit auto mode,即Mode2模式。

这里,楼主的主时钟已经修改为24.5MHz且1分频,所以配置参数与其它网友不同,大家在引用时,需要注意。

//================================================================================
// TIMER01_0_enter_DefaultMode_from_RESET
//================================================================================
extern void
TIMER01_0_enter_DefaultMode_from_RESET (void)
{
  // $[Timer Initialization]
  //Save Timer Configuration
  uint8_t TCON_save;

  TCON_save = TCON;
  //Stop Timers
  TCON &= ~TCON_TR0__BMASK & ~TCON_TR1__BMASK;

  // [Timer Initialization]$

  // $[TH0 - Timer 0 High Byte]
  // [TH0 - Timer 0 High Byte]$

  // $[TL0 - Timer 0 Low Byte]
  // [TL0 - Timer 0 Low Byte]$

  // $[TH1 - Timer 1 High Byte]
  /*
   // TH1 (Timer 1 High Byte) = 0x96
   */
  TH1 = (0x96 << TH1_TH1__SHIFT);
  // [TH1 - Timer 1 High Byte]$

  // $[TL1 - Timer 1 Low Byte]
  // [TL1 - Timer 1 Low Byte]$

  // $[Timer Restoration]
  //Restore Timer Configuration
  TCON |= (TCON_save & TCON_TR0__BMASK) | (TCON_save & TCON_TR1__BMASK);

  // [Timer Restoration]$
}

注意:这里还要强调一个事情。开发板将Uart0的P0.4和P0.5两个引脚连接到了Vcom上面,且波特率固定为115200bps。

下面是使用串口工具打印的信息

eepw07.PNG



高工
2022-01-17 04:19:57     打赏
15楼

OLED屏显示

OLED屏在小显示屏里面的显示效果非常棒。在狭小空间里面其显示效果更是非常出色。不仅宽视角,而且自发光,对比度巨高。

oled.jpg





高工
2022-01-17 04:24:37     打赏
16楼

OLED屏源代码


/******************************************************************************

          ��Ȩ���� (C), 2011-2012, ������ӿƼ�(http://xydz123.taobao.com/)

 ******************************************************************************
  �� �� ��   : oled.c
  �� �� ��   : v1.0
  ��    ��   : Guokaiyi
  ��������   : 2012-12-1
  ����޸�   : 
  ��������   : LED128x64OLED��ʾ���ײ�����
  �޸���ʷ   :
  1.��    ��   : 2012-12-1
    ��    ��   : Guokaiyi
    �޸�����   : �����ļ�
******************************************************************************/

/*----------------------------------------------------------------------------*
 * ����ͷ�ļ�                                                                 *
 *----------------------------------------------------------------------------*/
#include <stdint.h>
#include <SI_EFM8BB52_Register_Enums.h>

#include "oled.h"

/*----------------------------------------------------------------------------*
 * �궨��                                                                     *
 *----------------------------------------------------------------------------*/

/*----------------------------------------------------------------------------*
 * ȫ�ֱ���                                                                   *
 *----------------------------------------------------------------------------*/

SI_SBIT(LED_SCL, SFR_P1, 2);
SI_SBIT(LED_SDA, SFR_P1, 1);
SI_SBIT(LED_RST, SFR_P1, 0);
SI_SBIT(LED_DC, SFR_P1, 3);
SI_SBIT(LED_CS, SFR_P0, 7);
 
const uint8_t code F6x8[][6] =
{
    { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },   //sp0
    { 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00 },   // !1
    { 0x00, 0x00, 0x07, 0x00, 0x07, 0x00 },   // "2
    { 0x00, 0x14, 0x7f, 0x14, 0x7f, 0x14 },   // #3
    { 0x00, 0x24, 0x2a, 0x7f, 0x2a, 0x12 },   // $4
    { 0x00, 0x62, 0x64, 0x08, 0x13, 0x23 },   // %5
    { 0x00, 0x36, 0x49, 0x55, 0x22, 0x50 },   // &6
    { 0x00, 0x00, 0x05, 0x03, 0x00, 0x00 },   // '7
    { 0x00, 0x00, 0x1c, 0x22, 0x41, 0x00 },   // (8
    { 0x00, 0x00, 0x41, 0x22, 0x1c, 0x00 },   // )9
    { 0x00, 0x14, 0x08, 0x3E, 0x08, 0x14 },   // *10
    { 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08 },   // +11
    { 0x00, 0x00, 0x00, 0xA0, 0x60, 0x00 },   // ,12
    { 0x00, 0x08, 0x08, 0x08, 0x08, 0x08 },   // -13
    { 0x00, 0x00, 0x60, 0x60, 0x00, 0x00 },   // .14
    { 0x00, 0x20, 0x10, 0x08, 0x04, 0x02 },   // /15
    { 0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E },   // 016
    { 0x00, 0x00, 0x42, 0x7F, 0x40, 0x00 },   // 117
    { 0x00, 0x42, 0x61, 0x51, 0x49, 0x46 },   // 218
    { 0x00, 0x21, 0x41, 0x45, 0x4B, 0x31 },   // 319
    { 0x00, 0x18, 0x14, 0x12, 0x7F, 0x10 },   // 420
    { 0x00, 0x27, 0x45, 0x45, 0x45, 0x39 },   // 521
    { 0x00, 0x3C, 0x4A, 0x49, 0x49, 0x30 },   // 622
    { 0x00, 0x01, 0x71, 0x09, 0x05, 0x03 },   // 723
    { 0x00, 0x36, 0x49, 0x49, 0x49, 0x36 },   // 824
    { 0x00, 0x06, 0x49, 0x49, 0x29, 0x1E },   // 925
    { 0x00, 0x00, 0x36, 0x36, 0x00, 0x00 },   // :26
    { 0x00, 0x00, 0x56, 0x36, 0x00, 0x00 },   // ;27
    { 0x00, 0x08, 0x14, 0x22, 0x41, 0x00 },   // <28
    { 0x00, 0x14, 0x14, 0x14, 0x14, 0x14 },   // =29
    { 0x00, 0x00, 0x41, 0x22, 0x14, 0x08 },   // >30
    { 0x00, 0x02, 0x01, 0x51, 0x09, 0x06 },   // ?31
    { 0x00, 0x32, 0x49, 0x59, 0x51, 0x3E },   // @32
    { 0x00, 0x7C, 0x12, 0x11, 0x12, 0x7C },   // A33
    { 0x00, 0x7F, 0x49, 0x49, 0x49, 0x36 },   // B34
    { 0x00, 0x3E, 0x41, 0x41, 0x41, 0x22 },   // C35
    { 0x00, 0x7F, 0x41, 0x41, 0x22, 0x1C },   // D36
    { 0x00, 0x7F, 0x49, 0x49, 0x49, 0x41 },   // E37
    { 0x00, 0x7F, 0x09, 0x09, 0x09, 0x01 },   // F38
    { 0x00, 0x3E, 0x41, 0x49, 0x49, 0x7A },   // G39
    { 0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F },   // H40
    { 0x00, 0x00, 0x41, 0x7F, 0x41, 0x00 },   // I41
    { 0x00, 0x20, 0x40, 0x41, 0x3F, 0x01 },   // J42
    { 0x00, 0x7F, 0x08, 0x14, 0x22, 0x41 },   // K43
    { 0x00, 0x7F, 0x40, 0x40, 0x40, 0x40 },   // L44
    { 0x00, 0x7F, 0x02, 0x0C, 0x02, 0x7F },   // M45
    { 0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F },   // N46
    { 0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E },   // O47
    { 0x00, 0x7F, 0x09, 0x09, 0x09, 0x06 },   // P48
    { 0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E },   // Q49
    { 0x00, 0x7F, 0x09, 0x19, 0x29, 0x46 },   // R50
    { 0x00, 0x46, 0x49, 0x49, 0x49, 0x31 },   // S51
    { 0x00, 0x01, 0x01, 0x7F, 0x01, 0x01 },   // T52
    { 0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F },   // U53
    { 0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F },   // V54
    { 0x00, 0x3F, 0x40, 0x38, 0x40, 0x3F },   // W55
    { 0x00, 0x63, 0x14, 0x08, 0x14, 0x63 },   // X56
    { 0x00, 0x07, 0x08, 0x70, 0x08, 0x07 },   // Y57
    { 0x00, 0x61, 0x51, 0x49, 0x45, 0x43 },   // Z58
    { 0x00, 0x00, 0x7F, 0x41, 0x41, 0x00 },   // [59
    { 0x00, 0x02, 0x04, 0x08, 0x10, 0x20 },   // \60
    { 0x00, 0x00, 0x41, 0x41, 0x7F, 0x00 },   // ]61
    { 0x00, 0x04, 0x02, 0x01, 0x02, 0x04 },   // ^62
    { 0x00, 0x40, 0x40, 0x40, 0x40, 0x40 },   // _63
    { 0x00, 0x00, 0x01, 0x02, 0x04, 0x00 },   // '64
    { 0x00, 0x20, 0x54, 0x54, 0x54, 0x78 },   // a65
    { 0x00, 0x7F, 0x48, 0x44, 0x44, 0x38 },   // b66
    { 0x00, 0x38, 0x44, 0x44, 0x44, 0x20 },   // c67
    { 0x00, 0x38, 0x44, 0x44, 0x48, 0x7F },   // d68
    { 0x00, 0x38, 0x54, 0x54, 0x54, 0x18 },   // e69
    { 0x00, 0x08, 0x7E, 0x09, 0x01, 0x02 },   // f70
    { 0x00, 0x18, 0xA4, 0xA4, 0xA4, 0x7C },   // g71
    { 0x00, 0x7F, 0x08, 0x04, 0x04, 0x78 },   // h72
    { 0x00, 0x00, 0x44, 0x7D, 0x40, 0x00 },   // i73
    { 0x00, 0x40, 0x80, 0x84, 0x7D, 0x00 },   // j74
    { 0x00, 0x7F, 0x10, 0x28, 0x44, 0x00 },   // k75
    { 0x00, 0x00, 0x41, 0x7F, 0x40, 0x00 },   // l76
    { 0x00, 0x7C, 0x04, 0x18, 0x04, 0x78 },   // m77
    { 0x00, 0x7C, 0x08, 0x04, 0x04, 0x78 },   // n78
    { 0x00, 0x38, 0x44, 0x44, 0x44, 0x38 },   // o79
    { 0x00, 0xFC, 0x24, 0x24, 0x24, 0x18 },   // p80
    { 0x00, 0x18, 0x24, 0x24, 0x18, 0xFC },   // q81
    { 0x00, 0x7C, 0x08, 0x04, 0x04, 0x08 },   // r82
    { 0x00, 0x48, 0x54, 0x54, 0x54, 0x20 },   // s83
    { 0x00, 0x04, 0x3F, 0x44, 0x40, 0x20 },   // t84
    { 0x00, 0x3C, 0x40, 0x40, 0x20, 0x7C },   // u85
    { 0x00, 0x1C, 0x20, 0x40, 0x20, 0x1C },   // v86
    { 0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C },   // w87
    { 0x00, 0x44, 0x28, 0x10, 0x28, 0x44 },   // x88
    { 0x00, 0x1C, 0xA0, 0xA0, 0xA0, 0x7C },   // y89
    { 0x00, 0x44, 0x64, 0x54, 0x4C, 0x44 },   // z90
    { 0x14, 0x14, 0x14, 0x14, 0x14, 0x14 }    // horiz lines91
};

//�����ַ���ԭ��
const uint8_t code F14x16_Idx[] =
{
    "������ӿƼ���Ļ����"
};

//�����ַ�������
const uint8_t code F14x16[] =
{  
    0x00,0x80,0xE0,0x1C,0x12,0x10,0x50,0x52,0x4C,0x50,0x50,0x30,0x08,0x00,
    0x01,0x00,0x7F,0x00,0x00,0x01,0x7D,0x45,0x45,0x45,0x45,0x7C,0x00,0x00,/*"��",0*/
    0x00,0x20,0x20,0xA8,0xA8,0xB8,0xA6,0xA8,0xB8,0x68,0xA8,0x20,0x20,0x00,
    0x00,0x40,0x30,0x0F,0x76,0x46,0x4E,0x56,0x46,0x76,0x17,0x10,0x60,0x00,/*"��",1*/
    0x00,0x00,0xF0,0x90,0x90,0x90,0xFE,0x90,0x90,0x90,0xF0,0x10,0x00,0x00,
    0x00,0x00,0x0F,0x08,0x08,0x08,0x7F,0x48,0x48,0x48,0x4F,0x50,0x60,0x00,/*"��",2*/
    0x00,0x00,0x04,0x04,0x04,0x04,0x04,0xE4,0x14,0x0C,0x04,0x84,0x80,0x00,
    0x00,0x00,0x01,0x01,0x01,0x41,0x41,0x3F,0x01,0x01,0x01,0x00,0x00,0x00,/*"��",3*/
    0x00,0x00,0x48,0xFC,0x44,0x42,0x00,0x88,0x30,0x00,0xFE,0x02,0x00,0x00,
    0x00,0x0C,0x02,0x7F,0x01,0x01,0x08,0x08,0x05,0x04,0xFF,0x04,0x02,0x00,/*"��",4*/
    0x00,0x00,0x20,0xFE,0x20,0x90,0x20,0x20,0x20,0xFE,0x20,0xA0,0x10,0x00,
    0x00,0x02,0x41,0x7F,0x81,0x80,0x41,0x47,0x29,0x18,0x27,0x41,0x40,0x00,/*"��",5*/
    0x00,0x00,0xFE,0x14,0x14,0x34,0x54,0x14,0x94,0x74,0x14,0x9C,0x00,0x00,
    0x00,0x30,0x0F,0x88,0x48,0x39,0x0F,0x09,0x08,0x7F,0x09,0x04,0x04,0x00,/*"��",6*/
    0x00,0x04,0x04,0xF4,0x54,0xCE,0x54,0x54,0x4E,0x4C,0xF4,0x04,0x04,0x00,
    0x00,0x08,0x0A,0x3E,0x0A,0x09,0x7E,0x0A,0x0A,0x7A,0x0E,0x0A,0x09,0x00,/*"Ļ",7*/
    0x00,0x20,0x04,0x80,0xFC,0x04,0xF4,0x04,0xFC,0x00,0xF0,0xFC,0x00,0x00,
    0x00,0x00,0x7F,0x40,0x27,0x18,0x07,0x10,0x67,0x00,0x4F,0xFF,0x00,0x00,/*"��",8*/
    0x00,0x80,0x88,0x98,0x20,0x20,0x20,0x20,0xA0,0xFE,0x24,0x2C,0x10,0x00,
    0x00,0x00,0x1F,0x60,0x10,0x28,0x21,0x1F,0x10,0x13,0x1C,0x20,0x70,0x00,/*"��",9*/
};

//======================================================
// 128X64OLEDҺ���ײ�����[8X16]�����
// �����: Guokaiyi
// ��  ��: [8X16]�����ַ�����ģ���� (����ȡģ,�ֽڵ���)
// !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
//======================================================
const uint8_t code F8X16[]=
{
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 0
    0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x30,0x00,0x00,0x00,//!1
    0x00,0x10,0x0C,0x06,0x10,0x0C,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//"2
    0x40,0xC0,0x78,0x40,0xC0,0x78,0x40,0x00,0x04,0x3F,0x04,0x04,0x3F,0x04,0x04,0x00,//#3
    0x00,0x70,0x88,0xFC,0x08,0x30,0x00,0x00,0x00,0x18,0x20,0xFF,0x21,0x1E,0x00,0x00,//$4
    0xF0,0x08,0xF0,0x00,0xE0,0x18,0x00,0x00,0x00,0x21,0x1C,0x03,0x1E,0x21,0x1E,0x00,//%5
    0x00,0xF0,0x08,0x88,0x70,0x00,0x00,0x00,0x1E,0x21,0x23,0x24,0x19,0x27,0x21,0x10,//&6
    0x10,0x16,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//'7
    0x00,0x00,0x00,0xE0,0x18,0x04,0x02,0x00,0x00,0x00,0x00,0x07,0x18,0x20,0x40,0x00,//(8
    0x00,0x02,0x04,0x18,0xE0,0x00,0x00,0x00,0x00,0x40,0x20,0x18,0x07,0x00,0x00,0x00,//)9
    0x40,0x40,0x80,0xF0,0x80,0x40,0x40,0x00,0x02,0x02,0x01,0x0F,0x01,0x02,0x02,0x00,//*10
    0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x1F,0x01,0x01,0x01,0x00,//+11
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xB0,0x70,0x00,0x00,0x00,0x00,0x00,//,12
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,//-13
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00,//.14
    0x00,0x00,0x00,0x00,0x80,0x60,0x18,0x04,0x00,0x60,0x18,0x06,0x01,0x00,0x00,0x00,///15
    0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,//016
    0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//117
    0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,//218
    0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00,//319
    0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,//420
    0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00,//521
    0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00,//622
    0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,//723
    0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,//824
    0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00,//925
    0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,//:26
    0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x60,0x00,0x00,0x00,0x00,//;27
    0x00,0x00,0x80,0x40,0x20,0x10,0x08,0x00,0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x00,//<28
    0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00,//=29
    0x00,0x08,0x10,0x20,0x40,0x80,0x00,0x00,0x00,0x20,0x10,0x08,0x04,0x02,0x01,0x00,//>30
    0x00,0x70,0x48,0x08,0x08,0x08,0xF0,0x00,0x00,0x00,0x00,0x30,0x36,0x01,0x00,0x00,//?31
    0xC0,0x30,0xC8,0x28,0xE8,0x10,0xE0,0x00,0x07,0x18,0x27,0x24,0x23,0x14,0x0B,0x00,//@32
    0x00,0x00,0xC0,0x38,0xE0,0x00,0x00,0x00,0x20,0x3C,0x23,0x02,0x02,0x27,0x38,0x20,//A33
    0x08,0xF8,0x88,0x88,0x88,0x70,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x11,0x0E,0x00,//B34
    0xC0,0x30,0x08,0x08,0x08,0x08,0x38,0x00,0x07,0x18,0x20,0x20,0x20,0x10,0x08,0x00,//C35
    0x08,0xF8,0x08,0x08,0x08,0x10,0xE0,0x00,0x20,0x3F,0x20,0x20,0x20,0x10,0x0F,0x00,//D36
    0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x20,0x23,0x20,0x18,0x00,//E37
    0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x00,0x03,0x00,0x00,0x00,//F38
    0xC0,0x30,0x08,0x08,0x08,0x38,0x00,0x00,0x07,0x18,0x20,0x20,0x22,0x1E,0x02,0x00,//G39
    0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x20,0x3F,0x21,0x01,0x01,0x21,0x3F,0x20,//H40
    0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//I41
    0x00,0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,0x00,//J42
    0x08,0xF8,0x88,0xC0,0x28,0x18,0x08,0x00,0x20,0x3F,0x20,0x01,0x26,0x38,0x20,0x00,//K43
    0x08,0xF8,0x08,0x00,0x00,0x00,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x20,0x30,0x00,//L44
    0x08,0xF8,0xF8,0x00,0xF8,0xF8,0x08,0x00,0x20,0x3F,0x00,0x3F,0x00,0x3F,0x20,0x00,//M45
    0x08,0xF8,0x30,0xC0,0x00,0x08,0xF8,0x08,0x20,0x3F,0x20,0x00,0x07,0x18,0x3F,0x00,//N46
    0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x10,0x20,0x20,0x20,0x10,0x0F,0x00,//O47
    0x08,0xF8,0x08,0x08,0x08,0x08,0xF0,0x00,0x20,0x3F,0x21,0x01,0x01,0x01,0x00,0x00,//P48
    0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x18,0x24,0x24,0x38,0x50,0x4F,0x00,//Q49
    0x08,0xF8,0x88,0x88,0x88,0x88,0x70,0x00,0x20,0x3F,0x20,0x00,0x03,0x0C,0x30,0x20,//R50
    0x00,0x70,0x88,0x08,0x08,0x08,0x38,0x00,0x00,0x38,0x20,0x21,0x21,0x22,0x1C,0x00,//S51
    0x18,0x08,0x08,0xF8,0x08,0x08,0x18,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,//T52
    0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,//U53
    0x08,0x78,0x88,0x00,0x00,0xC8,0x38,0x08,0x00,0x00,0x07,0x38,0x0E,0x01,0x00,0x00,//V54
    0xF8,0x08,0x00,0xF8,0x00,0x08,0xF8,0x00,0x03,0x3C,0x07,0x00,0x07,0x3C,0x03,0x00,//W55
    0x08,0x18,0x68,0x80,0x80,0x68,0x18,0x08,0x20,0x30,0x2C,0x03,0x03,0x2C,0x30,0x20,//X56
    0x08,0x38,0xC8,0x00,0xC8,0x38,0x08,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,//Y57
    0x10,0x08,0x08,0x08,0xC8,0x38,0x08,0x00,0x20,0x38,0x26,0x21,0x20,0x20,0x18,0x00,//Z58
    0x00,0x00,0x00,0xFE,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x7F,0x40,0x40,0x40,0x00,//[59
    0x00,0x0C,0x30,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x06,0x38,0xC0,0x00,//\60
    0x00,0x02,0x02,0x02,0xFE,0x00,0x00,0x00,0x00,0x40,0x40,0x40,0x7F,0x00,0x00,0x00,//]61
    0x00,0x00,0x04,0x02,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//^62
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,//_63
    0x00,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//`64
    0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x19,0x24,0x22,0x22,0x22,0x3F,0x20,//a65
    0x08,0xF8,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x3F,0x11,0x20,0x20,0x11,0x0E,0x00,//b66
    0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x0E,0x11,0x20,0x20,0x20,0x11,0x00,//c67
    0x00,0x00,0x00,0x80,0x80,0x88,0xF8,0x00,0x00,0x0E,0x11,0x20,0x20,0x10,0x3F,0x20,//d68
    0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x22,0x22,0x22,0x22,0x13,0x00,//e69
    0x00,0x80,0x80,0xF0,0x88,0x88,0x88,0x18,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//f70
    0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x6B,0x94,0x94,0x94,0x93,0x60,0x00,//g71
    0x08,0xF8,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,//h72
    0x00,0x80,0x98,0x98,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//i73
    0x00,0x00,0x00,0x80,0x98,0x98,0x00,0x00,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,//j74
    0x08,0xF8,0x00,0x00,0x80,0x80,0x80,0x00,0x20,0x3F,0x24,0x02,0x2D,0x30,0x20,0x00,//k75
    0x00,0x08,0x08,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//l76
    0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x20,0x3F,0x20,0x00,0x3F,0x20,0x00,0x3F,//m77
    0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,//n78
    0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,//o79
    0x80,0x80,0x00,0x80,0x80,0x00,0x00,0x00,0x80,0xFF,0xA1,0x20,0x20,0x11,0x0E,0x00,//p80
    0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x0E,0x11,0x20,0x20,0xA0,0xFF,0x80,//q81
    0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x20,0x20,0x3F,0x21,0x20,0x00,0x01,0x00,//r82
    0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x33,0x24,0x24,0x24,0x24,0x19,0x00,//s83
    0x00,0x80,0x80,0xE0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x1F,0x20,0x20,0x00,0x00,//t84
    0x80,0x80,0x00,0x00,0x00,0x80,0x80,0x00,0x00,0x1F,0x20,0x20,0x20,0x10,0x3F,0x20,//u85
    0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x00,0x01,0x0E,0x30,0x08,0x06,0x01,0x00,//v86
    0x80,0x80,0x00,0x80,0x00,0x80,0x80,0x80,0x0F,0x30,0x0C,0x03,0x0C,0x30,0x0F,0x00,//w87
    0x00,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x31,0x2E,0x0E,0x31,0x20,0x00,//x88
    0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x80,0x81,0x8E,0x70,0x18,0x06,0x01,0x00,//y89
    0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x21,0x30,0x2C,0x22,0x21,0x30,0x00,//z90
    0x00,0x00,0x00,0x00,0x80,0x7C,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x3F,0x40,0x40,//{91
    0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,//|92
    0x00,0x02,0x02,0x7C,0x80,0x00,0x00,0x00,0x00,0x40,0x40,0x3F,0x00,0x00,0x00,0x00,//}93
    0x00,0x06,0x01,0x01,0x02,0x02,0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//~94
};

/*----------------------------------------------------------------------------*
 * �ڲ�����ԭ��                                                               *
 *----------------------------------------------------------------------------*/
void LED_WrDat(uint8_t ucData);
void LED_WrCmd(uint8_t ucCmd);
void LED_SetPos(uint8_t ucIdxX, uint8_t ucIdxY);
void SetStartColumn(uint8_t ucData);
void SetAddressingMode(uint8_t ucData);
void SetColumnAddress(uint8_t a, uint8_t b);
void SetPageAddress(uint8_t a, uint8_t b);
void SetStartLine(uint8_t d);
void SetContrastControl(uint8_t d);
void SetChargePump(uint8_t d);
void SetSegmentRemap(uint8_t d);
void SetEntireDisplay(uint8_t d);
void SetInverseDisplay(uint8_t d);
void SetMultiplexRatio(uint8_t d);
void SetDisplayOnOff(uint8_t d);
void SetStartPage(uint8_t d);
void SetCommonRemap(uint8_t d);
void SetDisplayOffset(uint8_t d);
void SetDisplayClock(uint8_t d);
void SetPrechargePeriod(uint8_t d);
void SetCommonConfig(uint8_t d);
void SetVCOMH(uint8_t d);
void SetNop(void);

/*----------------------------------------------------------------------------*
 * �ⲿ����ԭ��                                                               *
 *----------------------------------------------------------------------------*/

/*****************************************************************************
 �� �� ��  : LED_WrDat
 ��������  : ��OLEDд����
 �������  : uint8_t ucData
 �������  : NONE
 �� �� ֵ  : NONE
*****************************************************************************/
void LED_WrDat(uint8_t ucData)
{
    uint8_t i = 8;
    LED_CS = 0;
    LED_DC   = 1;
    LED_SCL  = 0;
    
    while (i--)
    {
        if (ucData & 0x80)
        {
            LED_SDA = 1;
        }
        else
        {
            LED_SDA = 0;
        }
        
        LED_SCL = 1; 
        _nop_();
        LED_SCL = 0;    
        ucData <<= 1;    
    }
    LED_CS = 1;
    return;
}

/*****************************************************************************
 �� �� ��  : LED_WrCmd
 ��������  : ��OLEDд����
 �������  : uint8_t ucCmd
 �������  : NONE
 �� �� ֵ  : NONE
*****************************************************************************/
void LED_WrCmd(uint8_t ucCmd)
{
    uint8_t i = 8;
    LED_CS = 0;
    LED_DC   = 0;
    LED_SCL  = 0;
    while (i--)
    {
        if (ucCmd & 0x80)
        {
            LED_SDA = 1;
        }
        else
        {
            LED_SDA = 0;
        }
        LED_SCL = 1;
        _nop_();           
        LED_SCL = 0;    
        ucCmd <<= 1;   
    }  
    LED_CS = 1;
    return;
}


/*****************************************************************************
 �� �� ��  : LED_SetPos
 ��������  : ��������
 �������  : uint8_t ucIdxX
             uint8_t ucIdxY
 �������  : NONE
 �� �� ֵ  : NONE
*****************************************************************************/
void LED_SetPos(uint8_t ucIdxX, uint8_t ucIdxY)
{ 
    LED_WrCmd(0xb0 + ucIdxY);
    LED_WrCmd(((ucIdxX & 0xf0) >> 4) | 0x10);
    LED_WrCmd((ucIdxX & 0x0f) | 0x00); 
    _nop_();
} 

/*****************************************************************************
 �� �� ��  : LED_Fill
 ��������  : ��ȫ��д��ͬһ���ַ����� 
             �� LED_Fill(0x01);    ����ijһλ0Ϊ���� 1Ϊ��
            ------------------------------------------------------
                                ��128��
                  1           1                1
              ��  0           0                0
              8   0           0                0
              ��  0       ����0     ��������   0
              ��  0           0                0
              ��  0           0                0
              ��  0           0                0
              8   0           0                0
              ҳ  1           1                1
              64  0           0                0
              ��  .           .                .
                  .           .    ��������    .
                  .           .                . 
                  .           .                .
                  0           0                0
            ------------------------------------------------------
 �������  : uint8_t ucData
 �������  : NONE
 �� �� ֵ  : NONE
*****************************************************************************/
void LED_Fill(uint8_t ucData)
{
    uint8_t ucPage,ucColumn;
    
    for(ucPage = 0; ucPage < 8; ucPage++)
    {
        LED_WrCmd(0xb0 + ucPage);  //0xb0+0~7��ʾҳ0~7
        LED_WrCmd(0x00);           //0x00+0~16��ʾ��128�зֳ�16�����ַ��ij���еĵڼ���
        LED_WrCmd(0x10);           //0x10+0~16��ʾ��128�зֳ�16�����ַ���ڵڼ���
        for(ucColumn = 0; ucColumn < 128; ucColumn++)
        {
            LED_WrDat(ucData);
        }
    }
} 

void SetStartColumn(uint8_t ucData)
{
    LED_WrCmd(0x00+ucData % 16);   // Set Lower Column Start Address for Page Addressing Mode
                                   // Default => 0x00
    LED_WrCmd(0x10+ucData / 16);   // Set Higher Column Start Address for Page Addressing Mode
                                   // Default => 0x10
}

void SetAddressingMode(uint8_t ucData)
{
    LED_WrCmd(0x20);        // Set Memory Addressing Mode
    LED_WrCmd(ucData);      // Default => 0x02
                            // 0x00 => Horizontal Addressing Mode
                            // 0x01 => Vertical Addressing Mode
                            // 0x02 => Page Addressing Mode
}

void SetColumnAddress(uint8_t a, uint8_t b)
{
    LED_WrCmd(0x21);        // Set Column Address
    LED_WrCmd(a);           // Default => 0x00 (Column Start Address)
    LED_WrCmd(b);           // Default => 0x7F (Column End Address)
}

void SetPageAddress(uint8_t a, uint8_t b)
{
    LED_WrCmd(0x22);        // Set Page Address
    LED_WrCmd(a);           // Default => 0x00 (Page Start Address)
    LED_WrCmd(b);           // Default => 0x07 (Page End Address)
}

void SetStartLine(uint8_t ucData)
{
    LED_WrCmd(0x40|ucData); // Set Display Start Line
                            // Default => 0x40 (0x00)
}

void SetContrastControl(uint8_t ucData)
{
    LED_WrCmd(0x81);        // Set Contrast Control
    LED_WrCmd(ucData);      // Default => 0x7F
}

void SetChargePump(uint8_t ucData)
{
    LED_WrCmd(0x8D);        // Set Charge Pump
    LED_WrCmd(0x10|ucData); // Default => 0x10
                            // 0x10 (0x00) => Disable Charge Pump
                            // 0x14 (0x04) => Enable Charge Pump
}

void SetSegmentRemap(uint8_t ucData)
{
    LED_WrCmd(0xA0|ucData); // Set Segment Re-Map
                            // Default => 0xA0
                            // 0xA0 (0x00) => Column Address 0 Mapped to SEG0
                            // 0xA1 (0x01) => Column Address 0 Mapped to SEG127
}

void SetEntireDisplay(uint8_t ucData)
{
    LED_WrCmd(0xA4|ucData); // Set Entire Display On / Off
                            // Default => 0xA4
                            // 0xA4 (0x00) => Normal Display
                            // 0xA5 (0x01) => Entire Display On
}

void SetInverseDisplay(uint8_t ucData)
{
    LED_WrCmd(0xA6|ucData); // Set Inverse Display On/Off
                            // Default => 0xA6
                            // 0xA6 (0x00) => Normal Display
                            // 0xA7 (0x01) => Inverse Display On
}

void SetMultiplexRatio(uint8_t ucData)
{
    LED_WrCmd(0xA8);        // Set Multiplex Ratio
    LED_WrCmd(ucData);      // Default => 0x3F (1/64 Duty)
}

void SetDisplayOnOff(uint8_t ucData)
{
    LED_WrCmd(0xAE|ucData); // Set Display On/Off
                            // Default => 0xAE
                            // 0xAE (0x00) => Display Off
                            // 0xAF (0x01) => Display On
}

void SetStartPage(uint8_t ucData)
{
    LED_WrCmd(0xB0|ucData); // Set Page Start Address for Page Addressing Mode
                            // Default => 0xB0 (0x00)
}

void SetCommonRemap(uint8_t ucData)
{
    LED_WrCmd(0xC0|ucData); // Set COM Output Scan Direction
                            // Default => 0xC0
                            // 0xC0 (0x00) => Scan from COM0 to 63
                            // 0xC8 (0x08) => Scan from COM63 to 0
}

void SetDisplayOffset(uint8_t ucData)
{
    LED_WrCmd(0xD3);        // Set Display Offset
    LED_WrCmd(ucData);      // Default => 0x00
}

void SetDisplayClock(uint8_t ucData)
{
    LED_WrCmd(0xD5);        // Set Display Clock Divide Ratio / Oscillator Frequency
    LED_WrCmd(ucData);      // Default => 0x80
                            // D[3:0] => Display Clock Divider
                            // D[7:4] => Oscillator Frequency
}

void SetPrechargePeriod(uint8_t ucData)
{
    LED_WrCmd(0xD9);        // Set Pre-Charge Period
    LED_WrCmd(ucData);      // Default => 0x22 (2 Display Clocks [Phase 2] / 2 Display Clocks [Phase 1])
                            // D[3:0] => Phase 1 Period in 1~15 Display Clocks
                            // D[7:4] => Phase 2 Period in 1~15 Display Clocks
}

void SetCommonConfig(uint8_t ucData)
{
    LED_WrCmd(0xDA);        // Set COM Pins Hardware Configuration
    LED_WrCmd(0x02|ucData); // Default => 0x12 (0x10)
                            // Alternative COM Pin Configuration
                            // Disable COM Left/Right Re-Map
}

void SetVCOMH(uint8_t ucData)
{
    LED_WrCmd(0xDB);        // Set VCOMH Deselect Level
    LED_WrCmd(ucData);      // Default => 0x20 (0.77*VCC)
}

void SetNop(void)
{
    LED_WrCmd(0xE3);        // Command for No Operation
}

/*****************************************************************************
 �� �� ��  : LED_Init
 ��������  : OLED��ʼ��
 �������  : void
 �������  : NONE
 �� �� ֵ  : NONE
*****************************************************************************/
void LED_Init(void)
{
    uint8_t i;

    LED_SCL = 1;      
    LED_RST = 0;
    
    for(i = 0; i < 100; i++)
    {
        _nop_();            //���ϵ絽���濪ʼ��ʼ��Ҫ���㹻��ʱ�䣬���ȴ�RC��λ���      
    }
    
    LED_RST = 1;

    SetDisplayOnOff(0x00);     // Display Off (0x00/0x01)
    SetDisplayClock(0x80);     // Set Clock as 100 Frames/Sec
    SetMultiplexRatio(0x3F);   // 1/64 Duty (0x0F~0x3F)
    SetDisplayOffset(0x00);    // Shift Mapping RAM Counter (0x00~0x3F)
    SetStartLine(0x00);        // Set Mapping RAM Display Start Line (0x00~0x3F)
    SetChargePump(0x04);       // Enable Embedded DC/DC Converter (0x00/0x04)
    SetAddressingMode(0x02);   // Set Page Addressing Mode (0x00/0x01/0x02)
    SetSegmentRemap(0x01);     // Set SEG/Column Mapping     0x00���ҷ��� 0x01����
    SetCommonRemap(0x08);      // Set COM/Row Scan Direction 0x00���·��� 0x08����
    SetCommonConfig(0x10);     // Set Sequential Configuration (0x00/0x10)
    SetContrastControl(0xCF);  // Set SEG Output Current
    SetPrechargePeriod(0xF1);  // Set Pre-Charge as 15 Clocks & Discharge as 1 Clock
    SetVCOMH(0x40);            // Set VCOM Deselect Level
    SetEntireDisplay(0x00);    // Disable Entire Display On (0x00/0x01)
    SetInverseDisplay(0x00);   // Disable Inverse Display On (0x00/0x01)  
    SetDisplayOnOff(0x01);     // Display On (0x00/0x01)
    LED_Fill(0x00);            // ��ʼ����
    LED_SetPos(0,0);

    return;
} 
 
/*****************************************************************************
 �� �� ��  : LED_P6x8Char
 ��������  : ��ʾһ��6x8��׼ASCII�ַ�
 �������  : uint8_t ucIdxX  ��ʾ�ĺ�����0~122
             uint8_t ucIdxY  ҳ��Χ0��7
             uint8_t ucData  ��ʾ���ַ�
 �������  : NONE
 �� �� ֵ  : NONE
*****************************************************************************/
void LED_P6x8Char(uint8_t ucIdxX, uint8_t ucIdxY, uint8_t ucData)
{
    uint8_t i, ucDataTmp;
       
    ucDataTmp = ucData-32;
    if(ucIdxX > 122)
    {
        ucIdxX = 0;
        ucIdxY++;
    }
    
    LED_SetPos(ucIdxX, ucIdxY);
    
    for(i = 0; i < 6; i++)
    {     
        LED_WrDat(F6x8[ucDataTmp][i]);  
    }
}

/*****************************************************************************
 �� �� ��  : LED_P6x8Str
 ��������  : д��һ��6x8��׼ASCII�ַ���
 �������  : uint8_t ucIdxX       ��ʾ�ĺ�����0~122
             uint8_t ucIdxY       ҳ��Χ0��7
             uint8_t ucDataStr[]  ��ʾ���ַ���
 �������  : NONE
 �� �� ֵ  : NONE
*****************************************************************************/
void LED_P6x8Str(uint8_t ucIdxX, uint8_t ucIdxY, uint8_t ucDataStr[])
{
    uint8_t i, j, ucDataTmp;

    for (j = 0; ucDataStr[j] != '\0'; j++)
    {    
        ucDataTmp = ucDataStr[j] - 32;
        if(ucIdxX > 122)
        {
            ucIdxX = 0;
            ucIdxY++;
        }
        
        LED_SetPos(ucIdxX,ucIdxY); 
        
        for(i = 0; i < 6; i++)
        {     
            LED_WrDat(F6x8[ucDataTmp][i]);  
        }
        ucIdxX += 6;
    }

    return;
}

/*****************************************************************************
 �� �� ��  : LED_P8x16Str
 ��������  : д��һ��8x16��׼ASCII�ַ���
 �������  : uint8_t ucIdxX       Ϊ��ʾ�ĺ�����0~120
             uint8_t ucIdxY       Ϊҳ��Χ0��3
             uint8_t ucDataStr[]  Ҫ��ʾ���ַ���
 �������  : NONE
 �� �� ֵ  : NONE
*****************************************************************************/
void LED_P8x16Str(uint8_t ucIdxX, uint8_t ucIdxY, uint8_t ucDataStr[])
{
    uint8_t i, j, ucDataTmp;

    ucIdxY <<= 1;
    
    for (j = 0; ucDataStr[j] != '\0'; j++)
    {    
        ucDataTmp = ucDataStr[j] - 32;
        if(ucIdxX > 120)
        {
            ucIdxX = 0;
            ucIdxY += 2;
        }
        LED_SetPos(ucIdxX, ucIdxY);   
        
        for(i = 0; i < 8; i++) 
        {
            LED_WrDat(F8X16[(ucDataTmp << 4) + i]);
        }
        
        LED_SetPos(ucIdxX, ucIdxY + 1);   
        
        for(i = 0; i < 8; i++) 
        {
            LED_WrDat(F8X16[(ucDataTmp << 4) + i + 8]);
        }
        ucIdxX += 8;
        
    }

    return;
}

/*****************************************************************************
 �� �� ��  : LED_P14x16Str
 ��������  : д��һ��14x16�������ַ������ַ���������躬�д��֣�
 �������  : uint8_t ucIdxX       Ϊ��ʾ�ĺ�����0~114
             uint8_t ucIdxY       Ϊҳ��Χ0��3
             uint8_t ucDataStr[]  Ҫ��ʾ�������ַ���
 �������  : NONE
 �� �� ֵ  : NONE
*****************************************************************************/
void LED_P14x16Str(uint8_t ucIdxX,uint8_t ucIdxY,uint8_t ucDataStr[])
{
    uint8_t i, j;
    uint16_t usAddress;
    
    ucIdxY <<= 1;
    
    j = 0;
    while(ucDataStr[j] != '\0')
    {
        i = 0;
        usAddress = 1;
        while(F14x16_Idx[i] > 127)
        {
            if(F14x16_Idx[i] == ucDataStr[j])
            {
                if(F14x16_Idx[i + 1] == ucDataStr[j + 1])
                {
                    usAddress = i * 14;
                    break;
                }
            }
            i += 2;            
        }
        
        if(ucIdxX > 114)
        {
            ucIdxX = 0;
            ucIdxY += 2;
        }
        
        if(usAddress != 1)// ��ʾ����                   
        {
            LED_SetPos(ucIdxX, ucIdxY);
            for(i = 0; i < 14; i++)               
            {
                LED_WrDat(F14x16[usAddress]);   
                usAddress++;
            }
            
            LED_SetPos(ucIdxX,ucIdxY + 1); 
            for(i = 0;i < 14;i++)          
            {
                LED_WrDat(F14x16[usAddress]);
                usAddress++;
            }
            
            j += 2;        
        }
        else              //��ʾ�հ��ַ�            
        {
            LED_SetPos(ucIdxX,ucIdxY);
            for(i = 0;i < 14;i++)
            {
                LED_WrDat(0);
            }
            
            LED_SetPos(ucIdxX,ucIdxY + 1);
            for(i = 0;i < 14;i++)
            {           
                LED_WrDat(0);   
            }
            
            j++;
        }
        
        ucIdxX += 14;
    }

    return;
}

/*****************************************************************************
 �� �� ��  : LED_PXx16MixStr
 ��������  : ���14x16���ֺ��ַ�����ַ��� ���ַ���������躬�д��֣�
 �������  : uint8_t ucIdxX       Ϊ��ʾ�ĺ�����0~114
             uint8_t ucIdxY       Ϊҳ��Χ0��3
             uint8_t ucDataStr[]  Ҫ��ʾ�������ַ���
 �������  : NONE
 �� �� ֵ  : NONE
*****************************************************************************/
void LED_PXx16MixStr(uint8_t ucIdxX, uint8_t ucIdxY, uint8_t ucDataStr[])
{
    uint8_t ucTmpStr[3];
    uint8_t i = 0;
    
    while(ucDataStr[i] != '\0')
    {
        if(ucDataStr[i] > 127)
        {
            ucTmpStr[0] = ucDataStr[i];
            ucTmpStr[1] = ucDataStr[i + 1];
            ucTmpStr[2] = '\0';          //����Ϊ�����ֽ�
            LED_P14x16Str(ucIdxX, ucIdxY, ucTmpStr);  //��ʾ����
            ucIdxX += 14;
            i += 2;
        }
        else
        {
            ucTmpStr[0] = ucDataStr[i];    
            ucTmpStr[1] = '\0';          //��ĸռһ���ֽ�
            LED_P8x16Str(ucIdxX, ucIdxY, ucTmpStr);  //��ʾ��ĸ
            ucIdxX += 8;
            i += 1;
        }
    }

    return;
} 

/*****************************************************************************
 �� �� ��  : LED_PrintChar
 ��������  : ��һ��Char����ת����3λ��������ʾ
 �������  : uint8_t ucIdxX    ucIdxX�ķ�ΧΪ0��122
             uint8_t ucIdxY    ucIdxY�ķ�ΧΪ0��7
             CHAR8 cData      cDataΪ��Ҫת����ʾ����ֵ -128~127
 �������  : none
 �� �� ֵ  : none
*****************************************************************************/
void LED_PrintChar(uint8_t ucIdxX, uint8_t ucIdxY, char cData)
{
    uint16_t i, j, k, usData;

    if(cData < 0)
    {
        LED_P6x8Char(ucIdxX, ucIdxY, '-');
        usData = (uint16_t)(-cData);
    }
    else
    {
        LED_P6x8Char(ucIdxX, ucIdxY, '+');
        usData = (uint16_t)cData;
    }
    i = usData / 100;
    j = (usData % 100) / 10;
    k = usData % 10;
    
    LED_P6x8Char(ucIdxX+6, ucIdxY, i+48);
    LED_P6x8Char(ucIdxX+12, ucIdxY, j+48);
    LED_P6x8Char(ucIdxX+18, ucIdxY, k+48);   

    return;
}

/*****************************************************************************
 �� �� ��  : LED_PrintShort
 ��������  : ��һ��Short����ת����5λ��������ʾ
 �������  : uint8_t ucIdxX ucIdxX�ķ�ΧΪ0��120
             uint8_t ucIdxY ucIdxYΪҳ�ķ�Χ0��7
             SHORT16 sData  sDataΪ��Ҫת����ʾ����ֵ
 �������  : none
 �� �� ֵ  : none
*****************************************************************************/
void LED_PrintShort(uint8_t ucIdxX, uint8_t ucIdxY, int16_t sData)
{
    uint16_t i, j, k, l, m, usData;
    if(sData < 0)
    {
        LED_P6x8Char(ucIdxX,ucIdxY,'-');
        usData = (uint16_t)(-sData);
    }
    else
    {
        LED_P6x8Char(ucIdxX,ucIdxY,'+');
        usData = (uint16_t)sData;
    }
    
    l = usData / 10000;
    m = (usData % 10000) /1000;
    i = (usData % 1000) / 100;
    j = (usData % 100) / 10;
    k = usData % 10;
    LED_P6x8Char(ucIdxX+6, ucIdxY, l+48);
    LED_P6x8Char(ucIdxX+12, ucIdxY, m+48);
    LED_P6x8Char(ucIdxX+18, ucIdxY, i+48);
    LED_P6x8Char(ucIdxX+24, ucIdxY, j+48);
    LED_P6x8Char(ucIdxX+30, ucIdxY, k+48);  

    return;
}

/*****************************************************************************
 �� �� ��  : LED_PrintImage
 ��������  : ��ͼ����ʾ����
 �������  : uint8_t *pucTable     ��άͼ������ĵ�ַ
             uint16_t usRowNum    ��άͼ�������1~64
             uint16_t usColumnNum ��άͼ�������1~128
 �������  : none
 �� �� ֵ  : none
*****************************************************************************/
void LED_PrintImage(uint8_t *pucTable, uint16_t usRowNum, uint16_t usColumnNum)
{
    uint8_t ucData;
    uint16_t i,j,k,m,n;
    uint16_t usRowTmp;

    m = usRowNum >> 3;   //����ͼƬ������8λΪһ������������
    n = usRowNum % 8;    //����������ʣ�µ�����
    
    for(i = 0; i < m; i++) //��������ɨ��
    {
        LED_SetPos(0,(uint8_t)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] == LED_IMAGE_WHITE)
                {
                    ucData = ucData | 0x80;
                }
                
            }
            LED_WrDat(ucData);
        }
    }
    
    LED_SetPos(0,(uint8_t)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] == LED_IMAGE_WHITE)
            {
                ucData = ucData | 0x80;
            }
            
        }
        ucData = ucData >> (8 - n);
        LED_WrDat(ucData);
    }

    return;
}

void LED_PrintBMP(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint8_t bmp[])
{
  uint16_t ii = 0;
  uint8_t x, y;
  for(y = y0; y <= y1; y++)
    {
      LED_SetPos(x0, y);
      for(x=x0;x < x1; x++)
        {
          LED_WrDat(bmp[ii++]);
        }
    }
}



高工
2022-01-17 05:14:26     打赏
17楼

效果展示

周末由于身体不适,加之北京疫情突发,我又恰巧疑似与确诊病例有时空交集。唉~

本次的界面展示也仅限于逆变器界面了。先上图:

inverter.jpg


其实通过Modbus协议可以非常轻松的扩展寄存器变量。如果你不了解Modbus协议,抓紧时间充分了解。



高工
2022-01-17 05:25:38     打赏
18楼

专家
2022-01-17 05:55:40     打赏
19楼

谢谢分享


专家
2022-01-17 08:20:38     打赏
20楼

谢谢分享


共26条 2/3 1 2 3 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]