No you don't have to declare enum volatile, and the compiler should give you error. This because you are creating an enumerated series of constants and they can't change.
You must declare volatile your input variable, because this is the one that changes under interrupt. You must do this to advice the compiler to take care when optimizing code to make no assumptions on its value. If you don't there will be cases in which the compiler will assume that the variable is in a specific condition and will omit some code or use an old value.
the "problem" is that Arduino IDE "compiler" is so "automated" AKA stuff is hidden from user.
It did not complain when I tested this base code.
At present the input "pins" array is not volatile and I'll change that.
I have a small additional challenge implementing the ISR ( interrupt service routine).
The interrupt code involves callback and is defined as Arduino API.
The ISR does not accept any parameters , consequently each interrupt process implementation has to have its own ISR. So in theory the input ( variable ) is processed only in one place.
It is convoluted mess and I am working on it.
But I needed the basic state machine to work first.
SO far so good.
Context: MFC MDI CScrollView app, targeting Windows 7
When handling a WM_GESTURE command, specifically when GESTUREINFO.dwID = GID_PAN, and attempting to call UpdatePanningFeedback() to provide "over-panning" feedback when user attempts to pan beyond the scroll limits, the entire application window moves instead of the client area of the windows handle provided...
// In this case m_hWnd is my CScrollView derived view class member windows handle.
UpdatePanningFeedback(m_hWnd, 0, yOverpan, gi.dwFlags & GF_INERTIA);
Does anyone know if there is an alternative way to achieve the effect of the "over-panning" (that visual feedback that seems like your trying to stretch the client area beyond it's limits like a rubberband) only in the client area of the CScrollView window?
That is a fairly basic logic/counting problem that you should be able to figure out by writing the numbers on paper, and deciding how to calculate the number of digits vs the number of spaces for each value.
Your loop values are slightly off. You should be counting 1 - 3 - 5 - 3 - 1, and printing the numeric values in each line rather than stars. Your main loops should be something like:
int num = 5;
// go from 1 to 5for (index = 1; index <= num; index += 2)
// print the first set of values
printf("%d\n", index); // just to show the number
// already printed the 5 set, so go from 3 to 1for (index = num - 2; index > 0; index -= 2)
// print the last set of values
That is an example, your job is to fill in the fine detail. You will learn much more by trying it yourself than if someone else writes it for you. As an exercise you can try different values of num also.