SCH MME sensor test
Dependencies: mbed Adafruit_GFX
main.cpp@1:bbf8b08b8a20, 2019-11-06 (annotated)
- Committer:
- shinshingo
- Date:
- Wed Nov 06 09:06:56 2019 +0000
- Revision:
- 1:bbf8b08b8a20
- Parent:
- 0:28c89a4b6b69
comment;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shinshingo | 0:28c89a4b6b69 | 1 | #include "mbed.h" |
shinshingo | 0:28c89a4b6b69 | 2 | #include "Adafruit_SSD1306.h" |
shinshingo | 0:28c89a4b6b69 | 3 | #include "mlx90615.h" |
shinshingo | 0:28c89a4b6b69 | 4 | |
shinshingo | 0:28c89a4b6b69 | 5 | DigitalOut myled_R(LED1); |
shinshingo | 0:28c89a4b6b69 | 6 | |
shinshingo | 0:28c89a4b6b69 | 7 | I2C i2c_sensor(I2C_SDA,I2C_SCL); |
shinshingo | 0:28c89a4b6b69 | 8 | I2C i2c_oled(D12, A6); |
shinshingo | 0:28c89a4b6b69 | 9 | |
shinshingo | 0:28c89a4b6b69 | 10 | Adafruit_SSD1306_I2c myOled(i2c_oled,NC,0x78,64,128); |
shinshingo | 0:28c89a4b6b69 | 11 | MLX90615 myMlx(&i2c_sensor); |
shinshingo | 0:28c89a4b6b69 | 12 | |
shinshingo | 0:28c89a4b6b69 | 13 | Serial pc(USBTX, USBRX, 9600); |
shinshingo | 0:28c89a4b6b69 | 14 | Serial HC06(D1, D0, 9600); |
shinshingo | 0:28c89a4b6b69 | 15 | |
shinshingo | 0:28c89a4b6b69 | 16 | int main() |
shinshingo | 0:28c89a4b6b69 | 17 | { |
shinshingo | 0:28c89a4b6b69 | 18 | float temp = 0.0; |
shinshingo | 0:28c89a4b6b69 | 19 | float amb_temp = 0.0; |
shinshingo | 0:28c89a4b6b69 | 20 | int16_t ir_data = 0; |
shinshingo | 0:28c89a4b6b69 | 21 | |
shinshingo | 0:28c89a4b6b69 | 22 | myOled.begin(); |
shinshingo | 0:28c89a4b6b69 | 23 | myOled.printf("%ux%u \nHellow World\r\n", myOled.width(), myOled.height()); |
shinshingo | 0:28c89a4b6b69 | 24 | myOled.display(); |
shinshingo | 0:28c89a4b6b69 | 25 | |
shinshingo | 0:28c89a4b6b69 | 26 | myOled.clearDisplay(); |
shinshingo | 0:28c89a4b6b69 | 27 | |
shinshingo | 0:28c89a4b6b69 | 28 | pc.printf("===============Hello world===============\n\r"); |
shinshingo | 0:28c89a4b6b69 | 29 | |
shinshingo | 0:28c89a4b6b69 | 30 | while(1) |
shinshingo | 0:28c89a4b6b69 | 31 | { |
shinshingo | 0:28c89a4b6b69 | 32 | myled_R = !myled_R; |
shinshingo | 0:28c89a4b6b69 | 33 | |
shinshingo | 0:28c89a4b6b69 | 34 | temp = 0; |
shinshingo | 0:28c89a4b6b69 | 35 | amb_temp = 0; |
shinshingo | 0:28c89a4b6b69 | 36 | ir_data = 0; |
shinshingo | 0:28c89a4b6b69 | 37 | |
shinshingo | 0:28c89a4b6b69 | 38 | if (myMlx.getTemp(&temp)& myMlx.getTempAmbient(&amb_temp) & myMlx.getRawIR(&ir_data)) |
shinshingo | 0:28c89a4b6b69 | 39 | { |
shinshingo | 0:28c89a4b6b69 | 40 | myOled.clearDisplay(); |
shinshingo | 0:28c89a4b6b69 | 41 | myOled.setTextCursor(0,0); |
shinshingo | 0:28c89a4b6b69 | 42 | pc.printf("%5.2f, %5.2f, %d\n",temp, amb_temp, ir_data); |
shinshingo | 0:28c89a4b6b69 | 43 | HC06.printf("%5.2f, %5.2f, %d\r\n",temp, amb_temp, ir_data); |
shinshingo | 0:28c89a4b6b69 | 44 | myOled.printf("%5.2f, %5.2f, %d\r\n",temp, amb_temp, ir_data); |
shinshingo | 0:28c89a4b6b69 | 45 | myOled.display(); |
shinshingo | 0:28c89a4b6b69 | 46 | } |
shinshingo | 0:28c89a4b6b69 | 47 | wait(1.0); |
shinshingo | 0:28c89a4b6b69 | 48 | |
shinshingo | 0:28c89a4b6b69 | 49 | |
shinshingo | 0:28c89a4b6b69 | 50 | } |
shinshingo | 0:28c89a4b6b69 | 51 | } |