Page 1 of 1

shell script for the lcd shutdown

Posted: Mon Feb 19, 2018 6:16 pm
by novice81
im new to this and was wondering if anyone could help with some shell script to get the lcd to shut off when you issue the " sudo shutdown now" comand

Re: shell script for the lcd shutdown

Posted: Mon Feb 19, 2018 6:29 pm
by elParaguayo
Have you seen this thread: viewtopic.php?f=32&t=204627

If your question is different, please provide more information about what you're trying to do.

Re: shell script for the lcd shutdown

Posted: Mon Feb 19, 2018 6:33 pm
by novice81
yes i have i wrote that thread to see if it was possible and how to access the directory if it was. now that i have established its possible i would like some help with the code to put in the shutdown directory to make the lcd off when i issue the shutdown command because my teacher doesn"t know what hes doing

Re: shell script for the lcd shutdown

Posted: Mon Feb 19, 2018 7:20 pm
by elParaguayo
Sorry, had missed that it was your thread. Why not carry on in that thread if it's directly related?

Re: shell script for the lcd shutdown

Posted: Mon Feb 19, 2018 7:26 pm
by novice81
i could've but in my mind it was 2 seperate things and/or topics, but thats just me

Re: shell script for the lcd shutdown

Posted: Mon Feb 19, 2018 8:21 pm
by pcmanbob
if you are still talking about the 16x2 LCD then as I said before all you can do is turn off the back light.

But would need to know how you are controlling the 16X2 LCD i2c or direct on gpio.

Re: shell script for the lcd shutdown

Posted: Mon Feb 19, 2018 8:25 pm
by novice81
we are using i2c

Re: shell script for the lcd shutdown

Posted: Mon Feb 19, 2018 8:33 pm
by pcmanbob
novice81 wrote:
Mon Feb 19, 2018 8:25 pm
we are using i2c
Don't have LCD with that interface but depending on the drivers you are using it may be possible
see this thread viewtopic.php?f=32&t=204036&hilit=lcd+backlight

Re: shell script for the lcd shutdown

Posted: Wed Feb 21, 2018 5:56 pm
by novice81
i have the code i just don't know how to get it to run when issuing the shutdown command, thats what i need help with

Re: shell script for the lcd shutdown

Posted: Thu Feb 22, 2018 9:25 am
by pcmanbob
Can you not add it to the program that is using the LCD so that when you exit that it issues the the instruction to turn off the LCD.

Re: shell script for the lcd shutdown

Posted: Mon Feb 26, 2018 5:56 pm
by novice81
I was under the impression you had to add a line that initiates it upon shutdown are you saying you can just put it in the directory and it works?

Re: shell script for the lcd shutdown

Posted: Mon Feb 26, 2018 6:23 pm
by pcmanbob
If you have a line of python code that instructs you LCD to turn off the back light then that line of code needs to be run using python So the place to add it is in the python program that is controlling your LCD.

If you wanted this to happen on shutdown you would have to run a python program before shutting down that was able to import the relevant driver and then execute the command to turn off the back light.

you can't run a random line of python code in the shell which is what is controlling the shutdown.

is there a particular reason you want to turn the back light off when shutting down ?

Re: shell script for the lcd shutdown

Posted: Mon Feb 26, 2018 7:03 pm
by novice81
it a project my teacher gave me. he gave me the project because my class mates would get confused on the shutdown because the lcd would still be on even though the machine itself would be done writing to the card.

Re: shell script for the lcd shutdown

Posted: Mon Feb 26, 2018 7:28 pm
by pcmanbob
On one of my pi builds that does broadband speed testing and has a 20x4 LCD I that I loan out to people with broadband speed issues, i simply put up a final message that says "Please wait 30 sec before powering off good bye"

how are you ending the program that does the writing to the LCD ?
can't you add the back light off command to that program so that when you exit it the last thing it does is turn off the back light.

If you really want to power the back light only on shutdown, you could modify the LCD so the the back light is controlled by a transistor, you can then bias the base low normally and on power up you run a python program that drives the base high turning on the back light, then on shutdown all outputs would switch off resulting in display being off.