bitmap logo st7920

1 post / 0 new
HOHM's picture

Offline

Joined: Sep 19, 2018

Replies: 3
bitmap logo st7920
September 26, 2018 - 3:30pm

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

}