oled i2c 128x32 экран- кастомные шрифты

Тема в разделе "Arduino & Shields", создана пользователем qazwsx1212, 7 мар 2018.

Метки:
  1. qazwsx1212

    qazwsx1212 Нуб

    как добавить в библиотеку U8glib свой шрифт?
    в гугле меня забанили(
     
  2. qazwsx1212

    qazwsx1212 Нуб

    Код (C++):
    // my.c
    // Font type    : Numeric (10 characters)
    // Font size    : 9x16 pixels
    // Memory usage : 184 bytes

    #if defined(__AVR__)
        #include <avr/pgmspace.h>
        #define fontdatatype const uint8_t
    #elif defined(__PIC32MX__)
        #define PROGMEM
        #define fontdatatype const unsigned char
    #elif defined(__arm__)
        #define PROGMEM
        #define fontdatatype const unsigned char
    #endif

    fontdatatype my[184] PROGMEM={
    0x09,0x10,0x30,0x0A,
    0xFF,0xFF,0x03,0x03,0x03,0x03,0xFF,0xFF,0x00,0xFF,0xFF,0xE0,0xE0,0xE0,0xE0,0xFF,0xFF,0x00,  // 0
    0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,  // 1
    0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xFF,0xFF,0x00,0xFF,0xFF,0xE1,0xE1,0xE1,0xE1,0xE1,0xE1,0x00,  // 2
    0x00,0xC3,0xC3,0xC3,0xC3,0xC3,0xFF,0xFF,0x00,0x00,0xE1,0xE1,0xE1,0xE1,0xE1,0xFF,0xFF,0x00,  // 3
    0xFF,0xFF,0xC0,0xC0,0xC0,0xC0,0xFF,0xFF,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0xFF,0xFF,0x00,  // 4
    0xFF,0xFF,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0x00,0xE1,0xE1,0xE1,0xE1,0xE1,0xE1,0xFF,0xFF,0x00,  // 5
    0xFF,0xFF,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0x00,0xFF,0xFF,0xE1,0xE1,0xE1,0xE1,0xFF,0xFF,0x00,  // 6
    0x03,0x03,0x03,0x03,0x03,0x03,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x00,  // 7
    0xFF,0xFF,0xC3,0xC3,0xC3,0xC3,0xFF,0xFF,0x00,0xFF,0xFF,0xE1,0xE1,0xE1,0xE1,0xFF,0xFF,0x00,  // 8
    0xFF,0xFF,0xC3,0xC3,0xC3,0xC3,0xFF,0xFF,0x00,0xE1,0xE1,0xE1,0xE1,0xE1,0xE1,0xFF,0xFF,0x00,  // 9
    };
     
    этот вариант у меня не прокатил(((
     
  3. qazwsx1212

    qazwsx1212 Нуб

    Код (C++):
    #include "U8glib.h"
    U8GLIB_SSD1306_128X32 u8g(U8G_I2C_OPT_NONE);

    #if defined(__AVR__)
        #include <avr/pgmspace.h>
        #define fontdatatype const uint8_t
    #elif defined(__PIC32MX__)
        #define PROGMEM
        #define fontdatatype const unsigned char
    #elif defined(__arm__)
        #define PROGMEM
        #define fontdatatype const unsigned char
    #endif

    fontdatatype my[184] PROGMEM={
    0x09,0x10,0x30,0x0A,
    0xFF,0xFF,0x03,0x03,0x03,0x03,0xFF,0xFF,0x00,0xFF,0xFF,0xE0,0xE0,0xE0,0xE0,0xFF,0xFF,0x00,  // 0
    0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,  // 1
    0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xFF,0xFF,0x00,0xFF,0xFF,0xE1,0xE1,0xE1,0xE1,0xE1,0xE1,0x00,  // 2
    0x00,0xC3,0xC3,0xC3,0xC3,0xC3,0xFF,0xFF,0x00,0x00,0xE1,0xE1,0xE1,0xE1,0xE1,0xFF,0xFF,0x00,  // 3
    0xFF,0xFF,0xC0,0xC0,0xC0,0xC0,0xFF,0xFF,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0xFF,0xFF,0x00,  // 4
    0xFF,0xFF,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0x00,0xE1,0xE1,0xE1,0xE1,0xE1,0xE1,0xFF,0xFF,0x00,  // 5
    0xFF,0xFF,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0x00,0xFF,0xFF,0xE1,0xE1,0xE1,0xE1,0xFF,0xFF,0x00,  // 6
    0x03,0x03,0x03,0x03,0x03,0x03,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x00,  // 7
    0xFF,0xFF,0xC3,0xC3,0xC3,0xC3,0xFF,0xFF,0x00,0xFF,0xFF,0xE1,0xE1,0xE1,0xE1,0xFF,0xFF,0x00,  // 8
    0xFF,0xFF,0xC3,0xC3,0xC3,0xC3,0xFF,0xFF,0x00,0xE1,0xE1,0xE1,0xE1,0xE1,0xE1,0xFF,0xFF,0x00,  // 9
    };

    void draw(void) {
    u8g.setFont(my);
      u8g.drawStr( 0, 16, "01234");


    }

    void setup() {
    }

    void loop(void) {
      // picture loop
      u8g.firstPage();
      do
      {
      draw();
      }
      while( u8g.nextPage() );
      /*
      название другой функции
      */

      delay(500);
    }
     
    мой ГовноКод