|

楼主 |
发表于 2017-8-11 09:42:38
|
显示全部楼层
嗯 是OLED,移植参考你那篇 OLED上面移植STemWin5.20应用代码如下,谢谢版主- /*********************************************************************
- * *
- * SEGGER Microcontroller GmbH & Co. KG *
- * Solutions for real time microcontroller applications *
- * *
- **********************************************************************
- * *
- * C-file generated by: *
- * *
- * GUI_Builder for emWin version 5.32 *
- * Compiled Oct 8 2015, 11:59:02 *
- * (c) 2015 Segger Microcontroller GmbH & Co. KG *
- * *
- **********************************************************************
- * *
- * Internet: www.segger.com Support: support@segger.com *
- * *
- **********************************************************************
- */
- // USER START (Optionally insert additional includes)
- // USER END
- //#include "DIALOG.h"
- //#include "MainTask.h"
- #include "GUI.h"
- #include "WM.h"
- #include "BUTTON.h"
- #include "CHECKBOX.h"
- #include "DROPDOWN.h"
- #include "EDIT.h"
- #include "FRAMEWIN.h"
- #include "LISTBOX.h"
- #include "MULTIEDIT.h"
- #include "RADIO.h"
- #include "SLIDER.h"
- #include "TEXT.h"
- #include "PROGBAR.h"
- #include "SCROLLBAR.h"
- #include "LISTVIEW.h"
- #include "GRAPH.h"
- #include "MENU.h"
- #include "MULTIPAGE.h"
- #include "ICONVIEW.h"
- #include "TREEVIEW.h"
- #include <stdlib.h>
- #include "stddef.h"
- /*********************************************************************
- *
- * Defines
- *
- **********************************************************************
- */
- #define ID_FRAMEWIN_0 (GUI_ID_USER + 0x00)
- #define ID_SCROLLBAR_0 (GUI_ID_USER + 0x01)
- #define ID_LISTBOX_0 (GUI_ID_USER + 0x02)
- #define ID_LISTBOX_1 (GUI_ID_USER + 0x03)
- // #define WM_UP_FOCUS (WM_USER + 0x00)
- // #define WM_DOWN_FOCUS (WM_USER + 0x01)
- // #define MSG_NextMusic (WM_USER + 0x32)
- #define ID_TIMER_HSCROLL 0
- #define ID_TIMER_ADD_WIFIAP 1
- #define TOTAL_ITEMS 20
- #define WM_UP_FOCUS (WM_USER + 0x00)
- #define WM_DOWN_FOCUS (WM_USER + 0x01)
- typedef enum {LEFT_SCROLL = 0, RIGHT_SCROLL = !LEFT_SCROLL} dir_scroll_enum;
- dir_scroll_enum dir_scroll = RIGHT_SCROLL;
- typedef char uint8_t;
- typedef struct message_wifi_ap
- {
- uint8_t encryption; // wifi-ap Encryption
- uint8_t name[20]; // wifi-ap ssid
- uint8_t rssi; // wifi-ap rssi
- uint8_t mac[17]; // wifi-ap MAC address
- uint8_t ch; // wifi-ap ch
- uint8_t freq_offset; // wifi-ap freq_offset
- uint8_t freq_calibration; // wifi-ap freq_calibration
- }message_wifi_ap_def;
- // USER START (Optionally insert additional defines)
- // USER END
- message_wifi_ap_def *p_message_display_wifi_ap = NULL;
- message_wifi_ap_def message_display_wifi_ap[TOTAL_ITEMS];
- WM_HWIN hwin_wifi;
- /*********************************************************************
- *
- * Static data
- *
- **********************************************************************
- */
- // USER START (Optionally insert additional static data)
- // USER END
- /*********************************************************************
- *
- *
- */
- // struct message_focus_listbox* creat_struct_message_focus_listbox(uint8_t len)
- // {
- // struct message_focus_listbox *message_focus_listbox = (struct message_focus_listbox *)malloc (sizeof (struct message_focus_listbox) * len);
- // return message_focus_listbox;
- // }
- /*********************************************************************
- *
- * Static data
- *
- **********************************************************************
- */
- // USER START (Optionally insert additional static data)
- // USER END
- /*********************************************************************
- *
- * _aDialogCreate
- */
- static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
- { FRAMEWIN_CreateIndirect, "Framewin", ID_FRAMEWIN_0, 0, 0, 128, 64, 0, 0x64, 0 },
- { LISTBOX_CreateIndirect, "Listbox", ID_LISTBOX_0, 0, 0, 118, 16, 0, 0x0, 0 },
- { LISTBOX_CreateIndirect, "Listbox", ID_LISTBOX_1, 0, 17, 118, 16, 0, 0x0, 0 },
- { SCROLLBAR_CreateIndirect, "Scrollbar", ID_SCROLLBAR_0, 0, 37, 118, 8, 0, 0x0, 0 },
- // USER START (Optionally insert additional widgets)
- // USER END
- };
- /*********************************************************************
- *
- * Static code
- *
- **********************************************************************
- */
- // USER START (Optionally insert additional static code)
- // USER END
- /*********************************************************************
- *
- * _cbDialog
- */
- static void _cbDialog(WM_MESSAGE * pMsg)
- {
- WM_HWIN hItem;
- int NCode;
- int Id;
- static int last_id;
- //
- static int current_operated_listbox;
- static int current_index_item_vscroll = 1; // current_index_item_vscroll
- /* user for hscroll*/
- static int current_selected_item_hscroll_total_steps; // current_selected_item_hscroll_total_steps
- static int current_selected_item_hscroll_real_time_steps;
- static int last_selected_item_hscroll_real_time_steps;
- char buf[20];
- // USER START (Optionally insert additional variables)
- // USER END
- switch (pMsg->MsgId)
- {
- case WM_INIT_DIALOG:
- // Initialization of 'ID_TIMER_HSCROLL'
- WM_CreateTimer(WM_GetClientWindow(pMsg->hWin), ID_TIMER_HSCROLL, 1000, 0);
- WM_CreateTimer(WM_GetClientWindow(pMsg->hWin), ID_TIMER_ADD_WIFIAP, 500, 0);
- //
- // Initialization of 'Framewin'
- //
- hItem = pMsg->hWin;
- FRAMEWIN_SetText(hItem, "Wi-Fi");
- FRAMEWIN_SetFont(hItem, GUI_FONT_10_ASCII);
- FRAMEWIN_AddCloseButton(hItem, FRAMEWIN_BUTTON_RIGHT, 0);
- //
- // Initialization of 'Listbox'
- //
- hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0);
- LISTBOX_SetFont(hItem,GUI_FONT_16B_ASCII);
- LISTBOX_AddString(hItem, "Item01234567890123456789");
- //
- // Initialization of 'Listbox'
- //
- hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_1);
- LISTBOX_SetFont(hItem,GUI_FONT_16B_ASCII);
- LISTBOX_AddString(hItem, "Item01234567890123456789");
-
- //
- // Initialization of 'Scrollbar'
- //
- //hItem = WM_GetDialogItem(pMsg->hWin, ID_SCROLLBAR_0);
- // 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_LISTBOX_0: // Notifications sent by 'Listbox'
- 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_SEL_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
- case ID_LISTBOX_1: // Notifications sent by 'Listbox'
- 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_SEL_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
- case ID_SCROLLBAR_0: // Notifications sent by 'Listbox'
- 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_SCROLLBAR_ADDED:
- // 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;
- }
- break;
- // USER START (Optionally insert additional message handling)
- // USER END
- case WM_KEY:
- Id = ((WM_KEY_INFO*)(pMsg->Data.p))->Key;
- switch(Id)
- {
- case GUI_KEY_ENTER: // Notifications sent by 'GUI_KEY_ENTER'
- //current_selected_item = LISTBOX_GetSel(WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0)) + 1;
- printf("GUI_KEY_ENTER\\r\\n");
- break;
- // USER START (Optionally insert additional code for further Ids)
- // USER END
- }
- break;
- // USER START (Optionally insert additional message handling)
- // USER END
- case WM_UP_FOCUS:
- // USER START (Optionally insert additional code for further Ids)
- // USER END
- // read current focus listbox
- Id = WM_GetId(WM_GetFocussedWindow());
- if(Id == ID_LISTBOX_1)
- {
- printf("focus listbox ID_LISTBOX_0\\r\\n");
- hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0);
- WM_SetFocus(hItem);
- }
- current_index_item_vscroll--;
- printf("current_index_item_vscroll = %d",current_index_item_vscroll);
- if(current_index_item_vscroll == 0)
- {
- current_index_item_vscroll = 20;
- }
- hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_1);
- LISTBOX_AddString(hItem, (const char*)(p_message_display_wifi_ap->name));
- p_message_display_wifi_ap = &message_display_wifi_ap[current_index_item_vscroll];
- hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0);
- LISTBOX_AddString(hItem, (const char*)(p_message_display_wifi_ap->name));
- break;
- // USER START (Optionally insert additional message handling)
- // USER END
- case WM_DOWN_FOCUS:
- // USER START (Optionally insert additional code for further Ids)
- // USER END
- // read current focus listbox
- Id = WM_GetId(WM_GetFocussedWindow());
- if(Id == ID_LISTBOX_0)
- {
- printf("focus listbox ID_LISTBOX_1\\r\\n");
- hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_1);
- WM_SetFocus(hItem);
- }
- current_index_item_vscroll++;
- printf("current_index_item_vscroll = %d",current_index_item_vscroll);
- if(current_index_item_vscroll == 21)
- {
- current_index_item_vscroll = 1;
- }
- hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_0);
- LISTBOX_AddString(hItem, (const char*)(p_message_display_wifi_ap->name));
- p_message_display_wifi_ap = &message_display_wifi_ap[current_index_item_vscroll];
- hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTBOX_1);
- LISTBOX_AddString(hItem, (const char*)(p_message_display_wifi_ap->name));
- break;
- // USER START (Optionally insert additional message handling)
- // USER END
- case WM_TIMER:
- Id = WM_GetTimerId(pMsg->Data.v);
- switch (Id)
- {
- case ID_TIMER_HSCROLL:
- hItem = WM_GetFocussedWindow();
- Id = WM_GetId(hItem);
- LISTBOX_SetAutoScrollH(hItem,1);
- if(last_id != Id)
- {
- LISTBOX_SetScrollStepH(hItem,1000);
- GUI_SendKeyMsg(GUI_KEY_RIGHT, 1);
- current_selected_item_hscroll_total_steps = WM_GetScrollPosH(WM_GetDialogItem(pMsg->hWin, Id));
- LISTBOX_SetScrollStepH(hItem,1);
- SCROLLBAR_SetNumItems(WM_GetDialogItem(pMsg->hWin, ID_SCROLLBAR_0),current_selected_item_hscroll_total_steps + 10);
- printf("current_selected_item_hscroll_total_steps =%d\\r\\n", current_selected_item_hscroll_total_steps + 10);
- last_id = Id;
- }
- LISTBOX_SetAutoScrollH(hItem,0);
- if(dir_scroll)
- {
- SCROLLBAR_Inc(WM_GetDialogItem(pMsg->hWin, ID_SCROLLBAR_0));
- GUI_SendKeyMsg(GUI_KEY_RIGHT, 1);
- }else{
- SCROLLBAR_Dec(WM_GetDialogItem(pMsg->hWin, ID_SCROLLBAR_0));
- GUI_SendKeyMsg(GUI_KEY_LEFT, 1);
- }
- current_selected_item_hscroll_real_time_steps = WM_GetScrollPosH(WM_GetDialogItem(pMsg->hWin, Id));
- //printf("current_selected_item_hscroll_real_time_steps =%d\\r\\n", current_selected_item_hscroll_real_time_steps);
- if(last_selected_item_hscroll_real_time_steps == current_selected_item_hscroll_real_time_steps)
- {
- //dir_scroll = !dir_scroll;
- //printf("current_hscroll_real_time_steps = %d\\r\\n",current_hscroll_real_time_steps);
- WM_SetScrollPosH(WM_GetDialogItem(pMsg->hWin, Id),0);
- SCROLLBAR_AddValue(WM_GetDialogItem(pMsg->hWin, ID_SCROLLBAR_0),-1000);
- }
- else{
- last_selected_item_hscroll_real_time_steps = current_selected_item_hscroll_real_time_steps;
- }
- sprintf(buf, "Wi-Fi %d/%d",current_index_item_vscroll,TOTAL_ITEMS);
- FRAMEWIN_SetText(pMsg->hWin, buf);
- printf("current_index_item_vscroll = %d\\r\\n",current_index_item_vscroll);
- WM_RestartTimer(pMsg->Data.v, 1000);
- break;
- case ID_TIMER_ADD_WIFIAP:
- WM_RestartTimer(pMsg->Data.v, 500);
- break;
- }
- break;
- // USER START (Optionally insert additional message handling)
- // USER END
- default:
- WM_DefaultProc(pMsg);
- break;
- }
- }
- /*********************************************************************
- *
- * Public code
- *
- **********************************************************************
- */
- /*********************************************************************
- *
- * CreateFramewin
- */
- void CreateFramewin(void);
- void CreateFramewin(void) {
- hwin_wifi = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), &_cbDialog, WM_HBKWIN, 0, 0);
- }
- // USER START (Optionally insert additional public code)
- // USER END
- void MainTask(void)
- {
- // message of current focus listbox len = 20
- //p_message_focus_listbox = creat_struct_message_focus_listbox(20);
- /* emwin init */
- GUI_Init();
- /* create wm */
- CreateFramewin();
- WM_SetCallback(WM_HBKWIN, _cbDialog);
- //WM_SendMessageNoPara(WM_HBKWIN,WM_INIT_DIALOG);
- // Open Multiple Buffering
- //WM_MULTIBUF_Enable(1);
-
- /* Use memory devices for all windows */
- //WM_MOTION_Enable(1);
- //WM_MOTION_SetDefaultPeriod(1000);
- WM_SetCreateFlags(WM_CF_MEMDEV);
- WM_EnableMemdev(hwin_wifi);
-
- while(1)
- {
- GUI_Delay(10);
- //printf("MainTask\\r\\n");
- }
- }
- /*************************** End of file ****************************/
复制代码 |
|