DISPLAY ST7920

HOHM's picture

Offline

Joined: Sep 19, 2018

Replies: 3
DISPLAY ST7920
September 23, 2018 - 8:42pm

Hello
I would like to put a bitmap image that I already have at the start of the screen (logo);
st7920 library (u8glib) screen
but I can not do it someone could help me please

Jayant's picture

Offline

Joined: May 19, 2015

Replies: 204
Bitmap with ST7920 using u8glib lib
September 24, 2018 - 11:34am

Please be more precise when describing your problem. What do you mean by "I can not do it"? what problem are you facing?

The complete explanation of how to use bitmap on with ST7920 is given here

https://circuitdigest.com/microcontroller-projects/graphical-lcd-interfa...

In the program given in the above link cut the following lines from the void loop function 

 clearLCD();
  u8g.firstPage();  
  do {
     picture();
  } while( u8g.nextPage() );
  delay(3000);

 

And paste it at the end of setup() function and your screen will boot with the bitmap image. 

 

HOHM's picture

Offline

Joined: Sep 19, 2018

Replies: 3
BITMAP LOGO
September 26, 2018 - 3:27pm

Hello
knows my program and the boot image and then the program and starts again
could you please look in advance thank you

#include <Time.h>
#include <TimeLib.h>
#include <DS3232RTC.h>
#include <sunMoon.h>
#include "U8glib.h"

