#include <stdio.h>
#include <ssd1306.h>
#include "pico/stdlib.h"
#include "hardware/i2c.h"
#include "fonts/font5x8.h"
#define I2C_PORT i2c0
#define SDA_PIN 4
#define SCL_PIN 5
int main() {
stdio_init_all();
// Inicializa o I2C
i2c_init(I2C_PORT, 400 * 1000);
gpio_set_function(SDA_PIN, GPIO_FUNC_I2C);
gpio_set_function(SCL_PIN, GPIO_FUNC_I2C);
gpio_pull_up(SDA_PIN);
gpio_pull_up(SCL_PIN);
// Inicializa o display OLED (endereço 0x3C padrão)
SSD1306 oled = SSD1306(128, 64, i2c0);
oled.init();
oled.setFixedFont(font5x8); // Define a fonte
while (true) {
oled.fill(0); // Limpa o display
oled.drawString(0, 0, "Ola do Pico W!");
oled.drawString(0, 10, "Display OLED");
oled.drawString(0, 20, "SDK C");
oled.update(); // Atualiza o display
sleep_ms(2000);
oled.fill(0);
oled.drawString(0, 0, "Contagem:");
for (int i = 0; i < 10; i++) {
char buffer[3];
snprintf(buffer, sizeof(buffer), "%d", i);
oled.fillRect(0, 10, 128, 10, 0); // Limpa a linha da contagem
oled.drawString(0, 10, buffer);
oled.update();
sleep_ms(1000);
}
}
return 0;
}