Go Down

Topic: Hookup Guide: 240x128 Graphic LCD Module Display T6963 ERM240128SYG-2 (Read 7159 times) previous topic - next topic

yatin

Thanks for help david!
I tried with custom keypad earlier with success! but forgot about askii value thanks for guidance!
Secondly as I want to print many things I want to make a background logos and screen which i want to keep const and just want to change the other data, but I dont want to reconfig all screen as this will consume a lot ram of my uc so is there any way to generate or edit only specific loop with keeping other as it is means in above ex. how can i keep key word on lcd and just write 1/2/3.. as per keypad input? means I dont want to reconstruct entire screen to save space!
Yatin
Hard work is only solution if you are not smart!!

david_prentice

As a general rule,   you draw the whole screen once.    Then only redraw small areas as they change.

You can see how to do most things by studying the example sketches.     Modify small sections at a time until you get the functionality that you want for your app.   You can use Serial for input and debug output.

When you are happy with the display,   you do the same exercise with the Keypad examples.

Then add the keypad to your sketch.

Arduino is very simple to use but you should do it in small steps.    Testing as you proceed.

David.

yatin

Thanks for help,
I am trying to understand the concept of current page() and next page(); If there is any link or something available to get a brief explanation? I tried with documentation but didnt got my concepts clear!
I need to understand those concept of function pointer and all to understand that FPS example of this library!
Yatin
Hard work is only solution if you are not smart!!

yatin

#48
Feb 28, 2016, 06:23 am Last Edit: Feb 28, 2016, 08:38 am by yatin
Guys, I am facing a programming problem which I am unable to identify!
I am doing a code for my project as U mentioned above I am going good in it!
But a strange unexpected output arrivese, dont understand why that happening so I need help from forum over it!
Code: [Select]

#include "U8glib.h"

U8GLIB_T6963_240X128 u8g(2, 3, 4, 5, 6, 7, 8, 9, 10, A5, 12, 14, 13); // 8Bit Com: D0..D7: 2,3,4,5,6,7,8,9, C/D=A5, wr=12, rd=14, cs=10,FS=Gnd, reset=13
#include <Keypad.h>
const byte ROWS = 4; //four rows
const byte COLS = 4; //three columns
char keys[ROWS][COLS] = {
    {'1','2','3','A'},
    {'4','5','6','B'},
    {'7','8','9','>'},
    {'*','0','#','<'}
};
byte rowPins[ROWS] = {42, 44, 46, 48}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {43, 45, 47, 49}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
int Switch_position=0;
int Variable_Switch_A=0;
int Variable_Switch_B=0;
int Variable_Switch_C=0;
//char a='2',b='0',c='0',d='0',e,f,g,h,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y;
char ab;
int i,j;
int error_flag=0,votage_selected;
char keypad_value[4]={0,0,0,0};
#define Switch_Position_A 22
#define Switch_Position_B 23
#define Switch_Position_C 24


void setup() {
  Serial.begin(57600);


  pinMode(Switch_Position_A,INPUT);
pinMode(Switch_Position_B,INPUT);
pinMode(Switch_Position_C,INPUT);
  /*****************display***************************/
 if ( u8g.getMode() == U8G_MODE_R3G3B2 ) {
    u8g.setColorIndex(255);     // white
  }
  else if ( u8g.getMode() == U8G_MODE_GRAY2BIT ) {
    u8g.setColorIndex(3);         // max intensity
  }
  else if ( u8g.getMode() == U8G_MODE_BW ) {
    u8g.setColorIndex(1);         // pixel on
  }
  else if ( u8g.getMode() == U8G_MODE_HICOLOR ) {
    u8g.setHiColorByRGB(255,255,255);
  }
}
void IR(void){
  u8g.setFont(u8g_font_ncenR12r);
  //u8g.setFont(u8g_font_4x6);
  u8g.drawStr( 200, 12, "IR");
  u8g.drawStr( 10, 32, "1] SETTINGS");
  u8g.drawStr( 10, 62, "2] RUN TEST");
  //Serial.println("IR");
  }
