1 UART
实验目的
串口在我们开发单片机项目是很重要的,可以观察我们的代码运行情况,本节的目的就 是实现串口双工收发。
虽然说 osal 相关的代码已经跟硬件关系不大了,但是我们还是来贴出相关的硬件原理图贴出来。
1.1 串口初始化
osal_init_system-》
osalInitTasks-》
SimpleBLEPeripheral_Init-》
95 行,串口初始化 波特率默认是 115200, 形参是回调函数
170 行, 这个事串口的会调函数,当收到串口数据时执行该函数
174 行, 判断是否是串口有数据
179 行, 读出串口数据
194 行, 作为测试,我们把读出来的数据重新通过串口发送出去。
/ 串口回调函数, 下面把该回调函数里实现的功能讲解一下
/*
1, 思路: 当串口收到数据后,就会马上调用以下回调函数,在实际测试中发现,此回调
函数调用频繁, 如果你不执行NPI_ReadTransport函数进行读取, 那么这个回调函数就会
频繁地被执行,但是,你通过串口发送一段数据, 你本意是想处理这一完整一段的数据,所以,
我们在下面引入了时间的处理方法, 也即接收的数据够多或者超时,就读取一次数据,
然后根据当前的状态决定执行,如果没有连接上,就把所有数据当做AT命令处理, 如果连接
上了,就把数据送到对端。
1.2 多种串口函数实现
注意红框内的各种串口输出调用,方便我们使用。
1.4 封装两个功能的详解
循环打印实现
2 系统定时器
OSAL 里使用了一个 1ms 的节拍器作为系统定时器,这个定时器是可配置的, 这一节我们就来看一看这个定时器的最基本用法。
2.1 实验目的
简单体会 osal 节拍定时器下的系统定时器,实际上,在我们的单片机应用程序中,通 常使用此定时器定期执行某些固定的代码, 例如用来控制 led 的闪烁与定期输出数据
2.2 源码分析
定时器函数定义
OSAL_Timers.c
OSAL_Timers.h
这两个函数是 OSAL 系统定义的定时器,打开 OSAL_Timers.h , 我们发现有如下函 4 个函数是我们很常用的,做一下介绍, 其他的暂时不讲
【1】启动定时器, 仅一次
uint8 osal_start_timerEx( uint8 taskID, uint16 event_id, uint32 timeout_value )
【2】启动定时器, 自动重装
uint8 osal_start_reload_timer( uint8 taskID, uint16 event_id, uint32
timeout_value )
【3】停止定时器
uint8 osal_stop_timerEx( uint8 task_id, uint16 event_id )
【4】返回系统时钟 (一般用于对比现在与历史的时间, 后面我们的 AT 命令就用到这个来辅助了)
uint32 osal_GetSystemClock( void )
2.3 定时器简单使用
在本例中, 我们启动后 5 秒钟吧 led1 点亮
102 行, 启动任务, 后面将会启动一个定时器的
139 行, 启动一个定时器,注意下形参: SimpleBLETest_TaskID是我们的 app 任务 ID SBP_PERIODIC_EVT 是我们定义的用户任务标识这个的定义比较有意思, 都是以位来判断的,这样的好处是可以节约内存, 比如我们这个 例子中,uint16 SimpleBLETest_ProcessEvent( uint8 task_id, uint16 events ) 的形参 events 就 是包含 16 个位的事件标记值,一般都是我们处理完成 一个任务后,把相对应的任务事件标 记值的相关位清零, 见上图的 146 行。 SBP_PERIODIC_EVT_PERIOD 是定时器的定时时长, 单位为 ms.
150 行, 是定时器时间到
153 行, 执行 led1 点亮。
2.4 定时器定义
有些同学不免要问系统节拍定时器来自哪里,我们在这里也提及一下:
86 行,节拍间隔时间 88 行, osal 的定时器
这一块相关的代码是在 ti 提供的库里边的, 我们看不到代码, 因此, 在编码过程中,我们就不要再对 timer3 相关的寄存器进行读写了, 免得出错。
注意: 这个系统节拍定时器的参数是不可以修改的, 这里只是提供头文件给 我们了解一下 而已, 库文件里已经写死了的,我们不能修改了。
编译
3 LED点灯
3.1 实验目的
简单体会 osal 提供的函数来点亮 led 的最基本用法
3.2 源码分析
这两个函数是 HAL 层定义好的函数, 提供给我们的应用程序进行调用, 里边比较重要的函数如下:
形参 Mode 的定义如下:
#define HAL_LED_MODE_OFF 0x00 // 关闭灯
#define HAL_LED_MODE_ON 0x01 // 开启灯
#define HAL_LED_MODE_BLINK 0x02 // 灯闪一次
#define HAL_LED_MODE_FLASH 0x04 // 灯连续闪烁 1s 一次
#define HAL_LED_MODE_TOGGLE 0x08 // 灯的输出取反
【2】led 灯闪烁
void HalLedBlink (uint8 leds, uint8 numBlinks, uint8 percent, uint16 period)
参数 leds : 对应的 led
参数 numBlinks: 闪烁次数
参数 percent: 占空比
参数 period: 周期(ms)
例如要 led1 输出 1hz 的方波
HalLedBlink(HAL_LED_1, 100, 50,1000);
表现为 led1 1 秒亮灭一次。
3.3 led 简单使用
在本例中, 我们启动后 led1 点亮
144 行, 灯连续闪烁 1s 一次 一共两次
TI 在开发板这些套件的时候,考虑到不同的人群不同的项目要求,并且 考虑到不同的管脚 分配以便能达到更低功耗,所以才出了好几种开发板,熟悉的朋友还会知道有一个开发板叫做SensorTAG, 是专门针对可穿戴传感器集合开发的, 由于那些集成的传感器我们很难购 买到,所以我们没有开发SensorTag 的兼容开发板
为了让 led1 灯正常工作,我们需要确保两个宏定义的设置如下:
设置方法:
3.4 跑马灯使用
在本例中, 我们启动后 led1 点亮
142 行, 启动自动重转定时器
159 行,定义一个静态变量, 静态变量也就是说这个变量在程序退出该函数后, 该变量不 会被销毁,并且定义时可以赋初值,在本例中,我们为了代码的统一性,定义了该静态变量, 实际上,把该变量定义到全局变量也是可以的。
4 OLED使用
4.1 实验目的
TI 的 SmartRF 蓝牙 4.0 开发套件是包含有 lcd 显示屏的,这也是我们的套件 与之不同之处,我们使用同样分辨率的 oled 显示屏,尺寸小,显示效果佳,更省电,但显示驱动 不同,因此,我们需要修改驱动。
虽然说 osal 相关的代码已经跟硬件关系不大了,但是我们还是来贴出相关的硬件原理图出来
4.2 OSAL 中显示屏相关函数
在 Hal_lcd.h (src\components\hal\include) 中, 是给 app 等程序文件引用的与显示相关的函数, 主要是显示屏初始化与显示操作。
例如比较常用的几个函数如下
95 行: 显示屏初始化
100 行:显示一个字符串到屏幕上
105 行:显示一个值到屏幕上
在 Hal_lcd.c (src\components\hal\target\cc2540eb) 文件中, 我们实现了头 文件中的驱动 函数: ( 实际上, 这个 Hal_lcd.c 文件是我们自己唯一修改过的驱
动, 其它的 osal 驱动都 不必修改 )
以上是 oled 显示屏的控制线定义。
584 行, 是初始化函数。
在 Hal_drivers.c (src\components\hal\common) 文件中, 实现了对显示屏
驱动的调用:
131 行, 由此可见, 我们需要定义 HAL_LCD=TRUE , 才会有条件地执行
对显示屏的初 始化。这个定义在 IAR 中的以下地方:
在以下文件中:
simpleBLETest.c
(osal 操作系统 - 实验 08 oled 显示 \ble-cc254x-1.3.2- osal\projects\ble\simpleble\source)
含有我们调用不同函数实现不同的显示效果的操作,在实际显示时,可以调用我们最方便使用的函数来实现显示:
hal_lcd.h
cpp
/**************************************************************************************************
Filename: hal_lcd.h
Revised: $Date: 2007-07-06 10:42:24 -0700 (Fri, 06 Jul 2007) $
Revision: $Revision: 13579 $
Description: This file contains the interface to the LCD Service.
Copyright 2005-2007 Texas Instruments Incorporated. All rights reserved.
IMPORTANT: Your use of this Software is limited to those specific rights
granted under the terms of a software license agreement between the user
who downloaded the software, his/her employer (which must be your employer)
and Texas Instruments Incorporated (the "License"). You may not use this
Software unless you agree to abide by the terms of the License. The License
limits your use, and you acknowledge, that the Software may not be modified,
copied or distributed unless embedded on a Texas Instruments microcontroller
or used solely and exclusively in conjunction with a Texas Instruments radio
frequency transceiver, which is integrated into your product. Other than for
the foregoing purpose, you may not use, reproduce, copy, prepare derivative
works of, modify, distribute, perform, display or sell this Software and/or
its documentation for any purpose.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED 揂S IS?WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
Should you have any questions regarding your right to use this Software,
contact Texas Instruments Incorporated at www.TI.com.
**************************************************************************************************/
#ifndef HAL_LCD_H
#define HAL_LCD_H
#ifdef __cplusplus
extern "C"
{
#endif
/**************************************************************************************************
* INCLUDES
**************************************************************************************************/
#include "hal_board.h"
#if (defined HAL_LCD) && (HAL_LCD == TRUE)
#endif
/**************************************************************************************************
* CONSTANTS
**************************************************************************************************/
/* These are used to specify which line the text will be printed */
#define HAL_LCD_LINE_1 0x01
#define HAL_LCD_LINE_2 0x02
/*
This to support LCD with extended number of lines (more than 2).
Don't use these if LCD doesn't support more than 2 lines
*/
#define HAL_LCD_LINE_3 0x03
#define HAL_LCD_LINE_4 0x04
#define HAL_LCD_LINE_5 0x05
#define HAL_LCD_LINE_6 0x06
#define HAL_LCD_LINE_7 0x07
#define HAL_LCD_LINE_8 0x08
/**************************************************************************************************
* MACROS
**************************************************************************************************/
/**************************************************************************************************
* TYPEDEFS
**************************************************************************************************/
/**************************************************************************************************
* GLOBAL VARIABLES
**************************************************************************************************/
/**************************************************************************************************
* FUNCTIONS - API
**************************************************************************************************/
/*
* Initialize LCD Service
*/
extern void HalLcdInit(void);
/*
* Write a string to the LCD
*/
extern void HalLcdWriteString ( char *str, uint8 option);
/*
* Write a value to the LCD
*/
extern void HalLcdWriteValue ( uint32 value, const uint8 radix, uint8 option);
/*
* Write a value to the LCD
*/
extern void HalLcdWriteScreen( char *line1, char *line2 );
/*
* Write a string followed by a value to the LCD
*/
extern void HalLcdWriteStringValue( char *title, uint16 value, uint8 format, uint8 line );
/*
* Write a string followed by 2 values to the LCD
*/
extern void HalLcdWriteStringValueValue( char *title, uint16 value1, uint8 format1, uint16 value2, uint8 format2, uint8 line );
/*
* Write a percentage bar to the LCD
*/
extern void HalLcdDisplayPercentBar( char *title, uint8 value );
/**************************************************************************************************
**************************************************************************************************/
#ifdef __cplusplus
}
#endif
#endif
cpp
/**************************************************************************************************
* INCLUDES
**************************************************************************************************/
#if (HAL_LCD == TRUE)
#include "hal_types.h"
#include "hal_lcd.h"
#include "OSAL.h"
#include "OnBoard.h"
#include "hal_assert.h"
#if defined (ZTOOL_P1) || defined (ZTOOL_P2)
#include "DebugTrace.h"
#endif
#else
#include "ioCC2540.h"
#endif
#ifdef LCD_TO_UART
#include "npi.h"
#endif
#include "stdio.h"
#include "Hal_lcd.h"
#define LCD_SCL P1_5 //SCLK 时钟 D0(SCLK)
#define LCD_SDA P1_6 //SDA D1(MOSI) 数据
#define LCD_RST P1_7 //_RES hardware reset 复位
#define LCD_DC P1_2 //A0 H/L 命令数据选通端,H:数据,L:命令
#define X_WIDTH 128
#define Y_WIDTH 64
/* LCD lines */
#define LCD_MAX_LINE_COUNT 8
#define LCD_MAX_LINE_LENGTH 21
#define LCD_MAX_BUF 25
static uint8 *Lcd_Line1;
#ifdef LCD_SUPPORT
/***************************16*16的点阵字体取模方式:共阴------列行式------逆向输出*********/
const unsigned char F16x16[] =
{
/*-- 文字: 创 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x40,0x20,0xD0,0x4C,0x43,0x44,0xC8,0x10,0x20,0x00,0xF8,0x00,0x00,0xFF,0x00,0x00,
0x00,0x00,0x3F,0x40,0x44,0x48,0x47,0x40,0x70,0x00,0x0F,0x40,0x80,0x7F,0x00,0x00,
/*-- 文字: 思 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0xFE,0x92,0x92,0x92,0x92,0xFE,0x92,0x92,0x92,0x92,0xFE,0x00,0x00,0x00,
0x40,0x38,0x01,0x00,0x3C,0x40,0x40,0x42,0x4C,0x40,0x40,0x70,0x05,0x08,0x30,0x00,
/*-- 文字: 通 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x40,0x42,0xCC,0x00,0x00,0xE2,0x22,0x2A,0x2A,0xF2,0x2A,0x26,0x22,0xE0,0x00,0x00,
0x80,0x40,0x3F,0x40,0x80,0xFF,0x89,0x89,0x89,0xBF,0x89,0xA9,0xC9,0xBF,0x80,0x00,
/*-- 文字: 信 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x80,0x60,0xF8,0x07,0x00,0x04,0x24,0x24,0x25,0x26,0x24,0x24,0x24,0x04,0x00,
0x01,0x00,0x00,0xFF,0x00,0x00,0x00,0xF9,0x49,0x49,0x49,0x49,0x49,0xF9,0x00,0x00,
/*-- 文字: 创 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x40,0x20,0xD0,0x4C,0x43,0x44,0xC8,0x10,0x20,0x00,0xF8,0x00,0x00,0xFF,0x00,0x00,
0x00,0x00,0x3F,0x40,0x44,0x48,0x47,0x40,0x70,0x00,0x0F,0x40,0x80,0x7F,0x00,0x00,
/*-- 文字: 造 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x40,0x40,0x42,0xCC,0x00,0x28,0x26,0x24,0x24,0x3F,0x24,0x24,0x24,0x20,0x00,0x00,
0x00,0x40,0x20,0x1F,0x20,0x40,0x5F,0x49,0x49,0x49,0x49,0x49,0x5F,0x40,0x40,0x00,
/*-- 文字: 奇 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x40,0x40,0x44,0x44,0x64,0x54,0x4C,0x47,0x4C,0x54,0x64,0xC4,0x44,0x40,0x40,0x00,
0x00,0x00,0x00,0x1E,0x12,0x12,0x12,0x12,0x1E,0x40,0x80,0x7F,0x00,0x00,0x00,0x00,
/*-- 文字: 迹 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x40,0x40,0x42,0xCC,0x00,0x08,0xC8,0x08,0xF8,0x09,0x0E,0xF8,0x08,0x48,0x88,0x00,
0x00,0x40,0x20,0x1F,0x20,0x51,0x48,0x46,0x41,0x48,0x50,0x4F,0x40,0x40,0x41,0x00,
/*-- 文字: 思 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0xFE,0x92,0x92,0x92,0x92,0xFE,0x92,0x92,0x92,0x92,0xFE,0x00,0x00,0x00,
0x40,0x38,0x01,0x00,0x3C,0x40,0x40,0x42,0x4C,0x40,0x40,0x70,0x05,0x08,0x30,0x00,
/*-- 文字: 索 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x80,0x60,0x24,0x24,0x24,0xA4,0x64,0x3F,0x24,0x24,0xA4,0x24,0x24,0xA0,0x60,0x00,
0x00,0x80,0x48,0x29,0x09,0x4D,0x8D,0x7B,0x0B,0x09,0x28,0x4C,0x98,0x00,0x00,0x00,
/*-- 文字: 未 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x80,0x80,0x88,0x88,0x88,0x88,0x88,0xFF,0x88,0x88,0x88,0x88,0x88,0x80,0x80,0x00,
0x20,0x20,0x10,0x08,0x04,0x02,0x01,0xFF,0x01,0x02,0x04,0x08,0x10,0x20,0x20,0x00,
/*-- 文字: 来 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x08,0x08,0x28,0xC8,0x08,0x08,0xFF,0x08,0x08,0x88,0x68,0x08,0x08,0x00,0x00,
0x21,0x21,0x11,0x11,0x09,0x05,0x03,0xFF,0x03,0x05,0x09,0x11,0x11,0x21,0x21,0x00,
/*-- 文字: 科 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x24,0x24,0xA4,0xFE,0xA3,0x22,0x00,0x22,0xCC,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,
0x08,0x06,0x01,0xFF,0x00,0x01,0x04,0x04,0x04,0x04,0x04,0xFF,0x02,0x02,0x02,0x00,
/*-- 文字: 技 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x10,0x10,0x10,0xFF,0x10,0x90,0x08,0x88,0x88,0x88,0xFF,0x88,0x88,0x88,0x08,0x00,
0x04,0x44,0x82,0x7F,0x01,0x80,0x80,0x40,0x43,0x2C,0x10,0x28,0x46,0x81,0x80,0x00,
/*-- 文字: 共 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x10,0x10,0x10,0xFF,0x10,0x10,0x10,0x10,0xFF,0x10,0x10,0x10,0x00,0x00,
0x00,0x04,0x84,0x44,0x24,0x17,0x04,0x04,0x04,0x04,0x17,0x24,0x44,0x84,0x04,0x00,
/*-- 文字: 赢 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x02,0x02,0xEE,0xAA,0xAA,0xAA,0xAA,0xAB,0xAA,0xAA,0xAA,0xAA,0xEA,0x02,0x02,0x00,
0x80,0x7E,0xAA,0xFE,0x00,0xBE,0x42,0x3A,0x42,0xBE,0x80,0x7E,0x12,0x7E,0xE0,0x00,
};
/****************************************8*16的点阵************************************/
static const unsigned char 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,//0 16
0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//1 17
0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,//2 18
0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00,//3 19
0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,//4 20
0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00,//5 21
0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00,//6 22
0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,//7 23
0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,//8 24
0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00,//9 25
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,//A 33
0x08,0xF8,0x88,0x88,0x88,0x70,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x11,0x0E,0x00,//B 34
0xC0,0x30,0x08,0x08,0x08,0x08,0x38,0x00,0x07,0x18,0x20,0x20,0x20,0x10,0x08,0x00,//C 35
0x08,0xF8,0x08,0x08,0x08,0x10,0xE0,0x00,0x20,0x3F,0x20,0x20,0x20,0x10,0x0F,0x00,//D 36
0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x20,0x23,0x20,0x18,0x00,//E 37
0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x00,0x03,0x00,0x00,0x00,//F 38
0xC0,0x30,0x08,0x08,0x08,0x38,0x00,0x00,0x07,0x18,0x20,0x20,0x22,0x1E,0x02,0x00,//G 39
0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x20,0x3F,0x21,0x01,0x01,0x21,0x3F,0x20,//H 40
0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//I 41
0x00,0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,0x00,//J 42
0x08,0xF8,0x88,0xC0,0x28,0x18,0x08,0x00,0x20,0x3F,0x20,0x01,0x26,0x38,0x20,0x00,//K 43
0x08,0xF8,0x08,0x00,0x00,0x00,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x20,0x30,0x00,//L 44
0x08,0xF8,0xF8,0x00,0xF8,0xF8,0x08,0x00,0x20,0x3F,0x00,0x3F,0x00,0x3F,0x20,0x00,//M 45
0x08,0xF8,0x30,0xC0,0x00,0x08,0xF8,0x08,0x20,0x3F,0x20,0x00,0x07,0x18,0x3F,0x00,//N 46
0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x10,0x20,0x20,0x20,0x10,0x0F,0x00,//O 47
0x08,0xF8,0x08,0x08,0x08,0x08,0xF0,0x00,0x20,0x3F,0x21,0x01,0x01,0x01,0x00,0x00,//P 48
0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x18,0x24,0x24,0x38,0x50,0x4F,0x00,//Q 49
0x08,0xF8,0x88,0x88,0x88,0x88,0x70,0x00,0x20,0x3F,0x20,0x00,0x03,0x0C,0x30,0x20,//R 50
0x00,0x70,0x88,0x08,0x08,0x08,0x38,0x00,0x00,0x38,0x20,0x21,0x21,0x22,0x1C,0x00,//S 51
0x18,0x08,0x08,0xF8,0x08,0x08,0x18,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,//T 52
0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,//U 53
0x08,0x78,0x88,0x00,0x00,0xC8,0x38,0x08,0x00,0x00,0x07,0x38,0x0E,0x01,0x00,0x00,//V 54
0xF8,0x08,0x00,0xF8,0x00,0x08,0xF8,0x00,0x03,0x3C,0x07,0x00,0x07,0x3C,0x03,0x00,//W 55
0x08,0x18,0x68,0x80,0x80,0x68,0x18,0x08,0x20,0x30,0x2C,0x03,0x03,0x2C,0x30,0x20,//X 56
0x08,0x38,0xC8,0x00,0xC8,0x38,0x08,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,//Y 57
0x10,0x08,0x08,0x08,0xC8,0x38,0x08,0x00,0x20,0x38,0x26,0x21,0x20,0x20,0x18,0x00,//Z 58
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,//a 65
0x08,0xF8,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x3F,0x11,0x20,0x20,0x11,0x0E,0x00,//b 66
0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x0E,0x11,0x20,0x20,0x20,0x11,0x00,//c 67
0x00,0x00,0x00,0x80,0x80,0x88,0xF8,0x00,0x00,0x0E,0x11,0x20,0x20,0x10,0x3F,0x20,//d 68
0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x22,0x22,0x22,0x22,0x13,0x00,//e 69
0x00,0x80,0x80,0xF0,0x88,0x88,0x88,0x18,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//f 70
0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x6B,0x94,0x94,0x94,0x93,0x60,0x00,//g 71
0x08,0xF8,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,//h 72
0x00,0x80,0x98,0x98,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//i 73
0x00,0x00,0x00,0x80,0x98,0x98,0x00,0x00,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,//j 74
0x08,0xF8,0x00,0x00,0x80,0x80,0x80,0x00,0x20,0x3F,0x24,0x02,0x2D,0x30,0x20,0x00,//k 75
0x00,0x08,0x08,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//l 76
0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x20,0x3F,0x20,0x00,0x3F,0x20,0x00,0x3F,//m 77
0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,//n 78
0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,//o 79
0x80,0x80,0x00,0x80,0x80,0x00,0x00,0x00,0x80,0xFF,0xA1,0x20,0x20,0x11,0x0E,0x00,//p 80
0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x0E,0x11,0x20,0x20,0xA0,0xFF,0x80,//q 81
0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x20,0x20,0x3F,0x21,0x20,0x00,0x01,0x00,//r 82
0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x33,0x24,0x24,0x24,0x24,0x19,0x00,//s 83
0x00,0x80,0x80,0xE0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x1F,0x20,0x20,0x00,0x00,//t 84
0x80,0x80,0x00,0x00,0x00,0x80,0x80,0x00,0x00,0x1F,0x20,0x20,0x20,0x10,0x3F,0x20,//u 85
0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x00,0x01,0x0E,0x30,0x08,0x06,0x01,0x00,//v 86
0x80,0x80,0x00,0x80,0x00,0x80,0x80,0x80,0x0F,0x30,0x0C,0x03,0x0C,0x30,0x0F,0x00,//w 87
0x00,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x31,0x2E,0x0E,0x31,0x20,0x00,//x 88
0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x80,0x81,0x8E,0x70,0x18,0x06,0x01,0x00,//y 89
0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x21,0x30,0x2C,0x22,0x21,0x30,0x00,//z 90
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
};
#endif
/************************************6*8的点阵************************************/
static const unsigned char F6x8[92][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
};
/*-- 宽度x高度=128x64 D:\mdcg.bmp--*/
#if 0
unsigned char BMP[] =
{
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xFC,0xFC,0x70,0xE0,0xFF,0x8C,0xF0,0xE0,0xC0,0xC0,0xC0,0xE0,
0xE0,0xF0,0xF0,0xF0,0xF8,0x98,0x1C,0x0C,0x2C,0x24,0x04,0x1C,0xF8,0x00,0x00,0xFE,
0xFF,0x4C,0x4C,0xF8,0xF8,0x60,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x60,0x60,0xF8,0xF8,0xFF,0xBF,0xFE,0xFF,0xFF,0xFF,0x87,0x83,0xBF,0xBF,0xFF,0xFF,
0xFD,0xE1,0xF1,0xFF,0xFF,0xFF,0xFC,0x61,0x62,0x32,0x13,0x1D,0x0F,0x00,0x00,0x03,
0xEF,0x7A,0x7E,0xCF,0x9D,0x1B,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0x60,
0x18,0x0C,0xC6,0xE2,0x79,0x7D,0xB7,0xF2,0x71,0x39,0x19,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x0E,0x0E,0x0E,0xCE,0x0E,0x0E,0x0E,0x0E,0x0E,0xFE,0x00,0x00,0x00,0x00,
0x0E,0x0E,0x0E,0xCE,0x3E,0xCE,0x0E,0x0E,0x0E,0xC0,0x00,0x00,0x00,0xFE,0x00,0x00,
0x00,0x09,0x97,0xDE,0x6D,0xB7,0xFF,0x7F,0xFF,0xFF,0x9F,0x1F,0x4F,0x87,0xC7,0xE7,
0x17,0x9F,0x9D,0xF1,0xE1,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x0F,
0x83,0xE0,0x60,0x1D,0xFF,0xFE,0x06,0x0E,0x1C,0x18,0x00,0x00,0xF0,0x87,0xC1,0xE0,
0x70,0x38,0x1F,0x1E,0x1F,0x1D,0x07,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xFE,0xC0,0xCE,0xF0,0xF0,0xC0,0x00,
0x30,0x30,0x30,0xF0,0x30,0x30,0x00,0x00,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xF0,0xCF,0xC0,0xC0,0xC0,0xC0,0xFE,0xC1,0xC0,0xC0,0x00,0x00,
0x30,0x3E,0x3E,0x31,0xF0,0x31,0x3E,0x3E,0x30,0xFF,0x00,0x00,0x00,0xFF,0x00,0x00,
0x00,0x00,0x00,0x03,0x0D,0x3E,0xDB,0x6B,0x37,0x1F,0x7C,0xFC,0xC5,0xC7,0x3F,0x07,
0x03,0x86,0x8C,0xC0,0xC0,0xC1,0xE3,0x6F,0xEE,0xFC,0x38,0x30,0x30,0x90,0x90,0x7B,
0xE9,0xEC,0x7C,0xFC,0xFF,0xFE,0xFE,0xF7,0xEF,0x3F,0x3F,0xBD,0xF7,0xDF,0x7E,0xF8,
0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0xFF,0xFF,0xC1,0xC1,0xC1,0x01,0x01,0xFF,0x01,0x01,0xF1,0xF1,0x01,0x00,
0x00,0x00,0x00,0xFF,0x00,0x00,0x0E,0x0E,0x0E,0xFF,0x0E,0x0E,0x0E,0xFE,0x00,0x00,
0x00,0x38,0x38,0x38,0x39,0x39,0x39,0x39,0x39,0x39,0x39,0x01,0xFF,0xFF,0x00,0x00,
0x38,0x38,0x38,0x38,0xFF,0x38,0x38,0x38,0x00,0xFF,0x00,0x00,0x00,0xFF,0x00,0x00,
0x00,0x00,0x00,0x08,0xFC,0xFC,0x1E,0x3E,0xFE,0xFE,0xE7,0xE7,0xE3,0xC7,0xCF,0xD9,
0xF1,0xF0,0xF9,0x0C,0x60,0xFF,0xFF,0xDB,0x9B,0x08,0x01,0xFF,0xFF,0xCC,0xEC,0xEE,
0xEE,0xC3,0xFF,0x2D,0x6C,0x76,0x37,0x33,0x13,0xFF,0x7C,0x96,0xD6,0xEB,0x6B,0xE9,
0xFF,0xFF,0xF8,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0xFF,0xFF,0xC1,0x01,0xFF,0x00,0x00,0x07,0xF8,0x06,0x01,0x01,0xC0,0x00,
0xC0,0xC0,0xC0,0x3F,0x38,0x38,0x00,0x00,0xF8,0x07,0x00,0x00,0x00,0xFF,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x38,0x38,0x07,0x07,0x00,0x00,
0x38,0x38,0x38,0x38,0x07,0x06,0x06,0x06,0x06,0x01,0x38,0x38,0x38,0x3F,0x00,0x00,
0x00,0x00,0x00,0x00,0x7F,0xFF,0x00,0x00,0x7F,0xFF,0x00,0x00,0x00,0x00,0x00,0x81,
0xC1,0x7D,0x1F,0x03,0x87,0x66,0x7C,0x1C,0x1E,0x1F,0x3F,0x3B,0x33,0x37,0x37,0x7E,
0x7C,0x37,0x34,0x37,0x3F,0x1B,0x1B,0x78,0x7F,0x87,0x84,0xFE,0xFE,0x03,0x07,0x07,
0x18,0x38,0x60,0xC0,0x0F,0x3C,0xE0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x38,0x07,0x07,0x01,0x06,0x01,0x38,0x38,0x06,0x01,0x06,0x38,0x38,0x3F,0x00,
0x01,0x01,0x01,0x00,0x38,0x38,0x06,0x06,0x01,0x38,0x38,0x38,0x38,0x07,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x3F,0x3F,0x3F,0x3F,0x3F,0xB0,0x80,0x70,0xB8,0x7F,0x7F,
0x1B,0x0C,0x06,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x40,
0x40,0x60,0xA0,0xB0,0x98,0x48,0x48,0x64,0x34,0x1F,0x1B,0x0F,0x07,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x07,0x06,0x19,0x3F,0x7C,0xF8,0xC0,0x80,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xC0,0xF0,0xF8,0xCC,0xE6,0x1F,0x0D,0x03,0x01,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x78,0x3F,0x3F,0x3F,0x3F,0x06,
0x02,0x03,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0xFF,0xFF,0xFF,0xFF,0x0E,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
#endif
/*********************LCD 延时1ms************************************/
void LCD_DLY_ms(unsigned int ms)
{
unsigned int a;
while(ms)
{
a=1800;
while(a--);
ms--;
}
return;
}
/*********************LCD写数据************************************/
void LCD_WrDat(unsigned char dat)
{
unsigned char i=8, temp=0;
LCD_DC=1;
for(i=0;i<8;i++) //发送一个八位数据
{
LCD_SCL=0;
temp = dat&0x80;
if (temp == 0)
{
LCD_SDA = 0;
}
else
{
LCD_SDA = 1;
}
LCD_SCL=1;
dat<<=1;
}
}
/*********************LCD写命令************************************/
void LCD_WrCmd(unsigned char cmd)
{
unsigned char i=8, temp=0;
LCD_DC=0;
for(i=0;i<8;i++) //发送一个八位数据
{
LCD_SCL=0;
temp = cmd&0x80;
if (temp == 0)
{
LCD_SDA = 0;
}
else
{
LCD_SDA = 1;
}
LCD_SCL=1;
cmd<<=1;;
}
}
/*********************LCD 设置坐标************************************/
void LCD_Set_Pos(unsigned char x, unsigned char y)
{
LCD_WrCmd(0xb0+y);
LCD_WrCmd(((x&0xf0)>>4)|0x10);
LCD_WrCmd((x&0x0f)|0x01);
}
/*********************LCD全屏************************************/
void LCD_Fill(unsigned char bmp_dat)
{
unsigned char 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_dat);
}
}
/***************功能描述:行填充, y为页范围0~7****************/
void LCD_FillLine(unsigned char y,unsigned char ch)
{
unsigned char x;
LCD_WrCmd(0xb0+y);
LCD_WrCmd(0x01);
LCD_WrCmd(0x10);
for(x=0;x<X_WIDTH;x++)
LCD_WrDat(ch);
}
/*********************LCD复位************************************/
void LCD_CLS(void)
{
unsigned char 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);
}
}
/*********************LCD初始化************************************/
void HalLcd_HW_Init(void)
{
P1SEL &= 0x1b; //让 P1.2 P1.5 P1.6 P1.7为普通IO口 00011011
P1DIR |= 0xe4; //把 P1.2 P1.3 1.7设置为输出 11100100
LCD_SCL=1;
LCD_RST=0;
LCD_DLY_ms(50);
LCD_RST=1; //从上电到下面开始初始化要有足够的时间,即等待RC复位完毕
LCD_WrCmd(0xae);//--turn off oled panel
LCD_WrCmd(0x00);//---set low column address
LCD_WrCmd(0x10);//---set high column address
LCD_WrCmd(0x40);//--set start line address Set Mapping RAM Display Start Line (0x00~0x3F)
LCD_WrCmd(0x81);//--set contrast control register
LCD_WrCmd(0xcf); // Set SEG Output Current Brightness
LCD_WrCmd(0xa1);//--Set SEG/Column Mapping 0xa0左右反置 0xa1正常
LCD_WrCmd(0xc8);//Set COM/Row Scan Direction 0xc0上下反置 0xc8正常
LCD_WrCmd(0xa6);//--set normal display
LCD_WrCmd(0xa8);//--set multiplex ratio(1 to 64)
LCD_WrCmd(0x3f);//--1/64 duty
LCD_WrCmd(0xd3);//-set display offset Shift Mapping RAM Counter (0x00~0x3F)
LCD_WrCmd(0x00);//-not offset
LCD_WrCmd(0xd5);//--set display clock divide ratio/oscillator frequency
LCD_WrCmd(0x80);//--set divide ratio, Set Clock as 100 Frames/Sec
LCD_WrCmd(0xd9);//--set pre-charge period
LCD_WrCmd(0xf1);//Set Pre-Charge as 15 Clocks & Discharge as 1 Clock
LCD_WrCmd(0xda);//--set com pins hardware configuration
LCD_WrCmd(0x12);
LCD_WrCmd(0xdb);//--set vcomh
LCD_WrCmd(0x40);//Set VCOM Deselect Level
LCD_WrCmd(0x20);//-Set Page Addressing Mode (0x00/0x01/0x02)
LCD_WrCmd(0x02);//
LCD_WrCmd(0x8d);//--set Charge Pump enable/disable
LCD_WrCmd(0x14);//--set(0x10) disable
LCD_WrCmd(0xa4);// Disable Entire Display On (0xa4/0xa5)
LCD_WrCmd(0xa6);// Disable Inverse Display On (0xa6/a7)
LCD_WrCmd(0xaf);//--turn on oled panel
LCD_Fill(0x00); //初始成黑屏
LCD_Set_Pos(0,0);
}
/***************功能描述:显示6*8一组标准ASCII字符串 显示的坐标(x,y),y为页范围0~7****************/
void LCD_P6x8Str(unsigned char x, unsigned char y,unsigned char ch[])
{
unsigned char 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);
if(c > 0 && c < 92)
{
for(i=0;i<6;i++)
LCD_WrDat(F6x8[c][i]);
}
x+=6;
j++;
}
}
/***********功能描述:显示一行ascii 码?无显示的点阵显示黑色, y为页的范围0~7*****************/
void HalLcd_HW_WriteLine(unsigned char line, const char *pText)
{
LCD_FillLine(line-1, 0); //先把这一行显示成黑色
LCD_P6x8Str(0, line-1, (unsigned char *)pText);
}
#ifdef LCD_SUPPORT
/*******************功能描述:显示8*16一组标准ASCII字符串 显示的坐标(x,y),y为页范围0~7****************/
void LCD_P8x16Str(unsigned char x, unsigned char y,unsigned char ch[])
{
unsigned char 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++;
}
}
/*****************功能描述:显示16*16点阵 显示的坐标(x,y),y为页范围0~7****************************/
void LCD_P16x16Ch(unsigned char x, unsigned char y, unsigned char N)
{
unsigned char wm=0;
unsigned int adder=32*N; //
LCD_Set_Pos(x , y);
for(wm = 0;wm < 16;wm++) //
{
LCD_WrDat(F16x16[adder]);
adder += 1;
}
LCD_Set_Pos(x,y + 1);
for(wm = 0;wm < 16;wm++) //
{
LCD_WrDat(F16x16[adder]);
adder += 1;
}
}
/***********功能描述:显示显示BMP图片128×64起始点坐标(x,y),x的范围0~127,y为页的范围0~7*****************/
void Draw_BMP(unsigned char x0, unsigned char y0,unsigned char x1, unsigned char y1,unsigned char BMP[])
{
unsigned int j=0;
unsigned char 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[j++]);
}
}
}
#endif
/**************************************************************************************************
z-stack代码,未修改
**************************************************************************************************/
void HalLcdInit(void)
{
#if (HAL_LCD == TRUE)
HalLcd_HW_Init();
#endif
}
/*************************************************************************************************
* LCD EMULATION FUNCTIONS
*
* Some evaluation boards are equipped with Liquid Crystal Displays
* (LCD) which may be used to display diagnostic information. These
* functions provide LCD emulation, sending the diagnostic strings
* to Z-Tool via the RS232 serial port. These functions are enabled
* when the "LCD_SUPPORTED" compiler flag is placed in the makefile.
*
* Most applications update both lines (1 and 2) of the LCD whenever
* text is posted to the device. This emulator assumes that line 1 is
* updated first (saved locally) and the formatting and send operation
* is triggered by receipt of line 2. Nothing will be transmitted if
* only line 1 is updated.
*
*************************************************************************************************/
/**************************************************************************************************
z-stack代码,未修改
**************************************************************************************************/
void HalLcdWriteString ( char *str, uint8 option)
{
#ifdef LCD_TO_UART
NPI_WriteTransport ( (uint8*)str,osal_strlen(str));
NPI_WriteTransport ("\r\n",2);
#endif
#if (HAL_LCD == TRUE)
uint8 strLen = 0;
uint8 totalLen = 0;
uint8 *buf;
uint8 tmpLen;
if ( Lcd_Line1 == NULL )
{
Lcd_Line1 = osal_mem_alloc( HAL_LCD_MAX_CHARS+1 );
HalLcdWriteString( "TexasInstruments", 1 );
}
strLen = (uint8)osal_strlen( (char*)str );
/* Check boundries */
if ( strLen > HAL_LCD_MAX_CHARS )
strLen = HAL_LCD_MAX_CHARS;
if ( option == HAL_LCD_LINE_1 )
{
/* Line 1 gets saved for later */
osal_memcpy( Lcd_Line1, str, strLen );
Lcd_Line1[strLen] = '\0';
}
else
{
/* Line 2 triggers action */
tmpLen = (uint8)osal_strlen( (char*)Lcd_Line1 );
totalLen = tmpLen + 1 + strLen + 1;
buf = osal_mem_alloc( totalLen );
if ( buf != NULL )
{
/* Concatenate strings */
osal_memcpy( buf, Lcd_Line1, tmpLen );
buf[tmpLen++] = ' ';
osal_memcpy( &buf[tmpLen], str, strLen );
buf[tmpLen+strLen] = '\0';
/* Send it out */
#if defined (ZTOOL_P1) || defined (ZTOOL_P2)
#if defined(SERIAL_DEBUG_SUPPORTED)
debug_str( (uint8*)buf );
#endif //LCD_SUPPORTED
#endif //ZTOOL_P1
/* Free mem */
osal_mem_free( buf );
}
}
/* Display the string */
HalLcd_HW_WriteLine (option, str);
#endif //HAL_LCD
}
/**************************************************************************************************
* @fn HalLcdWriteValue
*
* @brief Write a value to the LCD,
向lcd指定行写入一个32位的值
*
* @param value - value that will be displayed,
需要显示的32位数
* radix - 8, 10, 16,
进制,8进制显示 10进制显示,16进制显示
* option - display options,
指定行显示
*
* @return None
**************************************************************************************************/
void HalLcdWriteValue ( uint32 value, const uint8 radix, uint8 option)
{
#if (HAL_LCD == TRUE)
uint8 buf[LCD_MAX_BUF];
_ltoa( value, &buf[0], radix );
HalLcdWriteString( (char*)buf, option );
#endif
}
/**************************************************************************************************
z-stack代码,未修改
**************************************************************************************************/
void HalLcdWriteScreen( char *line1, char *line2 )
{
#if (HAL_LCD == TRUE)
HalLcdWriteString( line1, 1 );
HalLcdWriteString( line2, 2 );
#endif
}
/**************************************************************************************************
z-stack代码,未修改
**************************************************************************************************/
void HalLcdWriteStringValue( char *title, uint16 value, uint8 format, uint8 line )
{
#if (HAL_LCD == TRUE)
uint8 tmpLen;
uint8 buf[LCD_MAX_BUF];
uint32 err;
tmpLen = (uint8)osal_strlen( (char*)title );
osal_memcpy( buf, title, tmpLen );
buf[tmpLen] = ' ';
err = (uint32)(value);
_ltoa( err, &buf[tmpLen+1], format );
HalLcdWriteString( (char*)buf, line );
#endif
}
/**************************************************************************************************
z-stack代码,未修改
**************************************************************************************************/
void HalLcdWriteStringValueValue( char *title, uint16 value1, uint8 format1,
uint16 value2, uint8 format2, uint8 line )
{
#if (HAL_LCD == TRUE)
uint8 tmpLen;
uint8 buf[LCD_MAX_BUF];
uint32 err;
tmpLen = (uint8)osal_strlen( (char*)title );
if ( tmpLen )
{
osal_memcpy( buf, title, tmpLen );
buf[tmpLen++] = ' ';
}
err = (uint32)(value1);
_ltoa( err, &buf[tmpLen], format1 );
tmpLen = (uint8)osal_strlen( (char*)buf );
buf[tmpLen++] = ',';
buf[tmpLen++] = ' ';
err = (uint32)(value2);
_ltoa( err, &buf[tmpLen], format2 );
HalLcdWriteString( (char *)buf, line );
#endif
}
/**************************************************************************************************
z-stack代码,未修改
**************************************************************************************************/
void HalLcdDisplayPercentBar( char *title, uint8 value )
{
#if (HAL_LCD == TRUE)
uint8 percent;
uint8 leftOver;
uint8 buf[17];
uint32 err;
uint8 x;
/* Write the title: */
HalLcdWriteString( title, HAL_LCD_LINE_1 );
if ( value > 100 )
value = 100;
/* convert to blocks */
percent = (uint8)(value / 10);
leftOver = (uint8)(value % 10);
/* Make window */
osal_memcpy( buf, "[ ] ", 15 );
for ( x = 0; x < percent; x ++ )
{
buf[1+x] = '>';
}
if ( leftOver >= 5 )
buf[1+x] = '+';
err = (uint32)value;
_ltoa( err, (uint8*)&buf[13], 10 );
HalLcdWriteString( (char*)buf, HAL_LCD_LINE_2 );
#endif
}
/*int 转 字符串函数*/
/*
unsigned char* IntToStr(unsigned char* buf, int m)
{
unsigned char tmp[16];
unsigned long isNegtive = 0;
unsigned long index;
if(m < 0)
{
isNegtive = 1;
m = - m;
}
tmp[15] = '\0';
index = 14;
do
{
tmp[index--] = m % 10 + '0';
m /= 10;
} while (m > 0);
if(isNegtive)
tmp[index--] = '-';
strcpy((char *)buf, (char *)(tmp + index + 1));
return buf;
}
*/
#ifdef LCD_SUPPORT
int main()
{
unsigned char i=0;
HalLcd_HW_Init(); //oled 初始化
LCD_Fill(0xff); //屏全亮
while(1)
{
for(i=0; i<8; i++)
{
LCD_P16x16Ch(i*16,0,i); //点阵显示
LCD_P16x16Ch(i*16,2,i+8);
LCD_P16x16Ch(i*16,4,i+16);
LCD_P16x16Ch(i*16,6,i+24);
}
HalHW_WaitMS(1000);
LCD_CLS();
LCD_P8x16Str(44,0,"saler");
LCD_P8x16Str(20,2,"OLED DISPLAY");
LCD_P8x16Str(8,4,"TEL:18144070918");
LCD_P6x8Str(20,6,"2357481431@qq.com");
LCD_P6x8Str(20,7,"2016-10-6 18:18");
HalHW_WaitMS(1000);
//LCD_CLS();
//Draw_BMP(0,0,128,8,BMP); //图片显示
//DelayMS(1000);
}
}
#endif
添加宏定义LCD_TO_UART ,可以使得lcd输出的内容打印到串口
未完待续