+++ /dev/null
-/*
- Definition of new types for Switch Kontrol
-*/
-
-#include "avr/pgmspace.h" // Needed for PROGMEM stuff
-
-
-/* declaration of relay postions
-*/
-typedef enum { RELAY_STATE_OPEN, RELAY_STATE_CLOSED } relayState_t;
-
-
-/* declaration of possible state selections for the switch (new enum type)
-*/
-typedef enum { nonstop, studio1, studio2, _NbrSwitchSelections } switchSelection_t;
-
-/* explicit conversions from int to switchSelection_t for +, ++, and += operators
- this makes possible to increment values of type switchSelection_t like this:
- switchSelection_t selection = studio1; // variable declaration & initialization
- selection = selection + 1; // => selection is studio2 (one way to do it)
- selection += 1; // => selection is nonstop (that works, too)
- selection++; // => selection is studio1 (other way)
- ++selection; // => selection is studio2 (yet another way)
- etc.
-*/
-// `+` operator in `selection = selection + i`
-switchSelection_t operator+(switchSelection_t lhs, int rhs) {
- return static_cast<switchSelection_t>(
- (static_cast<int>(lhs) + rhs) % _NbrSwitchSelections
- );
-}
-// `+` operator in `selection = i + selection`
-switchSelection_t operator+(int lhs, switchSelection_t rhs) {
- return static_cast<switchSelection_t>(
- (lhs + static_cast<int>(rhs)) % _NbrSwitchSelections
- );
-}
-// `++` operator in `++selection`
-switchSelection_t &operator++(switchSelection_t &s) {
- s = static_cast<switchSelection_t>((s + 1) % _NbrSwitchSelections);
- return s;
-}
-// `++` operator in `selection++`
-switchSelection_t operator++(switchSelection_t &s, int) {
- return static_cast<switchSelection_t>(++s - 1);
-}
-// `+=` operator in `selection += i`
-switchSelection_t operator+=(switchSelection_t &lhs, int rhs) {
- lhs = static_cast<switchSelection_t>(
- (static_cast<int>(lhs) + rhs) % _NbrSwitchSelections
- );
- return lhs;
-}
-
-
-/* store switch state labels as an array in program memory
- see http://arduino.cc/en/Reference/PROGMEM
-*/
-/*
-prog_char label_nonstop[] PROGMEM = "Non-Stop";
-prog_char label_studio1[] PROGMEM = "Studio 1";
-prog_char label_studio2[] PROGMEM = "Studio 2";
-
-PROGMEM const char *selection_labels[] = {
- label_nonstop, label_studio1, label_studio2
-};
-
-*/