void IR_SETTINGS(void){
  u8g.setFont(u8g_font_ncenR12r);
  //u8g.setFont(u8g_font_4x6);
  u8g.drawStr( 200, 12, "IR");
  u8g.drawStr( 10, 32, "1] VOLTAGE");
  u8g.drawStr( 10, 62, "2] TIME");
  u8g.setFont(u8g_font_4x6);
  u8g.drawStr( 0, 12, "Settings->voltage");
}
void IR_SETTINGS_VOLTAGE(void){
 
  u8g.setFont(u8g_font_ncenR12r);
  u8g.drawStr( 200, 12, "IR");
  u8g.setFont(u8g_font_4x6);
  u8g.drawStr( 0, 12, "Settings->voltage");
  u8g.setFont(u8g_font_ncenR08r);
  u8g.drawStr( 5, 30, "PLEASE ENTER TEST VOLTAGE VALUE");
  u8g.drawStr( 5, 50, "FROM 10V-9999V ");
  u8g.drawStr( 5, 70, "RESOLUTION WILL BE IN 10V STEPS");
 
  u8g.setFont(u8g_font_ncenR12r);
   u8g.drawStr( 5, 100, "TEST VOLTAGE=");
   {
   u8g.drawStr(160,100,&keypad_value[j]);
   }
 
//}
}
void IR_SETTINGS_VOLTAGE_SELECTED_DISPLAY(void)
{
  Serial.println("I am in IR_SETTINGS_VOLTAGE_SELECTED_DISPLAY");
  u8g.setFont(u8g_font_ncenR12r);
  u8g.drawStr( 200, 12, "IR");
  u8g.setFont(u8g_font_4x6);
  u8g.drawStr( 0, 12, "Settings->voltage");
  u8g.setFont(u8g_font_ncenR08r);
  u8g.drawStr( 0, 52,"U SELECTED VOLTAGE VALUE");
  char buffer[4];
  sprintf(buffer,"%d",votage_selected);
  Serial.println(buffer);
  u8g.drawStr( 0, 72,&buffer[j]);
  Serial.println(buffer[j]);
}
void DM(void){
}

  void SV(void){
   
  }
    void DD(void){
     
    }
      void VM(void){
    }
uint16_t picture_loop_with_fps(void (*draw_fn)(void)) {
   u8g.firstPage(); 
    do {
      draw_fn();
     
    } while( u8g.nextPage() );
   
    //error_flag=0;
}

int z=0;////////////////////initial flag
void loop() {
char key = keypad.getKey();
Switch_position=0;
Variable_Switch_A=0;
Variable_Switch_B=0;
Variable_Switch_C=0;
if(digitalRead(Switch_Position_C)==1)
  {
   Variable_Switch_C=1;
  }
if(digitalRead(Switch_Position_B)==1)
  {
    Variable_Switch_B=1;
  }
 if(digitalRead(Switch_Position_A)==1)
  {
    Variable_Switch_A=1;
  }
  Switch_position=Variable_Switch_A+Variable_Switch_B+Variable_Switch_C;


switch (Switch_position){
  case 1:
  if(z==0){                 //////for initial display call
  picture_loop_with_fps(IR);
  Serial.println("IR");
 
  Serial.println("I am ready");
   key = keypad.getKey();
  if (key=='1'){
    z=1;            /////to direct it to settings of IR mode
  }
  }
    if(z==1){               /////for going in setting option
    Serial.print("key 1,z=");
    Serial.println(z);
    picture_loop_with_fps(IR_SETTINGS);
    key = keypad.getKey();
    if (key=='1'){
    z=2;            /////to direct it to IR-setting-voltage mode
  delay(200);
  }
    }
   if(z==2){               /////for going in IR-setting-voltage option
 
     Serial.print("key 1,z=");
    Serial.println(z);
    for(i=0;i<4;i++)
    {
      key=0;
      delay(100);
      picture_loop_with_fps(IR_SETTINGS_VOLTAGE);
       
       while(!key){
        key = keypad.getKey();
       }
       Serial.print("key");
       Serial.println(key);
       if(key=='>')
       {
       i=4;
       z=3;
    }
    else{
      keypad_value[i]=key;
     
    z=3;
    }
    }
    i=4;
    z=3;
   }
   if(z==3)
   {
    Serial.print("z=:");
     Serial.println(z);
    picture_loop_with_fps(IR_SETTINGS_VOLTAGE);
    votage_selected = atoi(keypad_value);
     Serial.print("votage_selected");
     Serial.println(votage_selected);
    picture_loop_with_fps(IR_SETTINGS_VOLTAGE_SELECTED_DISPLAY);
    delay(2000);
    z=4;
   }
  break;
  case 2:
  picture_loop_with_fps(DM);
  break;
  case 3:
  picture_loop_with_fps(SV);
  break;
  case 4:
  picture_loop_with_fps(DD);
  break;
  case 5:
  picture_loop_with_fps(VM);
  break;
}

 
}


