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.
Diff: Global.cpp
- Revision:
- 6:0d9fa7152934
- Parent:
- 5:9a1ec02229dd
- Child:
- 7:6f7bd18ce796
diff -r 9a1ec02229dd -r 0d9fa7152934 Global.cpp --- a/Global.cpp Fri Oct 09 14:29:32 2015 +0000 +++ b/Global.cpp Sat Oct 10 20:16:31 2015 +0000 @@ -38,9 +38,46 @@ DigitalOut Global::led2(LED2); DigitalOut Global::led3(LED3); DigitalOut Global::led4(LED4); +LocalFileSystem Global::local("local"); + void Global::initialize(){ - + timer.start(); + fileread(); +} + +void Global::fileread(){ + float a, b, c, d, e, f; + + FILE* fp = fopen("/local/init.csv", "r"); + if(fp == NULL) { + filewrite(); + return; + } + //1行目 + fscanf( fp, "%f,%f,%f,%f,%f,%f",&a, &b, &c, &d, &e, &f); + setneutralpitch(a); + setmaxpitch(b); + setminpitch(c); + setneutralyaw(d); + setmaxyaw(e); + setminyaw(f); + fclose(fp); +} + +void Global::filewrite(){ + FILE* fp = fopen("/local/init.csv", "w"); + if(fp == NULL) { + error("Could not open file for write\n"); + } + fprintf(fp, "%f,%f,%f,%f,%f,%f\n", + getneutralpitch(), + getmaxpitch(), + getminpitch(), + getneutralyaw(), + getmaxyaw(), + getminyaw()); + fclose(fp); }