test ssd1306 with arduino nano
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

46 lines
1.2 KiB

#include "twi.h"
#include "ssd1306.h"
#include "sevenseg.h"
void main() {
TWI_Init();
ssd1306_128x32_i2c_init();
// ssd1306_128x64_spi_init(-1, 0, 1); // Use this line for nano pi (RST not used, 0=CE, gpio1=D/C)
// ssd1306_128x64_spi_init(3,4,5); // Use this line for Atmega328p (3=RST, 4=CE, 5=D/C)
// ssd1306_128x64_spi_init(24, 0, 23); // Use this line for Raspberry (gpio24=RST, 0=CE, gpio23=D/C)
// ssd1306_128x64_spi_init(22, 5, 21); // Use this line for ESP32 (VSPI) (gpio22=RST, gpio5=CE for VSPI, gpio21=D/C)
// composite_video_128x64_mono_init(); // Use this line for ESP32 with Composite video support
ssd1306_clearScreen();
//ssd1306_drawLine(0,0, ssd1306_displayWidth() -1, ssd1306_displayHeight() -1);
const uint8_t charw = 18;
const uint8_t spacing = 6;
const uint8_t barw=4;
struct SevenSeg sseg = {
.x0 = 0,
.y0 = 0,
.charwidth = 17,
.thick = 3,
//.charwidth = 16,
//.thick = 1,
.spacing = 4,
};
uint16_t i = 0;
uint16_t v;
uint16_t w;
int drawing = false;
for (;;) {
sseg_number(&sseg, i, 5, 1);
i++;
if (i == 9999) i = 0;
_delay_ms(100);
}
}