diff --git a/firmware/v01/Makefile b/firmware/v01/Makefile index 6d6e285..a055371 100644 --- a/firmware/v01/Makefile +++ b/firmware/v01/Makefile @@ -4,12 +4,12 @@ BOARD_TAG = pro BOARD_SUB = 8MHzatmega328 USER_LIB_PATH += /home/ricardo/Arduino/libraries ARDUINO_LIBS += LiquidCrystal \ - SPI \ - SD \ - SoftwareSerial + SPI \ + SD \ + SoftwareSerial -ARDUINO_DIR = /home/ricardo/arduino-1.8.5 -# ARDUINO_DIR = /home/ricardo/Installs/arduino-1.8.7 +# ARDUINO_DIR = /home/ricardo/arduino-1.8.5 + ARDUINO_DIR = /home/ricardo/Installs/arduino-1.8.7 MONITOR_PORT = /dev/ttyUSB0 -include /usr/share/arduino/Arduino.mk -include /home/ricardo/Installs/Arduino-Makefile-1.6.0/Arduino.mk diff --git a/firmware/v01/v01.ino b/firmware/v01/v01.ino index 7c2908b..32bb033 100644 --- a/firmware/v01/v01.ino +++ b/firmware/v01/v01.ino @@ -27,6 +27,7 @@ Tue Jun 12 14:56:12 GMT 2018 #define ACT 19 // Button 3 will be function Action #define BLUE_RX 8 // Arduino rx serial line to bluetooth #define BLUE_TX 9 // Arduino tx serial line to bluetooth +const int chipSelect = 10; // Chip Select pin for controlling SD card LiquidCrystal lcd(7, 6, 2, 3, 4, 5); // LCD screen pins, LiquidCrystal(rs, enable, d4, d5, d6, d7) //----------------------------------------------------------------------------------------------------- @@ -75,8 +76,8 @@ String screens[numOfScreens][2] = {{"Voltage 1","Volts"}, {"Voltage 2","Volts"}, String parameters_sd[2] = {"No","Yes"}; // String to display the sd card logging String parameters_load[2] = {"Off","On"}; // String to display the load state String sd_card[4] = {"Card missing","Card inserted","File Write fail","Writing..."}; // String to display the sd card state -String file_name = "measures"; // Initial file name only 8 characters allowed -float parameters[4]; // Parameters of the several voltages and current +String file_name = "measures"; // Initial file name only 8 characters allowed +float parameters[4]; // Parameters of the several voltages and current float denominator; // Denominator to calculate the voltage divider int resistor1 = 22000; // Resistor one of voltage divider @@ -125,7 +126,7 @@ void setup() interrupts(); // enable all interrupts // ---------------------------------------------------------- - if (SD.begin()) // Initiate SD card + if (SD.begin(chipSelect)) // Initiate SD card { sd_status = sd_in; // If sd card is initiated successfully change variable sd_in sd_inserted = yes; // and change variable sd_inserted to yes @@ -147,30 +148,41 @@ ISR(TIMER1_COMPA_vect) } digitalWrite(load_line, load_status); // Turn load on or off depending on the load_status + + + if (mySerial.available()) { ble_data = mySerial.read(); - Serial.write(mySerial.read()); - if (ble_data == 'A') { +// Serial.write(mySerial.read()); // For debug only + switch(ble_data) + { + case 'a': dtostrf(parameters[battery_volt], 5, 2, outstr); mySerial.write(outstr); - } - if (ble_data == 'B') { + break; + + case 'b': dtostrf(parameters[voltage_1], 5, 2, outstr); mySerial.write(outstr); - } - if (ble_data == 'C') { + break; + + case 'c': dtostrf(parameters[voltage_2], 5, 2, outstr); mySerial.write(outstr); - } - if (ble_data == 'D') { + break; + + case 'd': dtostrf(parameters[curr], 5, 2, outstr); mySerial.write(outstr); - } - if (ble_data == 'E') { + break; + + case 'e': load_status = on; - } - if (ble_data == 'F') { + break; + + case 'f': load_status = off; + break; } } } @@ -187,8 +199,6 @@ void loop() - Serial.write(ble_data); // For debug only - if (sd_inserted == no) // If SD card is not inserted { sd_status = sd_not_in; // change card status to sd card not inserted