Obvious - Which pin are you using to read the buttons? Far as I can tell the LCD library to run 'event = lcd.getButton()' wants it to be A0
setSteps((stepsPerDiv + adjustSteps) * 2, 1);
printDivideVals(thisDiv,gAngle);
void goDivide(long gAngle)
{
long thisDiv = 1;
int event = LCD_BUTTON_NONE;
int flag = 0;
float tmpSTEPS_PER_REV = (float)globals.stepsPerRev;
float remainder;
float divLeftOver = 0.0;
long adjustSteps = 0;
stepsPerDiv = (long)(tmpSTEPS_PER_REV *((float)gAngle/(float)MINUTES_IN_CIRCLE));
remainder = (float) (tmpSTEPS_PER_REV *((float)gAngle/(float)MINUTES_IN_CIRCLE));
remainder -= (float)stepsPerDiv;
divisions = (long)((float) MINUTES_IN_CIRCLE / (float) gAngle);
printDivideVals(thisDiv,gAngle);
while(event != LCD_BUTTON_SELECT){
event = lcd.getButton();
switch(event){
case LCD_BUTTON_LEFT:
flag++;
thisDiv--;
divLeftOver -= remainder;
if(thisDiv < 1)
thisDiv = divisions;
digitalWrite( globals.DirPin, ANTICLOCKWISE );
break;
case LCD_BUTTON_RIGHT:
flag++;
thisDiv++;
divLeftOver += remainder;
if(thisDiv > divisions)
thisDiv = 1;
digitalWrite( globals.DirPin, CLOCKWISE );
break;
}
if(flag){
if(abs(divLeftOver) >= 1.0){
adjustSteps = 1;
if(abs(divLeftOver) == divLeftOver)
divLeftOver -= 1.0; // Positive value >= 1.0
else
divLeftOver += 1.0; // Negative Value <= 1.0
} else
adjustSteps = 0;
setSteps((stepsPerDiv + adjustSteps) * 2, 1);
printDivideVals(thisDiv,gAngle);
}
flag = 0;
}
}
Have operation with my little testing platform
From: "the program starts running and no button will stop it."
To: "the program starts running and the button will stop it."
Question is: The <Contin> UP/DWN Starts menu choice is one direction only, plus being slow I don't really get the item. You have the Jog function which also has a Cont choice that runs both directions . . .
Next thing to do is to load it to the rotary table gizmo and see how she does . .
if(abs(divLeftOver) == divLeftOver)
if(divLeftOver > 0.0)
Foozer, I suspect your keyboard problem could be due to different resistance values between my Freetronics and your sainsmart keyboards.
Jog Angle XX0 - 00 - 00 XX not changing - Left-Right moves cursor, Up-Down no change from zero.
Foozer, This old post explains how to modify the LCD code for the sainsmart
http://www.homemodelenginemachinist.com/showpost.php?p=273830&postcount=219
Thanks, the lcd.cpp file is perty straighforward, 'cept for the
// Button mapping table generated by genlookup.c
static unsigned char const buttonMappings[] PROGMEM = {
2, 0, 0, 0, 3, 0, 0, 0, 0, 4, 4, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0};
Part of me wants to know what that actually means, the other part say's forget it, stick in the verbose coding . . That can be changed to suit variance in resistor values. Up/Down button reads work every place 'cept that for that one usage.
Any event if this dunderhead can get your sketch to run, anyone can get it to run . . .
Foozer, Sorry I missed this. The original author of the LCD library published his source on github. Chack th esource and you'll probbaly find the URL. From memory, he used a program to generate that code (and the source for the generator was in his repository).
Thanks, I'll take a look . .
Robert
This post of mine links to the github source of the LCD library
http://www.homemodelenginemachinist.com/showpost.php?p=261783&postcount=20
Enter your email address to join: