⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 butterflylogger_src_20060822 for atmel avr
💻 C
📖 第 1 页 / 共 3 页
字号:
    else if (input == KEY_PREV)    {        enter = 1;        return ST_OPTIONS_BOOT;    }        return ST_OPTIONS_BOOT_FUNC;}/*******************************************************************************   Function name : PowerSaveFunc**   Returns :       char ST_state (to the state-machine)**   Parameters :    char input (from joystick)**   Purpose :       Enable power save******************************************************************************/// mt __flash char TEXT_POWER[]                     = "Press enter to sleep";// mt jw const char TEXT_POWER[]  PROGMEM  = "Press enter to sleep";char PowerSaveFunc(char input){    static char enter = 1;            if(enter)    {        enter = 0;        //mt jw LCD_puts_f(TEXT_POWER, 1);		LCD_puts_f(PSTR("Press enter to sleep"), 1);    }    else if(input == KEY_ENTER)    {        gPowerSave = TRUE;        enter = 1;        return ST_AVRBF;    }    else if (input == KEY_PREV)    {        enter = 1;        return ST_OPTIONS_POWER_SAVE;    }	    return ST_OPTIONS_POWER_SAVE_FUNC;	}/*******************************************************************************   Function name : AutoPower**   Returns :       char ST_state (to the state-machine)**   Parameters :    char input (from joystick)**   Purpose :       Enable/Disable auto power save******************************************************************************/char AutoPower(char input){    static char enter = 1;            char PH;    char PL;        if(enter)    {        enter = 0;                if(gAutoPowerSave)          {                 PH = CHAR2BCD2(gPowerSaveTimeout);            PL = (PH & 0x0F) + '0';            PH = (PH >> 4) + '0';			            LCD_putc(0, 'M');            LCD_putc(1, 'I');            LCD_putc(2, 'N');            LCD_putc(3, ' ');            LCD_putc(4, PH);            LCD_putc(5, PL);            LCD_putc(6, '\0');			            LCD_UpdateRequired(TRUE, 0);            }        else            LCD_puts_f(PSTR("Off"),1);	// mt LCD_puts("Off", 1);        		    }    else if(input == KEY_ENTER)    {		enter = 1;				return ST_OPTIONS_AUTO_POWER_SAVE;    }    else if (input == KEY_PLUS)    {		        gPowerSaveTimeout += 5;		        if(gPowerSaveTimeout > 90)        {            gPowerSaveTimeout = 90;        }        else        {                gAutoPowerSave = TRUE;			            PH = CHAR2BCD2(gPowerSaveTimeout);            PL = (PH & 0x0F) + '0';            PH = (PH >> 4) + '0';			            LCD_putc(0, 'M');            LCD_putc(1, 'I');            LCD_putc(2, 'N');            LCD_putc(3, ' ');            LCD_putc(4, PH);            LCD_putc(5, PL);            LCD_putc(6, '\0');			            LCD_UpdateRequired(TRUE, 0);                }    }    else if (input == KEY_MINUS)    {        if(gPowerSaveTimeout)            gPowerSaveTimeout -= 5;		        if(gPowerSaveTimeout < 5)        {            gAutoPowerSave = FALSE;            gPowerSaveTimeout = 0;            LCD_puts_f(PSTR("Off"),1);	// mt LCD_puts("Off", 1);        }        else        {               gAutoPowerSave = TRUE;			            PH = CHAR2BCD2(gPowerSaveTimeout);            PL = (PH & 0x0F) + '0';            PH = (PH >> 4) + '0';                        LCD_putc(0, 'M');            LCD_putc(1, 'I');            LCD_putc(2, 'N');            LCD_putc(3, ' ');            LCD_putc(4, PH);            LCD_putc(5, PL);            LCD_putc(6, '\0');			            LCD_UpdateRequired(TRUE, 0);                             }    }	    return ST_OPTIONS_AUTO_POWER_SAVE_FUNC;    	}/*******************************************************************************   Function name : LogTiming**   Returns :       char ST_state (to the state-machine)**   Parameters :    char input (from joystick)**   Purpose :       Enable/Disable RS232 Logging******************************************************************************/char LogTiming(char input){    static char enter = 1;    	static char logging,logtime,logunit;        if(enter)    {        enter = 0;        		// get local copy of global variables.		logging=gLogging;		logtime=gLogTime;		logunit=gLogTimeUnit;		        if(logging)          {   			PrintLogTime( logtime,  logunit); 		}        else            LCD_puts("Off", 1);                    }    else if(input == KEY_ENTER)    {		enter = 1;				//save changes and exit		gLogging = logging;				gLogTime = logtime;		gLogTimeUnit= logunit ;				return ST_OPTIONS_LOGTIME;    }    else if (input == KEY_PLUS)    {		        logtime += 1;		        if(logtime > 90)        {            logtime = 90;        }        else        {                logging = TRUE;						PrintLogTime( logtime,  logunit);                 }    }    else if (input == KEY_MINUS)    {        if(logtime)            logtime -= 1;		        if(logtime <1 )        {            logging = FALSE;            logtime = 0;            LCD_puts("Off", 1);        }        else        {               logging = TRUE;						PrintLogTime( logtime,  logunit);                             }    }	else if (input == KEY_NEXT)	{		logunit--;		if (logunit > TICK)			logunit = HOUR;		if(logging)        {			PrintLogTime( logtime,  logunit);         }        else        {   			LCD_puts("Off", 1);        }    }	else if (input == KEY_PREV)	{		logunit++;		if (logunit > TICK)			logunit = TICK;		if(logging)        {			PrintLogTime( logtime,  logunit);         }        else        {   			LCD_puts("Off", 1);        }	}    return ST_OPTIONS_LOGTIME_FUNC;    }/*******************************************************************************   Function name : PrintLogTime**   Returns :       None**   Parameters :    char logtime, char logunit: the unit and time between logs.**   Purpose :       Print a time to the LCD******************************************************************************/void PrintLogTime(char logtime, char logunit){    char PH;    char PL;		PH = CHAR2BCD2(logtime);	PL = (PH & 0x0F) + '0';	PH = (PH >> 4) + '0';		if (logunit==HOUR)	{		LCD_putc(0, 'H');		LCD_putc(1, 'R');		LCD_putc(2, 'S');	}else if (logunit==MINUTE)	{		LCD_putc(0, 'M');		LCD_putc(1, 'I');		LCD_putc(2, 'N');	}else if (logunit==SECOND)	{		LCD_putc(0, 'S');		LCD_putc(1, 'E');		LCD_putc(2, 'C');	}else if (logunit==TICK)	{		LCD_putc(0, 'T');		LCD_putc(1, 'C');		LCD_putc(2, 'K');	}			LCD_putc(3, ' ');	LCD_putc(4, PH);	LCD_putc(5, PL);	LCD_putc(6, '\0');		LCD_UpdateRequired(TRUE, 0); }/*******************************************************************************   Function name : Delay**   Returns :       None**   Parameters :    unsigned int millisec**   Purpose :       Delay-loop (based on a 1Mhz Clock)******************************************************************************/void Delay(unsigned int millisec){    // mt, int i did not work in the simulator:  int i; 	uint8_t i;        while (millisec--)		//mt: for (i=0; i<125; i++);		for (i=0; i<125; i++)  			asm volatile ("nop"::);}/*******************************************************************************   Function name : Revision**   Returns :       None**   Parameters :    char input**   Purpose :       Display the software revision******************************************************************************/char Revision(char input){	static char enter = 1;	//char TH;	//char TL;     	//char HB;	//int Temp;	    if(enter == 1)    {        enter = 0;        		// mtA         LCD_putc(0, 'R'); // LCD_putc(0, 'R');        LCD_putc(1, 'E'); // LCD_putc(1, 'E');        LCD_putc(2, 'V'); // LCD_putc(2, 'V');						  // LCD_putc(3, ' ');        LCD_putc(3, (SWHIGH + 0x30)); // LCD_putc(4, (SWHIGH + 0x30));       //SWHIGH/LOW are defined in "main.h"        LCD_putc(4, (SWLOW + 0x30)); // LCD_putc(5, (SWLOW + 0x30));		LCD_putc(5, (SWREV + 0x40)); // LCD_putc(5, (SWLOW + 0x30));        LCD_putc(6, '\0');		// mtE                LCD_UpdateRequired(TRUE, 0);              }    else if (input == KEY_PREV)    {        enter = 1;        return ST_AVRBF;    }	    return ST_AVRBF_REV;}/*******************************************************************************   Function name : UploadFunc**   Returns :       None**   Parameters :    char input**   Purpose :       Send data to RS232******************************************************************************/         //__flash char TEXT_UPLOAD[]                     = "Press enter to send data"  ;char UploadFunc(char input){	static char enter = 1;		if(enter == 1)	{		enter = 0;		LCD_puts_f(PSTR("Press enter to send data"),1);		//	LCD_UpdateRequired(TRUE, 0);       	}	else if (input == KEY_PREV)	{		enter = 1;		return ST_OPTIONS_UPLOAD;	}	else if (input == KEY_ENTER)    	{		// send current data		DumpFlash(DUMP_NORMAL);		enter=1;			}	else if (input == KEY_PLUS)    	{		// send ALL the data		DumpFlash(DUMP_ALL);		enter=1;			}	else if (input == KEY_MINUS)    	{		// send ALL the data

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -