On 23/10/17 16:05, Mark Webb-Johnson wrote:
The #define will be seen by anything that pulls in vehicle_nissanleaf.h. You are pretty safe in this case, as vehicle_nissanleaf.cpp is probably the only thing that will ever pull in that .h.
Classes don’t have private #defines. That is a pre-processor directive, so is actually processed even before the C/C++ compiler is called.
Yeah, I thought it would work like that. I've moved the defines to the .h file without changing their names, rebased, tested and pushed to my branch.
I think the car-on and car-off detection will always be vehicle-specific. Perhaps something to help with this could be done in vehicle.{h,cpp}? Perhaps a CarAwakeTickle() function that the car module calls, and if that is not called in N seconds, then vehicle.{h,cpp} automatically records the car as off? Just not sure how many vehicles would need this. Perhaps simplest for you to implement:
I'll see what I can prototype in the leaf code and if it's generally useful it can be pulled out.
For high-level events like car-off, car-started, car-asleep, etc, I think these can be handled at a high level (probably in vehicle.{h,cpp}).
Yes, once the condition is actually identified, it makes sense to trigger a shared event for common functionality to build upon.