AruinoIDE 2.3.4 - Board UNO
Hi Group, as I am not a wel trained programmer I run into a problem.
getting during compilation a error: 'runTimeClock' was not declared in this scope
// (c) Harry H.Arends
#include <Wire.h>
#include <LiquidCrystal_I2C.h >
//#include <TimeLib.h>
#include <AccelStepper.h>
#include <MultiStepper.h>
const int enPin = 8;
const int stepXPin = 2; //X.STEP
const int dirXPin = 5; // X.DIR
const int stepYPin = 3; //Y.STEP
const int dirYPin = 6; // Y.DIR
// Define the stepper motor and the pins that is connected to
AccelStepper stepperX(1, stepXPin, dirXPin); // (Typeof driver: with 2 pins, STEP, DIR)
AccelStepper stepperY(1, stepYPin, dirYPin);
byte index = 0; // Index into array; where to store the character
const byte numChars = 15;
char inChar; // Where to store the character read
char *AXpos;
char *EYpos;
char AXposR[7];
char EYposR[7];
char inData[numChars]; // an array to store the received data
const char *delimiter = ",";
const long _maxRotorAX = 18000L; // maximum rotor azimuth in degrees * 1000
const long _maxRotorEY = 18000L; // maximum rotor elevation in degrees * 1000
long lastTime = 0;
long minutes = 0;
long hours = 0;
unsigned long value;
LiquidCrystal_I2C lcd(0x27, 20, 4); // set the LCD address to 0x27 for a 16 chars and 2 line display
boolean newData = false;
boolean newTime = false;
unsigned long start, finished, elapsed;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600); // initialize serial communication
//while (!Serial.available())
// delay(0);
value = millis();
lcd.init(); // initialize the lcd
// Print a message to the LCD.
lcd.backlight();
lcd.setCursor(0, 0); // LCD row1
lcd.print(" XY-Antenna");
lcd.setCursor(0, 1); // LCD row1
//lcd.print("RT= 00 00:00:00");
//lcd.print("Et= ");
runTimeClock();
lcd.setCursor(0, 2);
lcd.print("Arduino LCM IIC 2004");
lcd.setCursor(1, 3);
lcd.print("(c)Harry H. Arends");
Serial.println("XtTrm Ready");
stepperX.setMaxSpeed(10000); // Set maximum speed value for the stepper
stepperX.setAcceleration(1000); // Set acceleration value for the stepper
stepperX.setCurrentPosition(0); // Set the current position to 0 steps
stepperY.setMaxSpeed(10000);
stepperY.setAcceleration(500);
stepperY.setCurrentPosition(0);
}
void loop() {
recvWithEndMarker();
processNewData();
extractData();
updateDisplay();
runTimeClock();
}
void recvWithEndMarker() {
static byte ndx = 0;
char endMarker = '\n';
char rc;
while (Serial.available() > 0 && newData == false) {
rc = Serial.read();
if (rc != endMarker) {
inData[ndx] = rc;
ndx++;
if (ndx >= numChars) {
ndx = numChars - 1;
}
} else {
inData[ndx] = '\0'; // terminate the string
ndx = 0;
newData = true;
}
}
}
void processNewData() {
if (newData == true) {
//Serial.print("This came just in ... ");
//Serial.println(inData);
// newData = false;
} else {
}
}
void extractData() {
//Extract two numbers from received data
if (newData == true) {
AXpos = strtok(inData, delimiter);
EYpos = strtok(NULL, delimiter);
}
void updateDisplay() {
if (newData) {
// Clear used rows
lcd.setCursor(0, 2);
// 12345678901234567890
lcd.print(" ");
lcd.setCursor(0, 3);
lcd.print(" ");
lcd.setCursor(0, 2);
lcd.print("Xt= ");
lcd.print(AXpos);
lcd.setCursor(0, 3);
lcd.print("Yt= ");
lcd.print(EYpos);
lcd.setCursor(8, 1);
newData = false;
}
}
void runTimeClock() {
uint16_t seconds = 0, minutes = 0, hours = 0, days = 0;
static uint32_t lastTime = -1000;
static uint32_t count = 0;
uint32_t now = millis();
lcd.setCursor(5, 1);
if (now - lastTime >= 1000) {
lastTime = now;
now = count;
++count;
seconds = now % 60;
now /= 60;
minutes = now % 60;
now /= 60;
hours = now % 24;
days = now / 24;
lcd.print(days);
lcd.print(" ");
lcd.print(hours);
printDigits(minutes);
printDigits(seconds);
Serial.println();
}
}
void printDigits(int digits) {
// utility function for digital clock display: prints preceding colon and leading 0
lcd.print(":");
if (digits < 10)
//Serial.print('0');
lcd.print('0');
//Serial.print(digits);
lcd.print(digits);
}
If I move this sub to the top the next sub produces a error.
My question is as follows: should I move all the subs to the start of the sketch or can it be solved in a other way??