C++ API reference

C++ Classes

Compass

The id-4001’s compass uses 16 LEDs in a circle to display wind direction

class Compass

Compass class used to manipulate the id-4001 compass.

Author

Joe (joe.sedutto@silvertech.com)

Public Functions

Compass(byte _WINDA_PIN, byte _WINDB_PIN, byte _WINDC_PIN, byte _WINDD_PIN)

Construct a new Compass object.

Parameters
  • _WINDA_PIN – Wind “A” pin.

  • _WINDB_PIN – Wind “B” pin.

  • _WINDC_PIN – Wind “C” pin.

  • _WINDD_PIN – Wind “D” pin.

void setHeading(int angle)

Set the output heading.

Parameters

angle – In degrees, 0-360

void iterate(int angle)

Like Display’s iterate function, this method expects you to do the scheduling on your own.

void clearStats()

Simple method to clear/reset all running stats.

Private Members

int windDirAvg[compassTrail + 1]

This is neat, it stores the last 10 wind directions to avg them.

Display

The id-4001’s display is made from many 8 segment indicators, a few special indicators and some LEDs

class Display

Display object used to manipulate the display.

Author

Joe (joe.sedutto@silvertech.com)

Public Functions

Display(byte _SEG_SEL_A_PIN, byte _SEG_SEL_B_PIN, byte _SEG_SEL_C_PIN, byte _SEG_SEL_D_PIN, byte _SEG_DP_PIN, byte _SEG_A_PIN, byte _SEG_B_PIN, byte _SEG_C_PIN, byte _SEG_D_PIN, byte _SEG_E_PIN, byte _SEG_F_PIN, byte _SEG_G_PIN)

Constructs a new Display object.

Parameters
  • _SEG_SEL_A_PIN – Segment Selector (A)

  • _SEG_SEL_B_PIN – Segment Selector (B)

  • _SEG_SEL_C_PIN – Segment Selector (C)

  • _SEG_SEL_D_PIN – Segment Selector (D)

  • _SEG_DP_PIN – Segment Decimal Point pin

  • _SEG_A_PIN – Segment “A” LED (top)

  • _SEG_B_PIN – Segment “B” LED (top right)

  • _SEG_C_PIN – Segment “C” LED (bottom right)

  • _SEG_D_PIN – Segment “D” LED (bottom)

  • _SEG_E_PIN – Segment “E” LED (bottom left)

  • _SEG_F_PIN – Segment “F” LED (top left)

  • _SEG_G_PIN – Segment “G” LED (center)

void setBaro(int pres, bool falling = false)

Set barometric pressure.

Parameters
  • pres – Pressure in Millibar

  • falling – Wether or not the pressure has been trending up, or down.

void setWindspeed(float speed)

Set windspeed.

Note

Speed can be a float! setWindspeed will auto-scale from 0-9.9, and from 10-99

Parameters

speed – Windspeed in km/h

void setTemp(int temp, bool indoor = true)

Set the temperature.

Parameters
  • temp – A temperature in degrees C

  • indoor – Whether or not this reading is indoor or outdoor

void setTime(char *time, bool am = false, bool pm = false)

Set the display time section.

Note

The AM lamp and PM lamp can be enabled/disabled at the same time. They are not mutually exclusive.

Parameters
  • time – Any char array with 6 chars exactly, the time display can also display the date, error codes and more

  • am – AM lamp

  • pm – PM lamp

void setErr(int err)

Raise and display an error code.

See also

Error

Parameters

err – An error code, (0-99)

void clearDisplay()

Instantly clear an error from the display.

See also

Error

void refresh(unsigned int scrTime = 2000)

Refresh the screen.

Deprecated:

Deprecated, recommended to use Display.iterate instead.

Parameters

scrTime – Time to be spent displaying each segment, in microseconds

void iterate()

Iterates through each display module at a time, designed to be called with a regular timer callback.

Private Functions

int nth_digit(int val, int n)

Return the n’th digit in an int (base 10)

Note

Do not confuse with bitRead(): Returning the n’th bit in an int (base 2)

