Go Down

Topic: using sprintf with a color O'LED display..... (Read 792 times) previous topic - next topic


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: [Select]

         #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);
      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);
      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);



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(){


Feb 03, 2013, 09:39 pm Last Edit: Feb 03, 2013, 09:55 pm by Chaul Reason: 1
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..

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131