Psi Swarm robot library version 0.9

Dependents:   PsiSwarm_V9_Blank

Fork of PsiSwarmV9 by James Hilder

Revision:
8:6c92789d5f87
Parent:
6:b340a527add9
Child:
12:878c6e9d9e60
diff -r aa5a4a257895 -r 6c92789d5f87 eprom.cpp
--- a/eprom.cpp	Sun Oct 16 11:11:21 2016 +0000
+++ b/eprom.cpp	Sun Oct 16 12:54:33 2016 +0000
@@ -1,11 +1,11 @@
 /** University of York Robotics Laboratory PsiSwarm Library: Eprom Functions Source File
- * 
+ *
  * Copyright 2016 University of York
  *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
  * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and limitations under the License.
  *
  * File: eprom.cpp
@@ -13,7 +13,7 @@
  * (C) Dept. Electronics & Computer Science, University of York
  * James Hilder, Alan Millard, Alexander Horsfield, Homero Elizondo, Jon Timmis
  *
- * PsiSwarm Library Version: 0.7
+ * PsiSwarm Library Version: 0.8
  *
  * October 2016
  *
@@ -25,8 +25,8 @@
  *
  * int main() {
  *     init();
- *     write_eeprom_byte(0,0xDD);    //Writes byte 0xDD in EPROM address 0
- *     char c = read_eeprom_byte(0); //c will hold 0xDD
+ *     eprom.write_eeprom_byte(0,0xDD);    //Writes byte 0xDD in EPROM address 0
+ *     char c = eprom.read_eeprom_byte(0); //c will hold 0xDD
  *     //Valid address range is from 0 to 65279
  * }
  * @endcode
@@ -39,7 +39,7 @@
  * @param address The address to store the data, range 0-65279
  * @param data The character to store
  */
-void write_eeprom_byte ( int address, char data )
+void Eprom::write_eeprom_byte ( int address, char data )
 {
     char write_array[3];
     if(address > 65279) {
@@ -59,7 +59,7 @@
  * @param address The address to read from, range 0-65279
  * @return The character stored at address
  */
-char read_eeprom_byte ( int address )
+char Eprom::read_eeprom_byte ( int address )
 {
     char address_array [2];
     address_array[0] = address / 256;
@@ -74,7 +74,7 @@
  *
  * @return The character stored at address after the previous one read from
  */
-char read_next_eeprom_byte ()
+char Eprom::read_next_eeprom_byte ()
 {
     char data [1];
     primary_i2c.read(EEPROM_ADDRESS, data, 1, false);
@@ -85,7 +85,7 @@
  *
  * @return 1 if a valid firmware is read, 0 otherwise
  */
-char read_firmware ()
+char Eprom::read_firmware ()
 {
     char address_array [2] = {255,0};
     primary_i2c.write(EEPROM_ADDRESS, address_array, 2, false);
@@ -113,18 +113,18 @@
         has_temperature_sensor= firmware_bytes[19];
         has_recharging_circuit= firmware_bytes[20];
         has_433_radio= firmware_bytes[21];
-        if(firmware_version > 1.0){
-        motor_calibration_set = firmware_bytes[22];
-        if(motor_calibration_set == 1){
-            left_motor_calibration_value = (float) firmware_bytes[23] * 65536;
-            left_motor_calibration_value += ((float) firmware_bytes[24] * 256);
-            left_motor_calibration_value += firmware_bytes[25];
-            left_motor_calibration_value /= 16777216;
-            right_motor_calibration_value = (float) firmware_bytes[26] * 65536;
-            right_motor_calibration_value += ((float) firmware_bytes[27] * 256);
-            right_motor_calibration_value += firmware_bytes[28];
-            right_motor_calibration_value /= 16777216;
-        }
+        if(firmware_version > 1.0) {
+            motor_calibration_set = firmware_bytes[22];
+            if(motor_calibration_set == 1) {
+                left_motor_calibration_value = (float) firmware_bytes[23] * 65536;
+                left_motor_calibration_value += ((float) firmware_bytes[24] * 256);
+                left_motor_calibration_value += firmware_bytes[25];
+                left_motor_calibration_value /= 16777216;
+                right_motor_calibration_value = (float) firmware_bytes[26] * 65536;
+                right_motor_calibration_value += ((float) firmware_bytes[27] * 256);
+                right_motor_calibration_value += firmware_bytes[28];
+                right_motor_calibration_value /= 16777216;
+            }
         } else motor_calibration_set = 0;
         return 1;
     }