Motoo Tanaka
/
test_S11059
test program for S11059
main.cpp@0:0b1764160e19, 2017-05-12 (annotated)
- Committer:
- Rhyme
- Date:
- Fri May 12 02:12:56 2017 +0000
- Revision:
- 0:0b1764160e19
test program for S11059
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Rhyme | 0:0b1764160e19 | 1 | #include "mbed.h" |
Rhyme | 0:0b1764160e19 | 2 | #include "MSS.h" |
Rhyme | 0:0b1764160e19 | 3 | #include "S11059.h" |
Rhyme | 0:0b1764160e19 | 4 | |
Rhyme | 0:0b1764160e19 | 5 | #define MSU_S11059_ADDRESS 0x2A |
Rhyme | 0:0b1764160e19 | 6 | |
Rhyme | 0:0b1764160e19 | 7 | int main(void) |
Rhyme | 0:0b1764160e19 | 8 | { |
Rhyme | 0:0b1764160e19 | 9 | uint16_t uR, uG, uB, uIR ; |
Rhyme | 0:0b1764160e19 | 10 | uint8_t ctrl ; |
Rhyme | 0:0b1764160e19 | 11 | |
Rhyme | 0:0b1764160e19 | 12 | S11059 *s11059 = new S11059(PIN_SDA, PIN_SCL, MSU_S11059_ADDRESS) ; |
Rhyme | 0:0b1764160e19 | 13 | printf("=== test S11059 for %s (%s) ===\n", BOARD_NAME, __DATE__) ; |
Rhyme | 0:0b1764160e19 | 14 | printf(" R, G, B, IR\n") ; |
Rhyme | 0:0b1764160e19 | 15 | |
Rhyme | 0:0b1764160e19 | 16 | while(1) { |
Rhyme | 0:0b1764160e19 | 17 | ctrl = 0x89 ; // ADC reset, High Gain, integration time 1.4ms |
Rhyme | 0:0b1764160e19 | 18 | s11059->setControl(ctrl) ; |
Rhyme | 0:0b1764160e19 | 19 | ctrl = 0x09 ; // Release ADC reset, High Gain, integration time 1.4ms |
Rhyme | 0:0b1764160e19 | 20 | s11059->setControl(ctrl) ; // start measure |
Rhyme | 0:0b1764160e19 | 21 | wait(0.02) ; |
Rhyme | 0:0b1764160e19 | 22 | s11059->getRData(&uR) ; |
Rhyme | 0:0b1764160e19 | 23 | s11059->getGData(&uG) ; |
Rhyme | 0:0b1764160e19 | 24 | s11059->getBData(&uB) ; |
Rhyme | 0:0b1764160e19 | 25 | s11059->getIRData(&uIR) ; |
Rhyme | 0:0b1764160e19 | 26 | printf("%6d, %6d, %6d, %6d\n", uR, uG, uB, uIR) ; |
Rhyme | 0:0b1764160e19 | 27 | wait(1) ; |
Rhyme | 0:0b1764160e19 | 28 | } |
Rhyme | 0:0b1764160e19 | 29 | } |