Commit 9ad41b5e authored by Harshith Goka's avatar Harshith Goka

Five Flex Sensors

parent fe37890b
package com.example.harshith.ddc;
public class DynamicGesture extends Gesture {
public int [][][] eFrame;
public DynamicGesture(){
eFrame = new int [sensors][][];
for (int i=0; i<sensors; i++) {
eFrame[i] = new int [dataPoints][];
for (int j=0; j<dataPoints; j++) {
eFrame[i][j] = new int[2];
}
}
}
public void printData(){
for (int i=0; i<sensors; i++) {
for (int j=0; j<dataPoints; j++) {
System.out.print(eFrame[i][j][0]); System.out.print(":");
System.out.print(eFrame[i][j][1] + " ");
}
System.out.print('\n');
}
}
public void updateFrame(int [][][] sensorLimits){
for (int i=0; i<sensors; i++) {
for (int j=0; j<dataPoints; j++) {
for (int k=0; k<2; k++) {
eFrame[i][j][k] = sensorLimits[i][j][k];
}
}
}
}
public boolean isInFrame(Live live, int index){for (int i=0; i<sensors; i++) {
if(!((eFrame[i][index][0]<live.reading[i]) && (live.reading[i]<eFrame[i][index][1]))){
return false;
}
}
return true;
}
}
\ No newline at end of file
package com.example.harshith.ddc;
public class Frame{
boolean mpu;
public int upperBound;
public int lowerBound;
public Frame(int index, boolean isMpu, int upBound, int lrBound, int levels){
if(!isMpu){
upperBound = upBound + index*((lrBound-upBound)/levels);
lowerBound = upBound + (index+1)*((lrBound-upBound)/levels);
}
else{
upperBound = lrBound - (index+2)*((lrBound-upBound)/levels);
lowerBound = lrBound - (index+1)*((lrBound-upBound)/levels);
}
if(index == 8){
upperBound = upBound;
lowerBound = lrBound;
}
}
public void pushLimits(int []d){
d[0] = upperBound;
d[1] = lowerBound;
}
public void print(){
System.out.print(upperBound);
System.out.print(' ');
System.out.println(lowerBound);
}
}
\ No newline at end of file
package com.example.harshith.ddc;
public class Gesture{
public int dataPoints = 15;
public int sensors = 11;
public int adcLevels = 2;
public int adcUpper = 60;
public int adcLower = 200;
public int mpuLevels = 3;
public int mpuUpper = 18000;
public int mpuLower = -18000;
public Gesture(){}
public void printData(){
System.out.println("Printing data...");
}
public void updateFrame(int [][] sensorLimits){
System.out.println("Updating static frame...");
}
public void updateFrame(int [][][] sensorLimits){
System.out.println("Updating dynamic frame...");
}
public void updateFrame(int []fing){
System.out.println("Updating frame for real...");
}
public boolean isInFrame(Live live){
System.out.println("Checking if the value is in the static frame...");
return true;
}
public boolean isInFrame(Live live, int index){
System.out.println("Checking if the value is in the dynamic frame...");
return true;
}
public void execute(int gest){
// perform system function
System.out.println(gest);
}
}
\ No newline at end of file
package com.example.harshith.ddc;
public class StaticGesture extends Gesture {
public int [][] eFrame;
public StaticGesture(){
eFrame = new int [sensors] [];
for (int i=0; i<sensors; i++) {
eFrame[i] = new int [2];
}
}
public void printData(){
for (int i=0; i<5; i++) {
String text = String.format("%03d", eFrame[i][0]);
System.out.print(text);
System.out.print(" ");
}
for (int i=5; i<sensors; i++) {
if(eFrame[i][1]<0) System.out.print(" ");
String text = String.format("%05d", eFrame[i][0]);
System.out.print(text);
System.out.print(" ");
}
System.out.print('\n');
for (int i=0; i<5; i++) {
String text = String.format("%03d", eFrame[i][1]);
System.out.print(text);
System.out.print(" ");
}
for (int i=5; i<sensors; i++) {
String text = String.format("%05d", eFrame[i][1]);
System.out.print(text);
System.out.print(" ");
}
System.out.print('\n');
}
public void updateFrame(int [][] sensorLimits){
//super.updateFrame(sensorLimits);
for (int i=0; i<sensors; i++) {
for (int j=0; j<2; j++) {
eFrame[i][j] = sensorLimits[i][j];
}
}
}
public void updateFrame(int []hand){
int [][]data = new int [sensors][2];
Frame []f = new Frame[sensors];
for (int i=0; i<5; i++) {
f[i] = new Frame(hand[i], false, adcUpper, adcLower, 2);
}
for (int i=5; i<sensors; i++) {
f[i] = new Frame(hand[i], true, mpuUpper, mpuLower, 3);
}
for (int i=0; i<sensors; i++) {
f[i].pushLimits(data[i]);
}
this.updateFrame(data);
}
public boolean isInFrame(Live live){for (int i=0; i<sensors; i++) {
if(!((eFrame[i][0]<live.reading[i]) && (live.reading[i]<eFrame[i][1]))){
return false;
}
}
return true;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment