Pages: [1]   Go Down
Author Topic: using sprintf with a color O'LED display.....  (Read 503 times)
0 Members and 1 Guest are viewing this topic.
Massachusetts
Offline Offline
Full Member
***
Karma: 0
Posts: 105
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Good morning folks,
I've been working on a project to display the output voltage of a analog sensor to an O'LED display and so far I've been able to write code to accomplish this, how ever their seems to be a small issue that I would like to over come if possible.  When I start the processor the screen displays the voltage in the correct decimal format, but the output flashes repeatedly on the screen every second in order to update the current analog sensor voltage, is there a way to manipulate the code to update the sensor voltage without flashing?

Thank you Guys!!




Code:

         #include <SMARTGPU.h>//include the SMARTGPU library!
         #define MULTIPLIER 100
         #define aref_voltage 3.0




  SMARTGPU lcd;//create our object called LCD     
     

//****************************O2 SENSOR INPUTS****************************     
      const int sensor1  = A0;  // the analog pin the 02 Sensor Vout pin is connected to
            int sensorValue1; //declare a variable
     
      const int sensor2  = A1;  // the analog pin the 02 Sensor Vout pin is connected to 
            int sensorValue2; // declare a variable   
               
      const int sensor3  = A2;  // the analog pin the 02 sensor Vout pin is connected to
            int sensorValue3; // declare a variable
           
           
           
void Display(){
     
      sensorValue1 = analogRead(sensor1);
      float VoltageSensor1 = sensorValue1*aref_voltage;
      VoltageSensor1 /= 1024.0;
      long lWhole1 = 0;
      unsigned long ulPart1 = 0;
      lWhole1=(long)((float)VoltageSensor1);// whole part of the number to the left of the decimal point
      ulPart1=(long)((float)VoltageSensor1*MULTIPLIER)-lWhole1*MULTIPLIER;// fractional part to the right of the decimal point

      char PPO1[1]= "";
      sprintf(PPO1, "%li.%02li", lWhole1,ulPart1);
      lcd.string(9,70,100,50,GREEN,FONT7,TRANS,PPO1);
   
   
 
      sensorValue2 = analogRead(sensor2);
      float VoltageSensor2 = sensorValue2*aref_voltage;
      VoltageSensor2 /= 1024.0;
      long lWhole2 = 0;
      unsigned long ulPart2 = 0;
      lWhole2=(long)((float)VoltageSensor2);// whole part of the number to the left of the decimal point
      ulPart2=(long)((float)VoltageSensor2*MULTIPLIER)-lWhole2*MULTIPLIER;// fractional part to the right of the decimal point

      char PPO2[2]= "";
      sprintf(PPO2, "%li.%02li", lWhole2,ulPart2);
      lcd.string(123,70,255,65,GREEN,FONT7,TRANS,PPO2);
   
   
 
      sensorValue3 = analogRead(sensor3);
      float VoltageSensor3 = sensorValue3*aref_voltage;
      VoltageSensor3 /= 1024.0;
      long lWhole3 = 0;
      unsigned long ulPart3 = 0;
      lWhole3=(long)((float)VoltageSensor3);// whole part of the number to the left of the decimal point
      ulPart3=(long)((float)VoltageSensor3*MULTIPLIER)-lWhole3*MULTIPLIER;// fractional part to the right of the decimal point

      char PPO3[3]= "";
      sprintf(PPO3, "%li.%02li", lWhole3,ulPart3);
      lcd.string(238,70,320,65,GREEN,FONT7,TRANS,PPO3);
 
 }
 
           



void setup(){

      lcd.init();  //configure serial and pinout on arduino for SMARTGPU
      lcd.start(); //initialize SMARTGPU processor 
      analogReference(EXTERNAL); // set external analog Ref for PPO output       

  } 

void loop(){
       
   
        lcd.imageSD(0,0,"main7");
        Display();     
     
  } 

Logged

Finland
Offline Offline
Jr. Member
**
Karma: 1
Posts: 84
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Try and update only the area that changes on screen. I'm not sure how imageSD function operates, but I'm guessing it causes a flicker when it's reloading the same image over and over again. Can you make it so that the image is only loaded once during setup(). However, the rest of program needs to make sure it does not clear the background too much. If that does not work the way you like, you may need to overlay the text with the image somehow in memory, but your microprocessor might not have enough memory for anything like that. I don't know is it possible to read video ram from this display. There might be something in the library that allowed you to limit flicker.

Edit: Ah, "TRANS" must mean transparent text. Never mind what I wrote then, I didn't get the full grasp of the problem yet. I think imageSD works by loading the image from SD to memory, and then you can use drawImage to send a command to the screen to display the selected image. I didn't think the analogRead, or what do you mean, could actually dim the screen or cause some similar effect. I must have missed something obvious..
« Last Edit: February 03, 2013, 03:55:00 pm by Chaul » Logged

Pages: [1]   Go Up
Jump to: