![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
オシロスコープ. このプログラムの説明は,CQ出版社「トランジスタ技術」の2021年10月号から開始された連載記事「STM32マイコンではじめるPC計測」の中にあります.このプログラムといっしょに使うPC側のプログラムについても同誌を参照してください.
Dependencies: Array_Matrix mbed SerialTxRxIntr DSP_ADDA_Dual
XferWaveform.hpp@0:4440ad009afe, 2021-09-09 (annotated)
- Committer:
- MikamiUitOpen
- Date:
- Thu Sep 09 08:47:03 2021 +0000
- Revision:
- 0:4440ad009afe
1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MikamiUitOpen | 0:4440ad009afe | 1 | //--------------------------------------------------------------------- |
MikamiUitOpen | 0:4440ad009afe | 2 | // 波形データを PC へ転送するための XferBase の派生クラス |
MikamiUitOpen | 0:4440ad009afe | 3 | // |
MikamiUitOpen | 0:4440ad009afe | 4 | // 2021/07/11, Copyright (c) 2021 MIKAMI, Naoki |
MikamiUitOpen | 0:4440ad009afe | 5 | //--------------------------------------------------------------------- |
MikamiUitOpen | 0:4440ad009afe | 6 | |
MikamiUitOpen | 0:4440ad009afe | 7 | #include "XferBase.hpp" |
MikamiUitOpen | 0:4440ad009afe | 8 | |
MikamiUitOpen | 0:4440ad009afe | 9 | #ifndef XFER_WAVEFORM_DERIVED_HPP |
MikamiUitOpen | 0:4440ad009afe | 10 | #define XFER_WAVEFORM_DERIVED_HPP |
MikamiUitOpen | 0:4440ad009afe | 11 | |
MikamiUitOpen | 0:4440ad009afe | 12 | class XferWaveform : public XferBase |
MikamiUitOpen | 0:4440ad009afe | 13 | { |
MikamiUitOpen | 0:4440ad009afe | 14 | public: |
MikamiUitOpen | 0:4440ad009afe | 15 | // コンストラクタ |
MikamiUitOpen | 0:4440ad009afe | 16 | XferWaveform(SerialRxTxIntr& rxTx, int size) |
MikamiUitOpen | 0:4440ad009afe | 17 | : XferBase(rxTx, size) {} |
MikamiUitOpen | 0:4440ad009afe | 18 | |
MikamiUitOpen | 0:4440ad009afe | 19 | private: |
MikamiUitOpen | 0:4440ad009afe | 20 | // 転送すべきデータを転送する形式に変換 |
MikamiUitOpen | 0:4440ad009afe | 21 | // -1 <= xIn[] <= 1 |
MikamiUitOpen | 0:4440ad009afe | 22 | // 対応関係:1 => 10000, -1 => 0 |
MikamiUitOpen | 0:4440ad009afe | 23 | virtual void Convert(const float xIn[]) |
MikamiUitOpen | 0:4440ad009afe | 24 | { |
MikamiUitOpen | 0:4440ad009afe | 25 | static const float FACTOR = 5000.0f; |
MikamiUitOpen | 0:4440ad009afe | 26 | for (int n=0; n<SIZE_; n++) |
MikamiUitOpen | 0:4440ad009afe | 27 | { |
MikamiUitOpen | 0:4440ad009afe | 28 | float x = FACTOR*(xIn[n] + 1.0f); |
MikamiUitOpen | 0:4440ad009afe | 29 | if (x > 10000) x = 10000; |
MikamiUitOpen | 0:4440ad009afe | 30 | if (x < 0) x = 0; |
MikamiUitOpen | 0:4440ad009afe | 31 | xn_[n] = (uint16_t)x; |
MikamiUitOpen | 0:4440ad009afe | 32 | } |
MikamiUitOpen | 0:4440ad009afe | 33 | } |
MikamiUitOpen | 0:4440ad009afe | 34 | |
MikamiUitOpen | 0:4440ad009afe | 35 | // コピー・コンストラクタおよび代入演算子の禁止のため |
MikamiUitOpen | 0:4440ad009afe | 36 | XferWaveform(const XferWaveform&); |
MikamiUitOpen | 0:4440ad009afe | 37 | XferWaveform& operator=(const XferWaveform&); |
MikamiUitOpen | 0:4440ad009afe | 38 | }; |
MikamiUitOpen | 0:4440ad009afe | 39 | #endif // XFER_WAVEFORM_DERIVED_HPP |