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: FreePilot PinDetect mbed-src
Fork of FreePilot_V2-2 by
Config.cpp@33:3e71c418e90d, 2015-02-02 (annotated)
- Committer:
- maximbolduc
- Date:
- Mon Feb 02 18:24:03 2015 +0000
- Revision:
- 33:3e71c418e90d
- Parent:
- 32:c57bc701d65c
- Child:
- 34:c2bc9f9be7ff
litle update
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| maximbolduc | 26:dc00998140af | 1 | #include "mbed.h" |
| maximbolduc | 26:dc00998140af | 2 | #include <string> |
| maximbolduc | 26:dc00998140af | 3 | #include "Config.h" |
| jhedmonton | 28:5905886c76ee | 4 | #include "base.h" |
| jhedmonton | 28:5905886c76ee | 5 | |
| maximbolduc | 26:dc00998140af | 6 | LocalFileSystem local("local"); // Create the local filesystem under the name "local" |
| maximbolduc | 30:3afafa1ef16b | 7 | char* line; |
| jhedmonton | 28:5905886c76ee | 8 | |
| maximbolduc | 26:dc00998140af | 9 | void Config_Startup() |
| maximbolduc | 26:dc00998140af | 10 | { |
| maximbolduc | 26:dc00998140af | 11 | FILE * fp; |
| maximbolduc | 26:dc00998140af | 12 | char line[256]; |
| jhedmonton | 28:5905886c76ee | 13 | |
| maximbolduc | 26:dc00998140af | 14 | //fp = fopen("/local/config.txt", "w"); |
| maximbolduc | 26:dc00998140af | 15 | //fprintf(fp, "BT,000666624C6A\r\nPA,0\r\nTC,4.5\r\nFG,30\r\nSC,2.7\r\nAP,-4"); //Rewrite text file for TESTING |
| maximbolduc | 26:dc00998140af | 16 | //fclose(fp); |
| jhedmonton | 28:5905886c76ee | 17 | |
| maximbolduc | 26:dc00998140af | 18 | fp = fopen("/local/config.txt", "r"); |
| jhedmonton | 28:5905886c76ee | 19 | |
| maximbolduc | 26:dc00998140af | 20 | while (fgets(line, sizeof(line), fp)) //Read through config file line by line |
| maximbolduc | 26:dc00998140af | 21 | Dispatch(line, true); //Send line to dispatcher, true indicates its coming from the config file |
| jhedmonton | 28:5905886c76ee | 22 | |
| maximbolduc | 26:dc00998140af | 23 | fclose(fp); |
| maximbolduc | 26:dc00998140af | 24 | } |
| jhedmonton | 28:5905886c76ee | 25 | |
| jhedmonton | 28:5905886c76ee | 26 | void Config_Save() |
| maximbolduc | 26:dc00998140af | 27 | { |
| jhedmonton | 28:5905886c76ee | 28 | FILE * fp; |
| jhedmonton | 28:5905886c76ee | 29 | fp = fopen("/local/config.txt", "w"); |
| jhedmonton | 28:5905886c76ee | 30 | |
| maximbolduc | 30:3afafa1ef16b | 31 | //sprintf("$ID,%d\r\n$BTMODE,%d\r\n$PA,%f\r\n$TC,%f\r\n |
| jhedmonton | 28:5905886c76ee | 32 | fprintf(fp, "$ID,%d\r\n",_ID);//address |
| jhedmonton | 28:5905886c76ee | 33 | fprintf(fp, "$BTMODE,%d\r\n",_btMode);//bluetooth mode |
| jhedmonton | 28:5905886c76ee | 34 | fprintf(fp, "$PA,%f\r\n",phaseadv);//phase advance |
| jhedmonton | 28:5905886c76ee | 35 | fprintf(fp, "$TC,%f\r\n",tcenter);//tcenter |
| jhedmonton | 28:5905886c76ee | 36 | fprintf(fp, "$FG,%f\r\n",fgain);//filter gain |
| jhedmonton | 28:5905886c76ee | 37 | fprintf(fp, "$SC,%f\r\n",scale);//scale |
| jhedmonton | 28:5905886c76ee | 38 | fprintf(fp, "$AP,%f\r\n",avgpos);//avgpos |
| jhedmonton | 28:5905886c76ee | 39 | |
| maximbolduc | 32:c57bc701d65c | 40 | fprintf(fp,"$GYRO,%i\r\n",gyro_pos); |
| jhedmonton | 28:5905886c76ee | 41 | fprintf(fp,"$GPSBAUD,%d\r\n",gps_baud); |
| maximbolduc | 30:3afafa1ef16b | 42 | fprintf(fp,"$HEIGHT,%f\r\n",antennaheight); |
| maximbolduc | 33:3e71c418e90d | 43 | // fprintf(fp,"$a_zBias,%f\r\n",a_zBias); |
| maximbolduc | 33:3e71c418e90d | 44 | // fprintf(fp,"$a_yBias,%f\r\n",a_yBias); |
| maximbolduc | 33:3e71c418e90d | 45 | // fprintf(fp,"$a_zBias,%f\r\n",a_zBias); |
| maximbolduc | 33:3e71c418e90d | 46 | // fprintf(fp,"$w_xBias,%f\r\n",w_xBias); |
| maximbolduc | 33:3e71c418e90d | 47 | // fprintf(fp,"$w_yBias,%f\r\n",w_yBias); |
| maximbolduc | 33:3e71c418e90d | 48 | // fprintf(fp,"$w_zBias,%f\r\n",w_zBias); |
| jhedmonton | 28:5905886c76ee | 49 | |
| jhedmonton | 28:5905886c76ee | 50 | fclose(fp); |
| jhedmonton | 28:5905886c76ee | 51 | } |
| jhedmonton | 28:5905886c76ee | 52 | |
| jhedmonton | 28:5905886c76ee | 53 | int Config_SetID() |
| jhedmonton | 28:5905886c76ee | 54 | { |
| jhedmonton | 28:5905886c76ee | 55 | char mac[6]; |
| jhedmonton | 28:5905886c76ee | 56 | mbed_mac_address(mac); |
| jhedmonton | 28:5905886c76ee | 57 | return( mac[3] << 16 | mac[4] << 8 | mac[5] << 0); |
| jhedmonton | 28:5905886c76ee | 58 | } |
| jhedmonton | 28:5905886c76ee | 59 | |
| jhedmonton | 28:5905886c76ee | 60 | int Config_GetID() |
| jhedmonton | 28:5905886c76ee | 61 | { |
| jhedmonton | 28:5905886c76ee | 62 | char mac[6]; |
| jhedmonton | 28:5905886c76ee | 63 | mbed_mac_address(mac); |
| jhedmonton | 28:5905886c76ee | 64 | int id = mac[3] << 16 | mac[4] << 8 | mac[5] << 0; // Bytes 4-6 form the unique idenfitfier |
| jhedmonton | 28:5905886c76ee | 65 | |
| jhedmonton | 28:5905886c76ee | 66 | return id; |
| jhedmonton | 28:5905886c76ee | 67 | } |
