Skip to content

Commit c7cb240

Browse files
author
ICMT
committed
commandye
1 parent 7ec1f47 commit c7cb240

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

src/main.cpp

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,6 @@ void saveKeys()
301301
Serial.println("Keys saved");
302302
}
303303

304-
305304
bool isDuplicateKey(const char *username, const char *secret)
306305
{
307306
for (int i = 0; i < keysCount; i++)
@@ -652,6 +651,23 @@ void processSerialInput()
652651
Serial.println("Invalid key index");
653652
}
654653
}
654+
else if (serialLine.startsWith("setunixtime "))
655+
{
656+
String timeStr = serialLine.substring(strlen("setunixtime "));
657+
timeStr.trim();
658+
unsigned long unixTime = timeStr.toInt();
659+
if (unixTime > 0)
660+
{
661+
rtc.adjust(DateTime(unixTime));
662+
Serial.print("RTC time set to Unix time: ");
663+
Serial.println(unixTime);
664+
}
665+
else
666+
{
667+
Serial.println("Invalid Unix time");
668+
}
669+
}
670+
655671
else if (serialLine == "list")
656672
{
657673
if (locked)
@@ -740,8 +756,10 @@ void configureWakeupButtons()
740756
nrf_gpio_cfg_sense_input(BUTTON_DOWN_PIN, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW);
741757
}
742758

743-
void fadeOutDisplay() {
744-
for (int contrast = 200; contrast >= 0; contrast -= 15) {
759+
void fadeOutDisplay()
760+
{
761+
for (int contrast = 200; contrast >= 0; contrast -= 15)
762+
{
745763
display.ssd1306_command(SSD1306_SETCONTRAST);
746764
display.ssd1306_command(contrast);
747765
delay(60);
@@ -777,14 +795,18 @@ void setup()
777795
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C))
778796
{
779797
Serial.println("SSD1306 init failed");
780-
while (1) {}
798+
while (1)
799+
{
800+
}
781801
}
782802
display.display();
783803

784804
if (!rtc.begin())
785805
{
786806
Serial.println("RTC init failed");
787-
while (1) {}
807+
while (1)
808+
{
809+
}
788810
}
789811

790812
configureWakeupButtons();

0 commit comments

Comments
 (0)