Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: Rm3100 SPI_TFT_ILI9341 TFT_fonts
Fork of Hello_RM3100 by
main.cpp@1:6d43a9476f67, 2018-03-06 (annotated)
- Committer:
- x893
- Date:
- Tue Mar 06 08:40:14 2018 +0000
- Revision:
- 1:6d43a9476f67
- Parent:
- 0:f939d6b78be6
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
fwrawx | 0:f939d6b78be6 | 1 | #include "mbed.h" |
fwrawx | 0:f939d6b78be6 | 2 | #include "Rm3100.hpp" |
x893 | 1:6d43a9476f67 | 3 | #include "SPI_TFT_ILI9341.h" |
x893 | 1:6d43a9476f67 | 4 | #include "string" |
x893 | 1:6d43a9476f67 | 5 | #include "Arial24x23.h" |
x893 | 1:6d43a9476f67 | 6 | |
x893 | 1:6d43a9476f67 | 7 | // mosi, miso, sclk, cs, reset, dc |
x893 | 1:6d43a9476f67 | 8 | SPI_TFT_ILI9341 TFT(D8, D9, D10, D11, D12, D8); |
fwrawx | 0:f939d6b78be6 | 9 | |
fwrawx | 0:f939d6b78be6 | 10 | int main(void) |
fwrawx | 0:f939d6b78be6 | 11 | { |
fwrawx | 0:f939d6b78be6 | 12 | Serial pc(USBTX, USBRX); |
fwrawx | 0:f939d6b78be6 | 13 | pc.baud(115200); |
fwrawx | 0:f939d6b78be6 | 14 | |
x893 | 1:6d43a9476f67 | 15 | printf("### RM3100 ###\r\n"); |
x893 | 1:6d43a9476f67 | 16 | TFT.set_font((unsigned char*) Arial24x23); // select font 2 |
x893 | 1:6d43a9476f67 | 17 | TFT.locate(48,115); |
x893 | 1:6d43a9476f67 | 18 | TFT.printf("Bigger Font"); |
fwrawx | 0:f939d6b78be6 | 19 | |
fwrawx | 0:f939d6b78be6 | 20 | int addr = ((Rm3100::RM3100_ADDR | Rm3100::RM3100_ADDR_SSN) << 1); |
fwrawx | 0:f939d6b78be6 | 21 | struct Rm3100::Status status = { 0 }; |
fwrawx | 0:f939d6b78be6 | 22 | struct Rm3100::Sample sample = { 0 }; |
fwrawx | 0:f939d6b78be6 | 23 | |
fwrawx | 0:f939d6b78be6 | 24 | Rm3100 sensor(I2C_SDA, I2C_SCL, addr); |
fwrawx | 0:f939d6b78be6 | 25 | |
fwrawx | 0:f939d6b78be6 | 26 | sensor.Begin(); |
fwrawx | 0:f939d6b78be6 | 27 | osDelay(1); |
fwrawx | 0:f939d6b78be6 | 28 | |
fwrawx | 0:f939d6b78be6 | 29 | sensor.SetCycleCounts(200); |
fwrawx | 0:f939d6b78be6 | 30 | osDelay(1); |
fwrawx | 0:f939d6b78be6 | 31 | |
fwrawx | 0:f939d6b78be6 | 32 | sensor.SetRate(100.0f); |
fwrawx | 0:f939d6b78be6 | 33 | osDelay(1); |
fwrawx | 0:f939d6b78be6 | 34 | |
fwrawx | 0:f939d6b78be6 | 35 | sensor.SetContinuousMeasurementMode(true); |
fwrawx | 0:f939d6b78be6 | 36 | osDelay(1); |
fwrawx | 0:f939d6b78be6 | 37 | |
fwrawx | 0:f939d6b78be6 | 38 | while (true) { |
fwrawx | 0:f939d6b78be6 | 39 | sensor.GetStatus(&status); |
fwrawx | 0:f939d6b78be6 | 40 | if (status.drdy) { |
fwrawx | 0:f939d6b78be6 | 41 | sensor.GetSample(&sample); |
fwrawx | 0:f939d6b78be6 | 42 | printf("x: %f, y: %f, z: %f\r\n", sample.x, sample.y, sample.z); |
fwrawx | 0:f939d6b78be6 | 43 | } |
fwrawx | 0:f939d6b78be6 | 44 | osDelay(10); |
fwrawx | 0:f939d6b78be6 | 45 | } |
fwrawx | 0:f939d6b78be6 | 46 | } |