Home Contents Start Prev 1 2 3 4 5 6 7 8 9 10 11 Next

Software Development

The arduino IDE does not cater well for larger multi-file projects so my approach to reduce complexity will be:

  • Wherever possible, base functionality will be written as a library.
  • The arduinoIDE preferences is changed to point at the kupe directory. This means a libraries directory can be created in the kupe directory rather than using the global Arduino libraries location.
  • All arduino pins will be in one pin_definition.h header file.
  • Any higher level functions that use underlying libraries will be their own .ino file. I aim to keep these to a minimum if possible.
  • Test .ino files for libraries will be the test subdirectory and sym linked to a kupe.ino file (one at a time).
  • As more functionality is added to kupe, an appropriate file will be created in the versions subdirectory and sym linked to kupe.ino.

The (current) content of the kupe directory:

  lrwxr-xr-x  1 cjordan  staff    24 15 Nov 15:51 kupe.ino -> versions/rc_motionV3.ino
  drwxr-xr-x  6 cjordan  staff   192 15 Nov 15:18 libraries
  -rw-r--r--  1 cjordan  staff  2823 15 Nov 16:27 locomotion.ino
  -rw-r--r--  1 cjordan  staff  1224  9 Nov 22:22 pin_definitions.h
  drwxr-xr-x  2 cjordan  staff    64 15 Nov 15:50 temp
  drwxr-xr-x  6 cjordan  staff   192  8 Nov 13:17 test
  drwxr-xr-x  5 cjordan  staff   160 15 Nov 15:50 versions

Examples of test files:

  -rw-r--r--  1 cjordan  staff  1193  6 Sep 13:44 TestKupeMotorController.ino
  -rw-r--r--  1 cjordan  staff  1351 20 Oct 22:34 TestLocomotion.ino
  -rw-r--r--  1 cjordan  staff  1991  8 Nov 15:21 TestRC.ino
  -rw-r--r--  1 cjordan  staff   216 27 Oct 17:01 test.txt

Examples of versions files:

  -rw-r--r--  1 cjordan  staff  1783  9 Nov 22:24 rc_motion.ino
  -rw-r--r--  1 cjordan  staff  1986 15 Nov 15:19 rc_motionV2.ino
  -rw-r--r--  1 cjordan  staff  1943 22 Nov 10:30 rc_motionV3.ino

It does cause a proliferation of headers:

  #include 
  #include 
  #include "pin_definitions.h"
  #include "KupeMotorController.h"
  #include "RadioControlHelper.h"

  uint8_t rc_pins[] = {pin_STOP, pin_aux2, pin_THROTTLE, pin_STEERING, pin_aux3};

  RadioControl RC = RadioControl(rc_pins, 5);
  RadioControlHelper rcHelper = RadioControlHelper();

  void setup()
  {
    Serial.begin(9600);
    ...

And using libraries where a simple .ino file or extra functions may seem overkill, but it hides the complexity away from the kupe directory. I may initially write a .ino file to get simple functionality but once it is bedded in, I will move it to its own library. So the code ends up looking like this:

  void loop()
  {
    RC.checkInterrupts();

    // we check to see if we need to kill motors via RC.
    if (rcHelper.getBoolean(RC.readChannel(0))) {
      Serial.println("Manual motors off");
      robotStop();
      delay(1000);
      return;
    }
    ...

Rather than:

  if (getBoolean(RC.readChannel(0))) {
    Serial.println("Manual motors off");
    robotStop();
    ...

So we end up with more object creation and slightly more complex calling syntax but hopefully, this will pay dividends later when things get more complex.


November 2025


Home Contents Start Prev 1 2 3 4 5 6 7 8 9 10 11 Next