gbmanager/lcd.h
2022-05-30 21:36:56 +02:00

37 lines
No EOL
696 B
C++

#ifndef LCD_H
#define LCD_H
#include <string>
#include "hardware/i2c.h"
#include "pico/stdlib.h"
enum class Mode
{
COMMAND,
CHARACTER
};
class LCD
{
public:
LCD(i2c_inst_t *i2c, const uint gpio_sda, const uint gpio_scl,
const uint8_t i2c_addr = 0x27, uint8_t num_cols = 16, uint8_t num_lines = 2);
int backlight_off();
int backlight_on();
void sendString(const std::string &str);
void setCursor(int line, int position);
void clear();
private:
void sendByte(uint8_t val, Mode mode);
void toggleEnable(uint8_t val);
void i2cWriteByte(uint8_t val);
void sendChar(char val);
i2c_inst_t *i2c;
uint8_t i2c_addr;
uint8_t num_cols;
uint8_t num_lines;
};
#endif