Added a GPIO to power on/off for external I2C sensor(s) (with LEDs)

Dependencies:   UniGraphic mbed vt100

18-Jun-2018 外部センサの電源オン・オフ機能は下位互換の為に無効になっていました。 この版で再度有効にしました。

Committer:
Rhyme
Date:
Fri Apr 13 04:19:23 2018 +0000
Revision:
0:846e2321c637
power to color sensor on/off test OK. Currently the function is disabled.

Who changed what in which revision?

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