#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include "pico/stdlib.h"
#include "hardware/i2c.h"
#include "ssd1306.h"
#include "image.h"
#define SLEEPTIME 25
void setup_gpios(void);
void animation(void);
int main() {
stdio_init_all();
setup_gpios();
animation();
return 0;
}
void setup_gpios(void) {
i2c_init(i2c1, 400000);
gpio_set_function(2, GPIO_FUNC_I2C);
gpio_set_function(3, GPIO_FUNC_I2C);
gpio_pull_up(2);
gpio_pull_up(3);
}
void animation(void) {
char *words[] = {"SSD1306", "DISPLAY", "DRIVER"};
ssd1306_t disp;
disp.external_vcc = false;
ssd1306_init(&disp, 128, 64, 0x3C, i2c1);
ssd1306_clear(&disp);
for (;;) {
for (int y = 0; y < 31; ++y) {
ssd1306_draw_line(&disp, 0, y, 127, y);
ssd1306_show(&disp);
sleep_ms(SLEEPTIME);
ssd1306_clear(&disp);
}
for (int y = 0, i = 1; y >= 0; y += i) {
ssd1306_draw_line(&disp, 0, 31 - y, 127, 31 + y);
ssd1306_draw_line(&disp, 0, 31 + y, 127, 31 - y);
ssd1306_show(&disp);
sleep_ms(SLEEPTIME);
ssd1306_clear(&disp);
if (y == 32) i = -1;
}
for (int i = 0; i < sizeof(words) / sizeof(char *); ++i) {
ssd1306_draw_string(&disp, 8, 24, 2, words[i]);
ssd1306_show(&disp);
sleep_ms(800);
ssd1306_clear(&disp);
}
for (int y = 31; y < 63; ++y) {
ssd1306_draw_line(&disp, 0, y, 127, y);
ssd1306_show(&disp);
sleep_ms(SLEEPTIME);
ssd1306_clear(&disp);
}
ssd1306_bmp_show_image(&disp, image_data, image_size);
ssd1306_show(&disp);
sleep_ms(2000);
}
}
Loading
ssd1306
ssd1306