This is my whole program but I know it is too big to read and understand so just posting where I am facing problem!
Code: [Select]
if(z==2){               /////for going in IR-setting-voltage option
 
     Serial.print("key 1,z=");
    Serial.println(z);
    for(i=0;i<4;i++)
    {
      key=0;
      delay(100);
      picture_loop_with_fps(IR_SETTINGS_VOLTAGE);
       
       while(!key){
        key = keypad.getKey();
       }
       Serial.print("key");
       Serial.println(key);
       if(key=='>')
       {
       i=4;
       z=3;
    }
    else{
      keypad_value[i]=key;
     
    z=3;
    }
    }
    i=4;
    z=3;
   }
   if(z==3)
   {
    Serial.print("z=:");
     Serial.println(z);
    picture_loop_with_fps(IR_SETTINGS_VOLTAGE);
    votage_selected = atoi(keypad_value);
     Serial.print("votage_selected");
     Serial.println(votage_selected);
    picture_loop_with_fps(IR_SETTINGS_VOLTAGE_SELECTED_DISPLAY);
    delay(2000);
    z=4;
   }

In this loop my expectation is if i press '>' or enter 4 digit value this program should execute following loop
Code: [Select]
void IR_SETTINGS_VOLTAGE_SELECTED_DISPLAY(void)
{
  Serial.println("I am in IR_SETTINGS_VOLTAGE_SELECTED_DISPLAY");
  u8g.setFont(u8g_font_ncenR12r);
  u8g.drawStr( 200, 12, "IR");
  u8g.setFont(u8g_font_4x6);
  u8g.drawStr( 0, 12, "Settings->voltage");
  u8g.setFont(u8g_font_ncenR08r);
  u8g.drawStr( 0, 52,"U SELECTED VOLTAGE VALUE");
  char buffer[4];
  sprintf(buffer,"%d",votage_selected);
  Serial.println(buffer);
  u8g.drawStr( 0, 72,&buffer[j]);
  Serial.println(buffer[j]);
}

but strange thing is if I press '>' then it executes this code and print the display on lcd properly on country if i enter 4 digit value without pressing '>' so then z becomes three value goes in votage_selected and also get seria printed
Code: [Select]
Serial.println("I am in IR_SETTINGS_VOLTAGE_SELECTED_DISPLAY");
...
sprintf(buffer,"%d",votage_selected);
  Serial.println(buffer);
  u8g.drawStr( 0, 72,&buffer[j]);
  Serial.println(buffer[j]);

but again immediately my z becmes 0 and start executing my this loop
Code: [Select]
if(z==0){                 //////for initial display call
  picture_loop_with_fps(IR);
  Serial.println("IR");
 
  Serial.println("I am ready");
...

And this only happens with 4 value i/p not with '>' input?
I am not getting where I am doing wrong can any one could help me?
Yatin
Hard work is only solution if you are not smart!!

yatin

Also i would like to know can we print int value on display like we print string by using u8g.drawStr()?
Yatin
Hard work is only solution if you are not smart!!

david_prentice

Read the u8glib documentation.    e.g. from u8glib wiki

Most Arduino libraries extend the regular print class.

Look for yourself.

At the end of the day,   all "print" methods convert expressions into a readable text string.   then display the string.

David.

yatin

As it didnt mention there, so i think there is no direct option other than int to string conversion!
Thanks for help!
Yatin
Hard work is only solution if you are not smart!!

david_prentice

I am not at a PC.    If u8glib extends the print class,   it will do everything that the regular print class does.   Just like you can say Serial.print(123.4567, 3) and get a float printed with 3 decimal places.

Of course the docs may say that it only has its own limited print() methods.
This is why you read the documentation.

David.

Pspranav7

Thank you hyadent for your interfacing connections, and olikraus  for your very very helpful....U8Glib library....
it helped a lot....

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!

Arduino
via Egeo 16
Torino, 10131
Italy