Replaced BLE if statment to a switch statment.

This commit is contained in:
2018-11-05 20:13:50 +00:00
parent 75fe7048fe
commit 19bbe242c3
2 changed files with 32 additions and 22 deletions

View File

@@ -8,8 +8,8 @@ ARDUINO_LIBS += LiquidCrystal \
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

View File

@@ -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)
//-----------------------------------------------------------------------------------------------------
@@ -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