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: main.cpp
- Revision:
- 2:153ec87771a0
- Parent:
- 1:a770d742e28a
- Child:
- 3:f24de3613c5c
--- a/main.cpp Wed May 28 05:27:51 2014 +0000 +++ b/main.cpp Sun Jun 01 08:05:23 2014 +0000 @@ -1,26 +1,109 @@ #include "mbed.h" +#include "network.h" #include <fstream> +#include <cmath> +#include <queue> + #define PACKET_COUNT 4 -Serial pc(USBTX, USBRX); // tx, rx - DigitalOut myled1(LED1); - DigitalOut myled2(LED2); + Serial pc(USBTX, USBRX); // tx, rx + DigitalOut myled4(LED4); DigitalOut myled3(LED3); - DigitalOut myled4(LED4); - LocalFileSystem local("local"); // Create the local filesystem under the name "local" + LocalFileSystem local("local"); int read_buffer[100][20]; + + +//Converts the data from the buffer into values +//and puts it in a struct which we can pass to another fn + control_p set_cp_values(int packet_num){ + + control_p packet_data; + + int bit_index = 0; + int sequence = 0; + int furnace = 0; + int interval = 0; + int bit_decrement = 0; + + bit_decrement = 3; + for(; bit_index < 4; bit_index++){ + if( read_buffer[packet_num][2 + bit_index] == 1){ //need to add 2 because starrt bits + sequence += pow(2.0,bit_decrement); + } + bit_decrement--; + } + + bit_decrement = 3; + for(; bit_index < 8; bit_index++){ + if( read_buffer[packet_num][2 + bit_index] == 1){ + furnace += pow(2.0,bit_decrement); + } + bit_decrement--; + } + + bit_decrement = 6; + for(; bit_index < 18; bit_index++){ + if( read_buffer[packet_num][2 + bit_index] == 1){ + interval += pow(2.0,bit_decrement); + } + bit_decrement--; + } + + // packet_data.sequence = sequence; + // packet_data.furnace = furnace; + // packet_data.interval = interval; + + return packet_data; + + + + + +} + + +std::queue<vector<int> > buffer; +vector<int> numbers; + +std::queue<string> buffer2; + int main() { + + // numbers.push_back(1); + // numbers.push_back(2); + // numbers.push_back(3); + string a; + + a[0] = 'a'; + a[1] = 'b'; + + + // queue.push(numbers); + + myled4 = 1; int index = 0; int num_packets = 0; + /* + while(1){ + pc.printf("PYTHON PLZ"); + myled3= 1; + wait(1); + } + + return 0; + */ + FILE *fp = fopen("/local/packet.txt", "w"); - + fprintf(fp,"%s",a); + fclose(fp); + return 0; for(; num_packets < PACKET_COUNT; num_packets++){ @@ -47,6 +130,11 @@ } fclose(fp); - myled1 = 1; } + + + + + +