Charles Young's development fork. Going forward I only want to push mature code to main repository.
Fork of GEO_COUNTER_L432KC by
Diff: main.cpp
- Revision:
- 17:6eed17197004
- Parent:
- 16:b2e77eb76ab4
- Child:
- 18:ef5678ab1889
--- a/main.cpp Mon Sep 03 10:12:02 2018 -0700 +++ b/main.cpp Mon Sep 03 17:31:41 2018 +0000 @@ -82,7 +82,8 @@ }; WheelState currentWheelState; -I2C i2c(D4, D5); // I2C port +I2C i2c(D4, D5); // I2C port +Ticker SecTenth_Beat; // .1 second ticker Ticker Sec_Beat; // 1 second ticker Serial PC(USBTX, USBRX); // Virtual COM via USB (PC connection) Serial GPS(D1, D0); // Serial port for GPS module @@ -110,6 +111,7 @@ void Display_init(void); // initialize MAX7219 void Display_6D_write(uint8_t); // write to MAX7219 (Main 6-digits display) void Display_2D_write(unsigned short); // write to MAX7219 (Gate 2-digits display) +void WheelStateMachine(WheelStateEvent event); //============================================================================== //============================================================================== @@ -147,7 +149,7 @@ // set the 1 sec ticker to periodically call the Update() routine // NOTE: this is also the 1-sec time base for counters. A better approach // would replace the ticker with an interrupt from the RTC (to be implemented) - Sec_Beat.attach_us(&UpdateInput, 100000); + SecTenth_Beat.attach_us(&UpdateInput, 100000); Sec_Beat.attach_us(&UpdateOutput, 1000000); //RTC::attach(&Update, RTC::Second); //RTC::detach(RTC::Second); @@ -273,20 +275,19 @@ void WheelStateMachine(WheelStateEvent event) { - switch currentWheelState - { - WHEEL_INACTIVE: + switch (currentWheelState) { + case WHEEL_INACTIVE: if (WHEEL_Pressed == event) currentWheelState = WHEEL_MODE_SELECT; break; - WHEEL_MODE_SELECT: + case WHEEL_MODE_SELECT: if (WHEEL_Pressed == event) currentWheelState = WHEEL_SUBMODE_SELECT; else if (WHEEL_Timeout == event) currentWheelState = WHEEL_INACTIVE; break; - WHEEL_SUBMODE_SELECT: + case WHEEL_SUBMODE_SELECT: if (WHEEL_Pressed == event) currentWheelState = WHEEL_MODE_SELECT; else @@ -294,6 +295,7 @@ currentWheelState = WHEEL_INACTIVE; break; default: + break; } }