changed read from int to short

pull/74/head
alanbjohnston 5 years ago committed by GitHub
parent 7d5908bac1
commit 669bc26f25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -18,7 +18,7 @@ int Sensor1 = 0;
int Sensor2 = 0; int Sensor2 = 0;
float Sensor3 = 0; float Sensor3 = 0;
void eeprom_word_write(int addr, int val); void eeprom_word_write(int addr, int val);
int eeprom_word_read(int addr); short eeprom_word_read(int addr);
void setup() { void setup() {
@ -47,9 +47,9 @@ void setup() {
Serial.println("Reading gyro offsets from EEPROM\n"); Serial.println("Reading gyro offsets from EEPROM\n");
float xOffset = ((float)eeprom_word_read(1))/100.0; float xOffset = ((float)eeprom_word_read(1)) / 100.0;
float yOffset = ((float)eeprom_word_read(2))/100.0; float yOffset = ((float)eeprom_word_read(2)) / 100.0;
float zOffset = ((float)eeprom_word_read(3))/100.0; float zOffset = ((float)eeprom_word_read(3)) / 100.0;
Serial.println(xOffset, DEC); Serial.println(xOffset, DEC);
Serial.println(yOffset, DEC); Serial.println(yOffset, DEC);
@ -71,9 +71,9 @@ void setup() {
eeprom_word_write(3, (int)(mpu6050.getGyroZoffset() * 100.0) + 0.5); eeprom_word_write(3, (int)(mpu6050.getGyroZoffset() * 100.0) + 0.5);
Serial.println(eeprom_word_read(0), HEX); Serial.println(eeprom_word_read(0), HEX);
Serial.println(((float)eeprom_word_read(1))/100.0, DEC); Serial.println(((float)eeprom_word_read(1)) / 100.0, DEC);
Serial.println(((float)eeprom_word_read(2))/100.0, DEC); Serial.println(((float)eeprom_word_read(2)) / 100.0, DEC);
Serial.println(((float)eeprom_word_read(3))/100.0, DEC); Serial.println(((float)eeprom_word_read(3)) / 100.0, DEC);
} }
} }
@ -135,7 +135,7 @@ void loop() {
delay(50); // wait for a second delay(50); // wait for a second
digitalWrite(PC13, HIGH); // turn the LED off digitalWrite(PC13, HIGH); // turn the LED off
char result = Serial1.read(); char result = Serial1.read();
// Serial1.println(result); // Serial1.println(result);
if (result == 'R') { if (result == 'R') {
Serial1.println("OK"); Serial1.println("OK");
@ -175,7 +175,7 @@ void loop() {
Serial1.print(" "); Serial1.print(" ");
Serial1.println(Sensor3); Serial1.println(Sensor3);
// Serial1.println(counter++); // Serial1.println(counter++);
} }
} }
#endif #endif
@ -192,7 +192,7 @@ void eeprom_word_write(int addr, int val)
} }
int eeprom_word_read(int addr) short eeprom_word_read(int addr)
{ {
return((EEPROM.read(addr * 2 + 1) << 8) | EEPROM.read(addr * 2)); return ((EEPROM.read(addr * 2 + 1) << 8) | EEPROM.read(addr * 2));
} }

Loading…
Cancel
Save

Powered by TurnKey Linux.