Last active
March 16, 2017 12:11
-
-
Save jindrichsirucek/8c23b1a03b8374d1217fbc5de0b19bea to your computer and use it in GitHub Desktop.
Animation function for LCD 1602 connected to ESP8266 (arduino) written in C/C++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <ESP8266WiFi.h> | |
#include <LiquidCrystal_I2C.h> | |
#include <Wire.h> //I2C communication | |
#define LCD_DISPLAY_ADDRESS 0x27 | |
#define AP_SSID "wifiAP" | |
#define AP_PASSWORD "password" | |
LiquidCrystal_I2C lcd(LCD_DISPLAY_ADDRESS, 16, 2); // set the lcd address to 0x27 for a 16 chars and 2 line display | |
byte newCharWifiSending[][8] = | |
{ | |
{ | |
B00000, | |
B00000, | |
B00000, | |
B00000, | |
B00000, | |
B00000, | |
B00100, | |
B00000 | |
}, | |
{ | |
B00000, | |
B00000, | |
B00000, | |
B00100, | |
B01010, | |
B00000, | |
B00100, | |
B00000 | |
}, | |
{ | |
B00000, | |
B01110, | |
B10001, | |
B00100, | |
B01010, | |
B00000, | |
B00100, | |
B00000 | |
}, | |
{ | |
B01110, | |
B11111, | |
B10001, | |
B00100, | |
B01010, | |
B00000, | |
B00100, | |
B00000 | |
} | |
}; | |
void setup() | |
{ | |
Wire.begin(4, 5); //Wire.begin(int sda, int scl) !!! labels GPIO4 and GPIO5 on EPS8266 are swaped at old esps!!!! | |
lcd.begin(); | |
lcd.createChar(0, newCharWifiSending[0]); //First symbol | |
lcd.setCursor(0, 1); //set position of symbol - 0 pos, 1 - row | |
lcd.write(0);//show symbol at given position | |
uint8_t attempt = 100; | |
uint8_t waitSymbolCounter = 0; | |
WiFi.begin(AP_SSID, AP_PASSWORD); | |
while (WiFi.status() == WL_CONNECTED && attempt--) | |
{ | |
delay(100); | |
waitSymbolCounter = animateProgressSymbol(waitSymbolCounter); | |
} | |
} | |
void loop() | |
{ | |
} | |
uint8_t animateProgressSymbol(uint8_t waitSymbolCounter) | |
{ | |
lcd.createChar(0, newCharWifiSending[waitSymbolCounter]); | |
if(waitSymbolCounter < sizeof(newCharWifiSending)/sizeof(newCharWifiSending[0]))//Array length | |
waitSymbolCounter++; | |
else | |
waitSymbolCounter = 0; | |
return waitSymbolCounter; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment