Jump to content

lijian100

Members
  • Posts

    2
  • Joined

  • Last visited

  1. Hello everyone! Petition bright, I'm a newbie.I'm learning how to use ginput Toggle, my "ginput_lld_toggle_board.h": #define GINPUT_TOGGLE_NUM_PORTS 1 // The total number of toggle inputs #define GINPUT_TOGGLE_CONFIG_ENTRIES 1 // The total number of GToggleConfig entries #define GINPUT_TOGGLE_SW1 0 // Switch 1 #define GINPUT_TOGGLE_DECLARE_STRUCTURE() \ const GToggleConfig GInputToggleConfigTable[GINPUT_TOGGLE_CONFIG_ENTRIES] = { \ {GPIOM, /* Switch 1 */ \ PIN18, \ PIN18, \ 1},} my "ginput_lld_toggle_Pal.c": #if (GFX_USE_GINPUT && GINPUT_NEED_TOGGLE) /*|| defined(__DOXYGEN__)*/ #include "../../../../src/ginput/ginput_driver_toggle.h" GINPUT_TOGGLE_DECLARE_STRUCTURE(); void ginput_lld_toggle_init(const GToggleConfig *ptc) { GPIO_Init(GPIOM, PIN18, 0, 1, 0); // input AND pull_up } unsigned ginput_lld_toggle_getbits(const GToggleConfig *ptc) { return GPIO_GetBit(GPIOM, PIN18); // get_bit 18 } #endif /* GFX_USE_GINPUT && GINPUT_NEED_TOGGLE */ my "main.cpp": //----------------------------uGFX_GINPUT_TOGGLE_TEST--------------------------- template<> OS_PROCESS void TProc1::exec() { GEvent* event; static GListener pl; GSourceHandle upHandle = ginputGetToggle(GINPUT_TOGGLE_SW1); geventListenerInit(&pl); geventAttachSource(&pl, upHandle, GLISTEN_TOGGLE_ON|GLISTEN_TOGGLE_OFF); while(1) { gfxSleepMilliseconds(100); // uGFX_dalay sleep(200); // OS_dalay event = geventEventWait(&pl, 1000); if(event) T++; // test1 is NG! if(GPIO_GetBit(GPIOM, PIN18)) T++; // test2 is OK! } } After GIPIO switch, if(event) did not work. if(GPIO_GetBit(GPIOM, PIN18)) Work properly, How do I implement this test? Sorry for the above text translator's help to me, hope the description is clear, thanks!
×
×
  • Create New...