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: mbed CubicSpline
main.cpp@0:462ec4384136, 2020-10-21 (annotated)
- Committer:
- aktk
- Date:
- Wed Oct 21 17:27:16 2020 +0000
- Revision:
- 0:462ec4384136
first commit;
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| aktk | 0:462ec4384136 | 1 | #include "mbed.h" |
| aktk | 0:462ec4384136 | 2 | #include "CubicSpline.h" |
| aktk | 0:462ec4384136 | 3 | DigitalOut myled(LED1); |
| aktk | 0:462ec4384136 | 4 | CubicSpline2d sensor(5,AsDEBUG); |
| aktk | 0:462ec4384136 | 5 | extern Serial g_Serial_Signal; |
| aktk | 0:462ec4384136 | 6 | extern AnalogIn g_Sensor_Voltage; |
| aktk | 0:462ec4384136 | 7 | |
| aktk | 0:462ec4384136 | 8 | int main() |
| aktk | 0:462ec4384136 | 9 | { |
| aktk | 0:462ec4384136 | 10 | double x,y; |
| aktk | 0:462ec4384136 | 11 | Timer t; |
| aktk | 0:462ec4384136 | 12 | myled = 1; |
| aktk | 0:462ec4384136 | 13 | printf("c or l>"); |
| aktk | 0:462ec4384136 | 14 | if(g_Serial_Signal.getc() == 'c') { |
| aktk | 0:462ec4384136 | 15 | sensor.calibrateSensor(); |
| aktk | 0:462ec4384136 | 16 | sensor.printOutData(); |
| aktk | 0:462ec4384136 | 17 | sensor.saveSetting(); |
| aktk | 0:462ec4384136 | 18 | } else { |
| aktk | 0:462ec4384136 | 19 | sensor.loadSetting(); |
| aktk | 0:462ec4384136 | 20 | printf("press any key"); |
| aktk | 0:462ec4384136 | 21 | g_Serial_Signal.getc(); |
| aktk | 0:462ec4384136 | 22 | sensor.printOutData(); |
| aktk | 0:462ec4384136 | 23 | } |
| aktk | 0:462ec4384136 | 24 | myled = 0; |
| aktk | 0:462ec4384136 | 25 | |
| aktk | 0:462ec4384136 | 26 | while(1) { |
| aktk | 0:462ec4384136 | 27 | myled = 1; |
| aktk | 0:462ec4384136 | 28 | if(g_Serial_Signal.readable()) { |
| aktk | 0:462ec4384136 | 29 | g_Serial_Signal.getc(); |
| aktk | 0:462ec4384136 | 30 | y = g_Sensor_Voltage.read(); |
| aktk | 0:462ec4384136 | 31 | t.start(); |
| aktk | 0:462ec4384136 | 32 | x = sensor.getX(y); |
| aktk | 0:462ec4384136 | 33 | t.stop(); |
| aktk | 0:462ec4384136 | 34 | printf("y: %f -> x: %f (time: %f)\n",y, x , t.read()); |
| aktk | 0:462ec4384136 | 35 | t.reset(); |
| aktk | 0:462ec4384136 | 36 | myled = 0; |
| aktk | 0:462ec4384136 | 37 | wait(0.2); |
| aktk | 0:462ec4384136 | 38 | } |
| aktk | 0:462ec4384136 | 39 | } |
| aktk | 0:462ec4384136 | 40 | } |