/* * Task of polling buttons. */ void poll_buttons (void *data) { unsigned char pagenum = 0; unsigned char up_pressed = 0, left_pressed = 0; unsigned char center_pressed = 0, right_pressed = 0; unsigned char down_pressed = 0; printf (&line1, "Testing LCD."); printf (&line2, "Use buttons."); for (;;) { timer_delay (&timer, 10); int key = button_get(); if (key != BUTTON_UP) up_pressed = 0; else if (! up_pressed) { up_pressed = 1; /* Up button: clear screen. */ lcd_clear_all (&line1, &line2); printf (&line1, "Cleared."); } if (key != BUTTON_LEFT) left_pressed = 0; else if (! left_pressed) { left_pressed = 1; /* Left button: show previous page of symbols. */ display_page (--pagenum); } if (key != BUTTON_SELECT) center_pressed = 0; else if (! center_pressed) { center_pressed = 1; /* Center button: show current page of symbols. */ display_page (pagenum); } if (key != BUTTON_RIGHT) right_pressed = 0; else if (! right_pressed) { right_pressed = 1; /* Right button: show next page of symbols. */ display_page (++pagenum); } if (key != BUTTON_DOWN) down_pressed = 0; else if (! down_pressed) { down_pressed = 1; /* Down button: scroll long message. */ printf (&line2, message1); } } }
/* * Task of polling buttons. */ void poll_buttons (void *data) { unsigned char pagenum = 0; unsigned char b1_pressed = 0, b2_pressed = 0; unsigned char b3_pressed = 0, b4_pressed = 0; printf (&line1, "Testing LCD."); printf (&line2, "Use buttons."); for (;;) { timer_delay (&timer, 10); if (! button1_pressed ()) b1_pressed = 0; else if (! b1_pressed) { b1_pressed = 1; /* Button 1: clear screen. */ lcd_clear_all (&line1, &line2); printf (&line1, "Cleared."); } if (! button2_pressed ()) b2_pressed = 0; else if (! b2_pressed) { b2_pressed = 1; /* Button 2: show previous page of symbols. */ display_page (--pagenum); } if (! button3_pressed ()) b3_pressed = 0; else if (! b3_pressed) { b3_pressed = 1; /* Button 3: show next page of symbols. */ display_page (++pagenum); } if (! button4_pressed ()) b4_pressed = 0; else if (! b4_pressed) { b4_pressed = 1; /* Button 4: scroll long message. */ printf (&line2, message1); timer_delay (&timer, 500); printf (&line2, message2); } } }
int pd_Calibration(void) { int xres, yres, ret; pdl_cal_t cal; struct lcd_s *lcd = lcd_get(NULL); lcd_get_res(lcd, &xres, &yres); printf("xres = %d, yres = %d\n", xres, yres); lcd_init(lcd); lcd_clear_all(lcd); get_sample(&cal, 0, 50, 50, "top left"); get_sample(&cal, 1, xres - 50, 50, "top right"); get_sample(&cal, 2, xres - 50, yres - 50, "bot right"); get_sample(&cal, 3, 50, yres - 50, "bot left"); get_sample(&cal, 4, xres >> 1, yres >> 1, "center"); pdl_cal(&cal, &pd_pdl); //visual verify calibration result ret = verify(xres, yres); if(!ret) nvm_save(); lcd_clear_all(lcd); return ret; }
void display_page (unsigned char n) { unsigned char i; lcd_clear_all (&line1, &line2); line1.raw = 1; line2.raw = 1; n <<= 5; for (i=0; i<8; ++i) putchar (&line1, n + i); if (n) for (i=8; i<16; ++i) putchar (&line1, n + i); for (i=16; i<32; ++i) putchar (&line2, n + i); line1.raw = 0; line2.raw = 0; }
void cal_task( void * data) { // initialize LCD lcd_clear_all(); lcd_init(); lcd_led_power(1); // draw splash screen lcd_text(32,10,3,"NFC",0); lcd_text(12,40,1,"ipTronix Arrow NXP",0); lcd_update(0,63); // initialize pll Si5351_Initialize(); // prepare new screen during splash wait lcd_clear_all(); lcd_vert_line(10,63,64); vTaskDelay(500); // application main loop for (;;) { int i; int max = 0; int maxval = 0; for (i=0;i<128;i++) { Si5351_OutputFrequency((9560000+i*8000000/128)*25/24); lcd_update(0,63); vTaskDelay(1); samples[i] = ADCRead(3); if (i!=64) lcd_clear_area(i,10,i,63); lcd_vert_line(63-samples[i]*51/1023,63,i); if (maxval<samples[i]) { maxval = samples[i]; max = i; } if (GPIOGetPinValue( PIN_ISP ) == 0) { lcd_clear_all(); lcd_text(52,26,2,"ISP",0); lcd_update(0,63); NVIC_SystemReset(); } if (GPIOGetPinValue( PIN_CAL_DET ) == 0) { NVIC_SystemReset(); } } char str[20]; float freq= 9.56+(float)max*8/128; sprintf(str,"fmax = %2d.%03d MHz",(int)freq,((int)(freq*1000))%1000); lcd_text(0, 0 , 0, str, 0); lcd_update(0,63); vTaskDelay(1500); lcd_clear_all(); lcd_vert_line(10,63,64); } }
void ui_task( void * data) { int i; portBASE_TYPE res; int count = 10; char acTempStr[20]; uint8_t acTemp[2]; uint8_t bMosfetEnabled = 0; // init LCD; lcd_clear_all(); lcd_init(); lcd_led_power(1); //lcd_test(0); lcd_text(32,10,3,"NFC",0); lcd_text(12,40,1,"ipTronix Arrow NXP",0); lcd_update(0,63); lcd_clear_all(); vTaskDelay(1500); lcd_clear_all(); for (;;) { KEY_EVENT_t key; char str[30]; lcd_text(12,10,1,"Please approach card",0); lcd_update(0,63); do { res = xQueueReceive(xUIQueue,&taginfo,/*portMAX_DELAY*/20); key=CAP_KEY_GetEvent(); count++; if ((count >= 3) && (res!= pdPASS)) { count = 0; I2CRead(0x90,0,&acTemp[0],2); sprintf(acTempStr,"Temperature %d",acTemp[0]); lcd_text(12,27,1,acTempStr,0); sprintf(acTempStr,"Keys %d",keystate); lcd_text(28,46,2,acTempStr,0); lcd_update(0,63); } if (bMosfetEnabled) { bMosfetEnabled = 0; GPIOSetBitValue(PIN_MOSFET,0); } else { bMosfetEnabled = 1; GPIOSetBitValue(PIN_MOSFET,1); } if (GPIOGetPinValue( PIN_ISP ) == 0) { lcd_clear_all(); lcd_text(52,26,2,"ISP",0); lcd_update(0,63); NVIC_SystemReset(); } if (GPIOGetPinValue( PIN_CAL_DET )) { NVIC_SystemReset(); } } while (res!= pdPASS) ; if (res == pdPASS) { lcd_clear_all(); sprintf(str, "UID "); for (i=0;i<taginfo.szUidLen;i++) { sprintf(&str[4+i*2],"%02X",taginfo.abtUid[i]); } lcd_text(0,0,1,str,0); sprintf(str,"NDEF Len %d",taginfo.msgLen); lcd_text(0,12,1,str,0); snprintf(str,30,"MSG %s",taginfo.msg); lcd_text(0,24,1,str,0); lcd_update(0,63); vTaskDelay(1500); lcd_clear_all(); count = 10; } lcd_update(0,63); } }
void ui_task( void * data) { portBASE_TYPE res; m_eMode = mdAUTHENTICATE; // init LCD; lcd_clear_all(); lcd_init(); lcd_led_power(1); //lcd_test(0); lcd_text(32,10,3,"NFC",0); lcd_text(12,40,1,"ipTronix Arrow NXP",0); lcd_update(0,63); lcd_clear_all(); vTaskDelay(1500); for (;;) { char str[30]; lcd_clear_all(); lcd_text(32,0,1,"Authentication",0); lcd_text(32,20,2,"Scan card",0); switch (m_eMode) { case mdAUTHENTICATE: lcd_text(10,40,2,"AUTHENTICATE",1); break; case mdAUTHORIZE: lcd_text(22,40,2,"AUTHORIZE",1); break; case mdDENY: lcd_text(42,40,2,"DENY",1); break; } lcd_update(0,63); do { key=CAP_KEY_GetEvent(); res = xQueueReceive(xUIQueue,&payload,100); if (GPIOGetPinValue( PIN_ISP ) == 0) { lcd_clear_all(); lcd_text(52,26,2,"ISP",0); lcd_update(0,63); NVIC_SystemReset(); } } while ((key==keNONE) && (res!= pdPASS)); if (key==keK3_PRESS || key==keK3_REPEAT) { if (m_eMode<mdDENY) m_eMode++; else m_eMode=mdAUTHENTICATE; } else if (key==keK1_PRESS || key==keK1_REPEAT) { if (m_eMode>mdAUTHENTICATE) m_eMode--; else m_eMode = mdDENY; } key=keNONE; if (res==pdPASS) { lcd_clear_all(); snprintf(str, sizeof(payload.name),"Name %s", payload.name); lcd_text(0,20,2,str,0); sprintf(str,"Access %08X",payload.access_rights); lcd_text(0,40,2,str,0); lcd_update(0,63); if (payload.access_rights==0xffffffff) GPIOSetBitValue(PIN_MOSFET,1); vTaskDelay(1500); GPIOSetBitValue(PIN_MOSFET,0); } } }