Scale-N

Scale-N

Arduino

Componenten

Rollend Materieel

Naslag

Onderdelen

Wissels

Basis Electronica

Symbols Electronica

Programming Arduino

DCC++

DR5000

Products

Link

Stats













































Module, Oled module
  • resolution: 128X64
  • super wide viewing angle: more than 160 ° (maximum viewing angle display a screen)
  • ultra-low power consumption: normal display 0.08W (far below the TFT display)
  • wide supply range: DC 3V-5V (without any changes, directly compatible with common 3.3V and 5V power supply system)
  • industrial grade: Operating temperature range -30 degree~ 70 degree
  • the ultra-small size: (length) 35.4MM * (W) 33.5MM * (thickness) 4.3MM
  • support for multiple operating modes: 3-wire SPI, 4 wire SPI, IIC
  • with chip select CS signal, you can achieve multiple SPI or IIC device on the same bus work
  • compatible with 3.3V and 5V control chip I / O level (without any set, directly compatible)
  • OLED screen, internal drive chip: SH1106 (Operation and SSD1306 same)

Bitmap


#include "U8glib.h"
 
U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_NONE); // I2C / TWI 
 
const uint8_t bm[] PROGMEM = {
  0b00011000,
  0b00111100,
  0b01111110,
  0b11111111,
  0b11111111,
  0b01111110,
  0b00111100,
  0b00011000
};
 
static int WIDTH=128;
static int HEIGHT=64;
 
int x, y;
 
void setup(void) {
  x = 0;
  y = 0;
}
 
void loop(void) {
 
  u8g.firstPage();  
  do {
    u8g.drawBitmapP( x, y, 1, 8, bm);
  } while( u8g.nextPage() );
  
  delay(100);
 
  x += 8;
  if( x >= WIDTH){
    x = 0;
    y += 8;
    if( y >= HEIGHT){
      y = 0;
    }
  }
}

    


Wave



his example read analog input inside loop(), it’s not in fixed timing, and affected by the slow operation of displaying. To read input in accurate timing

#include "U8glib.h"
 
U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_NONE); // I2C / TWI 
 
const int WIDTH=128;
const int HEIGHT=64;
const int LENGTH=WIDTH;
 
const int analogInPin = A0;
int analogInValue = 0;
 
int x;
int y[LENGTH];
 
void clearY(){
  for(int i=0; i= WIDTH){
    x = 0;
    clearY();
  }
}
    


Analog input



the analog input is captured inside loop(), it’s not in fixed timing, and affected by the slow operation of displaying

#include "U8glib.h"
 
U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_NONE); // I2C / TWI 
 
const int WIDTH=128;
const int HEIGHT=64;
const int LENGTH=WIDTH;
 
const int LED = 13;
boolean LEDst = false;
 
//true: request capture analog input in ISR
//false: stop capture, draw waveform in loop
boolean capture = false;
 
const int analogInPin = A0;
int analogInValue = 0;
 
int x;
int y[LENGTH];
 
/*
    reference: Arduino Timer and Interrupt Tutorial
    http://blog.oscarliang.net/arduino-timer-and-interrupt-tutorial/
    
    For our TIMER1 Interrupt:
    Clock Freq = 16MHz
    no prescale, 1
    16MHz - 0.0625us/cycle
   
    To calculator preload value to generate 1ms(1KHz) 
    (65536 - t) x 0.0625us = 1000us
    t = 65536 - 1000/0.0625 = 49536
    
    To calculator preload value to generate 0.5ms(2KHz)
    (65536 - t) x 0.0625us = 500us
    t = 65536 - 500/0.0625 = 57536
 
 */
const int TCNT1_PRELOAD = 57536;
 
void clearY(){
  for(int i=0; i= WIDTH){
      capture = false;
    }
  }
}
    
Oled 4Pin-1.3 IIC Blue, #1, Bak 1.03.B


Library OLED SSD1306 - SH1106
OLED_SSD1306___SH1106-1.0.6.zip
U8glib-1.19.1.zip