microSD カードのビットマップ・ファイルのビュアー.画像の最大値 縦:272ピクセル,横:480ピクセル. Bitmap file viewer for microSD card. Maximum size Vertical: 272 pixels, Horizontal: 480.
Dependencies: SDFileSystem_Warning_Fixed F746_GUI
mbed_src_STM32F7/common/CallChain.cpp@1:bb146d5fe9aa, 2018-10-23 (annotated)
- Committer:
- MikamiUitOpen
- Date:
- Tue Oct 23 11:51:47 2018 +0000
- Revision:
- 1:bb146d5fe9aa
- Parent:
- 0:f62ffd3644bf
2
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MikamiUitOpen | 0:f62ffd3644bf | 1 | #include "CallChain.h" |
MikamiUitOpen | 0:f62ffd3644bf | 2 | #include "cmsis.h" |
MikamiUitOpen | 0:f62ffd3644bf | 3 | |
MikamiUitOpen | 0:f62ffd3644bf | 4 | namespace mbed { |
MikamiUitOpen | 0:f62ffd3644bf | 5 | |
MikamiUitOpen | 0:f62ffd3644bf | 6 | CallChain::CallChain(int size) : _chain(), _size(size), _elements(0) { |
MikamiUitOpen | 0:f62ffd3644bf | 7 | _chain = new pFunctionPointer_t[size](); |
MikamiUitOpen | 0:f62ffd3644bf | 8 | } |
MikamiUitOpen | 0:f62ffd3644bf | 9 | |
MikamiUitOpen | 0:f62ffd3644bf | 10 | CallChain::~CallChain() { |
MikamiUitOpen | 0:f62ffd3644bf | 11 | clear(); |
MikamiUitOpen | 0:f62ffd3644bf | 12 | delete _chain; |
MikamiUitOpen | 0:f62ffd3644bf | 13 | } |
MikamiUitOpen | 0:f62ffd3644bf | 14 | |
MikamiUitOpen | 0:f62ffd3644bf | 15 | pFunctionPointer_t CallChain::add(void (*function)(void)) { |
MikamiUitOpen | 0:f62ffd3644bf | 16 | return common_add(new FunctionPointer(function)); |
MikamiUitOpen | 0:f62ffd3644bf | 17 | } |
MikamiUitOpen | 0:f62ffd3644bf | 18 | |
MikamiUitOpen | 0:f62ffd3644bf | 19 | pFunctionPointer_t CallChain::add_front(void (*function)(void)) { |
MikamiUitOpen | 0:f62ffd3644bf | 20 | return common_add_front(new FunctionPointer(function)); |
MikamiUitOpen | 0:f62ffd3644bf | 21 | } |
MikamiUitOpen | 0:f62ffd3644bf | 22 | |
MikamiUitOpen | 0:f62ffd3644bf | 23 | int CallChain::size() const { |
MikamiUitOpen | 0:f62ffd3644bf | 24 | return _elements; |
MikamiUitOpen | 0:f62ffd3644bf | 25 | } |
MikamiUitOpen | 0:f62ffd3644bf | 26 | |
MikamiUitOpen | 0:f62ffd3644bf | 27 | pFunctionPointer_t CallChain::get(int i) const { |
MikamiUitOpen | 0:f62ffd3644bf | 28 | if (i < 0 || i >= _elements) |
MikamiUitOpen | 0:f62ffd3644bf | 29 | return NULL; |
MikamiUitOpen | 0:f62ffd3644bf | 30 | return _chain[i]; |
MikamiUitOpen | 0:f62ffd3644bf | 31 | } |
MikamiUitOpen | 0:f62ffd3644bf | 32 | |
MikamiUitOpen | 0:f62ffd3644bf | 33 | int CallChain::find(pFunctionPointer_t f) const { |
MikamiUitOpen | 0:f62ffd3644bf | 34 | for (int i = 0; i < _elements; i++) |
MikamiUitOpen | 0:f62ffd3644bf | 35 | if (f == _chain[i]) |
MikamiUitOpen | 0:f62ffd3644bf | 36 | return i; |
MikamiUitOpen | 0:f62ffd3644bf | 37 | return -1; |
MikamiUitOpen | 0:f62ffd3644bf | 38 | } |
MikamiUitOpen | 0:f62ffd3644bf | 39 | |
MikamiUitOpen | 0:f62ffd3644bf | 40 | void CallChain::clear() { |
MikamiUitOpen | 0:f62ffd3644bf | 41 | for(int i = 0; i < _elements; i ++) { |
MikamiUitOpen | 0:f62ffd3644bf | 42 | delete _chain[i]; |
MikamiUitOpen | 0:f62ffd3644bf | 43 | _chain[i] = NULL; |
MikamiUitOpen | 0:f62ffd3644bf | 44 | } |
MikamiUitOpen | 0:f62ffd3644bf | 45 | _elements = 0; |
MikamiUitOpen | 0:f62ffd3644bf | 46 | } |
MikamiUitOpen | 0:f62ffd3644bf | 47 | |
MikamiUitOpen | 0:f62ffd3644bf | 48 | bool CallChain::remove(pFunctionPointer_t f) { |
MikamiUitOpen | 0:f62ffd3644bf | 49 | int i; |
MikamiUitOpen | 0:f62ffd3644bf | 50 | |
MikamiUitOpen | 0:f62ffd3644bf | 51 | if ((i = find(f)) == -1) |
MikamiUitOpen | 0:f62ffd3644bf | 52 | return false; |
MikamiUitOpen | 0:f62ffd3644bf | 53 | if (i != _elements - 1) |
MikamiUitOpen | 0:f62ffd3644bf | 54 | memmove(_chain + i, _chain + i + 1, (_elements - i - 1) * sizeof(pFunctionPointer_t)); |
MikamiUitOpen | 0:f62ffd3644bf | 55 | delete f; |
MikamiUitOpen | 0:f62ffd3644bf | 56 | _elements --; |
MikamiUitOpen | 0:f62ffd3644bf | 57 | return true; |
MikamiUitOpen | 0:f62ffd3644bf | 58 | } |
MikamiUitOpen | 0:f62ffd3644bf | 59 | |
MikamiUitOpen | 0:f62ffd3644bf | 60 | void CallChain::call() { |
MikamiUitOpen | 0:f62ffd3644bf | 61 | for(int i = 0; i < _elements; i++) |
MikamiUitOpen | 0:f62ffd3644bf | 62 | _chain[i]->call(); |
MikamiUitOpen | 0:f62ffd3644bf | 63 | } |
MikamiUitOpen | 0:f62ffd3644bf | 64 | |
MikamiUitOpen | 0:f62ffd3644bf | 65 | void CallChain::_check_size() { |
MikamiUitOpen | 0:f62ffd3644bf | 66 | if (_elements < _size) |
MikamiUitOpen | 0:f62ffd3644bf | 67 | return; |
MikamiUitOpen | 0:f62ffd3644bf | 68 | _size = (_size < 4) ? 4 : _size + 4; |
MikamiUitOpen | 0:f62ffd3644bf | 69 | pFunctionPointer_t* new_chain = new pFunctionPointer_t[_size](); |
MikamiUitOpen | 0:f62ffd3644bf | 70 | memcpy(new_chain, _chain, _elements * sizeof(pFunctionPointer_t)); |
MikamiUitOpen | 0:f62ffd3644bf | 71 | delete _chain; |
MikamiUitOpen | 0:f62ffd3644bf | 72 | _chain = new_chain; |
MikamiUitOpen | 0:f62ffd3644bf | 73 | } |
MikamiUitOpen | 0:f62ffd3644bf | 74 | |
MikamiUitOpen | 0:f62ffd3644bf | 75 | pFunctionPointer_t CallChain::common_add(pFunctionPointer_t pf) { |
MikamiUitOpen | 0:f62ffd3644bf | 76 | _check_size(); |
MikamiUitOpen | 0:f62ffd3644bf | 77 | _chain[_elements] = pf; |
MikamiUitOpen | 0:f62ffd3644bf | 78 | _elements ++; |
MikamiUitOpen | 0:f62ffd3644bf | 79 | return pf; |
MikamiUitOpen | 0:f62ffd3644bf | 80 | } |
MikamiUitOpen | 0:f62ffd3644bf | 81 | |
MikamiUitOpen | 0:f62ffd3644bf | 82 | pFunctionPointer_t CallChain::common_add_front(pFunctionPointer_t pf) { |
MikamiUitOpen | 0:f62ffd3644bf | 83 | _check_size(); |
MikamiUitOpen | 0:f62ffd3644bf | 84 | memmove(_chain + 1, _chain, _elements * sizeof(pFunctionPointer_t)); |
MikamiUitOpen | 0:f62ffd3644bf | 85 | _chain[0] = pf; |
MikamiUitOpen | 0:f62ffd3644bf | 86 | _elements ++; |
MikamiUitOpen | 0:f62ffd3644bf | 87 | return pf; |
MikamiUitOpen | 0:f62ffd3644bf | 88 | } |
MikamiUitOpen | 0:f62ffd3644bf | 89 | |
MikamiUitOpen | 0:f62ffd3644bf | 90 | } // namespace mbed |