This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
ui_api [2017/10/31 13:39] 1.241.172.144 |
ui_api [2017/10/31 13:41] (current) 1.241.172.144 |
||
|---|---|---|---|
| Line 2: | Line 2: | ||
| <code> | <code> | ||
| + | #include <stdio.h> /* printf */ | ||
| + | #include <stdint.h> /* uint??_t */ | ||
| + | #include <string.h> /* for memset */ | ||
| + | #include <unistd.h> /* for open/close .. */ | ||
| + | #include <fcntl.h> /* for O_RDWR */ | ||
| + | #include <sys/ioctl.h> /* for ioctl */ | ||
| + | #include <sys/mman.h> /* for mmap */ | ||
| + | #include <linux/fb.h> /* for fb_var_screeninfo, FBIOGET_VSCREENINFO */ | ||
| + | #include <linux/input.h> | ||
| + | #include <poll.h> | ||
| + | #include <sys/fcntl.h> /* for O_RDWR */ | ||
| + | |||
| + | #include "directfb/directfb.h" /* 항상 UI.h 와 함께 UI.h 보다 먼저 */ | ||
| + | #include "UI.h" /* direct fb */ | ||
| + | |||
| + | #include "MMD1100.h" /* MSR */ | ||
| + | #include "Buzzer.h" | ||
| + | #include "LED.h" | ||
| + | #include "KeyBackLight.h" | ||
| + | #include "ThermalPrinter.h" | ||
| + | |||
| + | #include <termios.h> /* struct termios */ | ||
| + | |||
| + | |||
| + | /* | ||
| + | DirectFB support still image type | ||
| + | jpg | ||
| + | png | ||
| + | gif | ||
| + | |||
| + | */ | ||
| + | |||
| + | /* Application Action | ||
| + | Key : Test Action | ||
| + | ------------------------------------------------------------------------------------- | ||
| + | F1 : Display VI_logo_320_240_R90.jpg | ||
| + | F2 : Display VI_logo_320_240_R270.jpg | ||
| + | F3 : Draw Blue Box | ||
| + | F4 : Clear Screen | ||
| + | F5 : Display String.. | ||
| + | F6 (*) : LCD Back light -, Read Thermal Printer Info | ||
| + | F7 (#) : LCD Back light + | ||
| + | F8 (Up) : Key Backlight On | ||
| + | F9 (Down) : Key Backlight Off | ||
| + | F10 (Scan) : - | ||
| + | ESC : - Printer Pattern | ||
| + | BACKSPACE : - Throw Printer paper | ||
| + | ENTER : Exit App | ||
| + | 1 : LED On - DEVICE_LED_B14 = HANDY_READY or PRINTER_BUSY or AP_STATUS | ||
| + | : Beep 도 | ||
| + | 2 : LED Off - DEVICE_LED_B14 = HANDY_READY or PRINTER_BUSY or AP_STATUS | ||
| + | : Beep 레 | ||
| + | 3 : LED On - DEVICE_LED_A25 = HANDY_PROCESS or PRINTER_READY | ||
| + | : Beep 미 | ||
| + | 4 : LED Off - DEVICE_LED_A25 = HANDY_PROCESS or PRINTER_READY | ||
| + | : Beep 파 | ||
| + | 5 : LED On - DEVICE_LED_C21 = HANDY_COLPLETE or | ||
| + | : Beep 솔 | ||
| + | 6 : LED Off - DEVICE_LED_C21 = HANDY_COLPLETE or | ||
| + | : Beep 라 | ||
| + | 7 : LED On - DEVICE_LED_B15 = HANDY_ERROR or PRINTER_NO_PAPER or AP_ERROR | ||
| + | : Beep 시 | ||
| + | 8 : LED Off - DEVICE_LED_B15 = HANDY_ERROR or PRINTER_NO_PAPER or AP_ERROR | ||
| + | : Beep 옥타브 내림 | ||
| + | 9 : Beep 옥타브 올림 | ||
| + | 0 : Read MMD1100 version | ||
| + | */ | ||
| + | |||
| + | //#define TEST_LTE_MODEM | ||
| + | |||
| + | //#define TEST_THERMAL_PRINTER | ||
| + | |||
| + | /***************************************************************************/ | ||
| + | /* For directfb | ||
| + | */ | ||
| + | /***************************************************************************/ | ||
| + | #ifdef TEST_LTE_MODEM | ||
| + | #define LTE_INITIAL_IMAGE_FILE "320x480.jpg" | ||
| + | #endif /* TEST_LTE_MODEM */ | ||
| + | |||
| + | #define TEST_IMAGE_FILE_1 "VI_logo_320_240_R90.jpg" | ||
| + | #define TEST_IMAGE_FILE_2 "VI_logo_320_240_R270.jpg" | ||
| + | |||
| + | #define TEST_DISPLAY_STRING "밸류이노베이션 VI" | ||
| + | |||
| + | /***************************************************************************/ | ||
| + | /* For Test LCD BackLight | ||
| + | */ | ||
| + | /***************************************************************************/ | ||
| + | #define DEVICE_LCD_BACKLIGHT "/sys/class/backlight/backlight/brightness" | ||
| + | |||
| + | |||
| + | #ifdef TEST_LTE_MODEM | ||
| + | |||
| + | #define DEVICE_LTE_TEST_LED_SW "/sys/class/leds/lte_sw/brightness" | ||
| + | #define DEVICE_LTE_TEST_LED_KEY "/sys/class/leds/lte_key/brightness" | ||
| + | //#define DEVICE_LTE_TEST_LED_AP "/sys/class/leds/lte_ap_ready/brightness" | ||
| + | //#define DEVICE_LTE_TEST_LED_USB_ON "/sys/class/leds/lte_usb_on/brightness" | ||
| + | //#define DEVICE_LTE_TEST_LED_DTR "/sys/class/leds/lte_dtr/brightness" | ||
| + | |||
| + | int lte_on_off_switch(bool Switch/*true=on, false=Off*/) | ||
| + | { | ||
| + | FILE * pDeviceFile; | ||
| + | char pString[2] = { 0, 0 }; | ||
| + | int StringLength; | ||
| + | |||
| + | pDeviceFile = fopen ( DEVICE_LTE_TEST_LED_SW, "w+"); | ||
| + | if ( pDeviceFile == (FILE *)0 ) | ||
| + | { | ||
| + | return -2; | ||
| + | } | ||
| + | |||
| + | if ( Switch == true ) | ||
| + | { | ||
| + | pString[0] = '1'; | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | pString[0] = '0'; | ||
| + | } | ||
| + | StringLength = (int)strlen(pString); | ||
| + | if ( fwrite ( pString, StringLength, 1, pDeviceFile ) < 0 ) | ||
| + | { | ||
| + | return -3; | ||
| + | } | ||
| + | |||
| + | fclose ( pDeviceFile ); | ||
| + | |||
| + | return 0; | ||
| + | } | ||
| + | |||
| + | int lte_power_key(bool Pressed/*true=on, false=Off*/) | ||
| + | { | ||
| + | FILE * pDeviceFile; | ||
| + | char pString[2] = { 0, 0 }; | ||
| + | int StringLength; | ||
| + | |||
| + | pDeviceFile = fopen ( DEVICE_LTE_TEST_LED_KEY, "w+"); | ||
| + | if ( pDeviceFile == (FILE *)0 ) | ||
| + | { | ||
| + | return -2; | ||
| + | } | ||
| + | |||
| + | if ( Pressed == true ) | ||
| + | { | ||
| + | pString[0] = '1'; | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | pString[0] = '0'; | ||
| + | } | ||
| + | StringLength = (int)strlen(pString); | ||
| + | if ( fwrite ( pString, StringLength, 1, pDeviceFile ) < 0 ) | ||
| + | { | ||
| + | return -3; | ||
| + | } | ||
| + | |||
| + | fclose ( pDeviceFile ); | ||
| + | |||
| + | return 0; | ||
| + | } | ||
| + | |||
| + | #if 0 | ||
| + | |||
| + | #define DEVICE_LTE "/dev/ttyS4" | ||
| + | #define DEVICE_LTE_DEFAULT_BAUDRATE 115200 | ||
| + | |||
| + | struct termios BackupTerminalInfo; | ||
| + | |||
| + | int lte_open(int *pDeviceFileDescriptor) | ||
| + | { | ||
| + | struct termios TerminalInfo; | ||
| + | |||
| + | if ( pDeviceFileDescriptor == (int *)0 ) | ||
| + | { | ||
| + | return -2; | ||
| + | } | ||
| + | |||
| + | /* 화일을 연다. */ | ||
| + | *pDeviceFileDescriptor = open( DEVICE_LTE, (O_RDWR | O_NOCTTY) ); | ||
| + | if ( *pDeviceFileDescriptor < 0 ) | ||
| + | { | ||
| + | *pDeviceFileDescriptor = -1; | ||
| + | return -1; | ||
| + | } | ||
| + | /* 현재 설정을 BackupTerminalInfo에 저장 */ | ||
| + | tcgetattr( *pDeviceFileDescriptor, &BackupTerminalInfo ); | ||
| + | memset( &TerminalInfo, 0, sizeof(TerminalInfo) ); | ||
| + | switch( DEVICE_LTE_DEFAULT_BAUDRATE ) | ||
| + | { | ||
| + | case 19200: | ||
| + | TerminalInfo.c_cflag = B19200 | CS8 | CSTOPB | CLOCAL | CREAD ; | ||
| + | break; | ||
| + | case 38400: | ||
| + | TerminalInfo.c_cflag = B38400 | CS8 | CSTOPB | CLOCAL | CREAD ; | ||
| + | break; | ||
| + | case 57600: | ||
| + | TerminalInfo.c_cflag = B57600 | CS8 | CSTOPB | CLOCAL | CREAD ; | ||
| + | break; | ||
| + | case 115200: | ||
| + | TerminalInfo.c_cflag = B115200 | CS8 | CSTOPB | CLOCAL | CREAD ; | ||
| + | break; | ||
| + | case 9600: | ||
| + | default: | ||
| + | TerminalInfo.c_cflag = B9600 | CS8 | CSTOPB | CLOCAL | CREAD ; | ||
| + | break; | ||
| + | } | ||
| + | TerminalInfo.c_iflag = 0; /* IGNPAR? */ | ||
| + | TerminalInfo.c_oflag = 0; | ||
| + | //set input mode (non-canonical, no echo,.....) | ||
| + | TerminalInfo.c_lflag = 0; | ||
| + | TerminalInfo.c_cc[VTIME] = 100; /* time-out 값으로 사용된다. time-out 값은 TIME*0.1초 이다. */ | ||
| + | TerminalInfo.c_cc[VMIN] = 0; /* MIN은 read가 리턴되기 위한 최소한의 문자 개수 */ | ||
| + | |||
| + | tcflush( *pDeviceFileDescriptor, TCIFLUSH ); | ||
| + | tcsetattr( *pDeviceFileDescriptor, TCSANOW, &TerminalInfo ); | ||
| + | // raw mode | ||
| + | fcntl( *pDeviceFileDescriptor, F_SETFL, O_NONBLOCK ); | ||
| + | |||
| + | return 0; | ||
| + | } | ||
| + | |||
| + | int lte_close(int DeviceFileDescriptor) | ||
| + | { | ||
| + | |||
| + | if ( DeviceFileDescriptor < 0 ) | ||
| + | { | ||
| + | return -1; | ||
| + | } | ||
| + | |||
| + | /* 이전 상태로 되돌린다. */ | ||
| + | tcsetattr( DeviceFileDescriptor, TCSANOW, &BackupTerminalInfo ); | ||
| + | |||
| + | close( DeviceFileDescriptor ); | ||
| + | |||
| + | return 0; | ||
| + | } | ||
| + | |||
| + | int lte_serial_polling(int DeviceFileDescriptor) | ||
| + | { | ||
| + | struct pollfd PollFileDescriptor; | ||
| + | uint32_t Temp; | ||
| + | int Result; | ||
| + | uint8_t ReceivedByte; | ||
| + | |||
| + | memset( &PollFileDescriptor, 0, sizeof(struct pollfd) ); | ||
| + | PollFileDescriptor.fd = DeviceFileDescriptor; | ||
| + | PollFileDescriptor.events = POLLIN; | ||
| + | PollFileDescriptor.revents = 0; | ||
| + | |||
| + | Result = poll( (struct pollfd *)&PollFileDescriptor, 1, 300); // 300 msec | ||
| + | |||
| + | if ( (Result == 1) && ((PollFileDescriptor.revents & POLLIN) != 0) ) | ||
| + | { | ||
| + | if ( read( DeviceFileDescriptor, &ReceivedByte, 1 ) == 1 ) | ||
| + | { | ||
| + | printf( "Input %c\n", ReceivedByte ); | ||
| + | } | ||
| + | } | ||
| + | return 0; | ||
| + | } | ||
| + | |||
| + | #endif | ||
| + | |||
| + | #endif /* TEST_LTE_MODEM */ | ||
| + | |||
| + | |||
| + | /***************************************************************************/ | ||
| + | /* For Test LCD BackLight | ||
| + | */ | ||
| + | /***************************************************************************/ | ||
| + | int bright_set(const uint8_t Brightness) | ||
| + | { | ||
| + | FILE * pDeviceFile; | ||
| + | char pString[10] = {0}; | ||
| + | int StringLength; | ||
| + | |||
| + | pDeviceFile = fopen(DEVICE_LCD_BACKLIGHT, "w+"); | ||
| + | if ( pDeviceFile == (FILE *)0 ) | ||
| + | { | ||
| + | printf("failed to open back light device : %s\n", DEVICE_LCD_BACKLIGHT); | ||
| + | return -1; | ||
| + | } | ||
| + | |||
| + | sprintf(pString, "%d", Brightness); | ||
| + | StringLength = (int)strlen(pString); | ||
| + | |||
| + | if ( fwrite(pString, StringLength, 1, pDeviceFile) < 0 ) | ||
| + | { | ||
| + | return -1; | ||
| + | } | ||
| + | |||
| + | fclose(pDeviceFile); | ||
| + | |||
| + | return 0; | ||
| + | } | ||
| + | |||
| + | int bright_get(uint8_t *pBrightness) | ||
| + | { | ||
| + | FILE * pDeviceFile; | ||
| + | char pCommand[128] = {0}; | ||
| + | char pString[10] = {0}; | ||
| + | |||
| + | char buf[10] = {0}; | ||
| + | int level = 0; | ||
| + | |||
| + | if ( pBrightness == (uint8_t *)0 ) | ||
| + | { | ||
| + | printf("bright_get : Input Parameter error\n"); | ||
| + | return -1; | ||
| + | } | ||
| + | |||
| + | sprintf(pCommand, "cat %s", DEVICE_LCD_BACKLIGHT); | ||
| + | pDeviceFile = popen(pCommand, "r"); | ||
| + | if ( pDeviceFile == (FILE *)0 ) | ||
| + | { | ||
| + | return -1; | ||
| + | } | ||
| + | |||
| + | while( fgets(pString, 10, pDeviceFile) ); | ||
| + | *pBrightness = (uint8_t)strtoul(pString, NULL, 10); | ||
| + | |||
| + | fclose(pDeviceFile); | ||
| + | |||
| + | return 0; | ||
| + | } | ||
| + | |||
| + | void print_hex_dump(uint8_t *pBuffer, uint32_t ByteLengthForDump) | ||
| + | { | ||
| + | uint32_t Address; | ||
| + | |||
| + | printf( "--------------------------------------------------------------------------------------------\n" ); | ||
| + | printf( "Address | 0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0A 0x0B 0x0C 0x0D 0x0E 0x0F\n" ); | ||
| + | printf( "--------------------------------------------------------------------------------------------" ); | ||
| + | for( Address = 0; Address < ByteLengthForDump; Address++ ) | ||
| + | { | ||
| + | if (( Address & 0x0000000F ) == 0 ) | ||
| + | { | ||
| + | printf( "\n0x%08X :", Address ); | ||
| + | } | ||
| + | printf ( " 0x%02X", pBuffer[Address] ); | ||
| + | } | ||
| + | printf( "\n--------------------------------------------------------------------------------------------\n" ); | ||
| + | } | ||
| + | |||
| + | static char *pFontList[8] = | ||
| + | { | ||
| + | "D2Coding.ttf", | ||
| + | "NanumSquareR.ttf", | ||
| + | "NanumGothic.ttf", | ||
| + | "NanumGothicCoding.ttf", | ||
| + | "NanumMyeongjo.ttf", | ||
| + | "NanumBarunGothic.ttf", | ||
| + | "NanumBrush.ttf", | ||
| + | "NanumPen.ttf" | ||
| + | }; | ||
| + | |||
| + | |||
| + | int main() | ||
| + | { | ||
| + | void * pUI; | ||
| + | |||
| + | uint32_t KeyCode; | ||
| + | bool IsReleased; | ||
| + | |||
| + | #ifdef TEST_THERMAL_PRINTER | ||
| + | int ThermalPrinter; | ||
| + | uint32_t ThermalPrinterDotsInLine; | ||
| + | int ThermalPrinterImageSize; | ||
| + | char pThermapPrinterTestString[100]; | ||
| + | #endif /* TEST_THERMAL_PRINTER */ | ||
| + | |||
| + | int IsInLoop; | ||
| + | uint32_t Octave; | ||
| + | uint8_t Brightness; | ||
| + | |||
| + | int DeviceFileDescriptorForMSR; | ||
| + | MSRTrack_t MSRTrack; | ||
| + | MMD1100Response_t MSRResponse; | ||
| + | uint32_t IsNotTrack; | ||
| + | uint8_t pVersion[1024]; | ||
| + | int ReadByteLength; | ||
| + | uint8_t pImageBuffer[10000]; | ||
| + | |||
| + | #ifdef TEST_LTE_MODEM | ||
| + | int DeviceLTE; | ||
| + | #endif /* TEST_LTE_MODEM */ | ||
| + | |||
| + | #ifdef TEST_THERMAL_PRINTER | ||
| + | thermal_printer_open( &ThermalPrinter ); | ||
| + | #endif /* TEST_THERMAL_PRINTER */ | ||
| + | |||
| + | if ( ui_initialize( &pUI, 0 ) != 0 ) | ||
| + | { | ||
| + | printf( "ui_initialize() Fail!\n"); | ||
| + | return -1; | ||
| + | } | ||
| + | |||
| + | #ifdef TEST_THERMAL_PRINTER | ||
| + | if ( thermal_printer_get_dots_in_line( ThermalPrinter, &ThermalPrinterDotsInLine ) < 0 ) | ||
| + | { | ||
| + | printf( "Fail to get Termal Printer Dots In Line\n" ); | ||
| + | ui_release( pUI ); | ||
| + | return -1; | ||
| + | } | ||
| + | printf( "Termal Printer Dots In Line = %d\n", ThermalPrinterDotsInLine ); | ||
| + | |||
| + | if ( ui_printer_create_surface( pUI, ThermalPrinterDotsInLine/*SurfaceWidth*/, ThermalPrinterDotsInLine/*SurfaceHeight*/) < 0 ) | ||
| + | { | ||
| + | printf( "Fail to ui_printer_create_surface()\n" ); | ||
| + | ui_release( pUI ); | ||
| + | return -1; | ||
| + | } | ||
| + | #endif /* TEST_THERMAL_PRINTER */ | ||
| + | |||
| + | if ( ui_clear_screen( pUI ) != 0 ) | ||
| + | { | ||
| + | printf( "ui_clear_screen() Fail!\n"); | ||
| + | ui_release( pUI ); | ||
| + | return -1; | ||
| + | } | ||
| + | printf( "FillRectangle to clear surface OK!\n"); | ||
| + | |||
| + | if ( bright_get(&Brightness) != 0 ) | ||
| + | { | ||
| + | printf("Fail to bright_get()\n"); | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | printf("Brightness == %d\n", Brightness); | ||
| + | } | ||
| + | Brightness = 8; /* */ | ||
| + | if( bright_set(Brightness) != 0 ) | ||
| + | { | ||
| + | printf("Fail to bright_set(0)\n"); | ||
| + | } | ||
| + | |||
| + | if ( buzzer_open() < 0 ) | ||
| + | { | ||
| + | printf("Fail to buzzer_open\n"); | ||
| + | } | ||
| + | |||
| + | if ( mmd1100_open( &DeviceFileDescriptorForMSR ) != 0 ) | ||
| + | { | ||
| + | printf( "Fail to mmd1100_open\n" ); | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | printf( "OK to mmd1100_open\n" ); | ||
| + | } | ||
| + | |||
| + | #ifdef TEST_LTE_MODEM | ||
| + | ui_draw_image( pUI, LTE_INITIAL_IMAGE_FILE, 0, 0 ); | ||
| + | #endif /* TEST_LTE_MODEM */ | ||
| + | |||
| + | #ifdef TEST_LTE_MODEM | ||
| + | usleep( 100000 ); /* 100ms */ | ||
| + | lte_on_off_switch( true/*true=on, false=Off*/ ); | ||
| + | usleep( 50000 ); /* >=30ms */ | ||
| + | lte_power_key( true/*true=on, false=Off*/ ); | ||
| + | usleep( 200000 ); /* >=100ms */ | ||
| + | lte_power_key( false/*true=on, false=Off*/ ); | ||
| + | #endif /* TEST_LTE_MODEM */ | ||
| + | |||
| + | #if 0 | ||
| + | if ( lte_open( &DeviceLTE ) != 0 ) | ||
| + | { | ||
| + | printf( "Fail to ttyS4\n" ); | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | printf( "OK to ttyS4\n" ); | ||
| + | } | ||
| + | //int lte_close(int DeviceFileDescriptor) | ||
| + | for ( KeyCode = 0; KeyCode < 10; KeyCode++ ) | ||
| + | { | ||
| + | int waitcounter; | ||
| + | if ( write( DeviceLTE, "AT+GMI", 6 ) != 0 ) | ||
| + | { | ||
| + | printf( "Fail to w ttyS4\n" ); | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | printf( "OK to W ttyS4\n" ); | ||
| + | } | ||
| + | for ( waitcounter = 0; waitcounter < 10; waitcounter++ ) | ||
| + | { | ||
| + | lte_serial_polling( DeviceLTE ); | ||
| + | } | ||
| + | usleep( 1000000 ); /* 1 s */ | ||
| + | } | ||
| + | |||
| + | #endif /* TEST_LTE_MODEM */ | ||
| + | |||
| + | Octave = 4; | ||
| + | IsInLoop = 1; | ||
| + | /* Start event loop */ | ||
| + | while ( IsInLoop ) | ||
| + | { | ||
| + | if ( ui_key_is_inputed( pUI, 100/*100ms MiliSecondWaitTimeout*/) == 0 ) | ||
| + | { | ||
| + | uint8_t ReceivedByte; | ||
| + | |||
| + | #if 1 | ||
| + | if ( mmd1100_receive( &MSRTrack, &MSRResponse, &IsNotTrack, 10000/*10ms ResponseTimeout*/) == 0 ) | ||
| + | { | ||
| + | printf("MSR IN\n"); | ||
| + | if ( IsNotTrack == 1 ) | ||
| + | { | ||
| + | switch ( MSRResponse.Command ) | ||
| + | { | ||
| + | case MMD1100_COMMAND_GET_VERSION: | ||
| + | if ( MSRResponse.ErrorCode == 0 ) | ||
| + | { | ||
| + | printf(" MMD1100_COMMAND_GET_VERSION : %s\n", MSRResponse.pData ); | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | printf(" MMD1100_COMMAND_GET_VERSION : Error = 0x%02X\n", MSRResponse.ErrorCode ); | ||
| + | } | ||
| + | break; | ||
| + | case MMD1100_COMMAND_LOAD_USER_PARAMETERS: | ||
| + | break; | ||
| + | case MMD1100_COMMAND_UART_CALIBRATION: | ||
| + | break; | ||
| + | case MMD1100_COMMAND_OTP_WRITE: | ||
| + | break; | ||
| + | case MMD1100_COMMAND_GET_STATUS: | ||
| + | break; | ||
| + | case MMD1100_COMMAND_READ_DATA_RETRY: | ||
| + | break; | ||
| + | case MMD1100_COMMAND_SOFTWARE_RESET: | ||
| + | break; | ||
| + | default: | ||
| + | break; | ||
| + | } | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | int i; | ||
| + | if ( MSRTrack.ErrorCodeForTrack1 == 0 ) | ||
| + | { | ||
| + | printf( " Track 1 : " ); | ||
| + | for ( i = 0; i < MSRTrack.LengthOfTrack1; i++ ) | ||
| + | { | ||
| + | printf( "%c", MSRTrack.pTrack1[i] ); | ||
| + | } | ||
| + | printf( "\n" ); | ||
| + | if ( ( (MSRTrack.LengthOfTrack1 * 8) % 7 ) == 0 ) | ||
| + | { | ||
| + | printf( " Length OK \n" ); | ||
| + | } | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | printf(" Track 1 : ErrorCode = 0x%02X\n", MSRTrack.ErrorCodeForTrack1 ); | ||
| + | } | ||
| + | if ( MSRTrack.ErrorCodeForTrack2 == 0 ) | ||
| + | { | ||
| + | printf( " Track 2 Raw Data : (Length = %d)\n ", MSRTrack.LengthOfRaw2 ); | ||
| + | for ( i = 0; i < MSRTrack.LengthOfRaw2; i++ ) | ||
| + | { | ||
| + | printf( "%02X ", MSRTrack.pRaw2[i] ); | ||
| + | } | ||
| + | printf( "\n" ); | ||
| + | printf( " Track 2 : (Length = %d)\n ", MSRTrack.LengthOfTrack2 ); | ||
| + | for ( i = 0; i < MSRTrack.LengthOfTrack2; i++ ) | ||
| + | { | ||
| + | printf( "%c", MSRTrack.pTrack2[i] ); | ||
| + | } | ||
| + | printf( "\n" ); | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | printf(" Track 2 : ErrorCode = 0x%02X\n", MSRTrack.ErrorCodeForTrack2 ); | ||
| + | } | ||
| + | if ( MSRTrack.ErrorCodeForTrack3 == 0 ) | ||
| + | { | ||
| + | printf( " Track 3 Raw Data : (Length = %d)\n ", MSRTrack.LengthOfRaw3 ); | ||
| + | for ( i = 0; i < MSRTrack.LengthOfRaw3; i++ ) | ||
| + | { | ||
| + | printf( "%02X ", MSRTrack.pRaw3[i] ); | ||
| + | } | ||
| + | printf( "\n" ); | ||
| + | printf( " Track 3 : (Length = %d)\n ", MSRTrack.LengthOfTrack3 ); | ||
| + | for ( i = 0; i < MSRTrack.LengthOfTrack3; i++ ) | ||
| + | { | ||
| + | printf( "%c", MSRTrack.pTrack3[i] ); | ||
| + | } | ||
| + | printf( "\n" ); | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | printf(" Track 3 : ErrorCode = 0x%02X\n", MSRTrack.ErrorCodeForTrack3 ); | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | #endif | ||
| + | |||
| + | continue; | ||
| + | } | ||
| + | |||
| + | while ( ui_key_get_code( pUI, &KeyCode, &IsReleased ) == 0 ) | ||
| + | { | ||
| + | switch ( KeyCode ) | ||
| + | { | ||
| + | case KEY_ESC: /*Repeated input 3 times... TODO:check!!!*/ | ||
| + | printf("Key Code : KEY_ESC (0x%X)\n", KeyCode); | ||
| + | if ( IsReleased == true ) | ||
| + | { /* Key Released */ | ||
| + | ; | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | ; | ||
| + | } | ||
| + | break; | ||
| + | case KEY_1: | ||
| + | printf("Key code : KEY_1 (0x%X)\n", KeyCode); | ||
| + | if ( IsReleased == true ) | ||
| + | { /* Key Released */ | ||
| + | led_switch(DEVICE_LED_B14, true/*On*/ ); | ||
| + | buzzer_off(); | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | buzzer_on_code( MUSIC_FREQUENCY_CODE_C, Octave ); /* C(도) */ | ||
| + | } | ||
| + | break; | ||
| + | case KEY_2: | ||
| + | printf("Key code : KEY_2 (0x%X)\n", KeyCode); | ||
| + | if ( IsReleased == true ) | ||
| + | { /* Key Released */ | ||
| + | led_switch(DEVICE_LED_B14, false/*Off*/ ); | ||
| + | buzzer_off(); | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | buzzer_on_code( MUSIC_FREQUENCY_CODE_D, Octave ); /* D(레) */ | ||
| + | } | ||
| + | break; | ||
| + | case KEY_3: | ||
| + | printf("Key code : KEY_3 (0x%X)\n", KeyCode); | ||
| + | if ( IsReleased == true ) | ||
| + | { /* Key Released */ | ||
| + | led_switch(DEVICE_LED_A25, true/*On*/ ); | ||
| + | buzzer_off(); | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | buzzer_on_code( MUSIC_FREQUENCY_CODE_E, Octave ); /* E(미) */ | ||
| + | } | ||
| + | break; | ||
| + | case KEY_4: | ||
| + | printf("Key code : KEY_4 (0x%X)\n", KeyCode); | ||
| + | if ( IsReleased == true ) | ||
| + | { /* Key Released */ | ||
| + | led_switch(DEVICE_LED_A25, false/*Off*/ ); | ||
| + | buzzer_off(); | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | buzzer_on_code( MUSIC_FREQUENCY_CODE_F, Octave ); /* F(파) */ | ||
| + | } | ||
| + | break; | ||
| + | case KEY_5: | ||
| + | printf("Key code : KEY_5 (0x%X)\n", KeyCode); | ||
| + | if ( IsReleased == true ) | ||
| + | { /* Key Released */ | ||
| + | led_switch(DEVICE_LED_C21, true/*On*/ ); | ||
| + | buzzer_off(); | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | buzzer_on_code( MUSIC_FREQUENCY_CODE_G, Octave ); /* G(솔) */ | ||
| + | } | ||
| + | break; | ||
| + | case KEY_6: | ||
| + | printf("Key code : KEY_6 (0x%X)\n", KeyCode); | ||
| + | if ( IsReleased == true ) | ||
| + | { /* Key Released */ | ||
| + | led_switch(DEVICE_LED_C21, false/*Off*/ ); | ||
| + | buzzer_off(); | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | buzzer_on_code( MUSIC_FREQUENCY_CODE_A, Octave ); /* A(라) */ | ||
| + | } | ||
| + | break; | ||
| + | case KEY_7: | ||
| + | printf("Key code : KEY_7 (0x%X)\n", KeyCode); | ||
| + | if ( IsReleased == true ) | ||
| + | { /* Key Released */ | ||
| + | led_switch(DEVICE_LED_B15, true/*On*/ ); | ||
| + | buzzer_off(); | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | buzzer_on_code( MUSIC_FREQUENCY_CODE_B, Octave ); /* B(시) */ | ||
| + | } | ||
| + | break; | ||
| + | case KEY_8: | ||
| + | printf("Key code : KEY_8 (0x%X)\n", KeyCode); | ||
| + | if ( IsReleased == true ) | ||
| + | { /* Key Released */ | ||
| + | led_switch(DEVICE_LED_B15, false/*Off*/ ); | ||
| + | buzzer_off(); | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | buzzer_on_code( MUSIC_FREQUENCY_CODE_C, (Octave + 1) ); /* C(도) */ | ||
| + | } | ||
| + | break; | ||
| + | case KEY_9: | ||
| + | printf("Key code : KEY_9 (0x%X)\n", KeyCode); | ||
| + | if ( IsReleased == true ) | ||
| + | { /* Key Released */ | ||
| + | #ifdef TEST_THERMAL_PRINTER | ||
| + | uint32_t Uint32Value; | ||
| + | bool BoolValue; | ||
| + | |||
| + | if ( thermal_printer_get_dots_in_line( ThermalPrinter, &Uint32Value ) < 0 ) | ||
| + | { | ||
| + | printf( " Thermal Printer : Dots In Line Get Fail\n" ); | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | printf( " Thermal Printer : Dots In Line = %d\n", Uint32Value ); | ||
| + | } | ||
| + | if ( thermal_printer_get_heater_temperature( ThermalPrinter, &Uint32Value ) < 0 ) | ||
| + | { | ||
| + | printf( " Thermal Printer : Heater Temperature Get Fail\n" ); | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | printf( " Thermal Printer : Heater Temperature = %d\n", Uint32Value ); | ||
| + | } | ||
| + | if ( thermal_printer_get_heater_adc_raw_value( ThermalPrinter, &Uint32Value ) < 0 ) | ||
| + | { | ||
| + | printf( " Thermal Printer : Heater Temperature ADC raw data Get Fail\n" ); | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | printf( " Thermal Printer : Heater Temperature ADC raw data = %d\n", Uint32Value ); | ||
| + | } | ||
| + | if ( thermal_printer_get_heater_power_state( ThermalPrinter, &BoolValue ) < 0 ) | ||
| + | { | ||
| + | printf( " Thermal Printer : Heater Power State Get Fail\n" ); | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | if ( BoolValue == true ) | ||
| + | { | ||
| + | printf( " Thermal Printer : Heater Power State true\n" ); | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | printf( " Thermal Printer : Heater Power State false\n" ); | ||
| + | } | ||
| + | } | ||
| + | if ( thermal_printer_get_heater_overheat_state( ThermalPrinter, &BoolValue ) < 0 ) | ||
| + | { | ||
| + | printf( " Thermal Printer : Heater overheat State Get Fail\n" ); | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | if ( BoolValue == true ) | ||
| + | { | ||
| + | printf( " Thermal Printer : Heater overheat State true\n" ); | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | printf( " Thermal Printer : Heater overheat State false\n" ); | ||
| + | } | ||
| + | } | ||
| + | if ( thermal_printer_get_paper_state( ThermalPrinter, &BoolValue ) < 0 ) | ||
| + | { | ||
| + | printf( " Thermal Printer : paper State Get Fail\n" ); | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | if ( BoolValue == true ) | ||
| + | { | ||
| + | printf( " Thermal Printer : paper State true\n" ); | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | printf( " Thermal Printer : paper State false\n" ); | ||
| + | } | ||
| + | } | ||
| + | if ( thermal_printer_get_cover_state( ThermalPrinter, &BoolValue ) < 0 ) | ||
| + | { | ||
| + | printf( " Thermal Printer : cover State Get Fail\n" ); | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | if ( BoolValue == true ) | ||
| + | { | ||
| + | printf( " Thermal Printer : cover State true\n" ); | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | printf( " Thermal Printer : cover State false\n" ); | ||
| + | } | ||
| + | } | ||
| + | #endif /* TEST_THERMAL_PRINTER */ | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | ; | ||
| + | } | ||
| + | break; | ||
| + | case KEY_0: | ||
| + | if ( IsReleased == true ) | ||
| + | { /* Key Released */ | ||
| + | uint32_t MakedPacketByteLength; | ||
| + | |||
| + | if ( mmd1100_make_packet(pVersion, | ||
| + | &MakedPacketByteLength, | ||
| + | MMD1100_COMMAND_GET_VERSION, | ||
| + | (uint8_t *)0 ) != 0 ) | ||
| + | { | ||
| + | printf( "Fail to mmd1100_make_packet\n" ); | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | if ( mmd1100_send(pVersion, MakedPacketByteLength) > 0 ) | ||
| + | { | ||
| + | printf( "OK to mmd1100_send\n" ); | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | printf( "Fail to mmd1100_send\n" ); | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | printf("Key code : KEY_0 (0x%X)\n", KeyCode); | ||
| + | break; | ||
| + | case KEY_BACKSPACE: | ||
| + | if ( IsReleased == true ) | ||
| + | { /* Key Released */ | ||
| + | #ifdef TEST_THERMAL_PRINTER | ||
| + | thermal_printer_paper_throw( ThermalPrinter, 120/*Line*/ ); | ||
| + | printf( "thermal_printer_paper_throw 120 lines\n" ); | ||
| + | #endif /* TEST_THERMAL_PRINTER */ | ||
| + | } | ||
| + | printf("Key code : KEY_BACKSPACE (0x%X)\n", KeyCode); | ||
| + | break; | ||
| + | case KEY_ENTER: | ||
| + | printf("Key code : KEY_ENTER (0x%X)\n", KeyCode); | ||
| + | if ( IsReleased == true ) | ||
| + | { /* Key Released */ | ||
| + | #ifdef TEST_THERMAL_PRINTER | ||
| + | thermal_printer_print_test_pattern( ThermalPrinter, DEVICE_THERMAL_PRINTER_TEST_PATTERN_1 ); | ||
| + | usleep(100000); | ||
| + | thermal_printer_paper_throw( ThermalPrinter, 100/*Line*/ ); | ||
| + | usleep(100000); | ||
| + | thermal_printer_print_test_pattern( ThermalPrinter, DEVICE_THERMAL_PRINTER_TEST_PATTERN_2 ); | ||
| + | usleep(100000); | ||
| + | thermal_printer_paper_throw( ThermalPrinter, 100/*Line*/ ); | ||
| + | usleep(100000); | ||
| + | thermal_printer_print_test_pattern( ThermalPrinter, DEVICE_THERMAL_PRINTER_TEST_PATTERN_3 ); | ||
| + | usleep(100000); | ||
| + | thermal_printer_paper_throw( ThermalPrinter, 100/*Line*/ ); | ||
| + | usleep(100000); | ||
| + | thermal_printer_print_test_pattern( ThermalPrinter, DEVICE_THERMAL_PRINTER_TEST_PATTERN_4 ); | ||
| + | usleep(100000); | ||
| + | thermal_printer_paper_throw( ThermalPrinter, 150/*Line*/ ); | ||
| + | #else /* TEST_THERMAL_PRINTER */ | ||
| + | IsInLoop = 0; /* Exit */ | ||
| + | #endif /* TEST_THERMAL_PRINTER */ | ||
| + | } | ||
| + | break; | ||
| + | case KEY_F1: | ||
| + | printf("Key code : KEY_F1 (0x%X)\n", KeyCode); | ||
| + | if ( IsReleased == true ) | ||
| + | { | ||
| + | ui_draw_image( pUI, TEST_IMAGE_FILE_1, 0, 0 ); | ||
| + | } | ||
| + | break; | ||
| + | case KEY_F2: | ||
| + | printf("Key code : KEY_F2 (0x%X)\n", KeyCode); | ||
| + | if ( IsReleased == true ) | ||
| + | { | ||
| + | ui_draw_image( pUI, TEST_IMAGE_FILE_2, 0, 0 ); | ||
| + | } | ||
| + | break; | ||
| + | case KEY_F3: | ||
| + | printf("Key code : KEY_F3 (0x%X)\n", KeyCode); | ||
| + | if ( IsReleased == true ) | ||
| + | { /* Key Released */ | ||
| + | UIcolor_t Color; | ||
| + | Color.B = 0xFF; | ||
| + | Color.G = 0x00; | ||
| + | Color.R = 0xFF; | ||
| + | Color.Alpha = 0xFF; | ||
| + | ui_fill_rectangle( pUI, Color, 100, 100, 40, 80 ); | ||
| + | } | ||
| + | break; | ||
| + | case KEY_F4: | ||
| + | printf("Key code : KEY_F4 (0x%X)\n", KeyCode); | ||
| + | if ( IsReleased == true ) | ||
| + | { /* Key Released */ | ||
| + | ui_clear_screen( pUI ); | ||
| + | } | ||
| + | break; | ||
| + | case KEY_F5: | ||
| + | printf("Key code : KEY_F5 (0x%X)\n", KeyCode); | ||
| + | if ( IsReleased == true ) | ||
| + | { | ||
| + | UIcolor_t Color; | ||
| + | Color.B = 0xFF; | ||
| + | Color.G = 0x00; | ||
| + | Color.R = 0xFF; | ||
| + | Color.Alpha = 0xFF; | ||
| + | #ifdef TEST_THERMAL_PRINTER | ||
| + | ui_draw_string( pUI, Color, 20, 40, 280, 400, TEST_DISPLAY_STRING, UI_TEXT_LAYOUT_TOP_LEFT ); | ||
| + | ui_draw_string( pUI, Color, 20, 40, 280, 400, TEST_DISPLAY_STRING, UI_TEXT_LAYOUT_MIDDLE_CENTER ); | ||
| + | ui_draw_string( pUI, Color, 20, 40, 280, 400, TEST_DISPLAY_STRING, UI_TEXT_LAYOUT_BOTTOM_RIGHT ); | ||
| + | ui_draw_rectangle( pUI, Color, 20, 40, 280, 400 ); | ||
| + | #else /* TEST_THERMAL_PRINTER */ | ||
| + | ui_draw_string( pUI, Color, 20, 40, 200, 240, TEST_DISPLAY_STRING, UI_TEXT_LAYOUT_TOP_LEFT ); | ||
| + | ui_change_font( pUI, "NanumBrush.ttf", 28); | ||
| + | ui_draw_string( pUI, Color, 20, 40, 200, 240, TEST_DISPLAY_STRING, UI_TEXT_LAYOUT_MIDDLE_CENTER ); | ||
| + | ui_change_font( pUI, "NanumPen.ttf", 28); | ||
| + | ui_draw_string( pUI, Color, 20, 40, 200, 240, TEST_DISPLAY_STRING, UI_TEXT_LAYOUT_BOTTOM_RIGHT ); | ||
| + | |||
| + | ui_change_font( pUI, "NanumGothic.ttf", 22); | ||
| + | ui_draw_string( pUI, Color, 20, 80, 200, 160, TEST_DISPLAY_STRING, UI_TEXT_LAYOUT_TOP_LEFT ); | ||
| + | ui_change_font( pUI,"NanumMyeongjo.ttf", 22); | ||
| + | ui_draw_string( pUI, Color, 20, 80, 200, 160, TEST_DISPLAY_STRING, UI_TEXT_LAYOUT_BOTTOM_RIGHT ); | ||
| + | |||
| + | ui_change_font( pUI, "D2Coding.ttf", 22); | ||
| + | ui_draw_rectangle( pUI, Color, 20, 40, 200, 240 ); | ||
| + | #endif /* TEST_THERMAL_PRINTER */ | ||
| + | } | ||
| + | break; | ||
| + | case KEY_F6: /* '*' or '00' */ | ||
| + | if ( IsReleased == true ) | ||
| + | { /* Key Released */ | ||
| + | #ifdef TEST_THERMAL_PRINTER | ||
| + | ReadByteLength = thermal_printer_read(ThermalPrinter, pVersion, 100); | ||
| + | printf( "ThermalPrinter read [%d : %s]\n", ReadByteLength, pVersion ); | ||
| + | #else /* TEST_THERMAL_PRINTER */ | ||
| + | if( Brightness != 8 ) | ||
| + | { | ||
| + | Brightness ++; | ||
| + | if( bright_set(Brightness) != 0 ) | ||
| + | { | ||
| + | printf("Fail to bright_set\n"); | ||
| + | } | ||
| + | printf("bright -\n"); | ||
| + | } | ||
| + | #endif /* TEST_THERMAL_PRINTER */ | ||
| + | } | ||
| + | printf("Key code : KEY_F6 (0x%X)\n", KeyCode); | ||
| + | break; | ||
| + | case KEY_F7: /* '#' or '000' */ | ||
| + | if ( IsReleased == true ) | ||
| + | { /* Key Released */ | ||
| + | #ifdef TEST_THERMAL_PRINTER | ||
| + | uint32_t LineHeight; | ||
| + | uint32_t PrinterFontSize; | ||
| + | uint32_t FontFileIndex; | ||
| + | |||
| + | for ( FontFileIndex = 0; FontFileIndex < 8; FontFileIndex++ ) | ||
| + | { | ||
| + | for ( PrinterFontSize = 16; PrinterFontSize <= 32; PrinterFontSize += 2 ) | ||
| + | { | ||
| + | memset( pThermapPrinterTestString, 0, 100 ); | ||
| + | sprintf ( pThermapPrinterTestString, "%s %d", TEST_DISPLAY_STRING, PrinterFontSize ); | ||
| + | printf( "Thermal Printer Test String = %s\n", pThermapPrinterTestString ); | ||
| + | |||
| + | thermal_printer_get_dots_in_line( ThermalPrinter, &ThermalPrinterDotsInLine ); | ||
| + | printf( "Termal Printer Dots In Line = %d\n", ThermalPrinterDotsInLine ); | ||
| + | |||
| + | /* ui_printer_font_set( pUI, "D2Coding.ttf", PrinterFontSize );*/ | ||
| + | ui_printer_font_set( pUI, pFontList[FontFileIndex], PrinterFontSize ); | ||
| + | |||
| + | if ( ui_printer_font_get_line_height( pUI, &LineHeight ) < 0 ) | ||
| + | { | ||
| + | printf( "Fail to Get Termal Printer Line Height\n" ); | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | printf( "Termal Printer Line Height = %d\n", LineHeight ); | ||
| + | |||
| + | memset( pImageBuffer, 0, ((LineHeight * ThermalPrinterDotsInLine) / 8 ) ); | ||
| + | ThermalPrinterImageSize = ui_printer_string( pUI, | ||
| + | pFontList[FontFileIndex], | ||
| + | UI_TEXT_LAYOUT_TOP_LEFT, | ||
| + | pImageBuffer, | ||
| + | (ThermalPrinterDotsInLine / 8), | ||
| + | LineHeight); | ||
| + | if ( ThermalPrinterImageSize > 0 ) | ||
| + | { | ||
| + | printf( "Termal Printer Image Size = %d Byte\n", ThermalPrinterImageSize ); | ||
| + | // print_hex_dump( pImageBuffer, ThermalPrinterImageSize ); | ||
| + | if ( thermal_printer_print( ThermalPrinter, pImageBuffer, ThermalPrinterImageSize ) < 0 ) | ||
| + | { | ||
| + | printf( "Fail to Print Image Size = %d Byte\n", ThermalPrinterImageSize ); | ||
| + | } | ||
| + | printf( "Print Termal Printer Image Size = %d Byte\n", ThermalPrinterImageSize ); | ||
| + | } | ||
| + | |||
| + | /* clear Line area.. if it needed */ | ||
| + | memset( pImageBuffer, 0, ((LineHeight * ThermalPrinterDotsInLine) / 8 ) ); | ||
| + | ThermalPrinterImageSize = ui_printer_string( pUI, | ||
| + | /* TEST_DISPLAY_STRING,*/ | ||
| + | pThermapPrinterTestString, | ||
| + | UI_TEXT_LAYOUT_TOP_LEFT, | ||
| + | pImageBuffer, | ||
| + | (ThermalPrinterDotsInLine / 8), | ||
| + | LineHeight); | ||
| + | if ( ThermalPrinterImageSize > 0 ) | ||
| + | { | ||
| + | printf( "Termal Printer Image Size = %d Byte\n", ThermalPrinterImageSize ); | ||
| + | // print_hex_dump( pImageBuffer, ThermalPrinterImageSize ); | ||
| + | if ( thermal_printer_print( ThermalPrinter, pImageBuffer, ThermalPrinterImageSize ) < 0 ) | ||
| + | { | ||
| + | printf( "Fail to Print Image Size = %d Byte\n", ThermalPrinterImageSize ); | ||
| + | } | ||
| + | printf( "Print Termal Printer Image Size = %d Byte\n", ThermalPrinterImageSize ); | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | |||
| + | thermal_printer_paper_throw( ThermalPrinter, 150/*Line*/ ); | ||
| + | #else /* TEST_THERMAL_PRINTER */ | ||
| + | if( Brightness != 0 ) | ||
| + | { | ||
| + | Brightness --; | ||
| + | if( bright_set(Brightness) != 0 ) | ||
| + | { | ||
| + | printf("Fail to bright_set\n"); | ||
| + | } | ||
| + | printf("bright +\n"); | ||
| + | } | ||
| + | #endif /* TEST_THERMAL_PRINTER */ | ||
| + | } | ||
| + | printf("Key code : KEY_F7 (0x%X)\n", KeyCode); | ||
| + | break; | ||
| + | case KEY_F8: | ||
| + | printf("Key code : KEY_F8 - Side Key Up or Feed (0x%X)\n", KeyCode); | ||
| + | if ( IsReleased == true ) | ||
| + | { /* Key Released */ | ||
| + | key_back_light( true/*On*/ ); | ||
| + | } | ||
| + | break; | ||
| + | case KEY_F9: | ||
| + | printf("Key code : KEY_F9 - Side Key Down or Select (0x%X)\n", KeyCode); | ||
| + | if ( IsReleased == true ) | ||
| + | { /* Key Released */ | ||
| + | key_back_light( false/*Off*/ ); | ||
| + | } | ||
| + | break; | ||
| + | case KEY_F10: | ||
| + | printf("Key code : KEY_F10 - Scan Key or SetUp (0x%X)\n", KeyCode); | ||
| + | break; | ||
| + | default: | ||
| + | // printf("Key code : (0x%X)\n", KeyCode); | ||
| + | break; | ||
| + | } | ||
| + | } | ||
| + | |||
| + | if ( IsInLoop == 0 ) | ||
| + | { | ||
| + | printf( "Exit Main Loop\n" ); | ||
| + | } | ||
| + | } /* while (IsInLoop)*/ | ||
| + | |||
| + | #ifdef TEST_LTE_MODEM | ||
| + | lte_on_off_switch( false/*true=on, false=Off*/ ); | ||
| + | #endif /* TEST_LTE_MODEM */ | ||
| + | |||
| + | printf( "Close opend system\n" ); | ||
| + | if ( mmd1100_close() != 0 ) | ||
| + | { | ||
| + | printf("Fail to mmd1100_close\n"); | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | printf("OK to mmd1100_close\n"); | ||
| + | } | ||
| + | if ( buzzer_close() < 0 ) | ||
| + | { | ||
| + | printf("Fail to buzzer_close\n"); | ||
| + | } | ||
| + | /* clean up */ | ||
| + | ui_release( pUI ); | ||
| + | #ifdef TEST_THERMAL_PRINTER | ||
| + | thermal_printer_close( ThermalPrinter ); | ||
| + | #endif /* TEST_THERMAL_PRINTER */ | ||
| + | |||
| + | return 0; | ||
| + | } | ||
| </code> | </code> | ||
| Line 7: | Line 1104: | ||
| <code> | <code> | ||
| + | #ifndef __UI_H__ | ||
| + | #define __UI_H__ | ||
| + | |||
| + | #include <stdint.h> /* uint??_t */ | ||
| + | //#include <stdbool.h> /* Bool */ | ||
| + | #include "directfb/directfb.h" /* 항상 UI.h 와 함께 UI.h 보다 먼저 */ | ||
| + | |||
| + | |||
| + | typedef struct | ||
| + | { | ||
| + | uint8_t R; | ||
| + | uint8_t G; | ||
| + | uint8_t B; | ||
| + | uint8_t Alpha; | ||
| + | } UIcolor_t; | ||
| + | |||
| + | typedef enum | ||
| + | { | ||
| + | UI_TEXT_LAYOUT_NONE = 0, | ||
| + | UI_TEXT_LAYOUT_TOP_LEFT, | ||
| + | UI_TEXT_LAYOUT_TOP_CENTER, | ||
| + | UI_TEXT_LAYOUT_TOP_RIGHT, | ||
| + | UI_TEXT_LAYOUT_BOTTOM_LEFT, | ||
| + | UI_TEXT_LAYOUT_BOTTOM_CENTER, | ||
| + | UI_TEXT_LAYOUT_BOTTOM_RIGHT, | ||
| + | UI_TEXT_LAYOUT_MIDDLE_LEFT, | ||
| + | UI_TEXT_LAYOUT_MIDDLE_CENTER, | ||
| + | UI_TEXT_LAYOUT_MIDDLE_RIGHT, | ||
| + | UI_TEXT_LAYOUT_OUTLINE_TOP_LEFT, | ||
| + | UI_TEXT_LAYOUT_OUTLINE_TOP_CENTER, | ||
| + | UI_TEXT_LAYOUT_OUTLINE_TOP_RIGHT, | ||
| + | UI_TEXT_LAYOUT_OUTLINE_BOTTOM_LEFT, | ||
| + | UI_TEXT_LAYOUT_OUTLINE_BOTTOM_CENTER, | ||
| + | UI_TEXT_LAYOUT_OUTLINE_BOTTOM_RIGHT, | ||
| + | UI_TEXT_LAYOUT_OUTLINE_MIDDLE_LEFT, | ||
| + | UI_TEXT_LAYOUT_OUTLINE_MIDDLE_CENTER, | ||
| + | UI_TEXT_LAYOUT_OUTLINE_MIDDLE_RIGHT, | ||
| + | } UItextLayout_t; | ||
| + | |||
| + | |||
| + | #define UI_DRIVER_MESSAGE_ERROR // Must be Defined | ||
| + | //#define UI_DRIVER_MESSAGE_DEBUG | ||
| + | //#define UI_DRIVER_MESSAGE_INFO | ||
| + | //#define UI_DRIVER_MESSAGE_KEY_EVENT_INFO | ||
| + | |||
| + | |||
| + | extern int ui_initialize(void **pUI, uint32_t Rotate); | ||
| + | extern int ui_release(void *pUI); | ||
| + | extern int ui_change_font(void *pUI, char *pFontFile, int FontSize); | ||
| + | |||
| + | /* | ||
| + | // 아래와 같은 형태로 Layout이 나타난다. | ||
| + | // ----------------------------------------- | ||
| + | // |UI_TEXT_LAYOUT_TOP_LEFT | | ||
| + | // | | | ||
| + | // | UI_TEXT_LAYOUT_MIDDLE_CENTER | | ||
| + | // | | | ||
| + | // | UI_TEXT_LAYOUT_BOTTOM_RIGHT| | ||
| + | // ----------------------------------------- | ||
| + | */ | ||
| + | extern int ui_draw_string(void *pUI, UIcolor_t Color, | ||
| + | uint32_t X, uint32_t Y, uint32_t W, uint32_t H, | ||
| + | char *pString, | ||
| + | UItextLayout_t UItextLayout); | ||
| + | |||
| + | extern int ui_draw_line(void *pUI, UIcolor_t Color, | ||
| + | uint32_t X1, uint32_t Y1, uint32_t X2, uint32_t Y2); | ||
| + | |||
| + | extern int ui_draw_rectangle(void *pUI, UIcolor_t Color, | ||
| + | uint32_t X, uint32_t Y, uint32_t W, uint32_t H); | ||
| + | |||
| + | extern int ui_fill_rectangle(void *pUI, UIcolor_t Color, | ||
| + | uint32_t X, uint32_t Y, uint32_t W, uint32_t H); | ||
| + | |||
| + | extern int ui_clear_screen(void *pUI); | ||
| + | |||
| + | /* | ||
| + | jpg | ||
| + | png | ||
| + | gif | ||
| + | */ | ||
| + | extern int ui_draw_image(void *pUI, char *pImageFile, uint32_t X, uint32_t Y); | ||
| + | |||
| + | /* | ||
| + | 0: No key input or Parameter Error | ||
| + | 1: Key is inputed | ||
| + | */ | ||
| + | extern int ui_key_is_inputed(void *pUI, uint32_t MiliSecondWaitTimeout); | ||
| + | |||
| + | /* | ||
| + | 0: OK | ||
| + | -1: Error | ||
| + | */ | ||
| + | extern int ui_key_get_code(void *pUI, uint32_t *pKeyCode, bool *pIsReleased); | ||
| + | |||
| + | |||
| + | extern int ui_printer_create_surface(void *pUI, uint32_t SurfaceWidth, uint32_t SurfaceHeight); | ||
| + | extern int ui_printer_font_set(void *pUI, char *pFontFile, int FontSize); | ||
| + | extern int ui_printer_font_get_line_height(void *pUI, uint32_t *pLineHeight); | ||
| + | extern int ui_printer_string(void *pUI, | ||
| + | char *pString, | ||
| + | UItextLayout_t UItextLayout, | ||
| + | uint8_t *pImageBuffer, | ||
| + | uint32_t ByteSizeOfImageBufferWidth, | ||
| + | uint32_t ByteSizeOfImageBufferHeight); | ||
| + | |||
| + | |||
| + | #endif /* __UI_H__ */ | ||
| </code> | </code> | ||