One board, more roles

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi guys !

I'm doing a board that has few sensors and other functionalities.
Basic program is the same, but I don't need all that staff at one time, you understand me.

Code is not that big (round 2500 lines, lot of comments).
I don't use more .c and .h files.

So, my question is how to achieve this ?

Maybe is this a good solution to start with?

#define xyz


#ifdef yxz

#else

#endif

Thanks !

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It is the way I do:; maybe you should add a line : #undef xyz (by swapping these lines -yyp under vi-, it is easy to allow/disallow some feature. However, exhaustive testing is difficult -it adds complexity-

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you do much of this, or much if statements, it gets hard to maintain. You can't fix one behavior without breaking something else.

If you don't know my whole story, keep your mouth shut.

If you know my whole story, you're an accomplice. Keep your mouth shut. 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Obviously you can write many apps that all use the same hardware. e.g. Arduino
You have to upload a new app from the PC whenever you want to change the current app.

If you want several apps to be 'on' your board at all times, you build all the apps into a single executable. You select the required app from a menu.

David.