
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:
- 21:5640ebc362a0
- Parent:
- 20:fb73eaaf0894
- Child:
- 22:2616a57327d8
- Child:
- 24:db7494389c03
--- a/main.cpp Tue Sep 04 19:57:31 2018 +0000 +++ b/main.cpp Tue Sep 04 17:40:29 2018 -0700 @@ -3,7 +3,6 @@ // // Latest review: August 27, 2018 - Walter Trovo // -// Sep 4, 2018: Charles Young: Created RotarySwitch class to manage mode selection // Feb 14, 2018: initial release aimed to test the counters, the serial port // the PWM output and the MAX7219 operation. // Feb 15, 2018: Removed MAX7219 libray (replaced with custom routine). @@ -12,11 +11,10 @@ // this block includes key libraries +#include "mbed.h" // global Mbed library (always needed) #include <string> // strings management -#include "RotarySwitch.hpp" -// Everything associated with the rotary switch and the associated LEDs -// is hidden in this class. +#include <RotarySwitch.hpp> RotarySwitch ModeSwitch; // definitions of fixed parameters @@ -33,6 +31,22 @@ #define TGATE 10 // gate time (currently fixed for testing purpose) #define MAX_VAL 999999 // Max value managed by the 6-digits display +// definitions of the input/outputs (pins) +DigitalOut AUX (D2); // AUX control for GPS module +InterruptIn TRIG1 (D3); // Counter 1 trigger +InterruptIn TRIG2 (D6); // Counter 2 trigger +PwmOut PWM (D10); // PWM output +DigitalOut BUZZ (D13); // Buzzer + +AnalogIn AIN0 (A0); // ADC input 0 (High Voltage) +AnalogIn AIN1 (A1); // ADC input 1 (aux) +DigitalOut CS2 (A2); // 74HC595 RCLK (pin 12) +DigitalOut CS1 (A3); // MAX7219 CS (pin 12) +DigitalOut SCK (A4); // 74HC595 SRCLK (pin 11) & MAX7219 SCK (pin 13) +AnalogIn KEYB (A5); // Keyboard input (SW2 & SW3) +DigitalOut MOSI (A6); // 74HC595 SER (pin 14) & MAX7219 DIN (pin 1) +DigitalIn UN (A7); // Unused (in V1 PCB A5 and A7 must be connected) + // LED on processor board DigitalOut led1(LED1); @@ -91,7 +105,7 @@ // RTC is supposed to be loose time at power down (no backup battery) // An initialization is performed anyway set_time(0); // Set time - + PWM.period_ms(3); // set the PWM period PWM.write(0.8); // set the PWM duty-cycle @@ -128,14 +142,11 @@ seconds = time(NULL); // get current time strftime(Text, 50, "%H:%M:%S", localtime(&seconds)); PC.printf(" RTC: %s, CNT1: %7d CNT2: %7d",Text, Count1, Count2); - //PC.printf(" wheel %d %d", WheelCurrent, QEPB.read()); + // PC.printf(" wheel %d %d", WheelCurrent, QEPB.read()); } void UpdateOutput() { - // This must be called periodically to update the LEDs - ModeSwitch.UpdateOutput(); - if(Stopped) { // disable interrupts on TRIG1 and TRIG2 @@ -176,10 +187,7 @@ } void UpdateInput() -{ - // This must be called periodically to monitor switch input - ModeSwitch.UpdateInput(); - +{ ADC_val = KEYB.read(); // read voltage from keyboard if ( (ADC_val<0.1) // START/STOP pushbutton pressed && (!StartStopPressed)) @@ -195,6 +203,7 @@ Count1 = 0; // clear counters Count2 = 0; } + logToPC(); return; } @@ -208,6 +217,7 @@ return; } + //--------------------------------------------------------------------------- // Increment CNT1 every time a rising edge is detected on TRIG2 (interrupt) @@ -229,6 +239,7 @@ return; } + //--------------------------------------------------------------------------- // Initialize the MAX7219