Color sensor reset at the end of calibration added. sensor id auto assignment was changed to be a fixed value assignment to avoid sensor id shift when some sensor is absent.
Dependencies: UniGraphic mbed vt100
afLib/Command.h@1:8818b793d147, 2018-02-23 (annotated)
- Committer:
- Rhyme
- Date:
- Fri Feb 23 07:51:55 2018 +0000
- Revision:
- 1:8818b793d147
- Parent:
- 0:ce97f6d34336
Wrong behavior when one of color sensor is missing has been fixed.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Rhyme | 0:ce97f6d34336 | 1 | /** |
Rhyme | 0:ce97f6d34336 | 2 | * Copyright 2015 Afero, Inc. |
Rhyme | 0:ce97f6d34336 | 3 | * |
Rhyme | 0:ce97f6d34336 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
Rhyme | 0:ce97f6d34336 | 5 | * you may not use this file except in compliance with the License. |
Rhyme | 0:ce97f6d34336 | 6 | * You may obtain a copy of the License at |
Rhyme | 0:ce97f6d34336 | 7 | * |
Rhyme | 0:ce97f6d34336 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
Rhyme | 0:ce97f6d34336 | 9 | * |
Rhyme | 0:ce97f6d34336 | 10 | * Unless required by applicable law or agreed to in writing, software |
Rhyme | 0:ce97f6d34336 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
Rhyme | 0:ce97f6d34336 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
Rhyme | 0:ce97f6d34336 | 13 | * See the License for the specific language governing permissions and |
Rhyme | 0:ce97f6d34336 | 14 | * limitations under the License. |
Rhyme | 0:ce97f6d34336 | 15 | */ |
Rhyme | 0:ce97f6d34336 | 16 | |
Rhyme | 0:ce97f6d34336 | 17 | #ifndef COMMAND_H__ |
Rhyme | 0:ce97f6d34336 | 18 | #define COMMAND_H__ |
Rhyme | 0:ce97f6d34336 | 19 | |
Rhyme | 0:ce97f6d34336 | 20 | #include "mbed.h" //wsugi |
Rhyme | 0:ce97f6d34336 | 21 | #include <string> //wsugi |
Rhyme | 0:ce97f6d34336 | 22 | |
Rhyme | 0:ce97f6d34336 | 23 | using namespace std; //wsugi |
Rhyme | 0:ce97f6d34336 | 24 | |
Rhyme | 0:ce97f6d34336 | 25 | #define SPI_CMD_MAX_LEN 256 |
Rhyme | 0:ce97f6d34336 | 26 | |
Rhyme | 0:ce97f6d34336 | 27 | #define UPDATE_REASON_UNKNOWN 0 |
Rhyme | 0:ce97f6d34336 | 28 | #define UPDATE_REASON_LOCAL_UPDATE 1 |
Rhyme | 0:ce97f6d34336 | 29 | #define UPDATE_REASON_SERVICE_SET 2 |
Rhyme | 0:ce97f6d34336 | 30 | #define UPDATE_REASON_MCU_SET 3 |
Rhyme | 0:ce97f6d34336 | 31 | #define UPDATE_REASON_RELINK 4 |
Rhyme | 0:ce97f6d34336 | 32 | #define UPDATE_REASON_REBOOT 5 |
Rhyme | 0:ce97f6d34336 | 33 | |
Rhyme | 0:ce97f6d34336 | 34 | class Command { |
Rhyme | 0:ce97f6d34336 | 35 | public: |
Rhyme | 0:ce97f6d34336 | 36 | Command(uint16_t len, uint8_t *bytes); |
Rhyme | 0:ce97f6d34336 | 37 | |
Rhyme | 0:ce97f6d34336 | 38 | Command(uint8_t requestId, const char *str); |
Rhyme | 0:ce97f6d34336 | 39 | |
Rhyme | 0:ce97f6d34336 | 40 | Command(uint8_t requestId, uint8_t cmd, uint16_t attrId); |
Rhyme | 0:ce97f6d34336 | 41 | |
Rhyme | 0:ce97f6d34336 | 42 | Command(uint8_t requestId, uint8_t cmd, uint16_t attrId, uint16_t valueLen, uint8_t *value); |
Rhyme | 0:ce97f6d34336 | 43 | |
Rhyme | 0:ce97f6d34336 | 44 | Command(uint8_t requestId, uint8_t cmd, uint16_t attrId, uint8_t status, uint8_t reason, uint16_t valueLen, |
Rhyme | 0:ce97f6d34336 | 45 | uint8_t *value); |
Rhyme | 0:ce97f6d34336 | 46 | |
Rhyme | 0:ce97f6d34336 | 47 | Command(); |
Rhyme | 0:ce97f6d34336 | 48 | |
Rhyme | 0:ce97f6d34336 | 49 | ~Command(); |
Rhyme | 0:ce97f6d34336 | 50 | |
Rhyme | 0:ce97f6d34336 | 51 | uint8_t getCommand(); |
Rhyme | 0:ce97f6d34336 | 52 | |
Rhyme | 0:ce97f6d34336 | 53 | uint8_t getReqId(); |
Rhyme | 0:ce97f6d34336 | 54 | |
Rhyme | 0:ce97f6d34336 | 55 | uint16_t getAttrId(); |
Rhyme | 0:ce97f6d34336 | 56 | |
Rhyme | 0:ce97f6d34336 | 57 | uint16_t getValueLen(); |
Rhyme | 0:ce97f6d34336 | 58 | |
Rhyme | 0:ce97f6d34336 | 59 | void getValue(uint8_t *value); |
Rhyme | 0:ce97f6d34336 | 60 | |
Rhyme | 0:ce97f6d34336 | 61 | uint8_t *getValueP(); |
Rhyme | 0:ce97f6d34336 | 62 | |
Rhyme | 0:ce97f6d34336 | 63 | uint16_t getSize(); |
Rhyme | 0:ce97f6d34336 | 64 | |
Rhyme | 0:ce97f6d34336 | 65 | uint16_t getBytes(uint8_t *bytes); |
Rhyme | 0:ce97f6d34336 | 66 | |
Rhyme | 0:ce97f6d34336 | 67 | bool isValid(); |
Rhyme | 0:ce97f6d34336 | 68 | |
Rhyme | 0:ce97f6d34336 | 69 | void dump(); |
Rhyme | 0:ce97f6d34336 | 70 | |
Rhyme | 0:ce97f6d34336 | 71 | void dumpBytes(); |
Rhyme | 0:ce97f6d34336 | 72 | |
Rhyme | 0:ce97f6d34336 | 73 | private: |
Rhyme | 0:ce97f6d34336 | 74 | uint8_t getVal(char c); |
Rhyme | 0:ce97f6d34336 | 75 | int strToValue(char *valueStr, uint8_t *value); |
Rhyme | 0:ce97f6d34336 | 76 | |
Rhyme | 0:ce97f6d34336 | 77 | uint8_t strToCmd(char *cmdStr); |
Rhyme | 0:ce97f6d34336 | 78 | |
Rhyme | 0:ce97f6d34336 | 79 | uint16_t strToAttrId(char *attrIdStr); |
Rhyme | 0:ce97f6d34336 | 80 | |
Rhyme | 0:ce97f6d34336 | 81 | uint16_t _len; |
Rhyme | 0:ce97f6d34336 | 82 | uint8_t _cmd; |
Rhyme | 0:ce97f6d34336 | 83 | uint8_t _requestId; |
Rhyme | 0:ce97f6d34336 | 84 | uint16_t _attrId; |
Rhyme | 0:ce97f6d34336 | 85 | uint8_t _status; |
Rhyme | 0:ce97f6d34336 | 86 | uint8_t _reason; |
Rhyme | 0:ce97f6d34336 | 87 | uint16_t _valueLen; |
Rhyme | 0:ce97f6d34336 | 88 | uint8_t *_value; |
Rhyme | 0:ce97f6d34336 | 89 | |
Rhyme | 0:ce97f6d34336 | 90 | char _printBuf[256]; |
Rhyme | 0:ce97f6d34336 | 91 | |
Rhyme | 0:ce97f6d34336 | 92 | }; |
Rhyme | 0:ce97f6d34336 | 93 | |
Rhyme | 0:ce97f6d34336 | 94 | #endif // COMMAND_H__ |