Replaced BLE if statment to a switch statment.
This commit is contained in:
@@ -8,8 +8,8 @@ ARDUINO_LIBS += LiquidCrystal \
|
|||||||
SD \
|
SD \
|
||||||
SoftwareSerial
|
SoftwareSerial
|
||||||
|
|
||||||
ARDUINO_DIR = /home/ricardo/arduino-1.8.5
|
# ARDUINO_DIR = /home/ricardo/arduino-1.8.5
|
||||||
# ARDUINO_DIR = /home/ricardo/Installs/arduino-1.8.7
|
ARDUINO_DIR = /home/ricardo/Installs/arduino-1.8.7
|
||||||
MONITOR_PORT = /dev/ttyUSB0
|
MONITOR_PORT = /dev/ttyUSB0
|
||||||
-include /usr/share/arduino/Arduino.mk
|
-include /usr/share/arduino/Arduino.mk
|
||||||
-include /home/ricardo/Installs/Arduino-Makefile-1.6.0/Arduino.mk
|
-include /home/ricardo/Installs/Arduino-Makefile-1.6.0/Arduino.mk
|
||||||
|
@@ -27,6 +27,7 @@ Tue Jun 12 14:56:12 GMT 2018
|
|||||||
#define ACT 19 // Button 3 will be function Action
|
#define ACT 19 // Button 3 will be function Action
|
||||||
#define BLUE_RX 8 // Arduino rx serial line to bluetooth
|
#define BLUE_RX 8 // Arduino rx serial line to bluetooth
|
||||||
#define BLUE_TX 9 // Arduino tx 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)
|
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
|
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_status = sd_in; // If sd card is initiated successfully change variable sd_in
|
||||||
sd_inserted = yes; // and change variable sd_inserted to yes
|
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
|
digitalWrite(load_line, load_status); // Turn load on or off depending on the load_status
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (mySerial.available()) {
|
if (mySerial.available()) {
|
||||||
ble_data = mySerial.read();
|
ble_data = mySerial.read();
|
||||||
Serial.write(mySerial.read());
|
// Serial.write(mySerial.read()); // For debug only
|
||||||
if (ble_data == 'A') {
|
switch(ble_data)
|
||||||
|
{
|
||||||
|
case 'a':
|
||||||
dtostrf(parameters[battery_volt], 5, 2, outstr);
|
dtostrf(parameters[battery_volt], 5, 2, outstr);
|
||||||
mySerial.write(outstr);
|
mySerial.write(outstr);
|
||||||
}
|
break;
|
||||||
if (ble_data == 'B') {
|
|
||||||
|
case 'b':
|
||||||
dtostrf(parameters[voltage_1], 5, 2, outstr);
|
dtostrf(parameters[voltage_1], 5, 2, outstr);
|
||||||
mySerial.write(outstr);
|
mySerial.write(outstr);
|
||||||
}
|
break;
|
||||||
if (ble_data == 'C') {
|
|
||||||
|
case 'c':
|
||||||
dtostrf(parameters[voltage_2], 5, 2, outstr);
|
dtostrf(parameters[voltage_2], 5, 2, outstr);
|
||||||
mySerial.write(outstr);
|
mySerial.write(outstr);
|
||||||
}
|
break;
|
||||||
if (ble_data == 'D') {
|
|
||||||
|
case 'd':
|
||||||
dtostrf(parameters[curr], 5, 2, outstr);
|
dtostrf(parameters[curr], 5, 2, outstr);
|
||||||
mySerial.write(outstr);
|
mySerial.write(outstr);
|
||||||
}
|
break;
|
||||||
if (ble_data == 'E') {
|
|
||||||
|
case 'e':
|
||||||
load_status = on;
|
load_status = on;
|
||||||
}
|
break;
|
||||||
if (ble_data == 'F') {
|
|
||||||
|
case 'f':
|
||||||
load_status = off;
|
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
|
if (sd_inserted == no) // If SD card is not inserted
|
||||||
{
|
{
|
||||||
sd_status = sd_not_in; // change card status to sd card not inserted
|
sd_status = sd_not_in; // change card status to sd card not inserted
|
||||||
|
Reference in New Issue
Block a user