// simple project using Arduino UNO and 128x64 SSD1306 IIC OLED Display, created by upir, 2023
// youtube channel: https://www.youtube.com/upir_upir
// YOUTUBE VIDEO: https://youtu.be/Eyvzw_ujcS0
// More videos with Arduino UNO and OLED screens: https://www.youtube.com/playlist?list=PLjQRaMdk7pBZ1UV3IL5ol8Qc7R9k-kwXA
// Links from the video:
// Lopaka editor: https://lopaka.app/
// 128x64 SSD1306 OLED Display 1.54": https://s.click.aliexpress.com/e/_DCYdWXb
// 128x64 SSD1306 OLED Display 0.96": https://s.click.aliexpress.com/e/_DCKdvnh
// 128x64 SSD1306 OLED Display 2.42": https://s.click.aliexpress.com/e/_DFdMoTh
// Arduino UNO: https://s.click.aliexpress.com/e/_AXDw1h
#include <Arduino.h>
#include <U8g2lib.h>
#include <Wire.h> // library requires for IIC communication
U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // initialization for the used OLED display
// images from https://lopaka.app/
//static const unsigned char image_Lock_7x8_bits[] U8X8_PROGMEM = {0x1c,0x22,0x22,0x7f,0x7f,0x77,0x7f,0x3e};
//static const unsigned char image_Bluetooth_Idle_5x8_bits[] U8X8_PROGMEM = {0x04,0x0d,0x16,0x0c,0x0c,0x16,0x0d,0x04};
//static const unsigned char image_Volup_8x6_bits[] U8X8_PROGMEM = {0x48,0x8c,0xaf,0xaf,0x8c,0x48};
//static const unsigned char image_Alert_9x8_bits[] U8X8_PROGMEM = {0x10,0x00,0x38,0x00,0x28,0x00,0x6c,0x00,0x6c,0x00,0xfe,0x00,0xee,0x00,0xff,0x01};
int progress = 0; // progress of the progressbar
char buffer[32]; // helper buffer to construct a string to be displayed
void setup(void) {
u8g2.begin(); // start the u8g2 library
}
void loop(void) {
u8g2.clearBuffer(); // clear the internal memory
/*
// code from https://lopaka.app/
*/
static const unsigned char image_ButtonRightSmall_3x5_bits[] U8X8_PROGMEM = {0x01,0x03,0x07,0x03,0x01};
u8g2.setBitmapMode(1);
/*u8g2.setFont(u8g2_font_4x6_tr);
u8g2.drawStr(0, 5, "GBC Solutions");
u8g2.setFont(u8g2_font_4x6_tr);
u8g2.drawStr(89, 5, "BMS Ver 6");
*/
u8g2.drawStr(1, 5, "Bat Voltage");
u8g2.setFont(u8g2_font_4x6_tr);
u8g2.drawStr(68, 5, "Calib V");
u8g2.setFont(u8g2_font_4x6_tr);
u8g2.drawStr(2, 28, "In Voltage");
u8g2.setFont(u8g2_font_4x6_tr);
u8g2.drawStr(68, 28, "Boost V");
u8g2.drawXBMP( 45, 15, 3, 5, image_ButtonRightSmall_3x5_bits);
u8g2.drawXBMP( 45, 0, 3, 5, image_ButtonRightSmall_3x5_bits);
u8g2.setFont(u8g2_font_4x6_tr);
u8g2.drawStr(1, 20, "Boost OK");
u8g2.drawStr(52,20,"Battery on Charge");
u8g2.drawStr(1, 13, "Battery OK");
u8g2.drawXBMP( 45, 8, 3, 5, image_ButtonRightSmall_3x5_bits);
u8g2.drawStr(52,13,"Load ON");
u8g2.drawXBMP( 97, 0, 3, 5, image_ButtonRightSmall_3x5_bits);
u8g2.drawXBMP( 44, 23, 3, 5, image_ButtonRightSmall_3x5_bits);
u8g2.drawXBMP( 97, 23, 3, 5, image_ButtonRightSmall_3x5_bits);
sprintf(buffer, "%d", progress); // construct a string with the progress variable
u8g2.drawStr(50, 28, buffer); // display the string
sprintf(buffer, "%d", progress+1); // construct a string with the progress variable
u8g2.drawStr(102, 28, buffer); // display the string
sprintf(buffer, "%d", progress); // construct a string with the progress variable
u8g2.drawStr(50, 5, buffer); // display the string
sprintf(buffer, "%d", progress); // construct a string with the progress variable
u8g2.drawStr(102, 5, buffer); // display the string //u8g2.setFont(u8g2_font_haxrcorp4089_tr);
u8g2.sendBuffer(); // transfer internal memory to the display
// increase the progress value to go over 0-100
progress = progress + 1;
if (progress > 127) {
progress = 0;
}
}