GY-63_MS5611/libraries/I2C_LCD/I2C_LCD.h

131 lines
3.1 KiB
C
Raw Normal View History

2023-12-17 07:01:57 -05:00
#pragma once
//
// FILE: I2C_LCD.h
// AUTHOR: Rob.Tillaart@gmail.com
2023-12-21 13:55:56 -05:00
// VERSION: 0.1.2
2023-12-17 07:01:57 -05:00
// DATE: 2023-12-16
// PUPROSE: Arduino library for I2C_LCD
// URL: https://github.com/RobTillaart/I2C_LCD
2023-12-21 13:55:56 -05:00
#define I2C_LCD_LIB_VERSION (F("0.1.2"))
2023-12-17 07:01:57 -05:00
#include "Arduino.h"
#include "Wire.h"
2023-12-20 15:07:32 -05:00
#ifndef POSITIVE
#define POSITIVE 1
#endif
#ifndef NEGATIVE
#define NEGATIVE 0
#endif
2023-12-17 07:01:57 -05:00
class I2C_LCD : public Print
{
public:
2023-12-20 15:07:32 -05:00
// only one constructor
2023-12-17 07:01:57 -05:00
explicit I2C_LCD(uint8_t address, TwoWire * wire = &Wire);
2023-12-20 15:07:32 -05:00
// adjust pins
void config(uint8_t address, uint8_t enable, uint8_t readWrite, uint8_t registerSelect,
uint8_t data4, uint8_t data5, uint8_t data6, uint8_t data7,
2023-12-21 13:55:56 -05:00
uint8_t backLight, uint8_t polarity);
2023-12-17 07:01:57 -05:00
2023-12-20 15:07:32 -05:00
// only supports 5x8 char set for now.
// blocks 100+ millisec to give device chance to reset
2023-12-17 07:01:57 -05:00
void begin(uint8_t cols = 20, uint8_t rows = 4);
2023-12-20 15:07:32 -05:00
bool isConnected();
2023-12-17 07:01:57 -05:00
2023-12-20 15:07:32 -05:00
// BACKLIGHT
2023-12-21 13:55:56 -05:00
void setBacklightPin(uint8_t pin, uint8_t polarity);
2023-12-20 15:07:32 -05:00
void setBacklight(bool on);
void backlight() { setBacklight(true); };
void noBacklight() { setBacklight(false); };
2023-12-17 07:01:57 -05:00
2023-12-20 15:07:32 -05:00
// DISPLAY ON OFF
2023-12-17 07:01:57 -05:00
void display();
void noDisplay();
2023-12-20 15:07:32 -05:00
void on() { display(); };
void off() { noDisplay(); };
2023-12-17 07:01:57 -05:00
2023-12-20 15:07:32 -05:00
// POSITIONING & CURSOR
void clear(); // clears whole screen
void clearEOL(); // clears line from current pos.
2023-12-17 07:01:57 -05:00
void home();
2023-12-20 15:07:32 -05:00
bool setCursor(uint8_t col, uint8_t row);
void noBlink();
void blink();
void noCursor();
void cursor();
void scrollDisplayLeft();
void scrollDisplayRight();
void moveCursorRight();
void moveCursorLeft();
// next 4 limited support
void autoscroll();
void noAutoscroll();
void leftToRight();
void rightToLeft();
2023-12-17 07:01:57 -05:00
2023-12-20 15:07:32 -05:00
// 8 definable characters
void createChar(uint8_t index, uint8_t * charmap);
// clean way to print them
inline size_t special(uint8_t index) { return write((uint8_t)index); };
2023-12-17 07:01:57 -05:00
2023-12-21 13:55:56 -05:00
// PRINT INTERFACE ++
2023-12-17 07:01:57 -05:00
size_t write(uint8_t c);
2023-12-21 13:55:56 -05:00
size_t center(uint8_t row, const char * message);
size_t right(uint8_t col, uint8_t row, const char * message);
2023-12-17 07:01:57 -05:00
2023-12-20 15:07:32 -05:00
// DEBUG development
uint8_t getColumn() { return _pos; }; // works.
uint32_t getWriteCount() { return _count; }; // works
private:
2023-12-17 07:01:57 -05:00
void sendData(uint8_t value);
void sendCommand(uint8_t value);
2023-12-21 13:55:56 -05:00
void send(uint8_t value, bool dataFlag);
2023-12-17 07:01:57 -05:00
void write4bits(uint8_t value);
uint8_t _address = 0;
TwoWire * _wire = NULL;
2023-12-20 15:07:32 -05:00
uint8_t _enable = 4;
uint8_t _readWrite = 2;
uint8_t _registerSelect = 1;
uint8_t _dataPin[4] = { 16, 32, 64, 128 };
2023-12-17 07:01:57 -05:00
2023-12-20 15:07:32 -05:00
uint8_t _backLightPin = 8;
uint8_t _backLightPol = 1;
uint8_t _backLight = 1;
2023-12-17 07:01:57 -05:00
uint8_t _cols = 20;
uint8_t _rows = 4;
2023-12-21 13:55:56 -05:00
2023-12-20 15:07:32 -05:00
// DISPLAYCONTROL bit always on, set in constructor.
uint8_t _displayControl = 0;
// optimization
bool _pinsInOrder = true;
// overflow protection
uint8_t _pos = 0;
uint32_t _count = 0;
2023-12-17 07:01:57 -05:00
};
// -- END OF FILE --