/*
Refaça o programa pratico 01 presente no Ebook do Capítulo de ADC,
mude a unidade de medida da temperatura de celsius para fahrenheit.
*/
#include <stdio.h>
#include "pico/stdlib.h"
#include <string.h>
#include "ssd1306.h"
#include "hardware/i2c.h"
// Definição de constantes dos pinos GPIO e I2C (SCL, SDA)
#define SCL_PIN 27
#define SDA_PIN 26
uint8_t ssd[ssd1306_buffer_length]; // buffer display OLED
// renderização do display OLED
struct render_area frame_area = {
.start_column = 0,
.end_column = ssd1306_width - 1,
.start_page = 0,
.end_page = ssd1306_n_pages - 1
};
// Exibe mensagem de até três linhas no display OLED
void showMessageOnScreen(char *line_1, char *line_2, char *line_3) {
memset(ssd, 0, ssd1306_buffer_length);
ssd1306_draw_string(ssd, 0, 0, line_1);
ssd1306_draw_string(ssd, 0, 16, line_2);
ssd1306_draw_string(ssd, 0, 32, line_3);
render_on_display(ssd, &frame_area);
}
int main() {
stdio_init_all();
// Inicialização do I2C
i2c_init(i2c1, ssd1306_i2c_clock * 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 do display OLED
ssd1306_init();
calculate_render_area_buffer_length(&frame_area);
// Loop
while (true) {
showMessageOnScreen("X JOYSTICK LED", " BUZZER", " LED RGB");
sleep_ms(1000);
}
}