/* Title: wire.c
 * Author: Jed Marti KI7NNP
 * Description: Wire size table.
 * Revision History: (Thu Dec 28 21:27:28 2023)
 *   Fri Jan 26 14:28:22 2024 - Adapted for new system.
 */

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>

#include "inductor.h"


WireSize_t sizeTable[] = {
  {.msg="#32", .gauge=32, .nominal=0.008, .weight=.194, .ohms=166, .maxA=0.53},
  {.msg="#30", .gauge=30, .nominal=0.010, .weight=0.303, .ohms=106, .maxA=0.86},
  {.msg="#28", .gauge=28, .diameter=0.013, .nominal=0.0126, .weight=0.481, .ohms=66.4, .maxA=1.4},
  {.msg="#26", .gauge=26, .diameter=0.017, .nominal=0.0159, .weight=0.765, .ohms=42.1, .maxA=2.2},
  {.msg="#24", .gauge=24, .diameter=0.021, .nominal=0.0201, .weight=1.22, .ohms=26.2, .maxA=3.5},
  {.msg="#22", .gauge=22, .diameter=0.028, .nominal=0.0253, .weight=1.94, .ohms=16.6, .maxA=7.0},
  {.msg="#20", .gauge=20, .nominal=0.0320, .weight=3.10, .ohms=10.3, .maxA=9.0},
  {.msg="#18", .gauge=18, .diameter=0.044, .nominal=0.0403, .weight=4.92, .ohms=6.51, .maxA=16.0},
  {.msg="#16", .gauge=16, .diameter=0.054, .nominal=0.0508, .weight=7.81, .ohms=4.1, .maxA=22.0},
  {.msg="#14", .gauge=14, .diameter=0.067, .nominal=0.0641, .weight=10.9, .ohms=3.51, .maxA=32.0}
};


double gaugeDiameter(int32_t g)
/*     Search the table for a gauge and return the diameter of the wire with enamel insulation.
 *   This has been fiddled somewhat for the characteristics of 3D printing.
 * Parameters:
 *   g: The numeric wire gauge for the ones we know.
 * External References:
 *   sizeTable[]: What we know about the wire.
 * Returned values: the diameter or -1 if the gauge isn't known.
 * Errors detected: unknown gauge.
 */
{
  int32_t i;
  for (i = 0; i < sizeof(sizeTable) / sizeof(WireSize_t); ++i)
    if (sizeTable[i].gauge == g) return sizeTable[i].diameter;

  return -1.0;
}


// EOF