U8GLIB_ST7920_128X64 u8g(13, 11, 12, U8G_PIN_NONE);
const char *Day[] = {"","Dim","Lun", "Mar", "Mer", "Jeu", "Ven","Sam"};
const uint8_t bonsai_bitmap[] PROGMEM = {

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // ................................................................................................................................
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // ................................................................................................................................
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // ................................................................................................................................
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x80,0x00,0x00,0x00,0x00,0x00,0x00, // .................................................................########.......................................................
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xFF,0xF3,0xF0,0x00,0x00,0x00,0x00,0x00, // ............................................................################..######............................................
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00,0x00, // ........................................................###############################.........................................
  0x00,0x00,0x00,0x00,0x00,0x0F,0xFF,0xFF,0xFF,0xFE,0x7F,0x00,0x00,0x00,0x00,0x00, // ............................................###################################..#######........................................
  0x00,0x00,0x00,0x00,0x00,0x1F,0xFF,0xFF,0xFF,0xF8,0x1F,0x00,0x00,0x00,0x00,0x00, // ...........................................##################################......#####........................................
  0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x80,0x00,0x7F,0x00,0x00,0x00, // ................................................#################################................#######........................
  0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0xFF,0xFF,0xFF,0xF8,0x01,0xFF,0x83,0xE0,0x00, // ..........................................###########################################..........##########.....#####.............
  0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0xFF,0xFF,0xFF,0xFC,0x19,0xFC,0xFF,0xF0,0x00, // ..........................................############################################.....##..#######..############............
  0x00,0x00,0x00,0x00,0x00,0x07,0xFF,0xFF,0xFD,0xFF,0x30,0x3F,0xFF,0xFF,0xE0,0x00, // .............................................#########################.#########..##......#########################.............
  0x00,0x00,0x00,0x00,0x00,0x1F,0xFF,0xFF,0xF8,0x00,0x07,0xFF,0xFF,0xFC,0x00,0x00, // ...........................................##########################................#########################..................
  0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0xFF,0xE0,0x00,0x7F,0xFF,0xFF,0xFC,0xF8,0x00, // ..........................................#########################..............#############################..#####...........
  0x00,0x00,0x00,0x00,0x1C,0x1F,0xFF,0x8F,0x80,0x3F,0xFF,0xFF,0xFF,0xFF,0xF8,0x00, // ...................................###.....##############...#####.........###########################################...........
  0x00,0x00,0x00,0x00,0x3F,0xFF,0xFF,0x87,0xFF,0xFF,0xFF,0xFF,0x80,0x7F,0xE0,0x00, // ..................................#######################....####################################........##########.............
  0x00,0x00,0x00,0x00,0x3F,0xFF,0xFF,0x87,0xFF,0xC0,0x03,0xC3,0xE0,0x00,0x00,0x00, // ..................................#######################....#############............####....#####.............................
  0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x0F,0xF0,0x00,0x00,0x01,0xE0,0x00,0x00,0x00, // ........................................################....########...........................####.............................
  0x00,0x00,0x00,0x00,0x01,0xFF,0x87,0xFF,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // .......................................##########....############...............................................................
  0x00,0x00,0x00,0x00,0x00,0x0F,0xF0,0xFF,0x00,0x00,0x00,0x03,0xFC,0x00,0x00,0x00, // ............................................########....########..............................########..........................
  0x00,0x00,0x3F,0xE7,0xDF,0x01,0xF0,0x3F,0xC0,0x00,0x7F,0x07,0xC0,0x07,0xF0,0x00, // ..................#########..#####.#####.......#####......########...............#######.....#####...........#######............
  0x00,0x00,0x1F,0xFF,0xFF,0xF8,0x00,0x1F,0xF8,0x00,0xFF,0xFF,0xFF,0xFF,0xF0,0x00, // ...................##########################..............##########...........####################################............
  0x00,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0xBF,0xFF,0xE0,0x3F,0xFF,0xFF,0xFF,0xF8,0x00, // .......................##################################.#################.......###################################...........
  0x00,0x00,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE1,0xFF,0xFF,0xFF,0xFF,0xFF,0x00, // ...................########################################################....#########################################........
  0x00,0xDF,0xBF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x80, // ........##.######.#######################################################################################################.......
  0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x80, // .......##################################################################################################################.......
  0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0x00,0x7F,0xFF,0xFF,0xFF,0xE0,0x00, // ......#################################################################..........##################################.............
  0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,0x00,0x3F,0xFF,0xFF,0xFF,0xFF,0x00, // .......#############################################################..............######################################........
  0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x1F,0xFF,0xFF,0xFF,0x0E,0x00, // .........#######################################################...................#############################....###.........
  0x00,0x1F,0xFF,0xFF,0xFF,0xFF,0x87,0xFC,0x03,0xF0,0x00,0x1F,0x0F,0xFC,0x00,0x00, // ...........######################################....#########........######...............#####....##########..................
  0x00,0x3F,0xFF,0xFF,0xC7,0xFF,0x1F,0xF0,0xE3,0xF9,0xE0,0x0E,0x0F,0xFF,0x80,0x00, // ..........########################...###########...#########....###...#######..####.........###.....#############...............
  0x00,0xFF,0xFF,0xF3,0x80,0x00,0x1F,0xC1,0xFF,0xFF,0xF0,0x00,0x00,0x00,0x00,0x00, // ........####################..###..................#######.....#####################............................................
  0x00,0x7E,0x1F,0xE7,0x80,0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0x80,0x00,0x00,0x00,0x00, // .........######....########..####................########################################.......................................
  0x00,0x3E,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xC0,0x00,0x00,0x00,0x00, // ..........#####.................................##########################################......................................
  0x00,0x00,0x00,0x00,0x00,0x03,0xFF,0x0C,0x7C,0x3F,0x03,0xC0,0x00,0x00,0x00,0x00, // ..............................................##########....##...#####....######......####......................................
  0x00,0x00,0x00,0x00,0x00,0x07,0xFC,0x00,0x00,0x07,0xF8,0x00,0x00,0x00,0x00,0x00, // .............................................#########.......................########...........................................
  0x00,0x00,0x00,0x00,0x00,0x07,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // .............................................#########..........................................................................
  0x00,0x00,0x00,0x00,0x00,0x0F,0xFC,0x00,0x00,0x01,0x00,0x00,0x01,0x40,0x00,0x00, // ............................................##########.........................#.......................#.#......................
  0x00,0x00,0x00,0x00,0x00,0x0F,0xFF,0xC0,0x00,0x01,0x00,0x00,0x00,0x00,0xE0,0x00, // ............................................##############.....................#................................###.............
  0x00,0x00,0x00,0x00,0x00,0x07,0xFF,0xFC,0x00,0x01,0xC6,0x31,0xCC,0x81,0x10,0x00, // .............................................#################.................###...##...##...###..##..#......#...#............
  0x00,0x00,0x00,0x00,0x00,0x03,0xFF,0xFF,0x80,0x01,0x29,0x4A,0x12,0x81,0x10,0x00, // ..............................................###################..............#..#.#..#.#..#.#....#..#.#......#...#............
  0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xFF,0xC0,0x01,0x29,0x49,0x9E,0x81,0x10,0x00, // ....................................................##############.............#..#.#..#.#..#..##..####.#......#...#............
  0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xFF,0xE0,0x01,0x29,0x48,0x52,0x80,0xA0,0x00, // ......................................................#############............#..#.#..#.#..#....#.#..#.#.......#.#.............
  0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xFF,0xF0,0x00,0xC6,0x4B,0x92,0x91,0xB0,0x00, // .....................................................###############............##...##..#..#.###..#..#.#..#...##.##............
  0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // ................................................#####################...........................................................
  0x00,0x00,0x00,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0x00,0x00,0x00,0x00, // ...........................##############################################################.......................................
  0x00,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00, // ....................############################################################################................................
  0x00,0x00,0x7F,0xE0,0x00,0x1F,0xFF,0xE0,0x00,0x00,0x00,0x3F,0xF0,0x00,0x00,0x00, // .................##########................################...............................##########............................
  0x00,0x00,0x78,0x03,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x00,0x00,0x00, // .................####.........#####.............................................................####............................
  0x00,0x00,0x7F,0x73,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x70,0x00,0x00,0x00, // .................#######.###..########..................................................#####....###............................
  0x00,0x00,0x3F,0xFF,0xC0,0x00,0x00,0x00,0x00,0x00,0x07,0xFF,0xF0,0x00,0x00,0x00, // ..................################...................................................###############............................
  0x00,0x00,0x1F,0xFF,0xE0,0x00,0x00,0x00,0x00,0x00,0x1F,0xFF,0xE0,0x00,0x00,0x00, // ...................################................................................################.............................
  0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0x00,0x00,0x00, // ........................#########################################################################...............................
  0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00, // .........................######################################################################.................................
  0x00,0x00,0x00,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF8,0x00,0x00,0x00,0x00, // ...........................##################################################################...................................
  0x00,0x00,0x00,0x07,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC0,0x00,0x00,0x00,0x00, // .............................#############################################################......................................
  0x00,0x00,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00, // ...............................#########################################################........................................
  0x00,0x00,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00,0x00, // ...............................########################################################.........................................
  0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF8,0x00,0x00,0x00,0x00,0x00, // ................................#####################################################...........................................
  0x00,0x00,0x00,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,0x00,0x00,0x00,0x00,0x00, // ....................................################################################............................................
  0x00,0x00,0x00,0x00,0x0F,0xC0,0x00,0xFF,0xC0,0x07,0xE0,0x00,0x00,0x00,0x00,0x00, // ....................................######..............##########...........######.............................................
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // ................................................................................................................................
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // ................................................................................................................................
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00  // ................................................................................................................................
};
 

