Okay, so... Maybe a little more on my testing setup.
I am using a 500 Ohm potentiometer to simulate the same device that is built into the rotator. The potentiometer in the rotator is what gives the rotator its heading. When the potentiometer is at 0 or 500 ohms, it is pointing north. Using a calculation of Ohms/1.388 you get a result that is between 0 and 360. this associates to the degrees on a compass thus a heading.
I am displaying this information via an I2C 20 x 4 display. And this is where my problem comes into play....
My primary issue at this point is that the bottom line... has a compass heading on it.. like this
CALL 19:30
270
|
S.....W.....N.....E.....
The bottom line needs to scroll left and right, to corrispond with the heading above it. This I can achieve. The problem is.. that when that (S.....W.....N.....E.....) Scrolls to the left it scrolls up onto line 2 from the right. When it scrolls to the right it scrolls up onto line 1 from the left.
I my goal is to have that (S.....W.....N.....E.....) scroll around on its self as if it is one big loop, on a single line. Thus giving the display of a naval, or guidance heading.
Here is a copy of my current, and very commented code.
/* Amateur Radio Antenna Rotator Controller
This is a beta version, very very basic. Its intended to be used as a testing and learning platform for myself.
Hopfuly it will help others with some of the problems and milestones I have been facing.
Powered by Arduino Uno Rev. 3
I2C 20 x 4 LCD Display
* 5v -- Vcc
* Gnd -- Gnd
* A4 -- SDA
* A5 -- SCL
Potentiometer
* 5v -- Pwr
* Gnd -- GND
* A0 -- Wiper
Original code by John Brent (VA3WPN) 2014 */
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
int headPin = 0; // Pin connected to heading pot wiper
int potHead; // Variable to read heading pot value
LiquidCrystal_I2C lcd(0x20,20,4); // set the LCD address to 0x20 for a 20 chars and 4 line display
byte headN[8] = { B10001, B11001, B10101, B10011, B10001, B00100, B00100, B00100 }; // North Marker
byte headE[8] = { B01110, B01000, B01110, B01000, B01110, B00100, B00100, B00100 }; // East Marker
byte headS[8] = { B01110, B01000, B01110, B00010, B01110, B00100, B00100, B00100 }; // South Marker
byte headW[8] = { B10001, B10101, B10101, B01010, B01010, B00100, B00100, B00100 }; // West Marker
byte headA[8] = { B00000, B00000, B00000, B00100, B00100, B10101, B01110, B00100 }; // Heading Arrow
void setup()
{
Serial.begin(9600);
lcd.init(); // initialize the lcd
lcd.backlight(); // Turns on the back light
lcd.setCursor(1, 1);
lcd.print("Rotator Controller"); // Sets Callsign of Station
lcd.setCursor(6, 2);
lcd.print("V1.0 Beta"); // Displays Time
delay(3000);
lcd.clear();
// Station Info
lcd.setCursor(0, 0); // Sets cursor to callsign posision
lcd.print("CALL"); // Sets Callsign of Station
lcd.setCursor(15, 0); // Sets cursor to time posision
lcd.print("19:30"); // Displays Time
}
void loop()
{
potHead = analogRead(headPin); // Reads the value of the heading pot
potHead = map(potHead, 0, 686, -360, 360); // Maps the heading pot value to the heading display
setHeading(potHead); // Displays the heading information on the display
delay(10);
}
void setHeading(int potHead) // Build the setHeading Function
{
int cR;
cR = potHead/24;
lcd.createChar(0, headA); // Defines Heading Arrow
lcd.createChar(1, headN); // Defines North Marker
lcd.createChar(2, headS); // Defines South Marker
lcd.createChar(3, headE); // Defines East Marker
lcd.createChar(4, headW); // Defines West Marker
lcd.setCursor(9, 1);
lcd.print(potHead); // Displays Heading in Degrese
lcd.setCursor(10, 2);
lcd.write(0); // Heading Indicator
lcd.setCursor(cR, 3);
lcd.write(2); // South
lcd.print("....");
lcd.write(4); // West
lcd.print("....");
lcd.write(1); // North
lcd.print("....");
lcd.write(3); // East
lcd.print("....");
Serial.println(potHead); // Used for Serial Debugging
}
I hope this clears up my goal, and my problem. And Helps someone else along the way.