2022-05-30 16:09:09 +02:00
|
|
|
#ifndef LCD_H
|
|
|
|
#define LCD_H
|
|
|
|
|
2022-05-30 21:33:48 +02:00
|
|
|
#include <string>
|
|
|
|
|
2022-05-30 16:09:09 +02:00
|
|
|
#include "hardware/i2c.h"
|
|
|
|
#include "pico/stdlib.h"
|
|
|
|
|
2022-05-31 09:47:43 +02:00
|
|
|
enum class Mode { COMMAND, CHARACTER };
|
2022-05-30 21:33:48 +02:00
|
|
|
|
2022-05-31 09:47:43 +02:00
|
|
|
class LCD {
|
2022-05-30 16:09:09 +02:00
|
|
|
public:
|
|
|
|
LCD(i2c_inst_t *i2c, const uint gpio_sda, const uint gpio_scl,
|
2022-05-31 09:47:43 +02:00
|
|
|
const uint8_t i2c_addr = 0x27, uint8_t num_cols = 16,
|
|
|
|
uint8_t num_lines = 2);
|
|
|
|
|
2022-05-30 21:33:48 +02:00
|
|
|
void sendString(const std::string &str);
|
|
|
|
void setCursor(int line, int position);
|
|
|
|
void clear();
|
2022-05-30 16:09:09 +02:00
|
|
|
|
|
|
|
private:
|
2022-05-30 21:33:48 +02:00
|
|
|
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;
|
2022-05-30 16:09:09 +02:00
|
|
|
uint8_t i2c_addr;
|
|
|
|
uint8_t num_cols;
|
|
|
|
uint8_t num_lines;
|
2022-05-31 12:29:45 +02:00
|
|
|
uint8_t cursor_x{0};
|
|
|
|
uint8_t cursor_y{0};
|
2022-05-30 16:09:09 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|