
MEAS KMA36 DCS FOR MicroZed
Digital Position Sensor
SENSOR SOLUTIONS /// MEAS KMA36 DCS DEVELOPMENT KIT 07/2016
printf("Disable Fast Rate Complete with status: ");
if(stat==kma36_status_ok)
printf("Ok.\n");
if(stat==kma36_status_i2c_transfer_error)
printf("Transfer Error.\n");
}
// Wait for another key press and then display the main menu again
printf("\nPress any key to continue...\n");
read(1, (char*)&key_input, 1);
kma36_main_menu();
}else if(key_input == 'a' || key_input == 'A'){ //If the 'a' or 'A' key is pressed
if(address_set_flag==0){ // Address was not set yet--cannot perform this operation
printf("KMA36 I2C Address has not yet been set. Cannot complete this operation.\n");
}else{
// Display oversampling selection menu
printf("\n");
printf("Select an oversampling rate:\n");
printf(" (0) - Oversampling Rate 2\n");
printf(" (1) - Oversampling Rate 4\n");
printf(" (2) - Oversampling Rate 8\n");
printf(" (3) - Oversampling Rate 32\n");
// Get keyboard input ignoring keypresses that are not '0' or '1' or '2' or '3'
read(1, (char*)&key_input, 1);
while(key_input!='0' && key_input!='1' && key_input!='2' && key_input!='3'){
read(1, (char*)&key_input, 1);
}
if(key_input == '0'){ // If the '0' key is pressed
// Set oversampling to 2
kma36_set_accuracy(kma36_oversampling_2);
printf("Set KMA36 Oversampling Rate to 2\n");
}else if(key_input == '1'){ // If the '1' key is pressed
// Set oversampling to 4
kma36_set_accuracy(kma36_oversampling_4);
printf("Set KMA36 Oversampling Rate to 4\n");
}else if(key_input == '2'){ // If the '2' key is pressed
// Set oversampling to 8
kma36_set_accuracy(kma36_oversampling_8);
printf("Set KMA36 Oversampling Rate to 8\n");
}else if(key_input == '3'){ // If the '3' key is pressed
// Set oversampling to 32
kma36_set_accuracy(kma36_oversampling_32);
printf("Set KMA36 Oversampling Rate to 32\n");
}
}
// Wait for another key press and then display the main menu again
printf("\nPress any key to continue...\n");
read(1, (char*)&key_input, 1);
kma36_main_menu();
}else if(key_input == 'b' || key_input == 'B'){ // If the 'b' or 'B' key is pressed
if(address_set_flag==0){ // Address was not set yet--cannot perform this operation
printf("KMA36 I2C Address has not yet been set. Cannot complete this operation.\n");
}else{
res = 0;
// If resolution is out of bounds, get a new number
while(res<1 || res>32767){
res = 0;
// Display oversampling selection menu
printf("\nSpecify a resolution between 1 and 32767:\n ");
// Get keyboard input ignoring keypresses that are not numbers or the enter key
read(1, (char*)&key_input, 1);
if(key_input=='0' || key_input=='1' || key_input=='2' || key_input=='3' || key_input=='4' ||
key_input=='5' || key_input=='6' || key_input=='7' || key_input=='8' || key_input=='9'){
res *= 10;