Add password/lock screen to firmware March 06, 2019 08:53AM |
Registered: 5 years ago Posts: 23 |
Re: Add password/lock screen to firmware March 06, 2019 07:57PM |
Admin Registered: 13 years ago Posts: 7,002 |
Re: Add password/lock screen to firmware March 06, 2019 09:36PM |
Admin Registered: 13 years ago Posts: 7,002 |
Re: Add password/lock screen to firmware March 06, 2019 10:10PM |
Admin Registered: 13 years ago Posts: 7,002 |
Re: Add password/lock screen to firmware March 07, 2019 02:32AM |
Registered: 5 years ago Posts: 23 |
Re: Add password/lock screen to firmware March 07, 2019 03:12AM |
Admin Registered: 13 years ago Posts: 7,002 |
static void lcd_lockscreen() { uint8_t entercode[4] = {0}; uint8_t combination[4] = {5,4,3,2}; bool lockstate = true; lcd.clear(); // "01234567890123456789" lcd.setCursor(0, 1); lcd_printPGM(PSTR( " Enter Combination. " )); lcd.setCursor(0, 3); lcd_printPGM(PSTR( " [ ][ ][ ][ ] " )); encoderDiff=0; while (lockstate) { for (int i = 0; i < 4; i++) { while(digitalRead(BTN_ENC) == HIGH) { entercode[ i ] = encoderDiff/4; lcd.setCursor(3+i*4, 3); lcd.print(itostr2(entercode[ i ])); } while(digitalRead(BTN_ENC) == LOW) {} lcd.setCursor(3+i*4, 3); lcd_printPGM(PSTR("XX")); } if ((entercode[0] == combination[0]) && (entercode[1] == combination[1]) && (entercode[2] == combination[2]) && (entercode[3] == combination[3])) { lockstate = false; } } buttons = 0; encoderDiff = 0; }Add it above the line "static void lcd_implementation_status_screen()"
void lcd_lockscreen();Added above the line " #define LCD_MESSAGE_CPGM(x) lcd_setstatus_PGM(PSTR(x))"
lcd_lockscreen();Add below the line " _delay_ms(1000); // wait 1sec to display the splash screen"
Re: Add password/lock screen to firmware March 07, 2019 09:01PM |
Registered: 5 years ago Posts: 23 |
static void lcd_lockscreen() { //state a function uint8_t entercode[4] = {0}; //variable to hold user input, a 4 item array, uint8_t instead of int to save memory i assume? uint8_t combination[4] = {5,4,3,2}; //variable holding password array bool lockstate = true; //boolean to toggle the while loop/lock screen lcd.clear(); //clears the LCD // "01234567890123456789" //<--commenting to remind numbers only? lcd.setCursor(0, 1); lcd_printPGM(PSTR( " Enter Combination. " )); //prints message on screen lcd.setCursor(0, 3); lcd_printPGM(PSTR( " [ ][ ][ ][ ] " )); //printPGM(PSTR( and print(F the same thing? to save memory? encoderDiff=0; //resets encoder value, how'd you know what the encoder variable is called? and why does it have to be reset? I took it out as a test and there doesn't seem to be any difference? while (lockstate) { //enters lock screen for (int i = 0; i < 4; i++) { //loops thru the 4 array items while(digitalRead(BTN_ENC) == HIGH) { //button function of encoder, a digital input, normally high when not pressed entercode[ i ] = encoderDiff/4; //divide by 4 because encoder skips in increments of 4? lcd.setCursor(3+i*4, 3); lcd.print(itostr2(entercode[ i ])); //displays value, question: what's print(itostr2, why not just print or print(F? } while(digitalRead(BTN_ENC) == LOW) {} //encoder button becomes low when pressed lcd.setCursor(3+i*4, 3); lcd_printPGM(PSTR("XX")); //hides input value by printing XX, also lets user know a value was inputted } if ((entercode[0] == combination[0]) && (entercode[1] == combination[1]) && (entercode[2] == combination[2]) && (entercode[3] == combination[3])) //when the entered and set passcode matches { lockstate = false; //sets boolean false to exit the loop/lock screen } } buttons = 0; //what is this? the variable was never used, left over code? encoderDiff = 0; //why do we have to reset the encoder value? does it affect anything if we just leave it? }
lcd.setCursor(0, 2); lcd_printPGM(PSTR( "CODE WRONG TRY AGAIN" )); lcd.setCursor(0, 3); lcd_printPGM(PSTR( " [ ][ ][ ][ ] " ));just after the IF function so it's fool proof and the user knows the code is wrong, and it clears the XX
In file included from sketch\ultralcd.cpp:40:0: sketch\ultralcd_implementation_hitachi_HD44780.h: In function 'void lcd_lockscreen()': sketch\ultralcd_implementation_hitachi_HD44780.h:433:28: warning: 'void lcd_lockscreen()' was declared 'extern' and later 'static' [-fpermissive] static void lcd_lockscreen() { ^ In file included from sketch\ultralcd.cpp:2:0: sketch\ultralcd.h:23:8: note: previous declaration of 'void lcd_lockscreen()' void lcd_lockscreen(); ^should i be concerned? I'm not really sure what it's saying? i think it's saying that
void loop()just before line 602
#ifdef SDSUPPORT if (card.saving)and it's not the right place, the lock screen pops up after I've selected a file in the SD card, and the lockscreen loops itself.
Re: Add password/lock screen to firmware March 07, 2019 10:44PM |
Admin Registered: 13 years ago Posts: 7,002 |
Re: Add password/lock screen to firmware March 12, 2019 02:38AM |
Registered: 5 years ago Posts: 23 |
Re: Add password/lock screen to firmware April 14, 2019 11:36PM |
Registered: 5 years ago Posts: 23 |
Re: Add password/lock screen to firmware April 18, 2019 09:17AM |
Admin Registered: 13 years ago Posts: 7,002 |
Re: Add password/lock screen to firmware April 18, 2019 10:05AM |
Admin Registered: 13 years ago Posts: 7,002 |
Re: Add password/lock screen to firmware April 18, 2019 10:34PM |
Registered: 5 years ago Posts: 23 |
Re: Add password/lock screen to firmware May 28, 2019 05:36AM |
Registered: 5 years ago Posts: 23 |
if(lock==1){ MENU_ITEM(function, "Unlock", lcd_lockscreen); }else{just before #ifdef SDSUPPORT in ultralcd.cpp