Any suggestions for making my code more elegant?
ITSeng
Posts: 5
As I've posted recently, I forgot my old user name so·I have a new one. I posted an extensive thread a few years ago about a submarine project I'm 99% finished with. The sub uses 2 BS2s, the code below is used to control the vehicle, the other BS2 does all of the sensor functions. I'd like some suggestions to see if I can clean this up a little.
What it does (it does work perfectly and is stable):
Controls 2 trolling motors with 2 HB25s, sends feedback to a GUI
Controls 2 servos that aim the camera
Controls a lighting system
Controls solenoid valves for a compressed CO2 system for diving and surfacing
Everytime·I look at it I get the feeling there is a simpler way to do some of the functions.
The letter "C" means a camera function in the code.
I'll try to add a picture of my "custom" circuit set-up. [noparse]:)[/noparse]
Post Edited (ITSeng) : 10/16/2008 10:03:11 PM GMT
What it does (it does work perfectly and is stable):
Controls 2 trolling motors with 2 HB25s, sends feedback to a GUI
Controls 2 servos that aim the camera
Controls a lighting system
Controls solenoid valves for a compressed CO2 system for diving and surfacing
Everytime·I look at it I get the feeling there is a simpler way to do some of the functions.
The letter "C" means a camera function in the code.
I'll try to add a picture of my "custom" circuit set-up. [noparse]:)[/noparse]
Post Edited (ITSeng) : 10/16/2008 10:03:11 PM GMT
Comments
LM = left motor
RM = right motor
upC = camera up
displ = display left (motor)
this is an address and an·ASCI srting sent to the display software for instance:
[noparse][[/noparse]$B0,$FE,2,77,111,116,111,114,115,32,82,101,97,100,121,32,32,32,32,32,CR]
Things like what is in the "datain" subroutine, it just seems like there's an easier way.
You think this code looks complicated? The code for the sensor BS2 is 5X as complicated.
Also you have lots of data being sent out serially with lots of repeats. That may also be able to be condensed by using the repeat modifier for SEROUT.
In the motor display section, you may find that SELECT would be handy.
Just my $.02
humanoido