Parameters
  • val – An int value

  • n – What power to extract, eg 0 for 1 in 1234. and 2 for 3 in 1234

Returns

The digit extracted (0-9)

bool hasElapsed(unsigned long time, int dur)

Checks to see if a set amount of time has elapsed.

Parameters
  • time – The time in millis() to reference from

  • dur – A duration (in seconds)

Returns

true if time has expired

Returns

false if time has not yet expired

void writeRawDigit(byte value, byte index, bool dp = false, bool drawZeros = false)

Writes a specific value to a specific LED index.

See also

segmentLookup

Parameters
  • value – The value to write

  • index – The index of the segment to display on

  • dp – Set the seg dp or not (used for some misc features)

C++ Other

Error Codes

An error enumerator handles keeping track of all the possible error codes.

enum Error

Represents all possible id-4001-wifi errors.

Values:

enumerator noErr

Err00: Only used for testing.

enumerator noComm

Err01: No communication (Ususally refering to communication with ESP32 or API server).

enumerator notImplemented

Err02: Feature is not implemented or not yet finished. (May trigger on unconfigured buttons/config settings).

enumerator outOfRange

Err03: Function produced numbers out of range or function is not applicable to the current range (ie, rate when there is no deviation data).

enumerator gpsError

Err04: GPS error, usually encoding failure.

enumerator i2cError

Err05: i^2c error, ususally decoding failure.

Animations

A collection of little animations for the ID-4001-WiFi project.

Author

Joe (joe.sedutto@silvertech.com)

Date

2022-05-10

Copyright

Copyright (c) 2022

Functions

void startupAnimation1(Compass compass)

Simple little spinning compass startup animation.

Buttons

Methods, constructors and data types for all the various buttons and switches.

Functions

void configureButtons()

Configure the ID-4001’s buttons.

Author

Joe (joe.sedutto@silvertech.com)

void updateButtons()

Updates every button, switching from front to back when appropriate.

Note

This should be called at the start of every loop

espAPI

Functions and methods to interact with the esp32 api slave.

Functions

WireSlaveRequest slaveReq(Wire, esp_slave_addr, max_slave_response)
RunningAverage windspeedAvg(avgSize)
RunningAverage tempAvg(avgSize)
RunningAverage baroAvg(avgSize)
void beginESP()

Setup for the ESP api.

String getValue(String data, char separator, int index)
bool getNewPacket()
float average(float *arr, int len)

Methods to retrive i2c vars

float getWindspeed(Stat _stat = nul)
int getTemp(Stat _stat = nul)
int getBaro(Stat _stat = nul)
void clearStats()

conversions

Various conversion utilities.

Functions

int milibarToInchMG(int millibar)

Converts Millibar to Inches of Mercury.

Parameters

millibar – Value in millibars

Returns

int Value in Inches of Mercury

int celsiusToFahrenheit(int celsius)

Converts Degrees Centigrade to Degrees Fahrenheit.

Parameters

celsius – Value in C

Returns

int Value in F

float kmhToMph(float kmh)

Converts Kilometers per hour to Miles per hour.

Parameters

kmh – Value in Kmh

Returns

float Value in Mph

float kmhToKnots(float kmh)

Converts Kilometers per hour to knots.

Parameters

kmh – Value in Kmh

Returns

float Value in kts

gps

Methods and Utilities for the GPS on the id-4001-wifi.

Functions

void isrPPS()

Inturrupt method called by pps gps pin.

Deprecated:
Author

Nick Soggu

void beginGPS()

Initalize and construct GPS and requirements for communication.

Author

Nick Soggu

void syncCheck()

Check if sync is ready and etc.

Deprecated:
Author

Nick Soggu

bool isAm()

Checks if its AM or PM.

Returns

true AM

Returns

false PM

char *encodeTime()

Method for building a new time char array.

Author

Joe

Note

Returns a pointer!! Be sure to free(encodeTime) when done!

void updateGPS()

Updates the GPS background functions, should be called every loop.

Author

Joe