/* check status */ void check_status(void) { if (GPIOA->IDR & GPIO_Pin_1) { GPIOD->ODR &= ~GPIO_Pin_15; status = 0; LCD_String("BT", 22, 6, 1, BLACK, GLASSY); } else { GPIOD->ODR |= GPIO_Pin_15; status = 1; LCD_String("BT", 22, 6, 1, BLUE, GLASSY); } }
/*输出成绩*/ void PrScore(void) { char str[10]; LCD_Fill(25,3,110,21,LCD_COLOR_YELLOW); sprintf(str,"score:%d",score); LCD_String(27,4,str,LCD_COLOR_BLACK); }
/*游戏结束*/ void GameOver(void) { PrScore(); //setcolor(RED); //settextstyle(0,0,4); LCD_String(100,100,"游戏结束,按任意键继续",LCD_COLOR_RED); WaitForKey(); }
void JPEG_encode(void)//编码主函数 { u8 res; u16 i,j,color; res=f_mount(0, &fatfs); while(res)LCD_String(20,20,"SD mount failed!",RED); res=f_open(&fileW,"0:/DCMI/ph1.jpg",FA_WRITE|FA_CREATE_ALWAYS);//创建并打开 while(res)LCD_String(20,20,"file create failed!",RED); cinfo=jpeg_create_compress();//创建JPEG压缩文件 cinfo->image_width=240; cinfo->image_height=320; cinfo->output=0;//数据输出到NULL; jpeg_set_default(cinfo);//设置默认参数 jpeg_start_compress(cinfo);//开始压缩,写压缩文件头信息 j=0; while(cinfo->next_line<cinfo->image_height) { for(i=0;i<240;i++)//读取一行 { LCD_Cursor(i,cinfo->next_line); if((lcdid&0xff00)==0x9300)color=BGR565toRGB565(LCD_ReadRAM()); else color=LCD_ReadRAM(); cinfo->inbuf[j++]=(u8)((color&0xf800)>>8); cinfo->inbuf[j++]=(u8)((color&0x07e0)>>3); cinfo->inbuf[j++]=(u8)((color&0x001f)<<3); } cinfo->next_line++; //当数据填满时压缩并输出数据(填满16行) if(cinfo->next_line%cinfo->inbuf_height==0) { j=0; jint_process_rows(cinfo);//在这里压缩 memset((void*)(cinfo->inbuf),0,cinfo->inbuf_size);//清空输入缓冲区 } } jpeg_finish_compress(cinfo); f_close(&fileW); LEDOn(LED4); while(1); }
int main (void) { PORTB = 0x00; DDRB = 0xFF; LCD_Init(); LCD_Box(0,0,131,131,FILL,WHITE); LCD_Box(3,3,128,128,NOFILL,BLUE); LCD_Circle(65,100,10,GREEN); LCD_Circle(65,110,10,RED); LCD_String("===============", 22, 6, BLACK, WHITE); LCD_String(" POZDRAWIAM ", 42, 6, GREEN, WHITE); LCD_String("forum.atnel.pl", 52, 6, BLUE, WHITE); LCD_String(" SunRiver ", 72, 6, PINK, WHITE); LCD_String("===============", 82, 6, BLACK, WHITE); }
int main(void) { uint8_t i, j; SysTick_Config(SystemCoreClock/1000); //1ms tick RCC_Init(); USARTInit(); LCD_Init(); LED_Init(); LED_On(); LCD_Clear(); //LCD_char(0, 0, 0); LCD_String("abcdefg",0,0); LCD_String("6543210",0,3); while(1){ delay_ms(100); printf("done!\n\r"); LED_Toogle(); } }
/*! * @brief Udskriver tekst på Nokia 5110 LCD * @details Metoden bruges til at skrive en ny linje nederst på Nokia 5110 LCD skærmen, den husker på- og flytter de forhenværende linjer en linje op, når der indættes en ny. * @public * @memberof LCD * @author Jeppe Stærk ([email protected]) */ void lcd_newline(char* characters) { int i; for(i = 0; i < 5; i++) { strncpy(lineStr[i],lineStr[i+1],12); } strcpy(lineStr[5], characters); LCD_Clear(); for(i = 0; i < 6; i++) { LCD_gotoXY(0,i); LCD_String(lineStr[i]); } }
int main(void) { TIME_Init(); FVM_Init(); LCD_Init(); LCD_SelectBuffer(LCD_Screen); LCD_SetDrawMode(0,1); LCD_SetFont((unsigned char *)Font_Ascii_Medium); //LCD_String(0,1,"the quick brown fox jumps over the lazy dog"); LCD_String(0,1,"THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG"); LCD_LowLevelRefresh(0); UI_DrawBottomMenu(&MainMenu); while(1) { } }
/* main work function */ void work(void) { unsigned short i, j; unsigned char mailbox_num = 0; volatile ProtoIOMBox * mbox; /* setup status */ status_setup(); /* setup serial console */ usart1_setup(); /* setup proto */ proto_setup(); mbox = proto_srv_dat.mailboxes[mailbox_num]; /* setup button */ buttons_setup(); /* lcd setup */ LCD_Setup(); LCD_Clear(BLACK); for (i = 0; i < 10; i++) { for (j = 0; j < 10; j++) { LCD_Pixel(j + 10, i + 10, test.data[i * 10 + j]); } } LCD_Window(0, 0, 9, 9); LCD_RS_LOW; LCD_SELECT; for (i = 0; i < 100; i++) { LCD_Send(test.data[i] >> 8); LCD_Send(test.data[i] & 0x00ff); } LCD_Cursor(0, 0); LCD_DESEL; /* check status */ check_status(); /* send ping */ mbox->outbox->header = 'C'; /* Command */ mbox->outbox->size = 0x00; /* 0 for ping request */ mbox->outbox_s = PROTO_IO_MBOX_READY; /* Box ready */ mbox->inbox->size = 64; /* buffer len for control */ mbox->inbox_s = PROTO_IO_MBOX_READY; /* Box ready */ /* wait connection estabilished */ while (status == 0); /* send ping message */ proto_send_msg(mailbox_num); /* wait to send message */ while (mbox->outbox_s <= PROTO_IO_MBOX_SEND); if (mbox->outbox_s == PROTO_IO_MBOX_COMPLETE) LCD_String("Con", 36, 6, 1, WHITE, GLASSY); else LCD_String("Un", 36, 6, 1, RED, GLASSY); /* get ping message */ /* FIXME wtf? this not work or work parity */ //proto_get_msg(mailbox_num); /* wait to get message */ while (mbox->inbox_s <= PROTO_IO_MBOX_SEND); if (mbox->inbox_s == PROTO_IO_MBOX_COMPLETE) { LCD_String("OK", 36 + 3 * 7, 6, 1, GREEN, GLASSY); for (i = 0; i < mbox->inbox->size; i++) LCD_Char(mbox->inbox->message[i], 70 + i * 6, 6, 1, WHITE, GLASSY); } else LCD_String("ERR", 36 + 3 * 7, 6, 1, RED, GLASSY); /* infinity loop */ while (1) { if (button_state.state[B_LGHT] == B_CLICK) { sender('+'); button_state.state[B_LGHT] = B_RELEASE; } if (button_state.state[B_MOD] == B_CLICK) { sender('m'); button_state.state[B_MOD] = B_RELEASE; } if (button_state.state[B_SET] == B_CLICK) { sender('-'); button_state.state[B_SET] = B_RELEASE; } if (button_state.state[B_UP] == B_CLICK) { sender('<'); button_state.state[B_UP] = B_RELEASE; } if (button_state.state[B_SU] == B_CLICK) { sender('p'); button_state.state[B_SU] = B_RELEASE; } if (button_state.state[B_DWN] == B_CLICK) { sender('>'); button_state.state[B_DWN] = B_RELEASE; } } }
void Nokia_lcd::cLCD_String(char *pString, unsigned char x, unsigned char y, int fColor, int bColor) { LCD_String(pString, y,x, fColor, bColor); }
int main() { NODE *n = NULL; NODE *p; NODE r; // STACK *j; r.depth = 0; p = &r; InitPeripherals(); Delay(1); LED_OFF(); /*while(1) { if(!S6 && !S7 && !S8) { forward(); } if(S6 && !S7 && !S8) { right(); } if(!S6 && !S7 && S8) { left(); } if(S6 && S7 && !S8) { right(); } if(!S6 && S7 && S8) { left(); } if(S6 && S7 && S8) { stop(); } }*/ LCD_Command(0x80); LCD_String(" Welcome. "); LCD_Command(0xC0); LCD_String(" "); Delay(100); LCD_Command(0x80); LCD_String(" SW1=QR SW2=FR "); LCD_Command(0xC0); LCD_String(" SW3=SC SW4=MC "); while(SW1 || SW2 || SW3 || SW4) { if(!SW1) { LCD_Command(0x80); LCD_String(" TRAVERSING "); LCD_Command(0xC0); LCD_String(" "); start = createTree(n, p); } if(!SW2) { LCD_Command(0x80); LCD_String(" TRAVERSING "); LCD_Command(0xC0); LCD_String(" FINDING CENTER "); traverse(); } if(!SW3) { while(1) { LCD_Command(0x80); LCD_String(" "); if(S1) LCD_String("1"); else LCD_String("0"); LCD_String(" "); if(S2) LCD_String("11"); else LCD_String("00"); LCD_String(" "); if(S3) LCD_String("1"); else LCD_String("0"); LCD_Command(0xC0); if(S4) LCD_String("1"); else LCD_String("0"); LCD_String(" "); if(S5) LCD_String("1"); else LCD_String("0"); LCD_String(" "); if(S6) LCD_String("11"); else LCD_String("00"); LCD_String(" "); if(S7) LCD_String("11"); else LCD_String("00"); LCD_String(" "); if(S8) LCD_String("11"); else LCD_String("00"); LCD_String(" "); if(S9) LCD_String("1"); else LCD_String("0"); LCD_String(" "); if(S10) LCD_String("1"); else LCD_String("0"); } } if(!SW4) { LCD_Command(0x80); LCD_String(" MOTOR. "); LCD_Command(0xC0); LCD_String(" CHECK. "); Delay(100); LCD_Command(0x80); LCD_String(" FORWARD. "); LCD_Command(0xC0); LCD_String(" "); forward(); Delay(200); LCD_Command(0x80); LCD_String(" LEFT "); LCD_Command(0xC0); LCD_String(" "); left(); Delay(200); LCD_Command(0x80); LCD_String(" RIGHT. "); LCD_Command(0xC0); LCD_String(" "); right(); Delay(200); LCD_Command(0x80); LCD_String(" REVERSE. "); LCD_Command(0xC0); LCD_String(" "); reverse(); Delay(200); LCD_Command(0x80); LCD_String(" STOPPED. "); LCD_Command(0xC0); LCD_String(" "); stop(); } } }