![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Table controller for piswarm-office
Fork of PiSwarmTableController by
Revision 5:68a1ce96bfeb, committed 2014-08-14
- Comitter:
- hee502
- Date:
- Thu Aug 14 09:06:31 2014 +0000
- Parent:
- 4:3cbff30b7b7b
- Commit message:
- Table controller for piswarm-office
Changed in this revision
diff -r 3cbff30b7b7b -r 68a1ce96bfeb alpha433.cpp --- a/alpha433.cpp Fri Jul 18 21:23:37 2014 +0000 +++ b/alpha433.cpp Thu Aug 14 09:06:31 2014 +0000 @@ -239,7 +239,7 @@ //Add reset timeout reset_timeout.detach(); reset_timeout.attach(this,&Alpha433::timeout,0.5); - pc.printf("Rec. ISR\n"); + //pc.printf("Rec. ISR\n"); int res = _read(0x0000); if(res==0) res = _read(0x0000); char read_failure = 0;
diff -r 3cbff30b7b7b -r 68a1ce96bfeb communications.cpp --- a/communications.cpp Fri Jul 18 21:23:37 2014 +0000 +++ b/communications.cpp Thu Aug 14 09:06:31 2014 +0000 @@ -47,7 +47,7 @@ } message[4+length]=NULL; rf.sendString(4+length,message); - if(RF_DEBUG==1)pc.printf("RF message sent"); + //if(RF_DEBUG==1)//pc.printf("RF message sent"); } @@ -171,7 +171,7 @@ case 0: // Stop [0 data] if(length==0) { //piswarm.stop(); - if(RF_DEBUG==1) pc.printf(" - Stop Command Issued - "); + if(RF_DEBUG==1) //pc.printf(" - Stop Command Issued - "); success = 1; } else if(RF_DEBUG==1) pc.printf(" - Invalid\n"); break;
diff -r 3cbff30b7b7b -r 68a1ce96bfeb main.cpp --- a/main.cpp Fri Jul 18 21:23:37 2014 +0000 +++ b/main.cpp Thu Aug 14 09:06:31 2014 +0000 @@ -7,13 +7,13 @@ #include "main.h" #include "communications.h" #include "display.h" //Display driver for the Midas 16x2 I2C Display - +LocalFileSystem local("local"); //OBJECTS PwmOut ir_pwm_out(p21); //PWM Output for the IR LED driver DigitalOut ir_led(LED1); DigitalOut tx_led(LED3); DigitalOut pir_led(LED4); -AnalogIn input_1(p20); +DigitalIn input_1(p20); AnalogIn input_2(p19); DigitalIn input_3(p18); DigitalIn input_4(p17); @@ -46,6 +46,7 @@ float speed = 0; int sound = 0; +float soundLevel = 0.00; float soundRaw = 0; float soundFiltered = 0; float soundFilteredPrev = 0; @@ -53,10 +54,17 @@ float targetY = 0; char data[13];//0-3:speed, 4:sound, 5-8:targetX, 9-12:targetY char * dataP; +char text[17]; +char *textP = &text[0]; int level_3 = 0; int level_4 = 0; int level_5 = 0; int level_6 = 0; +int pir[3]; +int fileCount = 0; +char fileName[50]; + +FILE *fp; //int counter = 0;//for Edgar to try effect of sound change @@ -71,13 +79,15 @@ init(); char phase = 0; char motor_step = 0; + pc.baud(9600); + //pc.printf("hello"); ir_led_timer.start(); ir_pwm_out.period_us(1000); ir_pwm_out.pulsewidth_us(0); polling_ticker.attach(&polling,0.2); soundFiltered = 3400.00;//R17=137K, background~3400 - sound_ticker.attach(&soundReading,0.01); - + sound_ticker.attach(&soundReading,1.0); + while(1) { if(command_timer.read_us() > 500000){ command_timer.reset(); @@ -133,7 +143,8 @@ void polling(){ /*Movement*/ - if(input_3.read() == 1){ + pir[0] = input_3.read(); + if(pir[0] == 1){ if(level_3 < 10){ level_3++; } @@ -143,7 +154,8 @@ level_3--; } } - if(input_4.read() == 1){ + pir[1] = input_4.read(); + if(pir[1] == 1){ if(level_4 < 10){ level_4++; } @@ -153,7 +165,8 @@ level_4--; } } - if(input_5.read() == 1){ + pir[2] = input_5.read(); + if(pir[2] == 1){ if(level_5 < 10){ level_5++; } @@ -258,18 +271,40 @@ snprintf(text,17,"3:%i 4:%i 5:%i 6:%i",input_3_window,input_4_window,input_5_window,input_6_window); display.write_string(text,16); }*/ + /*sprintf(fileName,"%s%d%s","/local/",fileCount,".txt"); + fp = fopen(fileName, "w"); + snprintf(text,17,"%d,%d,%d,%0.2f,%d\n", pir[0],pir[1],pir[2],speed, sound); + fprintf(fp, "text/n/r"); + fclose(fp); + fileCount++;*/ } void soundReading(void){ - soundFilteredPrev = soundFiltered;//save previous value - sound = input_1.read_u16();//read new value - soundFiltered *= 0.96;//filter new value - soundRaw = sound * 0.04; - soundFiltered += soundRaw; + //soundFilteredPrev = soundFiltered;//save previous value + //sound = input_1.read_u16();//read new value + if(input_1){ + soundLevel+=0.1; + if(soundLevel > 1.0) + soundLevel = 1.0; + } + else{ + soundLevel-=0.07; + if(soundLevel < 0.00) + soundLevel = 0.00; + } + if(soundLevel > 0.5){ + sound = 1; + } + else{ + sound = 0; + } + //soundFiltered *= 0.96;//filter new value + //soundRaw = sound * 0.04; + //soundFiltered += soundRaw; /*if((soundFiltered - soundFilteredPrev) > 10.00) soundFiltered = soundFilteredPrev + 10.00; if((soundFiltered - soundFilteredPrev) < -10.00) - soundFiltered = soundFilteredPrev - 10.00;*/ + soundFiltered = soundFilteredPrev - 10.00;*/ } void handleUserRFCommand(char sender, char broadcast_message, char request_response, char id, char is_command, char function, char * data, char length){