#define OUR_latitude 43.70 //nice
#define OUR_longtitude 7.25 //nice
#define OUR_timezone 120// localtime with UTC difference in minutes

sunMoon sm;

void draw(time_t sRise, time_t sSet) {
u8g.drawBitmapP( 0, 0, 16,64, bonsai_bitmap);
//delay(2000);
//clearLCD();
u8g.setFont(u8g_font_fur11);//(u8g_font_unifont); // select font6x10
u8g.setPrintPos(0, 15); // set position
printLcdDate(RTC.get()); // display time
u8g.setPrintPos(58, 15); // set position
printLcdDate1(RTC.get()); // display date
u8g.setPrintPos(0, 30); // set position
printLcdDate(sRise);
u8g.setPrintPos(0, 45); // set position
printLcdDate(sSet);
u8g.setPrintPos(100,15);
u8g.print(Day[weekday()]);
u8g.setPrintPos(60, 45);
if (RTC.get() >=sRise && RTC.get() <=sSet )
  {
    Serial.println("Jour");
    u8g.setPrintPos(60, 45);
    u8g.print("Jour");
  }
  else if (RTC.get()>=sSet && RTC.get() <=sRise )
  {
    Serial.println("Nuit");
    u8g.setPrintPos(60,45);
    u8g.print("Nuit");
  }
  else
  {
  }
 }
