📄 main.c
字号:
//ICC-AVR application builder : 2007-11-19 15:57:27
// Target : M128
// Crystal: 4.0000Mhz
#include <iom128v.h>
#include <macros.h>
#include "stdtypes.h"
#include "timer.h"
#include "key.h"
#include "port.h"
#include "lcd.h"
#include "menu.h"
#define INT8U unsigned char
extern UNS8 key_num;
float para;
void delay_ms(unsigned int time);
void delay_us(int time);
unsigned char key_function(void);
void testfloat(int i,int j,float test)//用此程序显示8数组
{
//定义一个浮点数变量
char temp[8]; //定义此数组,用于存放格式化输出字符串
int k;
for(k = 0; k < 8; k++)
{
temp[k]=' ';
}
sprintf((char *)&temp,"%4.2f",test); //格式化输出转换,输出宽度4,精度0.01
//strcat(temp,"\r\n"); //加回车换行符
LCD_write_string(i, j,temp);
// UsartSend1(temp, strlen(temp)); //通过串口一发送出去
}
//call this routine to initialize all peripherals
void init_devices(void)
{
//stop errant interrupts until set up
CLI(); //disable all interrupts
XDIV = 0x00; //xtal divider
XMCRA = 0x00; //external memory
port_init();
MCUCR = 0x00;
EICRA = 0x00; //extended ext ints
EICRB = 0x00; //extended ext ints
EIMSK = 0x00;
TIMSK = 0x01; //timer interrupt sources
ETIMSK = 0x00; //extended timer interrupt sources
SEI(); //re-enable interrupts
//all peripherals are now initialized
}
//
void main(void)
{
char row1[16];
UNS8 i,j=1;
init_devices();
LCD_init();
timer0_init();
MCUCR = 0x00;//IO
g_ReceiveKeyFlag=0;
g_KeyValue=0;
key_function();
SEI(); //re-enable interrupts
//all peripherals are now initialized
while(1)
{
}
}
/* 微秒级延时程序 */
void delay_us(int time)
{
do
{
time--;
}
while (time>1);
}
/* 毫秒级延时程序 */
void delay_ms(unsigned int time)
{
while(time!=0)
{
delay_us(1000);
time--;
}
}
/*菜单功能函数,使用键盘实现显示、测量、设置、保存、上、下功能*/
unsigned char key_function(void)
{
//unsigned char i;
KeyProcess();
switch (key_num) {
//调用菜单功能函数
case '1': display_lcd (); //display
case '2': set_up (); //set up
case '3': para_up (para); //para up
case '5': para_down (para); //measure
case '6': measure (); //save
case '7': save (); //down
default : main_menu ();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -