MWX Library
latest_en
latest_en
  • The MWX Library
  • revision history
  • About the MWX library
    • License
    • Terms
    • The design policy
  • Install and Build
    • Environment (OS, etc.)
    • Installing the TWELITE SDK
    • Building ACT
    • Creating a new project
    • Installing VSCode
    • Build definition Makefile
    • Other platforms
  • Sample ACTs
    • act0 .. 4
    • Scratch
    • Slp_Wk_and_Tx
    • Parent_MONOSTICK
    • PingPong
    • BRD_APPTWELITE
    • BRD_I2C_TEMPHUMID
    • PAL_AMB
    • PAL_AMB-usenap
    • PAL_AMB-bhv
    • PAL_MAG
    • PAL_MOT-single
    • PAL_MOT-fifo
    • PulseCounter
    • WirelessUART
    • Rcv_Univsl
    • Unit_???
  • API
    • Definition.
    • class object
      • the_twelite
      • Analogue
      • Buttons
      • EEPROM
      • PulseCounter
      • Serial
      • SerialParser
      • SPI
        • SPI (using member functions)
        • SPI (using helper class)
      • TickTimer
      • Timer0 .. 4
      • Wire
        • Wire (using member functions))
        • Wire (using helper class)
    • Classes
      • MWX_APIRET
      • alloc
      • axis_xyzt
      • packet_rx
      • packet_tx
      • serparser
      • pktparser
        • E_PKT
        • idenify_packet_type()
        • TwePacket
          • TwePacketTwelite
          • TwePacketIO
          • TwePacketUART
          • TwePacketPAL
      • smplbuf
        • .get_stream_helper()
        • smplbuf_strm_u8
      • smplque
      • mwx::stream
        • format (mwx::mwx_format)
        • mwx::bigendian
        • mwx::crlf
        • mwx::flush
        • stream_helper
      • SM_SIMPLE state machine
    • Call back functions
      • setup()
      • begin()
      • loop()
      • wakeup()
      • init_coldboot()
      • init_warmboot()
      • on_rx_packet()
      • on_tx_comp()
    • BEHAVIOR
      • PAL_AMB-behavior
    • Functions
      • System Functions
        • millis()
        • delay()
        • delayMicroseconds()
        • random()
      • DIO General purpose IO
        • pinMode()
        • digitalWrite()
        • digitalRead()
        • attachIntDio()
        • detachIntDio()
        • digitalReadBitmap()
      • Utility Functions
        • Printf utils
        • pack_bits()
        • collect_bits()
        • Byte array utils
        • pack_bytes()
        • expand_bytes()
        • CRC8, XOR, LRC
        • div100()
        • Scale utils
        • pnew
    • External Libraries
      • EASTL
  • Board (BRD)
    • <BRD_APPTWELITE>
    • <MONOSTICK>
    • PAL
      • <PAL_AMB>
      • <PAL_MAG>
      • <PAL_MOT>
      • <PAL_NOTICE>
    • <CUE>
  • Sensor Devices (SNS)
    • SHTC3 - Temp/Humd sensor
    • SHT3x - Temp/Humd sensor
    • LTR-308ALS - Luminance Sensor
    • MC3630 - Accel sensor
    • BMx280 - Temp/Humd/Pressure Sensor
    • PCA9632 - LED Driver
  • Network (NWK)
    • Simple Relay Net <NWK_SIMPLE>
    • Layered Tree Net <NWK_LAYERED>
  • Settings (STG) - Interactive settings mode
    • <STG_STD>
GitBook提供
このページ内
  • Methods
  • setup()
  • begin()
  • end()
  • available()
  • read()
  • About operation
  • Initial value determination
  • Sleep
PDFとしてエクスポート
  1. API
  2. class object

Buttons

Digital input management class (mwx::periph_buttons)

Detects changes in digital inputs. This class detects changes when the same detected value is obtained multiple times. This is useful for reducing the effect of chattering on mechanical buttons.

Methods

setup()

void setup(uint8_t max_history);

The parameter max_history is the maximum number of references that can be set with begin(). Memory is allocated and initialized here.

begin()

void begin(uint32_t bmPortMask,
				   uint8_t u8HistoryCount,
				   uint16_t tick_delta);

Starts the Buttons operation, the first parameter bmPortMask specifies the bitmap of digital inputs to be monitored. bit 0 corresponds to DIO 0, ... , bit N corresponds to DIO N. More than one can be specified: the second u8HistoryCount is the number of times required to confirm the value; the third tick_delta specifies the interval in ms between value checks; the fourth u8HistoryCount is the number of times to confirm the value.

It will take u8HistoryCount*tick_delta[ms] to confirm the value. For example, if u8HistoryCount=5 and tick_delta=4, it will take at least 20ms to confirm the state.

The confirmation is done in the TickTimer event handler. Since it is not an interrupt handler, it is affected by delays in processing, etc., but it is sufficient to suppress chattering of mechanical buttons, etc.

end()

void end()

Terminates the Buttons operation.

available()

inline bool available()

Returns true when a change is detected. It is cleared when read() is executed.

read()

bool read(uint32_t& u32port, uint32_t& u32changed)

Called when u32port becomes available. u32portis the bitmap of the current input DIO andu32changed` is the bitmap of the DIO where the change was detected.

Returns false if Buttons is not working.

About operation

Initial value determination

When Buttons starts to operate, the input status of DIO is not yet determined. When the value is determined, it becomes available. At this time, the MSB (bit31) of the bitmap read by read() is set to 1.

Since this function requires the operation to be determined, it cannot be used to monitor ports whose input values change constantly.

Sleep

If Buttons is in operation before Sleep, it will resume after it is restored. After resumption, initial determination is performed.

前へAnalogue次へEEPROM

最終更新 2 年前