void printDate(time_t date) {
char buff[20];
sprintf(buff, "%2d-%02d-%4d %02d:%02d:%02d",
day(date), month(date), year(date), hour(date), minute(date), second(date));
Serial.print(buff);
}

void Time(time_t date) {
char buff[20];
sprintf(buff, "%02d:%02d:%02d",
hour(date), minute(date), second(date));
Serial.print(buff);
}

//additional function
void printLcdDate(time_t date) {
char buff[20];
sprintf(buff, "%02d:%02d:%02d",
hour(date), minute(date), second(date));
u8g.print(buff);
}
//additional function
void printLcdDate1(time_t date) {
char buff[20];
sprintf(buff, "%2d-%02d",//-%4d",
day(date), month(date), year(date));
u8g.print(buff);
}

void setup() {
tmElements_t tm; // specific time

tm.Second = 0;
tm.Minute = 12;
tm.Hour = 12;
tm.Day = 3;
tm.Month = 8;
tm.Year = 2016 - 1970;
time_t s_date = makeTime(tm);

Serial.begin(9600);
setSyncProvider(RTC.get); // the function to get the time from the RTC
if (timeStatus() != timeSet)
Serial.println("Unable to sync with the RTC");
else
Serial.println("RTC has set the system time");

sm.init(OUR_timezone, OUR_latitude, OUR_longtitude);
Serial.print("Today is ");
printDate(RTC.get()); Serial.println("");
byte mDay = sm.moonDay();
time_t sRise = sm.sunRise();
time_t sSet = sm.sunSet();
Serial.print("Moon age is "); Serial.print(mDay); Serial.println("day(s)");
Serial.print("Today sunrise and sunset: ");
printDate(sRise); Serial.print("; ");
printDate(sSet); Serial.println("\t");

Serial.print("Specific date was ");
printDate(s_date); Serial.println("");
mDay = sm.moonDay(s_date);
sRise = sm.sunRise(s_date);
sSet = sm.sunSet(s_date);
Serial.print("Specific date sunrise and sunset was: ");
Serial.print("Moon age was "); Serial.print(mDay); Serial.println("day(s)");
printDate(sRise); Serial.print("; ");
printDate(sSet); Serial.println("");
}
void picture(void) {
  u8g.drawBitmapP( 0, 0, 16,64, bonsai_bitmap);
}
void clearLCD(){
    u8g.firstPage();  
    do {
    } while( u8g.nextPage() );
}
void loop() {

time_t sRise = sm.sunRise();
time_t sSet = sm.sunSet();

printDate(RTC.get()); Serial.print("\t");
Time(sRise); Serial.print("\t ");
Time(sSet); Serial.println("");

if (RTC.get() >=sRise && RTC.get() <=sSet )
{
Serial.println("Jour");

}
else if (RTC.get()>=sSet && RTC.get() <=sRise )
{
Serial.println("Nuit");
}
  else
{
}    

 u8g.firstPage();
  do  {
   picture();
  } while( u8g.nextPage() );
    delay(2000);
    clearLCD();
    u8g.firstPage();
  do  {
     draw(sRise, sSet);
  } while(u8g.nextPage());
    delay(1000); // Delay of 1sec

}

Aswinth Raj's picture

Offline

Joined: Aug 16, 2016

Replies: 878
What is the problem?
September 27, 2018 - 1:06pm

code looks fine, what problem r u facing?

HOHM's picture

Offline

Joined: Sep 19, 2018

Replies: 3
bitmap logo
September 27, 2018 - 6:05pm

Hello
the logo oscillates between the program,
I would like to boot on the logo with a delay and then pass on my program, if you can help me, thank you

Aswinth Raj's picture

Offline

Joined: Aug 16, 2016

Replies: 878
change the void loop
September 30, 2018 - 11:23am

Remove the below lines in the void loop function

clearLCD();
  u8g.firstPage();  
  do {
     picture();
  } while( u8g.nextPage() );
  delay(3000);

 

Then you will get the logo only during boot