xtest18_7.c

来自「AT91sam7s 256 B/D example」· C语言 代码 · 共 42 行

C
42
字号
/* ========================================================================== */
/*	   Xtest18_7.c : User-defined printf() Function for Text LCD	      */
/* ========================================================================== */
/*			  Designed and programmed by Duck-Yong Yoon in 2007.  */

#include <stdio.h>
#include "AT91SAM7S256.h"
#include "lib_AT91SAM7S256.h"
#include "OK7S256ads.h"

int fputc(int ch, FILE *f)			// for the user-defined printf()
{
  if((ch >= 0x20) && (ch <= 0x7E))		// check from 0x20 to 0x7E
    LCD_data(ch);

  return ch;
}

int main(void)
{ unsigned int i;
  double x;

  MCU_initialize();				// initialize AT91SAM7S256 & kit
  Delay_ms(50);					// wait for system stabilization
  LCD_initialize();				// initialize text LCD
  Beep();

  LCD_string(0x80,"Integer  =   000");		// display title
  LCD_string(0xC0,"Floating = 0.000");

  while(1)
    { for(i=1, x=0.001; i <= 200; i++, x += 0.001) // loop by 200 times
        { LCD_command(0x8D);
          printf("%3d\n", i);
          LCD_command(0xCB);
          printf("%5.3f\n", x);
          Delay_ms(500);
        }
      Beep();
    }
}

⌨️ 快捷键说明

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