aboutsummaryrefslogtreecommitdiff
path: root/libraries/Robot_Control/keyboard.cpp
diff options
context:
space:
mode:
authorCristian Maglie <c.maglie@bug.st>2013-08-23 15:59:24 +0200
committerCristian Maglie <c.maglie@bug.st>2013-08-23 15:59:24 +0200
commit540743129b2badb813b703208d121ff14553c147 (patch)
tree6fadb4ebce68e1f0cb298a282be135c23fd156ed /libraries/Robot_Control/keyboard.cpp
parent073b3ac9d4ae93ac0bb3a91afc65ae9d8f1d5d59 (diff)
parent67c84855c2f3ce99b091a756bb2ca1a016260659 (diff)
Merge branch 'ide-1.5.x' into dev-ide-1.5.x-discovery
Conflicts: app/src/processing/app/Preferences.java app/src/processing/app/debug/Uploader.java
Diffstat (limited to 'libraries/Robot_Control/keyboard.cpp')
-rw-r--r--libraries/Robot_Control/keyboard.cpp65
1 files changed, 0 insertions, 65 deletions
diff --git a/libraries/Robot_Control/keyboard.cpp b/libraries/Robot_Control/keyboard.cpp
deleted file mode 100644
index 7e647bb..0000000
--- a/libraries/Robot_Control/keyboard.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-#include "ArduinoRobot.h"
-
-#if ARDUINO >= 100
-#include "Arduino.h"
-#else
-#include "WProgram.h"
-#endif
-int pul_min[]={0,133,319,494,732};
-int pul_max[]={10,153,339,514,752};
-/*int pul_min[]={0,123,295,471,714};
-int pul_max[]={0,143,315,491,734};*/
-/*
-int pul_min[]={0,133,319,494,732};
-int pul_max[]={10,153,339,514,752};
-*/
-void sort(int* v);
-
-void RobotControl::keyboardCalibrate(int *vals){
- for(int i=0;i<5;i++){
- pul_min[i]=vals[i]-10;
- pul_max[i]=vals[i]+10;
- }
-}
-int8_t RobotControl::keyboardRead(void)
-{
-
- int lectura_pul;
- int8_t conta_pul=0;
- static int anterior=0;
-
- lectura_pul = this->averageAnalogInput(KEY);
-
- while ((conta_pul < NUMBER_BUTTONS) && !(lectura_pul >= pul_min[conta_pul] && lectura_pul <= pul_max[conta_pul]))
- conta_pul++;
-
- if (conta_pul >= NUMBER_BUTTONS)
- conta_pul = -1;
- else
- delay(100);
-
- return conta_pul;
-}
-
-int RobotControl::averageAnalogInput(int pinNum)
-{
- int vals[5];
- for(int i=0;i<5;i++){
- for(int j=i;j<5;j++){
- vals[j]=::analogRead(pinNum);
- }
- sort(vals);
- }
- return vals[0];
-}
-void sort(int* v){
- int tmp;
- for(int i=0;i<4;i++)
- for(int j=i+1;j<5;j++)
- if(v[j]<v[i]){
- tmp=v[j];
- v[j]=v[i];
- v[i]=tmp;
- }
- v[0]=v[3];
-} \ No newline at end of file