Skocz do zawartości

ESP8266 własne znaki na LCD ST7032i (część II)


99teki

Pomocna odpowiedź

kod programu 

/*
	ST7032 I2C LCD control sample
	Original source : CustomCharacter.ino (LiquidCrystal Library)
	2013/05/21 tomozh@gmail.com
*/

/*
  LiquidCrystal Library - Custom Characters
 
 Demonstrates how to add custom characters on an LCD  display.  
 The LiquidCrystal library works with all LCD displays that are 
 compatible with the  Hitachi HD44780 driver. There are many of 
 them out there, and you can usually tell them by the 16-pin interface.
 
 This sketch prints "I <heart> Arduino!" and a little dancing man
 to the LCD.
 
  The circuit:
 * LCD RS pin to digital pin 12
 * LCD Enable pin to digital pin 11
 * LCD D4 pin to digital pin 5
 * LCD D5 pin to digital pin 4
 * LCD D6 pin to digital pin 3
 * LCD D7 pin to digital pin 2
 * LCD R/W pin to ground
 * 10K potentiometer:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)
 * 10K poterntiometer on pin A0
 
 created21 Mar 2011
 by Tom Igoe
 Based on Adafruit's example at
 https://github.com/adafruit/SPI_VFD/blob/master/examples/createChar/createChar.pde
 
 This example code is in the public domain.
 http://www.arduino.cc/en/Tutorial/LiquidCrystal
 
 Also useful:
 http://icontexto.com/charactercreator/
 
 */

// include the library code:
//#include <LiquidCrystal.h>
#include <Wire.h>
#include "ST7032_asukiaaa.h"

// initialize the library with the numbers of the interface pins
//LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
ST7032_asukiaaa lcd;

// make some custom characters:
byte heart[8] = {
  0b00000,
  0b01010,
  0b11111,
  0b11111,
  0b11111,
  0b01110,
  0b00100,
  0b00000
};

byte smiley[8] = {
  0b00000,
  0b00000,
  0b01010,
  0b00000,
  0b00000,
  0b10001,
  0b01110,
  0b00000
};

byte frownie[8] = {
  0b00000,
  0b00000,
  0b01010,
  0b00000,
  0b00000,
  0b00000,
  0b01110,
  0b10001
};

byte armsDown[8] = {
  0b00100,
  0b01010,
  0b00100,
  0b00100,
  0b01110,
  0b10101,
  0b00100,
  0b01010
};

byte armsUp[8] = {
  0b00100,
  0b01010,
  0b00100,
  0b10101,
  0b01110,
  0b00100,
  0b00100,
  0b01010
};

	// ------------------------------------------ setup ------------------------
void setup() {
		
  lcd.begin(16, 2);
  lcd.setContrast(40);
			
  lcd.createChar(0, heart);
	lcd.createChar(1, smiley);
			
  lcd.createChar(2, frownie);
			
  lcd.createChar(3, armsDown);  
  lcd.createChar(4, armsUp);  
				
  lcd.setCursor(0, 0);
				
  lcd.print("I"); 
  lcd.write(0);
  lcd.print(" ESP8266 NonOs ");
  lcd.write(1);
			
}

	// ---------------------------------------------- loop --------------------------
void loop() {
  
  int sensorReading = analogRead(A0);
		
  int delayTime = map(sensorReading, 0, 1023, 200, 1000);
  
  lcd.setCursor(4, 1);
		// draw the little man, arms down:
  lcd.write(3); lcd.write(32); lcd.write(1); 
  delay(300);
  lcd.setCursor(10, 1);
		// draw him arms up:
  lcd.write(4); lcd.write(32); lcd.write(1); 
  delay(300); 
  
}
// ---------------------------------- end --------------------------------------

- wygląd ekranu z LCD.

Char_arm.jpg

Edytowano przez 99teki
Link do komentarza
Share on other sites

Dołącz do dyskusji, napisz odpowiedź!

Jeśli masz już konto to zaloguj się teraz, aby opublikować wiadomość jako Ty. Możesz też napisać teraz i zarejestrować się później.
Uwaga: wgrywanie zdjęć i załączników dostępne jest po zalogowaniu!

Anonim
Dołącz do dyskusji! Kliknij i zacznij pisać...

×   Wklejony jako tekst z formatowaniem.   Przywróć formatowanie

  Dozwolonych jest tylko 75 emoji.

×   Twój link będzie automatycznie osadzony.   Wyświetlać jako link

×   Twoja poprzednia zawartość została przywrócona.   Wyczyść edytor

×   Nie możesz wkleić zdjęć bezpośrednio. Prześlij lub wstaw obrazy z adresu URL.

×
×
  • Utwórz nowe...

Ważne informacje

Ta strona używa ciasteczek (cookies), dzięki którym może działać lepiej. Więcej na ten temat znajdziesz w Polityce Prywatności.