//============================================================================= //函 数 名: Display_Number() //功 能: 显示带符号的整数 //入口参数: v:显示的数据 x:X轴坐标 y:Y轴坐标 Len:长度1--5 //出口参数: 无 //返 回 值: 无 //说明 :处理长度最多5个数字(因为INT16U--->32768) // XY 均是起点位置坐标 也就是数值最高位的坐标 //============================================================================= void Display_SignedNumber(int Number,INT8U X,INT16U Y,INT8U Lenth) { if(Number < 0) { GUI_DispChar('-', X, Y); Display_Number(-Number, X+8, Y, Lenth); } else { GUI_DispChar(' ', X, Y); Display_Number(Number, X+8, Y, Lenth); } }
int main(void) { SystemInit(); // Setting System Clocks SysTick_Config(SystemCoreClock/1000000); // Setting Systick to Micro Seconds HC595_GPIO_Configure(); HC595_SPI_Configure(); uint32_t i; for(i=0;i<99999999;i++) { Display_Number(i); Delay(10000); } }
//----------------------------------------------------------------- int main(void) { int del =5; iolib_init(); printf("init finish\n"); /* BBBIO_GPIO_set_dir(BBBIO_GPIO1 , 0 , BBBIO_GPIO_PIN_12 | BBBIO_GPIO_PIN_13 | BBBIO_GPIO_PIN_14 | BBBIO_GPIO_PIN_15 ); */ BBBIO_sys_Enable_GPIO(BBBIO_GPIO2); iolib_setdir(8,11, BBBIO_DIR_OUT); // Scan A iolib_setdir(8,12, BBBIO_DIR_OUT); // Scan B iolib_setdir(8,15, BBBIO_DIR_OUT); // Scan C iolib_setdir(8,16, BBBIO_DIR_OUT); // Scan D iolib_setdir(8,39, BBBIO_DIR_OUT); // Seg A iolib_setdir(8,40, BBBIO_DIR_OUT); // Seg B iolib_setdir(8,41, BBBIO_DIR_OUT); // Seg C iolib_setdir(8,42, BBBIO_DIR_OUT); // Seg D iolib_setdir(8,43, BBBIO_DIR_OUT); // Seg E iolib_setdir(8,44, BBBIO_DIR_OUT); // Seg F iolib_setdir(8,45, BBBIO_DIR_OUT); // Seg G iolib_setdir(8,46, BBBIO_DIR_OUT); // Seg . (point) printf("OK"); int count = 0; int DisplayNumber =1234 ; while(count < 200) { count ++ ; pin_low(8,11); Display_Number(DisplayNumber / 1000); iolib_delay_ms(del); pin_high(8,11); pin_low(8,12); Display_Number(DisplayNumber / 100); iolib_delay_ms(del); pin_high(8,12); pin_low(8,15); Display_Number(DisplayNumber / 10); iolib_delay_ms(del); pin_high(8,15); pin_low(8,16); Display_Number(DisplayNumber); iolib_delay_ms(del); pin_high(8,16); } BBBIO_sys_Disable_GPIO(BBBIO_GPIO2); iolib_free(); return(0); }