Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Program Turntable.ino
- //Made by Allan Olsen, SMJK
- //First release 20190616
- //Version 20211116
- typedef unsigned char UBYTE;
- typedef signed char BYTE;
- typedef unsigned short int UWORD;
- typedef signed short int WORD;
- typedef unsigned long int ULONG;
- typedef signed long int LONG;
- typedef unsigned long TIME_T;
- enum DIRECTION {NEUTRAL=0, REVERSE, FORWARD};
- enum STATE {OFF=0, ON};
- void setup();
- void loop();
- void split_word(UWORD val, UBYTE *a, UBYTE *b);
- void join_word(UWORD *val, UBYTE a, UBYTE b);
- void save_eeprom(UWORD *v);
- void read_eeprom(UWORD *v);
- void stepper_move(UWORD steps, UBYTE dir);
- int chk_cancel_move();
- void calc_move(int new_pos, UBYTE direction);
- void chk_button_direction();
- void chk_button_move();
- void chk_button_halfturn();
- int chk_button_save_pos(int x);
- UBYTE reset_stepper();
- void alarm();
- void setup_routine();
- UBYTE calc_index(UWORD val);
- void calc_index_init();
- void Print(const char *txt);
- void Print(const char *txt, signed int var);
- void Print(const char *txt, unsigned int var);
- void Print(const char *txt, unsigned char var);
- void Println();
- void Println(const char *txt);
- void Println(const char *txt, signed int var);
- void Println(const char *txt, unsigned int var);
- void Println(const char *txt, unsigned char var);
- void Println(signed int var);
- void Println(unsigned int var);
- void Println(unsigned char var);
- #define DEBUG //Debug on, if you want text message on the serial terminal
- #include <Stepper.h>
- #include <EEPROM.h>
- //#define JERSLEV
- #define NYSKOV
- //#define NS_TEST
- UWORD analog_track_data;
- bool turn_activated=false;
- bool direction_activated=false;
- bool half_turn_activated=false;
- bool setup_init_activated=false;
- bool setup_init_start=false;
- bool setup_save_activated=false;
- UBYTE new_track_pos;
- WORD stepper_position;
- UBYTE direction;
- UBYTE step_correction_direction=FORWARD;
- UWORD step_correction=0;
- TIME_T time_setup;
- bool setup_mode=false;
- bool motor_direction_reverse=false, motor_direction_forward=false;
- UBYTE stepstartspeed;
- TIME_T move_cancel_time;
- bool move_cancel=false;
- #ifdef JERSLEV
- #include "jerslev.h"
- #endif
- #ifdef NYSKOV
- #include "nyskov.h"
- #endif
- #ifndef TRACK_NO
- #define TRACK_NO 5 //Default 5 tracks, if not defined in another place
- #endif
- #define MAX_V_VAL 1023 //Max value for analogRead at UNO, MEGA etc
- UWORD lo[TRACK_NO];
- UWORD hi[TRACK_NO];
- void setup()
- {
- #ifdef DEBUG
- Serial.begin(9600);
- #endif
- myStepper.setSpeed(STEPPERSPEED);
- calc_index_init();
- #ifdef ONE_PUSH_DIRECTION
- pinMode(pin_turn_direction,INPUT);
- pinMode(pin_LED_clockwise,OUTPUT);
- pinMode(pin_LED_counter_clockwise,OUTPUT);
- #endif
- #ifdef TWO_PUSH_DIRECTION
- pinMode(pin_turn_direction_forw,INPUT);
- pinMode(pin_turn_direction_backw,INPUT);
- pinMode(pin_setup_mode,INPUT);
- #endif
- #ifdef DRIVING_CURRENT
- pinMode(pin_dc_bit0,OUTPUT);
- pinMode(pin_dc_bit1,OUTPUT);
- pinMode(pin_dc_bit2,OUTPUT);
- pinMode(pin_dc_bit3,OUTPUT);
- pinMode(pin_dc_bit_active,OUTPUT);
- digitalWrite(pin_dc_bit0,LOW); //turn off bit 1 for driving current
- digitalWrite(pin_dc_bit1,LOW); //turn off bit 2 for driving current
- digitalWrite(pin_dc_bit2,LOW); //turn off bit 3 for driving current
- digitalWrite(pin_dc_bit3,LOW); //turn off bit 4 for driving current
- digitalWrite(pin_dc_bit_active,LOW); //turn off driving current
- #endif
- pinMode(pin_selector,INPUT);
- pinMode(pin_turn_move,INPUT);
- pinMode(pin_half_turn,INPUT);
- pinMode(pin_zero_point,INPUT);
- pinMode(pin_setup_save,INPUT);
- pinMode(pin_setup_led,OUTPUT);
- digitalWrite(pin_setup_led,LOW); //turn off setup LED
- #ifdef ONE_PUSH_DIRECTION
- digitalWrite(pin_LED_clockwise,HIGH); //turn on LED FORWARD
- digitalWrite(pin_LED_counter_clockwise,LOW); //turn off LED REVERSE
- direction=FORWARD;
- motor_direction_forward=true;
- Println("Direction: FORWARD");
- #endif
- #ifdef TWO_PUSH_DIRECTION
- direction=NEUTRAL;
- if(digitalRead(pin_turn_direction_forw))
- {
- direction=FORWARD;
- motor_direction_forward=true;
- motor_direction_reverse=false;
- Println("Direction: FORWARD");
- }
- if(digitalRead(pin_turn_direction_backw))
- {
- direction=REVERSE;
- motor_direction_forward=false;
- motor_direction_reverse=true;
- Println("Direction: REVERSE");
- }
- if(direction==NEUTRAL)
- Println("Direction: NEUTRAL");
- #endif
- new_track_pos=0;
- stepper_position=0;
- setup_mode=true; //set in setup mode for full speed at init
- read_eeprom(track_pos_steps);
- if(digitalRead(pin_zero_point)==0) //if sensor can't be seen at startup, try to find it ...
- {
- if(reset_stepper()==false) //if sensor haven't been found after one full turn
- {
- Println("Sensor not found! ");
- alarm(); //go in alarm mode
- }
- }
- else //but if sensor are seen at startup, we have to move a bit, until undetected
- {
- UWORD x=0;
- do
- {
- stepper_move(1, REVERSE); //and sensor has to be detected forward moving, so go reverse
- x++;
- if(x>GearStepsPrTurn) //if max steps has been reached, something is wrong
- alarm();
- }while(digitalRead(pin_zero_point)); // do until sensor report open
- if(reset_stepper()==false) //after detected, we have to reset to hardware zero point
- {
- Println("Sensor not found! ");
- alarm(); //and if sensor not found afterward, go in alarm mode
- }
- }
- setup_mode=false; //now set mode back to normal after startup.
- }
- void loop()
- {
- #ifdef TWO_PUSH_SETUP
- if(digitalRead(pin_turn_direction)&&digitalRead(pin_turn_move))
- #endif
- #ifdef ONE_PUSH_SETUP
- if(digitalRead(pin_setup_mode))
- #endif
- {
- if(setup_init_activated==false)
- {
- setup_init_activated=true;
- setup_init_start=true;
- time_setup=millis()+SETUPWAITTIME;
- }
- else
- {
- if(millis()>time_setup)
- {
- setup_mode=true;
- setup_init_start=false;
- setup_routine();
- }
- }
- }
- else
- {
- setup_init_activated=false;
- }
- chk_button_halfturn();
- chk_button_direction();
- chk_button_move();
- #ifdef DRIVING_CURRENT
- chk_driving_current();
- #endif
- }
- void split_word(UWORD val, UBYTE *a, UBYTE *b)
- {
- UWORD c;
- *a=val & 0xff;
- c=val & 0xff00;
- *b=c >> 8;
- }
- void join_word(UWORD *val, UBYTE a, UBYTE b)
- {
- *val=a | (b << 8);
- }
- void save_eeprom(UWORD *v)
- {
- UWORD addr;
- UBYTE a, b;
- addr=0;
- EEPROM.write(addr, MAGICFILENUMBER); //An 8 bit value saved for validating on read, that data exist
- Print("Saving to EEprom address ", addr);
- Println("value for Magicnumber: ",a);
- addr++;
- split_word(step_correction, &a, &b);
- EEPROM.write(addr, a); //Value for turntable zero from the sensor zero - low byte.
- EEPROM.write(addr+1, b); //Value for turntable zero from the sensor zero - high byte..
- Print("Saving corrections value ");
- Print("to EEprom address ", addr);
- Print("+ ", addr+1);
- Print("the low + high value: ",a);
- Print("+ (",b);
- Println("* 256) : total: ", step_correction);
- addr+=2;
- Print("Saving step corrections direction ");
- Print("to EEprom address ", addr);
- Println("(1=REVERSE, 2=FORWARD): ",step_correction_direction);
- EEPROM.write(addr, step_correction_direction); //Value for turntable direction from sensor zero.
- addr++;
- for(UBYTE x=0; x<TRACK_NO; x++)
- {
- split_word(v[x], &a, &b);
- EEPROM.write(addr, a);
- EEPROM.write(addr+1, b);
- Print("For track pos ",x);
- Print("saving to EEprom address ", addr);
- Print("+ ", addr+1);
- Print("the low + high value: ", a);
- Print("+ (", b);
- Println("* 256) : total: ", v[x]);
- addr+=2;
- }
- }
- void read_eeprom(UWORD *v)
- {
- UWORD addr;
- UBYTE a, b;
- addr=0;
- a=EEPROM.read(addr);
- Print("Loading from EEprom address ", addr);
- Println("value for Magicnumber: ",a);
- Println("Expected value for Magicnumber: ",MAGICFILENUMBER);
- if(a==MAGICFILENUMBER) //An 8 bit value for validating that data exist and is correct
- {
- addr++;
- a=EEPROM.read(addr); //Value for turntable zero from the sensor zero - low byte.
- b=EEPROM.read(addr+1); //Value for turntable zero from the sensor zero - high byte.
- join_word(&step_correction, a, b);
- Print("Corrections value ");
- Print("loading from EEprom address ", addr);
- Print("+ ", addr+1);
- Print("the low + high value: ", a);
- Print("+ (",b);
- Println("* 256) : total: ", step_correction);
- addr+=2;
- step_correction_direction=EEPROM.read(addr); //Value for turntable direction from sensor zero.
- Print("Step correction direction ");
- Print("loading from EEprom address ", addr);
- Println("(1=REVERSE, 2=FORWARD): ",step_correction_direction);
- addr++;
- for(UBYTE x=0; x<TRACK_NO; x++)
- {
- a=EEPROM.read(addr);
- b=EEPROM.read(addr+1);
- join_word(&v[x], a, b);
- Print("For track pos ",x);
- Print("loading from EEprom address ", addr);
- Print("+ ", addr+1);
- Print("the low + high value: ", a);
- Print("+ (", b);
- Println("* 256) : total: ", v[x]);
- addr+=2;
- }
- }
- else
- {
- return; //If magic number compare fails, return and use default values in array of data
- }
- }
- void stepper_move(UWORD steps, UBYTE dir)
- {
- stepstartspeed=STEPPERSTARTSP;
- if(steps==0) return;
- if(dir==NEUTRAL) return;
- if(setup_mode) myStepper.setSpeed(STEPPERSPEED);
- #ifdef DRIVING_CURRENT
- driving_current(OFF);
- #endif
- if(dir==FORWARD&&motor_direction_forward==false)
- {
- motor_direction_forward=true;
- motor_direction_reverse=false;
- myStepper.setSpeed(STEPPERSPEED);
- for(UWORD x=0; x<GEAR_BLUR; x++) //Cheap steppers can have blur in gear when shift from on direction to the other direction
- {
- myStepper.step(1);
- }
- }
- if(dir==REVERSE&&motor_direction_reverse==false)
- {
- motor_direction_reverse=true;
- motor_direction_forward=false;
- for(UWORD x=0; x<GEAR_BLUR; x++) //Cheap steppers can have blur in gear when shift from on direction to the other direction
- {
- myStepper.step(-1);
- }
- }
- if(dir==FORWARD)
- {
- for(UWORD x=0; x<steps; x++)
- {
- if(setup_mode==false)
- {
- if(stepstartspeed < STEPPERSPEED)
- {
- stepstartspeed=stepstartspeed + STEP_UP_VAL;
- myStepper.setSpeed(stepstartspeed);
- }
- }
- if(chk_cancel_move())
- return; //Cancel move, so we return and skip moving
- myStepper.step(1);
- stepper_position++;
- if(stepper_position==GearStepsPrTurn) //we have a roll over
- stepper_position=0; //so set to zero
- }
- }
- if(dir==REVERSE)
- {
- for(UWORD x=0; x<steps; x++)
- {
- if(setup_mode==false)
- {
- if(stepstartspeed < STEPPERSPEED)
- {
- stepstartspeed=stepstartspeed + STEP_UP_VAL;
- myStepper.setSpeed(stepstartspeed);
- }
- }
- if(chk_cancel_move())
- return; //Cancel move, so we return and skip moving
- myStepper.step(-1);
- stepper_position--;
- if(stepper_position==-1)
- stepper_position=(GearStepsPrTurn - 1);
- }
- }
- #ifdef DRIVING_CURRENT
- if(direction&&setup_mode==false)
- driving_current(ON);
- #endif
- }
- int chk_cancel_move()
- {
- if(digitalRead(pin_turn_move))
- {
- if(move_cancel==false)
- {
- move_cancel=true;
- move_cancel_time=millis()+CANCELMOVETIME; //Wait/hold botton this amount of millis to cancel move
- }
- else
- {
- if(millis()>move_cancel_time) //And when the time is up
- {
- return true; //return true to stop steppper move
- }
- }
- }
- else
- {
- if(move_cancel==true)
- move_cancel=false;
- }
- return false;
- }
- void calc_move(int new_pos, UBYTE direction)
- {
- int count;
- if(direction==FORWARD) //if rotating is forward (clockwise)
- {
- if(stepper_position>track_pos_steps[new_pos]) //then if stepper pos is greater than new track pos
- count=(GearStepsPrTurn-stepper_position)+track_pos_steps[new_pos]; //the count is max step minus stepper pos plus new track pos
- else
- count=track_pos_steps[new_pos]-stepper_position; //else count is new track pos minus stepper pos
- }
- if(direction==REVERSE) //if rotating is backward (counter-clockwise)
- {
- if(stepper_position<track_pos_steps[new_pos]) //then if stepper pos is lesser than new track pos
- count=(GearStepsPrTurn-track_pos_steps[new_pos])+stepper_position; //the count is max step minus new track pos plus stepper pos
- else
- count=stepper_position-track_pos_steps[new_pos]; //else count is stepper pos minus new track pos
- }
- if(count >= (GearStepsPrTurn/2)) //if count is greater or equal to max step diveded by 2
- count=count-(GearStepsPrTurn/2); //then count is cut down with half the steps max, thereby take the shortest turn
- Println("New track pos ", new_pos);
- Println("Step count ", count);
- Println("Stepper pos before ", stepper_position);
- stepper_move(count, direction);
- Println("Stepper pos after ", stepper_position);
- Println();
- }
- #ifdef TWO_PUSH_DIRECTION
- void chk_button_direction()
- {
- UBYTE t=false, u=false;
- if(setup_init_start)
- return; //We try to come in prog mode, return
- if(digitalRead(pin_turn_direction_forw))
- {
- if(direction_activated==false)
- {
- direction_activated=true;
- if(direction==NEUTRAL)
- {
- direction=FORWARD;
- Println("Direction: FORWARD");
- }
- }
- }
- else
- t=true;
- if(digitalRead(pin_turn_direction_backw))
- {
- if(direction_activated==false)
- {
- direction_activated=true;
- if(direction==NEUTRAL)
- {
- direction=REVERSE;
- Println("Direction: REVERSE");
- }
- }
- }
- else
- u=true;
- if(t&&u)
- {
- if(direction_activated)
- {
- direction_activated=false;
- if(direction)
- {
- direction=NEUTRAL;
- Println("Direction: NEUTRAL");
- }
- }
- }
- }
- #endif
- #ifdef ONE_PUSH_DIRECTION
- void chk_button_direction()
- {
- if(setup_init_start)
- return; //We try to come in prog mode, return
- if(digitalRead(pin_turn_direction))
- {
- if(direction_activated==false)
- {
- direction_activated=true;
- if(direction==FORWARD)
- {
- direction=REVERSE;
- digitalWrite(pin_LED_counter_clockwise, HIGH);
- digitalWrite(pin_LED_clockwise, LOW);
- Println("Direction: REVERSE");
- }
- else
- {
- direction=FORWARD;
- digitalWrite(pin_LED_clockwise, HIGH);
- digitalWrite(pin_LED_counter_clockwise, LOW);
- Println("Direction: FORWARD");
- }
- }
- }
- else
- {
- direction_activated=false;
- }
- }
- #endif
- void chk_button_move()
- {
- if(setup_init_start)
- return; //We try to come in prog mode, return
- if(digitalRead(pin_turn_move))
- {
- if(turn_activated==false)
- {
- turn_activated=true;
- if(setup_mode)
- {
- stepper_move(1, direction);
- }
- else
- {
- if(direction != NEUTRAL)
- {
- analog_track_data=analogRead(pin_selector);
- new_track_pos=calc_index(analog_track_data);
- calc_move(new_track_pos, direction);
- }
- else
- Println("Direction neutral, can't move ");
- }
- }
- }
- else
- {
- if(turn_activated==true)
- {
- turn_activated=false;
- move_cancel=false;
- }
- }
- }
- void chk_button_halfturn()
- {
- if(digitalRead(pin_half_turn))
- {
- if(half_turn_activated==false)
- {
- half_turn_activated=true;
- if(setup_mode)
- {
- stepper_move(HIGHSTEP, direction);
- }
- else
- {
- Println("Turn 180 degrees");
- stepper_move(GearStepsPrTurn / 2, direction);
- Print("Stepper pos ", stepper_position);
- Println();
- }
- }
- }
- else
- {
- half_turn_activated=false;
- }
- }
- int chk_button_save_pos(int x)
- {
- #ifdef PUSH_NORMALY_CLOSED
- if(digitalRead(pin_setup_save)==false) //If button is a NC
- #endif
- #ifdef PUSH_NORMALY_OPEN
- if(digitalRead(pin_setup_save)) //If button is a NO
- #endif
- {
- if(setup_save_activated==false)
- {
- setup_save_activated=true;
- track_pos_steps[x]=stepper_position;
- Println("Track steps saved for ", x);
- Println("Step pos ", track_pos_steps[x]);
- return false;
- }
- }
- else
- {
- setup_save_activated=false;
- }
- return true;
- }
- UBYTE read_save_pos_correction(UWORD x)
- {
- #ifdef PUSH_NORMALY_CLOSED
- if(digitalRead(pin_setup_save)==false) //If button is a NC
- #endif
- #ifdef PUSH_NORMALY_OPEN
- if(digitalRead(pin_setup_save)) //If button is a NO
- #endif
- {
- if(setup_save_activated==false)
- {
- setup_save_activated=true;
- step_correction=x;
- step_correction_direction=direction;
- Println("Step pos correction ", x );
- Println("Stepper position ", stepper_position);
- return false;
- }
- }
- else
- {
- setup_save_activated=false;
- }
- return true;
- }
- UBYTE reset_stepper()
- {
- UBYTE tmp_direction;
- myStepper.setSpeed(STEPPERSPEED);
- bool found=false;
- UWORD tmp_track_select;
- tmp_direction=direction;
- direction=FORWARD;
- #ifdef DRIVING_CURRENT
- driving_current(OFF);
- #endif
- Println("Trying to find sensor ... ");
- for(UWORD x=0; x<GearStepsPrTurn; x++)
- {
- stepper_move(1, direction);
- if(digitalRead(pin_zero_point)) //Found sensor zero point
- {
- Println("Found it ");
- found=true;
- if(step_correction)
- {
- Println("Now sets the stepper correction ");
- stepper_move(step_correction, step_correction_direction);
- }
- stepper_position=0; //after step correction set, reset stepper position
- break;
- }
- }
- if(found)
- {
- tmp_track_select=analogRead(pin_selector);
- new_track_pos=calc_index(tmp_track_select);
- calc_move(new_track_pos, direction);
- Println("New track pos after startup ", new_track_pos);
- Println("Stepper pos after startup ", stepper_position);
- }
- direction=tmp_direction;
- return (found);
- }
- void alarm()
- {
- Println("Shutting down ... ");
- while (1)
- {
- #ifdef TWO_LED_DIRECTION
- digitalWrite(pin_LED_clockwise, HIGH);
- digitalWrite(pin_LED_counter_clockwise, LOW);
- delay(300);
- digitalWrite(pin_LED_counter_clockwise, HIGH);
- digitalWrite(pin_LED_clockwise, LOW);
- delay(300);
- #else
- digitalWrite(pin_setup_led, HIGH);
- delay(300);
- digitalWrite(pin_setup_led, LOW);
- delay(300);
- #endif
- }
- }
- void setup_routine()
- {
- UBYTE y;
- Println("Now in programming mode ");
- digitalWrite(pin_setup_led, HIGH);
- Println("Looking after the zero pos sensor ... ");
- if(digitalRead(pin_zero_point)) //sensor detectet
- {
- UWORD x=0;
- do
- {
- stepper_move(1, REVERSE);
- x++;
- if(x > GearStepsPrTurn)
- alarm(); //If sensor reading dosn't break before max steps, set alarm
- }while (digitalRead(pin_zero_point)); //move backward until sensor reading break the signal
- }
- bool found=false;
- for(int x=0; x<GearStepsPrTurn; x++)
- {
- if(digitalRead(pin_zero_point)) //we found sensor zero point
- {
- stepper_position=0; //so reset stepper value
- found=true;
- break;
- }
- else
- {
- stepper_move(1, FORWARD);
- }
- }
- if(found)
- {
- Println("Zero sensor found ");
- Println("Set turntable zero compared to sensor zero");
- }
- else
- alarm();
- y=0;
- do //set and save turntable zero point from sensor zero point
- {
- chk_button_halfturn(); //step 10 steps per push
- chk_button_direction(); //direction change
- chk_button_move(); //step 1 step per push
- y=read_save_pos_correction(stepper_position); //save value of stepper_position in step_correction
- }while (y);
- Println("Zero point saved ");
- stepper_position=0; //and reset stepper_position
- y=0;
- for(int x=0; x<TRACK_NO; x++)
- {
- Println("Now set steps for track ",x);
- do
- {
- chk_button_halfturn(); //step 10 steps per push
- chk_button_direction(); //direction change
- chk_button_move(); //step 1 step per push
- y=chk_button_save_pos(x); //save value of stepper_position in track pos
- }while (y); //Continue loop until y gets false
- Print("Steps saved for track ", x);
- Println(" value for steps ",track_pos_steps[x] );
- }
- save_eeprom(track_pos_steps); //now save all values in eeprom
- setup_mode=true; //set in setup mode to have full speed in setup_mode
- read_eeprom(track_pos_steps);
- if(digitalRead(pin_zero_point)==0) //if sensor can't be seen at startup, then find sensor pos by turning turntable
- {
- if(reset_stepper()==false) //and if sensor hasn't been found after one full turn
- {
- Println("Sensor not found! ");
- alarm(); //go in alarm mode
- }
- }
- else //but if sensor is active at startup, make a reverse move until no longer active
- {
- UWORD x=0;
- do
- {
- stepper_move(1, REVERSE);
- x++;
- if(x>GearStepsPrTurn)
- alarm();
- }while(digitalRead(pin_zero_point));
- if(reset_stepper()==false) //and if sensor hasn't been found after one full turn
- {
- Println("Sensor not found! ");
- alarm(); //go in alarm mode
- }
- }
- Println("Now out of programming mode");
- digitalWrite(pin_setup_led, LOW);
- setup_mode=false;
- }
- UBYTE calc_index(UWORD val)
- {
- UBYTE x,y=0;
- for(x=0; x<TRACK_NO; x++)
- {
- if (val >= lo[x]&&val <= hi[x])
- {
- y=x;
- break;
- }
- }
- return (y);
- }
- void calc_index_init()
- {
- UBYTE x;
- UBYTE max_index=TRACK_NO - 1; //number of track index minus one
- UWORD offset_val=(MAX_V_VAL / max_index) / 2; //value in fluctuation from center value
- UWORD range_val=MAX_V_VAL / max_index; //size a range covers
- lo[0]=0;
- hi[0]=offset_val;
- #ifdef DEBUG
- Print("Max Index ", max_index);
- Print(" - Offset Val ", offset_val);
- Println(" - Range Val ", range_val);
- #endif
- for(x=1; x <= max_index; x++)
- {
- lo[x]=hi[x - 1] + 1;
- hi[x]=lo[x] + range_val;
- }
- if (hi[max_index] > MAX_V_VAL) hi[max_index]=MAX_V_VAL;
- #ifdef DEBUG
- for(x=0; x<TRACK_NO; x++)
- {
- Print("Index ", x);
- Print("low and high value: ", lo[x]);
- Println("- ", hi[x]);
- }
- #endif
- }
- void Print(const char *txt)
- {
- #ifdef DEBUG
- String text=txt;
- Serial.print(text);
- #else
- return;
- #endif
- }
- void Print(const char *txt, signed int var)
- {
- #ifdef DEBUG
- String text=txt;
- Serial.print(text);
- Serial.print(var);
- Serial.print(" ");
- #else
- return;
- #endif
- }
- void Print(const char *txt, unsigned int var)
- {
- Print(txt, (signed int) var);
- }
- void Print(const char *txt, unsigned char var)
- {
- Print(txt, (signed int) var);
- }
- void Println()
- {
- #ifdef DEBUG
- Serial.println();
- Serial.println();
- #else
- return;
- #endif
- }
- void Println(const char *txt)
- {
- #ifdef DEBUG
- String text=txt;
- Serial.println(text);
- #else
- return;
- #endif
- }
- void Println(const char *txt, signed int var)
- {
- #ifdef DEBUG
- String text=txt;
- Serial.print(text);
- Serial.println(var);
- #else
- return;
- #endif
- }
- void Println(const char *txt, unsigned int var)
- {
- Println(txt, (signed int) var);
- }
- void Println(const char *txt, unsigned char var)
- {
- Println(txt, (signed int) var);
- }
- void Println(signed int var)
- {
- #ifdef DEBUG
- Serial.println(var);
- #else
- return;
- #endif
- }
- void Println(unsigned int var)
- {
- Println((signed int) var);
- }
- void Println(unsigned char var)
- {
- Println((signed int) var);
- }
Advertisement
Add Comment
Please, Sign In to add comment