Thanks for the reply,
I'm creating an arduino based smart watch using the Freetronics OLED (128x128) screen.
One of the biggest issues is the size of the code that displays BMPs in a sequence one after another.
I''m not really sure if i can improve this further since it was created by the engineers at Freetronics and im sure they tried to optimize it as much as they could, here is the code anyway;
while(digitalRead(button) == HIGH) {
uint32_t start = millis();
for(int i = 0; i < FRAME_COUNT2; i++) {
char filename[20];
snprintf(filename, sizeof(filename), "frames3/%03d.bmp", i);
File frame = SD.open(filename);
oled.displayBMP(frame, 0, 0);
frame.close();
}
}
I also think they way in which i am displaying messages onto the screen is probably very inefficient, this is how i am doing it. The way in which i am counting down can probably be shortened any ideas would be great.
void breathing_tech()
{
oled.selectFont(Droid_Sans_24);
oled.drawFilledBox(0,0,128,128,BLUE);
oled.drawString(0,64, " Program begins\n in\n 1", WHITE, BLUE);
digitalWrite(motor, HIGH);
delay(2000);
oled.drawString(0,64, " Program begins\n in\n 2", WHITE, BLUE);
digitalWrite(motor, HIGH);
delay(2000);
oled.drawString(0,64, " Program begins\n in\n 3", WHITE, BLUE);
digitalWrite(motor, HIGH);
delay(2000);
digitalWrite(motor, LOW);
oled.clearScreen();
oled.drawFilledBox(0,0,128,128,GREEN);
oled.drawString(0,64, " Hold\n \n 1", WHITE, GREEN);
delay(2000);
oled.drawString(0,64, " Hold\n \n 2", WHITE, GREEN);
delay(2000);
oled.drawString(0,64, " Hold\n \n 3", WHITE, GREEN);
delay(2000);
oled.drawFilledBox(0,0,128,128,BLUE);
oled.drawString(0,64, " Move\n out\n 1", WHITE, BLUE);
digitalWrite(motor, HIGH);
delay(2000);
oled.drawString(0,64, " Move\n out\n 2", WHITE, BLUE);
digitalWrite(motor, HIGH);
delay(2000);
oled.drawString(0,64, " Move\n out\n 3", WHITE, BLUE);
digitalWrite(motor, HIGH);
delay(2000);
oled.clearScreen();
oled.drawFilledBox(0,0,128,128,BLUE);
digitalWrite(motor, LOW);
oled.selectFont(Droid_Sans_24);
oled.drawString(0, 80, " Rest. . .", WHITE, BLUE);
oled.selectFont(SystemFont5x7);
oled.drawString(10, 70,"To change exercises\nhold the\nbutton down\n \nPress nothing to\ncontinue breathing", WHITE, BLUE);
delay(6000);
}
Also the way in which the user cycles through each different menu on the smart watch is listed below. Once again i can probably do this in a more efficient manner:
void loop()
{
if (buttonstate2 == LOW)
{
oled.clearScreen();
oled.drawFilledBox(0,0,128,128,BLACK);
while(digitalRead(button2)== HIGH)
{
menu();} oled.clearScreen(); }
else
{
mainclock();
}
}
void menu ()
{
oled.selectFont(SystemFont5x7);
oled.drawString(0,120, "Settings", WHITE, BLACK);
oled.drawString(0,64, "Biometrics", WHITE, BLACK);
oled.drawString(90,120, "Advice\n& Tips", WHITE, BLACK);//possibly change to something else
oled.drawString(0,0, "Back", WHITE, BLACK);
if (digitalRead(button3) == LOW)
{
oled.clearScreen();
while(digitalRead(button2) == HIGH) {
settings();
if (digitalRead(button4) == LOW)
{
oled.clearScreen();
while(digitalRead(button2) == HIGH){
oled.selectFont(SystemFont5x7);
oled.drawString(0,120, "Min\n +", BLUE, BLACK);
oled.drawString(0,64, "Min\n -", BLUE, BLACK);
oled.drawString(90,120, "Set\nDate", WHITE, BLACK);
oled.drawString(0,0, "Back", WHITE, BLACK);
if (digitalRead(button3) == LOW)
{ }
}
oled.clearScreen();
settings();
}
}
oled.clearScreen();
menu();
}
}
void settings()
{
oled.selectFont(SystemFont5x7);
oled.drawString(90,120, "Fitness\n Mode", WHITE, BLACK);
oled.drawString(0,64, "Set\nTime\nDate", WHITE, BLACK);
oled.drawString(0,0, "Back", WHITE, BLACK);
}
Any help would be great!
Thanks