Hi, I am working on a project to make a menu on a nokia5110 display using the LCD5110_Graph library.
In a previous code I used words (such as: Settings, Time) for the Main Menu, but this time I used bitmpas as Icons instead of words. It works but sometimes when I press the buttons the bitmap sometimes dosen’t change and the variable that the buttons add or subtract also doesn’t change. The bitmaps also seem to be partly correct because some parts of it don’t show up correctly. (Bitmaps converted as png are attached below)
here is a video that shown my result: https://drive.google.com/open?id=1LUm-7t4dqsl6c8HAKhq_3iH05OnLfAru
Here is the code:
#include <LCD5110_Graph.h>
LCD5110 myLcd(7, 6, 5, 3, 4);
const uint8_t SettingIcon[] PROGMEM = {
0xFF, 0x01, 0x01, 0x01, 0x01, 0x61, 0x91, 0x19, 0x11, 0x11, 0x11, 0x11, 0x87, 0x87, 0x87, 0x87,
0x19, 0x11, 0x11, 0x11, 0x19, 0x91, 0x61, 0x01, 0x01, 0x01, 0x01, 0xFF, 0xFF, 0x00, 0x1E, 0x1E,
0x12, 0x92, 0x40, 0x00, 0x00, 0x0C, 0x12, 0x21, 0x40, 0x40, 0x40, 0x40, 0x21, 0x12, 0x0C, 0x00,
0x00, 0x40, 0x92, 0x12, 0x1E, 0x1E, 0x00, 0xFF, 0x7F, 0x60, 0x60, 0x60, 0x60, 0x61, 0x62, 0x66,
0x62, 0x62, 0x62, 0x66, 0x78, 0x78, 0x78, 0x78, 0x66, 0x62, 0x62, 0x62, 0x66,
};
const uint8_t TimeIcon[] PROGMEM= {
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x60, 0x10, 0x08, 0x08, 0x04, 0x04, 0x04, 0xE6, 0x06, 0x04,
0x04, 0x04, 0x08, 0x08, 0x10, 0x60, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x04, 0x3F, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00,
0x00, 0xC0, 0x3F, 0x04, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x41,
0x42, 0x42, 0x44, 0x44, 0x44, 0x4C, 0x4C, 0x44, 0x44, 0x44, 0x42, 0x42, 0x41,
};
extern uint8_t SmallFont[];
const int buttonL = 11;
const int buttonR = 10;
int stateL;
int stateR;
int lastStateL = 0;
int lastStateR = 0;
int navigatorVar = 1;
void setup() {
myLcd.InitLCD();
myLcd.setFont(SmallFont);
myLcd.update();
pinMode(buttonL, INPUT);
pinMode(buttonR, INPUT);
}
void checkIfLeftButtonIsPressed(){
if(lastStateL != stateL){
if(stateL == HIGH){
navigatorVar++;
}
}
}
void checkIfRightButtonIsPressed(){
if(lastStateR != stateR){
if(stateR == HIGH){
navigatorVar--;
}
}
}
void loop() {
stateL = digitalRead(buttonL);
stateR = digitalRead(buttonR);
checkIfLeftButtonIsPressed();
checkIfRightButtonIsPressed();
if(navigatorVar > 2){navigatorVar = 1;}
if(navigatorVar < 1){navigatorVar = 2;}
switch(navigatorVar){
case 1:
myLcd.clrScr();
myLcd.drawBitmap(28, 10, SettingIcon, 28, 22);
myLcd.update();
break;
case 2:
myLcd.clrScr();
myLcd.drawBitmap(28, 10, TimeIcon, 28, 22);
myLcd.update();
break;
}
}