Sample program for communicating with Fujitsuu IoT Platform using HTTP

Dependencies:   AsciiFont GR-PEACH_video GraphicsFramework LCD_shield_config R_BSP USBHost_custom easy-connect-gr-peach mbed-http picojson BM1383GLV KX022 rohm-sensor-hal rohm-bh1745

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,4098);
00067     pc.baud(115200);
00068     printf("Start.\n");
00069 
00070     /* Initialization of LCD */
00071 #ifdef USE_SENSOR_SHIELD
00072     /* For fixing the direction of LCD output when using Sensor Shield and HVC-P2 together */
00073     D_D0 = 1;
00074     D_D1 = 1;
00075 #endif
00076 
00077 #ifdef USE_HVC_P2
00078     Init_LCD_Display();
00079 
00080     /* Start recognition processing */
00081     recognitionTask.start(callback(recognition_task, &Display));
00082 
00083     /* Start touch panel processing */
00084     touchTask.start(callback(touch_task, &Display));
00085 #endif // USE_HVC_P2
00086 
00087     /* Start IOT ready processing */
00088     iotReadyTask->start(callback(iot_ready_task));
00089 
00090 #ifdef USE_HVC_P2
00091     /* Backlight on */
00092     Thread::wait(200);
00093     lcd_cntrst.write(1.0);
00094 
00095     /* Wait for the threads to finish */
00096     recognitionTask.join();
00097     touchTask.join();
00098 #endif // USE_HVC_P2
00099     iotReadyTask->join();
00100 }