Exemple #1
0
/*******************************************************************************
* Function Name  : main.
* Description    : Main routine.
* Input          : None.
* Output         : None.
* Return         : None.
*******************************************************************************/
int main(void)
{

/* ================================================================ */
/* Board Initializations and Configurations except OLED             */
/* (clocks, I/Os, on-chip peripherals, on-board ICs)                */
/* ================================================================ */

    LBF_Board_Init();

    Red_Led_ON();

/* ================================================================ */
/* Optional initialization of Middleware libraries :                */
/* USBD drivers, FatFS File System, STemWin GUI                     */
/* ================================================================ */

    // UNCOMMENT IF YOU WELL BE USING ...:
  
    /* ... La BlueFrog as USB Mass Storage (Full Speed)             */
    /*     (based on ST-provided stack part of STM32 Cube offering  */
    // Delay_ms(1000);
    // LBF_LaunchUSB_MassStorage();
 
    /* ... the FAT File System (FatFS)                              */
    /*     (based on ChanN's FatFS included in STM32 Cube offering) */
    // LBF_FatFS_Init();

    /* ... the STemWin Graphical Library                            */
    /*     (based on Segger's emWin included in STM32 Cube offering)*/
    LBF_emWin_Init();


    Red_Led_OFF();



/* ================================================================ */
/*   Application Code Below                                         */
/* ================================================================ */

/* ==  User Declarations ========================================== */

uint16_t fconfig[11];  // configuration file to control some OLED parameters
GUI_MEMDEV_Handle hMemDevice;  //handle to a memory device


/* ==  Body              ========================================== */

   fconfig[0]=0xFFFF;  // to use default settings
   LBF_OLED_Init(fconfig);  
        //sets up OLED register and powers on OLED VDDH(13V) 


   OLED_Fill(0, 0, 160, 128, CYAN);

   Red_Led_ON();


  /*** Start Demo *******************************************************/

  /* Different options posible */ 
  /* Use Display Cache or Use Memory Device or use Banded Memory Device */
  /* With 32K SRAM only the latter allows to cover full screen */


  // =============================================================
  // == Using the dislay cache  ==================================

  // Usage of display cache can be enabled through parameters of function 
  // GUIDRV_FlexColor_SetFunc() called in LCDConf_FlexColor_LBF.c
  // found in library LBF_STemWin

  // !!! ISSUE !!!
  // XSIZE_PHYS x YSIZE_PHYS (defined in above files) need to be set to 160x128 
  // to hold full display. However at 16bpp that represents about 40BK
  // but available SRAM is only 32KB...
  // Work-Around: define a smaller display cache (XSIZE_PHYS, YSIZE_PHYS)
  // -- but will not allow to address full screen

  // Not much interest vs use of "Memory Device", below, anyway
/*
  GUI_SetFont(&GUI_Font20_1);
  GUI_SetTextMode(GUI_TM_TRANS);  // write with transparent background
  GUI_DispStringAt("Hello from La BlueFrog !", LCD_GetXSize()/8, LCD_GetYSize()/2);  
  Green_Led_ON();
*/


  // =============================================================
  // == Using a "Memory Device"  (refer to emWin documentation) 

  // Work with a centered 128x64 window    
  // (cannot cover full screen for same memory limitation as above)
  #define X_FULL_SCREEN  160
  #define Y_FULL_SCREEN  128
  #define MD_X_LEFT  (X_FULL_SCREEN -128)/2
  #define MD_X_RIGHT  160-MD_X_LEFT
  #define MD_Y_TOP   (Y_FULL_SCREEN -64)/2
  #define MD_Y_BOT    128-MD_Y_TOP


  // Create Memory Device (top left & bottom right coordinates) on Layer 0:
  GUI_SelectLayer(0);
  hMemDevice = GUI_MEMDEV_Create(MD_X_LEFT, MD_Y_TOP,  (MD_X_RIGHT-MD_X_LEFT+1), (MD_Y_BOT-MD_Y_TOP+1) );
      // Caution: 
      // Memory allocated by GUI_X_Config in GUIConf_LBF.c must be sufficient to fit MemDevice buffer
      // plus other needs of emWin
      // Else GUI_MEMDEV_Create will fail (returns 0) and operations will be done directly to screen

  // Activate it: 
  GUI_MEMDEV_Select(hMemDevice);

  // Draw Stuff   (refer to emWin documentation)
  GUI_DrawGradientRoundedH( MD_X_LEFT, MD_Y_TOP,  MD_X_RIGHT, MD_Y_BOT, 
                            10, // rounded corner radius
                            0xFF0000, 0xFFFF00); // red to yellow
  GUI_SetPenSize(6);
  GUI_DrawLine(MD_X_LEFT, MD_Y_TOP, MD_X_RIGHT, MD_Y_BOT);
  GUI_DrawLine(MD_X_LEFT, MD_Y_BOT, MD_X_RIGHT, MD_Y_TOP);

  GUI_SetFont(&GUI_Font13_1);
  GUI_SetColor(GUI_BLACK);
  GUI_SetTextMode(GUI_TM_TRANS);  // write with transparent background
  GUI_DispStringAt("Hello !\n", MD_X_LEFT+10, MD_Y_TOP+10 );  

  // Copy to display
  GUI_MEMDEV_CopyToLCD(hMemDevice);

  // Free memory
  GUI_MEMDEV_Delete(hMemDevice);


  // =============================================================
  // == Using a "Banded Memory Device"  (refer to emWin documentation) 
  // == (Banding, aka tiling, allows to cover full screen by processing
  // ==  a number of bands successively)

  //TODO
  // use function: GUI_MEMDEV_Draw (GUI_RECT * pRect, GUI_CALLBACK_VOID_P * pfDraw, 
  //                 void* pData, int NumLines, int Flags);



while(1);

 
}
Exemple #2
0
/*********************************************************************
*
*       _cbDialog
*/
static void _cbDialog(WM_MESSAGE * pMsg)
{
    WM_HWIN hItem;
    int     NCode;
    int     Id;
    // USER START (Optionally insert additional variables)
    // USER END
    GUI_DrawBitmap(&bmlogo,40,10);
#if(Gradient_Rectangle)
    {
        GUI_DrawGradientRoundedH(220,120,580,380,20,REC_color1,REC_color2);
    }
#endif

#if(RoundedFrame)
    GUI_SetColor(GUI_GREEN);
    GUI_DrawRoundedFrame(218,118,582,382,20,3);
#endif

#if(FillRoundedRect)
    GUI_SetColor(RoundedRect);
    GUI_FillRoundedRect(220,120,580,380,20);
#endif

    switch (pMsg->MsgId)
        {
        case WM_INIT_DIALOG:
            //
            // Initialization of 'inuse'
            //


            hItem = pMsg->hWin;
            FRAMEWIN_SetTitleVis(hItem, 0);
            FRAMEWIN_SetClientColor( hItem, framewin_backcolor);
            FRAMEWIN_SetFont(hItem, GUI_FONT_8_1);
            FRAMEWIN_SetText(hItem, "Framewin");
            FRAMEWIN_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
            FRAMEWIN_SetTextColor(hItem, 0x00000000);


            hItem = pMsg->hWin;
            FRAMEWIN_SetTitleVis(hItem, 0);

            hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_1);
            BUTTON_SetFont(hItem, &GUI_Fonthz_song30);
            BUTTON_SetText(hItem, "返回 ");
#if(Button_3Dskin)
            BUTTON_SetSkin(hItem,BUTTON_SKIN_FLEX);
#endif
#if(!Button_3Dskin)
            BUTTON_SetBkColor( hItem,BUTTON_CI_UNPRESSED,Button_unpress_color);
            BUTTON_SetBkColor( hItem,BUTTON_CI_PRESSED,Button_press_color);
#endif

            //
            // Initialization of 'Button'
            //
            hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_0);
            BUTTON_SetFont(hItem, &GUI_Fonthz_song30);
            BUTTON_SetText(hItem, "停止充电 ");
