Oct-12-2023, 07:47 PM
Hey guys, my name is James I'm from Houston, TX, it's been roughly 22yrs since I last tried any programming in college. I recently decided to try and duplicate a switch panel that is made for off road (called a spod and has touchscreen control), it's almost $1200 to buy it and I'm about trying to make things my way cheaper, with more functionality. Over the last 3 weeks I have been writing this code to work in conjunction with a raspberry pi and touchscreen to operate different things on my 18 jeep jku, as well as my tuning software(HP Tuners). so far, I'm in about ~$80 and 3 weeks of tinkering and I feel like I have roughly 80% of the functionality of the $1200 unit. it's been a process getting here, make one change and have to completely rewrite the program to work with that change. Was wondering if anyone could look at what I have so far and make some suggestions to make it shorter and more elegant? A rundown of the program thus far. from a fresh boot I have 8 GUI switches that will control 1-8 relays( I have all the GPIO stuff removed for windows, but it works), I have it to where the text and color changes based off the state of the output that controls the relay. I also have an all off button that kills the output to all relays when pushed. as well as an exit button that closes the program, and a shutdown button that shuts down the rasberry pi. I have right now an all on relay that turns all the relays on, but I want to change this to user selectable vis check boxes or radio buttons. I have a setup button that goes to a different window where you can name the buttons whatever you want. There are some things I want to change as well as see if I can shorten any of these up. I will attach my program and attachments from my git hub account here https://github.com/joegibbstruck/Start-o...relays.git I know some of this will be strictly rasberry pi, and some of them are straight GUI but I'll take any help I can get, these are all notes in my code as well, not looking for someone to write all my code just pointers on how to modify it from here without having to rewrite the entire thing.
Things I would like a little help / direction with
1) How would I go about using radio buttons or check boxes to link certain switches together rather than having to list each switch individually via code?
for example, open a new window select 1-8 buttons and refence that back to the code for the main switch to operate.
2) Right now, to label the switches I am writing to individual text files. this works but I have to create 8 text files before I start the program. this is a 2-part question, how do I make a new file if one does not exist, and can I refence 8 items from 1 text file in say a list or dictionary? if so, what would the steps be to make that happen?
3)by writing to the .txt files it stores my information as well as changes the text on the buttons, but if you don't restart the text goes back to the previous state when pressed. how would I force a restart when the submit button is pressed?
4) if I change the name of one or two buttons but leave the others blank, then when you restart everything goes back to "factory", what would I use to write to the .txt file if there is a change present but not overwrite the file if left blank?
5)Right now I have to use 17 globals from my second setup window, is there a way to make a global list, and just 1 global variable to refence all of the others?
6)similar to number 2 right now I have to read from 8 .txt files to pull the data from to maintain the button labels, anyway, to reference a list or something in 1 .txt file for all 8?
7) how would I force this program to run on start up?
8) anyway, to remove the close and minimize button on the main window?
9) potentially I would have up to 24 relays controlled by this, how would I hide the code from 9-24 until needed? say a check box in the setup menu to unlock another main page with more buttons?
I appreciate any help anyone is willing to give, like I said I'm just looking for direction. I make notes as I go and work on my issues one at a time I figured this way at least maybe I can get directions for multiple issues.
Things I would like a little help / direction with
1) How would I go about using radio buttons or check boxes to link certain switches together rather than having to list each switch individually via code?
for example, open a new window select 1-8 buttons and refence that back to the code for the main switch to operate.
2) Right now, to label the switches I am writing to individual text files. this works but I have to create 8 text files before I start the program. this is a 2-part question, how do I make a new file if one does not exist, and can I refence 8 items from 1 text file in say a list or dictionary? if so, what would the steps be to make that happen?
3)by writing to the .txt files it stores my information as well as changes the text on the buttons, but if you don't restart the text goes back to the previous state when pressed. how would I force a restart when the submit button is pressed?
4) if I change the name of one or two buttons but leave the others blank, then when you restart everything goes back to "factory", what would I use to write to the .txt file if there is a change present but not overwrite the file if left blank?
5)Right now I have to use 17 globals from my second setup window, is there a way to make a global list, and just 1 global variable to refence all of the others?
6)similar to number 2 right now I have to read from 8 .txt files to pull the data from to maintain the button labels, anyway, to reference a list or something in 1 .txt file for all 8?
7) how would I force this program to run on start up?
8) anyway, to remove the close and minimize button on the main window?
9) potentially I would have up to 24 relays controlled by this, how would I hide the code from 9-24 until needed? say a check box in the setup menu to unlock another main page with more buttons?
I appreciate any help anyone is willing to give, like I said I'm just looking for direction. I make notes as I go and work on my issues one at a time I figured this way at least maybe I can get directions for multiple issues.