novice81
Posts: 10
Joined: Mon Feb 05, 2018 8:36 pm

shell script for the lcd shutdown

Mon Feb 19, 2018 6:16 pm

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

User avatar
elParaguayo
Posts: 1943
Joined: Wed May 16, 2012 12:46 pm
Location: London, UK

Re: shell script for the lcd shutdown

Mon Feb 19, 2018 6:29 pm

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.
RPi Information Screen: plugin based system for displaying weather, travel information, football scores etc.

novice81
Posts: 10
Joined: Mon Feb 05, 2018 8:36 pm

Re: shell script for the lcd shutdown

Mon Feb 19, 2018 6:33 pm

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

User avatar
elParaguayo
Posts: 1943
Joined: Wed May 16, 2012 12:46 pm
Location: London, UK

Re: shell script for the lcd shutdown

Mon Feb 19, 2018 7:20 pm

Sorry, had missed that it was your thread. Why not carry on in that thread if it's directly related?
RPi Information Screen: plugin based system for displaying weather, travel information, football scores etc.

novice81
Posts: 10
Joined: Mon Feb 05, 2018 8:36 pm

Re: shell script for the lcd shutdown

Mon Feb 19, 2018 7:26 pm

i could've but in my mind it was 2 seperate things and/or topics, but thats just me

pcmanbob
Posts: 7306
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: shell script for the lcd shutdown

Mon Feb 19, 2018 8:21 pm

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.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

novice81
Posts: 10
Joined: Mon Feb 05, 2018 8:36 pm

Re: shell script for the lcd shutdown

Mon Feb 19, 2018 8:25 pm

we are using i2c

pcmanbob
Posts: 7306
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: shell script for the lcd shutdown

Mon Feb 19, 2018 8:33 pm

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
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

novice81
Posts: 10
Joined: Mon Feb 05, 2018 8:36 pm

Re: shell script for the lcd shutdown

Wed Feb 21, 2018 5:56 pm

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

pcmanbob
Posts: 7306
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: shell script for the lcd shutdown

Thu Feb 22, 2018 9:25 am

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.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

novice81
Posts: 10
Joined: Mon Feb 05, 2018 8:36 pm

Re: shell script for the lcd shutdown

Mon Feb 26, 2018 5:56 pm

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?

pcmanbob
Posts: 7306
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: shell script for the lcd shutdown

Mon Feb 26, 2018 6:23 pm

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 ?
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

novice81
Posts: 10
Joined: Mon Feb 05, 2018 8:36 pm

Re: shell script for the lcd shutdown

Mon Feb 26, 2018 7:03 pm

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.

pcmanbob
Posts: 7306
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: shell script for the lcd shutdown

Mon Feb 26, 2018 7:28 pm

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.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

Return to “Python”