Sample program that can send the recognition data from HVC-P2 to Fujitsu IoT Platform using REST (HTTP)

Dependencies:   AsciiFont GR-PEACH_video GraphicsFramework LCD_shield_config R_BSP USBHost_custom easy-connect-gr-peach mbed-http picojson

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 #include "iot_platform.h"
00008 
00009 static DisplayBase Display;
00010 static DigitalOut  lcd_pwon(P7_15);
00011 static DigitalOut  lcd_blon(P8_1);
00012 static PwmOut      lcd_cntrst(P8_15);
00013 static Thread      recognitionTask;
00014 static Thread      touchTask;
00015 
00016 extern void iot_ready_task(void);
00017 
00018 Serial pc(USBTX, USBRX);
00019 DigitalOut D_D0(P2_14);
00020 DigitalOut D_D1(P2_15);
00021 
00022 /****** LCD ******/
00023 static void IntCallbackFunc_LoVsync(DisplayBase::int_type_t int_type)
00024 {
00025     /* Interrupt callback function for Vsync interruption */
00026     touch_lcd_int(int_type);
00027 }
00028 
00029 static void Init_LCD_Display(void)
00030 {
00031     DisplayBase::graphics_error_t error;
00032     DisplayBase::lcd_config_t lcd_config;
00033     PinName lvds_pin[8] = {
00034         /* data pin */
00035         P5_7, P5_6, P5_5, P5_4, P5_3, P5_2, P5_1, P5_0
00036     };
00037 
00038     lcd_pwon = 0;
00039     lcd_blon = 0;
00040     Thread::wait(100);
00041     lcd_pwon = 1;
00042     lcd_blon = 1;
00043 
00044     Display.Graphics_Lvds_Port_Init(lvds_pin, 8);
00045 
00046     /* Graphics initialization process */
00047     lcd_config = LcdCfgTbl_LCD_shield;
00048     error = Display.Graphics_init(&lcd_config);
00049     if (error != DisplayBase::GRAPHICS_OK) {
00050         printf("Line %d, error %d\n", __LINE__, error);
00051         mbed_die();
00052     }
00053 
00054     /* Interrupt callback function setting (Vsync signal output from scaler 0) */
00055     error = Display.Graphics_Irq_Handler_Set(DisplayBase::INT_TYPE_S0_LO_VSYNC, 0, IntCallbackFunc_LoVsync);
00056     if (error != DisplayBase::GRAPHICS_OK) {
00057         printf("Line %d, error %d\n", __LINE__, error);
00058         mbed_die();
00059     }
00060 }
00061 
00062 /****** main ******/
00063 int main(void)
00064 {
00065 
00066     Thread *iotReadyTask = new Thread(osPriorityNormal, 4 * 1024);
00067     pc.baud(115200);
00068     printf("Start.\n");
00069 
00070     /* Initialization of LCD */
00071     D_D0 = 1;
00072     D_D1 = 1;
00073 
00074     Init_LCD_Display();
00075 
00076     /* Start recognition processing */
00077     recognitionTask.start(callback(recognition_task, &Display));
00078 
00079     /* Start touch panel processing */
00080     touchTask.start(callback(touch_task, &Display));
00081 
00082     /* Start IOT ready processing */
00083     iotReadyTask->start(callback(iot_ready_task));
00084 
00085     /* Backlight on */
00086     Thread::wait(200);
00087     lcd_cntrst.write(1.0);
00088 
00089     /* Wait for the threads to finish */
00090     recognitionTask.join();
00091     touchTask.join();
00092     iotReadyTask->join();
00093 }