Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Firmware/LoRaSerial/LoRaSerial.ino
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ bool trainingPreviousRxInProgress = false; //Previous RX status
float originalChannel; //Original channel from HOP table while training is in progress
uint8_t trainingPartnerID[UNIQUE_ID_BYTES]; //Unique ID of the training partner
uint8_t myUniqueId[UNIQUE_ID_BYTES]; // Unique ID of this system
uint32_t buttonPressedTime;

//Virtual-Circuit
int8_t cmdVc; //VC index for ATI commands only
Expand Down
20 changes: 12 additions & 8 deletions Firmware/LoRaSerial/System.ino
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ void updateButton()
static bool buttonWasPressed;
uint32_t deltaTime;
static Settings originalSettings;
static uint32_t pressedTime;

if (trainBtn != NULL)
{
Expand All @@ -271,9 +270,7 @@ void updateButton()
//Determine the current button state
if (buttonWasPressed)
{
//Update the LEDs
deltaTime = millis() - pressedTime;
buttonLeds(deltaTime);
deltaTime = millis() - buttonPressedTime;
if (!buttonPressed)
{
//Button just released
Expand Down Expand Up @@ -319,8 +316,6 @@ void updateButton()
else
{
//The user has stopped training with the button
//Restore the previous settings
settings = originalSettings;
if (inTraining)
{
inTraining = false;
Expand All @@ -338,11 +333,14 @@ void updateButton()
if (buttonPressed)
{
//Button just pressed
pressedTime = millis();
buttonPressedTime = millis();

//Save the previous led state
if (!inTraining)
{
originalSettings = settings;
settings.selectLedUse = LEDS_BUTTON_PRESS;
}
}
}

Expand Down Expand Up @@ -1064,14 +1062,16 @@ void updateCylonLEDs()
}

//Acknowledge the button press
void buttonLeds(uint32_t pressedMilliseconds)
void buttonLeds()
{
const uint32_t blinkTime = 1000 / 4; //Blink 4 times per second
uint8_t on;
const uint32_t onTime = blinkTime / 2;
uint32_t pressedMilliseconds;
uint8_t seconds;

//Display the number of seconds the button has been pushed
pressedMilliseconds = millis() - buttonPressedTime;
seconds = pressedMilliseconds / 1000;
setRSSI((pressedMilliseconds >= trainButtonFactoryResetTime) ? 15 : seconds);

Expand Down Expand Up @@ -1146,6 +1146,10 @@ void updateLeds()
radioLeds();
break;

case LEDS_BUTTON_PRESS:
buttonLeds();
break;

//Turn off all the LEDs
case LEDS_ALL_OFF:
break;
Expand Down