Ryo Hagimoto / Mbed OS GR-PEACH_HVC-P2_sample_20180314

Dependencies:   GraphicsFramework GR-PEACH_video LCD_shield_config AsciiFont R_BSP USBHost_custom

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "DisplayBace.h"
00003 #include "rtos.h"
00004 #include "LCD_shield_config_4_3inch.h"
00005 #include "recognition_proc.h"
00006 #include "touch_proc.h"
00007 
00008 static DisplayBase Display;
00009 static DigitalOut  lcd_pwon(P7_15);
00010 static DigitalOut  lcd_blon(P8_1);
00011 static PwmOut      lcd_cntrst(P8_15);
00012 static Thread      recognitionTask(osPriorityNormal, 1024 * 8);
00013 static Thread      touchTask;
00014 
00015 /****** LCD ******/
00016 static void IntCallbackFunc_LoVsync(DisplayBase::int_type_t int_type) {
00017     /* Interrupt callback function for Vsync interruption */
00018     touch_lcd_int(int_type);
00019 }
00020 
00021 static void Init_LCD_Display(void) {
00022     DisplayBase::graphics_error_t error;
00023     DisplayBase::lcd_config_t lcd_config;
00024     PinName lvds_pin[8] = {
00025         /* data pin */
00026         P5_7, P5_6, P5_5, P5_4, P5_3, P5_2, P5_1, P5_0
00027     };
00028 
00029     lcd_pwon = 0;
00030     lcd_blon = 0;
00031     Thread::wait(100);
00032     lcd_pwon = 1;
00033     lcd_blon = 1;
00034 
00035     Display.Graphics_Lvds_Port_Init(lvds_pin, 8);
00036 
00037     /* Graphics initialization process */
00038     lcd_config = LcdCfgTbl_LCD_shield;
00039     error = Display.Graphics_init(&lcd_config);
00040     if (error != DisplayBase::GRAPHICS_OK) {
00041         printf("Line %d, error %d\n", __LINE__, error);
00042         mbed_die();
00043     }
00044 
00045     /* Interrupt callback function setting (Vsync signal output from scaler 0) */
00046     error = Display.Graphics_Irq_Handler_Set(DisplayBase::INT_TYPE_S0_LO_VSYNC, 0, IntCallbackFunc_LoVsync);
00047     if (error != DisplayBase::GRAPHICS_OK) {
00048         printf("Line %d, error %d\n", __LINE__, error);
00049         mbed_die();
00050     }
00051 }
00052 
00053 /****** main ******/
00054 int main(void) {
00055     /* Initialization of LCD */
00056     Init_LCD_Display();
00057 
00058     /* Start recognition processing */
00059     recognitionTask.start(callback(recognition_task, &Display));
00060 
00061     /* Start touch panel processing */
00062     touchTask.start(callback(touch_task, &Display));
00063 
00064     /* Backlight on */
00065     Thread::wait(200);
00066     lcd_cntrst.write(1.0);
00067 
00068     /* Wait for the threads to finish */
00069     recognitionTask.join();
00070     touchTask.join();
00071 }