https://github.com/recursiveerror/omnicrystal
Biblioteca modular para LCD alfanuméricos compatíveis com HITACHI HD44780 feita com CoreArduino
https://github.com/recursiveerror/omnicrystal
Last synced: 3 months ago
JSON representation
Biblioteca modular para LCD alfanuméricos compatíveis com HITACHI HD44780 feita com CoreArduino
- Host: GitHub
- URL: https://github.com/recursiveerror/omnicrystal
- Owner: RecursiveError
- License: lgpl-2.1
- Created: 2023-02-24T17:24:01.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-28T18:34:43.000Z (almost 3 years ago)
- Last Synced: 2025-03-12T18:46:02.555Z (about 1 year ago)
- Language: C++
- Size: 41 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# omnicrystal
[English version](https://github.com/RecursiveError/omnicrystal/blob/main/README_EN.md)
Biblioteca modular para LCD alfanuméricos compatíveis com HITACHI HD44780 feita com CoreArduino
Essa Biblioteca permite que usuario escolha e crie a interface de comunicação com o display LCD, Essa Biblioteca vem com duas interfaces por padrão: paralela e PCF8754(Wire)
(PCF6754 NÃO ESTÁ IMPLEMTENTADA PARA PLATAFORMA SEM SUPORTE A I2C, use o exemplo de softI2C nessas plataformas)
### Criando sua propria interface
para criar sua propria interface é bem simples, basta implementar a interface "LCDInterface" com a função send publica.
A função "send" recebe dois parametros uint8_t, "data" e "config", em que seus Bits representam:
| BITS | BIT7 | BIT6 |BIT5| BIT4| BIT3| BIT2| BIT1| BIT0|
| :------ | :------ | :------| :------| :------| :------| :------| :------| :------|
| DATA | D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 |
| CONFIG | Reserved | Reserved | Reserved | Reserved | EN2 | EN | RW | RS |
o estado de cada bit representa o estado da porta: 1 == HIGH | 0 == LOW
conecte cada bit a sua respectiva porta e pronto voce já tem uma interface funcional
(para trabalhar com PCF8754 voce pode copiar essa linha ```uint8_t package = (config & 0b00000111) | (data & 0xF0) | 0x08; ``` e enviar pela sua biblioteca I2C de sua escolha)
#### exemplo soft_i2c
```c++
/*soft_i2c cunstom interface Exemple
Author: Guilherme Silva Schultz
Data: 2023-03-22
this example uses the library:
https://github.com/felias-fogg/SoftI2CMaster
*/
//made to run on arduino uno
//change settings according to your board
//Arduino Uno pin 13
#define SCL_PIN 5
#define SCL_PORT PORTB
//Arduino Uno pin 12
#define SDA_PIN 4
#define SDA_PORT PORTB
#include
#include
//Implements LCDinterface
class LCDPCF8754_SOFT : public LCDInterface{
private:
const uint8_t _addr;
public:
LCDPCF8574_SOFT(const uint8_t addr) : _addr{addr}
{i2c_init();}
void send(uint8_t config, uint8_t data){
/*
The first 3 Low Bits of PCF8754 correspond respectively
RS - R/W - EN
0x08 is the backlight
the last 4 high bits correspond to the data pins
*/
uint8_t package = (config & 0b00000111) | (data & 0xF0) | 0x08;
i2c_start((_addr<<1)|I2C_WRITE);
i2c_write(package);
i2c_stop();
}
};
//that's all you need to create a custom interface, now just use it.
LCDPCF8754_SOFT interface(0x27);
Omnicrystal lcd(interface, Bus4Bits, 2, 16);
void setup() {
lcd.begin();
lcd.print("hello SoftI2C!!");
}
void loop() {
}
```
#### Funções
`begin` Inicia o display
`command` Envia comando da tabela de comandos do display
`clear` Limpa o display
`reset` reinicia as variaveis internas do display
`moveCursorLeft` Move o curso para esquerda
`moveCursorRight` Move o cursor para direita
`moveDisplayLeft` Move o display para esquerda
`moveDisplayRight` Move o display para direita
`shiftOn` Ativa o autoscroll
`shiftOff` Desativa o autoscroll
`increment` Autoscroll incrementa a posição
`decrement` Autoscroll decrementa a posição
`cursorBlinkOn` Ativa o cursor piscando
`cursorBlinkOff` Desativa o cursor piscando
`cursorOn` Ativa o cursor
`cursorOff` Desativa o cursor
`displayOn` Ativa a exibição
`displayOff` Desativa a exibição
`setCursor(linha, coluna)` Move o cursor (contagem inicia do 0)
`createChar(char_array, slot)` Cria um caractere customizado (recebe um array de tamanho 8 e uma posição de 0-7)
`echo` Seleciona todos os LCDs (habilita todos os EN)
`selectLcd(LCD)` Seleciona um lcd 0 = EN1 (Padrão) | 1 = EN2