45 lines
952 B
C
45 lines
952 B
C
#include "HD44780.h"
|
|
#include <driver/i2c.h>
|
|
#include <esp_log.h>
|
|
#include <freertos/FreeRTOS.h>
|
|
#include <freertos/task.h>
|
|
#include <stdio.h>
|
|
|
|
#define LCD_ADDR 0x27
|
|
#define SDA_PIN 21
|
|
#define SCL_PIN 22
|
|
#define LCD_COLS 16
|
|
#define LCD_ROWS 2
|
|
|
|
void app_main(void) {
|
|
char *tag = "LCD_16x2";
|
|
|
|
ESP_LOGI(tag, "starting app_main");
|
|
|
|
LCD_init(LCD_ADDR, SDA_PIN, SCL_PIN, LCD_COLS, LCD_ROWS);
|
|
|
|
// LCD_clearScreen();
|
|
// LCD_writeStr("Hello There");
|
|
// LCD_setCursor(0, 1);
|
|
// LCD_writeStr(" Second Row! ");
|
|
|
|
char num[8];
|
|
while (true) {
|
|
LCD_clearScreen();
|
|
LCD_writeStr("Counting Down");
|
|
|
|
for (int i = 10; i >= 0; i--) {
|
|
LCD_setCursor(8, 1);
|
|
sprintf(num, "%d", i);
|
|
LCD_writeStr(num);
|
|
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
|
|
|
LCD_setCursor(0, 1);
|
|
LCD_writeStr(" ");
|
|
}
|
|
LCD_clearScreen();
|
|
LCD_writeStr("Liftoff!");
|
|
vTaskDelay(2000 / portTICK_PERIOD_MS);
|
|
}
|
|
}
|