Go Down

Topic: Inserting scroll to the left on text on lcd ... (Read 567 times) previous topic - next topic

sam_cqdx

Sep 21, 2012, 11:36 pm Last Edit: Sep 24, 2012, 11:05 pm by Coding Badly Reason: 1
Hi to all the pros on here ...have a Arduino mega 2560 with st7920 display controller lcd in serial mode(spI).... lcd 128*64
What i am trying to do is to get a line of text to scroll to the left off the screen and appear on the right side again and scroll to the left again. The specific line is a staus line/error message  that is displayed on the screen if a state changes by user intervention or some or other error the controller encounters....I have read up on the scroll to the left feature but would just like to insert it into the code as a friend of mine wrote the code and this is all new to me .....
Please check the last paragraph perhaps that will help more
Below is part of the code :

Thanks in advance,hope it makes sense to  what i tried to explain  
Here is another piece of code which might be of relivance..

Code: [Select]

// Definition of system states
enum State
{
 S_Init = 0,     // initializing
 S_Stopped,      // stopped, waiting for start button to be pressed
 S_Starting,     // start button pressed, soft start not finished yet
 S_Operating,    // normal operation, soft start completed
 S_Error         // had error so shutting down
};

static unsigned char state = S_Stopped;

static const char* statusText[] =
{
 "Init      ",
 "Stopped   ",
 "Starting  ",
 "Running   ",
 "Error     "
};


Last bit were the code is located on the lcd ...
Code: [Select]

static unsigned long updateTime = 0;    // temp so that we can measure how long display updates take    
   unsigned long now = micros();
   forceDisplayUpdate = false;
   
   lcd.setCursor(11, 0);  <<<<<<<<<<<<<<<how do i insert that marquee function in to this result to be displayed on the lcd
   lcd.print(F("Status "));   <<<<<<<<<<<<
   lcd.setCursor(11, 42);
   lcd.print(statusText[state]);




Code: [Select]

// Return true if any error flags are set
bool badState()
{
 for (int i = 0; i < numErrorMonitors; ++i)
 {
   if (errMonitors[i].getState())
   {
     return true;
   }
 }
 return false;
}

// Convert an ADC reading to a temperature in degrees Celsius
int calcTemp(int adcReading)
{
#if TEMP_SENSOR_TYPE == 34
 // Sensor outputs 10mV per deg F referenced to 0 deg F = -17.78 deg C
 return (int)(((adcReading * 250000L)/(9L * 1024L) - 1778L + 5L)/100L);
#elif TEMP_SENSOR_TYPE == 35
 // Sensor outputs 10mV per deg C referenced to 0 deg C
 return (int)(((adcReading * 1000L)/1024L) + 1L)/2;
#elif TEMP_SENSOR_TYPE == 335
 // Sensor outputs 10mV per deg C referenced to -273.16 deg C
 return (int)((((adcReading * 50000L)/1024L) - 27316L + 5L)/100L);
#else
# error "Invalid value for TEMP_SENSOR_TYPE"
#endif
}

void shutdown()
{
 digitalWrite(softStartRelayPin, HIGH);
 digitalWrite(fullStartRelayPin, HIGH);
}

void loop()
{
 if (newDataAvailable)
 {
   newDataAvailable = false;
   updateData();
   if (badState())
   {
     if (state != S_Error)
     {
       shutdown();
       state = S_Error;
     }
   }
   else if (state == S_Init)
   {
     // Now that we have valid data we can start monitoring it, so move to the Stopped state
     state = S_Stopped;
     startButton.getNewPress();
   }
 }
 
 switch (state)
 {
   case S_Init:
     // nothing to do in this state
     break;
   case S_Stopped:
     stoppedStateFunc();
     break;
   case S_Starting:
     startingStateFunc();
     break;
   case S_Operating:
     operatingStateFunc();
     break;
   case S_Error:
     errorStateFunc();
     break;
 }
 
 updateDisplay();
}

void stoppedStateFunc()
{
 adjustFanSpeeds();
 if (startButton.getNewPress())
 {
   softStartTime = millis();
   digitalWrite(fullStartRelayPin, LOW);
   state = S_Starting;
 }
}

void startingStateFunc()
{
 adjustFanSpeeds();
 if (millis() - softStartTime >= softStartDelay)
 {
   digitalWrite(softStartRelayPin, LOW);    // bypass the soft start resistor
   state = S_Operating;
 }
}

void operatingStateFunc()
{
 adjustFanSpeeds();
 if (startButton.getNewPress())
 {
   shutdown();
   state = S_Stopped;
 }
}

void errorStateFunc()
{
 adjustFanSpeeds();
 if (!badState())
 {
   // Now that we have had valid data for a while we can leave the error state
   state = S_Stopped;
   startButton.getNewPress();
 }
}

// End

pylon

If you wanna get help post your whole code and not just snippets. Don't put your post text into code tags, just your code. Also provide a link to every library you used.

Go Up