#if(Button_3Dskin)
            BUTTON_SetSkin(hItem,BUTTON_SKIN_FLEX);
#endif
#if(!Button_3Dskin)
            BUTTON_SetBkColor( hItem,BUTTON_CI_UNPRESSED,Button_unpress_color);
            BUTTON_SetBkColor( hItem,BUTTON_CI_PRESSED,Button_press_color);
#endif
            //
            // Initialization of 'Button'
            //
            //
            // Initialization of 'Edit'
            //
            hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_0);
            EDIT_EnableBlink( hItem,1 ,0);
            EDIT_SetDecMode(hItem,0,0,99,0,0);
            EDIT_SetFont(hItem, GUI_FONT_32_ASCII);
            EDIT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
            //
            // Initialization of 'Edit'
            //
            hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_1);
            EDIT_EnableBlink( hItem,1 ,0);
            EDIT_SetDecMode(hItem,0,0,99,0,0);
            EDIT_SetFont(hItem, GUI_FONT_32_ASCII);
            EDIT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
            EDIT_SetTextColor(hItem, EDIT_CI_ENABLED, 0x00000000);
            //
            // Initialization of 'Edit'
            //
            hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_2);
            EDIT_EnableBlink( hItem,1 ,0);
            EDIT_SetDecMode(hItem,0,0,99,0,0);
            EDIT_SetFont(hItem, GUI_FONT_32_ASCII);
            EDIT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
            EDIT_SetTextColor(hItem, EDIT_CI_ENABLED, 0x00000000);
            //
            // Initialization of 'Edit'
            //
            hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_3);
            EDIT_EnableBlink( hItem,1 ,0);
            EDIT_SetDecMode(hItem,0,0,9999,0,0);
            EDIT_SetFont(hItem, GUI_FONT_32_ASCII);
            EDIT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
            EDIT_SetTextColor(hItem, EDIT_CI_ENABLED, 0x00000000);
            //
            // Initialization of 'cddianliang'
            //
            hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0);
            TEXT_SetFont(hItem, &GUI_Fonthz_song24);

            TEXT_SetText(hItem, "使用电量 ");
            TEXT_SetTextAlign(hItem, GUI_TA_RIGHT);
            TEXT_SetTextColor(hItem, 0x00000000);
            //
            // Initialization of 'Text'
            //
            hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1);
            TEXT_SetFont(hItem, &GUI_Fonthz_song24);

            TEXT_SetText(hItem, "使用时间 ");
            TEXT_SetTextColor(hItem, 0x00000000);
            TEXT_SetTextAlign(hItem, GUI_TA_RIGHT);
            //
            // Initialization of 'Text'
            //
            hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_2);
            TEXT_SetFont(hItem, &GUI_Fonthz_song24);

            TEXT_SetText(hItem, "消费金额 ");
            TEXT_SetTextAlign(hItem, GUI_TA_RIGHT);
            TEXT_SetTextColor(hItem, 0x00000000);
            //
            // Initialization of 'Text'
            //
            hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_3);
            TEXT_SetFont(hItem, &GUI_Fonthz_song24);

            TEXT_SetText(hItem, "账户余额 ");
            TEXT_SetTextAlign(hItem, GUI_TA_RIGHT);
            TEXT_SetTextColor(hItem, 0x00000000);

            hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_4);
            TEXT_SetTextAlign(hItem, GUI_TA_LEFT | GUI_TA_TOP);
            TEXT_SetText(hItem, "安徽绿建科技有限公司 ");
            TEXT_SetTextColor(hItem, 0x00000000);
            TEXT_SetFont(hItem, &GUI_FontSong_60);
            //
            // Initialization of 'Text'
            //
            hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_5);
            TEXT_SetTextAlign(hItem, GUI_TA_LEFT | GUI_TA_TOP);
            TEXT_SetTextColor(hItem, 0x00000000);
            TEXT_SetText(hItem, "ANHUI GREEN BUILDING TECHNOLOGY CO.,LTD.");
            TEXT_SetFont(hItem, GUI_FONT_24_ASCII);
            // USER START (Optionally insert additional code for further widget initialization)
            // USER END
            break;
        case WM_NOTIFY_PARENT:
            Id    = WM_GetId(pMsg->hWinSrc);
            NCode = pMsg->Data.v;
            switch(Id)
                {
                case ID_BUTTON_0: // Notifications sent by 'Button'
                    switch(NCode)
                        {
                        case WM_NOTIFICATION_CLICKED:
                            // USER START (Optionally insert code for reacting on notification message)
                            // USER END
                            break;
                        case WM_NOTIFICATION_RELEASED:
                            // USER START (Optionally insert code for reacting on notification message)
                            // USER END
//                        op=ensure;
//                        handle_button();
                        
                        GUI_EndDialog( pMsg->hWin,1);
                        Createensure();
                            break;
                            // USER START (Optionally insert additional code for further notification handling)
                            // USER END
                        }
                    break;
                case ID_BUTTON_1: // Notifications sent by 'Button'
                    switch(NCode)
                        {
                        case WM_NOTIFICATION_CLICKED:
                            // USER START (Optionally insert code for reacting on notification message)
                            // USER END
                            break;
                        case WM_NOTIFICATION_RELEASED:
                            // USER START (Optionally insert code for reacting on notification message)
                            // USER END
                            GUI_EndDialog( pMsg->hWin,1);
                            Createwindow0();
                            break;
                            // USER START (Optionally insert additional code for further notification handling)
                            // USER END
                        }
                    break;
                case ID_EDIT_0: // Notifications sent by 'Edit'
                    switch(NCode)
                        {
                        case WM_NOTIFICATION_CLICKED:
                            // USER START (Optionally insert code for reacting on notification message)
                            // USER END
                            break;
                        case WM_NOTIFICATION_RELEASED:
                            // USER START (Optionally insert code for reacting on notification message)
                            // USER END
                            break;
                        case WM_NOTIFICATION_VALUE_CHANGED:
                            // USER START (Optionally insert code for reacting on notification message)
                            // USER END
                            break;
                            // USER START (Optionally insert additional code for further notification handling)
                            // USER END
                        }
                    break;
                case ID_EDIT_1: // Notifications sent by 'Edit'
                    switch(NCode)
                        {
                        case WM_NOTIFICATION_CLICKED:
                            // USER START (Optionally insert code for reacting on notification message)
                            // USER END
                            break;
                        case WM_NOTIFICATION_RELEASED:
                            // USER START (Optionally insert code for reacting on notification message)
                            // USER END
                            break;
                        case WM_NOTIFICATION_VALUE_CHANGED:
                            // USER START (Optionally insert code for reacting on notification message)
                            // USER END
                            break;
                            // USER START (Optionally insert additional code for further notification handling)
                            // USER END
                        }
                    break;
                case ID_EDIT_2: // Notifications sent by 'Edit'
                    switch(NCode)
                        {
                        case WM_NOTIFICATION_CLICKED:
                            // USER START (Optionally insert code for reacting on notification message)
                            // USER END
                            break;
                        case WM_NOTIFICATION_RELEASED:
                            // USER START (Optionally insert code for reacting on notification message)
                            // USER END
                            break;
                        case WM_NOTIFICATION_VALUE_CHANGED:
                            // USER START (Optionally insert code for reacting on notification message)
                            // USER END
                            break;
                            // USER START (Optionally insert additional code for further notification handling)
                            // USER END
                        }
                    break;
                case ID_EDIT_3: // Notifications sent by 'Edit'
                    switch(NCode)
                        {
                        case WM_NOTIFICATION_CLICKED:
                            // USER START (Optionally insert code for reacting on notification message)
                            // USER END
                            break;
                        case WM_NOTIFICATION_RELEASED:
                            // USER START (Optionally insert code for reacting on notification message)
                            // USER END
                            break;
                        case WM_NOTIFICATION_VALUE_CHANGED:
                            // USER START (Optionally insert code for reacting on notification message)
                            // USER END
                            break;
                            // USER START (Optionally insert additional code for further notification handling)
                            // USER END
                        }
                    break;
                    // USER START (Optionally insert additional code for further Ids)
                    // USER END
                }
            break;
            // USER START (Optionally insert additional message handling)
            // USER END
        default:
            WM_DefaultProc(pMsg);
            break;
        }
}
/*********************************************************************
*
*       _cbDialog
*/
static void _cbDialog(WM_MESSAGE * pMsg)
{
    WM_HWIN hItem;
    int     NCode;
    int     Id;
    // USER START (Optionally insert additional variables)
    // USER END
    GUI_DrawBitmap(&bmlogo,40,10);
#if(Gradient_Rectangle)
    {
        GUI_DrawGradientRoundedH(220,120,580,380,20,REC_color1,REC_color2);
    }
#endif

#if(RoundedFrame)
    GUI_SetColor(GUI_GREEN);
    GUI_DrawRoundedFrame(218,118,582,382,20,3);
#endif

#if(FillRoundedRect)
    GUI_SetColor(RoundedRect);
    GUI_FillRoundedRect(220,120,580,380,20);
#endif

    switch (pMsg->MsgId)
        {
        case WM_INIT_DIALOG:
            //
            // Initialization of 'ICcard'
            //
            hItem = pMsg->hWin;
            FRAMEWIN_SetTitleVis(hItem, 0);
            FRAMEWIN_SetClientColor( hItem, BACKCOLOR);
            FRAMEWIN_SetFont(hItem, GUI_FONT_8_1);
            FRAMEWIN_SetText(hItem, "Framewin");
            FRAMEWIN_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
            FRAMEWIN_SetTextColor(hItem, 0x00000000);
            //
            // Initialization of 'Button'
            //
//    hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_0);
//    BUTTON_SetFont(hItem, &GUI_Fonthz_song30);
//    BUTTON_SetText(hItem, "返回 ");
//  #if(Button_3Dskin)
//            BUTTON_SetSkin(hItem,BUTTON_SKIN_FLEX);
//#endif
//#if(!Button_3Dskin)
//            BUTTON_SetBkColor( hItem,BUTTON_CI_UNPRESSED,Button_unpress_color);
//            BUTTON_SetBkColor( hItem,BUTTON_CI_PRESSED,Button_press_color);
//#endif
            //
            // Initialization of 'Button'
            //
//            hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_1);
//            BUTTON_SetFont(hItem, GUI_FONT_13_1);
//            BUTTON_SetText(hItem, "exit");
//#if(Button_3Dskin)
//            BUTTON_SetSkin(hItem,BUTTON_SKIN_FLEX);
//#endif
//#if(!Button_3Dskin)
//            BUTTON_SetBkColor( hItem,BUTTON_CI_UNPRESSED,Button_unpress_color);
//            BUTTON_SetBkColor( hItem,BUTTON_CI_PRESSED,Button_press_color);
//#endif
            hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0);
            TEXT_SetTextAlign(hItem, GUI_TA_LEFT | GUI_TA_TOP);
            TEXT_SetText(hItem, "安徽绿建科技有限公司 ");
            TEXT_SetTextColor(hItem, 0x00000000);
            TEXT_SetFont(hItem, &GUI_FontSong_60);
            //
            // Initialization of 'Text'
            //
            hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1);
            TEXT_SetTextAlign(hItem, GUI_TA_LEFT | GUI_TA_TOP);
            TEXT_SetTextColor(hItem, 0x00000000);
            TEXT_SetText(hItem, "ANHUI GREEN BUILDING TECHNOLOGY CO.,LTD.");
            TEXT_SetFont(hItem, GUI_FONT_24_ASCII);

            //
            // Initialization of 'Text'
            //
            hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_2);
            TEXT_SetFont(hItem, &GUI_Fonthz_song30);
            TEXT_SetWrapMode(hItem,GUI_WRAPMODE_WORD);
            TEXT_SetText(hItem, "您好像没有刷卡,系统将在2S后自动退出 ");
            TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
            TEXT_SetTextColor(hItem, 0x00FFFFFF);
            // USER START (Optionally insert additional code for further widget initialization)
            // USER END
            break;
        case WM_NOTIFY_PARENT:
            Id    = WM_GetId(pMsg->hWinSrc);
            NCode = pMsg->Data.v;
            switch(Id)
                {
                case ID_BUTTON_0: // Notifications sent by 'Button'
                    switch(NCode)
                        {
                        case WM_NOTIFICATION_CLICKED:
                            // USER START (Optionally insert code for reacting on notification message)
                            // USER END
                            break;
                        case WM_NOTIFICATION_RELEASED:
                            // USER START (Optionally insert code for reacting on notification message)
                            // USER END
                            break;
                            // USER START (Optionally insert additional code for further notification handling)
                            // USER END
                        }
                    break;
                case ID_BUTTON_1: // Notifications sent by 'Button'
                    switch(NCode)
                        {
                        case WM_NOTIFICATION_CLICKED:
                            // USER START (Optionally insert code for reacting on notification message)
                            // USER END
                            break;
                        case WM_NOTIFICATION_RELEASED:
                            // USER START (Optionally insert code for reacting on notification message)
                            // USER END
                            break;
                            // USER START (Optionally insert additional code for further notification handling)
                            // USER END
                        }
                    break;
                    // USER START (Optionally insert additional code for further Ids)
                    // USER END
                }
            break;
            // USER START (Optionally insert additional message handling)
            // USER END
        default:
            WM_DefaultProc(pMsg);
            break;
        }
}