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提供
このページ内
PDFとしてエクスポート
  1. API
  2. Classes
  3. smplbuf

.get_stream_helper()

前へsmplbuf次へsmplbuf_strm_u8

最終更新 2 年前

Operators and methods by via a that references a smplbuf array of type uint8_t.

smplbuf_u8<32> b;
auto&& bs = b.get_stream_helper(); // helper object

// Data String Generation
uint8_t FOURCHARS[]={'A', 'B', 'C', 'D'};
bs << FOURCHARS;
bs << ';';
bs << uint32_t(0x30313233); // "0123"
bs << format(";%d", 99);

Serial << b << crlf; // Output to Serial via smplbuf_u8<32> class

//Result: ABCD;0123;99

Helper object type names are resolved by auto&& because they are long. The interfaces defined in mwx::stream, such as << operator, can be used for this object.

The generated helper object bs starts reading/writing from the beginning of the main array b when it is created. If it is at the end of the array, data is added by append(). Each time a read/write operation is performed, the position is moved to the next one.

Helper functions can use the >> operator for reading.

//..Continuation of the above example
// ABCD;0123;99 <- stored in b

//Variable for storing read data
uint8_t FOURCHARS_READ[4];
uint32_t u32val_read;
uint8_t c_read[2];

// Read out by operator>>
bs.rewind();                //Rewind the position to the beginning.
bs >> FOURCHARS_READ;      //4 chars
bs >> mwx::null_stream(1); //1 char skipping
bs >> u32val_read;         //32bit data
bs >> mwx::null_stream(1); //1 char skipping
bs >> c_read;              //2 chars

// Result
Serial << crlf << "4chars=" << FOURCHARS_READ;
Serial << crlf << format("32bit val=0x%08x", u32val_read);
Serial << crlf << "2chars=" << c_read;

// 4chars=ABCD
// 32bit val=0x30313233
// 2chars=99
mwx::stream
stream_helper
helper object