ATTiny85 2 — ATtiny85 simulation

An interactive ATtiny85 circuit simulation you can run free in your browser on Velxio, by ian7171.

Components

Sketch code

#define F_CPU 8000000UL // Is slower than the CPU but for this is fine

#include <avr/io.h>
#include <avr/pgmspace.h>
#include <util/delay.h>
#include <stdint.h>
#include "functions.h"





/* =========================================================
   CURSOR
   ========================================================= */



/* =========================================================
   CLEAR DISPLAY
   ========================================================= */




/* =========================================================
   MINIMAL FONT IN FLASH
   Only H E L O needed for HELLO
   ========================================================= */

const uint8_t glyph_H[5] PROGMEM =
{
    0x7F, 0x08, 0x08, 0x08, 0x7F
};

const uint8_t glyph_E[5] PROGMEM =
{
    0x7F, 0x49, 0x49, 0x49, 0x41
};

const uint8_t glyph_L[5] PROGMEM =
{
    0x7F, 0x40, 0x40, 0x40, 0x40
};

const uint8_t glyph_O[5] PROGMEM =
{
    0x3E, 0x41, 0x41, 0x41, 0x3E
};


/* =========================================================
   PRINT ONE GLYPH
   ========================================================= */

static void oled_glyph(const uint8_t *glyph)
{
    oled_data_start();

    for (uint8_t i = 0; i < 5; i++)
    {
        uint8_t b =
            pgm_read_byte(&glyph[i]);

        usi_write_byte(b);
    }

    usi_write_byte(0x00);

    oled_data_stop();
}


/* =========================================================
   MAIN
   ========================================================= */

int main(void)
{
    usi_i2c_init(); // Set up AT85 SCL and SDA to USI
    oled_init(); // Init the OLED
    oled_clear(); // Clear the screen




    oled_cursor(10, 2);

   
    /*oled_glyph(glyph_E);
    oled_glyph(glyph_L);
    oled_glyph(glyph_L);
    oled_glyph(glyph_O);
 oled_glyph(glyph_H);*/
    while (1)
    {
    }

    return 0;
}

More projects by ian7171