parent
ce517df702
commit
253cf0f427
@ -0,0 +1,72 @@
|
||||
# See: https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification
|
||||
|
||||
##############################################################
|
||||
|
||||
menu.cpu=Processor
|
||||
|
||||
########################################
|
||||
## RAMBo
|
||||
########################################
|
||||
rambo.name=RAMBo
|
||||
|
||||
rambo.upload.tool=arduino:avrdude
|
||||
rambo.upload.protocol=wiring
|
||||
rambo.upload.maximum_size=258048
|
||||
rambo.upload.speed=115200
|
||||
|
||||
rambo.bootloader.low_fuses=0xFF
|
||||
rambo.bootloader.high_fuses=0xD8
|
||||
rambo.bootloader.extended_fuses=0xFD
|
||||
rambo.bootloader.path=stk500v2
|
||||
rambo.bootloader.file=stk500boot_v2_mega2560.hex
|
||||
rambo.bootloader.unlock_bits=0x3F
|
||||
rambo.bootloader.lock_bits=0x0F
|
||||
|
||||
rambo.build.mcu=atmega2560
|
||||
rambo.build.f_cpu=16000000L
|
||||
rambo.build.board=AVR_RAMBO
|
||||
rambo.build.core=arduino:arduino
|
||||
rambo.build.variant=rambo
|
||||
|
||||
########################################
|
||||
## Sanguino
|
||||
########################################
|
||||
sanguino.name=Sanguino
|
||||
|
||||
sanguino.upload.tool=ardunio:avrdude
|
||||
sanguino.upload.protocol=stk500
|
||||
sanguino.upload.maximum_size=131072
|
||||
sanguino.upload.speed=57600
|
||||
|
||||
sanguino.bootloader.low_fuses=0xD6
|
||||
sanguino.bootloader.high_fuses=0xDA
|
||||
sanguino.bootloader.extended_fuses=0xFD
|
||||
sanguino.bootloader.path=atmega
|
||||
sanguino.bootloader.unlock_bits=0x3F
|
||||
sanguino.bootloader.lock_bits=0x0F
|
||||
|
||||
sanguino.build.mcu=atmega1284p
|
||||
sanguino.build.f_cpu=16000000L
|
||||
sanguino.build.board=AVR_SANGUINO
|
||||
sanguino.build.core=arduino:arduino
|
||||
sanguino.build.variant=sanguino
|
||||
|
||||
sanguino.menu.cpu.atmega644=ATmega644P
|
||||
sanguino.menu.cpu.atmega644.upload.maximum_size=63488
|
||||
sanguino.menu.cpu.atmega644.bootloader.low_fuses=0xFF
|
||||
sanguino.menu.cpu.atmega644.bootloader.high_fuses=0x9A
|
||||
sanguino.menu.cpu.atmega644.bootloader.extended_fuses=0xFF
|
||||
sanguino.menu.cpu.atmega644.bootloader.file=ATmegaBOOT_168_atmega644p.hex
|
||||
sanguino.menu.cpu.atmega644.build.mcu=atmega644p
|
||||
|
||||
sanguino.menu.cpu.atmega12848m=ATmega1284p 8MHz
|
||||
sanguino.menu.cpu.atmega12848m.upload.speed=19200
|
||||
sanguino.menu.cpu.atmega12848m.bootloader.file=ATmegaBOOT_168_atmega1284p_8m.hex
|
||||
sanguino.menu.cpu.atmega12848m.build.f_cpu=8000000L
|
||||
|
||||
sanguino.menu.cpu.atmega1284=ATmega1284p 16MHz
|
||||
sanguino.menu.cpu.atmega1284.bootloader.file=ATmegaBOOT_168_atmega1284p.hex
|
||||
|
||||
sanguino.menu.cpu.atmega1284m=ATmega1284p 20MHz
|
||||
sanguino.menu.cpu.atmega1284m.bootloader.file=ATmegaBOOT_168_atmega1284p.hex
|
||||
sanguino.menu.cpu.atmega1284m.build.f_cpu=20000000L
|
@ -0,0 +1,1071 @@
|
||||
/**********************************************************/
|
||||
/* Serial Bootloader for Atmel megaAVR Controllers */
|
||||
/* */
|
||||
/* tested with ATmega8, ATmega128 and ATmega168 */
|
||||
/* should work with other mega's, see code for details */
|
||||
/* */
|
||||
/* ATmegaBOOT.c */
|
||||
/* */
|
||||
/* */
|
||||
/* 20090308: integrated Mega changes into main bootloader */
|
||||
/* source by D. Mellis */
|
||||
/* 20080930: hacked for Arduino Mega (with the 1280 */
|
||||
/* processor, backwards compatible) */
|
||||
/* by D. Cuartielles */
|
||||
/* 20070626: hacked for Arduino Diecimila (which auto- */
|
||||
/* resets when a USB connection is made to it) */
|
||||
/* by D. Mellis */
|
||||
/* 20060802: hacked for Arduino by D. Cuartielles */
|
||||
/* based on a previous hack by D. Mellis */
|
||||
/* and D. Cuartielles */
|
||||
/* */
|
||||
/* Monitor and debug functions were added to the original */
|
||||
/* code by Dr. Erik Lins, chip45.com. (See below) */
|
||||
/* */
|
||||
/* Thanks to Karl Pitrich for fixing a bootloader pin */
|
||||
/* problem and more informative LED blinking! */
|
||||
/* */
|
||||
/* For the latest version see: */
|
||||
/* http://www.chip45.com/ */
|
||||
/* */
|
||||
/* ------------------------------------------------------ */
|
||||
/* */
|
||||
/* based on stk500boot.c */
|
||||
/* Copyright (c) 2003, Jason P. Kyle */
|
||||
/* All rights reserved. */
|
||||
/* see avr1.org for original file and information */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it */
|
||||
/* and/or modify it under the terms of the GNU General */
|
||||
/* Public License as published by the Free Software */
|
||||
/* Foundation; either version 2 of the License, or */
|
||||
/* (at your option) any later version. */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will */
|
||||
/* be useful, but WITHOUT ANY WARRANTY; without even the */
|
||||
/* implied warranty of MERCHANTABILITY or FITNESS FOR A */
|
||||
/* PARTICULAR PURPOSE. See the GNU General Public */
|
||||
/* License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General */
|
||||
/* Public License along with this program; if not, write */
|
||||
/* to the Free Software Foundation, Inc., */
|
||||
/* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
/* */
|
||||
/* Licence can be viewed at */
|
||||
/* http://www.fsf.org/licenses/gpl.txt */
|
||||
/* */
|
||||
/* Target = Atmel AVR m128,m64,m32,m16,m8,m162,m163,m169, */
|
||||
/* m8515,m8535. ATmega161 has a very small boot block so */
|
||||
/* isn't supported. */
|
||||
/* */
|
||||
/* Tested with m168 */
|
||||
/**********************************************************/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
|
||||
/* some includes */
|
||||
#include <inttypes.h>
|
||||
#include <avr/io.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include <avr/wdt.h>
|
||||
#include <util/delay.h>
|
||||
|
||||
/* the current avr-libc eeprom functions do not support the ATmega168 */
|
||||
/* own eeprom write/read functions are used instead */
|
||||
#if !defined(__AVR_ATmega168__) || !defined(__AVR_ATmega328P__)
|
||||
#include <avr/eeprom.h>
|
||||
#endif
|
||||
|
||||
/* Use the F_CPU defined in Makefile */
|
||||
|
||||
/* 20060803: hacked by DojoCorp */
|
||||
/* 20070626: hacked by David A. Mellis to decrease waiting time for auto-reset */
|
||||
/* set the waiting time for the bootloader */
|
||||
/* get this from the Makefile instead */
|
||||
/* #define MAX_TIME_COUNT (F_CPU>>4) */
|
||||
|
||||
/* 20070707: hacked by David A. Mellis - after this many errors give up and launch application */
|
||||
#define MAX_ERROR_COUNT 5
|
||||
|
||||
/* set the UART baud rate */
|
||||
/* 20060803: hacked by DojoCorp */
|
||||
//#define BAUD_RATE 115200
|
||||
#ifndef BAUD_RATE
|
||||
#define BAUD_RATE 19200
|
||||
#endif
|
||||
|
||||
|
||||
/* SW_MAJOR and MINOR needs to be updated from time to time to avoid warning message from AVR Studio */
|
||||
/* never allow AVR Studio to do an update !!!! */
|
||||
#define HW_VER 0x02
|
||||
#define SW_MAJOR 0x01
|
||||
#define SW_MINOR 0x10
|
||||
|
||||
|
||||
/* Adjust to suit whatever pin your hardware uses to enter the bootloader */
|
||||
/* ATmega128 has two UARTS so two pins are used to enter bootloader and select UART */
|
||||
/* ATmega1280 has four UARTS, but for Arduino Mega, we will only use RXD0 to get code */
|
||||
/* BL0... means UART0, BL1... means UART1 */
|
||||
#ifdef __AVR_ATmega128__
|
||||
#define BL_DDR DDRF
|
||||
#define BL_PORT PORTF
|
||||
#define BL_PIN PINF
|
||||
#define BL0 PINF7
|
||||
#define BL1 PINF6
|
||||
#elif defined __AVR_ATmega1280__
|
||||
/* we just don't do anything for the MEGA and enter bootloader on reset anyway*/
|
||||
#elif defined __AVR_ATmega1284P_ || defined __AVR_ATmega644P__
|
||||
|
||||
#else
|
||||
/* other ATmegas have only one UART, so only one pin is defined to enter bootloader */
|
||||
#define BL_DDR DDRD
|
||||
#define BL_PORT PORTD
|
||||
#define BL_PIN PIND
|
||||
#define BL PIND6
|
||||
#endif
|
||||
|
||||
|
||||
/* onboard LED is used to indicate, that the bootloader was entered (3x flashing) */
|
||||
/* if monitor functions are included, LED goes on after monitor was entered */
|
||||
#if defined __AVR_ATmega128__ || defined __AVR_ATmega1280__
|
||||
/* Onboard LED is connected to pin PB7 (e.g. Crumb128, PROBOmega128, Savvy128, Arduino Mega) */
|
||||
#define LED_DDR DDRB
|
||||
#define LED_PORT PORTB
|
||||
#define LED_PIN PINB
|
||||
#define LED PINB7
|
||||
#elif defined __AVR_ATmega1284P__ || defined __AVR_ATmega644P__
|
||||
#define LED_DDR DDRB
|
||||
#define LED_PORT PORTB
|
||||
#define LED_PIN PINB
|
||||
#define LED PINB0
|
||||
#else
|
||||
/* Onboard LED is connected to pin PB5 in Arduino NG, Diecimila, and Duomilanuove */
|
||||
/* other boards like e.g. Crumb8, Crumb168 are using PB2 */
|
||||
#define LED_DDR DDRB
|
||||
#define LED_PORT PORTB
|
||||
#define LED_PIN PINB
|
||||
#define LED PINB5
|
||||
#endif
|
||||
|
||||
|
||||
/* monitor functions will only be compiled when using ATmega128, due to bootblock size constraints */
|
||||
#if defined(__AVR_ATmega128__) || defined(__AVR_ATmega1280__)
|
||||
#define MONITOR 1
|
||||
#endif
|
||||
|
||||
|
||||
/* define various device id's */
|
||||
/* manufacturer byte is always the same */
|
||||
#define SIG1 0x1E // Yep, Atmel is the only manufacturer of AVR micros. Single source :(
|
||||
|
||||
#if defined __AVR_ATmega1280__
|
||||
#define SIG2 0x97
|
||||
#define SIG3 0x03
|
||||
#define PAGE_SIZE 0x80U //128 words
|
||||
|
||||
#elif defined __AVR_ATmega1284P__
|
||||
#define SIG2 0x97
|
||||
#define SIG3 0x05
|
||||
#define PAGE_SIZE 0x080U //128 words
|
||||
|
||||
#elif defined __AVR_ATmega1281__
|
||||
#define SIG2 0x97
|
||||
#define SIG3 0x04
|
||||
#define PAGE_SIZE 0x80U //128 words
|
||||
|
||||
#elif defined __AVR_ATmega644P__
|
||||
#define SIG2 0x96
|
||||
#define SIG3 0x0A
|
||||
#define PAGE_SIZE 0x080U //128 words
|
||||
|
||||
#elif defined __AVR_ATmega128__
|
||||
#define SIG2 0x97
|
||||
#define SIG3 0x02
|
||||
#define PAGE_SIZE 0x80U //128 words
|
||||
|
||||
#elif defined __AVR_ATmega64__
|
||||
#define SIG2 0x96
|
||||
#define SIG3 0x02
|
||||
#define PAGE_SIZE 0x80U //128 words
|
||||
|
||||
#elif defined __AVR_ATmega32__
|
||||
#define SIG2 0x95
|
||||
#define SIG3 0x02
|
||||
#define PAGE_SIZE 0x40U //64 words
|
||||
|
||||
#elif defined __AVR_ATmega16__
|
||||
#define SIG2 0x94
|
||||
#define SIG3 0x03
|
||||
#define PAGE_SIZE 0x40U //64 words
|
||||
|
||||
#elif defined __AVR_ATmega8__
|
||||
#define SIG2 0x93
|
||||
#define SIG3 0x07
|
||||
#define PAGE_SIZE 0x20U //32 words
|
||||
|
||||
#elif defined __AVR_ATmega88__
|
||||
#define SIG2 0x93
|
||||
#define SIG3 0x0a
|
||||
#define PAGE_SIZE 0x20U //32 words
|
||||
|
||||
#elif defined __AVR_ATmega168__
|
||||
#define SIG2 0x94
|
||||
#define SIG3 0x06
|
||||
#define PAGE_SIZE 0x40U //64 words
|
||||
|
||||
#elif defined __AVR_ATmega328P__
|
||||
#define SIG2 0x95
|
||||
#define SIG3 0x0F
|
||||
#define PAGE_SIZE 0x40U //64 words
|
||||
|
||||
#elif defined __AVR_ATmega162__
|
||||
#define SIG2 0x94
|
||||
#define SIG3 0x04
|
||||
#define PAGE_SIZE 0x40U //64 words
|
||||
|
||||
#elif defined __AVR_ATmega163__
|
||||
#define SIG2 0x94
|
||||
#define SIG3 0x02
|
||||
#define PAGE_SIZE 0x40U //64 words
|
||||
|
||||
#elif defined __AVR_ATmega169__
|
||||
#define SIG2 0x94
|
||||
#define SIG3 0x05
|
||||
#define PAGE_SIZE 0x40U //64 words
|
||||
|
||||
#elif defined __AVR_ATmega8515__
|
||||
#define SIG2 0x93
|
||||
#define SIG3 0x06
|
||||
#define PAGE_SIZE 0x20U //32 words
|
||||
|
||||
#elif defined __AVR_ATmega8535__
|
||||
#define SIG2 0x93
|
||||
#define SIG3 0x08
|
||||
#define PAGE_SIZE 0x20U //32 words
|
||||
#endif
|
||||
|
||||
|
||||
/* function prototypes */
|
||||
void putch(char);
|
||||
char getch(void);
|
||||
void getNch(uint8_t);
|
||||
void byte_response(uint8_t);
|
||||
void nothing_response(void);
|
||||
char gethex(void);
|
||||
void puthex(char);
|
||||
void flash_led(uint8_t);
|
||||
|
||||
/* some variables */
|
||||
union address_union {
|
||||
uint16_t word;
|
||||
uint8_t byte[2];
|
||||
} address;
|
||||
|
||||
union length_union {
|
||||
uint16_t word;
|
||||
uint8_t byte[2];
|
||||
} length;
|
||||
|
||||
struct flags_struct {
|
||||
unsigned eeprom : 1;
|
||||
unsigned rampz : 1;
|
||||
} flags;
|
||||
|
||||
uint8_t buff[256];
|
||||
uint8_t address_high;
|
||||
|
||||
uint8_t pagesz=0x80;
|
||||
|
||||
uint8_t i;
|
||||
uint8_t bootuart = 0;
|
||||
|
||||
uint8_t error_count = 0;
|
||||
|
||||
void (*app_start)(void) = 0x0000;
|
||||
|
||||
|
||||
/* main program starts here */
|
||||
int main(void)
|
||||
{
|
||||
uint8_t ch,ch2;
|
||||
uint16_t w;
|
||||
|
||||
#ifdef WATCHDOG_MODS
|
||||
ch = MCUSR;
|
||||
MCUSR = 0;
|
||||
|
||||
WDTCSR |= _BV(WDCE) | _BV(WDE);
|
||||
WDTCSR = 0;
|
||||
|
||||
// Check if the WDT was used to reset, in which case we dont bootload and skip straight to the code. woot.
|
||||
if (! (ch & _BV(EXTRF))) // if it's a not an external reset...
|
||||
app_start(); // skip bootloader
|
||||
#else
|
||||
asm volatile("nop\n\t");
|
||||
#endif
|
||||
|
||||
/* set pin direction for bootloader pin and enable pullup */
|
||||
/* for ATmega128, two pins need to be initialized */
|
||||
#ifdef __AVR_ATmega128__
|
||||
BL_DDR &= ~_BV(BL0);
|
||||
BL_DDR &= ~_BV(BL1);
|
||||
BL_PORT |= _BV(BL0);
|
||||
BL_PORT |= _BV(BL1);
|
||||
#else
|
||||
/* We run the bootloader regardless of the state of this pin. Thus, don't
|
||||
put it in a different state than the other pins. --DAM, 070709
|
||||
This also applies to Arduino Mega -- DC, 080930
|
||||
BL_DDR &= ~_BV(BL);
|
||||
BL_PORT |= _BV(BL);
|
||||
*/
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __AVR_ATmega128__
|
||||
/* check which UART should be used for booting */
|
||||
if(bit_is_clear(BL_PIN, BL0)) {
|
||||
bootuart = 1;
|
||||
}
|
||||
else if(bit_is_clear(BL_PIN, BL1)) {
|
||||
bootuart = 2;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined __AVR_ATmega1280__ || defined __AVR_ATmega1284P__ || defined __AVR_ATmega644P__
|
||||
/* the mega1280 chip has four serial ports ... we could eventually use any of them, or not? */
|
||||
/* however, we don't wanna confuse people, to avoid making a mess, we will stick to RXD0, TXD0 */
|
||||
bootuart = 1;
|
||||
#endif
|
||||
|
||||
/* check if flash is programmed already, if not start bootloader anyway */
|
||||
if(pgm_read_byte_near(0x0000) != 0xFF) {
|
||||
|
||||
#ifdef __AVR_ATmega128__
|
||||
/* no UART was selected, start application */
|
||||
if(!bootuart) {
|
||||
app_start();
|
||||
}
|
||||
#else
|
||||
/* check if bootloader pin is set low */
|
||||
/* we don't start this part neither for the m8, nor m168 */
|
||||
//if(bit_is_set(BL_PIN, BL)) {
|
||||
// app_start();
|
||||
// }
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef __AVR_ATmega128__
|
||||
/* no bootuart was selected, default to uart 0 */
|
||||
if(!bootuart) {
|
||||
bootuart = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* initialize UART(s) depending on CPU defined */
|
||||
#if defined(__AVR_ATmega128__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644P__)
|
||||
if(bootuart == 1) {
|
||||
UBRR0L = (uint8_t)(F_CPU/(BAUD_RATE*16L)-1);
|
||||
UBRR0H = (F_CPU/(BAUD_RATE*16L)-1) >> 8;
|
||||
UCSR0A = 0x00;
|
||||
UCSR0C = 0x06;
|
||||
UCSR0B = _BV(TXEN0)|_BV(RXEN0);
|
||||
}
|
||||
if(bootuart == 2) {
|
||||
UBRR1L = (uint8_t)(F_CPU/(BAUD_RATE*16L)-1);
|
||||
UBRR1H = (F_CPU/(BAUD_RATE*16L)-1) >> 8;
|
||||
UCSR1A = 0x00;
|
||||
UCSR1C = 0x06;
|
||||
UCSR1B = _BV(TXEN1)|_BV(RXEN1);
|
||||
}
|
||||
#elif defined __AVR_ATmega163__
|
||||
UBRR = (uint8_t)(F_CPU/(BAUD_RATE*16L)-1);
|
||||
UBRRHI = (F_CPU/(BAUD_RATE*16L)-1) >> 8;
|
||||
UCSRA = 0x00;
|
||||
UCSRB = _BV(TXEN)|_BV(RXEN);
|
||||
#elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__)
|
||||
|
||||
#ifdef DOUBLE_SPEED
|
||||
UCSR0A = (1<<U2X0); //Double speed mode USART0
|
||||
UBRR0L = (uint8_t)(F_CPU/(BAUD_RATE*8L)-1);
|
||||
UBRR0H = (F_CPU/(BAUD_RATE*8L)-1) >> 8;
|
||||
#else
|
||||
UBRR0L = (uint8_t)(F_CPU/(BAUD_RATE*16L)-1);
|
||||
UBRR0H = (F_CPU/(BAUD_RATE*16L)-1) >> 8;
|
||||
#endif
|
||||
|
||||
UCSR0B = (1<<RXEN0) | (1<<TXEN0);
|
||||
UCSR0C = (1<<UCSZ00) | (1<<UCSZ01);
|
||||
|
||||
/* Enable internal pull-up resistor on pin D0 (RX), in order
|
||||
to supress line noise that prevents the bootloader from
|
||||
timing out (DAM: 20070509) */
|
||||
DDRD &= ~_BV(PIND0);
|
||||
PORTD |= _BV(PIND0);
|
||||
#elif defined __AVR_ATmega8__
|
||||
/* m8 */
|
||||
UBRRH = (((F_CPU/BAUD_RATE)/16)-1)>>8; // set baud rate
|
||||
UBRRL = (((F_CPU/BAUD_RATE)/16)-1);
|
||||
UCSRB = (1<<RXEN)|(1<<TXEN); // enable Rx & Tx
|
||||
UCSRC = (1<<URSEL)|(1<<UCSZ1)|(1<<UCSZ0); // config USART; 8N1
|
||||
#else
|
||||
/* m16,m32,m169,m8515,m8535 */
|
||||
UBRRL = (uint8_t)(F_CPU/(BAUD_RATE*16L)-1);
|
||||
UBRRH = (F_CPU/(BAUD_RATE*16L)-1) >> 8;
|
||||
UCSRA = 0x00;
|
||||
UCSRC = 0x06;
|
||||
UCSRB = _BV(TXEN)|_BV(RXEN);
|
||||
#endif
|
||||
|
||||
#if defined __AVR_ATmega1280__
|
||||
/* Enable internal pull-up resistor on pin D0 (RX), in order
|
||||
to supress line noise that prevents the bootloader from
|
||||
timing out (DAM: 20070509) */
|
||||
/* feature added to the Arduino Mega --DC: 080930 */
|
||||
DDRE &= ~_BV(PINE0);
|
||||
PORTE |= _BV(PINE0);
|
||||
#endif
|
||||
|
||||
|
||||
/* set LED pin as output */
|
||||
LED_DDR |= _BV(LED);
|
||||
|
||||
|
||||
/* flash onboard LED to signal entering of bootloader */
|
||||
#if defined(__AVR_ATmega128__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644P__)
|
||||
// 4x for UART0, 5x for UART1
|
||||
flash_led(NUM_LED_FLASHES + bootuart);
|
||||
#else
|
||||
flash_led(NUM_LED_FLASHES);
|
||||
#endif
|
||||
|
||||
/* 20050803: by DojoCorp, this is one of the parts provoking the
|
||||
system to stop listening, cancelled from the original */
|
||||
//putch('\0');
|
||||
|
||||
/* forever loop */
|
||||
for (;;) {
|
||||
|
||||
/* get character from UART */
|
||||
ch = getch();
|
||||
|
||||
/* A bunch of if...else if... gives smaller code than switch...case ! */
|
||||
|
||||
/* Hello is anyone home ? */
|
||||
if(ch=='0') {
|
||||
nothing_response();
|
||||
}
|
||||
|
||||
|
||||
/* Request programmer ID */
|
||||
/* Not using PROGMEM string due to boot block in m128 being beyond 64kB boundry */
|
||||
/* Would need to selectively manipulate RAMPZ, and it's only 9 characters anyway so who cares. */
|
||||
else if(ch=='1') {
|
||||
if (getch() == ' ') {
|
||||
putch(0x14);
|
||||
putch('A');
|
||||
putch('V');
|
||||
putch('R');
|
||||
putch(' ');
|
||||
putch('I');
|
||||
putch('S');
|
||||
putch('P');
|
||||
putch(0x10);
|
||||
} else {
|
||||
if (++error_count == MAX_ERROR_COUNT)
|
||||
app_start();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* AVR ISP/STK500 board commands DON'T CARE so default nothing_response */
|
||||
else if(ch=='@') {
|
||||
ch2 = getch();
|
||||
if (ch2>0x85) getch();
|
||||
nothing_response();
|
||||
}
|
||||
|
||||
|
||||
/* AVR ISP/STK500 board requests */
|
||||
else if(ch=='A') {
|
||||
ch2 = getch();
|
||||
if(ch2==0x80) byte_response(HW_VER); // Hardware version
|
||||
else if(ch2==0x81) byte_response(SW_MAJOR); // Software major version
|
||||
else if(ch2==0x82) byte_response(SW_MINOR); // Software minor version
|
||||
else if(ch2==0x98) byte_response(0x03); // Unknown but seems to be required by avr studio 3.56
|
||||
else byte_response(0x00); // Covers various unnecessary responses we don't care about
|
||||
}
|
||||
|
||||
|
||||
/* Device Parameters DON'T CARE, DEVICE IS FIXED */
|
||||
else if(ch=='B') {
|
||||
getNch(20);
|
||||
nothing_response();
|
||||
}
|
||||
|
||||
|
||||
/* Parallel programming stuff DON'T CARE */
|
||||
else if(ch=='E') {
|
||||
getNch(5);
|
||||
nothing_response();
|
||||
}
|
||||
|
||||
|
||||
/* P: Enter programming mode */
|
||||
/* R: Erase device, don't care as we will erase one page at a time anyway. */
|
||||
else if(ch=='P' || ch=='R') {
|
||||
nothing_response();
|
||||
}
|
||||
|
||||
|
||||
/* Leave programming mode */
|
||||
else if(ch=='Q') {
|
||||
nothing_response();
|
||||
#ifdef WATCHDOG_MODS
|
||||
// autoreset via watchdog (sneaky!)
|
||||
WDTCSR = _BV(WDE);
|
||||
while (1); // 16 ms
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/* Set address, little endian. EEPROM in bytes, FLASH in words */
|
||||
/* Perhaps extra address bytes may be added in future to support > 128kB FLASH. */
|
||||
/* This might explain why little endian was used here, big endian used everywhere else. */
|
||||
else if(ch=='U') {
|
||||
address.byte[0] = getch();
|
||||
address.byte[1] = getch();
|
||||
nothing_response();
|
||||
}
|
||||
|
||||
|
||||
/* Universal SPI programming command, disabled. Would be used for fuses and lock bits. */
|
||||
else if(ch=='V') {
|
||||
if (getch() == 0x30) {
|
||||
getch();
|
||||
ch = getch();
|
||||
getch();
|
||||
if (ch == 0) {
|
||||
byte_response(SIG1);
|
||||
} else if (ch == 1) {
|
||||
byte_response(SIG2);
|
||||
} else {
|
||||
byte_response(SIG3);
|
||||
}
|
||||
} else {
|
||||
getNch(3);
|
||||
byte_response(0x00);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Write memory, length is big endian and is in bytes */
|
||||
else if(ch=='d') {
|
||||
length.byte[1] = getch();
|
||||
length.byte[0] = getch();
|
||||
flags.eeprom = 0;
|
||||
if (getch() == 'E') flags.eeprom = 1;
|
||||
for (w=0;w<length.word;w++) {
|
||||
buff[w] = getch(); // Store data in buffer, can't keep up with serial data stream whilst programming pages
|
||||
}
|
||||
if (getch() == ' ') {
|
||||
if (flags.eeprom) { //Write to EEPROM one byte at a time
|
||||
address.word <<= 1;
|
||||
for(w=0;w<length.word;w++) {
|
||||
#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__)
|
||||
while(EECR & (1<<EEPE));
|
||||
EEAR = (uint16_t)(void *)address.word;
|
||||
EEDR = buff[w];
|
||||
EECR |= (1<<EEMPE);
|
||||
EECR |= (1<<EEPE);
|
||||
#else
|
||||
eeprom_write_byte((void *)address.word,buff[w]);
|
||||
#endif
|
||||
address.word++;
|
||||
}
|
||||
}
|
||||
else { //Write to FLASH one page at a time
|
||||
if (address.byte[1]>127) address_high = 0x01; //Only possible with m128, m256 will need 3rd address byte. FIXME
|
||||
else address_high = 0x00;
|
||||
#if defined(__AVR_ATmega128__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega1284P__)
|
||||
RAMPZ = address_high;
|
||||
#endif
|
||||
address.word = address.word << 1; //address * 2 -> byte location
|
||||
/* if ((length.byte[0] & 0x01) == 0x01) length.word++; //Even up an odd number of bytes */
|
||||
if ((length.byte[0] & 0x01)) length.word++; //Even up an odd number of bytes
|
||||
cli(); //Disable interrupts, just to be sure
|
||||
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644P__)
|
||||
while(bit_is_set(EECR,EEPE)); //Wait for previous EEPROM writes to complete
|
||||
#else
|
||||
while(bit_is_set(EECR,EEWE)); //Wait for previous EEPROM writes to complete
|
||||
#endif
|
||||
asm volatile(
|
||||
"clr r17 \n\t" //page_word_count
|
||||
"lds r30,address \n\t" //Address of FLASH location (in bytes)
|
||||
"lds r31,address+1 \n\t"
|
||||
"ldi r28,lo8(buff) \n\t" //Start of buffer array in RAM
|
||||
"ldi r29,hi8(buff) \n\t"
|
||||
"lds r24,length \n\t" //Length of data to be written (in bytes)
|
||||
"lds r25,length+1 \n\t"
|
||||
"length_loop: \n\t" //Main loop, repeat for number of words in block
|
||||
"cpi r17,0x00 \n\t" //If page_word_count=0 then erase page
|
||||
"brne no_page_erase \n\t"
|
||||
"wait_spm1: \n\t"
|
||||
"lds r16,%0 \n\t" //Wait for previous spm to complete
|
||||
"andi r16,1 \n\t"
|
||||
"cpi r16,1 \n\t"
|
||||
"breq wait_spm1 \n\t"
|
||||
"ldi r16,0x03 \n\t" //Erase page pointed to by Z
|
||||
"sts %0,r16 \n\t"
|
||||
"spm \n\t"
|
||||
#ifdef __AVR_ATmega163__
|
||||
".word 0xFFFF \n\t"
|
||||
"nop \n\t"
|
||||
#endif
|
||||
"wait_spm2: \n\t"
|
||||
"lds r16,%0 \n\t" //Wait for previous spm to complete
|
||||
"andi r16,1 \n\t"
|
||||
"cpi r16,1 \n\t"
|
||||
"breq wait_spm2 \n\t"
|
||||
|
||||
"ldi r16,0x11 \n\t" //Re-enable RWW section
|
||||
"sts %0,r16 \n\t"
|
||||
"spm \n\t"
|
||||
#ifdef __AVR_ATmega163__
|
||||
".word 0xFFFF \n\t"
|
||||
"nop \n\t"
|
||||
#endif
|
||||
"no_page_erase: \n\t"
|
||||
"ld r0,Y+ \n\t" //Write 2 bytes into page buffer
|
||||
"ld r1,Y+ \n\t"
|
||||
|
||||
"wait_spm3: \n\t"
|
||||
"lds r16,%0 \n\t" //Wait for previous spm to complete
|
||||
"andi r16,1 \n\t"
|
||||
"cpi r16,1 \n\t"
|
||||
"breq wait_spm3 \n\t"
|
||||
"ldi r16,0x01 \n\t" //Load r0,r1 into FLASH page buffer
|
||||
"sts %0,r16 \n\t"
|
||||
"spm \n\t"
|
||||
|
||||
"inc r17 \n\t" //page_word_count++
|
||||
"cpi r17,%1 \n\t"
|
||||
"brlo same_page \n\t" //Still same page in FLASH
|
||||
"write_page: \n\t"
|
||||
"clr r17 \n\t" //New page, write current one first
|
||||
"wait_spm4: \n\t"
|
||||
"lds r16,%0 \n\t" //Wait for previous spm to complete
|
||||
"andi r16,1 \n\t"
|
||||
"cpi r16,1 \n\t"
|
||||
"breq wait_spm4 \n\t"
|
||||
#ifdef __AVR_ATmega163__
|
||||
"andi r30,0x80 \n\t" // m163 requires Z6:Z1 to be zero during page write
|
||||
#endif
|
||||
"ldi r16,0x05 \n\t" //Write page pointed to by Z
|
||||
"sts %0,r16 \n\t"
|
||||
"spm \n\t"
|
||||
#ifdef __AVR_ATmega163__
|
||||
".word 0xFFFF \n\t"
|
||||
"nop \n\t"
|
||||
"ori r30,0x7E \n\t" // recover Z6:Z1 state after page write (had to be zero during write)
|
||||
#endif
|
||||
"wait_spm5: \n\t"
|
||||
"lds r16,%0 \n\t" //Wait for previous spm to complete
|
||||
"andi r16,1 \n\t"
|
||||
"cpi r16,1 \n\t"
|
||||
"breq wait_spm5 \n\t"
|
||||
"ldi r16,0x11 \n\t" //Re-enable RWW section
|
||||
"sts %0,r16 \n\t"
|
||||
"spm \n\t"
|
||||
#ifdef __AVR_ATmega163__
|
||||
".word 0xFFFF \n\t"
|
||||
"nop \n\t"
|
||||
#endif
|
||||
"same_page: \n\t"
|
||||
"adiw r30,2 \n\t" //Next word in FLASH
|
||||
"sbiw r24,2 \n\t" //length-2
|
||||
"breq final_write \n\t" //Finished
|
||||
"rjmp length_loop \n\t"
|
||||
"final_write: \n\t"
|
||||
"cpi r17,0 \n\t"
|
||||
"breq block_done \n\t"
|
||||
"adiw r24,2 \n\t" //length+2, fool above check on length after short page write
|
||||
"rjmp write_page \n\t"
|
||||
"block_done: \n\t"
|
||||
"clr __zero_reg__ \n\t" //restore zero register
|
||||
#if defined __AVR_ATmega168__ || __AVR_ATmega328P__ || __AVR_ATmega128__ || __AVR_ATmega1280__ || __AVR_ATmega1281__ || __AVR_ATmega1284P__ || __AVR_ATmega644P__
|
||||
: "=m" (SPMCSR) : "M" (PAGE_SIZE) : "r0","r16","r17","r24","r25","r28","r29","r30","r31"
|
||||
#else
|
||||
: "=m" (SPMCR) : "M" (PAGE_SIZE) : "r0","r16","r17","r24","r25","r28","r29","r30","r31"
|
||||
#endif
|
||||
);
|
||||
/* Should really add a wait for RWW section to be enabled, don't actually need it since we never */
|
||||
/* exit the bootloader without a power cycle anyhow */
|
||||
}
|
||||
putch(0x14);
|
||||
putch(0x10);
|
||||
} else {
|
||||
if (++error_count == MAX_ERROR_COUNT)
|
||||
app_start();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Read memory block mode, length is big endian. */
|
||||
else if(ch=='t') {
|
||||
length.byte[1] = getch();
|
||||
length.byte[0] = getch();
|
||||
#if defined(__AVR_ATmega128__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644P__)
|
||||
if (address.word>0x7FFF) flags.rampz = 1; // No go with m256, FIXME
|
||||
else flags.rampz = 0;
|
||||
#endif
|
||||
address.word = address.word << 1; // address * 2 -> byte location
|
||||
if (getch() == 'E') flags.eeprom = 1;
|
||||
else flags.eeprom = 0;
|
||||
if (getch() == ' ') { // Command terminator
|
||||
putch(0x14);
|
||||
for (w=0;w < length.word;w++) { // Can handle odd and even lengths okay
|
||||
if (flags.eeprom) { // Byte access EEPROM read
|
||||
#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__)
|
||||
while(EECR & (1<<EEPE));
|
||||
EEAR = (uint16_t)(void *)address.word;
|
||||
EECR |= (1<<EERE);
|
||||
putch(EEDR);
|
||||
#else
|
||||
putch(eeprom_read_byte((void *)address.word));
|
||||
#endif
|
||||
address.word++;
|
||||
}
|
||||
else {
|
||||
|
||||
if (!flags.rampz) putch(pgm_read_byte_near(address.word));
|
||||
#if defined(__AVR_ATmega128__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1284P__)
|
||||
else putch(pgm_read_byte_far(address.word + 0x10000));
|
||||
// Hmmmm, yuck FIXME when m256 arrvies
|
||||
#endif
|
||||
address.word++;
|
||||
}
|
||||
}
|
||||
putch(0x10);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Get device signature bytes */
|
||||
else if(ch=='u') {
|
||||
if (getch() == ' ') {
|
||||
putch(0x14);
|
||||
putch(SIG1);
|
||||
putch(SIG2);
|
||||
putch(SIG3);
|
||||
putch(0x10);
|
||||
} else {
|
||||
if (++error_count == MAX_ERROR_COUNT)
|
||||
app_start();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Read oscillator calibration byte */
|
||||
else if(ch=='v') {
|
||||
byte_response(0x00);
|
||||
}
|
||||
|
||||
|
||||
#if defined MONITOR
|
||||
|
||||
/* here come the extended monitor commands by Erik Lins */
|
||||
|
||||
/* check for three times exclamation mark pressed */
|
||||
else if(ch=='!') {
|
||||
ch = getch();
|
||||
if(ch=='!') {
|
||||
ch = getch();
|
||||
if(ch=='!') {
|
||||
PGM_P welcome = "";
|
||||
#if defined(__AVR_ATmega128__) || defined(__AVR_ATmega1280__)
|
||||
uint16_t extaddr;
|
||||
#endif
|
||||
uint8_t addrl, addrh;
|
||||
|
||||
#ifdef CRUMB128
|
||||
welcome = "ATmegaBOOT / Crumb128 - (C) J.P.Kyle, E.Lins - 050815\n\r";
|
||||
#elif defined PROBOMEGA128
|
||||
welcome = "ATmegaBOOT / PROBOmega128 - (C) J.P.Kyle, E.Lins - 050815\n\r";
|
||||
#elif defined SAVVY128
|
||||
welcome = "ATmegaBOOT / Savvy128 - (C) J.P.Kyle, E.Lins - 050815\n\r";
|
||||
#elif defined __AVR_ATmega1280__
|
||||
welcome = "ATmegaBOOT / Arduino Mega - (C) Arduino LLC - 090930\n\r";
|
||||
#endif
|
||||
|
||||
/* turn on LED */
|
||||
LED_DDR |= _BV(LED);
|
||||
LED_PORT &= ~_BV(LED);
|
||||
|
||||
/* print a welcome message and command overview */
|
||||
for(i=0; welcome[i] != '\0'; ++i) {
|
||||
putch(welcome[i]);
|
||||
}
|
||||
|
||||
/* test for valid commands */
|
||||
for(;;) {
|
||||
putch('\n');
|
||||
putch('\r');
|
||||
putch(':');
|
||||
putch(' ');
|
||||
|
||||
ch = getch();
|
||||
putch(ch);
|
||||
|
||||
/* toggle LED */
|
||||
if(ch == 't') {
|
||||
if(bit_is_set(LED_PIN,LED)) {
|
||||
LED_PORT &= ~_BV(LED);
|
||||
putch('1');
|
||||
} else {
|
||||
LED_PORT |= _BV(LED);
|
||||
putch('0');
|
||||
}
|
||||
}
|
||||
|
||||
/* read byte from address */
|
||||
else if(ch == 'r') {
|
||||
ch = getch(); putch(ch);
|
||||
addrh = gethex();
|
||||
addrl = gethex();
|
||||
putch('=');
|
||||
ch = *(uint8_t *)((addrh << 8) + addrl);
|
||||
puthex(ch);
|
||||
}
|
||||
|
||||
/* write a byte to address */
|
||||
else if(ch == 'w') {
|
||||
ch = getch(); putch(ch);
|
||||
addrh = gethex();
|
||||
addrl = gethex();
|
||||
ch = getch(); putch(ch);
|
||||
ch = gethex();
|
||||
*(uint8_t *)((addrh << 8) + addrl) = ch;
|
||||
}
|
||||
|
||||
/* read from uart and echo back */
|
||||
else if(ch == 'u') {
|
||||
for(;;) {
|
||||
putch(getch());
|
||||
}
|
||||
}
|
||||
#if defined(__AVR_ATmega128__) || defined(__AVR_ATmega1280__)
|
||||
/* external bus loop */
|
||||
else if(ch == 'b') {
|
||||
putch('b');
|
||||
putch('u');
|
||||
putch('s');
|
||||
MCUCR = 0x80;
|
||||
XMCRA = 0;
|
||||
XMCRB = 0;
|
||||
extaddr = 0x1100;
|
||||
for(;;) {
|
||||
ch = *(volatile uint8_t *)extaddr;
|
||||
if(++extaddr == 0) {
|
||||
extaddr = 0x1100;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
else if(ch == 'j') {
|
||||
app_start();
|
||||
}
|
||||
|
||||
} /* end of monitor functions */
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
/* end of monitor */
|
||||
#endif
|
||||
else if (++error_count == MAX_ERROR_COUNT) {
|
||||
app_start();
|
||||
}
|
||||
} /* end of forever loop */
|
||||
|
||||
}
|
||||
|
||||
|
||||
char gethexnib(void) {
|
||||
char a;
|
||||
a = getch(); putch(a);
|
||||
if(a >= 'a') {
|
||||
return (a - 'a' + 0x0a);
|
||||
} else if(a >= '0') {
|
||||
return(a - '0');
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
|
||||
char gethex(void) {
|
||||
return (gethexnib() << 4) + gethexnib();
|
||||
}
|
||||
|
||||
|
||||
void puthex(char ch) {
|
||||
char ah;
|
||||
|
||||
ah = ch >> 4;
|
||||
if(ah >= 0x0a) {
|
||||
ah = ah - 0x0a + 'a';
|
||||
} else {
|
||||
ah += '0';
|
||||
}
|
||||
|
||||
ch &= 0x0f;
|
||||
if(ch >= 0x0a) {
|
||||
ch = ch - 0x0a + 'a';
|
||||
} else {
|
||||
ch += '0';
|
||||
}
|
||||
|
||||
putch(ah);
|
||||
putch(ch);
|
||||
}
|
||||
|
||||
|
||||
void putch(char ch)
|
||||
{
|
||||
#if defined(__AVR_ATmega128__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644P__)
|
||||
if(bootuart == 1) {
|
||||
while (!(UCSR0A & _BV(UDRE0)));
|
||||
UDR0 = ch;
|
||||
}
|
||||
else if (bootuart == 2) {
|
||||
while (!(UCSR1A & _BV(UDRE1)));
|
||||
UDR1 = ch;
|
||||
}
|
||||
#elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__)
|
||||
while (!(UCSR0A & _BV(UDRE0)));
|
||||
UDR0 = ch;
|
||||
#else
|
||||
/* m8,16,32,169,8515,8535,163 */
|
||||
while (!(UCSRA & _BV(UDRE)));
|
||||
UDR = ch;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
char getch(void)
|
||||
{
|
||||
#if defined(__AVR_ATmega128__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644P__)
|
||||
uint32_t count = 0;
|
||||
if(bootuart == 1) {
|
||||
while(!(UCSR0A & _BV(RXC0))) {
|
||||
/* 20060803 DojoCorp:: Addon coming from the previous Bootloader*/
|
||||
/* HACKME:: here is a good place to count times*/
|
||||
count++;
|
||||
if (count > MAX_TIME_COUNT)
|
||||
app_start();
|
||||
}
|
||||
|
||||
return UDR0;
|
||||
}
|
||||
else if(bootuart == 2) {
|
||||
while(!(UCSR1A & _BV(RXC1))) {
|
||||
/* 20060803 DojoCorp:: Addon coming from the previous Bootloader*/
|
||||
/* HACKME:: here is a good place to count times*/
|
||||
count++;
|
||||
if (count > MAX_TIME_COUNT)
|
||||
app_start();
|
||||
}
|
||||
|
||||
return UDR1;
|
||||
}
|
||||
return 0;
|
||||
#elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__)
|
||||
uint32_t count = 0;
|
||||
while(!(UCSR0A & _BV(RXC0))){
|
||||
/* 20060803 DojoCorp:: Addon coming from the previous Bootloader*/
|
||||
/* HACKME:: here is a good place to count times*/
|
||||
count++;
|
||||
if (count > MAX_TIME_COUNT)
|
||||
app_start();
|
||||
}
|
||||
return UDR0;
|
||||
#else
|
||||
/* m8,16,32,169,8515,8535,163 */
|
||||
uint32_t count = 0;
|
||||
while(!(UCSRA & _BV(RXC))){
|
||||
/* 20060803 DojoCorp:: Addon coming from the previous Bootloader*/
|
||||
/* HACKME:: here is a good place to count times*/
|
||||
count++;
|
||||
if (count > MAX_TIME_COUNT)
|
||||
app_start();
|
||||
}
|
||||
return UDR;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void getNch(uint8_t count)
|
||||
{
|
||||
while(count--) {
|
||||
#if defined(__AVR_ATmega128__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644P__)
|
||||
if(bootuart == 1) {
|
||||
while(!(UCSR0A & _BV(RXC0)));
|
||||
UDR0;
|
||||
}
|
||||
else if(bootuart == 2) {
|
||||
while(!(UCSR1A & _BV(RXC1)));
|
||||
UDR1;
|
||||
}
|
||||
#elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__)
|
||||
getch();
|
||||
#else
|
||||
/* m8,16,32,169,8515,8535,163 */
|
||||
/* 20060803 DojoCorp:: Addon coming from the previous Bootloader*/
|
||||
//while(!(UCSRA & _BV(RXC)));
|
||||
//UDR;
|
||||
getch(); // need to handle time out
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void byte_response(uint8_t val)
|
||||
{
|
||||
if (getch() == ' ') {
|
||||
putch(0x14);
|
||||
putch(val);
|
||||
putch(0x10);
|
||||
} else {
|
||||
if (++error_count == MAX_ERROR_COUNT)
|
||||
app_start();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void nothing_response(void)
|
||||
{
|
||||
if (getch() == ' ') {
|
||||
putch(0x14);
|
||||
putch(0x10);
|
||||
} else {
|
||||
if (++error_count == MAX_ERROR_COUNT)
|
||||
app_start();
|
||||
}
|
||||
}
|
||||
|
||||
void flash_led(uint8_t count)
|
||||
{
|
||||
while (count--) {
|
||||
LED_PORT |= _BV(LED);
|
||||
_delay_ms(100);
|
||||
LED_PORT &= ~_BV(LED);
|
||||
_delay_ms(100);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* end of file ATmegaBOOT.c */
|
@ -0,0 +1,130 @@
|
||||
:020000021000EC
|
||||
:10F000000C9446F80C9465F80C9465F80C9465F82B
|
||||
:10F010000C9465F80C9465F80C9465F80C9465F8FC
|
||||
:10F020000C9465F80C9465F80C9465F80C9465F8EC
|
||||
:10F030000C9465F80C9465F80C9465F80C9465F8DC
|
||||
:10F040000C9465F80C9465F80C9465F80C9465F8CC
|
||||
:10F050000C9465F80C9465F80C9465F80C9465F8BC
|
||||
:10F060000C9465F80C9465F80C9465F80C9465F8AC
|
||||
:10F070000C9465F80C9465F80C9465F80C9465F89C
|
||||
:10F080000C9465F80C9465F80C9465F811241FBE77
|
||||
:10F09000CFEFD0E4DEBFCDBF11E0A0E0B1E0E8EDFE
|
||||
:10F0A000F7EF01E00BBF02C007900D92A230B1074D
|
||||
:10F0B000D9F712E0A2E0B1E001C01D92AD30B10776
|
||||
:10F0C000E1F70E947EF90C94EAFB0C9400F8909111
|
||||
:10F0D0000201913019F0923041F008959091C000F2
|
||||
:10F0E00095FFFCCF8093C60008959091C80095FFCE
|
||||
:10F0F000FCCF8093CE0008951F93982F95959595FA
|
||||
:10F1000095959595905D182F1F701A304CF4105DF1
|
||||
:10F11000892F0E9467F8812F0E9467F81F91089538
|
||||
:10F12000195A892F0E9467F8812F0E9467F81F9152
|
||||
:10F130000895EF92FF920F931F9380910201813007
|
||||
:10F1400069F1823031F080E01F910F91FF90EF90D4
|
||||
:10F150000895EE24FF2487018091C80087FD17C021
|
||||
:10F160000894E11CF11C011D111D81E4E81682E4E4
|
||||
:10F17000F8068FE0080780E0180770F3E0910401BB
|
||||
:10F18000F091050109958091C80087FFE9CF809132
|
||||
:10F19000CE001F910F91FF90EF900895EE24FF2471
|
||||
:10F1A00087018091C00087FD17C00894E11CF11C05
|
||||
:10F1B000011D111D81E4E81682E4F8068FE00807BE
|
||||
:10F1C00080E0180770F3E0910401F09105010995C2
|
||||
:10F1D0008091C00087FFE9CF8091C6001F910F91F9
|
||||
:10F1E000FF90EF9008951F930E9499F8182F0E94A6
|
||||
:10F1F00067F8113634F410330CF01053812F1F913F
|
||||
:10F2000008951755812F1F9108951F930E94F3F8B9
|
||||
:10F21000182F0E94F3F81295107F810F1F91089507
|
||||
:10F2200020910201882339F0213031F0223061F041
|
||||
:10F2300081508823C9F708959091C00097FFFCCFB3
|
||||
:10F240009091C6008150F5CF9091C80097FFFCCFF8
|
||||
:10F250009091CE008150EDCF1F93182F0E9499F806
|
||||
:10F26000803281F0809103018F5F809303018530AC
|
||||
:10F2700011F01F910895E0910401F09105010995A5
|
||||
:10F280001F91089584E10E9467F8812F0E9467F81A
|
||||
:10F2900080E10E9467F8EDCF0E9499F8803271F00A
|
||||
:10F2A000809103018F5F80930301853009F00895F9
|
||||
:10F2B000E0910401F09105010995089584E10E940F
|
||||
:10F2C00067F880E10E9467F8089515C0289A2FEF2B
|
||||
:10F2D00031EE44E0215030404040E1F700C00000F2
|
||||
:10F2E00028982FEF31EE44E0215030404040E1F7C4
|
||||
:10F2F00000C000008150882349F70895EF92FF92E3
|
||||
:10F300000F931F93CF93DF93000081E0809302015E
|
||||
:10F3100080E18093C4001092C5001092C00086E086
|
||||
:10F320008093C20088E18093C100209A81E00E940E
|
||||
:10F3300065F90E9499F88033B1F18133B9F18034D5
|
||||
:10F3400009F454C0813409F45AC0823409F469C004
|
||||
:10F35000853409F46CC0803531F1823521F1813575
|
||||
:10F3600011F1853509F469C0863509F471C0843618
|
||||
:10F3700009F47AC0843709F4E1C0853709F43FC144
|
||||
:10F38000863709F44AC0809103018F5F809303019F
|
||||
:10F39000853079F6E0910401F091050109950E940C
|
||||
:10F3A00099F8803351F60E944CF9C3CF0E9499F826
|
||||
:10F3B000803249F784E10E9467F881E40E9467F88F
|
||||
:10F3C00086E50E9467F882E50E9467F880E20E9465
|
||||
:10F3D00067F889E40E9467F883E50E9467F880E592
|
||||
:10F3E0000E9467F880E10E9467F8A3CF0E9499F815
|
||||
:10F3F0008638C8F20E9499F80E944CF99ACF0E9470
|
||||
:10F4000099F8803809F414C1813809F415C182389B
|
||||
:10F4100009F416C1883909F407C180E00E942CF96B
|
||||
:10F4200088CF84E10E9410F90E944CF982CF85E0D8
|
||||
:10F430000E9410F90E944CF97CCF0E9499F88093A9
|
||||
:10F4400006010E9499F8809307010E944CF971CF40
|
||||
:10F450000E9499F8803309F405C183E00E9410F9F5
|
||||
:10F4600080E00E942CF965CF0E9499F880930902F0
|
||||
:10F470000E9499F88093080280910C028E7F8093FD
|
||||
:10F480000C020E9499F8853409F4FDC080910802AD
|
||||
:10F49000909109020097A1F068E0E62E61E0F62E57
|
||||
:10F4A00000E010E00E9499F8F70181937F010F5F5F
|
||||
:10F4B0001F4F80910802909109020817190790F3D5
|
||||
:10F4C0000E9499F8803209F05ECF80910C0280FF93
|
||||
:10F4D000ECC08091060190910701880F991F9093CD
|
||||
:10F4E000070180930601209108023091090221153D
|
||||
:10F4F0003105E9F048E0E42E41E0F42E00E010E0B0
|
||||
:10F50000F70161917F010E94DCFB809106019091DF
|
||||
:10F510000701019690930701809306010F5F1F4F2B
|
||||
:10F5200020910802309109020217130748F384E181
|
||||
:10F530000E9467F880E10E9467F8FBCE0E9499F86C
|
||||
:10F54000809309020E9499F8809308028091060135
|
||||
:10F550009091070197FDA3C020910C022D7F20936D
|
||||
:10F560000C02880F991F90930701809306010E9457
|
||||
:10F5700099F8853409F48DC080910C028E7F8093B8
|
||||
:10F580000C020E9499F8803209F0D3CE84E10E94E7
|
||||
:10F5900067F88091080290910902009709F440C031
|
||||
:10F5A00000E010E0809106019091070116C0FC0177
|
||||
:10F5B00084910E9467F8809106019091070101965D
|
||||
:10F5C00090930701809306010F5F1F4F209108025F
|
||||
:10F5D000309109020217130718F520910C0220FD43
|
||||
:10F5E00033C021FFE4CFA0E0B0E080509040AF4FA7
|
||||
:10F5F000BF4FABBFFC0187910E9467F8DCCF0E9430
|
||||
:10F6000099F8803209F0BFCE84E10E9467F88EE15C
|
||||
:10F610000E9467F887E90E9467F885E00E9467F812
|
||||
:10F6200080E10E9467F885CE83E00E942CF981CEAC
|
||||
:10F6300082E00E942CF97DCE81E00E942CF979CEE7
|
||||
:10F6400080E10E942CF975CE0E94D4FB0E9467F8DD
|
||||
:10F650008091060190910701019690930701809394
|
||||
:10F660000601B2CF0E9499F80E9499F8082F0E94D3
|
||||
:10F6700099F8002309F48BC0013009F48CC085E0AF
|
||||
:10F680000E942CF956CE80910C02816080930C026E
|
||||
:10F69000FDCE80910C02816080930C0272CF20918C
|
||||
:10F6A0000C02226020930C025CCF8091070187FD41
|
||||
:10F6B00076C010920B0280E08BBF80910601909182
|
||||
:10F6C0000701880F991F909307018093060180918D
|
||||
:10F6D000080280FF09C080910802909109020196FA
|
||||
:10F6E0009093090280930802F894F999FECF1127AC
|
||||
:10F6F000E0910601F0910701C8E0D1E08091080295
|
||||
:10F7000090910902103091F400915700017001307E
|
||||
:10F71000D9F303E000935700E8950091570001707A
|
||||
:10F720000130D9F301E100935700E8950990199051
|
||||
:10F730000091570001700130D9F301E000935700A8
|
||||
:10F74000E8951395103898F0112700915700017033
|
||||
:10F750000130D9F305E000935700E8950091570078
|
||||
:10F7600001700130D9F301E100935700E89532961A
|
||||
:10F77000029709F0C7CF103011F00296E5CF11249F
|
||||
:10F7800084E10E9467F880E10E9467F8D2CD8EE1A3
|
||||
:10F790000E942CF9CECD87E90E942CF9CACDF1E068
|
||||
:10F7A000F0930B0281E088CFF999FECF92BD81BD25
|
||||
:10F7B000F89A992780B50895262FF999FECF1FBA98
|
||||
:10F7C00092BD81BD20BD0FB6F894FA9AF99A0FBE8A
|
||||
:08F7D00001960895F894FFCFA3
|
||||
:02F7D8008000AF
|
||||
:040000031000F000F9
|
||||
:00000001FF
|
@ -0,0 +1,130 @@
|
||||
:020000021000EC
|
||||
:10F000000C9446F80C9465F80C9465F80C9465F82B
|
||||
:10F010000C9465F80C9465F80C9465F80C9465F8FC
|
||||
:10F020000C9465F80C9465F80C9465F80C9465F8EC
|
||||
:10F030000C9465F80C9465F80C9465F80C9465F8DC
|
||||
:10F040000C9465F80C9465F80C9465F80C9465F8CC
|
||||
:10F050000C9465F80C9465F80C9465F80C9465F8BC
|
||||
:10F060000C9465F80C9465F80C9465F80C9465F8AC
|
||||
:10F070000C9465F80C9465F80C9465F80C9465F89C
|
||||
:10F080000C9465F80C9465F80C9465F811241FBE77
|
||||
:10F09000CFEFD0E4DEBFCDBF11E0A0E0B1E0E8EDFE
|
||||
:10F0A000F7EF01E00BBF02C007900D92A230B1074D
|
||||
:10F0B000D9F712E0A2E0B1E001C01D92AD30B10776
|
||||
:10F0C000E1F70E947EF90C94EAFB0C9400F8909111
|
||||
:10F0D0000201913019F0923041F008959091C000F2
|
||||
:10F0E00095FFFCCF8093C60008959091C80095FFCE
|
||||
:10F0F000FCCF8093CE0008951F93982F95959595FA
|
||||
:10F1000095959595905D182F1F701A304CF4105DF1
|
||||
:10F11000892F0E9467F8812F0E9467F81F91089538
|
||||
:10F12000195A892F0E9467F8812F0E9467F81F9152
|
||||
:10F130000895EF92FF920F931F9380910201813007
|
||||
:10F1400069F1823031F080E01F910F91FF90EF90D4
|
||||
:10F150000895EE24FF2487018091C80087FD17C021
|
||||
:10F160000894E11CF11C011D111D81E2E81681EAE1
|
||||
:10F17000F80687E0080780E0180770F3E0910401C3
|
||||
:10F18000F091050109958091C80087FFE9CF809132
|
||||
:10F19000CE001F910F91FF90EF900895EE24FF2471
|
||||
:10F1A00087018091C00087FD17C00894E11CF11C05
|
||||
:10F1B000011D111D81E2E81681EAF80687E00807C3
|
||||
:10F1C00080E0180770F3E0910401F09105010995C2
|
||||
:10F1D0008091C00087FFE9CF8091C6001F910F91F9
|
||||
:10F1E000FF90EF9008951F930E9499F8182F0E94A6
|
||||
:10F1F00067F8113634F410330CF01053812F1F913F
|
||||
:10F2000008951755812F1F9108951F930E94F3F8B9
|
||||
:10F21000182F0E94F3F81295107F810F1F91089507
|
||||
:10F2200020910201882339F0213031F0223061F041
|
||||
:10F2300081508823C9F708959091C00097FFFCCFB3
|
||||
:10F240009091C6008150F5CF9091C80097FFFCCFF8
|
||||
:10F250009091CE008150EDCF1F93182F0E9499F806
|
||||
:10F26000803281F0809103018F5F809303018530AC
|
||||
:10F2700011F01F910895E0910401F09105010995A5
|
||||
:10F280001F91089584E10E9467F8812F0E9467F81A
|
||||
:10F2900080E10E9467F8EDCF0E9499F8803271F00A
|
||||
:10F2A000809103018F5F80930301853009F00895F9
|
||||
:10F2B000E0910401F09105010995089584E10E940F
|
||||
:10F2C00067F880E10E9467F8089515C0289A2FEF2B
|
||||
:10F2D00030E742E0215030404040E1F700C00000FC
|
||||
:10F2E00028982FEF30E742E0215030404040E1F7CE
|
||||
:10F2F00000C000008150882349F70895EF92FF92E3
|
||||
:10F300000F931F93CF93DF93000081E0809302015E
|
||||
:10F3100089E18093C4001092C5001092C00086E07D
|
||||
:10F320008093C20088E18093C100209A81E00E940E
|
||||
:10F3300065F90E9499F88033B1F18133B9F18034D5
|
||||
:10F3400009F454C0813409F45AC0823409F469C004
|
||||
:10F35000853409F46CC0803531F1823521F1813575
|
||||
:10F3600011F1853509F469C0863509F471C0843618
|
||||
:10F3700009F47AC0843709F4E1C0853709F43FC144
|
||||
:10F38000863709F44AC0809103018F5F809303019F
|
||||
:10F39000853079F6E0910401F091050109950E940C
|
||||
:10F3A00099F8803351F60E944CF9C3CF0E9499F826
|
||||
:10F3B000803249F784E10E9467F881E40E9467F88F
|
||||
:10F3C00086E50E9467F882E50E9467F880E20E9465
|
||||
:10F3D00067F889E40E9467F883E50E9467F880E592
|
||||
:10F3E0000E9467F880E10E9467F8A3CF0E9499F815
|
||||
:10F3F0008638C8F20E9499F80E944CF99ACF0E9470
|
||||
:10F4000099F8803809F414C1813809F415C182389B
|
||||
:10F4100009F416C1883909F407C180E00E942CF96B
|
||||
:10F4200088CF84E10E9410F90E944CF982CF85E0D8
|
||||
:10F430000E9410F90E944CF97CCF0E9499F88093A9
|
||||
:10F4400006010E9499F8809307010E944CF971CF40
|
||||
:10F450000E9499F8803309F405C183E00E9410F9F5
|
||||
:10F4600080E00E942CF965CF0E9499F880930902F0
|
||||
:10F470000E9499F88093080280910C028E7F8093FD
|
||||
:10F480000C020E9499F8853409F4FDC080910802AD
|
||||
:10F49000909109020097A1F068E0E62E61E0F62E57
|
||||
:10F4A00000E010E00E9499F8F70181937F010F5F5F
|
||||
:10F4B0001F4F80910802909109020817190790F3D5
|
||||
:10F4C0000E9499F8803209F05ECF80910C0280FF93
|
||||
:10F4D000ECC08091060190910701880F991F9093CD
|
||||
:10F4E000070180930601209108023091090221153D
|
||||
:10F4F0003105E9F048E0E42E41E0F42E00E010E0B0
|
||||
:10F50000F70161917F010E94DCFB809106019091DF
|
||||
:10F510000701019690930701809306010F5F1F4F2B
|
||||
:10F5200020910802309109020217130748F384E181
|
||||
:10F530000E9467F880E10E9467F8FBCE0E9499F86C
|
||||
:10F54000809309020E9499F8809308028091060135
|
||||
:10F550009091070197FDA3C020910C022D7F20936D
|
||||
:10F560000C02880F991F90930701809306010E9457
|
||||
:10F5700099F8853409F48DC080910C028E7F8093B8
|
||||
:10F580000C020E9499F8803209F0D3CE84E10E94E7
|
||||
:10F5900067F88091080290910902009709F440C031
|
||||
:10F5A00000E010E0809106019091070116C0FC0177
|
||||
:10F5B00084910E9467F8809106019091070101965D
|
||||
:10F5C00090930701809306010F5F1F4F209108025F
|
||||
:10F5D000309109020217130718F520910C0220FD43
|
||||
:10F5E00033C021FFE4CFA0E0B0E080509040AF4FA7
|
||||
:10F5F000BF4FABBFFC0187910E9467F8DCCF0E9430
|
||||
:10F6000099F8803209F0BFCE84E10E9467F88EE15C
|
||||
:10F610000E9467F887E90E9467F885E00E9467F812
|
||||
:10F6200080E10E9467F885CE83E00E942CF981CEAC
|
||||
:10F6300082E00E942CF97DCE81E00E942CF979CEE7
|
||||
:10F6400080E10E942CF975CE0E94D4FB0E9467F8DD
|
||||
:10F650008091060190910701019690930701809394
|
||||
:10F660000601B2CF0E9499F80E9499F8082F0E94D3
|
||||
:10F6700099F8002309F48BC0013009F48CC085E0AF
|
||||
:10F680000E942CF956CE80910C02816080930C026E
|
||||
:10F69000FDCE80910C02816080930C0272CF20918C
|
||||
:10F6A0000C02226020930C025CCF8091070187FD41
|
||||
:10F6B00076C010920B0280E08BBF80910601909182
|
||||
:10F6C0000701880F991F909307018093060180918D
|
||||
:10F6D000080280FF09C080910802909109020196FA
|
||||
:10F6E0009093090280930802F894F999FECF1127AC
|
||||
:10F6F000E0910601F0910701C8E0D1E08091080295
|
||||
:10F7000090910902103091F400915700017001307E
|
||||
:10F71000D9F303E000935700E8950091570001707A
|
||||
:10F720000130D9F301E100935700E8950990199051
|
||||
:10F730000091570001700130D9F301E000935700A8
|
||||
:10F74000E8951395103898F0112700915700017033
|
||||
:10F750000130D9F305E000935700E8950091570078
|
||||
:10F7600001700130D9F301E100935700E89532961A
|
||||
:10F77000029709F0C7CF103011F00296E5CF11249F
|
||||
:10F7800084E10E9467F880E10E9467F8D2CD8EE1A3
|
||||
:10F790000E942CF9CECD87E90E942CF9CACDF1E068
|
||||
:10F7A000F0930B0281E088CFF999FECF92BD81BD25
|
||||
:10F7B000F89A992780B50895262FF999FECF1FBA98
|
||||
:10F7C00092BD81BD20BD0FB6F894FA9AF99A0FBE8A
|
||||
:08F7D00001960895F894FFCFA3
|
||||
:02F7D8008000AF
|
||||
:040000031000F000F9
|
||||
:00000001FF
|
@ -0,0 +1,126 @@
|
||||
:10F800000C943E7C0C945B7C0C945B7C0C945B7C39
|
||||
:10F810000C945B7C0C945B7C0C945B7C0C945B7C0C
|
||||
:10F820000C945B7C0C945B7C0C945B7C0C945B7CFC
|
||||
:10F830000C945B7C0C945B7C0C945B7C0C945B7CEC
|
||||
:10F840000C945B7C0C945B7C0C945B7C0C945B7CDC
|
||||
:10F850000C945B7C0C945B7C0C945B7C0C945B7CCC
|
||||
:10F860000C945B7C0C945B7C0C945B7C0C945B7CBC
|
||||
:10F870000C945B7C0C945B7C0C945B7C11241FBE11
|
||||
:10F88000CFEFD0E1DEBFCDBF11E0A0E0B1E0EAEA0A
|
||||
:10F89000FFEF02C005900D92A230B107D9F712E038
|
||||
:10F8A000A2E0B1E001C01D92AD30B107E1F70E94C6
|
||||
:10F8B000747D0C94D37F0C94007C90910201913064
|
||||
:10F8C00019F0923041F008959091C00095FFFCCF5F
|
||||
:10F8D0008093C60008959091C80095FFFCCF809357
|
||||
:10F8E000CE0008951F93982F95959595959595958C
|
||||
:10F8F000905D182F1F701A304CF4105D892F0E94F4
|
||||
:10F900005D7C812F0E945D7C1F910895195A892F7B
|
||||
:10F910000E945D7C812F0E945D7C1F910895EF9273
|
||||
:10F92000FF920F931F9380910201813069F1823021
|
||||
:10F9300031F080E01F910F91FF90EF900895EE2439
|
||||
:10F94000FF2487018091C80087FD17C00894E11C3F
|
||||
:10F95000F11C011D111D81E4E81682E4F8068FE018
|
||||
:10F96000080780E0180770F3E0910401F0910501A9
|
||||
:10F9700009958091C80087FFE9CF8091CE001F9143
|
||||
:10F980000F91FF90EF900895EE24FF24870180915E
|
||||
:10F99000C00087FD17C00894E11CF11C011D111D5A
|
||||
:10F9A00081E4E81682E4F8068FE0080780E0180793
|
||||
:10F9B00070F3E0910401F091050109958091C00078
|
||||
:10F9C00087FFE9CF8091C6001F910F91FF90EF90C4
|
||||
:10F9D00008951F930E948F7C182F0E945D7C113622
|
||||
:10F9E00034F410330CF01053812F1F9108951755E4
|
||||
:10F9F000812F1F9108951F930E94E97C182F0E9468
|
||||
:10FA0000E97C1295107F810F1F91089520910201CA
|
||||
:10FA1000882339F0213031F0223061F08150882381
|
||||
:10FA2000C9F708959091C00097FFFCCF9091C60050
|
||||
:10FA30008150F5CF9091C80097FFFCCF9091CE00F8
|
||||
:10FA40008150EDCF1F93182F0E948F7C803281F060
|
||||
:10FA5000809103018F5F80930301853011F01F9126
|
||||
:10FA60000895E0910401F091050109951F91089511
|
||||
:10FA700084E10E945D7C812F0E945D7C80E10E9478
|
||||
:10FA80005D7CEDCF0E948F7C803271F0809103010C
|
||||
:10FA90008F5F80930301853009F00895E0910401A0
|
||||
:10FAA000F09105010995089584E10E945D7C80E153
|
||||
:10FAB0000E945D7C089515C0289A2FEF31EE44E036
|
||||
:10FAC000215030404040E1F700C0000028982FEF5F
|
||||
:10FAD00031EE44E0215030404040E1F700C00000EA
|
||||
:10FAE0008150882349F70895EF92FF920F931F9357
|
||||
:10FAF000CF93DF93000081E08093020180E1809347
|
||||
:10FB0000C4001092C5001092C00086E08093C2002D
|
||||
:10FB100088E18093C100209A81E00E945B7D0E9471
|
||||
:10FB20008F7C8033B1F18133B9F1803409F454C052
|
||||
:10FB3000813409F45AC0823409F469C0853409F467
|
||||
:10FB40006CC0803531F1823521F1813511F1853577
|
||||
:10FB500009F469C0863509F471C0843609F47AC0A5
|
||||
:10FB6000843709F4E1C0853709F439C1863709F4CF
|
||||
:10FB70004AC0809103018F5F80930301853079F63D
|
||||
:10FB8000E0910401F091050109950E948F7C80337A
|
||||
:10FB900051F60E94427DC3CF0E948F7C803249F78C
|
||||
:10FBA00084E10E945D7C81E40E945D7C86E50E9488
|
||||
:10FBB0005D7C82E50E945D7C80E20E945D7C89E440
|
||||
:10FBC0000E945D7C83E50E945D7C80E50E945D7CF7
|
||||
:10FBD00080E10E945D7CA3CF0E948F7C8638C8F2B2
|
||||
:10FBE0000E948F7C0E94427D9ACF0E948F7C803839
|
||||
:10FBF00009F40EC1813809F40FC1823809F410C12B
|
||||
:10FC0000883909F401C180E00E94227D88CF84E117
|
||||
:10FC10000E94067D0E94427D82CF85E00E94067D83
|
||||
:10FC20000E94427D7CCF0E948F7C809306010E94BF
|
||||
:10FC30008F7C809307010E94427D71CF0E948F7C50
|
||||
:10FC4000803309F4F1C083E00E94067D80E00E94C9
|
||||
:10FC5000227D65CF0E948F7C809309020E948F7C59
|
||||
:10FC60008093080280910C028E7F80930C020E9488
|
||||
:10FC70008F7C853409F4E9C08091080290910902D3
|
||||
:10FC80000097A1F068E0E62E61E0F62E00E010E0BB
|
||||
:10FC90000E948F7CF70181937F010F5F1F4F80913E
|
||||
:10FCA0000802909109020817190790F30E948F7CAF
|
||||
:10FCB000803209F05ECF80910C0280FFE5C0809118
|
||||
:10FCC000060190910701880F991F90930701809377
|
||||
:10FCD0000601209108023091090221153105E9F051
|
||||
:10FCE00048E0E42E41E0F42E00E010E0F7016191DD
|
||||
:10FCF0007F010E94C57F80910601909107010196C6
|
||||
:10FD000090930701809306010F5F1F4F2091080217
|
||||
:10FD1000309109020217130748F384E10E945D7CC9
|
||||
:10FD200080E10E945D7CFBCE0E948F7C8093090263
|
||||
:10FD30000E948F7C809308028091060190910701B8
|
||||
:10FD400097FD9CC020910C022D7F20930C02880F00
|
||||
:10FD5000991F90930701809306010E948F7C853440
|
||||
:10FD600009F486C080910C028E7F80930C020E9461
|
||||
:10FD70008F7C803209F0D3CE84E10E945D7C20919B
|
||||
:10FD800008023091090221153105D1F100E010E09F
|
||||
:10FD900080910601909107010CC041FF5CC0019663
|
||||
:10FDA00090930701809306010F5F1F4F02171307FF
|
||||
:10FDB00038F540910C0240FFF0CF0E94BD7F0E94B9
|
||||
:10FDC0005D7C809106019091070101969093070157
|
||||
:10FDD000809306012091080230910902E5CF0E942C
|
||||
:10FDE0008F7C803209F0C5CE84E10E945D7C8EE17B
|
||||
:10FDF0000E945D7C86E90E945D7C8AE00E945D7CB9
|
||||
:10FE000080E10E945D7C8BCE83E00E94227D87CEC4
|
||||
:10FE100082E00E94227D83CE81E00E94227D7FCEFF
|
||||
:10FE200080E10E94227D7BCE0E948F7C0E948F7C8D
|
||||
:10FE3000082F0E948F7C002309F497C0013009F439
|
||||
:10FE400098C08AE00E94227D6ACE80910C02816077
|
||||
:10FE500080930C0211CFFC0184910E945D7C209163
|
||||
:10FE6000080230910902809106019091070197CF15
|
||||
:10FE700080910C02816080930C0279CF20910C025A
|
||||
:10FE8000226020930C0263CF80910701880F880BBA
|
||||
:10FE9000817080930B028091060190910701880F79
|
||||
:10FEA000991F90930701809306018091080280FFBB
|
||||
:10FEB00009C080910802909109020196909309026D
|
||||
:10FEC00080930802F894F999FECF1127E09106017A
|
||||
:10FED000F0910701C8E0D1E08091080290910902F9
|
||||
:10FEE000103091F40091570001700130D9F303E014
|
||||
:10FEF00000935700E8950091570001700130D9F345
|
||||
:10FF000001E100935700E89509901990009157007E
|
||||
:10FF100001700130D9F301E000935700E895139583
|
||||
:10FF2000103898F011270091570001700130D9F373
|
||||
:10FF300005E000935700E8950091570001700130EB
|
||||
:10FF4000D9F301E100935700E8953296029709F042
|
||||
:10FF5000C7CF103011F00296E5CF112484E10E9442
|
||||
:10FF60005D7C80E10E945D7CDACD8EE10E94227D85
|
||||
:10FF7000D6CD86E90E94227DD2CDF999FECF92BDE1
|
||||
:10FF800081BDF89A992780B50895262FF999FECF5B
|
||||
:10FF90001FBA92BD81BD20BD0FB6F894FA9AF99AA6
|
||||
:0AFFA0000FBE01960895F894FFCFFC
|
||||
:02FFAA008000D5
|
||||
:040000030000F80001
|
||||
:00000001FF
|
@ -0,0 +1,254 @@
|
||||
# Makefile for ATmegaBOOT
|
||||
# E.Lins, 18.7.2005
|
||||
# $Id$
|
||||
#
|
||||
# Instructions
|
||||
#
|
||||
# To make bootloader .hex file:
|
||||
# make diecimila
|
||||
# make lilypad
|
||||
# make ng
|
||||
# etc...
|
||||
#
|
||||
# To burn bootloader .hex file:
|
||||
# make diecimila_isp
|
||||
# make lilypad_isp
|
||||
# make ng_isp
|
||||
# etc...
|
||||
|
||||
# program name should not be changed...
|
||||
PROGRAM = ATmegaBOOT_168
|
||||
|
||||
# enter the parameters for the avrdude isp tool
|
||||
ISPTOOL = stk500v2
|
||||
ISPPORT = usb
|
||||
ISPSPEED = -b 115200
|
||||
|
||||
MCU_TARGET = atmega168
|
||||
LDSECTION = --section-start=.text=0x3800
|
||||
|
||||
# the efuse should really be 0xf8; since, however, only the lower
|
||||
# three bits of that byte are used on the atmega168, avrdude gets
|
||||
# confused if you specify 1's for the higher bits, see:
|
||||
# http://tinker.it/now/2007/02/24/the-tale-of-avrdude-atmega168-and-extended-bits-fuses/
|
||||
#
|
||||
# similarly, the lock bits should be 0xff instead of 0x3f (to
|
||||
# unlock the bootloader section) and 0xcf instead of 0x0f (to
|
||||
# lock it), but since the high two bits of the lock byte are
|
||||
# unused, avrdude would get confused.
|
||||
|
||||
ISPFUSES = avrdude -c $(ISPTOOL) -p $(MCU_TARGET) -P $(ISPPORT) $(ISPSPEED) \
|
||||
-e -u -U lock:w:0x3f:m -U efuse:w:0x$(EFUSE):m -U hfuse:w:0x$(HFUSE):m -U lfuse:w:0x$(LFUSE):m
|
||||
ISPFLASH = avrdude -c $(ISPTOOL) -p $(MCU_TARGET) -P $(ISPPORT) $(ISPSPEED) \
|
||||
-U flash:w:$(PROGRAM)_$(TARGET).hex -U lock:w:0x0f:m
|
||||
|
||||
STK500 = "C:\Program Files\Atmel\AVR Tools\STK500\Stk500.exe"
|
||||
STK500-1 = $(STK500) -e -d$(MCU_TARGET) -pf -vf -if$(PROGRAM)_$(TARGET).hex \
|
||||
-lFF -LFF -f$(HFUSE)$(LFUSE) -EF8 -ms -q -cUSB -I200kHz -s -wt
|
||||
STK500-2 = $(STK500) -d$(MCU_TARGET) -ms -q -lCF -LCF -cUSB -I200kHz -s -wt
|
||||
|
||||
|
||||
OBJ = $(PROGRAM).o
|
||||
OPTIMIZE = -O2
|
||||
|
||||
DEFS =
|
||||
LIBS =
|
||||
|
||||
CC = avr-gcc
|
||||
|
||||
# Override is only needed by avr-lib build system.
|
||||
|
||||
override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) -DF_CPU=$(AVR_FREQ) $(DEFS)
|
||||
override LDFLAGS = -Wl,$(LDSECTION)
|
||||
#override LDFLAGS = -Wl,-Map,$(PROGRAM).map,$(LDSECTION)
|
||||
|
||||
OBJCOPY = avr-objcopy
|
||||
OBJDUMP = avr-objdump
|
||||
|
||||
all:
|
||||
|
||||
lilypad: TARGET = lilypad
|
||||
lilypad: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>1' '-DNUM_LED_FLASHES=3'
|
||||
lilypad: AVR_FREQ = 8000000L
|
||||
lilypad: $(PROGRAM)_lilypad.hex
|
||||
|
||||
lilypad_isp: lilypad
|
||||
lilypad_isp: TARGET = lilypad
|
||||
lilypad_isp: HFUSE = DD
|
||||
lilypad_isp: LFUSE = E2
|
||||
lilypad_isp: EFUSE = 00
|
||||
lilypad_isp: isp
|
||||
|
||||
lilypad_resonator: TARGET = lilypad_resonator
|
||||
lilypad_resonator: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=3'
|
||||
lilypad_resonator: AVR_FREQ = 8000000L
|
||||
lilypad_resonator: $(PROGRAM)_lilypad_resonator.hex
|
||||
|
||||
lilypad_resonator_isp: lilypad_resonator
|
||||
lilypad_resonator_isp: TARGET = lilypad_resonator
|
||||
lilypad_resonator_isp: HFUSE = DD
|
||||
lilypad_resonator_isp: LFUSE = C6
|
||||
lilypad_resonator_isp: EFUSE = 00
|
||||
lilypad_resonator_isp: isp
|
||||
|
||||
pro8: TARGET = pro_8MHz
|
||||
pro8: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=1' '-DWATCHDOG_MODS'
|
||||
pro8: AVR_FREQ = 8000000L
|
||||
pro8: $(PROGRAM)_pro_8MHz.hex
|
||||
|
||||
pro8_isp: pro8
|
||||
pro8_isp: TARGET = pro_8MHz
|
||||
pro8_isp: HFUSE = DD
|
||||
pro8_isp: LFUSE = C6
|
||||
pro8_isp: EFUSE = 00
|
||||
pro8_isp: isp
|
||||
|
||||
pro16: TARGET = pro_16MHz
|
||||
pro16: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=1' '-DWATCHDOG_MODS'
|
||||
pro16: AVR_FREQ = 16000000L
|
||||
pro16: $(PROGRAM)_pro_16MHz.hex
|
||||
|
||||
pro16_isp: pro16
|
||||
pro16_isp: TARGET = pro_16MHz
|
||||
pro16_isp: HFUSE = DD
|
||||
pro16_isp: LFUSE = C6
|
||||
pro16_isp: EFUSE = 00
|
||||
pro16_isp: isp
|
||||
|
||||
pro20: TARGET = pro_20mhz
|
||||
pro20: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=1' '-DWATCHDOG_MODS'
|
||||
pro20: AVR_FREQ = 20000000L
|
||||
pro20: $(PROGRAM)_pro_20mhz.hex
|
||||
|
||||
pro20_isp: pro20
|
||||
pro20_isp: TARGET = pro_20mhz
|
||||
pro20_isp: HFUSE = DD
|
||||
pro20_isp: LFUSE = C6
|
||||
pro20_isp: EFUSE = 00
|
||||
pro20_isp: isp
|
||||
|
||||
diecimila: TARGET = diecimila
|
||||
diecimila: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=1'
|
||||
diecimila: AVR_FREQ = 16000000L
|
||||
diecimila: $(PROGRAM)_diecimila.hex
|
||||
|
||||
diecimila_isp: diecimila
|
||||
diecimila_isp: TARGET = diecimila
|
||||
diecimila_isp: HFUSE = DD
|
||||
diecimila_isp: LFUSE = FF
|
||||
diecimila_isp: EFUSE = 00
|
||||
diecimila_isp: isp
|
||||
|
||||
ng: TARGET = ng
|
||||
ng: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>1' '-DNUM_LED_FLASHES=3'
|
||||
ng: AVR_FREQ = 16000000L
|
||||
ng: $(PROGRAM)_ng.hex
|
||||
|
||||
ng_isp: ng
|
||||
ng_isp: TARGET = ng
|
||||
ng_isp: HFUSE = DD
|
||||
ng_isp: LFUSE = FF
|
||||
ng_isp: EFUSE = 00
|
||||
ng_isp: isp
|
||||
|
||||
atmega328: TARGET = atmega328
|
||||
atmega328: MCU_TARGET = atmega328p
|
||||
atmega328: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=1' -DBAUD_RATE=57600
|
||||
atmega328: AVR_FREQ = 16000000L
|
||||
atmega328: LDSECTION = --section-start=.text=0x7800
|
||||
atmega328: $(PROGRAM)_atmega328.hex
|
||||
|
||||
atmega328_isp: atmega328
|
||||
atmega328_isp: TARGET = atmega328
|
||||
atmega328_isp: MCU_TARGET = atmega328p
|
||||
atmega328_isp: HFUSE = DA
|
||||
atmega328_isp: LFUSE = FF
|
||||
atmega328_isp: EFUSE = 05
|
||||
atmega328_isp: isp
|
||||
|
||||
atmega328_pro8: TARGET = atmega328_pro_8MHz
|
||||
atmega328_pro8: MCU_TARGET = atmega328p
|
||||
atmega328_pro8: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=1' -DBAUD_RATE=57600 -DDOUBLE_SPEED
|
||||
atmega328_pro8: AVR_FREQ = 8000000L
|
||||
atmega328_pro8: LDSECTION = --section-start=.text=0x7800
|
||||
atmega328_pro8: $(PROGRAM)_atmega328_pro_8MHz.hex
|
||||
|
||||
atmega328_pro8_isp: atmega328_pro8
|
||||
atmega328_pro8_isp: TARGET = atmega328_pro_8MHz
|
||||
atmega328_pro8_isp: MCU_TARGET = atmega328p
|
||||
atmega328_pro8_isp: HFUSE = DA
|
||||
atmega328_pro8_isp: LFUSE = FF
|
||||
atmega328_pro8_isp: EFUSE = 05
|
||||
atmega328_pro8_isp: isp
|
||||
|
||||
mega: TARGET = atmega1280
|
||||
mega: MCU_TARGET = atmega1280
|
||||
mega: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=0' -DBAUD_RATE=57600
|
||||
mega: AVR_FREQ = 16000000L
|
||||
mega: LDSECTION = --section-start=.text=0x1F000
|
||||
mega: $(PROGRAM)_atmega1280.hex
|
||||
|
||||
mega_isp: mega
|
||||
mega_isp: TARGET = atmega1280
|
||||
mega_isp: MCU_TARGET = atmega1280
|
||||
mega_isp: HFUSE = DA
|
||||
mega_isp: LFUSE = FF
|
||||
mega_isp: EFUSE = F5
|
||||
mega_isp: isp
|
||||
|
||||
atmega1284p: TARGET = atmega1284p
|
||||
atmega1284p: MCU_TARGET = atmega1284p
|
||||
atmega1284p: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=0' '-DBAUD_RATE=57600'
|
||||
atmega1284p: AVR_FREQ = 16000000L
|
||||
atmega1284p: LDSECTION = --section-start=.text=0x1F000
|
||||
atmega1284p: $(PROGRAM)_atmega1284p.hex
|
||||
|
||||
atmega1284p_8m: TARGET = atmega1284p
|
||||
atmega1284p_8m: MCU_TARGET = atmega1284p
|
||||
atmega1284p_8m: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=0' '-DBAUD_RATE=19200'
|
||||
atmega1284p_8m: AVR_FREQ = 8000000L
|
||||
atmega1284p_8m: LDSECTION = --section-start=.text=0x1F000
|
||||
atmega1284p_8m: $(PROGRAM)_atmega1284p_8m.hex
|
||||
|
||||
atmega644p: TARGET = atmega644p
|
||||
atmega644p: MCU_TARGET = atmega644p
|
||||
atmega644p: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=0' '-DBAUD_RATE=57600'
|
||||
atmega644p: AVR_FREQ = 16000000L
|
||||
atmega644p: LDSECTION = --section-start=.text=0xF800
|
||||
atmega644p: $(PROGRAM)_atmega644p.hex
|
||||
|
||||
|
||||
atmega1284p_isp: atmega1284p
|
||||
atmega1284p_isp: TARGET = atmega1284p
|
||||
atmega1284p_isp: MCU_TARGET = atmega1284p
|
||||
atmega1284p_isp: HFUSE = DC
|
||||
atmega1284p_isp: LFUSE = FF
|
||||
atmega1284p_isp: EFUSE = FD
|
||||
atmega1284p_isp: isp
|
||||
|
||||
isp: $(TARGET)
|
||||
$(ISPFUSES)
|
||||
$(ISPFLASH)
|
||||
|
||||
isp-stk500: $(PROGRAM)_$(TARGET).hex
|
||||
$(STK500-1)
|
||||
$(STK500-2)
|
||||
|
||||
%.elf: $(OBJ)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
|
||||
|
||||
clean:
|
||||
rm -rf *.o *.elf *.lst *.map *.sym *.lss *.eep *.srec *.bin *.hex
|
||||
|
||||
%.lst: %.elf
|
||||
$(OBJDUMP) -h -S $< > $@
|
||||
|
||||
%.hex: %.elf
|
||||
$(OBJCOPY) -j .text -j .data -O ihex $< $@
|
||||
|
||||
%.srec: %.elf
|
||||
$(OBJCOPY) -j .text -j .data -O srec $< $@
|
||||
|
||||
%.bin: %.elf
|
||||
$(OBJCOPY) -j .text -j .data -O binary $< $@
|
||||
|
@ -0,0 +1,114 @@
|
||||
|
||||
u8glib ChangeLog
|
||||
|
||||
2012-01-01 v0.01 Oliver Kraus <olikraus@gmail.com>
|
||||
* first beta release for Arduino IDE with simple SSD1325 support
|
||||
2012-01-04 v0.02 Oliver Kraus <olikraus@gmail.com>
|
||||
* support for some more display types
|
||||
2012-01-07 v0.03 Oliver Kraus <olikraus@gmail.com>
|
||||
* fixed some bugs, added more examples
|
||||
2012-01-07 v0.04 Oliver Kraus <olikraus@gmail.com>
|
||||
* single font file
|
||||
2012-01-08 v0.05 Oliver Kraus <olikraus@gmail.com>
|
||||
* Cleanup
|
||||
* More examples
|
||||
* SSD1325 graylevel support
|
||||
2012-01-15 v0.06 Oliver Kraus <olikraus@gmail.com>
|
||||
* LM6063 support
|
||||
2012-01-17 v0.07 Oliver Kraus <olikraus@gmail.com>
|
||||
* LM6063 support (update)
|
||||
2012-01-19 v0.08 Oliver Kraus <olikraus@gmail.com>
|
||||
* ST7920 beta device
|
||||
2012-01-21 v0.09 Oliver Kraus <olikraus@gmail.com>
|
||||
* ST7920 fixed (192x32)
|
||||
* fixed bug in com layer if pins are none
|
||||
* str reference position
|
||||
2012-01-22 v0.10 Oliver Kraus <olikraus@gmail.com>
|
||||
* Experimental LM6059
|
||||
2012-01-24 v0.11 Oliver Kraus <olikraus@gmail.com>
|
||||
* new st7920 memory layout for 128x64 lcd
|
||||
* experimental st7920 SPI
|
||||
2012-01-25 v0.12 Oliver Kraus <olikraus@gmail.com>
|
||||
* fixed st7920 memory layout for 128x64 lcd
|
||||
* ST7920 SPI performance improvement
|
||||
2012-01-27 v0.13 Oliver Kraus <olikraus@gmail.com>
|
||||
* LM6059 (Adafruit Display) fixed
|
||||
2012-02-01 v0.14 Oliver Kraus <olikraus@gmail.com>
|
||||
* undoRotation()
|
||||
* setRot..() can be used without restrictions
|
||||
* Class U8GLIB derived from Print class. New function "print"
|
||||
* Fixed memory index bug in the page management procedures
|
||||
2012-02-12 v1.00 Oliver Kraus <olikraus@gmail.com>
|
||||
* XBM support
|
||||
* F() macro support
|
||||
* str-rotation commands support ref-height and ref-position
|
||||
2012-03-17 v1.02 Oliver Kraus <olikraus@gmail.com>
|
||||
* U8GLIB_ST7687_C144MVGD spi experimental
|
||||
* U8GLIB_LC7981_160X80 8bit
|
||||
* Intersection test for frame and box procedures
|
||||
* 4L double memory architecture
|
||||
* setContrast infrastructure implemented, but not available for all devices
|
||||
* drawCircle, drawDisc
|
||||
* Bugfix for drawStr270
|
||||
* New examples: Chess (ported from dogm128 lib) and GraphicsTest
|
||||
2012-03-31 v1.03 Oliver Kraus <olikraus@gmail.com>
|
||||
* experimental parallel mode atmega
|
||||
* more unifont code pages
|
||||
* double memory, for NHD OLED and DOGXL160
|
||||
* "Menu" example
|
||||
* drawLine
|
||||
2012-04-13 v1.04 Oliver Kraus <olikraus@gmail.com>
|
||||
* Adjust U8grelease: Same version number with AVR and Arduino variant
|
||||
2012-06-10 v1.05 Oliver Kraus <olikraus@gmail.com>
|
||||
* m2icon font
|
||||
* experimental lc7981_240x64 device
|
||||
* experimental ssd1306
|
||||
* experimental ssd1322
|
||||
* Hardware state backup/restore procedure
|
||||
2012-06-15 v1.06 Oliver Kraus <olikraus@gmail.com>
|
||||
* SBN1661 (SED1520?) support
|
||||
* SSD1306 support
|
||||
* U8G_PROGMEM bugfix
|
||||
2012-07-04 v1.07 Oliver Kraus <olikraus@gmail.com>
|
||||
* Added Makefiles for AVR release (issue 77)
|
||||
* Fixed examples for Arduino Environment (issue 78)
|
||||
2012-10-02 v1.08 Oliver Kraus <olikraus@gmail.com>
|
||||
* Improved delay calculation for strobe pulse (issue 20)
|
||||
* Support Chipkit (issue 39)
|
||||
* Improved speed for ST7920 parallel mode (issue 79)
|
||||
* Overall speed optimization (new page intersection algorithm)
|
||||
* Support for Displays Newhaven NHD-C12864, CrystalFontz GFAG20232, Seeedstudio 96x96 OLED
|
||||
* Added SPI support for ST7920 with plain AVR (issue 85)
|
||||
* Add more LC7981 devices
|
||||
2012-12-23 v1.09 Oliver Kraus <olikraus@gmail.com>
|
||||
* Support for Displaytech 64128n
|
||||
* Support for MINI12864
|
||||
* HW SPI for ST7920
|
||||
* Add delay after sending a byte with (ST7920 com)
|
||||
* Support ATTiny
|
||||
* Support I2C for SSD1306
|
||||
* bdf2u8g, Windows executable released
|
||||
* LC7981 320x64
|
||||
* Scalue up: u8g::setScale2x2
|
||||
* Added more bitmap fonts
|
||||
* u8g::drawRBox(), u8g::drawRFrame()
|
||||
* Support for CFAG20232 (st7920_202x32)
|
||||
* Fixed ST7920 SW SPI for ChipKit
|
||||
* Support for tls8204
|
||||
2013-02-02 v1.10 Oliver Kraus <olikraus@gmail.com>
|
||||
* Support for SSD1309
|
||||
* Support for NHD-C12832A1Z
|
||||
* Bugfix: Fixed reset controll in parallel modes
|
||||
* Bugfix: Fixed calculation of cursor position
|
||||
* Bugfix: ST7920 parallel mode
|
||||
2013-03-2 v1.11 Oliver Kraus <olikraus@gmail.com>
|
||||
* Support for T6963
|
||||
* Support for Arduino Due
|
||||
* Sleep Mode
|
||||
* 4x mode for ST7920
|
||||
* New C++ interface for ST7920
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,21 @@
|
||||
|
||||
U8GLIB
|
||||
http://code.google.com/p/u8glib/
|
||||
|
||||
|
||||
Install instructions for the Arduino environment.
|
||||
|
||||
1. Unzip u8glib_arduino_vX.XX.zip into the "libraries" folder
|
||||
2. Start Arduino IDE
|
||||
|
||||
Install instructions for the Chipkit (Arduino) environment.
|
||||
|
||||
1. cd <mpide-... path>/libraries
|
||||
2. unzip u8glib_arduino_vX.XX.zip
|
||||
3. cd <mpide-... path>///hardware/pic32/libraries
|
||||
4. again: u8glib_arduino_vX.XX.zip
|
||||
5. Open hardware/pic32/cores/pic32/Print.h
|
||||
Remove line
|
||||
#define BYTE 0
|
||||
from the file, use PRINT_BYTE instead of BYTE.
|
||||
|
@ -0,0 +1,80 @@
|
||||
/*
|
||||
|
||||
U8glib.cpp
|
||||
|
||||
C++ Interface
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#include "U8glib.h"
|
||||
|
||||
|
||||
|
||||
uint8_t U8GLIB::initSPI(u8g_dev_t *dev, uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset)
|
||||
{
|
||||
prepare();
|
||||
return u8g_InitSPI(&u8g, dev, sck, mosi, cs, a0, reset);
|
||||
}
|
||||
|
||||
uint8_t U8GLIB::initHWSPI(u8g_dev_t *dev, uint8_t cs, uint8_t a0, uint8_t reset)
|
||||
{
|
||||
prepare();
|
||||
return u8g_InitHWSPI(&u8g, dev, cs, a0, reset);
|
||||
}
|
||||
|
||||
uint8_t U8GLIB::initI2C(u8g_dev_t *dev, uint8_t options)
|
||||
{
|
||||
prepare();
|
||||
return u8g_InitI2C(&u8g, dev, options);
|
||||
}
|
||||
|
||||
uint8_t U8GLIB::init8Bit(u8g_dev_t *dev, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7,
|
||||
uint8_t en, uint8_t cs1, uint8_t cs2, uint8_t di, uint8_t rw, uint8_t reset)
|
||||
{
|
||||
prepare();
|
||||
return u8g_Init8Bit(&u8g, dev, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, cs2, di, rw, reset);
|
||||
}
|
||||
|
||||
uint8_t U8GLIB::init8BitFixedPort(u8g_dev_t *dev, uint8_t en, uint8_t cs, uint8_t di, uint8_t rw, uint8_t reset)
|
||||
{
|
||||
prepare();
|
||||
return u8g_Init8BitFixedPort(&u8g, dev, en, cs, di, rw, reset);
|
||||
}
|
||||
|
||||
uint8_t U8GLIB::initRW8Bit(u8g_dev_t *dev, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7,
|
||||
uint8_t cs, uint8_t a0, uint8_t wr, uint8_t rd, uint8_t reset)
|
||||
{
|
||||
prepare();
|
||||
return u8g_InitRW8Bit(&u8g, dev, d0, d1, d2, d3, d4, d5, d6, d7, cs, a0, wr, rd, reset);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,826 @@
|
||||
/*
|
||||
|
||||
U8glib.h
|
||||
|
||||
C++ Interface
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _CPP_U8GLIB
|
||||
#define _CPP_U8GLIB
|
||||
|
||||
#include <Print.h>
|
||||
#include "utility/u8g.h"
|
||||
|
||||
|
||||
class U8GLIB : public Print
|
||||
{
|
||||
private:
|
||||
u8g_t u8g;
|
||||
u8g_uint_t tx, ty; // current position for the Print base class procedures
|
||||
uint8_t is_begin;
|
||||
|
||||
void prepare(void) { tx = 0; ty = 0; is_begin = 0; }
|
||||
void cbegin(void) { if ( is_begin == 0 ) { is_begin = 1; u8g_Begin(&u8g); } }
|
||||
uint8_t initSPI(u8g_dev_t *dev, uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE);
|
||||
uint8_t initHWSPI(u8g_dev_t *dev, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE);
|
||||
uint8_t initI2C(u8g_dev_t *dev, uint8_t options);
|
||||
protected:
|
||||
uint8_t init8BitFixedPort(u8g_dev_t *dev, uint8_t en, uint8_t cs, uint8_t di, uint8_t rw, uint8_t reset);
|
||||
private:
|
||||
uint8_t init8Bit(u8g_dev_t *dev, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7,
|
||||
uint8_t en, uint8_t cs1, uint8_t cs2, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE);
|
||||
uint8_t initRW8Bit(u8g_dev_t *dev, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7,
|
||||
uint8_t cs, uint8_t a0, uint8_t wr, uint8_t rd, uint8_t reset);
|
||||
public:
|
||||
|
||||
/* constructor */
|
||||
U8GLIB(void)
|
||||
{ }
|
||||
U8GLIB(u8g_dev_t *dev)
|
||||
{ prepare(); u8g_Init(&u8g, dev); }
|
||||
U8GLIB(u8g_dev_t *dev, uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset)
|
||||
{ initSPI(dev, sck, mosi, cs, a0, reset); }
|
||||
U8GLIB(u8g_dev_t *dev, uint8_t cs, uint8_t a0, uint8_t reset)
|
||||
{ initHWSPI(dev, cs, a0, reset); }
|
||||
U8GLIB(u8g_dev_t *dev, uint8_t options)
|
||||
{ initI2C(dev, options); }
|
||||
U8GLIB(u8g_dev_t *dev, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7,
|
||||
uint8_t en, uint8_t cs1, uint8_t cs2, uint8_t di, uint8_t rw, uint8_t reset)
|
||||
{ init8Bit(dev, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, cs2, di, rw, reset); }
|
||||
U8GLIB(u8g_dev_t *dev, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7,
|
||||
uint8_t cs, uint8_t a0, uint8_t wr, uint8_t rd, uint8_t reset)
|
||||
{ initRW8Bit(dev, d0, d1, d2, d3, d4, d5, d6, d7, cs, a0, wr, rd, reset); }
|
||||
|
||||
uint8_t begin(void) { is_begin = 1; return u8g_Begin(&u8g); }
|
||||
|
||||
void setPrintPos(u8g_uint_t x, u8g_uint_t y) { tx = x; ty = y; }
|
||||
u8g_t *getU8g(void) { return &u8g; }
|
||||
|
||||
|
||||
/* implementation of the write interface to the print class */
|
||||
#if defined(ARDUINO) && ARDUINO >= 100
|
||||
size_t write(uint8_t c) { tx += u8g_DrawGlyph(&u8g, tx, ty, c); return 1;}
|
||||
#else
|
||||
void write(uint8_t c) { tx += u8g_DrawGlyph(&u8g, tx, ty, c); }
|
||||
#endif
|
||||
|
||||
/* screen rotation */
|
||||
void undoRotation(void) { u8g_UndoRotation(&u8g); }
|
||||
void setRot90(void) { u8g_SetRot90(&u8g); }
|
||||
void setRot180(void) { u8g_SetRot180(&u8g); }
|
||||
void setRot270(void) { u8g_SetRot270(&u8g); }
|
||||
|
||||
/* screen scaling */
|
||||
void undoScale(void) { u8g_UndoScale(&u8g); }
|
||||
void setScale2x2(void) { u8g_SetScale2x2(&u8g); }
|
||||
|
||||
/* picture loop */
|
||||
void firstPage(void) { cbegin(); u8g_FirstPage(&u8g); }
|
||||
uint8_t nextPage(void) { return u8g_NextPage(&u8g); }
|
||||
|
||||
/* system commands */
|
||||
uint8_t setContrast(uint8_t contrast) { cbegin(); return u8g_SetContrast(&u8g, contrast); }
|
||||
void sleepOn(void) { u8g_SleepOn(&u8g); }
|
||||
void sleepOff(void) { u8g_SleepOff(&u8g); }
|
||||
|
||||
/* graphic primitives */
|
||||
void setColorIndex(uint8_t color_index) { u8g_SetColorIndex(&u8g, color_index); }
|
||||
uint8_t getColorIndex(void) { return u8g_GetColorIndex(&u8g); }
|
||||
|
||||
void setDefaultForegroundColor(void) { u8g_SetDefaultForegroundColor(&u8g); }
|
||||
void setDefaultBackgroundColor(void) { u8g_SetDefaultBackgroundColor(&u8g); }
|
||||
void setDefaultMidColor(void) { u8g_SetDefaultMidColor(&u8g); }
|
||||
|
||||
u8g_uint_t getWidth(void) { return u8g_GetWidth(&u8g); }
|
||||
u8g_uint_t getHeight(void) { return u8g_GetHeight(&u8g); }
|
||||
uint8_t getMode(void) { return u8g_GetMode(&u8g); }
|
||||
|
||||
void drawPixel(u8g_uint_t x, u8g_uint_t y) { return u8g_DrawPixel(&u8g, x, y); }
|
||||
void drawHLine(u8g_uint_t x, u8g_uint_t y, u8g_uint_t w) { u8g_DrawHLine(&u8g, x, y, w); }
|
||||
void drawVLine(u8g_uint_t x, u8g_uint_t y, u8g_uint_t h) { u8g_DrawVLine(&u8g, x, y, h); }
|
||||
void drawLine(u8g_uint_t x1, u8g_uint_t y1, u8g_uint_t x2, u8g_uint_t y2) { u8g_DrawLine(&u8g, x1, y1, x2, y2); }
|
||||
|
||||
void drawFrame(u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h) { u8g_DrawFrame(&u8g, x, y, w, h); }
|
||||
void drawRFrame(u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h, u8g_uint_t r) { u8g_DrawRFrame(&u8g, x, y, w, h,r); }
|
||||
void drawBox(u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h) { u8g_DrawBox(&u8g, x, y, w, h); }
|
||||
void drawRBox(u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h, u8g_uint_t r) { u8g_DrawRBox(&u8g, x, y, w, h,r); }
|
||||
|
||||
void drawCircle(u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rad, uint8_t opt = U8G_DRAW_ALL) { u8g_DrawCircle(&u8g, x0, y0, rad, opt); }
|
||||
void drawDisc(u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rad, uint8_t opt = U8G_DRAW_ALL) { u8g_DrawDisc(&u8g, x0, y0, rad, opt); }
|
||||
|
||||
/* bitmap handling */
|
||||
void drawBitmap(u8g_uint_t x, u8g_uint_t y, u8g_uint_t cnt, u8g_uint_t h, const uint8_t *bitmap)
|
||||
{ u8g_DrawBitmap(&u8g, x, y, cnt, h, bitmap); }
|
||||
void drawBitmapP(u8g_uint_t x, u8g_uint_t y, u8g_uint_t cnt, u8g_uint_t h, const u8g_pgm_uint8_t *bitmap)
|
||||
{ u8g_DrawBitmapP(&u8g, x, y, cnt, h, bitmap); }
|
||||
|
||||
void drawXBM(u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h, const uint8_t *bitmap)
|
||||
{ u8g_DrawXBM(&u8g, x, y, w, h, bitmap); }
|
||||
void drawXBMP(u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h, const u8g_pgm_uint8_t *bitmap)
|
||||
{ u8g_DrawXBMP(&u8g, x, y, w, h, bitmap); }
|
||||
|
||||
|
||||
/* font handling */
|
||||
void setFont(const u8g_fntpgm_uint8_t *font) {u8g_SetFont(&u8g, font); }
|
||||
int8_t getFontAscent(void) { return u8g_GetFontAscent(&u8g); }
|
||||
int8_t getFontDescent(void) { return u8g_GetFontDescent(&u8g); }
|
||||
int8_t getFontLineSpacing(void) { return u8g_GetFontLineSpacing(&u8g); }
|
||||
|
||||
u8g_uint_t drawStr(u8g_uint_t x, u8g_uint_t y, const char *s) { return u8g_DrawStr(&u8g, x, y, s); }
|
||||
u8g_uint_t drawStr90(u8g_uint_t x, u8g_uint_t y, const char *s) { return u8g_DrawStr90(&u8g, x, y, s); }
|
||||
u8g_uint_t drawStr180(u8g_uint_t x, u8g_uint_t y, const char *s) { return u8g_DrawStr180(&u8g, x, y, s); }
|
||||
u8g_uint_t drawStr270(u8g_uint_t x, u8g_uint_t y, const char *s) { return u8g_DrawStr270(&u8g, x, y, s); }
|
||||
u8g_uint_t drawStrP(u8g_uint_t x, u8g_uint_t y, const u8g_pgm_uint8_t *s) { return u8g_DrawStrP(&u8g, x, y, s); }
|
||||
u8g_uint_t drawStr90P(u8g_uint_t x, u8g_uint_t y, const u8g_pgm_uint8_t *s) { return u8g_DrawStr90P(&u8g, x, y, s); }
|
||||
u8g_uint_t drawStr180P(u8g_uint_t x, u8g_uint_t y, const u8g_pgm_uint8_t *s) { return u8g_DrawStr180P(&u8g, x, y, s); }
|
||||
u8g_uint_t drawStr270P(u8g_uint_t x, u8g_uint_t y, const u8g_pgm_uint8_t *s) { return u8g_DrawStr270P(&u8g, x, y, s); }
|
||||
|
||||
void setFontPosBaseline(void) { u8g_SetFontPosBaseline(&u8g); }
|
||||
void setFontPosBottom(void) { u8g_SetFontPosBottom(&u8g); }
|
||||
void setFontPosCenter(void) { u8g_SetFontPosCenter(&u8g); }
|
||||
void setFontPosTop(void) { u8g_SetFontPosTop(&u8g); }
|
||||
|
||||
void setFontRefHeightText(void) { u8g_SetFontRefHeightText(&u8g); }
|
||||
void setFontRefHeightExtendedText(void) { u8g_SetFontRefHeightExtendedText(&u8g); }
|
||||
void setFontRefHeightAll(void) { u8g_SetFontRefHeightAll(&u8g); }
|
||||
void setFontLineSpacingFactor(uint8_t factor) { u8g_SetFontLineSpacingFactor(&u8g, factor); }
|
||||
|
||||
|
||||
u8g_uint_t getStrPixelWidth(const char *s) { return u8g_GetStrPixelWidth(&u8g, s); }
|
||||
u8g_uint_t getStrPixelWidthP(u8g_pgm_uint8_t *s) { return u8g_GetStrPixelWidthP(&u8g, s); }
|
||||
u8g_uint_t getStrWidth(const char *s) { return u8g_GetStrWidth(&u8g, s); }
|
||||
u8g_uint_t getStrWidthP(u8g_pgm_uint8_t *s) { return u8g_GetStrWidthP(&u8g, s); }
|
||||
|
||||
void setHardwareBackup(u8g_state_cb backup_cb) { u8g_SetHardwareBackup(&u8g, backup_cb); }
|
||||
|
||||
#if defined(ARDUINO) && ARDUINO >= 100
|
||||
// support for the F() macro
|
||||
|
||||
u8g_uint_t drawStr(u8g_uint_t x, u8g_uint_t y, const __FlashStringHelper *s) { return u8g_DrawStrP(&u8g, x, y, (u8g_pgm_uint8_t *)s); }
|
||||
u8g_uint_t drawStr90(u8g_uint_t x, u8g_uint_t y, const __FlashStringHelper *s) { return u8g_DrawStr90P(&u8g, x, y, (u8g_pgm_uint8_t *)s); }
|
||||
u8g_uint_t drawStr180(u8g_uint_t x, u8g_uint_t y, const __FlashStringHelper *s) { return u8g_DrawStr180P(&u8g, x, y, (u8g_pgm_uint8_t *)s); }
|
||||
u8g_uint_t drawStr270(u8g_uint_t x, u8g_uint_t y, const __FlashStringHelper *s) { return u8g_DrawStr270P(&u8g, x, y, (u8g_pgm_uint8_t *)s); }
|
||||
|
||||
u8g_uint_t getStrPixelWidth(const __FlashStringHelper *s) { return u8g_GetStrPixelWidthP(&u8g, (u8g_pgm_uint8_t *)s); }
|
||||
u8g_uint_t getStrWidth(const __FlashStringHelper *s) { return u8g_GetStrWidthP(&u8g, (u8g_pgm_uint8_t *)s); }
|
||||
#endif
|
||||
|
||||
/* cursor handling */
|
||||
void setCursorFont(const u8g_pgm_uint8_t *cursor_font) { u8g_SetCursorFont(&u8g, cursor_font); }
|
||||
void setCursorStyle(uint8_t encoding) { u8g_SetCursorStyle(&u8g, encoding); }
|
||||
void setCursorPos(u8g_uint_t cursor_x, u8g_uint_t cursor_y) { u8g_SetCursorPos(&u8g, cursor_x, cursor_y); }
|
||||
void setCursorColor(uint8_t fg, uint8_t bg) { u8g_SetCursorColor(&u8g, fg, bg); }
|
||||
void enableCursor(void) { u8g_EnableCursor(&u8g); }
|
||||
void disableCursor(void) { u8g_DisableCursor(&u8g); }
|
||||
void drawCursor(void) { u8g_DrawCursor(&u8g); }
|
||||
|
||||
/* virtual screen */
|
||||
|
||||
void setVirtualScreenDimension(u8g_uint_t width, u8g_uint_t height) { u8g_SetVirtualScreenDimension(&u8g, width, height); }
|
||||
uint8_t addToVirtualScreen(u8g_uint_t x, u8g_uint_t y, U8GLIB &child_u8g) { return u8g_AddToVirtualScreen(&u8g, x, y, &child_u8g.u8g); }
|
||||
|
||||
};
|
||||
|
||||
|
||||
class U8GLIB_DOGS102 : public U8GLIB
|
||||
{
|
||||
public:
|
||||
U8GLIB_DOGS102(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_uc1701_dogs102_sw_spi, sck, mosi, cs, a0, reset)
|
||||
{ }
|
||||
U8GLIB_DOGS102(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_uc1701_dogs102_hw_spi, cs, a0, reset)
|
||||
{ }
|
||||
};
|
||||
|
||||
class U8GLIB_MINI12864 : public U8GLIB
|
||||
{
|
||||
public:
|
||||
U8GLIB_MINI12864(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_uc1701_mini12864_sw_spi, sck, mosi, cs, a0, reset)
|
||||
{ }
|
||||
U8GLIB_MINI12864(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_uc1701_mini12864_hw_spi, cs, a0, reset)
|
||||
{ }
|
||||
};
|
||||
|
||||
class U8GLIB_DOGM132 : public U8GLIB
|
||||
{
|
||||
public:
|
||||
U8GLIB_DOGM132(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_st7565_dogm132_sw_spi, sck, mosi, cs, a0, reset)
|
||||
{ }
|
||||
U8GLIB_DOGM132(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_st7565_dogm132_hw_spi, cs, a0, reset)
|
||||
{ }
|
||||
};
|
||||
|
||||
class U8GLIB_NHD_C12832 : public U8GLIB
|
||||
{
|
||||
public:
|
||||
U8GLIB_NHD_C12832(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_st7565_nhd_c12832_sw_spi, sck, mosi, cs, a0, reset)
|
||||
{ }
|
||||
U8GLIB_NHD_C12832(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_st7565_nhd_c12832_hw_spi, cs, a0, reset)
|
||||
{ }
|
||||
U8GLIB_NHD_C12832(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7,
|
||||
uint8_t en, uint8_t cs1, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_st7565_nhd_c12832_parallel, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, U8G_PIN_NONE, di, rw, reset)
|
||||
{ }
|
||||
};
|
||||
|
||||
class U8GLIB_DOGM128 : public U8GLIB
|
||||
{
|
||||
public:
|
||||
U8GLIB_DOGM128(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_st7565_dogm128_sw_spi, sck, mosi, cs, a0, reset)
|
||||
{ }
|
||||
U8GLIB_DOGM128(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_st7565_dogm128_hw_spi, cs, a0, reset)
|
||||
{ }
|
||||
};
|
||||
|
||||
class U8GLIB_LM6059 : public U8GLIB
|
||||
{
|
||||
public:
|
||||
U8GLIB_LM6059(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_st7565_lm6059_sw_spi, sck, mosi, cs, a0, reset)
|
||||
{ }
|
||||
U8GLIB_LM6059(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_st7565_lm6059_hw_spi, cs, a0, reset)
|
||||
{ }
|
||||
};
|
||||
|
||||
class U8GLIB_LM6063 : public U8GLIB
|
||||
{
|
||||
public:
|
||||
U8GLIB_LM6063(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_st7565_lm6063_sw_spi, sck, mosi, cs, a0, reset)
|
||||
{ }
|
||||
U8GLIB_LM6063(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_st7565_lm6063_hw_spi, cs, a0, reset)
|
||||
{ }
|
||||
};
|
||||
|
||||
class U8GLIB_64128N : public U8GLIB
|
||||
{
|
||||
public:
|
||||
U8GLIB_64128N(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_st7565_64128n_sw_spi, sck, mosi, cs, a0, reset)
|
||||
{ }
|
||||
U8GLIB_64128N(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_st7565_64128n_hw_spi, cs, a0, reset)
|
||||
{ }
|
||||
};
|
||||
|
||||
class U8GLIB_NHD_C12864 : public U8GLIB
|
||||
{
|
||||
public:
|
||||
U8GLIB_NHD_C12864(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_st7565_nhd_c12864_sw_spi, sck, mosi, cs, a0, reset)
|
||||
{ }
|
||||
U8GLIB_NHD_C12864(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_st7565_nhd_c12864_hw_spi, cs, a0, reset)
|
||||
{ }
|
||||
};
|
||||
|
||||
|
||||
class U8GLIB_ST7920_128X64 : public U8GLIB
|
||||
{
|
||||
public:
|
||||
U8GLIB_ST7920_128X64(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_st7920_128x64_sw_spi, sck, mosi, cs, a0, reset)
|
||||
{ }
|
||||
U8GLIB_ST7920_128X64(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_st7920_128x64_hw_spi, cs, a0, reset)
|
||||
{ }
|
||||
U8GLIB_ST7920_128X64(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7,
|
||||
uint8_t en, uint8_t cs1, uint8_t cs2, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_st7920_128x64_8bit, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, cs2, di, rw, reset)
|
||||
{ }
|
||||
// U8GLIB_ST7920_128X64(uint8_t cs)
|
||||
// : U8GLIB(&u8g_dev_st7920_128x64_sw_spi, cs, U8G_PIN_NONE, U8G_PIN_NONE)
|
||||
// { }
|
||||
};
|
||||
|
||||
class U8GLIB_ST7920_128X64_1X : public U8GLIB
|
||||
{
|
||||
public:
|
||||
U8GLIB_ST7920_128X64_1X(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_st7920_128x64_sw_spi, sck, mosi, cs, U8G_PIN_NONE, reset) // a0 = U8G_PIN_NONE
|
||||
{ }
|
||||
U8GLIB_ST7920_128X64_1X(uint8_t cs, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_st7920_128x64_hw_spi, cs, U8G_PIN_NONE, reset) // a0 = U8G_PIN_NONE
|
||||
{ }
|
||||
U8GLIB_ST7920_128X64_1X(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7,
|
||||
uint8_t en, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_st7920_128x64_8bit, d0, d1, d2, d3, d4, d5, d6, d7, en, U8G_PIN_NONE, U8G_PIN_NONE, di, rw, reset) // cs1 = cs2 = U8G_PIN_NONE
|
||||
{ }
|
||||
};
|
||||
|
||||
class U8GLIB_ST7920_128X64_4X : public U8GLIB
|
||||
{
|
||||
public:
|
||||
U8GLIB_ST7920_128X64_4X(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_st7920_128x64_4x_sw_spi, sck, mosi, cs, U8G_PIN_NONE, reset) // a0 = U8G_PIN_NONE
|
||||
{ }
|
||||
U8GLIB_ST7920_128X64_4X(uint8_t cs, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_st7920_128x64_4x_hw_spi, cs, U8G_PIN_NONE, reset) // a0 = U8G_PIN_NONE
|
||||
{ }
|
||||
U8GLIB_ST7920_128X64_4X(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7,
|
||||
uint8_t en, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_st7920_128x64_4x_8bit, d0, d1, d2, d3, d4, d5, d6, d7, en, U8G_PIN_NONE, U8G_PIN_NONE, di, rw, reset) // cs1 = cs2 = U8G_PIN_NONE
|
||||
{ }
|
||||
};
|
||||
|
||||
|
||||
|
||||
class U8GLIB_ST7920_192X32 : public U8GLIB // OBSOLETE, use U8GLIB_ST7920_192X32_1X instead
|
||||
{
|
||||
public:
|
||||
U8GLIB_ST7920_192X32(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_st7920_192x32_sw_spi, sck, mosi, cs, a0, reset)
|
||||
{ }
|
||||
U8GLIB_ST7920_192X32(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_st7920_192x32_hw_spi, cs, a0, reset)
|
||||
{ }
|
||||
U8GLIB_ST7920_192X32(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7,
|
||||
uint8_t en, uint8_t cs1, uint8_t cs2, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_st7920_192x32_8bit, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, cs2, di, rw, reset)
|
||||
{ }
|
||||
};
|
||||
|
||||
class U8GLIB_ST7920_192X32_1X : public U8GLIB
|
||||
{
|
||||
public:
|
||||
U8GLIB_ST7920_192X32_1X(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_st7920_192x32_sw_spi, sck, mosi, cs, U8G_PIN_NONE, reset) // a0 = U8G_PIN_NONE
|
||||
{ }
|
||||
U8GLIB_ST7920_192X32_1X(uint8_t cs, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_st7920_192x32_hw_spi, cs, U8G_PIN_NONE, reset) // a0 = U8G_PIN_NONE
|
||||
{ }
|
||||
U8GLIB_ST7920_192X32_1X(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7,
|
||||
uint8_t en, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_st7920_192x32_8bit, d0, d1, d2, d3, d4, d5, d6, d7, en, U8G_PIN_NONE, U8G_PIN_NONE, di, rw, reset) // cs1 = cs2 = U8G_PIN_NONE
|
||||
{ }
|
||||
};
|
||||
|
||||
class U8GLIB_ST7920_192X32_4X : public U8GLIB
|
||||
{
|
||||
public:
|
||||
U8GLIB_ST7920_192X32_4X(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_st7920_192x32_4x_sw_spi, sck, mosi, cs, U8G_PIN_NONE, reset) // a0 = U8G_PIN_NONE
|
||||
{ }
|
||||
U8GLIB_ST7920_192X32_4X(uint8_t cs, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_st7920_192x32_4x_hw_spi, cs, U8G_PIN_NONE, reset) // a0 = U8G_PIN_NONE
|
||||
{ }
|
||||
U8GLIB_ST7920_192X32_4X(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7,
|
||||
uint8_t en, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_st7920_192x32_4x_8bit, d0, d1, d2, d3, d4, d5, d6, d7, en, U8G_PIN_NONE, U8G_PIN_NONE, di, rw, reset) // cs1 = cs2 = U8G_PIN_NONE
|
||||
{ }
|
||||
};
|
||||
|
||||
|
||||
class U8GLIB_ST7920_202X32 : public U8GLIB
|
||||
{
|
||||
public:
|
||||
U8GLIB_ST7920_202X32(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_st7920_202x32_sw_spi, sck, mosi, cs, a0, reset)
|
||||
{ }
|
||||
U8GLIB_ST7920_202X32(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_st7920_202x32_hw_spi, cs, a0, reset)
|
||||
{ }
|
||||
U8GLIB_ST7920_202X32(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7,
|
||||
uint8_t en, uint8_t cs1, uint8_t cs2, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_st7920_202x32_8bit, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, cs2, di, rw, reset)
|
||||
{ }
|
||||
};
|
||||
|
||||
class U8GLIB_ST7920_202X32_1X : public U8GLIB
|
||||
{
|
||||
public:
|
||||
U8GLIB_ST7920_202X32_1X(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_st7920_202x32_sw_spi, sck, mosi, cs, U8G_PIN_NONE, reset) // a0 = U8G_PIN_NONE
|
||||
{ }
|
||||
U8GLIB_ST7920_202X32_1X(uint8_t cs, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_st7920_202x32_hw_spi, cs, U8G_PIN_NONE, reset) // a0 = U8G_PIN_NONE
|
||||
{ }
|
||||
U8GLIB_ST7920_202X32_1X(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7,
|
||||
uint8_t en, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_st7920_202x32_8bit, d0, d1, d2, d3, d4, d5, d6, d7, en, U8G_PIN_NONE, U8G_PIN_NONE, di, rw, reset) // cs1 = cs2 = U8G_PIN_NONE
|
||||
{ }
|
||||
};
|
||||
|
||||
class U8GLIB_ST7920_202X32_4X : public U8GLIB
|
||||
{
|
||||
public:
|
||||
U8GLIB_ST7920_202X32_4X(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_st7920_202x32_4x_sw_spi, sck, mosi, cs, U8G_PIN_NONE, reset) // a0 = U8G_PIN_NONE
|
||||
{ }
|
||||
U8GLIB_ST7920_202X32_4X(uint8_t cs, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_st7920_202x32_4x_hw_spi, cs, U8G_PIN_NONE, reset) // a0 = U8G_PIN_NONE
|
||||
{ }
|
||||
U8GLIB_ST7920_202X32_4X(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7,
|
||||
uint8_t en, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_st7920_202x32_4x_8bit, d0, d1, d2, d3, d4, d5, d6, d7, en, U8G_PIN_NONE, U8G_PIN_NONE, di, rw, reset) // cs1 = cs2 = U8G_PIN_NONE
|
||||
{ }
|
||||
};
|
||||
|
||||
|
||||
class U8GLIB_LC7981_160X80 : public U8GLIB
|
||||
{
|
||||
public:
|
||||
U8GLIB_LC7981_160X80(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7,
|
||||
uint8_t en, uint8_t cs1, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_lc7981_160x80_8bit, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, U8G_PIN_NONE, di, rw, reset)
|
||||
{ }
|
||||
};
|
||||
|
||||
class U8GLIB_LC7981_240X64 : public U8GLIB
|
||||
{
|
||||
public:
|
||||
U8GLIB_LC7981_240X64(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7,
|
||||
uint8_t en, uint8_t cs1, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_lc7981_240x64_8bit, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, U8G_PIN_NONE, di, rw, reset)
|
||||
{ }
|
||||
};
|
||||
|
||||
class U8GLIB_LC7981_240X128 : public U8GLIB
|
||||
{
|
||||
public:
|
||||
U8GLIB_LC7981_240X128(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7,
|
||||
uint8_t en, uint8_t cs1, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_lc7981_240x128_8bit, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, U8G_PIN_NONE, di, rw, reset)
|
||||
{ }
|
||||
};
|
||||
|
||||
// 16 bit mode required: Remove comment from "#define U8G_16BIT 1" in utility/u8g.h
|
||||
class U8GLIB_LC7981_320X64 : public U8GLIB
|
||||
{
|
||||
public:
|
||||
U8GLIB_LC7981_320X64(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7,
|
||||
uint8_t en, uint8_t cs1, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_lc7981_320x64_8bit, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, U8G_PIN_NONE, di, rw, reset)
|
||||
{ }
|
||||
};
|
||||
|
||||
|
||||
|
||||
class U8GLIB_DOGXL160_BW : public U8GLIB
|
||||
{
|
||||
public:
|
||||
U8GLIB_DOGXL160_BW(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_uc1610_dogxl160_bw_sw_spi, sck, mosi, cs, a0, reset)
|
||||
{ }
|
||||
U8GLIB_DOGXL160_BW(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_uc1610_dogxl160_bw_hw_spi, cs, a0, reset)
|
||||
{ }
|
||||
};
|
||||
|
||||
class U8GLIB_DOGXL160_GR : public U8GLIB
|
||||
{
|
||||
public:
|
||||
U8GLIB_DOGXL160_GR(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_uc1610_dogxl160_gr_sw_spi, sck, mosi, cs, a0, reset)
|
||||
{ }
|
||||
U8GLIB_DOGXL160_GR(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_uc1610_dogxl160_gr_hw_spi, cs, a0, reset)
|
||||
{ }
|
||||
};
|
||||
|
||||
class U8GLIB_DOGXL160_2X_BW : public U8GLIB
|
||||
{
|
||||
public:
|
||||
U8GLIB_DOGXL160_2X_BW(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_uc1610_dogxl160_2x_bw_sw_spi, sck, mosi, cs, a0, reset)
|
||||
{ }
|
||||
U8GLIB_DOGXL160_2X_BW(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_uc1610_dogxl160_2x_bw_hw_spi, cs, a0, reset)
|
||||
{ }
|
||||
};
|
||||
|
||||
class U8GLIB_DOGXL160_2X_GR : public U8GLIB
|
||||
{
|
||||
public:
|
||||
U8GLIB_DOGXL160_2X_GR(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_uc1610_dogxl160_2x_gr_sw_spi, sck, mosi, cs, a0, reset)
|
||||
{ }
|
||||
U8GLIB_DOGXL160_2X_GR(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_uc1610_dogxl160_2x_gr_hw_spi, cs, a0, reset)
|
||||
{ }
|
||||
};
|
||||
|
||||
|
||||
class U8GLIB_NHD27OLED_BW : public U8GLIB
|
||||
{
|
||||
public:
|
||||
U8GLIB_NHD27OLED_BW(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_ssd1325_nhd27oled_bw_sw_spi, sck, mosi, cs, a0, reset)
|
||||
{ }
|
||||
U8GLIB_NHD27OLED_BW(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_ssd1325_nhd27oled_bw_hw_spi, cs, a0, reset)
|
||||
{ }
|
||||
U8GLIB_NHD27OLED_BW(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7,
|
||||
uint8_t cs, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_ssd1325_nhd27oled_bw_parallel, d0, d1, d2, d3, d4, d5, d6, d7, U8G_PIN_NONE, cs, U8G_PIN_NONE, di, rw, reset)
|
||||
{ }
|
||||
};
|
||||
|
||||
class U8GLIB_NHD27OLED_2X_BW : public U8GLIB
|
||||
{
|
||||
public:
|
||||
U8GLIB_NHD27OLED_2X_BW(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_ssd1325_nhd27oled_2x_bw_sw_spi, sck, mosi, cs, a0, reset)
|
||||
{ }
|
||||
U8GLIB_NHD27OLED_2X_BW(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_ssd1325_nhd27oled_2x_bw_hw_spi, cs, a0, reset)
|
||||
{ }
|
||||
U8GLIB_NHD27OLED_2X_BW(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7,
|
||||
uint8_t cs, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_ssd1325_nhd27oled_2x_bw_parallel, d0, d1, d2, d3, d4, d5, d6, d7, U8G_PIN_NONE, cs, U8G_PIN_NONE, di, rw, reset)
|
||||
{ }
|
||||
};
|
||||
|
||||
class U8GLIB_NHD31OLED_BW : public U8GLIB
|
||||
{
|
||||
public:
|
||||
U8GLIB_NHD31OLED_BW(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_ssd1322_nhd31oled_bw_sw_spi, sck, mosi, cs, a0, reset)
|
||||
{ }
|
||||
U8GLIB_NHD31OLED_BW(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_ssd1322_nhd31oled_bw_hw_spi, cs, a0, reset)
|
||||
{ }
|
||||
};
|
||||
|
||||
class U8GLIB_NHD31OLED_2X_BW : public U8GLIB
|
||||
{
|
||||
public:
|
||||
U8GLIB_NHD31OLED_2X_BW(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_ssd1322_nhd31oled_2x_bw_sw_spi, sck, mosi, cs, a0, reset)
|
||||
{ }
|
||||
U8GLIB_NHD31OLED_2X_BW(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_ssd1322_nhd31oled_2x_bw_hw_spi, cs, a0, reset)
|
||||
{ }
|
||||
};
|
||||
|
||||
class U8GLIB_NHD31OLED_GR : public U8GLIB
|
||||
{
|
||||
public:
|
||||
U8GLIB_NHD31OLED_GR(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_ssd1322_nhd31oled_gr_sw_spi, sck, mosi, cs, a0, reset)
|
||||
{ }
|
||||
U8GLIB_NHD31OLED_GR(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_ssd1322_nhd31oled_gr_hw_spi, cs, a0, reset)
|
||||
{ }
|
||||
};
|
||||
|
||||
class U8GLIB_NHD31OLED_2X_GR : public U8GLIB
|
||||
{
|
||||
public:
|
||||
U8GLIB_NHD31OLED_2X_GR(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_ssd1322_nhd31oled_2x_gr_sw_spi, sck, mosi, cs, a0, reset)
|
||||
{ }
|
||||
U8GLIB_NHD31OLED_2X_GR(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_ssd1322_nhd31oled_2x_gr_hw_spi, cs, a0, reset)
|
||||
{ }
|
||||
};
|
||||
|
||||
|
||||
class U8GLIB_SSD1306_128X64 : public U8GLIB
|
||||
{
|
||||
public:
|
||||
U8GLIB_SSD1306_128X64(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_ssd1306_128x64_sw_spi, sck, mosi, cs, a0, reset)
|
||||
{ }
|
||||
U8GLIB_SSD1306_128X64(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_ssd1306_128x64_hw_spi, cs, a0, reset)
|
||||
{ }
|
||||
U8GLIB_SSD1306_128X64(uint8_t options = U8G_I2C_OPT_NONE)
|
||||
: U8GLIB(&u8g_dev_ssd1306_128x64_i2c, options)
|
||||
{ }
|
||||
|
||||
};
|
||||
|
||||
class U8GLIB_SSD1309_128X64 : public U8GLIB
|
||||
{
|
||||
public:
|
||||
U8GLIB_SSD1309_128X64(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_ssd1309_128x64_sw_spi, sck, mosi, cs, a0, reset)
|
||||
{ }
|
||||
U8GLIB_SSD1309_128X64(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_ssd1309_128x64_hw_spi, cs, a0, reset)
|
||||
{ }
|
||||
U8GLIB_SSD1309_128X64(uint8_t options = U8G_I2C_OPT_NONE)
|
||||
: U8GLIB(&u8g_dev_ssd1309_128x64_i2c, options)
|
||||
{ }
|
||||
|
||||
};
|
||||
|
||||
class U8GLIB_SSD1306_128X32 : public U8GLIB
|
||||
{
|
||||
public:
|
||||
U8GLIB_SSD1306_128X32(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_ssd1306_128x32_sw_spi, sck, mosi, cs, a0, reset)
|
||||
{ }
|
||||
U8GLIB_SSD1306_128X32(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_ssd1306_128x32_hw_spi, cs, a0, reset)
|
||||
{ }
|
||||
U8GLIB_SSD1306_128X32(uint8_t options = U8G_I2C_OPT_NONE)
|
||||
: U8GLIB(&u8g_dev_ssd1306_128x32_i2c, options)
|
||||
{ }
|
||||
|
||||
};
|
||||
|
||||
|
||||
class U8GLIB_NHD27OLED_GR : public U8GLIB
|
||||
{
|
||||
public:
|
||||
U8GLIB_NHD27OLED_GR(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_ssd1325_nhd27oled_gr_sw_spi, sck, mosi, cs, a0, reset)
|
||||
{ }
|
||||
U8GLIB_NHD27OLED_GR(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_ssd1325_nhd27oled_gr_hw_spi, cs, a0, reset)
|
||||
{ }
|
||||
};
|
||||
|
||||
class U8GLIB_NHD27OLED_2X_GR : public U8GLIB
|
||||
{
|
||||
public:
|
||||
U8GLIB_NHD27OLED_2X_GR(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_ssd1325_nhd27oled_2x_gr_sw_spi, sck, mosi, cs, a0, reset)
|
||||
{ }
|
||||
U8GLIB_NHD27OLED_2X_GR(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_ssd1325_nhd27oled_2x_gr_hw_spi, cs, a0, reset)
|
||||
{ }
|
||||
};
|
||||
|
||||
class U8GLIB_SSD1327_96X96_GR : public U8GLIB
|
||||
{
|
||||
public:
|
||||
U8GLIB_SSD1327_96X96_GR(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_ssd1327_96x96_gr_sw_spi, sck, mosi, cs, a0, reset)
|
||||
{ }
|
||||
U8GLIB_SSD1327_96X96_GR(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_ssd1327_96x96_gr_hw_spi, cs, a0, reset)
|
||||
{ }
|
||||
U8GLIB_SSD1327_96X96_GR(uint8_t options = U8G_I2C_OPT_NONE)
|
||||
: U8GLIB(&u8g_dev_ssd1327_96x96_gr_i2c, options)
|
||||
{ }
|
||||
};
|
||||
|
||||
class U8GLIB_SSD1327_96X96_2X_GR : public U8GLIB
|
||||
{
|
||||
public:
|
||||
U8GLIB_SSD1327_96X96_2X_GR(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_ssd1327_96x96_2x_gr_sw_spi, sck, mosi, cs, a0, reset)
|
||||
{ }
|
||||
U8GLIB_SSD1327_96X96_2X_GR(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_ssd1327_96x96_2x_gr_hw_spi, cs, a0, reset)
|
||||
{ }
|
||||
U8GLIB_SSD1327_96X96_2X_GR(uint8_t options = U8G_I2C_OPT_NONE)
|
||||
: U8GLIB(&u8g_dev_ssd1327_96x96_2x_gr_i2c, options)
|
||||
{ }
|
||||
};
|
||||
|
||||
class U8GLIB_PCF8812 : public U8GLIB
|
||||
{
|
||||
public:
|
||||
U8GLIB_PCF8812(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_pcf8812_96x65_sw_spi, sck, mosi, cs, a0, reset)
|
||||
{ }
|
||||
};
|
||||
|
||||
class U8GLIB_PCD8544 : public U8GLIB
|
||||
{
|
||||
public:
|
||||
U8GLIB_PCD8544(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_pcd8544_84x48_sw_spi, sck, mosi, cs, a0, reset)
|
||||
{ }
|
||||
};
|
||||
|
||||
class U8GLIB_TLS8204_84X48 : public U8GLIB
|
||||
{
|
||||
public:
|
||||
U8GLIB_TLS8204_84X48(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_tls8204_84x48_sw_spi, sck, mosi, cs, a0, reset)
|
||||
{ }
|
||||
};
|
||||
|
||||
class U8GLIB_KS0108_128 : public U8GLIB
|
||||
{
|
||||
public:
|
||||
U8GLIB_KS0108_128(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7,
|
||||
uint8_t en, uint8_t cs1, uint8_t cs2, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_ks0108_128x64_fast, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, cs2, di, rw, reset)
|
||||
{ }
|
||||
};
|
||||
|
||||
class U8GLIB_SBN1661_122X32 : public U8GLIB
|
||||
{
|
||||
public:
|
||||
U8GLIB_SBN1661_122X32(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7,
|
||||
uint8_t cs1, uint8_t cs2, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_sbn1661_122x32, d0, d1, d2, d3, d4, d5, d6, d7, U8G_PIN_NONE, cs1, cs2, di, rw, reset)
|
||||
{ }
|
||||
};
|
||||
|
||||
class U8GLIB_T6963_240X128 : public U8GLIB
|
||||
{
|
||||
public:
|
||||
U8GLIB_T6963_240X128(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7,
|
||||
uint8_t cs, uint8_t a0, uint8_t wr, uint8_t rd, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_t6963_240x128_8bit, d0, d1, d2, d3, d4, d5, d6, d7, cs, a0, wr, rd, reset)
|
||||
{ }
|
||||
};
|
||||
|
||||
class U8GLIB_T6963_240X64 : public U8GLIB
|
||||
{
|
||||
public:
|
||||
U8GLIB_T6963_240X64(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7,
|
||||
uint8_t cs, uint8_t a0, uint8_t wr, uint8_t rd, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_t6963_240x64_8bit, d0, d1, d2, d3, d4, d5, d6, d7, cs, a0, wr, rd, reset)
|
||||
{ }
|
||||
};
|
||||
|
||||
class U8GLIB_T6963_128X64 : public U8GLIB
|
||||
{
|
||||
public:
|
||||
U8GLIB_T6963_128X64(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7,
|
||||
uint8_t cs, uint8_t a0, uint8_t wr, uint8_t rd, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_t6963_128x64_8bit, d0, d1, d2, d3, d4, d5, d6, d7, cs, a0, wr, rd, reset)
|
||||
{ }
|
||||
};
|
||||
|
||||
|
||||
class U8GLIB_ST7687_C144MVGD: public U8GLIB
|
||||
{
|
||||
public:
|
||||
U8GLIB_ST7687_C144MVGD(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_st7687_c144mvgd_sw_spi, sck, mosi, cs, a0, reset)
|
||||
{ }
|
||||
U8GLIB_ST7687_C144MVGD(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7,
|
||||
uint8_t en, uint8_t cs, uint8_t a0, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_ks0108_128x64_fast, d0, d1, d2, d3, d4, d5, d6, d7, en, cs, U8G_PIN_NONE, a0, rw, reset)
|
||||
{ }
|
||||
};
|
||||
|
||||
class U8GLIB_ILI9325D_320x240 : public U8GLIB
|
||||
{
|
||||
public:
|
||||
/*
|
||||
U8GLIB_ILI9325D_320x240(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7,
|
||||
uint8_t en, uint8_t cs1, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE)
|
||||
: U8GLIB(&u8g_dev_ili9325d_320x240_8bit, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, U8G_PIN_NONE, di, rw, reset)
|
||||
{ }
|
||||
*/
|
||||
U8GLIB_ILI9325D_320x240( uint8_t en, uint8_t cs1, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE)
|
||||
{ init8BitFixedPort(&u8g_dev_ili9325d_320x240_8bit, en, cs1, di, rw, reset); }
|
||||
};
|
||||
|
||||
class U8GLIB_FLIPDISC_2X7 : public U8GLIB
|
||||
{
|
||||
public:
|
||||
U8GLIB_FLIPDISC_2X7(void) : U8GLIB(&u8g_dev_flipdisc_2x7)
|
||||
{ }
|
||||
};
|
||||
|
||||
class U8GLIB_VS : public U8GLIB
|
||||
{
|
||||
public:
|
||||
U8GLIB_VS(void) : U8GLIB(&u8g_dev_vs)
|
||||
{ }
|
||||
};
|
||||
|
||||
|
||||
#endif /* _CPP_U8GLIB */
|
@ -0,0 +1,130 @@
|
||||
/*
|
||||
|
||||
Bitmap.pde
|
||||
|
||||
Show simple bitmap
|
||||
|
||||
>>> Before compiling: Please remove comment from the constructor of the
|
||||
>>> connected graphics display (see below).
|
||||
|
||||
Universal 8bit Graphics Library, http://code.google.com/p/u8glib/
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "U8glib.h"
|
||||
|
||||
// setup u8g object, please remove comment from one of the following constructor calls
|
||||
// IMPORTANT NOTE: The complete list of supported devices is here: http://code.google.com/p/u8glib/wiki/device
|
||||
|
||||
//U8GLIB_NHD27OLED_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD27OLED_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD27OLED_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD27OLED_2X_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD31OLED_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD31OLED_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD31OLED_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD31OLED_2X_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGS102 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGM132 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGM128 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_ST7920_128X64_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_128X64_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_128X64_1X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_128X64_4X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_192X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_192X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_192X32_1X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_192X32_4X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_192X32_1X u8g(13, 11, 10); // SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10
|
||||
//U8GLIB_ST7920_192X32_4X u8g(10); // SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10, HW SPI
|
||||
//U8GLIB_ST7920_202X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_202X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_202X32_1X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_202X32_4X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_LM6059 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_LM6063 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGXL160_BW u8g(10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGXL160_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGXL160_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGXL160_2X_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_PCD8544 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
|
||||
//U8GLIB_PCF8812 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
|
||||
//U8GLIB_KS0108_128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs1=14, cs2=15,di=17,rw=16
|
||||
//U8GLIB_LC7981_160X80 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
|
||||
//U8GLIB_LC7981_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
|
||||
//U8GLIB_LC7981_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
|
||||
//U8GLIB_ILI9325D_320x240 u8g(18,17,19,U8G_PIN_NONE,16 ); // 8Bit Com: D0..D7: 0,1,2,3,4,5,6,7 en=wr=18, cs=17, rs=19, rd=U8G_PIN_NONE, reset = 16
|
||||
//U8GLIB_SBN1661_122X32 u8g(8,9,10,11,4,5,6,7,14,15, 17, U8G_PIN_NONE, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 cs1=14, cs2=15,di=17,rw=16,reset = 16
|
||||
//U8GLIB_SSD1306_128X64 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_SSD1306_128X64 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
|
||||
//U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
|
||||
//U8GLIB_SSD1306_128X32 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_SSD1306_128X32 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
|
||||
//U8GLIB_SSD1306_128X32 u8g(U8G_I2C_OPT_NONE); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
|
||||
//U8GLIB_SSD1309_128X64 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_SSD1327_96X96_GR u8g(U8G_I2C_OPT_NONE); // I2C
|
||||
//U8GLIB_SSD1327_96X96_2X_GR u8g(U8G_I2C_OPT_NONE); // I2C
|
||||
//U8GLIB_NHD_C12864 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
|
||||
//U8GLIB_NHD_C12832 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
|
||||
//U8GLIB_T6963_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
|
||||
//U8GLIB_T6963_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
|
||||
//U8GLIB_T6963_128X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
|
||||
|
||||
const uint8_t rook_bitmap[] PROGMEM = {
|
||||
0x00, // 00000000
|
||||
0x55, // 01010101
|
||||
0x7f, // 01111111
|
||||
0x3e, // 00111110
|
||||
0x3e, // 00111110
|
||||
0x3e, // 00111110
|
||||
0x3e, // 00111110
|
||||
0x7f // 01111111
|
||||
};
|
||||
|
||||
void draw(void) {
|
||||
// graphic commands to redraw the complete screen should be placed here
|
||||
u8g.drawBitmapP( 0, 0, 1, 8, rook_bitmap);
|
||||
}
|
||||
|
||||
void setup(void) {
|
||||
}
|
||||
|
||||
void loop(void) {
|
||||
// picture loop
|
||||
u8g.firstPage();
|
||||
do {
|
||||
draw();
|
||||
} while( u8g.nextPage() );
|
||||
|
||||
// rebuild the picture after some delay
|
||||
delay(1000);
|
||||
}
|
||||
|
@ -0,0 +1,180 @@
|
||||
/*
|
||||
|
||||
Chess.pde
|
||||
|
||||
Little Rook Chess
|
||||
|
||||
>>> Before compiling: Please remove comment from the constructor of the
|
||||
>>> connected graphics display (see below).
|
||||
|
||||
Universal 8bit Graphics Library, http://code.google.com/p/u8glib/
|
||||
|
||||
Copyright (c) 2012, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "U8glib.h"
|
||||
|
||||
// setup u8g object, please remove comment from one of the following constructor calls
|
||||
// IMPORTANT NOTE: The complete list of supported devices is here: http://code.google.com/p/u8glib/wiki/device
|
||||
|
||||
//U8GLIB_NHD27OLED_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD27OLED_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD27OLED_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD27OLED_2X_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD31OLED_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD31OLED_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD31OLED_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD31OLED_2X_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGS102 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGM132 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGM128 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_ST7920_128X64_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_128X64_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_128X64_1X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_128X64_4X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_192X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_192X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_192X32_1X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_192X32_4X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_192X32_1X u8g(13, 11, 10); // SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10
|
||||
//U8GLIB_ST7920_192X32_4X u8g(10); // SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10, HW SPI
|
||||
//U8GLIB_ST7920_202X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_202X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_202X32_1X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_202X32_4X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_LM6059 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_LM6063 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGXL160_BW u8g(10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGXL160_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGXL160_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGXL160_2X_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_PCD8544 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
|
||||
//U8GLIB_PCF8812 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
|
||||
//U8GLIB_KS0108_128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs1=14, cs2=15,di=17,rw=16
|
||||
//U8GLIB_LC7981_160X80 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
|
||||
//U8GLIB_LC7981_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
|
||||
//U8GLIB_LC7981_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
|
||||
//U8GLIB_ILI9325D_320x240 u8g(18,17,19,U8G_PIN_NONE,16 ); // 8Bit Com: D0..D7: 0,1,2,3,4,5,6,7 en=wr=18, cs=17, rs=19, rd=U8G_PIN_NONE, reset = 16
|
||||
//U8GLIB_SBN1661_122X32 u8g(8,9,10,11,4,5,6,7,14,15, 17, U8G_PIN_NONE, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 cs1=14, cs2=15,di=17,rw=16,reset = 16
|
||||
//U8GLIB_SSD1306_128X64 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_SSD1306_128X64 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
|
||||
//U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
|
||||
//U8GLIB_SSD1306_128X32 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_SSD1306_128X32 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
|
||||
//U8GLIB_SSD1306_128X32 u8g(U8G_I2C_OPT_NONE); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
|
||||
//U8GLIB_SSD1309_128X64 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_SSD1327_96X96_GR u8g(U8G_I2C_OPT_NONE); // I2C
|
||||
//U8GLIB_SSD1327_96X96_2X_GR u8g(U8G_I2C_OPT_NONE); // I2C
|
||||
//U8GLIB_NHD_C12864 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
|
||||
//U8GLIB_NHD_C12832 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
|
||||
//U8GLIB_T6963_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
|
||||
//U8GLIB_T6963_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
|
||||
//U8GLIB_T6963_128X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
|
||||
|
||||
|
||||
// DOGS102 shield configuration values
|
||||
uint8_t uiKeyPrev = 2;
|
||||
uint8_t uiKeyNext = 4;
|
||||
uint8_t uiKeySelect = 5;
|
||||
uint8_t uiKeyBack = 3;
|
||||
|
||||
// DOGM128-Shield configuration values
|
||||
// DOGXL60-Shield configuration values
|
||||
//uint8_t uiKeyPrev = 7;
|
||||
//uint8_t uiKeyNext = 3;
|
||||
//uint8_t uiKeySelect = 2;
|
||||
//uint8_t uiKeyBack = 8;
|
||||
|
||||
uint8_t uiKeyCodeFirst = CHESS_KEY_NONE;
|
||||
uint8_t uiKeyCodeSecond = CHESS_KEY_NONE;
|
||||
uint8_t uiKeyCode = CHESS_KEY_NONE;
|
||||
|
||||
|
||||
void uiSetup(void) {
|
||||
// configure input keys
|
||||
|
||||
pinMode(uiKeyPrev, INPUT); // set pin to input
|
||||
digitalWrite(uiKeyPrev, HIGH); // turn on pullup resistors
|
||||
pinMode(uiKeyNext, INPUT); // set pin to input
|
||||
digitalWrite(uiKeyNext, HIGH); // turn on pullup resistors
|
||||
pinMode(uiKeySelect, INPUT); // set pin to input
|
||||
digitalWrite(uiKeySelect, HIGH); // turn on pullup resistors
|
||||
pinMode(uiKeyBack, INPUT); // set pin to input
|
||||
digitalWrite(uiKeyBack, HIGH); // turn on pullup resistors
|
||||
}
|
||||
|
||||
void uiStep(void)
|
||||
{
|
||||
uiKeyCodeSecond = uiKeyCodeFirst;
|
||||
if ( digitalRead(uiKeyPrev) == LOW )
|
||||
uiKeyCodeFirst = CHESS_KEY_PREV;
|
||||
else if ( digitalRead(uiKeyNext) == LOW )
|
||||
uiKeyCodeFirst = CHESS_KEY_NEXT;
|
||||
else if ( digitalRead(uiKeySelect) == LOW )
|
||||
uiKeyCodeFirst = CHESS_KEY_SELECT;
|
||||
else if ( digitalRead(uiKeyBack) == LOW )
|
||||
uiKeyCodeFirst = CHESS_KEY_BACK;
|
||||
else
|
||||
uiKeyCodeFirst = CHESS_KEY_NONE;
|
||||
|
||||
if ( uiKeyCodeSecond == uiKeyCodeFirst )
|
||||
uiKeyCode = uiKeyCodeFirst;
|
||||
else
|
||||
uiKeyCode = CHESS_KEY_NONE;
|
||||
}
|
||||
|
||||
|
||||
void setup() {
|
||||
// rotate screen, if required
|
||||
u8g.setRot180();
|
||||
|
||||
uiSetup();
|
||||
chess_Init(u8g.getU8g(), 0);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
uint8_t keyCode = CHESS_KEY_NONE;
|
||||
|
||||
u8g.firstPage();
|
||||
do {
|
||||
chess_Draw();
|
||||
uiStep();
|
||||
if ( uiKeyCode != CHESS_KEY_NONE )
|
||||
keyCode = uiKeyCode;
|
||||
} while( u8g.nextPage() );
|
||||
|
||||
u8g_Delay(10);
|
||||
chess_Step(keyCode);
|
||||
uiStep();
|
||||
keyCode = uiKeyCode;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,230 @@
|
||||
/*
|
||||
|
||||
Console.pde
|
||||
|
||||
Read from serial monitor, output to display
|
||||
|
||||
>>> Before compiling: Please remove comment from the constructor of the
|
||||
>>> connected graphics display (see below).
|
||||
|
||||
Universal 8bit Graphics Library, http://code.google.com/p/u8glib/
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "U8glib.h"
|
||||
|
||||
// setup u8g object, please remove comment from one of the following constructor calls
|
||||
// IMPORTANT NOTE: The complete list of supported devices is here: http://code.google.com/p/u8glib/wiki/device
|
||||
|
||||
//U8GLIB_NHD27OLED_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD27OLED_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD27OLED_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD27OLED_2X_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD31OLED_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD31OLED_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD31OLED_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD31OLED_2X_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGS102 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGM132 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGM128 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_ST7920_128X64_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_128X64_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_128X64_1X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_128X64_4X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_192X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_192X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_192X32_1X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_192X32_4X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_192X32_1X u8g(13, 11, 10); // SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10
|
||||
//U8GLIB_ST7920_192X32_4X u8g(10); // SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10, HW SPI
|
||||
//U8GLIB_ST7920_202X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_202X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_202X32_1X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_202X32_4X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_LM6059 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_LM6063 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGXL160_BW u8g(10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGXL160_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGXL160_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGXL160_2X_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_PCD8544 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
|
||||
//U8GLIB_PCF8812 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
|
||||
//U8GLIB_KS0108_128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs1=14, cs2=15,di=17,rw=16
|
||||
//U8GLIB_LC7981_160X80 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
|
||||
//U8GLIB_LC7981_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
|
||||
//U8GLIB_LC7981_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
|
||||
//U8GLIB_ILI9325D_320x240 u8g(18,17,19,U8G_PIN_NONE,16 ); // 8Bit Com: D0..D7: 0,1,2,3,4,5,6,7 en=wr=18, cs=17, rs=19, rd=U8G_PIN_NONE, reset = 16
|
||||
//U8GLIB_SBN1661_122X32 u8g(8,9,10,11,4,5,6,7,14,15, 17, U8G_PIN_NONE, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 cs1=14, cs2=15,di=17,rw=16,reset = 16
|
||||
//U8GLIB_SSD1306_128X64 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_SSD1306_128X64 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
|
||||
//U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
|
||||
//U8GLIB_SSD1306_128X32 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_SSD1306_128X32 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
|
||||
//U8GLIB_SSD1306_128X32 u8g(U8G_I2C_OPT_NONE); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
|
||||
//U8GLIB_SSD1309_128X64 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_SSD1327_96X96_GR u8g(U8G_I2C_OPT_NONE); // I2C
|
||||
//U8GLIB_SSD1327_96X96_2X_GR u8g(U8G_I2C_OPT_NONE); // I2C
|
||||
//U8GLIB_NHD_C12864 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
|
||||
//U8GLIB_NHD_C12832 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
|
||||
//U8GLIB_T6963_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
|
||||
//U8GLIB_T6963_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
|
||||
//U8GLIB_T6963_128X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
|
||||
|
||||
|
||||
// setup input buffer
|
||||
#define LINE_MAX 30
|
||||
uint8_t line_buf[LINE_MAX] = "U8GLIB Console";
|
||||
uint8_t line_pos = 0;
|
||||
|
||||
// setup a text screen to support scrolling
|
||||
#define ROW_MAX 12
|
||||
|
||||
|
||||
uint8_t screen[ROW_MAX][LINE_MAX];
|
||||
uint8_t rows, cols;
|
||||
|
||||
// line height, which matches the selected font (5x7)
|
||||
#define LINE_PIXEL_HEIGHT 7
|
||||
|
||||
// clear entire screen, called during setup
|
||||
void clear_screen(void) {
|
||||
uint8_t i, j;
|
||||
for( i = 0; i < ROW_MAX; i++ )
|
||||
for( j = 0; j < LINE_MAX; j++ )
|
||||
screen[i][j] = 0;
|
||||
}
|
||||
|
||||
// append a line to the screen, scroll up
|
||||
void add_line_to_screen(void) {
|
||||
uint8_t i, j;
|
||||
for( j = 0; j < LINE_MAX; j++ )
|
||||
for( i = 0; i < rows-1; i++ )
|
||||
screen[i][j] = screen[i+1][j];
|
||||
|
||||
for( j = 0; j < LINE_MAX; j++ )
|
||||
screen[rows-1][j] = line_buf[j];
|
||||
}
|
||||
|
||||
// U8GLIB draw procedure: output the screen
|
||||
void draw(void) {
|
||||
uint8_t i, y;
|
||||
// graphic commands to redraw the complete screen are placed here
|
||||
y = 0; // reference is the top left -1 position of the string
|
||||
y--; // correct the -1 position of the drawStr
|
||||
for( i = 0; i < rows; i++ )
|
||||
{
|
||||
u8g.drawStr( 0, y, (char *)(screen[i]));
|
||||
y += u8g.getFontLineSpacing();
|
||||
}
|
||||
}
|
||||
|
||||
void exec_line(void) {
|
||||
// echo line to the serial monitor
|
||||
Serial.println((const char *)line_buf);
|
||||
|
||||
// add the line to the screen
|
||||
add_line_to_screen();
|
||||
|
||||
// U8GLIB picture loop
|
||||
u8g.firstPage();
|
||||
do {
|
||||
draw();
|
||||
} while( u8g.nextPage() );
|
||||
}
|
||||
|
||||
// clear current input buffer
|
||||
void reset_line(void) {
|
||||
line_pos = 0;
|
||||
line_buf[line_pos] = '\0';
|
||||
}
|
||||
|
||||
// add a single character to the input buffer
|
||||
void char_to_line(uint8_t c) {
|
||||
line_buf[line_pos] = c;
|
||||
line_pos++;
|
||||
line_buf[line_pos] = '\0';
|
||||
}
|
||||
|
||||
// check serial in and handle the character
|
||||
void read_line(void) {
|
||||
if ( Serial.available() )
|
||||
{
|
||||
uint8_t c;
|
||||
c = Serial.read();
|
||||
if ( line_pos >= cols-1 ) {
|
||||
exec_line();
|
||||
reset_line();
|
||||
char_to_line(c);
|
||||
}
|
||||
else if ( c == '\n' ) {
|
||||
// ignore '\n'
|
||||
}
|
||||
else if ( c == '\r' ) {
|
||||
exec_line();
|
||||
reset_line();
|
||||
}
|
||||
else {
|
||||
char_to_line(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Arduino master setup
|
||||
void setup(void) {
|
||||
// set font for the console window
|
||||
u8g.setFont(u8g_font_5x7);
|
||||
//u8g.setFont(u8g_font_9x15);
|
||||
|
||||
// set upper left position for the string draw procedure
|
||||
u8g.setFontPosTop();
|
||||
|
||||
// calculate the number of rows for the display
|
||||
rows = u8g.getHeight() / u8g.getFontLineSpacing();
|
||||
if ( rows > ROW_MAX )
|
||||
rows = ROW_MAX;
|
||||
|
||||
// estimate the number of columns for the display
|
||||
cols = u8g.getWidth() / u8g.getStrWidth("m");
|
||||
if ( cols > LINE_MAX-1 )
|
||||
cols = LINE_MAX-1;
|
||||
|
||||
clear_screen(); // clear screen
|
||||
delay(1000); // do some delay
|
||||
Serial.begin(9600); // init serial
|
||||
exec_line(); // place the input buffer into the screen
|
||||
reset_line(); // clear input buffer
|
||||
}
|
||||
|
||||
// Arduino main loop
|
||||
void loop(void) {
|
||||
read_line();
|
||||
}
|
||||
|
@ -0,0 +1,139 @@
|
||||
/*
|
||||
|
||||
F.pde
|
||||
|
||||
Example code for the F() macro.
|
||||
|
||||
>>> This example requires Arduino 1.0 and above.
|
||||
|
||||
>>> Before compiling: Please remove comment from the constructor of the
|
||||
>>> connected graphics display (see below).
|
||||
|
||||
Universal 8bit Graphics Library, http://code.google.com/p/u8glib/
|
||||
|
||||
Copyright (c) 2012, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "U8glib.h"
|
||||
|
||||
// setup u8g object, please remove comment from one of the following constructor calls
|
||||
// IMPORTANT NOTE: The complete list of supported devices is here: http://code.google.com/p/u8glib/wiki/device
|
||||
|
||||
//U8GLIB_NHD27OLED_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD27OLED_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD27OLED_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD27OLED_2X_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD31OLED_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD31OLED_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD31OLED_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD31OLED_2X_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGS102 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGM132 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGM128 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_ST7920_128X64_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_128X64_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_128X64_1X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_128X64_4X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_192X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_192X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_192X32_1X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_192X32_4X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_192X32_1X u8g(13, 11, 10); // SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10
|
||||
//U8GLIB_ST7920_192X32_4X u8g(10); // SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10, HW SPI
|
||||
//U8GLIB_ST7920_202X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_202X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_202X32_1X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_202X32_4X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_LM6059 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_LM6063 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGXL160_BW u8g(10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGXL160_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGXL160_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGXL160_2X_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_PCD8544 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
|
||||
//U8GLIB_PCF8812 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
|
||||
//U8GLIB_KS0108_128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs1=14, cs2=15,di=17,rw=16
|
||||
//U8GLIB_LC7981_160X80 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
|
||||
//U8GLIB_LC7981_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
|
||||
//U8GLIB_LC7981_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
|
||||
//U8GLIB_ILI9325D_320x240 u8g(18,17,19,U8G_PIN_NONE,16 ); // 8Bit Com: D0..D7: 0,1,2,3,4,5,6,7 en=wr=18, cs=17, rs=19, rd=U8G_PIN_NONE, reset = 16
|
||||
//U8GLIB_SBN1661_122X32 u8g(8,9,10,11,4,5,6,7,14,15, 17, U8G_PIN_NONE, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 cs1=14, cs2=15,di=17,rw=16,reset = 16
|
||||
//U8GLIB_SSD1306_128X64 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_SSD1306_128X64 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
|
||||
//U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
|
||||
//U8GLIB_SSD1306_128X32 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_SSD1306_128X32 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
|
||||
//U8GLIB_SSD1306_128X32 u8g(U8G_I2C_OPT_NONE); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
|
||||
//U8GLIB_SSD1309_128X64 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_SSD1327_96X96_GR u8g(U8G_I2C_OPT_NONE); // I2C
|
||||
//U8GLIB_SSD1327_96X96_2X_GR u8g(U8G_I2C_OPT_NONE); // I2C
|
||||
//U8GLIB_NHD_C12864 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
|
||||
//U8GLIB_NHD_C12832 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
|
||||
//U8GLIB_T6963_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
|
||||
//U8GLIB_T6963_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
|
||||
//U8GLIB_T6963_128X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
|
||||
|
||||
void draw(void) {
|
||||
// graphic commands to redraw the complete screen should be placed here
|
||||
|
||||
// assign default font
|
||||
u8g.setFont(u8g_font_unifont);
|
||||
|
||||
// pointer to strings in flash memory can be stored in a special type
|
||||
const __FlashStringHelper *flash_ptr;
|
||||
|
||||
// the result of the F() macro can be assigned to this pointer
|
||||
flash_ptr = F("Hello World!");
|
||||
|
||||
// this pointer can be used as argument to the draw procedures
|
||||
u8g.drawStr( 0+1, 20+1, flash_ptr);
|
||||
u8g.drawStr( 0, 20, flash_ptr);
|
||||
|
||||
// of course, the F() macro can be used directly
|
||||
u8g.drawStr( 0, 40, F("PROGMEM"));
|
||||
|
||||
}
|
||||
|
||||
void setup(void) {
|
||||
// flip screen, if required
|
||||
// u8g.setRot180();
|
||||
}
|
||||
|
||||
void loop(void) {
|
||||
// picture loop
|
||||
u8g.firstPage();
|
||||
do {
|
||||
draw();
|
||||
} while( u8g.nextPage() );
|
||||
|
||||
// rebuild the picture after some delay
|
||||
delay(500);
|
||||
}
|
||||
|
@ -0,0 +1,223 @@
|
||||
/*
|
||||
|
||||
GraphicsTest.pde
|
||||
|
||||
>>> Before compiling: Please remove comment from the constructor of the
|
||||
>>> connected graphics display (see below).
|
||||
|
||||
Universal 8bit Graphics Library, http://code.google.com/p/u8glib/
|
||||
|
||||
Copyright (c) 2012, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "U8glib.h"
|
||||
|
||||
// setup u8g object, please remove comment from one of the following constructor calls
|
||||
// IMPORTANT NOTE: The complete list of supported devices is here: http://code.google.com/p/u8glib/wiki/device
|
||||
|
||||
//U8GLIB_NHD27OLED_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD27OLED_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD27OLED_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD27OLED_2X_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD31OLED_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD31OLED_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD31OLED_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD31OLED_2X_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGS102 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGM132 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGM128 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_ST7920_128X64_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_128X64_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_128X64_1X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_128X64_4X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_192X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_192X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_192X32_1X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_192X32_4X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_192X32_1X u8g(13, 11, 10); // SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10
|
||||
//U8GLIB_ST7920_192X32_4X u8g(10); // SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10, HW SPI
|
||||
//U8GLIB_ST7920_202X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_202X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_202X32_1X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_202X32_4X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_LM6059 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_LM6063 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGXL160_BW u8g(10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGXL160_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGXL160_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGXL160_2X_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_PCD8544 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
|
||||
//U8GLIB_PCF8812 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
|
||||
//U8GLIB_KS0108_128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs1=14, cs2=15,di=17,rw=16
|
||||
//U8GLIB_LC7981_160X80 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
|
||||
//U8GLIB_LC7981_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
|
||||
//U8GLIB_LC7981_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
|
||||
//U8GLIB_ILI9325D_320x240 u8g(18,17,19,U8G_PIN_NONE,16 ); // 8Bit Com: D0..D7: 0,1,2,3,4,5,6,7 en=wr=18, cs=17, rs=19, rd=U8G_PIN_NONE, reset = 16
|
||||
//U8GLIB_SBN1661_122X32 u8g(8,9,10,11,4,5,6,7,14,15, 17, U8G_PIN_NONE, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 cs1=14, cs2=15,di=17,rw=16,reset = 16
|
||||
//U8GLIB_SSD1306_128X64 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_SSD1306_128X64 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
|
||||
//U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
|
||||
//U8GLIB_SSD1306_128X32 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_SSD1306_128X32 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
|
||||
//U8GLIB_SSD1306_128X32 u8g(U8G_I2C_OPT_NONE); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
|
||||
//U8GLIB_SSD1309_128X64 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_SSD1327_96X96_GR u8g(U8G_I2C_OPT_NONE); // I2C
|
||||
//U8GLIB_SSD1327_96X96_2X_GR u8g(U8G_I2C_OPT_NONE); // I2C
|
||||
//U8GLIB_NHD_C12864 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
|
||||
//U8GLIB_NHD_C12832 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
|
||||
//U8GLIB_T6963_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
|
||||
//U8GLIB_T6963_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
|
||||
//U8GLIB_T6963_128X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
|
||||
|
||||
void u8g_prepare(void) {
|
||||
u8g.setFont(u8g_font_6x10);
|
||||
u8g.setFontRefHeightExtendedText();
|
||||
u8g.setDefaultForegroundColor();
|
||||
u8g.setFontPosTop();
|
||||
}
|
||||
|
||||
void u8g_box_frame(uint8_t a) {
|
||||
u8g.drawStr( 0, 0, "drawBox");
|
||||
u8g.drawBox(5,10,20,10);
|
||||
u8g.drawBox(10+a,15,30,7);
|
||||
u8g.drawStr( 0, 30, "drawFrame");
|
||||
u8g.drawFrame(5,10+30,20,10);
|
||||
u8g.drawFrame(10+a,15+30,30,7);
|
||||
}
|
||||
|
||||
void u8g_disc_circle(uint8_t a) {
|
||||
u8g.drawStr( 0, 0, "drawDisc");
|
||||
u8g.drawDisc(10,18,9);
|
||||
u8g.drawDisc(24+a,16,7);
|
||||
u8g.drawStr( 0, 30, "drawCircle");
|
||||
u8g.drawCircle(10,18+30,9);
|
||||
u8g.drawCircle(24+a,16+30,7);
|
||||
}
|
||||
|
||||
void u8g_r_frame(uint8_t a) {
|
||||
u8g.drawStr( 0, 0, "drawRFrame/Box");
|
||||
u8g.drawRFrame(5, 10,40,30, a+1);
|
||||
u8g.drawRBox(50, 10,25,40, a+1);
|
||||
}
|
||||
|
||||
void u8g_string(uint8_t a) {
|
||||
u8g.drawStr(30+a,31, " 0");
|
||||
u8g.drawStr90(30,31+a, " 90");
|
||||
u8g.drawStr180(30-a,31, " 180");
|
||||
u8g.drawStr270(30,31-a, " 270");
|
||||
}
|
||||
|
||||
void u8g_line(uint8_t a) {
|
||||
u8g.drawStr( 0, 0, "drawLine");
|
||||
u8g.drawLine(7+a, 10, 40, 55);
|
||||
u8g.drawLine(7+a*2, 10, 60, 55);
|
||||
u8g.drawLine(7+a*3, 10, 80, 55);
|
||||
u8g.drawLine(7+a*4, 10, 100, 55);
|
||||
}
|
||||
|
||||
void u8g_ascii_1() {
|
||||
char s[2] = " ";
|
||||
uint8_t x, y;
|
||||
u8g.drawStr( 0, 0, "ASCII page 1");
|
||||
for( y = 0; y < 6; y++ ) {
|
||||
for( x = 0; x < 16; x++ ) {
|
||||
s[0] = y*16 + x + 32;
|
||||
u8g.drawStr(x*7, y*10+10, s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void u8g_ascii_2() {
|
||||
char s[2] = " ";
|
||||
uint8_t x, y;
|
||||
u8g.drawStr( 0, 0, "ASCII page 2");
|
||||
for( y = 0; y < 6; y++ ) {
|
||||
for( x = 0; x < 16; x++ ) {
|
||||
s[0] = y*16 + x + 160;
|
||||
u8g.drawStr(x*7, y*10+10, s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
uint8_t draw_state = 0;
|
||||
|
||||
void draw(void) {
|
||||
u8g_prepare();
|
||||
switch(draw_state >> 3) {
|
||||
case 0: u8g_box_frame(draw_state&7); break;
|
||||
case 1: u8g_disc_circle(draw_state&7); break;
|
||||
case 2: u8g_r_frame(draw_state&7); break;
|
||||
case 3: u8g_string(draw_state&7); break;
|
||||
case 4: u8g_line(draw_state&7); break;
|
||||
case 5: u8g_ascii_1(); break;
|
||||
case 6: u8g_ascii_2(); break;
|
||||
}
|
||||
}
|
||||
|
||||
void setup(void) {
|
||||
|
||||
// flip screen, if required
|
||||
//u8g.setRot180();
|
||||
|
||||
// assign default color value
|
||||
if ( u8g.getMode() == U8G_MODE_R3G3B2 )
|
||||
u8g.setColorIndex(255); // white
|
||||
else if ( u8g.getMode() == U8G_MODE_GRAY2BIT )
|
||||
u8g.setColorIndex(3); // max intensity
|
||||
else if ( u8g.getMode() == U8G_MODE_BW )
|
||||
u8g.setColorIndex(1); // pixel on
|
||||
|
||||
//u8g.setContrast(0x30);
|
||||
|
||||
pinMode(13, OUTPUT);
|
||||
digitalWrite(13, HIGH);
|
||||
}
|
||||
|
||||
void loop(void) {
|
||||
|
||||
// picture loop
|
||||
u8g.firstPage();
|
||||
do {
|
||||
draw();
|
||||
} while( u8g.nextPage() );
|
||||
|
||||
// increase the state
|
||||
draw_state++;
|
||||
if ( draw_state >= 7*8 )
|
||||
draw_state = 0;
|
||||
|
||||
// rebuild the picture after some delay
|
||||
delay(150);
|
||||
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,136 @@
|
||||
/*
|
||||
|
||||
HelloWorld.pde
|
||||
|
||||
"Hello World!" example code.
|
||||
|
||||
>>> Before compiling: Please remove comment from the constructor of the
|
||||
>>> connected graphics display (see below).
|
||||
|
||||
Universal 8bit Graphics Library, http://code.google.com/p/u8glib/
|
||||
|
||||
Copyright (c) 2012, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "U8glib.h"
|
||||
|
||||
// setup u8g object, please remove comment from one of the following constructor calls
|
||||
// IMPORTANT NOTE: The complete list of supported devices is here: http://code.google.com/p/u8glib/wiki/device
|
||||
|
||||
//U8GLIB_NHD27OLED_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD27OLED_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD27OLED_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD27OLED_2X_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD31OLED_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD31OLED_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD31OLED_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD31OLED_2X_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGS102 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGM132 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGM128 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_ST7920_128X64_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_128X64_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_128X64_1X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_128X64_4X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_192X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_192X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_192X32_1X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_192X32_4X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_192X32_1X u8g(13, 11, 10); // SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10
|
||||
//U8GLIB_ST7920_192X32_4X u8g(10); // SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10, HW SPI
|
||||
//U8GLIB_ST7920_202X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_202X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_202X32_1X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_202X32_4X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_LM6059 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_LM6063 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGXL160_BW u8g(10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGXL160_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGXL160_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGXL160_2X_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_PCD8544 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
|
||||
//U8GLIB_PCF8812 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
|
||||
//U8GLIB_KS0108_128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs1=14, cs2=15,di=17,rw=16
|
||||
//U8GLIB_LC7981_160X80 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
|
||||
//U8GLIB_LC7981_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
|
||||
//U8GLIB_LC7981_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
|
||||
//U8GLIB_ILI9325D_320x240 u8g(18,17,19,U8G_PIN_NONE,16 ); // 8Bit Com: D0..D7: 0,1,2,3,4,5,6,7 en=wr=18, cs=17, rs=19, rd=U8G_PIN_NONE, reset = 16
|
||||
//U8GLIB_SBN1661_122X32 u8g(8,9,10,11,4,5,6,7,14,15, 17, U8G_PIN_NONE, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 cs1=14, cs2=15,di=17,rw=16,reset = 16
|
||||
//U8GLIB_SSD1306_128X64 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_SSD1306_128X64 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
|
||||
//U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
|
||||
//U8GLIB_SSD1306_128X32 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_SSD1306_128X32 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
|
||||
//U8GLIB_SSD1306_128X32 u8g(U8G_I2C_OPT_NONE); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
|
||||
//U8GLIB_SSD1309_128X64 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_SSD1327_96X96_GR u8g(U8G_I2C_OPT_NONE); // I2C
|
||||
//U8GLIB_SSD1327_96X96_2X_GR u8g(U8G_I2C_OPT_NONE); // I2C
|
||||
//U8GLIB_NHD_C12864 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
|
||||
//U8GLIB_NHD_C12832 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
|
||||
//U8GLIB_T6963_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
|
||||
//U8GLIB_T6963_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
|
||||
//U8GLIB_T6963_128X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
|
||||
|
||||
|
||||
void draw(void) {
|
||||
// graphic commands to redraw the complete screen should be placed here
|
||||
u8g.setFont(u8g_font_unifont);
|
||||
//u8g.setFont(u8g_font_osb21);
|
||||
u8g.drawStr( 0, 22, "Hello World!");
|
||||
}
|
||||
|
||||
void setup(void) {
|
||||
|
||||
// flip screen, if required
|
||||
// u8g.setRot180();
|
||||
|
||||
// set SPI backup if required
|
||||
//u8g.setHardwareBackup(u8g_backup_avr_spi);
|
||||
|
||||
// assign default color value
|
||||
if ( u8g.getMode() == U8G_MODE_R3G3B2 )
|
||||
u8g.setColorIndex(255); // white
|
||||
else if ( u8g.getMode() == U8G_MODE_GRAY2BIT )
|
||||
u8g.setColorIndex(3); // max intensity
|
||||
else if ( u8g.getMode() == U8G_MODE_BW )
|
||||
u8g.setColorIndex(1); // pixel on
|
||||
}
|
||||
|
||||
void loop(void) {
|
||||
// picture loop
|
||||
u8g.firstPage();
|
||||
do {
|
||||
draw();
|
||||
} while( u8g.nextPage() );
|
||||
|
||||
// rebuild the picture after some delay
|
||||
delay(500);
|
||||
}
|
||||
|
@ -0,0 +1,234 @@
|
||||
/*
|
||||
|
||||
Menu.pde
|
||||
|
||||
Simple Menu Selection
|
||||
|
||||
>>> Before compiling: Please remove comment from the constructor of the
|
||||
>>> connected graphics display (see below).
|
||||
|
||||
Universal 8bit Graphics Library, http://code.google.com/p/u8glib/
|
||||
|
||||
Copyright (c) 2012, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "U8glib.h"
|
||||
|
||||
// setup u8g object, please remove comment from one of the following constructor calls
|
||||
// IMPORTANT NOTE: The complete list of supported devices is here: http://code.google.com/p/u8glib/wiki/device
|
||||
|
||||
//U8GLIB_NHD27OLED_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD27OLED_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD27OLED_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD27OLED_2X_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD31OLED_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD31OLED_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD31OLED_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD31OLED_2X_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGS102 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGM132 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGM128 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_ST7920_128X64_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_128X64_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_128X64_1X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_128X64_4X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_192X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_192X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_192X32_1X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_192X32_4X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_192X32_1X u8g(13, 11, 10); // SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10
|
||||
//U8GLIB_ST7920_192X32_4X u8g(10); // SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10, HW SPI
|
||||
//U8GLIB_ST7920_202X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_202X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_202X32_1X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_202X32_4X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_LM6059 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_LM6063 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGXL160_BW u8g(10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGXL160_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGXL160_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGXL160_2X_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_PCD8544 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
|
||||
//U8GLIB_PCF8812 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
|
||||
//U8GLIB_KS0108_128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs1=14, cs2=15,di=17,rw=16
|
||||
//U8GLIB_LC7981_160X80 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
|
||||
//U8GLIB_LC7981_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
|
||||
//U8GLIB_LC7981_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
|
||||
//U8GLIB_ILI9325D_320x240 u8g(18,17,19,U8G_PIN_NONE,16 ); // 8Bit Com: D0..D7: 0,1,2,3,4,5,6,7 en=wr=18, cs=17, rs=19, rd=U8G_PIN_NONE, reset = 16
|
||||
//U8GLIB_SBN1661_122X32 u8g(8,9,10,11,4,5,6,7,14,15, 17, U8G_PIN_NONE, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 cs1=14, cs2=15,di=17,rw=16,reset = 16
|
||||
//U8GLIB_SSD1306_128X64 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_SSD1306_128X64 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
|
||||
//U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
|
||||
//U8GLIB_SSD1306_128X32 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_SSD1306_128X32 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
|
||||
//U8GLIB_SSD1306_128X32 u8g(U8G_I2C_OPT_NONE); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
|
||||
//U8GLIB_SSD1309_128X64 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_SSD1327_96X96_GR u8g(U8G_I2C_OPT_NONE); // I2C
|
||||
//U8GLIB_SSD1327_96X96_2X_GR u8g(U8G_I2C_OPT_NONE); // I2C
|
||||
//U8GLIB_NHD_C12864 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
|
||||
//U8GLIB_NHD_C12832 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
|
||||
//U8GLIB_T6963_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
|
||||
//U8GLIB_T6963_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
|
||||
//U8GLIB_T6963_128X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
|
||||
|
||||
|
||||
#define KEY_NONE 0
|
||||
#define KEY_PREV 1
|
||||
#define KEY_NEXT 2
|
||||
#define KEY_SELECT 3
|
||||
#define KEY_BACK 4
|
||||
|
||||
// DOGS102 shield configuration values
|
||||
//uint8_t uiKeyPrev = 2;
|
||||
//uint8_t uiKeyNext = 4;
|
||||
//uint8_t uiKeySelect = 5;
|
||||
//uint8_t uiKeyBack = 3;
|
||||
|
||||
// DOGM128-Shield configuration values
|
||||
// DOGXL60-Shield configuration values
|
||||
uint8_t uiKeyPrev = 7;
|
||||
uint8_t uiKeyNext = 3;
|
||||
uint8_t uiKeySelect = 2;
|
||||
uint8_t uiKeyBack = 8;
|
||||
|
||||
uint8_t uiKeyCodeFirst = KEY_NONE;
|
||||
uint8_t uiKeyCodeSecond = KEY_NONE;
|
||||
uint8_t uiKeyCode = KEY_NONE;
|
||||
|
||||
|
||||
void uiSetup(void) {
|
||||
// configure input keys
|
||||
|
||||
pinMode(uiKeyPrev, INPUT); // set pin to input
|
||||
digitalWrite(uiKeyPrev, HIGH); // turn on pullup resistors
|
||||
pinMode(uiKeyNext, INPUT); // set pin to input
|
||||
digitalWrite(uiKeyNext, HIGH); // turn on pullup resistors
|
||||
pinMode(uiKeySelect, INPUT); // set pin to input
|
||||
digitalWrite(uiKeySelect, HIGH); // turn on pullup resistors
|
||||
pinMode(uiKeyBack, INPUT); // set pin to input
|
||||
digitalWrite(uiKeyBack, HIGH); // turn on pullup resistors
|
||||
}
|
||||
|
||||
void uiStep(void) {
|
||||
uiKeyCodeSecond = uiKeyCodeFirst;
|
||||
if ( digitalRead(uiKeyPrev) == LOW )
|
||||
uiKeyCodeFirst = KEY_PREV;
|
||||
else if ( digitalRead(uiKeyNext) == LOW )
|
||||
uiKeyCodeFirst = KEY_NEXT;
|
||||
else if ( digitalRead(uiKeySelect) == LOW )
|
||||
uiKeyCodeFirst = KEY_SELECT;
|
||||
else if ( digitalRead(uiKeyBack) == LOW )
|
||||
uiKeyCodeFirst = KEY_BACK;
|
||||
else
|
||||
uiKeyCodeFirst = KEY_NONE;
|
||||
|
||||
if ( uiKeyCodeSecond == uiKeyCodeFirst )
|
||||
uiKeyCode = uiKeyCodeFirst;
|
||||
else
|
||||
uiKeyCode = KEY_NONE;
|
||||
}
|
||||
|
||||
|
||||
#define MENU_ITEMS 4
|
||||
char *menu_strings[MENU_ITEMS] = { "First Line", "Second Item", "3333333", "abcdefg" };
|
||||
|
||||
uint8_t menu_current = 0;
|
||||
uint8_t menu_redraw_required = 0;
|
||||
uint8_t last_key_code = KEY_NONE;
|
||||
|
||||
|
||||
void drawMenu(void) {
|
||||
uint8_t i, h;
|
||||
u8g_uint_t w, d;
|
||||
|
||||
u8g.setFont(u8g_font_6x13);
|
||||
u8g.setFontRefHeightText();
|
||||
u8g.setFontPosTop();
|
||||
|
||||
h = u8g.getFontAscent()-u8g.getFontDescent();
|
||||
w = u8g.getWidth();
|
||||
for( i = 0; i < MENU_ITEMS; i++ ) {
|
||||
d = (w-u8g.getStrWidth(menu_strings[i]))/2;
|
||||
u8g.setDefaultForegroundColor();
|
||||
if ( i == menu_current ) {
|
||||
u8g.drawBox(0, i*h+1, w, h);
|
||||
u8g.setDefaultBackgroundColor();
|
||||
}
|
||||
u8g.drawStr(d, i*h, menu_strings[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void updateMenu(void) {
|
||||
if ( uiKeyCode != KEY_NONE && last_key_code == uiKeyCode ) {
|
||||
return;
|
||||
}
|
||||
last_key_code = uiKeyCode;
|
||||
|
||||
switch ( uiKeyCode ) {
|
||||
case KEY_NEXT:
|
||||
menu_current++;
|
||||
if ( menu_current >= MENU_ITEMS )
|
||||
menu_current = 0;
|
||||
menu_redraw_required = 1;
|
||||
break;
|
||||
case KEY_PREV:
|
||||
if ( menu_current == 0 )
|
||||
menu_current = MENU_ITEMS;
|
||||
menu_current--;
|
||||
menu_redraw_required = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void setup() {
|
||||
// rotate screen, if required
|
||||
// u8g.setRot180();
|
||||
|
||||
uiSetup(); // setup key detection and debounce algorithm
|
||||
menu_redraw_required = 1; // force initial redraw
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
uiStep(); // check for key press
|
||||
|
||||
if ( menu_redraw_required != 0 ) {
|
||||
u8g.firstPage();
|
||||
do {
|
||||
drawMenu();
|
||||
} while( u8g.nextPage() );
|
||||
menu_redraw_required = 0;
|
||||
}
|
||||
|
||||
updateMenu(); // update menu bar
|
||||
|
||||
}
|
@ -0,0 +1,124 @@
|
||||
/*
|
||||
|
||||
PrintTest.pde
|
||||
|
||||
How to use the base class "Print"
|
||||
|
||||
>>> Before compiling: Please remove comment from the constructor of the
|
||||
>>> connected graphics display (see below).
|
||||
|
||||
Universal 8bit Graphics Library, http://code.google.com/p/u8glib/
|
||||
|
||||
Copyright (c) 2012, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "U8glib.h"
|
||||
|
||||
// setup u8g object, please remove comment from one of the following constructor calls
|
||||
// IMPORTANT NOTE: The complete list of supported devices is here: http://code.google.com/p/u8glib/wiki/device
|
||||
|
||||
//U8GLIB_NHD27OLED_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD27OLED_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD27OLED_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD27OLED_2X_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD31OLED_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD31OLED_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD31OLED_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD31OLED_2X_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGS102 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGM132 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGM128 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_ST7920_128X64_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_128X64_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_128X64_1X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_128X64_4X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_192X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_192X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_192X32_1X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_192X32_4X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_192X32_1X u8g(13, 11, 10); // SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10
|
||||
//U8GLIB_ST7920_192X32_4X u8g(10); // SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10, HW SPI
|
||||
//U8GLIB_ST7920_202X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_202X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_202X32_1X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_202X32_4X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_LM6059 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_LM6063 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGXL160_BW u8g(10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGXL160_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGXL160_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGXL160_2X_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_PCD8544 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
|
||||
//U8GLIB_PCF8812 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
|
||||
//U8GLIB_KS0108_128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs1=14, cs2=15,di=17,rw=16
|
||||
//U8GLIB_LC7981_160X80 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
|
||||
//U8GLIB_LC7981_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
|
||||
//U8GLIB_LC7981_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
|
||||
//U8GLIB_ILI9325D_320x240 u8g(18,17,19,U8G_PIN_NONE,16 ); // 8Bit Com: D0..D7: 0,1,2,3,4,5,6,7 en=wr=18, cs=17, rs=19, rd=U8G_PIN_NONE, reset = 16
|
||||
//U8GLIB_SBN1661_122X32 u8g(8,9,10,11,4,5,6,7,14,15, 17, U8G_PIN_NONE, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 cs1=14, cs2=15,di=17,rw=16,reset = 16
|
||||
//U8GLIB_SSD1306_128X64 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_SSD1306_128X64 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
|
||||
//U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
|
||||
//U8GLIB_SSD1306_128X32 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_SSD1306_128X32 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
|
||||
//U8GLIB_SSD1306_128X32 u8g(U8G_I2C_OPT_NONE); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
|
||||
//U8GLIB_SSD1309_128X64 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_SSD1327_96X96_GR u8g(U8G_I2C_OPT_NONE); // I2C
|
||||
//U8GLIB_SSD1327_96X96_2X_GR u8g(U8G_I2C_OPT_NONE); // I2C
|
||||
//U8GLIB_NHD_C12864 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
|
||||
//U8GLIB_NHD_C12832 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
|
||||
//U8GLIB_T6963_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
|
||||
//U8GLIB_T6963_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
|
||||
//U8GLIB_T6963_128X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
|
||||
|
||||
void draw(void) {
|
||||
// graphic commands to redraw the complete screen should be placed here
|
||||
u8g.setFont(u8g_font_unifont);
|
||||
u8g.setPrintPos(0, 20);
|
||||
// call procedure from base class, http://arduino.cc/en/Serial/Print
|
||||
u8g.print("Hello World!");
|
||||
}
|
||||
|
||||
void setup(void) {
|
||||
// flip screen, if required
|
||||
// u8g.setRot180();
|
||||
}
|
||||
|
||||
void loop(void) {
|
||||
// picture loop
|
||||
u8g.firstPage();
|
||||
do {
|
||||
draw();
|
||||
} while( u8g.nextPage() );
|
||||
|
||||
// rebuild the picture after some delay
|
||||
delay(500);
|
||||
}
|
||||
|
@ -0,0 +1,152 @@
|
||||
/*
|
||||
|
||||
HelloWorld.pde
|
||||
|
||||
"Hello World!" example code.
|
||||
|
||||
>>> Before compiling: Please remove comment from the constructor of the
|
||||
>>> connected graphics display (see below).
|
||||
|
||||
Universal 8bit Graphics Library, http://code.google.com/p/u8glib/
|
||||
|
||||
Copyright (c) 2012, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "U8glib.h"
|
||||
|
||||
// setup u8g object, please remove comment from one of the following constructor calls
|
||||
// IMPORTANT NOTE: The complete list of supported devices is here: http://code.google.com/p/u8glib/wiki/device
|
||||
|
||||
//U8GLIB_NHD27OLED_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD27OLED_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD27OLED_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD27OLED_2X_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD31OLED_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD31OLED_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD31OLED_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD31OLED_2X_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGS102 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGM132 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGM128 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_ST7920_128X64_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_128X64_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_128X64_1X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_128X64_4X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_192X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_192X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_192X32_1X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_192X32_4X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_192X32_1X u8g(13, 11, 10); // SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10
|
||||
//U8GLIB_ST7920_192X32_4X u8g(10); // SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10, HW SPI
|
||||
//U8GLIB_ST7920_202X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_202X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_202X32_1X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_202X32_4X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_LM6059 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_LM6063 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGXL160_BW u8g(10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGXL160_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGXL160_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGXL160_2X_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_PCD8544 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
|
||||
//U8GLIB_PCF8812 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
|
||||
//U8GLIB_KS0108_128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs1=14, cs2=15,di=17,rw=16
|
||||
//U8GLIB_LC7981_160X80 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
|
||||
//U8GLIB_LC7981_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
|
||||
//U8GLIB_LC7981_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
|
||||
//U8GLIB_ILI9325D_320x240 u8g(18,17,19,U8G_PIN_NONE,16 ); // 8Bit Com: D0..D7: 0,1,2,3,4,5,6,7 en=wr=18, cs=17, rs=19, rd=U8G_PIN_NONE, reset = 16
|
||||
//U8GLIB_SBN1661_122X32 u8g(8,9,10,11,4,5,6,7,14,15, 17, U8G_PIN_NONE, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 cs1=14, cs2=15,di=17,rw=16,reset = 16
|
||||
//U8GLIB_SSD1306_128X64 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_SSD1306_128X64 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
|
||||
//U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
|
||||
//U8GLIB_SSD1306_128X32 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_SSD1306_128X32 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
|
||||
//U8GLIB_SSD1306_128X32 u8g(U8G_I2C_OPT_NONE); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
|
||||
//U8GLIB_SSD1309_128X64 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_SSD1327_96X96_GR u8g(U8G_I2C_OPT_NONE); // I2C
|
||||
//U8GLIB_SSD1327_96X96_2X_GR u8g(U8G_I2C_OPT_NONE); // I2C
|
||||
//U8GLIB_NHD_C12864 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
|
||||
//U8GLIB_NHD_C12832 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
|
||||
//U8GLIB_T6963_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
|
||||
//U8GLIB_T6963_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
|
||||
//U8GLIB_T6963_128X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
|
||||
|
||||
uint8_t offset = 0;
|
||||
|
||||
void draw(void) {
|
||||
// graphic commands to redraw the complete screen should be placed here
|
||||
u8g.setFont(u8g_font_unifont);
|
||||
u8g.drawStr( 0+0, 20+0, "Hello!");
|
||||
u8g.drawStr( 0+2, 20+16, "Hello!");
|
||||
|
||||
u8g.drawBox(0, 0, 3, 3);
|
||||
u8g.drawBox(u8g.getWidth()-6, 0, 6, 6);
|
||||
u8g.drawBox(u8g.getWidth()-9, u8g.getHeight()-9, 9, 9);
|
||||
u8g.drawBox(0, u8g.getHeight()-12, 12, 12);
|
||||
}
|
||||
|
||||
void setup(void) {
|
||||
}
|
||||
|
||||
|
||||
void rotate(void) {
|
||||
static uint8_t dir = 0;
|
||||
static unsigned long next_rotation = 0;
|
||||
|
||||
if ( next_rotation < millis() )
|
||||
{
|
||||
switch(dir) {
|
||||
case 0: u8g.undoRotation(); break;
|
||||
case 1: u8g.setRot90(); break;
|
||||
case 2: u8g.setRot180(); break;
|
||||
case 3: u8g.setRot270(); offset = ( offset + 1 ) & 0x0f; break;
|
||||
}
|
||||
|
||||
dir++;
|
||||
dir &= 3;
|
||||
next_rotation = millis();
|
||||
next_rotation += 1000;
|
||||
}
|
||||
}
|
||||
|
||||
void loop(void) {
|
||||
// screen rotation
|
||||
rotate();
|
||||
|
||||
// picture loop
|
||||
u8g.firstPage();
|
||||
do {
|
||||
draw();
|
||||
} while( u8g.nextPage() );
|
||||
|
||||
// rebuild the picture after some delay
|
||||
delay(100);
|
||||
}
|
||||
|
@ -0,0 +1,141 @@
|
||||
/*
|
||||
|
||||
HelloWorld.pde
|
||||
|
||||
"Hello World!" example code.
|
||||
|
||||
>>> Before compiling: Please remove comment from the constructor of the
|
||||
>>> connected graphics display (see below).
|
||||
|
||||
Universal 8bit Graphics Library, http://code.google.com/p/u8glib/
|
||||
|
||||
Copyright (c) 2012, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "U8glib.h"
|
||||
|
||||
// setup u8g object, please remove comment from one of the following constructor calls
|
||||
// IMPORTANT NOTE: The complete list of supported devices is here: http://code.google.com/p/u8glib/wiki/device
|
||||
|
||||
//U8GLIB_NHD27OLED_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD27OLED_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD27OLED_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD27OLED_2X_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD31OLED_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD31OLED_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD31OLED_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD31OLED_2X_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGS102 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGM132 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGM128 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_ST7920_128X64_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_128X64_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_128X64_1X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_128X64_4X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_192X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_192X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_192X32_1X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_192X32_4X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_192X32_1X u8g(13, 11, 10); // SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10
|
||||
//U8GLIB_ST7920_192X32_4X u8g(10); // SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10, HW SPI
|
||||
//U8GLIB_ST7920_202X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_202X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_202X32_1X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_202X32_4X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_LM6059 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_LM6063 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGXL160_BW u8g(10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGXL160_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGXL160_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGXL160_2X_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_PCD8544 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
|
||||
//U8GLIB_PCF8812 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
|
||||
//U8GLIB_KS0108_128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs1=14, cs2=15,di=17,rw=16
|
||||
//U8GLIB_LC7981_160X80 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
|
||||
//U8GLIB_LC7981_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
|
||||
//U8GLIB_LC7981_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
|
||||
//U8GLIB_ILI9325D_320x240 u8g(18,17,19,U8G_PIN_NONE,16 ); // 8Bit Com: D0..D7: 0,1,2,3,4,5,6,7 en=wr=18, cs=17, rs=19, rd=U8G_PIN_NONE, reset = 16
|
||||
//U8GLIB_SBN1661_122X32 u8g(8,9,10,11,4,5,6,7,14,15, 17, U8G_PIN_NONE, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 cs1=14, cs2=15,di=17,rw=16,reset = 16
|
||||
//U8GLIB_SSD1306_128X64 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_SSD1306_128X64 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
|
||||
//U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
|
||||
//U8GLIB_SSD1306_128X32 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_SSD1306_128X32 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
|
||||
//U8GLIB_SSD1306_128X32 u8g(U8G_I2C_OPT_NONE); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
|
||||
//U8GLIB_SSD1309_128X64 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_SSD1327_96X96_GR u8g(U8G_I2C_OPT_NONE); // I2C
|
||||
//U8GLIB_SSD1327_96X96_2X_GR u8g(U8G_I2C_OPT_NONE); // I2C
|
||||
//U8GLIB_NHD_C12864 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
|
||||
//U8GLIB_NHD_C12832 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
|
||||
//U8GLIB_T6963_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
|
||||
//U8GLIB_T6963_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
|
||||
//U8GLIB_T6963_128X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
|
||||
|
||||
|
||||
void draw(void) {
|
||||
// graphic commands to redraw the complete screen should be placed here
|
||||
u8g.setFont(u8g_font_unifont);
|
||||
u8g.setFontPosTop();
|
||||
u8g.drawStr(0, 1, "Hello");
|
||||
u8g.drawHLine(0, 1+14, 40);
|
||||
u8g.setScale2x2(); // Scale up all draw procedures
|
||||
u8g.drawStr(0, 12, "Hello"); // actual display position is (0,24)
|
||||
u8g.drawHLine(0, 12+14, 40); // All other procedures are also affected
|
||||
u8g.undoScale(); // IMPORTANT: Switch back to normal mode
|
||||
}
|
||||
|
||||
void setup(void) {
|
||||
|
||||
// flip screen, if required
|
||||
u8g.setRot180();
|
||||
|
||||
// set SPI backup if required
|
||||
//u8g.setHardwareBackup(u8g_backup_avr_spi);
|
||||
|
||||
// assign default color value
|
||||
if ( u8g.getMode() == U8G_MODE_R3G3B2 )
|
||||
u8g.setColorIndex(255); // white
|
||||
else if ( u8g.getMode() == U8G_MODE_GRAY2BIT )
|
||||
u8g.setColorIndex(3); // max intensity
|
||||
else if ( u8g.getMode() == U8G_MODE_BW )
|
||||
u8g.setColorIndex(1); // pixel on
|
||||
}
|
||||
|
||||
void loop(void) {
|
||||
// picture loop
|
||||
u8g.firstPage();
|
||||
do {
|
||||
draw();
|
||||
} while( u8g.nextPage() );
|
||||
|
||||
// rebuild the picture after some delay
|
||||
delay(500);
|
||||
}
|
||||
|
@ -0,0 +1,154 @@
|
||||
/*
|
||||
|
||||
TextRotX.pde
|
||||
|
||||
Text rotation example code.
|
||||
|
||||
>>> Before compiling: Please remove comment from the constructor of the
|
||||
>>> connected graphics display (see below).
|
||||
|
||||
Universal 8bit Graphics Library, http://code.google.com/p/u8glib/
|
||||
|
||||
Copyright (c) 2012, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "U8glib.h"
|
||||
|
||||
// setup u8g object, please remove comment from one of the following constructor calls
|
||||
// IMPORTANT NOTE: The complete list of supported devices is here: http://code.google.com/p/u8glib/wiki/device
|
||||
|
||||
//U8GLIB_NHD27OLED_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD27OLED_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD27OLED_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD27OLED_2X_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD31OLED_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD31OLED_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD31OLED_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD31OLED_2X_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGS102 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGM132 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGM128 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_ST7920_128X64_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_128X64_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_128X64_1X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_128X64_4X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_192X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_192X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_192X32_1X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_192X32_4X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_192X32_1X u8g(13, 11, 10); // SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10
|
||||
//U8GLIB_ST7920_192X32_4X u8g(10); // SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10, HW SPI
|
||||
//U8GLIB_ST7920_202X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_202X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_202X32_1X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_202X32_4X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_LM6059 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_LM6063 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGXL160_BW u8g(10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGXL160_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGXL160_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGXL160_2X_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_PCD8544 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
|
||||
//U8GLIB_PCF8812 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
|
||||
//U8GLIB_KS0108_128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs1=14, cs2=15,di=17,rw=16
|
||||
//U8GLIB_LC7981_160X80 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
|
||||
//U8GLIB_LC7981_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
|
||||
//U8GLIB_LC7981_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
|
||||
//U8GLIB_ILI9325D_320x240 u8g(18,17,19,U8G_PIN_NONE,16 ); // 8Bit Com: D0..D7: 0,1,2,3,4,5,6,7 en=wr=18, cs=17, rs=19, rd=U8G_PIN_NONE, reset = 16
|
||||
//U8GLIB_SBN1661_122X32 u8g(8,9,10,11,4,5,6,7,14,15, 17, U8G_PIN_NONE, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 cs1=14, cs2=15,di=17,rw=16,reset = 16
|
||||
//U8GLIB_SSD1306_128X64 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_SSD1306_128X64 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
|
||||
//U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
|
||||
//U8GLIB_SSD1306_128X32 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_SSD1306_128X32 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
|
||||
//U8GLIB_SSD1306_128X32 u8g(U8G_I2C_OPT_NONE); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
|
||||
//U8GLIB_SSD1309_128X64 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_SSD1327_96X96_GR u8g(U8G_I2C_OPT_NONE); // I2C
|
||||
//U8GLIB_SSD1327_96X96_2X_GR u8g(U8G_I2C_OPT_NONE); // I2C
|
||||
//U8GLIB_NHD_C12864 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
|
||||
//U8GLIB_NHD_C12832 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
|
||||
//U8GLIB_T6963_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
|
||||
//U8GLIB_T6963_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
|
||||
//U8GLIB_T6963_128X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
|
||||
|
||||
// graphic commands to redraw the complete screen should be placed here
|
||||
void draw(void) {
|
||||
u8g_uint_t mx, my;
|
||||
|
||||
mx = u8g.getWidth();
|
||||
mx >>= 1;
|
||||
|
||||
my = u8g.getHeight();
|
||||
my >>= 1;
|
||||
|
||||
u8g.drawStr( mx, my, "Ag");
|
||||
u8g.drawStr90( mx, my, "Ag");
|
||||
u8g.drawStr180( mx, my, "Ag");
|
||||
u8g.drawStr270( mx, my, "Ag");
|
||||
}
|
||||
|
||||
void setup(void) {
|
||||
u8g.setFont(u8g_font_9x18);
|
||||
}
|
||||
|
||||
void change_font_pos(void) {
|
||||
static uint8_t dir = 0;
|
||||
static unsigned long next = 0;
|
||||
|
||||
if ( next < millis() )
|
||||
{
|
||||
switch(dir) {
|
||||
case 0: u8g.setFontPosBottom(); break;
|
||||
case 1: u8g.setFontPosBaseline(); break;
|
||||
case 2: u8g.setFontPosCenter(); break;
|
||||
case 3: u8g.setFontPosTop(); break;
|
||||
}
|
||||
|
||||
dir++;
|
||||
dir &= 3;
|
||||
next = millis();
|
||||
next += 1000;
|
||||
}
|
||||
}
|
||||
|
||||
void loop(void) {
|
||||
// change the font position
|
||||
change_font_pos();
|
||||
|
||||
// picture loop
|
||||
u8g.firstPage();
|
||||
do {
|
||||
draw();
|
||||
} while( u8g.nextPage() );
|
||||
|
||||
// rebuild the picture after some delay
|
||||
delay(100);
|
||||
}
|
||||
|
@ -0,0 +1,179 @@
|
||||
/*
|
||||
|
||||
U8gLogo.pde
|
||||
|
||||
Put the U8GLIB logo on the display.
|
||||
|
||||
>>> Before compiling: Please remove comment from the constructor of the
|
||||
>>> connected graphics display (see below).
|
||||
|
||||
Universal 8bit Graphics Library, http://code.google.com/p/u8glib/
|
||||
|
||||
Copyright (c) 2012, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "U8glib.h"
|
||||
|
||||
// setup u8g object, please remove comment from one of the following constructor calls
|
||||
// IMPORTANT NOTE: The complete list of supported devices is here: http://code.google.com/p/u8glib/wiki/device
|
||||
|
||||
//U8GLIB_NHD27OLED_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD27OLED_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD27OLED_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD27OLED_2X_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD31OLED_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD31OLED_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD31OLED_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD31OLED_2X_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGS102 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGM132 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGM128 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_ST7920_128X64_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_128X64_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_128X64_1X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_128X64_4X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_192X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_192X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_192X32_1X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_192X32_4X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_192X32_1X u8g(13, 11, 10); // SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10
|
||||
//U8GLIB_ST7920_192X32_4X u8g(10); // SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10, HW SPI
|
||||
//U8GLIB_ST7920_202X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_202X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_202X32_1X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_202X32_4X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_LM6059 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_LM6063 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGXL160_BW u8g(10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGXL160_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGXL160_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGXL160_2X_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_PCD8544 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
|
||||
//U8GLIB_PCF8812 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
|
||||
//U8GLIB_KS0108_128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs1=14, cs2=15,di=17,rw=16
|
||||
//U8GLIB_LC7981_160X80 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
|
||||
//U8GLIB_LC7981_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
|
||||
//U8GLIB_LC7981_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
|
||||
//U8GLIB_ILI9325D_320x240 u8g(18,17,19,U8G_PIN_NONE,16 ); // 8Bit Com: D0..D7: 0,1,2,3,4,5,6,7 en=wr=18, cs=17, rs=19, rd=U8G_PIN_NONE, reset = 16
|
||||
//U8GLIB_SBN1661_122X32 u8g(8,9,10,11,4,5,6,7,14,15, 17, U8G_PIN_NONE, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 cs1=14, cs2=15,di=17,rw=16,reset = 16
|
||||
//U8GLIB_SSD1306_128X64 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_SSD1306_128X64 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
|
||||
//U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
|
||||
//U8GLIB_SSD1306_128X32 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_SSD1306_128X32 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
|
||||
//U8GLIB_SSD1306_128X32 u8g(U8G_I2C_OPT_NONE); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
|
||||
//U8GLIB_SSD1309_128X64 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_SSD1327_96X96_GR u8g(U8G_I2C_OPT_NONE); // I2C
|
||||
//U8GLIB_SSD1327_96X96_2X_GR u8g(U8G_I2C_OPT_NONE); // I2C
|
||||
//U8GLIB_NHD_C12864 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
|
||||
//U8GLIB_NHD_C12832 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
|
||||
//U8GLIB_T6963_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
|
||||
//U8GLIB_T6963_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
|
||||
//U8GLIB_T6963_128X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
|
||||
|
||||
|
||||
void drawColorBox(void)
|
||||
{
|
||||
u8g_uint_t w,h;
|
||||
u8g_uint_t r, g, b;
|
||||
|
||||
w = u8g.getWidth()/32;
|
||||
h = u8g.getHeight()/8;
|
||||
for( b = 0; b < 4; b++ )
|
||||
for( g = 0; g < 8; g++ )
|
||||
for( r = 0; r < 8; r++ )
|
||||
{
|
||||
u8g.setColorIndex((r<<5) | (g<<2) | b );
|
||||
u8g.drawBox(g*w + b*w*8, r*h, w, h);
|
||||
}
|
||||
}
|
||||
|
||||
void drawLogo(uint8_t d)
|
||||
{
|
||||
u8g.setFont(u8g_font_gdr25r);
|
||||
u8g.drawStr(0+d, 30+d, "U");
|
||||
u8g.setFont(u8g_font_gdr30n);
|
||||
u8g.drawStr90(23+d,10+d,"8");
|
||||
u8g.setFont(u8g_font_gdr25r);
|
||||
u8g.drawStr(53+d,30+d,"g");
|
||||
|
||||
u8g.drawHLine(2+d, 35+d, 47);
|
||||
u8g.drawVLine(45+d, 32+d, 12);
|
||||
}
|
||||
|
||||
void drawURL(void)
|
||||
{
|
||||
u8g.setFont(u8g_font_4x6);
|
||||
if ( u8g.getHeight() < 59 )
|
||||
{
|
||||
u8g.drawStr(53,9,"code.google.com");
|
||||
u8g.drawStr(77,18,"/p/u8glib");
|
||||
}
|
||||
else
|
||||
{
|
||||
u8g.drawStr(1,54,"code.google.com/p/u8glib");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void draw(void) {
|
||||
if ( u8g.getMode() == U8G_MODE_R3G3B2 ) {
|
||||
drawColorBox();
|
||||
}
|
||||
u8g.setColorIndex(1);
|
||||
if ( U8G_MODE_GET_BITS_PER_PIXEL(u8g.getMode()) > 1 ) {
|
||||
drawLogo(2);
|
||||
u8g.setColorIndex(2);
|
||||
drawLogo(1);
|
||||
u8g.setColorIndex(3);
|
||||
}
|
||||
drawLogo(0);
|
||||
drawURL();
|
||||
|
||||
}
|
||||
|
||||
void setup(void) {
|
||||
// flip screen, if required
|
||||
//u8g.setRot180();
|
||||
}
|
||||
|
||||
void loop(void) {
|
||||
|
||||
// picture loop
|
||||
u8g.firstPage();
|
||||
do {
|
||||
draw();
|
||||
u8g.setColorIndex(1);
|
||||
} while( u8g.nextPage() );
|
||||
|
||||
// rebuild the picture after some delay
|
||||
delay(200);
|
||||
}
|
||||
|
@ -0,0 +1,136 @@
|
||||
/*
|
||||
|
||||
XBM.pde
|
||||
|
||||
drawXBM example code.
|
||||
|
||||
>>> Before compiling: Please remove comment from the constructor of the
|
||||
>>> connected graphics display (see below).
|
||||
|
||||
Universal 8bit Graphics Library, http://code.google.com/p/u8glib/
|
||||
|
||||
Copyright (c) 2012, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "U8glib.h"
|
||||
|
||||
// setup u8g object, please remove comment from one of the following constructor calls
|
||||
// IMPORTANT NOTE: The complete list of supported devices is here: http://code.google.com/p/u8glib/wiki/device
|
||||
|
||||
//U8GLIB_NHD27OLED_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD27OLED_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD27OLED_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD27OLED_2X_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD31OLED_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD31OLED_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD31OLED_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_NHD31OLED_2X_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGS102 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGM132 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGM128 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_ST7920_128X64_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_128X64_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_128X64_1X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_128X64_4X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_192X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_192X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_192X32_1X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_192X32_4X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_192X32_1X u8g(13, 11, 10); // SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10
|
||||
//U8GLIB_ST7920_192X32_4X u8g(10); // SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10, HW SPI
|
||||
//U8GLIB_ST7920_202X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_202X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
|
||||
//U8GLIB_ST7920_202X32_1X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_ST7920_202X32_4X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
|
||||
//U8GLIB_LM6059 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_LM6063 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGXL160_BW u8g(10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGXL160_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGXL160_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_DOGXL160_2X_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_PCD8544 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
|
||||
//U8GLIB_PCF8812 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
|
||||
//U8GLIB_KS0108_128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs1=14, cs2=15,di=17,rw=16
|
||||
//U8GLIB_LC7981_160X80 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
|
||||
//U8GLIB_LC7981_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
|
||||
//U8GLIB_LC7981_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
|
||||
//U8GLIB_ILI9325D_320x240 u8g(18,17,19,U8G_PIN_NONE,16 ); // 8Bit Com: D0..D7: 0,1,2,3,4,5,6,7 en=wr=18, cs=17, rs=19, rd=U8G_PIN_NONE, reset = 16
|
||||
//U8GLIB_SBN1661_122X32 u8g(8,9,10,11,4,5,6,7,14,15, 17, U8G_PIN_NONE, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 cs1=14, cs2=15,di=17,rw=16,reset = 16
|
||||
//U8GLIB_SSD1306_128X64 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_SSD1306_128X64 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
|
||||
//U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
|
||||
//U8GLIB_SSD1306_128X32 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_SSD1306_128X32 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
|
||||
//U8GLIB_SSD1306_128X32 u8g(U8G_I2C_OPT_NONE); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11)
|
||||
//U8GLIB_SSD1309_128X64 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
|
||||
//U8GLIB_SSD1327_96X96_GR u8g(U8G_I2C_OPT_NONE); // I2C
|
||||
//U8GLIB_SSD1327_96X96_2X_GR u8g(U8G_I2C_OPT_NONE); // I2C
|
||||
//U8GLIB_NHD_C12864 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
|
||||
//U8GLIB_NHD_C12832 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
|
||||
//U8GLIB_T6963_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
|
||||
//U8GLIB_T6963_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
|
||||
//U8GLIB_T6963_128X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
|
||||
|
||||
#define u8g_logo_width 38
|
||||
#define u8g_logo_height 24
|
||||
//static unsigned char u8g_logo_bits[] = {
|
||||
static unsigned char u8g_logo_bits[] U8G_PROGMEM = {
|
||||
0xff, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xe0, 0xe0,
|
||||
0xff, 0xff, 0x3f, 0xe3, 0xe1, 0xff, 0xff, 0x3f, 0xf3, 0xf1, 0xff, 0xff,
|
||||
0x3f, 0xf3, 0xf1, 0xfe, 0xbf, 0x37, 0xf3, 0x11, 0x1c, 0x1f, 0x30, 0xf3,
|
||||
0x01, 0x08, 0x8c, 0x20, 0xf3, 0x01, 0x00, 0xc0, 0x39, 0xf3, 0x81, 0xc7,
|
||||
0xc1, 0x39, 0xf3, 0xc1, 0xc7, 0xc9, 0x38, 0xf3, 0xc1, 0xc3, 0x19, 0x3c,
|
||||
0xe3, 0x89, 0x01, 0x98, 0x3f, 0xc7, 0x18, 0x00, 0x08, 0x3e, 0x0f, 0x3c,
|
||||
0x70, 0x1c, 0x30, 0x3f, 0xff, 0xfc, 0x87, 0x31, 0xff, 0xff, 0xbf, 0xc7,
|
||||
0x23, 0x01, 0x00, 0x00, 0xc6, 0x23, 0x03, 0x00, 0x00, 0x0e, 0x30, 0xff,
|
||||
0xff, 0x3f, 0x1f, 0x3c, 0xff, 0xff, 0x3f, 0xff, 0x3f, 0xff, 0xff, 0x3f,
|
||||
0xff, 0x3f, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0xff, 0x3f };
|
||||
|
||||
void draw(void) {
|
||||
// graphic commands to redraw the complete screen should be placed here
|
||||
u8g.drawXBMP( 0, 0, u8g_logo_width, u8g_logo_height, u8g_logo_bits);
|
||||
}
|
||||
|
||||
void setup(void) {
|
||||
// flip screen, if required
|
||||
// u8g.setRot180();
|
||||
}
|
||||
|
||||
void loop(void) {
|
||||
// picture loop
|
||||
u8g.firstPage();
|
||||
do {
|
||||
draw();
|
||||
} while( u8g.nextPage() );
|
||||
|
||||
// rebuild the picture after some delay
|
||||
delay(500);
|
||||
}
|
||||
|
@ -0,0 +1,80 @@
|
||||
|
||||
The U8glib code (http://code.google.com/p/u8glib/) is licensed under the terms of
|
||||
the new-bsd license (two-clause bsd license).
|
||||
See also: http://www.opensource.org/licenses/bsd-license.php
|
||||
|
||||
The repository and optionally the releases contain icons, which are
|
||||
derived from the WPZOOM Developer Icon Set:
|
||||
http://www.wpzoom.com/wpzoom/new-freebie-wpzoom-developer-icon-set-154-free-icons/
|
||||
WPZOOM Developer Icon Set by WPZOOM is licensed under a Creative Commons
|
||||
Attribution-ShareAlike 3.0 Unported License.
|
||||
|
||||
Fonts are licensed under different conditions.
|
||||
See http://code.google.com/p/u8glib/wiki/fontgroup for
|
||||
detailed information on the licensing conditions for each font.
|
||||
|
||||
============ X11 Fonts COUR, HELV, NCEN, TIM, SYMB ============
|
||||
|
||||
For fonts derived from the following files, the license below applies.
|
||||
COURB08.BDF COURB10.BDF COURB12.BDF COURB14.BDF COURB18.BDF
|
||||
COURB24.BDF COURR08.BDF COURR10.BDF COURR12.BDF COURR14.BDF
|
||||
COURR18.BDF COURR24.BDF HELVB08.BDF HELVB10.BDF HELVB12.BDF HELVB14.BDF
|
||||
HELVB18.BDF HELVB24.BDF HELVR08.BDF HELVR10.BDF HELVR12.BDF HELVR14.BDF
|
||||
HELVR18.BDF HELVR24.BDF NCENB08.BDF NCENB10.BDF NCENB12.BDF
|
||||
NCENB14.BDF NCENB18.BDF NCENB24.BDF NCENR08.BDF NCENR10.BDF
|
||||
NCENR12.BDF NCENR14.BDF NCENR18.BDF NCENR24.BDF SYMB08.BDF SYMB10.BDF
|
||||
SYMB12.BDF SYMB14.BDF SYMB18.BDF SYMB24.BDF TIMB08.BDF TIMB10.BDF
|
||||
TIMB12.BDF TIMB14.BDF TIMB18.BDF TIMB24.BDF TIMR08.BDF TIMR10.BDF
|
||||
TIMR12.BDF TIMR14.BDF TIMR18.BDF TIMR24.BDF
|
||||
|
||||
Copyright 1984-1989, 1994 Adobe Systems Incorporated.
|
||||
Copyright 1988, 1994 Digital Equipment Corporation.
|
||||
|
||||
Adobe is a trademark of Adobe Systems Incorporated which may be
|
||||
registered in certain jurisdictions.
|
||||
Permission to use these trademarks is hereby granted only in
|
||||
association with the images described in this file.
|
||||
|
||||
Permission to use, copy, modify, distribute and sell this software
|
||||
and its documentation for any purpose and without fee is hereby
|
||||
granted, provided that the above copyright notices appear in all
|
||||
copies and that both those copyright notices and this permission
|
||||
notice appear in supporting documentation, and that the names of
|
||||
Adobe Systems and Digital Equipment Corporation not be used in
|
||||
advertising or publicity pertaining to distribution of the software
|
||||
without specific, written prior permission. Adobe Systems and
|
||||
Digital Equipment Corporation make no representations about the
|
||||
suitability of this software for any purpose. It is provided "as
|
||||
is" without express or implied warranty.
|
||||
|
||||
|
||||
============ BSD License for U8glib Code ============
|
||||
|
||||
Universal 8bit Graphics Library (http://code.google.com/p/u8glib/)
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,1607 @@
|
||||
/*
|
||||
|
||||
u8g.h
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _U8G_H
|
||||
#define _U8G_H
|
||||
|
||||
//#define U8G_16BIT 1
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __18CXX
|
||||
typedef unsigned char uint8_t;
|
||||
typedef signed char int8_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef signed short int16_t;
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
#if defined(__AVR__)
|
||||
#include <avr/pgmspace.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*===============================================================*/
|
||||
#ifdef __GNUC__
|
||||
#define U8G_NOINLINE __attribute__((noinline))
|
||||
#define U8G_PURE __attribute__ ((pure))
|
||||
#define U8G_NOCOMMON __attribute__ ((nocommon))
|
||||
#define U8G_SECTION(name) __attribute__ ((section (name)))
|
||||
#else
|
||||
#define U8G_NOINLINE
|
||||
#define U8G_PURE
|
||||
#define U8G_NOCOMMON
|
||||
#define U8G_SECTION(name)
|
||||
#endif
|
||||
|
||||
/*===============================================================*/
|
||||
/* flash memory access */
|
||||
|
||||
#if defined(__AVR__)
|
||||
/* U8G_PROGMEM is used by the XBM example */
|
||||
#define U8G_PROGMEM U8G_SECTION(".progmem.data")
|
||||
typedef uint8_t PROGMEM u8g_pgm_uint8_t;
|
||||
typedef uint8_t u8g_fntpgm_uint8_t;
|
||||
#define u8g_pgm_read(adr) pgm_read_byte_near(adr)
|
||||
#define U8G_PSTR(s) ((u8g_pgm_uint8_t *)PSTR(s))
|
||||
#else
|
||||
#define U8G_PROGMEM
|
||||
#define PROGMEM
|
||||
typedef uint8_t u8g_pgm_uint8_t;
|
||||
typedef uint8_t u8g_fntpgm_uint8_t;
|
||||
#define u8g_pgm_read(adr) (*(const u8g_pgm_uint8_t *)(adr))
|
||||
#define U8G_PSTR(s) ((u8g_pgm_uint8_t *)(s))
|
||||
#endif
|
||||
|
||||
/*===============================================================*/
|
||||
/* forward */
|
||||
typedef struct _u8g_t u8g_t;
|
||||
typedef struct _u8g_dev_t u8g_dev_t;
|
||||
|
||||
typedef struct _u8g_dev_arg_pixel_t u8g_dev_arg_pixel_t;
|
||||
typedef struct _u8g_dev_arg_bbx_t u8g_dev_arg_bbx_t;
|
||||
typedef struct _u8g_box_t u8g_box_t;
|
||||
|
||||
|
||||
/*===============================================================*/
|
||||
/* generic */
|
||||
#if defined(U8G_16BIT)
|
||||
typedef uint16_t u8g_uint_t;
|
||||
typedef int16_t u8g_int_t;
|
||||
#else
|
||||
typedef uint8_t u8g_uint_t;
|
||||
typedef int8_t u8g_int_t;
|
||||
#endif
|
||||
|
||||
#ifdef OBSOLETE
|
||||
struct _u8g_box_t
|
||||
{
|
||||
u8g_uint_t x0, y0, x1, y1;
|
||||
};
|
||||
typedef struct _u8g_box_t u8g_box_t;
|
||||
#endif /* OBSOLETE */
|
||||
|
||||
|
||||
/*===============================================================*/
|
||||
/* device structure */
|
||||
|
||||
#ifdef __XC8
|
||||
/* device prototype */
|
||||
typedef uint8_t (*u8g_dev_fnptr)(void *u8g, void *dev, uint8_t msg, void *arg);
|
||||
|
||||
/* com prototype */
|
||||
typedef uint8_t (*u8g_com_fnptr)(void *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
|
||||
#else
|
||||
/* device prototype */
|
||||
typedef uint8_t (*u8g_dev_fnptr)(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
|
||||
|
||||
/* com prototype */
|
||||
typedef uint8_t (*u8g_com_fnptr)(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
struct _u8g_dev_t
|
||||
{
|
||||
u8g_dev_fnptr dev_fn; /* device procedure */
|
||||
void *dev_mem; /* device memory */
|
||||
u8g_com_fnptr com_fn; /* communication procedure */
|
||||
};
|
||||
|
||||
|
||||
/*===============================================================*/
|
||||
/* device list */
|
||||
|
||||
/* Size: 128x64 SDL, u8g_dev_sdl.c */
|
||||
extern u8g_dev_t u8g_dev_sdl_1bit;
|
||||
extern u8g_dev_t u8g_dev_sdl_1bit_h;
|
||||
extern u8g_dev_t u8g_dev_sdl_2bit;
|
||||
extern u8g_dev_t u8g_dev_sdl_2bit_double_mem;
|
||||
extern u8g_dev_t u8g_dev_sdl_8bit;
|
||||
int u8g_sdl_get_key(void);
|
||||
|
||||
/* Size: 70x30 monochrom, stdout */
|
||||
extern u8g_dev_t u8g_dev_stdout;
|
||||
|
||||
/* Size: monochrom, writes "u8g.pbm" */
|
||||
extern u8g_dev_t u8g_dev_pbm;
|
||||
extern u8g_dev_t u8g_dev_pbm_8h1;
|
||||
extern u8g_dev_t u8g_dev_pbm_8h2; /* grayscale simulation */
|
||||
|
||||
/* Size: 128x64 monochrom, no output, used for performance measure */
|
||||
extern u8g_dev_t u8g_dev_gprof;
|
||||
|
||||
/* Display: EA DOGS102, Size: 102x64 monochrom */
|
||||
extern u8g_dev_t u8g_dev_uc1701_dogs102_sw_spi;
|
||||
extern u8g_dev_t u8g_dev_uc1701_dogs102_hw_spi;
|
||||
|
||||
/* Display: Mini12864 (dealextreme), Size: 128x64 monochrom */
|
||||
extern u8g_dev_t u8g_dev_uc1701_mini12864_sw_spi;
|
||||
extern u8g_dev_t u8g_dev_uc1701_mini12864_hw_spi;
|
||||
|
||||
/* Display: EA DOGM132, Size: 128x32 monochrom */
|
||||
extern u8g_dev_t u8g_dev_st7565_dogm132_sw_spi;
|
||||
extern u8g_dev_t u8g_dev_st7565_dogm132_hw_spi;
|
||||
|
||||
/* Display: EA DOGM128, Size: 128x64 monochrom */
|
||||
extern u8g_dev_t u8g_dev_st7565_dogm128_sw_spi;
|
||||
extern u8g_dev_t u8g_dev_st7565_dogm128_hw_spi;
|
||||
/* Display: Topway LM6063 128x64 */
|
||||
extern u8g_dev_t u8g_dev_st7565_lm6063_sw_spi;
|
||||
extern u8g_dev_t u8g_dev_st7565_lm6063_hw_spi;
|
||||
/* Display: Topway LM6059 128x64 (Adafruit) */
|
||||
extern u8g_dev_t u8g_dev_st7565_lm6059_sw_spi;
|
||||
extern u8g_dev_t u8g_dev_st7565_lm6059_hw_spi;
|
||||
/* Display: Newhaven NHD-C12864 */
|
||||
extern u8g_dev_t u8g_dev_st7565_nhd_c12864_sw_spi;
|
||||
extern u8g_dev_t u8g_dev_st7565_nhd_c12864_hw_spi;
|
||||
/* Display: Newhaven NHD-C12832 */
|
||||
extern u8g_dev_t u8g_dev_st7565_nhd_c12832_sw_spi;
|
||||
extern u8g_dev_t u8g_dev_st7565_nhd_c12832_hw_spi;
|
||||
extern u8g_dev_t u8g_dev_st7565_nhd_c12832_parallel;
|
||||
/* Display: Displaytech 64128N */
|
||||
extern u8g_dev_t u8g_dev_st7565_64128n_sw_spi;
|
||||
extern u8g_dev_t u8g_dev_st7565_64128n_hw_spi;
|
||||
|
||||
/* dfrobot 128x64 Graphic LCD (SKU:FIT0021) */
|
||||
extern u8g_dev_t u8g_dev_st7920_128x64_sw_spi;
|
||||
extern u8g_dev_t u8g_dev_st7920_128x64_hw_spi;
|
||||
extern u8g_dev_t u8g_dev_st7920_128x64_8bit;
|
||||
|
||||
extern u8g_dev_t u8g_dev_st7920_128x64_4x_sw_spi;
|
||||
extern u8g_dev_t u8g_dev_st7920_128x64_4x_hw_spi;
|
||||
extern u8g_dev_t u8g_dev_st7920_128x64_4x_8bit;
|
||||
|
||||
/* NHD-19232WG */
|
||||
extern u8g_dev_t u8g_dev_st7920_192x32_sw_spi;
|
||||
extern u8g_dev_t u8g_dev_st7920_192x32_hw_spi;
|
||||
extern u8g_dev_t u8g_dev_st7920_192x32_8bit;
|
||||
|
||||
extern u8g_dev_t u8g_dev_st7920_192x32_4x_sw_spi;
|
||||
extern u8g_dev_t u8g_dev_st7920_192x32_4x_hw_spi;
|
||||
extern u8g_dev_t u8g_dev_st7920_192x32_4x_8bit;
|
||||
|
||||
/* CrystalFontz CFAG20232 */
|
||||
extern u8g_dev_t u8g_dev_st7920_202x32_sw_spi;
|
||||
extern u8g_dev_t u8g_dev_st7920_202x32_hw_spi;
|
||||
extern u8g_dev_t u8g_dev_st7920_202x32_8bit;
|
||||
|
||||
extern u8g_dev_t u8g_dev_st7920_202x32_4x_sw_spi;
|
||||
extern u8g_dev_t u8g_dev_st7920_202x32_4x_hw_spi;
|
||||
extern u8g_dev_t u8g_dev_st7920_202x32_4x_8bit;
|
||||
|
||||
/* LC7981 160x80 display */
|
||||
extern u8g_dev_t u8g_dev_lc7981_160x80_8bit;
|
||||
/* LC7981 240x64 display */
|
||||
extern u8g_dev_t u8g_dev_lc7981_240x64_8bit;
|
||||
/* LC7981 240x128 display */
|
||||
extern u8g_dev_t u8g_dev_lc7981_240x128_8bit;
|
||||
/* LC7981 320x64 display */
|
||||
extern u8g_dev_t u8g_dev_lc7981_320x64_8bit;
|
||||
|
||||
/* T6963, all t6963 devices have double page (2x) */
|
||||
extern u8g_dev_t u8g_dev_t6963_240x128_8bit;
|
||||
extern u8g_dev_t u8g_dev_t6963_240x64_8bit;
|
||||
extern u8g_dev_t u8g_dev_t6963_128x64_8bit;
|
||||
|
||||
/* Display: EA DOGXL160, Size: 160x104 monochrom & gray level */
|
||||
extern u8g_dev_t u8g_dev_uc1610_dogxl160_bw_sw_spi;
|
||||
extern u8g_dev_t u8g_dev_uc1610_dogxl160_bw_hw_spi;
|
||||
extern u8g_dev_t u8g_dev_uc1610_dogxl160_gr_sw_spi;
|
||||
extern u8g_dev_t u8g_dev_uc1610_dogxl160_gr_hw_spi;
|
||||
|
||||
extern u8g_dev_t u8g_dev_uc1610_dogxl160_2x_bw_sw_spi;
|
||||
extern u8g_dev_t u8g_dev_uc1610_dogxl160_2x_bw_hw_spi;
|
||||
extern u8g_dev_t u8g_dev_uc1610_dogxl160_2x_gr_sw_spi;
|
||||
extern u8g_dev_t u8g_dev_uc1610_dogxl160_2x_gr_hw_spi;
|
||||
|
||||
/* Display: Generic KS0108b, Size: 128x64 monochrom */
|
||||
extern u8g_dev_t u8g_dev_ks0108_128x64; /* official Arduino Library interface */
|
||||
extern u8g_dev_t u8g_dev_ks0108_128x64_fast; /* faster, but uses private tables from the Arduino Library */
|
||||
|
||||
/* Nokia 84x48 Display with PCD8544 */
|
||||
extern u8g_dev_t u8g_dev_pcd8544_84x48_sw_spi;
|
||||
extern u8g_dev_t u8g_dev_tls8204_84x48_sw_spi;
|
||||
|
||||
/* Nokia 96x65 Display with PCF8812 */
|
||||
extern u8g_dev_t u8g_dev_pcf8812_96x65_sw_spi;
|
||||
|
||||
/* NHD-2.7-12864UCY3 OLED Display with SSD1325 Controller */
|
||||
extern u8g_dev_t u8g_dev_ssd1325_nhd27oled_bw_sw_spi;
|
||||
extern u8g_dev_t u8g_dev_ssd1325_nhd27oled_bw_hw_spi;
|
||||
extern u8g_dev_t u8g_dev_ssd1325_nhd27oled_bw_parallel;
|
||||
extern u8g_dev_t u8g_dev_ssd1325_nhd27oled_gr_sw_spi;
|
||||
extern u8g_dev_t u8g_dev_ssd1325_nhd27oled_gr_hw_spi;
|
||||
|
||||
extern u8g_dev_t u8g_dev_ssd1325_nhd27oled_2x_bw_sw_spi;
|
||||
extern u8g_dev_t u8g_dev_ssd1325_nhd27oled_2x_bw_hw_spi;
|
||||
extern u8g_dev_t u8g_dev_ssd1325_nhd27oled_2x_bw_parallel;
|
||||
extern u8g_dev_t u8g_dev_ssd1325_nhd27oled_2x_gr_sw_spi;
|
||||
extern u8g_dev_t u8g_dev_ssd1325_nhd27oled_2x_gr_hw_spi;
|
||||
|
||||
/* LY120 OLED with SSD1327 Controller (tested with Seeedstudio module) */
|
||||
extern u8g_dev_t u8g_dev_ssd1327_96x96_gr_sw_spi;
|
||||
extern u8g_dev_t u8g_dev_ssd1327_96x96_gr_hw_spi;
|
||||
extern u8g_dev_t u8g_dev_ssd1327_96x96_gr_i2c;
|
||||
|
||||
extern u8g_dev_t u8g_dev_ssd1327_96x96_2x_gr_sw_spi;
|
||||
extern u8g_dev_t u8g_dev_ssd1327_96x96_2x_gr_hw_spi;
|
||||
extern u8g_dev_t u8g_dev_ssd1327_96x96_2x_gr_i2c;
|
||||
|
||||
/* NHD-3.12-25664 OLED Display with SSD1322 Controller */
|
||||
extern u8g_dev_t u8g_dev_ssd1322_nhd31oled_bw_sw_spi;
|
||||
extern u8g_dev_t u8g_dev_ssd1322_nhd31oled_bw_hw_spi;
|
||||
extern u8g_dev_t u8g_dev_ssd1322_nhd31oled_2x_bw_sw_spi;
|
||||
extern u8g_dev_t u8g_dev_ssd1322_nhd31oled_2x_bw_hw_spi;
|
||||
|
||||
extern u8g_dev_t u8g_dev_ssd1322_nhd31oled_gr_sw_spi;
|
||||
extern u8g_dev_t u8g_dev_ssd1322_nhd31oled_gr_hw_spi;
|
||||
extern u8g_dev_t u8g_dev_ssd1322_nhd31oled_2x_gr_sw_spi;
|
||||
extern u8g_dev_t u8g_dev_ssd1322_nhd31oled_2x_gr_hw_spi;
|
||||
|
||||
/* OLED 128x64 Display with SSD1306 Controller */
|
||||
extern u8g_dev_t u8g_dev_ssd1306_128x64_sw_spi;
|
||||
extern u8g_dev_t u8g_dev_ssd1306_128x64_hw_spi;
|
||||
extern u8g_dev_t u8g_dev_ssd1306_128x64_i2c;
|
||||
|
||||
/* OLED 128x64 Display with SSD1309 Controller */
|
||||
extern u8g_dev_t u8g_dev_ssd1309_128x64_sw_spi;
|
||||
extern u8g_dev_t u8g_dev_ssd1309_128x64_hw_spi;
|
||||
extern u8g_dev_t u8g_dev_ssd1309_128x64_i2c;
|
||||
|
||||
/* OLED 128x32 Display with SSD1306 Controller */
|
||||
extern u8g_dev_t u8g_dev_ssd1306_128x32_sw_spi;
|
||||
extern u8g_dev_t u8g_dev_ssd1306_128x32_hw_spi;
|
||||
extern u8g_dev_t u8g_dev_ssd1306_128x32_i2c;
|
||||
|
||||
/* experimental 65K TFT with st7687 controller */
|
||||
extern u8g_dev_t u8g_dev_st7687_c144mvgd_sw_spi;
|
||||
extern u8g_dev_t u8g_dev_st7687_c144mvgd_8bit;
|
||||
|
||||
/* SBN1661/SED1520 display with 122x32 */
|
||||
extern u8g_dev_t u8g_dev_sbn1661_122x32;
|
||||
|
||||
/* flip disc matrix */
|
||||
extern u8g_dev_t u8g_dev_flipdisc_2x7;
|
||||
void u8g_SetFlipDiscCallback(u8g_t *u8g, void (*cb)(uint8_t id, uint8_t page, uint8_t width, uint8_t *row1, uint8_t *row2));
|
||||
|
||||
/* ILI9325D based TFT */
|
||||
extern u8g_dev_t u8g_dev_ili9325d_320x240_8bit;
|
||||
|
||||
/* u8g_virtual_screen.c */
|
||||
extern u8g_dev_t u8g_dev_vs;
|
||||
|
||||
|
||||
/*===============================================================*/
|
||||
/* device messages */
|
||||
|
||||
struct _u8g_dev_arg_pixel_t
|
||||
{
|
||||
u8g_uint_t x, y; /* will be modified */
|
||||
uint8_t pixel; /* will be modified */
|
||||
uint8_t dir;
|
||||
uint8_t color;
|
||||
};
|
||||
/* typedef struct _u8g_dev_arg_pixel_t u8g_dev_arg_pixel_t; */ /* forward decl */
|
||||
|
||||
struct _u8g_dev_arg_bbx_t
|
||||
{
|
||||
u8g_uint_t x, y, w, h;
|
||||
};
|
||||
/* typedef struct _u8g_dev_arg_bbx_t u8g_dev_arg_bbx_t; */ /* forward decl */
|
||||
|
||||
struct _u8g_box_t
|
||||
{
|
||||
u8g_uint_t x0, y0, x1, y1;
|
||||
};
|
||||
/* typedef struct _u8g_box_t u8g_box_t; */ /* forward decl */
|
||||
|
||||
|
||||
#define U8G_DEV_MSG_INIT 10
|
||||
#define U8G_DEV_MSG_STOP 11
|
||||
|
||||
/* arg: pointer to uint8_t, contranst value between 0 and 255 */
|
||||
#define U8G_DEV_MSG_CONTRAST 15
|
||||
|
||||
#define U8G_DEV_MSG_SLEEP_ON 16
|
||||
#define U8G_DEV_MSG_SLEEP_OFF 17
|
||||
|
||||
#define U8G_DEV_MSG_PAGE_FIRST 20
|
||||
#define U8G_DEV_MSG_PAGE_NEXT 21
|
||||
|
||||
/* arg: u8g_dev_arg_bbx_t * */
|
||||
/* new algorithm with U8G_DEV_MSG_GET_PAGE_BOX makes this msg obsolete */
|
||||
/* #define U8G_DEV_MSG_IS_BBX_INTERSECTION 22 */
|
||||
|
||||
/* arg: u8g_box_t *, fill structure with current page properties */
|
||||
#define U8G_DEV_MSG_GET_PAGE_BOX 23
|
||||
|
||||
/*
|
||||
#define U8G_DEV_MSG_PRIMITIVE_START 30
|
||||
#define U8G_DEV_MSG_PRIMITIVE_END 31
|
||||
*/
|
||||
|
||||
/* arg: u8g_dev_arg_pixel_t * */
|
||||
#define U8G_DEV_MSG_SET_PIXEL 50
|
||||
#define U8G_DEV_MSG_SET_8PIXEL 59
|
||||
|
||||
#define U8G_DEV_MSG_SET_COLOR_INDEX 60
|
||||
|
||||
#define U8G_DEV_MSG_SET_XY_CB 61
|
||||
|
||||
#define U8G_DEV_MSG_GET_WIDTH 70
|
||||
#define U8G_DEV_MSG_GET_HEIGHT 71
|
||||
#define U8G_DEV_MSG_GET_MODE 72
|
||||
|
||||
/*===============================================================*/
|
||||
/* device modes */
|
||||
#define U8G_MODE(is_color, bits_per_pixel) (((is_color)<<4)|(bits_per_pixel))
|
||||
|
||||
#define U8G_MODE_UNKNOWN 0
|
||||
#define U8G_MODE_BW U8G_MODE(0, 1)
|
||||
#define U8G_MODE_GRAY2BIT U8G_MODE(0, 2)
|
||||
#define U8G_MODE_R3G3B2 U8G_MODE(1, 8)
|
||||
|
||||
#define U8G_MODE_GET_BITS_PER_PIXEL(mode) ((mode)&15)
|
||||
#define U8G_MODE_IS_COLOR(mode) (((mode)&16)==0?0:1)
|
||||
|
||||
|
||||
/*===============================================================*/
|
||||
/* com options */
|
||||
|
||||
/* uncomment the following line for Atmega HW SPI double speed, issue 89 */
|
||||
/* #define U8G_HW_SPI_2X 1 */
|
||||
|
||||
/* com messages */
|
||||
|
||||
#define U8G_COM_MSG_STOP 0
|
||||
#define U8G_COM_MSG_INIT 1
|
||||
|
||||
#define U8G_COM_MSG_ADDRESS 2
|
||||
|
||||
/* CHIP_SELECT argument: number of the chip which needs to be activated, so this is more like high active */
|
||||
#define U8G_COM_MSG_CHIP_SELECT 3
|
||||
|
||||
#define U8G_COM_MSG_RESET 4
|
||||
|
||||
#define U8G_COM_MSG_WRITE_BYTE 5
|
||||
#define U8G_COM_MSG_WRITE_SEQ 6
|
||||
#define U8G_COM_MSG_WRITE_SEQ_P 7
|
||||
|
||||
|
||||
/* com driver */
|
||||
uint8_t u8g_com_null_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* u8g_com_null.c */
|
||||
uint8_t u8g_com_arduino_std_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* u8g_com_arduino_std_sw_spi.c */
|
||||
uint8_t u8g_com_arduino_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* u8g_com_arduino_sw_spi.c */
|
||||
uint8_t u8g_com_arduino_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* u8g_com_arduino_hw_spi.c */
|
||||
uint8_t u8g_com_arduino_st7920_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* u8g_com_arduino_st7920_spi.c */
|
||||
uint8_t u8g_com_arduino_st7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* u8g_com_arduino_st7920_hw_spi.c */
|
||||
uint8_t u8g_com_arduino_parallel_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* u8g_com_arduino_parallel.c */
|
||||
uint8_t u8g_com_arduino_fast_parallel_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* u8g_com_arduino_fast_parallel.c */
|
||||
uint8_t u8g_com_arduino_port_d_wr_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* u8g_com_arduino_port_d_wr.c */
|
||||
uint8_t u8g_com_arduino_no_en_parallel_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* u8g_com_arduino_no_en_parallel.c */
|
||||
uint8_t u8g_com_arduino_ssd_i2c_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* u8g_com_arduino_ssd_i2c.c */
|
||||
uint8_t u8g_com_arduino_t6963_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* u8g_com_arduino_t6963.c */
|
||||
|
||||
|
||||
uint8_t u8g_com_atmega_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* u8g_com_atmega_hw_spi.c */
|
||||
uint8_t u8g_com_atmega_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* u8g_com_atmega_sw_spi.c */
|
||||
uint8_t u8g_com_atmega_st7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* u8g_com_atmega_st7920_spi.c */
|
||||
uint8_t u8g_com_atmega_st7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
|
||||
uint8_t u8g_com_atmega_parallel_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* u8g_com_atmega_parallel.c */
|
||||
|
||||
|
||||
/*
|
||||
Translation of system specific com drives to generic com names
|
||||
At the moment, the following generic com drives are available
|
||||
U8G_COM_HW_SPI
|
||||
U8G_COM_SW_SPI
|
||||
U8G_COM_PARALLEL
|
||||
U8G_COM_T6963
|
||||
U8G_COM_FAST_PARALLEL
|
||||
U8G_COM_SSD_I2C
|
||||
|
||||
defined(__18CXX) || defined(__PIC32MX)
|
||||
|
||||
*/
|
||||
/* ==== HW SPI, Arduino ====*/
|
||||
#if defined(ARDUINO)
|
||||
#if defined(__AVR__)
|
||||
#define U8G_COM_HW_SPI u8g_com_arduino_hw_spi_fn
|
||||
#define U8G_COM_ST7920_HW_SPI u8g_com_arduino_st7920_hw_spi_fn
|
||||
#elif defined(__18CXX) || defined(__PIC32MX)
|
||||
#define U8G_COM_HW_SPI u8g_com_null_fn
|
||||
#define U8G_COM_ST7920_HW_SPI u8g_com_null_fn
|
||||
#endif
|
||||
#endif
|
||||
/* ==== HW SPI, not Arduino ====*/
|
||||
#ifndef U8G_COM_HW_SPI
|
||||
#if defined(__AVR__)
|
||||
#define U8G_COM_HW_SPI u8g_com_atmega_hw_spi_fn
|
||||
#define U8G_COM_ST7920_HW_SPI u8g_com_atmega_st7920_hw_spi_fn
|
||||
#endif
|
||||
#endif
|
||||
#ifndef U8G_COM_HW_SPI
|
||||
#define U8G_COM_HW_SPI u8g_com_null_fn
|
||||
#define U8G_COM_ST7920_HW_SPI u8g_com_null_fn
|
||||
#endif
|
||||
|
||||
/* ==== SW SPI, Arduino ====*/
|
||||
#if defined(ARDUINO)
|
||||
#if defined(__AVR__)
|
||||
#define U8G_COM_SW_SPI u8g_com_arduino_sw_spi_fn
|
||||
#define U8G_COM_ST7920_SW_SPI u8g_com_arduino_st7920_spi_fn
|
||||
#elif defined(__18CXX) || defined(__PIC32MX)
|
||||
#define U8G_COM_SW_SPI u8g_com_arduino_sw_spi_fn
|
||||
#define U8G_COM_ST7920_SW_SPI u8g_com_arduino_st7920_spi_fn
|
||||
#elif defined(__arm__) /* Arduino Due */
|
||||
#define U8G_COM_SW_SPI u8g_com_arduino_std_sw_spi_fn
|
||||
#define U8G_COM_ST7920_SW_SPI u8g_com_arduino_st7920_spi_fn
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef U8G_COM_SW_SPI
|
||||
/* ==== SW SPI, not Arduino ====*/
|
||||
#if defined(__AVR__)
|
||||
#define U8G_COM_SW_SPI u8g_com_atmega_sw_spi_fn
|
||||
#define U8G_COM_ST7920_SW_SPI u8g_com_atmega_st7920_sw_spi_fn
|
||||
#endif
|
||||
#endif
|
||||
#ifndef U8G_COM_SW_SPI
|
||||
#define U8G_COM_SW_SPI u8g_com_null_fn
|
||||
#define U8G_COM_ST7920_SW_SPI u8g_com_null_fn
|
||||
#endif
|
||||
|
||||
/* ==== Parallel iinterface, Arduino ====*/
|
||||
#if defined(ARDUINO)
|
||||
#if defined(__AVR__)
|
||||
#define U8G_COM_PARALLEL u8g_com_arduino_parallel_fn
|
||||
#define U8G_COM_FAST_PARALLEL u8g_com_arduino_fast_parallel_fn
|
||||
#define U8G_COM_T6963 u8g_com_arduino_t6963_fn
|
||||
#else /* Arduino Due, Chipkit PIC32 */
|
||||
#define U8G_COM_PARALLEL u8g_com_arduino_parallel_fn
|
||||
#define U8G_COM_FAST_PARALLEL u8g_com_arduino_parallel_fn
|
||||
#define U8G_COM_T6963 u8g_com_null_fn
|
||||
#endif
|
||||
#endif
|
||||
#ifndef U8G_COM_PARALLEL
|
||||
#if defined(__AVR__)
|
||||
#define U8G_COM_PARALLEL u8g_com_atmega_parallel_fn
|
||||
#define U8G_COM_FAST_PARALLEL u8g_com_atmega_parallel_fn
|
||||
#define U8G_COM_T6963 u8g_com_null_fn
|
||||
#endif
|
||||
#endif
|
||||
#ifndef U8G_COM_PARALLEL
|
||||
#define U8G_COM_PARALLEL u8g_com_null_fn
|
||||
#define U8G_COM_FAST_PARALLEL u8g_com_null_fn
|
||||
#define U8G_COM_T6963 u8g_com_null_fn
|
||||
#endif
|
||||
|
||||
#if defined(ARDUINO)
|
||||
#if defined(__AVR__)
|
||||
#define U8G_COM_SSD_I2C u8g_com_arduino_ssd_i2c_fn
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef U8G_COM_SSD_I2C
|
||||
#if defined(__AVR__)
|
||||
/* AVR variant can use the arduino version at the moment */
|
||||
#define U8G_COM_SSD_I2C u8g_com_arduino_ssd_i2c_fn
|
||||
#endif
|
||||
#endif
|
||||
#ifndef U8G_COM_SSD_I2C
|
||||
#define U8G_COM_SSD_I2C u8g_com_null_fn
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/*===============================================================*/
|
||||
/* com api */
|
||||
uint8_t u8g_InitCom(u8g_t *u8g, u8g_dev_t *dev);
|
||||
void u8g_StopCom(u8g_t *u8g, u8g_dev_t *dev);
|
||||
void u8g_EnableCom(u8g_t *u8g, u8g_dev_t *dev); /* obsolete */
|
||||
void u8g_DisableCom(u8g_t *u8g, u8g_dev_t *dev); /* obsolete */
|
||||
void u8g_SetChipSelect(u8g_t *u8g, u8g_dev_t *dev, uint8_t cs);
|
||||
void u8g_SetResetLow(u8g_t *u8g, u8g_dev_t *dev);
|
||||
void u8g_SetResetHigh(u8g_t *u8g, u8g_dev_t *dev);
|
||||
void u8g_SetAddress(u8g_t *u8g, u8g_dev_t *dev, uint8_t address);
|
||||
uint8_t u8g_WriteByte(u8g_t *u8g, u8g_dev_t *dev, uint8_t val);
|
||||
uint8_t u8g_WriteSequence(u8g_t *u8g, u8g_dev_t *dev, uint8_t cnt, uint8_t *seq);
|
||||
uint8_t u8g_WriteSequenceP(u8g_t *u8g, u8g_dev_t *dev, uint8_t cnt, const uint8_t *seq);
|
||||
|
||||
|
||||
|
||||
#define U8G_ESC_DLY(x) 255, ((x) & 0x7f)
|
||||
#define U8G_ESC_CS(x) 255, (0xd0 | ((x)&0x0f))
|
||||
#define U8G_ESC_ADR(x) 255, (0xe0 | ((x)&0x0f))
|
||||
#define U8G_ESC_RST(x) 255, (0xc0 | ((x)&0x0f))
|
||||
#define U8G_ESC_VCC(x) 255, (0xbe | ((x)&0x01))
|
||||
#define U8G_ESC_END 255, 254
|
||||
#define U8G_ESC_255 255, 255
|
||||
//uint8_t u8g_WriteEscSeqP(u8g_t *u8g, u8g_dev_t *dev, u8g_pgm_uint8_t *esc_seq);
|
||||
uint8_t u8g_WriteEscSeqP(u8g_t *u8g, u8g_dev_t *dev, const uint8_t *esc_seq);
|
||||
|
||||
|
||||
/* u8g_com_api_16gr.c */
|
||||
uint8_t u8g_WriteByteBWTo16GrDevice(u8g_t *u8g, u8g_dev_t *dev, uint8_t b);
|
||||
uint8_t u8g_WriteSequenceBWTo16GrDevice(u8g_t *u8g, u8g_dev_t *dev, uint8_t cnt, uint8_t *ptr);
|
||||
uint8_t u8g_WriteByte4LTo16GrDevice(u8g_t *u8g, u8g_dev_t *dev, uint8_t b);
|
||||
uint8_t u8g_WriteSequence4LTo16GrDevice(u8g_t *u8g, u8g_dev_t *dev, uint8_t cnt, uint8_t *ptr);
|
||||
|
||||
|
||||
/*===============================================================*/
|
||||
/* u8g_arduino_common.c */
|
||||
void u8g_com_arduino_digital_write(u8g_t *u8g, uint8_t pin_index, uint8_t value);
|
||||
void u8g_com_arduino_assign_pin_output_high(u8g_t *u8g);
|
||||
|
||||
/*===============================================================*/
|
||||
/* u8g_com_io.c */
|
||||
|
||||
/* create internal number from port and pin */
|
||||
uint8_t u8g_Pin(uint8_t port, uint8_t bitpos);
|
||||
#define PN(port,bitpos) u8g_Pin(port,bitpos)
|
||||
|
||||
/* low level procedures */
|
||||
void u8g_SetPinOutput(uint8_t internal_pin_number);
|
||||
void u8g_SetPinLevel(uint8_t internal_pin_number, uint8_t level);
|
||||
void u8g_SetPinInput(uint8_t internal_pin_number);
|
||||
uint8_t u8g_GetPinLevel(uint8_t internal_pin_number);
|
||||
|
||||
/* u8g level procedures, expect U8G_PI_xxx macro */
|
||||
void u8g_SetPIOutput(u8g_t *u8g, uint8_t pi);
|
||||
void u8g_SetPILevel(u8g_t *u8g, uint8_t pi, uint8_t level);
|
||||
|
||||
|
||||
/*===============================================================*/
|
||||
/* page */
|
||||
struct _u8g_page_t
|
||||
{
|
||||
u8g_uint_t page_height;
|
||||
u8g_uint_t total_height;
|
||||
u8g_uint_t page_y0;
|
||||
u8g_uint_t page_y1;
|
||||
uint8_t page;
|
||||
};
|
||||
typedef struct _u8g_page_t u8g_page_t;
|
||||
|
||||
void u8g_page_First(u8g_page_t *p) U8G_NOINLINE; /* u8g_page.c */
|
||||
void u8g_page_Init(u8g_page_t *p, u8g_uint_t page_height, u8g_uint_t total_height ) U8G_NOINLINE; /* u8g_page.c */
|
||||
uint8_t u8g_page_Next(u8g_page_t *p) U8G_NOINLINE; /* u8g_page.c */
|
||||
|
||||
/*===============================================================*/
|
||||
/* page buffer (pb) */
|
||||
|
||||
struct _u8g_pb_t
|
||||
{
|
||||
u8g_page_t p;
|
||||
u8g_uint_t width; /* pixel width */
|
||||
void *buf;
|
||||
};
|
||||
typedef struct _u8g_pb_t u8g_pb_t;
|
||||
|
||||
|
||||
/* u8g_pb.c */
|
||||
void u8g_pb_Clear(u8g_pb_t *b);
|
||||
uint8_t u8g_pb_IsYIntersection(u8g_pb_t *pb, u8g_uint_t v0, u8g_uint_t v1);
|
||||
uint8_t u8g_pb_IsXIntersection(u8g_pb_t *b, u8g_uint_t v0, u8g_uint_t v1);
|
||||
uint8_t u8g_pb_IsIntersection(u8g_pb_t *pb, u8g_dev_arg_bbx_t *bbx);
|
||||
void u8g_pb_GetPageBox(u8g_pb_t *pb, u8g_box_t *box);
|
||||
uint8_t u8g_pb_Is8PixelVisible(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel);
|
||||
uint8_t u8g_pb_WriteBuffer(u8g_pb_t *b, u8g_t *u8g, u8g_dev_t *dev);
|
||||
|
||||
/*
|
||||
note on __attribute__ ((nocommon))
|
||||
AVR scripts often use --gc-sections on the linker to remove unused section.
|
||||
This works fine for initialed data and text sections. In principle .bss is also
|
||||
handled, but the name##_pb definition is not removed. Reason is, that
|
||||
array definitions are placed in the COMMON section, by default
|
||||
The attribute "nocommon" removes this automatic assignment to the
|
||||
COMMON section and directly puts it into .bss. As a result, if more
|
||||
than one buffer is defined in one file, then it will be removed with --gc-sections
|
||||
|
||||
.. not sure if Arduino IDE uses -fno-common... if yes, then the attribute is
|
||||
redundant.
|
||||
*/
|
||||
#define U8G_PB_DEV(name, width, height, page_height, dev_fn, com_fn) \
|
||||
uint8_t name##_buf[width] U8G_NOCOMMON ; \
|
||||
u8g_pb_t name##_pb = { {page_height, height, 0, 0, 0}, width, name##_buf}; \
|
||||
u8g_dev_t name = { dev_fn, &name##_pb, com_fn }
|
||||
|
||||
|
||||
void u8g_pb8v1_Init(u8g_pb_t *b, void *buf, u8g_uint_t width) U8G_NOINLINE;
|
||||
void u8g_pb8v1_Clear(u8g_pb_t *b) U8G_NOINLINE;
|
||||
|
||||
uint8_t u8g_pb8v1_IsYIntersection(u8g_pb_t *b, u8g_uint_t v0, u8g_uint_t v1);
|
||||
uint8_t u8g_pb8v1_IsXIntersection(u8g_pb_t *b, u8g_uint_t v0, u8g_uint_t v1);
|
||||
uint8_t u8g_pb8v1_WriteBuffer(u8g_pb_t *b, u8g_t *u8g, u8g_dev_t *dev);
|
||||
|
||||
uint8_t u8g_dev_pb8v1_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
|
||||
|
||||
/* u8g_pb16v1.c */
|
||||
uint8_t u8g_dev_pb16v1_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
|
||||
|
||||
/* u8g_pb14v1.c */
|
||||
uint8_t u8g_dev_pb14v1_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
|
||||
|
||||
/* u8g_pb8v2.c */
|
||||
uint8_t u8g_dev_pb8v2_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
|
||||
|
||||
/* u8g_pb16v2.c (double memory of pb8v2) */
|
||||
uint8_t u8g_dev_pb16v2_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
|
||||
|
||||
|
||||
/* u8g_pb8h1.c */
|
||||
uint8_t u8g_dev_pb8h1_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
|
||||
|
||||
/* u8g_pb16h1.c */
|
||||
uint8_t u8g_dev_pb16h1_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
|
||||
|
||||
/* u8g_pb32h1.c */
|
||||
uint8_t u8g_dev_pb32h1_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
|
||||
|
||||
|
||||
/* u8g_pb8h2.c 8 pixel rows, byte has horzontal orientation */
|
||||
uint8_t u8g_dev_pb8h2_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
|
||||
|
||||
/* u8g_pb16h2.c */
|
||||
uint8_t u8g_dev_pb16h2_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
|
||||
|
||||
|
||||
|
||||
/* u8g_pb8h1f.c */
|
||||
uint8_t u8g_dev_pb8h1f_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
|
||||
|
||||
/* u8g_pb8h8.c */
|
||||
uint8_t u8g_dev_pb8h8_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
|
||||
|
||||
|
||||
|
||||
/*===============================================================*/
|
||||
/* u8g_ll_api.c */
|
||||
|
||||
/* cursor draw callback */
|
||||
typedef void (*u8g_draw_cursor_fn)(u8g_t *u8g);
|
||||
|
||||
/* vertical reference point calculation callback */
|
||||
typedef u8g_uint_t (*u8g_font_calc_vref_fnptr)(u8g_t *u8g);
|
||||
|
||||
/* state backup and restore procedure */
|
||||
typedef void (*u8g_state_cb)(uint8_t msg);
|
||||
|
||||
|
||||
/* PI = Pin Index */
|
||||
|
||||
/* reset pin, usually optional */
|
||||
#define U8G_PI_RESET 0
|
||||
|
||||
/* address / data or instruction */
|
||||
#define U8G_PI_A0 1
|
||||
#define U8G_PI_DI 1
|
||||
|
||||
/* chip select line */
|
||||
#define U8G_PI_CS 2
|
||||
#define U8G_PI_CS1 2
|
||||
#define U8G_PI_CS2 3
|
||||
/* Feb 2013: A0 state moved from 7 to 3 for t6963 controller*/
|
||||
#define U8G_PI_A0_STATE 3
|
||||
|
||||
/* enable / clock signal */
|
||||
#define U8G_PI_EN 4
|
||||
#define U8G_PI_CS_STATE 4
|
||||
#define U8G_PI_SCK 4
|
||||
#define U8G_PI_SCL 4
|
||||
#define U8G_PI_RD 4
|
||||
|
||||
|
||||
/* data pins, shared with SPI and I2C pins */
|
||||
#define U8G_PI_D0 5
|
||||
#define U8G_PI_MOSI 5
|
||||
#define U8G_PI_SDA 5
|
||||
#define U8G_PI_D1 6
|
||||
#define U8G_PI_MISO 6
|
||||
#define U8G_PI_D2 7
|
||||
#define U8G_PI_D3 8
|
||||
#define U8G_PI_SET_A0 8
|
||||
#define U8G_PI_D4 9
|
||||
#define U8G_PI_D5 10
|
||||
#define U8G_PI_I2C_OPTION 11
|
||||
#define U8G_PI_D6 11
|
||||
#define U8G_PI_D7 12
|
||||
|
||||
/* read/write pin, must be the last pin in the list, this means U8G_PIN_LIST_LEN = U8G_PI_RW + 1*/
|
||||
#define U8G_PI_WR 13
|
||||
#define U8G_PI_RW 13
|
||||
|
||||
#define U8G_PIN_LIST_LEN 14
|
||||
|
||||
|
||||
#define U8G_PIN_NONE 255
|
||||
|
||||
#define U8G_FONT_HEIGHT_MODE_TEXT 0
|
||||
#define U8G_FONT_HEIGHT_MODE_XTEXT 1
|
||||
#define U8G_FONT_HEIGHT_MODE_ALL 2
|
||||
|
||||
struct _u8g_t
|
||||
{
|
||||
u8g_uint_t width;
|
||||
u8g_uint_t height;
|
||||
|
||||
|
||||
u8g_dev_t *dev; /* first device in the device chain */
|
||||
const u8g_pgm_uint8_t *font; /* regular font for all text procedures */
|
||||
const u8g_pgm_uint8_t *cursor_font; /* special font for cursor procedures */
|
||||
uint8_t cursor_fg_color, cursor_bg_color;
|
||||
uint8_t cursor_encoding;
|
||||
uint8_t mode; /* display mode, one of U8G_MODE_xxx */
|
||||
u8g_uint_t cursor_x;
|
||||
u8g_uint_t cursor_y;
|
||||
u8g_draw_cursor_fn cursor_fn;
|
||||
|
||||
int8_t glyph_dx;
|
||||
int8_t glyph_x;
|
||||
int8_t glyph_y;
|
||||
uint8_t glyph_width;
|
||||
uint8_t glyph_height;
|
||||
|
||||
u8g_font_calc_vref_fnptr font_calc_vref;
|
||||
uint8_t font_height_mode;
|
||||
int8_t font_ref_ascent;
|
||||
int8_t font_ref_descent;
|
||||
uint8_t font_line_spacing_factor; /* line_spacing = factor * (ascent - descent) / 64 */
|
||||
uint8_t line_spacing;
|
||||
|
||||
u8g_dev_arg_pixel_t arg_pixel;
|
||||
/* uint8_t color_index; */
|
||||
|
||||
uint8_t pin_list[U8G_PIN_LIST_LEN];
|
||||
|
||||
u8g_state_cb state_cb;
|
||||
|
||||
u8g_box_t current_page; /* current box of the visible page */
|
||||
|
||||
};
|
||||
|
||||
#define u8g_GetFontAscent(u8g) ((u8g)->font_ref_ascent)
|
||||
#define u8g_GetFontDescent(u8g) ((u8g)->font_ref_descent)
|
||||
#define u8g_GetFontLineSpacing(u8g) ((u8g)->line_spacing)
|
||||
|
||||
uint8_t u8g_call_dev_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
|
||||
|
||||
uint8_t u8g_InitLL(u8g_t *u8g, u8g_dev_t *dev);
|
||||
void u8g_FirstPageLL(u8g_t *u8g, u8g_dev_t *dev);
|
||||
uint8_t u8g_NextPageLL(u8g_t *u8g, u8g_dev_t *dev);
|
||||
uint8_t u8g_SetContrastLL(u8g_t *u8g, u8g_dev_t *dev, uint8_t contrast);
|
||||
void u8g_DrawPixelLL(u8g_t *u8g, u8g_dev_t *dev, u8g_uint_t x, u8g_uint_t y);
|
||||
void u8g_Draw8PixelLL(u8g_t *u8g, u8g_dev_t *dev, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_t pixel);
|
||||
uint8_t u8g_IsBBXIntersectionLL(u8g_t *u8g, u8g_dev_t *dev, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h); /* obsolete */
|
||||
u8g_uint_t u8g_GetWidthLL(u8g_t *u8g, u8g_dev_t *dev);
|
||||
u8g_uint_t u8g_GetHeightLL(u8g_t *u8g, u8g_dev_t *dev);
|
||||
|
||||
void u8g_UpdateDimension(u8g_t *u8g);
|
||||
uint8_t u8g_Begin(u8g_t *u8g); /* reset device, put it into default state and call u8g_UpdateDimension() */
|
||||
uint8_t u8g_Init(u8g_t *u8g, u8g_dev_t *dev); /* only usefull if the device only as hardcoded ports */
|
||||
uint8_t u8g_InitSPI(u8g_t *u8g, u8g_dev_t *dev, uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset);
|
||||
uint8_t u8g_InitHWSPI(u8g_t *u8g, u8g_dev_t *dev, uint8_t cs, uint8_t a0, uint8_t reset);
|
||||
uint8_t u8g_InitI2C(u8g_t *u8g, u8g_dev_t *dev, uint8_t options); /* use U8G_I2C_OPT_NONE as options */
|
||||
uint8_t u8g_Init8BitFixedPort(u8g_t *u8g, u8g_dev_t *dev, uint8_t en, uint8_t cs, uint8_t di, uint8_t rw, uint8_t reset);
|
||||
uint8_t u8g_Init8Bit(u8g_t *u8g, u8g_dev_t *dev, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7,
|
||||
uint8_t en, uint8_t cs1, uint8_t cs2, uint8_t di, uint8_t rw, uint8_t reset);
|
||||
uint8_t u8g_InitRW8Bit(u8g_t *u8g, u8g_dev_t *dev, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7,
|
||||
uint8_t cs, uint8_t a0, uint8_t wr, uint8_t rd, uint8_t reset);
|
||||
void u8g_FirstPage(u8g_t *u8g);
|
||||
uint8_t u8g_NextPage(u8g_t *u8g);
|
||||
uint8_t u8g_SetContrast(u8g_t *u8g, uint8_t contrast);
|
||||
void u8g_SleepOn(u8g_t *u8g);
|
||||
void u8g_SleepOff(u8g_t *u8g);
|
||||
void u8g_DrawPixel(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y);
|
||||
void u8g_Draw8Pixel(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_t pixel);
|
||||
|
||||
uint8_t u8g_Stop(u8g_t *u8g);
|
||||
void u8g_SetColorIndex(u8g_t *u8g, uint8_t idx);
|
||||
uint8_t u8g_GetColorIndex(u8g_t *u8g);
|
||||
|
||||
uint8_t u8g_GetDefaultForegroundColor(u8g_t *u8g);
|
||||
void u8g_SetDefaultForegroundColor(u8g_t *u8g);
|
||||
|
||||
uint8_t u8g_GetDefaultBackgroundColor(u8g_t *u8g);
|
||||
void u8g_SetDefaultBackgroundColor(u8g_t *u8g);
|
||||
|
||||
uint8_t u8g_GetDefaultMidColor(u8g_t *u8g);
|
||||
void u8g_SetDefaultMidColor(u8g_t *u8g);
|
||||
|
||||
#define u8g_GetWidth(u8g) ((u8g)->width)
|
||||
#define u8g_GetHeight(u8g) ((u8g)->height)
|
||||
#define u8g_GetMode(u8g) ((u8g)->mode)
|
||||
/*
|
||||
U8G_MODE_GET_BITS_PER_PIXEL(u8g_GetMode(u8g))
|
||||
U8G_MODE_IS_COLOR(u8g_GetMode(u8g))
|
||||
*/
|
||||
|
||||
/* u8g_state.c */
|
||||
#define U8G_STATE_ENV_IDX 0
|
||||
#define U8G_STATE_U8G_IDX 1
|
||||
#define U8G_STATE_RESTORE 0
|
||||
#define U8G_STATE_BACKUP 1
|
||||
#define U8G_STATE_MSG_COMPOSE(cmd,idx) (((cmd)<<1) | (idx))
|
||||
|
||||
#define U8G_STATE_MSG_RESTORE_ENV U8G_STATE_MSG_COMPOSE(U8G_STATE_RESTORE,U8G_STATE_ENV_IDX)
|
||||
#define U8G_STATE_MSG_BACKUP_ENV U8G_STATE_MSG_COMPOSE(U8G_STATE_BACKUP,U8G_STATE_ENV_IDX)
|
||||
#define U8G_STATE_MSG_RESTORE_U8G U8G_STATE_MSG_COMPOSE(U8G_STATE_RESTORE,U8G_STATE_U8G_IDX)
|
||||
#define U8G_STATE_MSG_BACKUP_U8G U8G_STATE_MSG_COMPOSE(U8G_STATE_BACKUP,U8G_STATE_U8G_IDX)
|
||||
|
||||
#define U8G_STATE_MSG_GET_IDX(msg) ((msg)&1)
|
||||
#define U8G_STATE_MSG_IS_BACKUP(msg) ((msg)&2)
|
||||
|
||||
|
||||
|
||||
void u8g_state_dummy_cb(uint8_t msg);
|
||||
void u8g_backup_avr_spi(uint8_t msg); /* backup SPI state on atmel avr controller */
|
||||
|
||||
void u8g_SetHardwareBackup(u8g_t *u8g, u8g_state_cb backup_cb);
|
||||
|
||||
/* u8g_clip.c */
|
||||
|
||||
uint8_t u8g_IsBBXIntersection(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h);
|
||||
|
||||
|
||||
/* u8g_rot.c */
|
||||
|
||||
void u8g_UndoRotation(u8g_t *u8g);
|
||||
void u8g_SetRot90(u8g_t *u8g);
|
||||
void u8g_SetRot180(u8g_t *u8g);
|
||||
void u8g_SetRot270(u8g_t *u8g);
|
||||
|
||||
/* u8g_scale.c */
|
||||
|
||||
void u8g_UndoScale(u8g_t *u8g);
|
||||
void u8g_SetScale2x2(u8g_t *u8g);
|
||||
|
||||
|
||||
/* u8g_font.c */
|
||||
|
||||
size_t u8g_font_GetSize(const void *font);
|
||||
uint8_t u8g_font_GetFontStartEncoding(const void *font) U8G_NOINLINE;
|
||||
uint8_t u8g_font_GetFontEndEncoding(const void *font) U8G_NOINLINE;
|
||||
|
||||
void u8g_SetFont(u8g_t *u8g, const u8g_fntpgm_uint8_t *font);
|
||||
|
||||
uint8_t u8g_GetFontBBXWidth(u8g_t *u8g);
|
||||
uint8_t u8g_GetFontBBXHeight(u8g_t *u8g);
|
||||
int8_t u8g_GetFontBBXOffX(u8g_t *u8g);
|
||||
int8_t u8g_GetFontBBXOffY(u8g_t *u8g);
|
||||
uint8_t u8g_GetFontCapitalAHeight(u8g_t *u8g);
|
||||
|
||||
uint8_t u8g_IsGlyph(u8g_t *u8g, uint8_t requested_encoding);
|
||||
int8_t u8g_GetGlyphDeltaX(u8g_t *u8g, uint8_t requested_encoding);
|
||||
|
||||
int8_t u8g_draw_glyph(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t encoding); /* used by u8g_cursor.c */
|
||||
|
||||
int8_t u8g_DrawGlyphDir(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_t encoding);
|
||||
int8_t u8g_DrawGlyph(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t encoding);
|
||||
int8_t u8g_DrawGlyph90(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t encoding);
|
||||
int8_t u8g_DrawGlyph180(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t encoding);
|
||||
int8_t u8g_DrawGlyph270(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t encoding);
|
||||
int8_t u8g_DrawGlyphFontBBX(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_t encoding);
|
||||
|
||||
u8g_uint_t u8g_DrawStr(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const char *s);
|
||||
u8g_uint_t u8g_DrawStr90(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const char *s);
|
||||
u8g_uint_t u8g_DrawStr180(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const char *s);
|
||||
u8g_uint_t u8g_DrawStr270(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const char *s);
|
||||
|
||||
u8g_uint_t u8g_DrawStrDir(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t dir, const char *s);
|
||||
|
||||
|
||||
u8g_uint_t u8g_DrawStrP(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const u8g_pgm_uint8_t *s);
|
||||
u8g_uint_t u8g_DrawStr90P(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const u8g_pgm_uint8_t *s);
|
||||
u8g_uint_t u8g_DrawStr180P(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const u8g_pgm_uint8_t *s);
|
||||
u8g_uint_t u8g_DrawStr270P(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const u8g_pgm_uint8_t *s);
|
||||
|
||||
|
||||
void u8g_SetFontRefHeightText(u8g_t *u8g);
|
||||
void u8g_SetFontRefHeightExtendedText(u8g_t *u8g);
|
||||
void u8g_SetFontRefHeightAll(u8g_t *u8g);
|
||||
void u8g_SetFontLineSpacingFactor(u8g_t *u8g, uint8_t factor);
|
||||
|
||||
u8g_uint_t u8g_font_calc_vref_font(u8g_t *u8g);
|
||||
u8g_uint_t u8g_font_calc_vref_bottom(u8g_t *u8g);
|
||||
u8g_uint_t u8g_font_calc_vref_top(u8g_t *u8g);
|
||||
u8g_uint_t u8g_font_calc_vref_center(u8g_t *u8g);
|
||||
|
||||
void u8g_SetFontPosBaseline(u8g_t *u8g);
|
||||
void u8g_SetFontPosBottom(u8g_t *u8g);
|
||||
void u8g_SetFontPosCenter(u8g_t *u8g);
|
||||
void u8g_SetFontPosTop(u8g_t *u8g);
|
||||
|
||||
|
||||
u8g_uint_t u8g_GetStrPixelWidth(u8g_t *u8g, const char *s);
|
||||
u8g_uint_t u8g_GetStrPixelWidthP(u8g_t *u8g, const u8g_pgm_uint8_t *s);
|
||||
int8_t u8g_GetStrX(u8g_t *u8g, const char *s);
|
||||
int8_t u8g_GetStrXP(u8g_t *u8g, const u8g_pgm_uint8_t *s);
|
||||
u8g_uint_t u8g_GetStrWidth(u8g_t *u8g, const char *s);
|
||||
u8g_uint_t u8g_GetStrWidthP(u8g_t *u8g, const u8g_pgm_uint8_t *s);
|
||||
|
||||
u8g_uint_t u8g_DrawStrFontBBX(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t dir, const char *s);
|
||||
|
||||
void u8g_GetStrMinBox(u8g_t *u8g, const char *s, u8g_uint_t *x, u8g_uint_t *y, u8g_uint_t *width, u8g_uint_t *height);
|
||||
void u8g_GetStrAMinBox(u8g_t *u8g, const char *s, u8g_uint_t *x, u8g_uint_t *y, u8g_uint_t *width, u8g_uint_t *height);
|
||||
|
||||
/* u8g_rect.c */
|
||||
|
||||
void u8g_draw_box(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h) U8G_NOINLINE;
|
||||
|
||||
void u8g_DrawHLine(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w);
|
||||
void u8g_DrawVLine(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w);
|
||||
void u8g_DrawFrame(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h);
|
||||
void u8g_DrawBox(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h);
|
||||
|
||||
void u8g_DrawRFrame(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h, u8g_uint_t r);
|
||||
void u8g_DrawRBox(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h, u8g_uint_t r);
|
||||
|
||||
/* u8g_bitmap.c */
|
||||
|
||||
void u8g_DrawHBitmap(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t cnt, const uint8_t *bitmap);
|
||||
void u8g_DrawHBitmapP(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t cnt, const u8g_pgm_uint8_t *bitmap);
|
||||
void u8g_DrawBitmap(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t cnt, u8g_uint_t h, const uint8_t *bitmap);
|
||||
void u8g_DrawBitmapP(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t cnt, u8g_uint_t h, const u8g_pgm_uint8_t *bitmap);
|
||||
|
||||
void u8g_DrawXBM(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h, const uint8_t *bitmap);
|
||||
void u8g_DrawXBMP(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h, const u8g_pgm_uint8_t *bitmap);
|
||||
|
||||
|
||||
/* u8g_line.c */
|
||||
void u8g_DrawLine(u8g_t *u8g, u8g_uint_t x1, u8g_uint_t y1, u8g_uint_t x2, u8g_uint_t y2);
|
||||
|
||||
|
||||
/* u8g_circle.c */
|
||||
|
||||
/* the following, commented code has been rewritten or is not yet finished
|
||||
#define U8G_CIRC_UPPER_RIGHT 0x01
|
||||
#define U8G_CIRC_UPPER_LEFT 0x02
|
||||
#define U8G_CIRC_LOWER_LEFT 0x04
|
||||
#define U8G_CIRC_LOWER_RIGHT 0x08
|
||||
#define U8G_CIRC_ALL (U8G_CIRC_UPPER_RIGHT|U8G_CIRC_UPPER_LEFT|U8G_CIRC_LOWER_RIGHT|U8G_CIRC_LOWER_LEFT)
|
||||
void u8g_DrawEmpCirc(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rad, uint8_t option);
|
||||
void u8g_DrawFillCirc(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rad, uint8_t option);
|
||||
void u8g_DrawEllipseRect(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t x1, u8g_uint_t y1);
|
||||
*/
|
||||
|
||||
#define U8G_DRAW_UPPER_RIGHT 0x01
|
||||
#define U8G_DRAW_UPPER_LEFT 0x02
|
||||
#define U8G_DRAW_LOWER_LEFT 0x04
|
||||
#define U8G_DRAW_LOWER_RIGHT 0x08
|
||||
#define U8G_DRAW_ALL (U8G_DRAW_UPPER_RIGHT|U8G_DRAW_UPPER_LEFT|U8G_DRAW_LOWER_RIGHT|U8G_DRAW_LOWER_LEFT)
|
||||
|
||||
void u8g_draw_circle(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rad, uint8_t option) U8G_NOINLINE;
|
||||
void u8g_draw_disc(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rad, uint8_t option) U8G_NOINLINE;
|
||||
|
||||
void u8g_DrawCircle(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rad, uint8_t option);
|
||||
void u8g_DrawDisc(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rad, uint8_t option);
|
||||
|
||||
/* u8g_clip.c */
|
||||
uint8_t u8g_is_box_bbx_intersection(u8g_box_t *box, u8g_dev_arg_bbx_t *bbx);
|
||||
|
||||
|
||||
/* u8g_cursor.c */
|
||||
void u8g_SetCursorFont(u8g_t *u8g, const u8g_pgm_uint8_t *cursor_font);
|
||||
void u8g_SetCursorStyle(u8g_t *u8g, uint8_t encoding);
|
||||
void u8g_SetCursorPos(u8g_t *u8g, u8g_uint_t cursor_x, u8g_uint_t cursor_y);
|
||||
void u8g_SetCursorColor(u8g_t *u8g, uint8_t fg, uint8_t bg);
|
||||
void u8g_EnableCursor(u8g_t *u8g);
|
||||
void u8g_DisableCursor(u8g_t *u8g);
|
||||
void u8g_DrawCursor(u8g_t *u8g);
|
||||
|
||||
|
||||
|
||||
/*===============================================================*/
|
||||
/* u8g_virtual_screen.c */
|
||||
void u8g_SetVirtualScreenDimension(u8g_t *vs_u8g, u8g_uint_t width, u8g_uint_t height);
|
||||
uint8_t u8g_AddToVirtualScreen(u8g_t *vs_u8g, u8g_uint_t x, u8g_uint_t y, u8g_t *child_u8g);
|
||||
|
||||
/*===============================================================*/
|
||||
void st_Draw(uint8_t fps);
|
||||
void st_Step(uint8_t player_pos, uint8_t is_auto_fire, uint8_t is_fire);
|
||||
|
||||
/*===============================================================*/
|
||||
/* u8g_com_i2c.c */
|
||||
|
||||
/* options for u8g_i2c_init() */
|
||||
#define U8G_I2C_OPT_NONE 0
|
||||
|
||||
/* retrun values from u8g_twi_get_error() */
|
||||
#define U8G_I2C_ERR_NONE 0x00
|
||||
/* the following values are bit masks */
|
||||
#define U8G_I2C_ERR_TIMEOUT 0x01
|
||||
#define U8G_I2C_ERR_BUS 0x02
|
||||
|
||||
void u8g_i2c_clear_error(void) U8G_NOINLINE;
|
||||
uint8_t u8g_i2c_get_error(void) U8G_NOINLINE;
|
||||
uint8_t u8g_i2c_get_err_pos(void) U8G_NOINLINE;
|
||||
void u8g_i2c_init(uint8_t options) U8G_NOINLINE; /* use U8G_I2C_OPT_NONE as options */
|
||||
uint8_t u8g_i2c_wait(uint8_t mask, uint8_t pos) U8G_NOINLINE;
|
||||
uint8_t u8g_i2c_start(uint8_t sla) U8G_NOINLINE;
|
||||
uint8_t u8g_i2c_send_byte(uint8_t data) U8G_NOINLINE;
|
||||
void u8g_i2c_stop(void) U8G_NOINLINE;
|
||||
|
||||
|
||||
/*===============================================================*/
|
||||
/* u8g_u8toa.c */
|
||||
/* v = value, d = number of digits */
|
||||
const char *u8g_u8toa(uint8_t v, uint8_t d);
|
||||
|
||||
/* u8g_u8toa.c */
|
||||
/* v = value, d = number of digits */
|
||||
const char *u8g_u16toa(uint16_t v, uint8_t d);
|
||||
|
||||
/*===============================================================*/
|
||||
/* u8g_delay.c */
|
||||
|
||||
/* delay by the specified number of milliseconds */
|
||||
void u8g_Delay(uint16_t val);
|
||||
|
||||
/* delay by one microsecond */
|
||||
void u8g_MicroDelay(void);
|
||||
|
||||
/* delay by 10 microseconds */
|
||||
void u8g_10MicroDelay(void);
|
||||
|
||||
/*===============================================================*/
|
||||
/* chessengine.c */
|
||||
#define CHESS_KEY_NONE 0
|
||||
#define CHESS_KEY_NEXT 1
|
||||
#define CHESS_KEY_PREV 2
|
||||
#define CHESS_KEY_SELECT 3
|
||||
#define CHESS_KEY_BACK 4
|
||||
|
||||
void chess_Init(u8g_t *u8g, uint8_t empty_body_color);
|
||||
void chess_Draw(void);
|
||||
void chess_Step(uint8_t keycode);
|
||||
|
||||
/*===============================================================*/
|
||||
/* font definitions */
|
||||
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_m2icon_5[] U8G_SECTION(".progmem.u8g_font_m2icon_5");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_m2icon_7[] U8G_SECTION(".progmem.u8g_font_m2icon_7");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_m2icon_9[] U8G_SECTION(".progmem.u8g_font_m2icon_9");
|
||||
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_u8glib_4[] U8G_SECTION(".progmem.u8g_font_u8glib_4");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_u8glib_4r[] U8G_SECTION(".progmem.u8g_font_u8glib_4r");
|
||||
|
||||
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_6x12_75r[] U8G_SECTION(".progmem.u8g_font_6x12_75r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_6x13_75r[] U8G_SECTION(".progmem.u8g_font_6x13_75r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_7x13_75r[] U8G_SECTION(".progmem.u8g_font_7x13_75r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_8x13_75r[] U8G_SECTION(".progmem.u8g_font_8x13_75r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_9x15_75r[] U8G_SECTION(".progmem.u8g_font_9x15_75r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_9x18_75r[] U8G_SECTION(".progmem.u8g_font_9x18_75r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_cu12_75r[] U8G_SECTION(".progmem.u8g_font_cu12_75r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_unifont_75r[] U8G_SECTION(".progmem.u8g_font_unifont_75r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_10x20_75r[] U8G_SECTION(".progmem.u8g_font_10x20_75r");
|
||||
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_10x20_67_75[] U8G_SECTION(".progmem.u8g_font_10x20_67_75");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_10x20_78_79[] U8G_SECTION(".progmem.u8g_font_10x20_78_79");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_10x20[] U8G_SECTION(".progmem.u8g_font_10x20");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_10x20r[] U8G_SECTION(".progmem.u8g_font_10x20r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_4x6[] U8G_SECTION(".progmem.u8g_font_4x6");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_4x6r[] U8G_SECTION(".progmem.u8g_font_4x6r");
|
||||
//extern const u8g_fntpgm_uint8_t u8g_font_4x6n[] U8G_SECTION(".progmem.u8g_font_4x6n");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_5x7[] U8G_SECTION(".progmem.u8g_font_5x7");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_5x7r[] U8G_SECTION(".progmem.u8g_font_5x7r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_5x8[] U8G_SECTION(".progmem.u8g_font_5x8");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_5x8r[] U8G_SECTION(".progmem.u8g_font_5x8r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_6x10[] U8G_SECTION(".progmem.u8g_font_6x10");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_6x10r[] U8G_SECTION(".progmem.u8g_font_6x10r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_6x12_67_75[] U8G_SECTION(".progmem.u8g_font_6x12_67_75");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_6x12_78_79[] U8G_SECTION(".progmem.u8g_font_6x12_78_79");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_6x12[] U8G_SECTION(".progmem.u8g_font_6x12");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_6x12r[] U8G_SECTION(".progmem.u8g_font_6x12r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_6x13_67_75[] U8G_SECTION(".progmem.u8g_font_6x13_67_75");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_6x13_78_79[] U8G_SECTION(".progmem.u8g_font_6x13_78_79");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_6x13B[] U8G_SECTION(".progmem.u8g_font_6x13B");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_6x13Br[] U8G_SECTION(".progmem.u8g_font_6x13Br");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_6x13[] U8G_SECTION(".progmem.u8g_font_6x13");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_6x13r[] U8G_SECTION(".progmem.u8g_font_6x13r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_6x13O[] U8G_SECTION(".progmem.u8g_font_6x13O");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_6x13Or[] U8G_SECTION(".progmem.u8g_font_6x13Or");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_7x13_67_75[] U8G_SECTION(".progmem.u8g_font_7x13_67_75");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_7x13_78_79[] U8G_SECTION(".progmem.u8g_font_7x13_78_79");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_7x13B[] U8G_SECTION(".progmem.u8g_font_7x13B");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_7x13Br[] U8G_SECTION(".progmem.u8g_font_7x13Br");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_7x13[] U8G_SECTION(".progmem.u8g_font_7x13");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_7x13r[] U8G_SECTION(".progmem.u8g_font_7x13r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_7x13O[] U8G_SECTION(".progmem.u8g_font_7x13O");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_7x13Or[] U8G_SECTION(".progmem.u8g_font_7x13Or");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_7x14B[] U8G_SECTION(".progmem.u8g_font_7x14B");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_7x14Br[] U8G_SECTION(".progmem.u8g_font_7x14Br");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_7x14[] U8G_SECTION(".progmem.u8g_font_7x14");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_7x14r[] U8G_SECTION(".progmem.u8g_font_7x14r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_8x13_67_75[] U8G_SECTION(".progmem.u8g_font_8x13_67_75");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_8x13B[] U8G_SECTION(".progmem.u8g_font_8x13B");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_8x13Br[] U8G_SECTION(".progmem.u8g_font_8x13Br");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_8x13[] U8G_SECTION(".progmem.u8g_font_8x13");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_8x13r[] U8G_SECTION(".progmem.u8g_font_8x13r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_8x13O[] U8G_SECTION(".progmem.u8g_font_8x13O");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_8x13Or[] U8G_SECTION(".progmem.u8g_font_8x13Or");
|
||||
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_9x15_67_75[] U8G_SECTION(".progmem.u8g_font_9x15_67_75");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_9x15_78_79[] U8G_SECTION(".progmem.u8g_font_9x15_78_79");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_9x15B[] U8G_SECTION(".progmem.u8g_font_9x15B");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_9x15Br[] U8G_SECTION(".progmem.u8g_font_9x15Br");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_9x15[] U8G_SECTION(".progmem.u8g_font_9x15");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_9x15r[] U8G_SECTION(".progmem.u8g_font_9x15r");
|
||||
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_9x18_67_75[] U8G_SECTION(".progmem.u8g_font_9x18_67_75");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_9x18_78_79[] U8G_SECTION(".progmem.u8g_font_9x18_78_79");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_9x18B[] U8G_SECTION(".progmem.u8g_font_9x18B");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_9x18[] U8G_SECTION(".progmem.u8g_font_9x18");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_9x18Br[] U8G_SECTION(".progmem.u8g_font_9x18Br");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_9x18r[] U8G_SECTION(".progmem.u8g_font_9x18r");
|
||||
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_cursor[] U8G_SECTION(".progmem.u8g_font_cursor");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_cursorr[] U8G_SECTION(".progmem.u8g_font_cursorr");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_micro[] U8G_SECTION(".progmem.u8g_font_micro");
|
||||
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_cu12_67_75[] U8G_SECTION(".progmem.u8g_font_cu12_67_75");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_cu12_78_79[] U8G_SECTION(".progmem.u8g_font_cu12_78_79");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_cu12[] U8G_SECTION(".progmem.u8g_font_cu12");
|
||||
|
||||
/*
|
||||
Free-Universal Bold
|
||||
r: Reduced char set (codes 32 - 128)
|
||||
n: Numbers (codes 42 - 57)
|
||||
no char: Full set (codes 32 - 255)
|
||||
*/
|
||||
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_fub11[] U8G_SECTION(".progmem.u8g_font_fub11");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_fub11r[] U8G_SECTION(".progmem.u8g_font_fub11r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_fub11n[] U8G_SECTION(".progmem.u8g_font_fub11n");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_fub14[] U8G_SECTION(".progmem.u8g_font_fub14");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_fub14r[] U8G_SECTION(".progmem.u8g_font_fub14r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_fub14n[] U8G_SECTION(".progmem.u8g_font_fub14n");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_fub17[] U8G_SECTION(".progmem.u8g_font_fub17");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_fub17r[] U8G_SECTION(".progmem.u8g_font_fub17r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_fub17n[] U8G_SECTION(".progmem.u8g_font_fub17n");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_fub20[] U8G_SECTION(".progmem.u8g_font_fub20");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_fub20r[] U8G_SECTION(".progmem.u8g_font_fub20r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_fub20n[] U8G_SECTION(".progmem.u8g_font_fub20n");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_fub25[] U8G_SECTION(".progmem.u8g_font_fub25");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_fub25r[] U8G_SECTION(".progmem.u8g_font_fub25r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_fub25n[] U8G_SECTION(".progmem.u8g_font_fub25n");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_fub30[] U8G_SECTION(".progmem.u8g_font_fub30");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_fub30r[] U8G_SECTION(".progmem.u8g_font_fub30r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_fub30n[] U8G_SECTION(".progmem.u8g_font_fub30n");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_fub35n[] U8G_SECTION(".progmem.u8g_font_fub35n");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_fub42n[] U8G_SECTION(".progmem.u8g_font_fub42n");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_fub49n[] U8G_SECTION(".progmem.u8g_font_fub49n");
|
||||
|
||||
/*
|
||||
Free-Universal Regular
|
||||
r: Reduced char set (codes 32 - 128)
|
||||
n: Numbers (codes 42 - 57)
|
||||
no char: Full set (codes 32 - 255)
|
||||
*/
|
||||
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_fur11[] U8G_SECTION(".progmem.u8g_font_fur11");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_fur11r[] U8G_SECTION(".progmem.u8g_font_fur11r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_fur11n[] U8G_SECTION(".progmem.u8g_font_fur11n");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_fur14[] U8G_SECTION(".progmem.u8g_font_fur14");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_fur14r[] U8G_SECTION(".progmem.u8g_font_fur14r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_fur14n[] U8G_SECTION(".progmem.u8g_font_fur14n");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_fur17[] U8G_SECTION(".progmem.u8g_font_fur17");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_fur17r[] U8G_SECTION(".progmem.u8g_font_fur17r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_fur17n[] U8G_SECTION(".progmem.u8g_font_fur17n");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_fur20[] U8G_SECTION(".progmem.u8g_font_fur20");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_fur20r[] U8G_SECTION(".progmem.u8g_font_fur20r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_fur20n[] U8G_SECTION(".progmem.u8g_font_fur20n");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_fur25[] U8G_SECTION(".progmem.u8g_font_fur25");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_fur25r[] U8G_SECTION(".progmem.u8g_font_fur25r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_fur25n[] U8G_SECTION(".progmem.u8g_font_fur25n");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_fur30[] U8G_SECTION(".progmem.u8g_font_fur30");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_fur30r[] U8G_SECTION(".progmem.u8g_font_fur30r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_fur30n[] U8G_SECTION(".progmem.u8g_font_fur30n");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_fur35n[] U8G_SECTION(".progmem.u8g_font_fur35n");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_fur42n[] U8G_SECTION(".progmem.u8g_font_fur42n");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_fur49n[] U8G_SECTION(".progmem.u8g_font_fur49n");
|
||||
|
||||
/*
|
||||
Gentium Bold
|
||||
r: Reduced char set (codes 32 - 128)
|
||||
n: Numbers (codes 42 - 57)
|
||||
no char: Full set (codes 32 - 255)
|
||||
*/
|
||||
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_gdb11[] U8G_SECTION(".progmem.u8g_font_gdb11");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_gdb12[] U8G_SECTION(".progmem.u8g_font_gdb12");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_gdb14[] U8G_SECTION(".progmem.u8g_font_gdb14");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_gdb17[] U8G_SECTION(".progmem.u8g_font_gdb17");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_gdb20[] U8G_SECTION(".progmem.u8g_font_gdb20");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_gdb25[] U8G_SECTION(".progmem.u8g_font_gdb25");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_gdb30[] U8G_SECTION(".progmem.u8g_font_gdb30");
|
||||
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_gdb11r[] U8G_SECTION(".progmem.u8g_font_gdb11r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_gdb12r[] U8G_SECTION(".progmem.u8g_font_gdb12r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_gdb14r[] U8G_SECTION(".progmem.u8g_font_gdb14r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_gdb17r[] U8G_SECTION(".progmem.u8g_font_gdb17r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_gdb20r[] U8G_SECTION(".progmem.u8g_font_gdb20r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_gdb25r[] U8G_SECTION(".progmem.u8g_font_gdb25r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_gdb30r[] U8G_SECTION(".progmem.u8g_font_gdb30r");
|
||||
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_gdb11n[] U8G_SECTION(".progmem.u8g_font_gdb11n");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_gdb12n[] U8G_SECTION(".progmem.u8g_font_gdb12n");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_gdb14n[] U8G_SECTION(".progmem.u8g_font_gdb14n");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_gdb17n[] U8G_SECTION(".progmem.u8g_font_gdb17n");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_gdb20n[] U8G_SECTION(".progmem.u8g_font_gdb20n");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_gdb25n[] U8G_SECTION(".progmem.u8g_font_gdb25n");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_gdb30n[] U8G_SECTION(".progmem.u8g_font_gdb30n");
|
||||
|
||||
/*
|
||||
Gentium Regular
|
||||
r: Reduced char set (codes 32 - 128)
|
||||
n: Numbers (codes 42 - 57)
|
||||
no char: Full set (codes 32 - 255)
|
||||
*/
|
||||
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_gdr9[] U8G_SECTION(".progmem.u8g_font_gdr9");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_gdr10[] U8G_SECTION(".progmem.u8g_font_gdr10");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_gdr11[] U8G_SECTION(".progmem.u8g_font_gdr11");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_gdr12[] U8G_SECTION(".progmem.u8g_font_gdr12");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_gdr14[] U8G_SECTION(".progmem.u8g_font_gdr14");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_gdr17[] U8G_SECTION(".progmem.u8g_font_gdr17");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_gdr20[] U8G_SECTION(".progmem.u8g_font_gdr20");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_gdr25[] U8G_SECTION(".progmem.u8g_font_gdr25");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_gdr30[] U8G_SECTION(".progmem.u8g_font_gdr30");
|
||||
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_gdr9r[] U8G_SECTION(".progmem.u8g_font_gdr9r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_gdr10r[] U8G_SECTION(".progmem.u8g_font_gdr10r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_gdr11r[] U8G_SECTION(".progmem.u8g_font_gdr11r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_gdr12r[] U8G_SECTION(".progmem.u8g_font_gdr12r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_gdr14r[] U8G_SECTION(".progmem.u8g_font_gdr14r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_gdr17r[] U8G_SECTION(".progmem.u8g_font_gdr17r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_gdr20r[] U8G_SECTION(".progmem.u8g_font_gdr20r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_gdr25r[] U8G_SECTION(".progmem.u8g_font_gdr25r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_gdr30r[] U8G_SECTION(".progmem.u8g_font_gdr30r");
|
||||
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_gdr9n[] U8G_SECTION(".progmem.u8g_font_gdr9n");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_gdr10n[] U8G_SECTION(".progmem.u8g_font_gdr10n");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_gdr11n[] U8G_SECTION(".progmem.u8g_font_gdr11n");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_gdr12n[] U8G_SECTION(".progmem.u8g_font_gdr12n");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_gdr14n[] U8G_SECTION(".progmem.u8g_font_gdr14n");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_gdr17n[] U8G_SECTION(".progmem.u8g_font_gdr17n");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_gdr20n[] U8G_SECTION(".progmem.u8g_font_gdr20n");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_gdr25n[] U8G_SECTION(".progmem.u8g_font_gdr25n");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_gdr30n[] U8G_SECTION(".progmem.u8g_font_gdr30n");
|
||||
|
||||
/*
|
||||
Old-Standard Bold
|
||||
r: Reduced char set (codes 32 - 128)
|
||||
n: Numbers (codes 42 - 57)
|
||||
no char: Full set (codes 32 - 255)
|
||||
*/
|
||||
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_osb18[] U8G_SECTION(".progmem.u8g_font_osb18");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_osb21[] U8G_SECTION(".progmem.u8g_font_osb21");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_osb26[] U8G_SECTION(".progmem.u8g_font_osb26");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_osb29[] U8G_SECTION(".progmem.u8g_font_osb29");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_osb35[] U8G_SECTION(".progmem.u8g_font_osb35");
|
||||
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_osb18r[] U8G_SECTION(".progmem.u8g_font_osb18r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_osb21r[] U8G_SECTION(".progmem.u8g_font_osb21r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_osb26r[] U8G_SECTION(".progmem.u8g_font_osb26r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_osb29r[] U8G_SECTION(".progmem.u8g_font_osb29r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_osb35r[] U8G_SECTION(".progmem.u8g_font_osb35r");
|
||||
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_osb18n[] U8G_SECTION(".progmem.u8g_font_osb18n");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_osb21n[] U8G_SECTION(".progmem.u8g_font_osb21n");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_osb26n[] U8G_SECTION(".progmem.u8g_font_osb26n");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_osb29n[] U8G_SECTION(".progmem.u8g_font_osb29n");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_osb35n[] U8G_SECTION(".progmem.u8g_font_osb35n");
|
||||
|
||||
/*
|
||||
Old-Standard Regular
|
||||
r: Reduced char set (codes 32 - 128)
|
||||
n: Numbers (codes 42 - 57)
|
||||
no char: Full set (codes 32 - 255)
|
||||
*/
|
||||
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_osr18[] U8G_SECTION(".progmem.u8g_font_osr18");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_osr21[] U8G_SECTION(".progmem.u8g_font_osr21");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_osr26[] U8G_SECTION(".progmem.u8g_font_osr26");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_osr29[] U8G_SECTION(".progmem.u8g_font_osr29");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_osr35[] U8G_SECTION(".progmem.u8g_font_osr35");
|
||||
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_osr18r[] U8G_SECTION(".progmem.u8g_font_osr18r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_osr21r[] U8G_SECTION(".progmem.u8g_font_osr21r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_osr26r[] U8G_SECTION(".progmem.u8g_font_osr26r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_osr29r[] U8G_SECTION(".progmem.u8g_font_osr29r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_osr35r[] U8G_SECTION(".progmem.u8g_font_osr35r");
|
||||
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_osr18n[] U8G_SECTION(".progmem.u8g_font_osr18n");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_osr21n[] U8G_SECTION(".progmem.u8g_font_osr21n");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_osr26n[] U8G_SECTION(".progmem.u8g_font_osr26n");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_osr29n[] U8G_SECTION(".progmem.u8g_font_osr29n");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_osr35n[] U8G_SECTION(".progmem.u8g_font_osr35n");
|
||||
|
||||
//extern const u8g_fntpgm_uint8_t u8g_font_osr41[] U8G_SECTION(".progmem.u8g_font_osr41");
|
||||
|
||||
/* GNU unifont */
|
||||
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_unifont_18_19[] U8G_SECTION(".progmem.u8g_font_unifont_18_19");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_unifont_72_73[] U8G_SECTION(".progmem.u8g_font_unifont_72_73");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_unifont_67_75[] U8G_SECTION(".progmem.u8g_font_unifont_67_75");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_unifont_76[] U8G_SECTION(".progmem.u8g_font_unifont_76");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_unifont_77[] U8G_SECTION(".progmem.u8g_font_unifont_77");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_unifont_78_79[] U8G_SECTION(".progmem.u8g_font_unifont_78_79");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_unifont_86[] U8G_SECTION(".progmem.u8g_font_unifont_86");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_unifont[] U8G_SECTION(".progmem.u8g_font_unifont");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_unifontr[] U8G_SECTION(".progmem.u8g_font_unifontr");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_unifont_0_8[] U8G_SECTION(".progmem.u8g_font_unifont_0_8");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_unifont_2_3[] U8G_SECTION(".progmem.u8g_font_unifont_2_3");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_unifont_4_5[] U8G_SECTION(".progmem.u8g_font_unifont_4_5");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_unifont_8_9[] U8G_SECTION(".progmem.u8g_font_unifont_8_9");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_unifont_12_13[] U8G_SECTION(".progmem.u8g_font_unifont_12_13");
|
||||
|
||||
|
||||
/* 04b fonts */
|
||||
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_04b_03b[] U8G_SECTION(".progmem.u8g_font_04b_03b");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_04b_03bn[] U8G_SECTION(".progmem.u8g_font_04b_03bn");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_04b_03br[] U8G_SECTION(".progmem.u8g_font_04b_03br");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_04b_03[] U8G_SECTION(".progmem.u8g_font_04b_03");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_04b_03n[] U8G_SECTION(".progmem.u8g_font_04b_03n");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_04b_03r[] U8G_SECTION(".progmem.u8g_font_04b_03r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_04b_24[] U8G_SECTION(".progmem.u8g_font_04b_24");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_04b_24n[] U8G_SECTION(".progmem.u8g_font_04b_24n");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_04b_24r[] U8G_SECTION(".progmem.u8g_font_04b_24r");
|
||||
|
||||
/* orgdot fonts */
|
||||
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_orgv01[] U8G_SECTION(".progmem.u8g_font_orgv01");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_orgv01r[] U8G_SECTION(".progmem.u8g_font_orgv01r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_orgv01n[] U8G_SECTION(".progmem.u8g_font_orgv01n");
|
||||
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_fixed_v0[] U8G_SECTION(".progmem.u8g_font_fixed_v0");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_fixed_v0r[] U8G_SECTION(".progmem.u8g_font_fixed_v0r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_fixed_v0n[] U8G_SECTION(".progmem.u8g_font_fixed_v0n");
|
||||
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_tpssb[] U8G_SECTION(".progmem.u8g_font_tpssb");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_tpssbr[] U8G_SECTION(".progmem.u8g_font_tpssbr");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_tpssbn[] U8G_SECTION(".progmem.u8g_font_tpssbn");
|
||||
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_tpss[] U8G_SECTION(".progmem.u8g_font_tpss");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_tpssr[] U8G_SECTION(".progmem.u8g_font_tpssr");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_tpssn[] U8G_SECTION(".progmem.u8g_font_tpssn");
|
||||
|
||||
/* contributed */
|
||||
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_freedoomr25n[] U8G_SECTION(".progmem.u8g_font_freedoomr25n");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_freedoomr10r[] U8G_SECTION(".progmem.u8g_font_freedoomr10r");
|
||||
|
||||
/* adobe X11 */
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_courB08[] U8G_SECTION(".progmem.u8g_font_courB08");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_courB08r[] U8G_SECTION(".progmem.u8g_font_courB08r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_courB10[] U8G_SECTION(".progmem.u8g_font_courB10");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_courB10r[] U8G_SECTION(".progmem.u8g_font_courB10r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_courB12[] U8G_SECTION(".progmem.u8g_font_courB12");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_courB12r[] U8G_SECTION(".progmem.u8g_font_courB12r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_courB14[] U8G_SECTION(".progmem.u8g_font_courB14");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_courB14r[] U8G_SECTION(".progmem.u8g_font_courB14r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_courB18[] U8G_SECTION(".progmem.u8g_font_courB18");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_courB18r[] U8G_SECTION(".progmem.u8g_font_courB18r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_courB24[] U8G_SECTION(".progmem.u8g_font_courB24");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_courB24r[] U8G_SECTION(".progmem.u8g_font_courB24r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_courB24n[] U8G_SECTION(".progmem.u8g_font_courB24n");
|
||||
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_courR08[] U8G_SECTION(".progmem.u8g_font_courR08");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_courR08r[] U8G_SECTION(".progmem.u8g_font_courR08r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_courR10[] U8G_SECTION(".progmem.u8g_font_courR10");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_courR10r[] U8G_SECTION(".progmem.u8g_font_courR10r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_courR12[] U8G_SECTION(".progmem.u8g_font_courR12");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_courR12r[] U8G_SECTION(".progmem.u8g_font_courR12r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_courR14[] U8G_SECTION(".progmem.u8g_font_courR14");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_courR14r[] U8G_SECTION(".progmem.u8g_font_courR14r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_courR18[] U8G_SECTION(".progmem.u8g_font_courR18");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_courR18r[] U8G_SECTION(".progmem.u8g_font_courR18r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_courR24[] U8G_SECTION(".progmem.u8g_font_courR24");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_courR24r[] U8G_SECTION(".progmem.u8g_font_courR24r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_courR24n[] U8G_SECTION(".progmem.u8g_font_courR24n");
|
||||
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_helvB08[] U8G_SECTION(".progmem.u8g_font_helvB08");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_helvB08r[] U8G_SECTION(".progmem.u8g_font_helvB08r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_helvB10[] U8G_SECTION(".progmem.u8g_font_helvB10");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_helvB10r[] U8G_SECTION(".progmem.u8g_font_helvB10r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_helvB12[] U8G_SECTION(".progmem.u8g_font_helvB12");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_helvB12r[] U8G_SECTION(".progmem.u8g_font_helvB12r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_helvB14[] U8G_SECTION(".progmem.u8g_font_helvB14");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_helvB14r[] U8G_SECTION(".progmem.u8g_font_helvB14r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_helvB18[] U8G_SECTION(".progmem.u8g_font_helvB18");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_helvB18r[] U8G_SECTION(".progmem.u8g_font_helvB18r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_helvB24[] U8G_SECTION(".progmem.u8g_font_helvB24");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_helvB24r[] U8G_SECTION(".progmem.u8g_font_helvB24r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_helvB24n[] U8G_SECTION(".progmem.u8g_font_helvB24n");
|
||||
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_helvR08[] U8G_SECTION(".progmem.u8g_font_helvR08");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_helvR08r[] U8G_SECTION(".progmem.u8g_font_helvR08r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_helvR10[] U8G_SECTION(".progmem.u8g_font_helvR10");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_helvR10r[] U8G_SECTION(".progmem.u8g_font_helvR10r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_helvR12[] U8G_SECTION(".progmem.u8g_font_helvR12");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_helvR12r[] U8G_SECTION(".progmem.u8g_font_helvR12r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_helvR14[] U8G_SECTION(".progmem.u8g_font_helvR14");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_helvR14r[] U8G_SECTION(".progmem.u8g_font_helvR14r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_helvR18[] U8G_SECTION(".progmem.u8g_font_helvR18");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_helvR18r[] U8G_SECTION(".progmem.u8g_font_helvR18r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_helvR24[] U8G_SECTION(".progmem.u8g_font_helvR24");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_helvR24r[] U8G_SECTION(".progmem.u8g_font_helvR24r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_helvR24n[] U8G_SECTION(".progmem.u8g_font_helvR24n");
|
||||
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_ncenB08[] U8G_SECTION(".progmem.u8g_font_ncenB08");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_ncenB08r[] U8G_SECTION(".progmem.u8g_font_ncenB08r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_ncenB10[] U8G_SECTION(".progmem.u8g_font_ncenB10");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_ncenB10r[] U8G_SECTION(".progmem.u8g_font_ncenB10r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_ncenB12[] U8G_SECTION(".progmem.u8g_font_ncenB12");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_ncenB12r[] U8G_SECTION(".progmem.u8g_font_ncenB12r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_ncenB14[] U8G_SECTION(".progmem.u8g_font_ncenB14");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_ncenB14r[] U8G_SECTION(".progmem.u8g_font_ncenB14r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_ncenB18[] U8G_SECTION(".progmem.u8g_font_ncenB18");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_ncenB18r[] U8G_SECTION(".progmem.u8g_font_ncenB18r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_ncenB24[] U8G_SECTION(".progmem.u8g_font_ncenB24");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_ncenB24r[] U8G_SECTION(".progmem.u8g_font_ncenB24r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_ncenB24n[] U8G_SECTION(".progmem.u8g_font_ncenB24n");
|
||||
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_ncenR08[] U8G_SECTION(".progmem.u8g_font_ncenR08");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_ncenR08r[] U8G_SECTION(".progmem.u8g_font_ncenR08r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_ncenR10[] U8G_SECTION(".progmem.u8g_font_ncenR10");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_ncenR10r[] U8G_SECTION(".progmem.u8g_font_ncenR10r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_ncenR12[] U8G_SECTION(".progmem.u8g_font_ncenR12");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_ncenR12r[] U8G_SECTION(".progmem.u8g_font_ncenR12r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_ncenR14[] U8G_SECTION(".progmem.u8g_font_ncenR14");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_ncenR14r[] U8G_SECTION(".progmem.u8g_font_ncenR14r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_ncenR18[] U8G_SECTION(".progmem.u8g_font_ncenR18");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_ncenR18r[] U8G_SECTION(".progmem.u8g_font_ncenR18r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_ncenR24[] U8G_SECTION(".progmem.u8g_font_ncenR24");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_ncenR24r[] U8G_SECTION(".progmem.u8g_font_ncenR24r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_ncenR24n[] U8G_SECTION(".progmem.u8g_font_ncenR24n");
|
||||
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_symb08[] U8G_SECTION(".progmem.u8g_font_symb08");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_symb08r[] U8G_SECTION(".progmem.u8g_font_symb08r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_symb10[] U8G_SECTION(".progmem.u8g_font_symb10");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_symb10r[] U8G_SECTION(".progmem.u8g_font_symb10r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_symb12[] U8G_SECTION(".progmem.u8g_font_symb12");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_symb12r[] U8G_SECTION(".progmem.u8g_font_symb12r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_symb14[] U8G_SECTION(".progmem.u8g_font_symb14");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_symb14r[] U8G_SECTION(".progmem.u8g_font_symb14r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_symb18[] U8G_SECTION(".progmem.u8g_font_symb18");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_symb18r[] U8G_SECTION(".progmem.u8g_font_symb18r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_symb24[] U8G_SECTION(".progmem.u8g_font_symb24");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_symb24r[] U8G_SECTION(".progmem.u8g_font_symb24r");
|
||||
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_timB08[] U8G_SECTION(".progmem.u8g_font_timB08");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_timB08r[] U8G_SECTION(".progmem.u8g_font_timB08r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_timB10[] U8G_SECTION(".progmem.u8g_font_timB10");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_timB10r[] U8G_SECTION(".progmem.u8g_font_timB10r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_timB12[] U8G_SECTION(".progmem.u8g_font_timB12");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_timB12r[] U8G_SECTION(".progmem.u8g_font_timB12r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_timB14[] U8G_SECTION(".progmem.u8g_font_timB14");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_timB14r[] U8G_SECTION(".progmem.u8g_font_timB14r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_timB18[] U8G_SECTION(".progmem.u8g_font_timB18");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_timB18r[] U8G_SECTION(".progmem.u8g_font_timB18r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_timB24[] U8G_SECTION(".progmem.u8g_font_timB24");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_timB24r[] U8G_SECTION(".progmem.u8g_font_timB24r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_timB24n[] U8G_SECTION(".progmem.u8g_font_timB24n");
|
||||
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_timR08[] U8G_SECTION(".progmem.u8g_font_timR08");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_timR08r[] U8G_SECTION(".progmem.u8g_font_timR08r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_timR10[] U8G_SECTION(".progmem.u8g_font_timR10");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_timR10r[] U8G_SECTION(".progmem.u8g_font_timR10r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_timR12[] U8G_SECTION(".progmem.u8g_font_timR12");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_timR12r[] U8G_SECTION(".progmem.u8g_font_timR12r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_timR14[] U8G_SECTION(".progmem.u8g_font_timR14");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_timR14r[] U8G_SECTION(".progmem.u8g_font_timR14r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_timR18[] U8G_SECTION(".progmem.u8g_font_timR18");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_timR18r[] U8G_SECTION(".progmem.u8g_font_timR18r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_timR24[] U8G_SECTION(".progmem.u8g_font_timR24");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_timR24r[] U8G_SECTION(".progmem.u8g_font_timR24r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_timR24n[] U8G_SECTION(".progmem.u8g_font_timR24n");
|
||||
|
||||
/* fontstruct */
|
||||
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_p01type[] U8G_SECTION(".progmem.u8g_font_p01type");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_p01typer[] U8G_SECTION(".progmem.u8g_font_p01typer");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_p01typen[] U8G_SECTION(".progmem.u8g_font_p01typen");
|
||||
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_lucasfont_alternate[] U8G_SECTION(".progmem.u8g_font_lucasfont_alternate");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_lucasfont_alternater[] U8G_SECTION(".progmem.u8g_font_lucasfont_alternater");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_lucasfont_alternaten[] U8G_SECTION(".progmem.u8g_font_lucasfont_alternaten");
|
||||
|
||||
//extern const u8g_fntpgm_uint8_t u8g_font_fs_onebrickpixelfont[] U8G_SECTION(".progmem.u8g_font_fs_onebrickpixelfont");
|
||||
//extern const u8g_fntpgm_uint8_t u8g_font_fs_onebrickpixelfontr[] U8G_SECTION(".progmem.u8g_font_fs_onebrickpixelfontr");
|
||||
//extern const u8g_fntpgm_uint8_t u8g_font_fs_onebrickpixelfontn[] U8G_SECTION(".progmem.u8g_font_fs_onebrickpixelfontn");
|
||||
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_chikita[] U8G_SECTION(".progmem.u8g_font_chikita");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_chikitar[] U8G_SECTION(".progmem.u8g_font_chikitar");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_chikitan[] U8G_SECTION(".progmem.u8g_font_chikitan");
|
||||
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_pixelle_micro[] U8G_SECTION(".progmem.u8g_font_pixelle_micro");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_pixelle_micror[] U8G_SECTION(".progmem.u8g_font_pixelle_micror");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_pixelle_micron[] U8G_SECTION(".progmem.u8g_font_pixelle_micron");
|
||||
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_trixel_square[] U8G_SECTION(".progmem.u8g_font_trixel_square");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_trixel_squarer[] U8G_SECTION(".progmem.u8g_font_trixel_squarer");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_trixel_squaren[] U8G_SECTION(".progmem.u8g_font_trixel_squaren");
|
||||
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_robot_de_niro[] U8G_SECTION(".progmem.u8g_font_robot_de_niro");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_robot_de_niror[] U8G_SECTION(".progmem.u8g_font_robot_de_niror");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_robot_de_niron[] U8G_SECTION(".progmem.u8g_font_robot_de_niron");
|
||||
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_baby[] U8G_SECTION(".progmem.u8g_font_baby");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_babyr[] U8G_SECTION(".progmem.u8g_font_babyr");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_babyn[] U8G_SECTION(".progmem.u8g_font_babyn");
|
||||
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_blipfest_07[] U8G_SECTION(".progmem.u8g_font_blipfest_07");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_blipfest_07r[] U8G_SECTION(".progmem.u8g_font_blipfest_07r");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_blipfest_07n[] U8G_SECTION(".progmem.u8g_font_blipfest_07n");
|
||||
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_6x10_marlin[] U8G_SECTION(".progmem.u8g_font_6x10_marlin");
|
||||
extern const u8g_fntpgm_uint8_t u8g_font_6x9[] U8G_SECTION(".progmem.u8g_font_6x9");
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _U8G_H */
|
||||
|
@ -0,0 +1,177 @@
|
||||
/*
|
||||
|
||||
u8g_bitmap.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
void u8g_DrawHBitmap(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t cnt, const uint8_t *bitmap)
|
||||
{
|
||||
while( cnt > 0 )
|
||||
{
|
||||
u8g_Draw8Pixel(u8g, x, y, 0, *bitmap);
|
||||
bitmap++;
|
||||
cnt--;
|
||||
x+=8;
|
||||
}
|
||||
}
|
||||
|
||||
void u8g_DrawBitmap(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t cnt, u8g_uint_t h, const uint8_t *bitmap)
|
||||
{
|
||||
if ( u8g_IsBBXIntersection(u8g, x, y, cnt*8, h) == 0 )
|
||||
return;
|
||||
while( h > 0 )
|
||||
{
|
||||
u8g_DrawHBitmap(u8g, x, y, cnt, bitmap);
|
||||
bitmap += cnt;
|
||||
y++;
|
||||
h--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void u8g_DrawHBitmapP(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t cnt, const u8g_pgm_uint8_t *bitmap)
|
||||
{
|
||||
while( cnt > 0 )
|
||||
{
|
||||
u8g_Draw8Pixel(u8g, x, y, 0, u8g_pgm_read(bitmap));
|
||||
bitmap++;
|
||||
cnt--;
|
||||
x+=8;
|
||||
}
|
||||
}
|
||||
|
||||
void u8g_DrawBitmapP(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t cnt, u8g_uint_t h, const u8g_pgm_uint8_t *bitmap)
|
||||
{
|
||||
if ( u8g_IsBBXIntersection(u8g, x, y, cnt*8, h) == 0 )
|
||||
return;
|
||||
while( h > 0 )
|
||||
{
|
||||
u8g_DrawHBitmapP(u8g, x, y, cnt, bitmap);
|
||||
bitmap += cnt;
|
||||
y++;
|
||||
h--;
|
||||
}
|
||||
}
|
||||
|
||||
/*=========================================================================*/
|
||||
|
||||
static void u8g_DrawHXBM(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, const uint8_t *bitmap)
|
||||
{
|
||||
uint8_t d;
|
||||
x+=7;
|
||||
while( w >= 8 )
|
||||
{
|
||||
u8g_Draw8Pixel(u8g, x, y, 2, *bitmap);
|
||||
bitmap++;
|
||||
w-= 8;
|
||||
x+=8;
|
||||
}
|
||||
if ( w > 0 )
|
||||
{
|
||||
d = *bitmap;
|
||||
x -= 7;
|
||||
do
|
||||
{
|
||||
if ( d & 1 )
|
||||
u8g_DrawPixel(u8g, x, y);
|
||||
x++;
|
||||
w--;
|
||||
d >>= 1;
|
||||
} while ( w > 0 );
|
||||
}
|
||||
}
|
||||
|
||||
void u8g_DrawXBM(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h, const uint8_t *bitmap)
|
||||
{
|
||||
u8g_uint_t b;
|
||||
b = w;
|
||||
b += 7;
|
||||
b >>= 3;
|
||||
|
||||
if ( u8g_IsBBXIntersection(u8g, x, y, w, h) == 0 )
|
||||
return;
|
||||
|
||||
while( h > 0 )
|
||||
{
|
||||
u8g_DrawHXBM(u8g, x, y, w, bitmap);
|
||||
bitmap += b;
|
||||
y++;
|
||||
h--;
|
||||
}
|
||||
}
|
||||
|
||||
static void u8g_DrawHXBMP(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, const u8g_pgm_uint8_t *bitmap)
|
||||
{
|
||||
uint8_t d;
|
||||
x+=7;
|
||||
while( w >= 8 )
|
||||
{
|
||||
u8g_Draw8Pixel(u8g, x, y, 2, u8g_pgm_read(bitmap));
|
||||
bitmap++;
|
||||
w-= 8;
|
||||
x+=8;
|
||||
}
|
||||
if ( w > 0 )
|
||||
{
|
||||
d = u8g_pgm_read(bitmap);
|
||||
x -= 7;
|
||||
do
|
||||
{
|
||||
if ( d & 1 )
|
||||
u8g_DrawPixel(u8g, x, y);
|
||||
x++;
|
||||
w--;
|
||||
d >>= 1;
|
||||
} while ( w > 0 );
|
||||
}
|
||||
}
|
||||
|
||||
void u8g_DrawXBMP(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h, const u8g_pgm_uint8_t *bitmap)
|
||||
{
|
||||
u8g_uint_t b;
|
||||
b = w;
|
||||
b += 7;
|
||||
b >>= 3;
|
||||
|
||||
if ( u8g_IsBBXIntersection(u8g, x, y, w, h) == 0 )
|
||||
return;
|
||||
while( h > 0 )
|
||||
{
|
||||
u8g_DrawHXBMP(u8g, x, y, w, bitmap);
|
||||
bitmap += b;
|
||||
y++;
|
||||
h--;
|
||||
}
|
||||
}
|
@ -0,0 +1,382 @@
|
||||
/*
|
||||
|
||||
u8g_circle.c
|
||||
|
||||
Utility to draw empty and filled circles.
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, bjthom@gmail.com
|
||||
u8g_DrawCircle & u8g_DrawDisc by olikraus@gmail.com
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
Addition to the U8G Library 02/25/12
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#ifdef OLD_CODE
|
||||
|
||||
void circ_upperRight(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t x0, u8g_uint_t y0) {
|
||||
u8g_DrawPixel(u8g, x0 + x, y0 - y);
|
||||
u8g_DrawPixel(u8g, x0 + y, y0 - x);
|
||||
}
|
||||
|
||||
void circ_upperLeft(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t x0, u8g_uint_t y0) {
|
||||
u8g_DrawPixel(u8g, x0 - x, y0 - y);
|
||||
u8g_DrawPixel(u8g, x0 - y, y0 - x);
|
||||
}
|
||||
|
||||
void circ_lowerRight(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t x0, u8g_uint_t y0) {
|
||||
u8g_DrawPixel(u8g, x0 + x, y0 + y);
|
||||
u8g_DrawPixel(u8g, x0 + y, y0 + x);
|
||||
}
|
||||
|
||||
void circ_lowerLeft(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t x0, u8g_uint_t y0) {
|
||||
u8g_DrawPixel(u8g, x0 - x, y0 + y);
|
||||
u8g_DrawPixel(u8g, x0 - y, y0 + x);
|
||||
}
|
||||
|
||||
void circ_all(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t x0, u8g_uint_t y0) {
|
||||
circ_upperRight(u8g, x, y, x0, y0);
|
||||
circ_upperLeft(u8g, x, y, x0, y0);
|
||||
circ_lowerRight(u8g, x, y, x0, y0);
|
||||
circ_lowerLeft(u8g, x, y, x0, y0);
|
||||
}
|
||||
|
||||
void u8g_DrawEmpCirc(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rad, uint8_t option)
|
||||
{
|
||||
if ( u8g_IsBBXIntersection(u8g, x0-rad-1, y0-rad-1, 2*rad+1, 2*rad+1) == 0)
|
||||
return;
|
||||
|
||||
int f = 1 - rad;
|
||||
int ddF_x = 1;
|
||||
int ddF_y = -2*rad;
|
||||
uint8_t x = 0;
|
||||
uint8_t y = rad;
|
||||
|
||||
void ( *circ_util )(u8g_t *, u8g_uint_t, u8g_uint_t, u8g_uint_t, u8g_uint_t);
|
||||
|
||||
switch (option)
|
||||
{
|
||||
case U8G_CIRC_UPPER_RIGHT:
|
||||
u8g_DrawPixel(u8g, x0, y0 - rad);
|
||||
u8g_DrawPixel(u8g, x0 + rad, y0);
|
||||
circ_util = circ_upperRight;
|
||||
break;
|
||||
case U8G_CIRC_UPPER_LEFT:
|
||||
u8g_DrawPixel(u8g, x0, y0 - rad);
|
||||
u8g_DrawPixel(u8g, x0 - rad, y0);
|
||||
circ_util = circ_upperLeft;
|
||||
break;
|
||||
case U8G_CIRC_LOWER_RIGHT:
|
||||
u8g_DrawPixel(u8g, x0, y0 + rad);
|
||||
u8g_DrawPixel(u8g, x0 + rad, y0);
|
||||
circ_util = circ_lowerRight;
|
||||
break;
|
||||
case U8G_CIRC_LOWER_LEFT:
|
||||
u8g_DrawPixel(u8g, x0, y0 + rad);
|
||||
u8g_DrawPixel(u8g, x0 - rad, y0);
|
||||
circ_util = circ_lowerLeft;
|
||||
break;
|
||||
default:
|
||||
case U8G_CIRC_ALL:
|
||||
u8g_DrawPixel(u8g, x0, y0 + rad);
|
||||
u8g_DrawPixel(u8g, x0, y0 - rad);
|
||||
u8g_DrawPixel(u8g, x0 + rad, y0);
|
||||
u8g_DrawPixel(u8g, x0 - rad, y0);
|
||||
circ_util = circ_all;
|
||||
break;
|
||||
}
|
||||
|
||||
while( x < y )
|
||||
{
|
||||
if(f >= 0)
|
||||
{
|
||||
y--;
|
||||
ddF_y += 2;
|
||||
f += ddF_y;
|
||||
}
|
||||
x++;
|
||||
ddF_x += 2;
|
||||
f += ddF_x;
|
||||
|
||||
circ_util(u8g, x, y, x0, y0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void u8g_DrawFillCirc(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rad, uint8_t option)
|
||||
{
|
||||
if ( u8g_IsBBXIntersection(u8g, x0-rad-1, y0-rad-1, 2*rad+1, 2*rad+1) == 0)
|
||||
return;
|
||||
|
||||
int f = 1 - rad;
|
||||
int ddF_x = 1;
|
||||
int ddF_y = -2*rad;
|
||||
uint8_t x = 0;
|
||||
uint8_t y = rad;
|
||||
|
||||
// Draw vertical diameter at the horiz. center
|
||||
// u8g_DrawVLine(u8g, x0, y0 - rad, 2*rad+1);
|
||||
|
||||
if (option == U8G_CIRC_UPPER_LEFT || option == U8G_CIRC_UPPER_RIGHT) {
|
||||
u8g_DrawVLine(u8g, x0, y0 - rad, rad+1);
|
||||
}
|
||||
else if (option == U8G_CIRC_LOWER_LEFT || option == U8G_CIRC_LOWER_RIGHT) {
|
||||
u8g_DrawVLine(u8g, x0, y0, rad+1);
|
||||
}
|
||||
else {
|
||||
u8g_DrawVLine(u8g, x0, y0 - rad, 2*rad+1);
|
||||
}
|
||||
|
||||
while( x < y )
|
||||
{
|
||||
if(f >= 0)
|
||||
{
|
||||
y--;
|
||||
ddF_y += 2;
|
||||
f += ddF_y;
|
||||
}
|
||||
x++;
|
||||
ddF_x += 2;
|
||||
f += ddF_x;
|
||||
|
||||
//Draw vertical lines from one point to another
|
||||
|
||||
switch (option)
|
||||
{
|
||||
case U8G_CIRC_UPPER_RIGHT:
|
||||
u8g_DrawVLine(u8g, x0+x, y0-y, y+1);
|
||||
u8g_DrawVLine(u8g, x0+y, y0-x, x+1);
|
||||
break;
|
||||
case U8G_CIRC_UPPER_LEFT:
|
||||
u8g_DrawVLine(u8g, x0-x, y0-y, y+1);
|
||||
u8g_DrawVLine(u8g, x0-y, y0-x, x+1);
|
||||
break;
|
||||
case U8G_CIRC_LOWER_RIGHT:
|
||||
u8g_DrawVLine(u8g, x0+x, y0, y+1);
|
||||
u8g_DrawVLine(u8g, x0+y, y0, x+1);
|
||||
break;
|
||||
case U8G_CIRC_LOWER_LEFT:
|
||||
u8g_DrawVLine(u8g, x0-x, y0, y+1);
|
||||
u8g_DrawVLine(u8g, x0-y, y0, x+1);
|
||||
break;
|
||||
case U8G_CIRC_ALL:
|
||||
u8g_DrawVLine(u8g, x0+x, y0-y, 2*y+1);
|
||||
u8g_DrawVLine(u8g, x0-x, y0-y, 2*y+1);
|
||||
u8g_DrawVLine(u8g, x0+y, y0-x, 2*x+1);
|
||||
u8g_DrawVLine(u8g, x0-y, y0-x, 2*x+1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*=========================================================================*/
|
||||
|
||||
static void u8g_draw_circle_section(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t x0, u8g_uint_t y0, uint8_t option) U8G_NOINLINE;
|
||||
|
||||
static void u8g_draw_circle_section(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t x0, u8g_uint_t y0, uint8_t option)
|
||||
{
|
||||
/* upper right */
|
||||
if ( option & U8G_DRAW_UPPER_RIGHT )
|
||||
{
|
||||
u8g_DrawPixel(u8g, x0 + x, y0 - y);
|
||||
u8g_DrawPixel(u8g, x0 + y, y0 - x);
|
||||
}
|
||||
|
||||
/* upper left */
|
||||
if ( option & U8G_DRAW_UPPER_LEFT )
|
||||
{
|
||||
u8g_DrawPixel(u8g, x0 - x, y0 - y);
|
||||
u8g_DrawPixel(u8g, x0 - y, y0 - x);
|
||||
}
|
||||
|
||||
/* lower right */
|
||||
if ( option & U8G_DRAW_LOWER_RIGHT )
|
||||
{
|
||||
u8g_DrawPixel(u8g, x0 + x, y0 + y);
|
||||
u8g_DrawPixel(u8g, x0 + y, y0 + x);
|
||||
}
|
||||
|
||||
/* lower left */
|
||||
if ( option & U8G_DRAW_LOWER_LEFT )
|
||||
{
|
||||
u8g_DrawPixel(u8g, x0 - x, y0 + y);
|
||||
u8g_DrawPixel(u8g, x0 - y, y0 + x);
|
||||
}
|
||||
}
|
||||
|
||||
void u8g_draw_circle(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rad, uint8_t option)
|
||||
{
|
||||
u8g_int_t f;
|
||||
u8g_int_t ddF_x;
|
||||
u8g_int_t ddF_y;
|
||||
u8g_uint_t x;
|
||||
u8g_uint_t y;
|
||||
|
||||
f = 1;
|
||||
f -= rad;
|
||||
ddF_x = 1;
|
||||
ddF_y = 0;
|
||||
ddF_y -= rad;
|
||||
ddF_y *= 2;
|
||||
x = 0;
|
||||
y = rad;
|
||||
|
||||
u8g_draw_circle_section(u8g, x, y, x0, y0, option);
|
||||
|
||||
while ( x < y )
|
||||
{
|
||||
if (f >= 0)
|
||||
{
|
||||
y--;
|
||||
ddF_y += 2;
|
||||
f += ddF_y;
|
||||
}
|
||||
x++;
|
||||
ddF_x += 2;
|
||||
f += ddF_x;
|
||||
|
||||
u8g_draw_circle_section(u8g, x, y, x0, y0, option);
|
||||
}
|
||||
}
|
||||
|
||||
void u8g_DrawCircle(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rad, uint8_t option)
|
||||
{
|
||||
/* check for bounding box */
|
||||
{
|
||||
u8g_uint_t radp, radp2;
|
||||
|
||||
radp = rad;
|
||||
radp++;
|
||||
radp2 = radp;
|
||||
radp2 *= 2;
|
||||
|
||||
if ( u8g_IsBBXIntersection(u8g, x0-radp, y0-radp, radp2, radp2) == 0)
|
||||
return;
|
||||
}
|
||||
|
||||
/* draw circle */
|
||||
u8g_draw_circle(u8g, x0, y0, rad, option);
|
||||
}
|
||||
|
||||
static void u8g_draw_disc_section(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t x0, u8g_uint_t y0, uint8_t option) U8G_NOINLINE;
|
||||
|
||||
static void u8g_draw_disc_section(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t x0, u8g_uint_t y0, uint8_t option)
|
||||
{
|
||||
/* upper right */
|
||||
if ( option & U8G_DRAW_UPPER_RIGHT )
|
||||
{
|
||||
u8g_DrawVLine(u8g, x0+x, y0-y, y+1);
|
||||
u8g_DrawVLine(u8g, x0+y, y0-x, x+1);
|
||||
}
|
||||
|
||||
/* upper left */
|
||||
if ( option & U8G_DRAW_UPPER_LEFT )
|
||||
{
|
||||
u8g_DrawVLine(u8g, x0-x, y0-y, y+1);
|
||||
u8g_DrawVLine(u8g, x0-y, y0-x, x+1);
|
||||
}
|
||||
|
||||
/* lower right */
|
||||
if ( option & U8G_DRAW_LOWER_RIGHT )
|
||||
{
|
||||
u8g_DrawVLine(u8g, x0+x, y0, y+1);
|
||||
u8g_DrawVLine(u8g, x0+y, y0, x+1);
|
||||
}
|
||||
|
||||
/* lower left */
|
||||
if ( option & U8G_DRAW_LOWER_LEFT )
|
||||
{
|
||||
u8g_DrawVLine(u8g, x0-x, y0, y+1);
|
||||
u8g_DrawVLine(u8g, x0-y, y0, x+1);
|
||||
}
|
||||
}
|
||||
|
||||
void u8g_draw_disc(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rad, uint8_t option)
|
||||
{
|
||||
u8g_int_t f;
|
||||
u8g_int_t ddF_x;
|
||||
u8g_int_t ddF_y;
|
||||
u8g_uint_t x;
|
||||
u8g_uint_t y;
|
||||
|
||||
f = 1;
|
||||
f -= rad;
|
||||
ddF_x = 1;
|
||||
ddF_y = 0;
|
||||
ddF_y -= rad;
|
||||
ddF_y *= 2;
|
||||
x = 0;
|
||||
y = rad;
|
||||
|
||||
u8g_draw_disc_section(u8g, x, y, x0, y0, option);
|
||||
|
||||
while ( x < y )
|
||||
{
|
||||
if (f >= 0)
|
||||
{
|
||||
y--;
|
||||
ddF_y += 2;
|
||||
f += ddF_y;
|
||||
}
|
||||
x++;
|
||||
ddF_x += 2;
|
||||
f += ddF_x;
|
||||
|
||||
u8g_draw_disc_section(u8g, x, y, x0, y0, option);
|
||||
}
|
||||
}
|
||||
|
||||
void u8g_DrawDisc(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rad, uint8_t option)
|
||||
{
|
||||
/* check for bounding box */
|
||||
{
|
||||
u8g_uint_t radp, radp2;
|
||||
|
||||
radp = rad;
|
||||
radp++;
|
||||
radp2 = radp;
|
||||
radp2 *= 2;
|
||||
|
||||
if ( u8g_IsBBXIntersection(u8g, x0-radp, y0-radp, radp2, radp2) == 0)
|
||||
return;
|
||||
}
|
||||
|
||||
/* draw disc */
|
||||
u8g_draw_disc(u8g, x0, y0, rad, option);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,156 @@
|
||||
/*
|
||||
|
||||
u8g_clip.c
|
||||
|
||||
procedures for clipping
|
||||
taken over from procs in u8g_pb.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2012, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
Notes
|
||||
|
||||
This is one of the most critical parts of u8glib. It must be fast, but still reliable.
|
||||
Based on the intersection program (see tools folder), there is minimized version of
|
||||
the condition for the intersaction test:
|
||||
minimized version
|
||||
---1----0 1 b1 <= a2 && b1 > b2
|
||||
-----1--0 1 b2 >= a1 && b1 > b2
|
||||
---1-1--- 1 b1 <= a2 && b2 >= a1
|
||||
It includes the assumption, that a1 <= a2 is always true (correct, because
|
||||
a1, a2 are the page dimensions.
|
||||
|
||||
The direct implementation of the above result is done in:
|
||||
uint8_t u8g_is_intersection_boolean(u8g_uint_t a0, u8g_uint_t a1, u8g_uint_t v0, u8g_uint_t v1)
|
||||
However, this is slower than a decision tree version:
|
||||
static uint8_t u8g_is_intersection_decision_tree(u8g_uint_t a0, u8g_uint_t a1, u8g_uint_t v0, u8g_uint_t v1)
|
||||
Also suprising is, that he the macro implementation is slower than the inlined version.
|
||||
|
||||
The decision tree is based on the expansion of the truth table.
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define U8G_ALWAYS_INLINE __attribute__((always_inline))
|
||||
#else
|
||||
#define U8G_ALWAYS_INLINE
|
||||
#endif
|
||||
|
||||
/*
|
||||
intersection assumptions:
|
||||
a1 <= a2 is always true
|
||||
|
||||
minimized version
|
||||
---1----0 1 b1 <= a2 && b1 > b2
|
||||
-----1--0 1 b2 >= a1 && b1 > b2
|
||||
---1-1--- 1 b1 <= a2 && b2 >= a1
|
||||
*/
|
||||
|
||||
#ifdef OLD_CODE_WHICH_IS_TOO_SLOW
|
||||
static uint8_t u8g_is_intersection_boolean(u8g_uint_t a0, u8g_uint_t a1, u8g_uint_t v0, u8g_uint_t v1)
|
||||
{
|
||||
uint8_t c1, c2, c3, tmp;
|
||||
c1 = v0 <= a1;
|
||||
c2 = v1 >= a0;
|
||||
c3 = v0 > v1;
|
||||
|
||||
tmp = c1;
|
||||
c1 &= c2;
|
||||
c2 &= c3;
|
||||
c3 &= tmp;
|
||||
c1 |= c2;
|
||||
c1 |= c3;
|
||||
return c1 & 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define U8G_IS_INTERSECTION_MACRO(a0,a1,v0,v1) ((uint8_t)( (v0) <= (a1) ) ? ( ( (v1) >= (a0) ) ? ( 1 ) : ( (v0) > (v1) ) ) : ( ( (v1) >= (a0) ) ? ( (v0) > (v1) ) : ( 0 ) ))
|
||||
|
||||
static uint8_t u8g_is_intersection_decision_tree(u8g_uint_t a0, u8g_uint_t a1, u8g_uint_t v0, u8g_uint_t v1) U8G_ALWAYS_INLINE;
|
||||
static uint8_t u8g_is_intersection_decision_tree(u8g_uint_t a0, u8g_uint_t a1, u8g_uint_t v0, u8g_uint_t v1)
|
||||
{
|
||||
/* surprisingly the macro leads to larger code */
|
||||
/* return U8G_IS_INTERSECTION_MACRO(a0,a1,v0,v1); */
|
||||
if ( v0 <= a1 )
|
||||
{
|
||||
if ( v1 >= a0 )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( v0 > v1 )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( v1 >= a0 )
|
||||
{
|
||||
if ( v0 > v1 )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
uint8_t u8g_IsBBXIntersection(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h)
|
||||
{
|
||||
register u8g_uint_t tmp;
|
||||
tmp = y;
|
||||
tmp += h;
|
||||
tmp--;
|
||||
if ( u8g_is_intersection_decision_tree(u8g->current_page.y0, u8g->current_page.y1, y, tmp) == 0 )
|
||||
return 0;
|
||||
|
||||
tmp = x;
|
||||
tmp += w;
|
||||
tmp--;
|
||||
return u8g_is_intersection_decision_tree(u8g->current_page.x0, u8g->current_page.x1, x, tmp);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,173 @@
|
||||
/*
|
||||
|
||||
u8g_com_api.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
uint8_t u8g_InitCom(u8g_t *u8g, u8g_dev_t *dev)
|
||||
{
|
||||
return dev->com_fn(u8g, U8G_COM_MSG_INIT, 0, NULL);
|
||||
}
|
||||
|
||||
void u8g_StopCom(u8g_t *u8g, u8g_dev_t *dev)
|
||||
{
|
||||
dev->com_fn(u8g, U8G_COM_MSG_STOP, 0, NULL);
|
||||
}
|
||||
|
||||
/* cs contains the chip number, which should be enabled */
|
||||
void u8g_SetChipSelect(u8g_t *u8g, u8g_dev_t *dev, uint8_t cs)
|
||||
{
|
||||
dev->com_fn(u8g, U8G_COM_MSG_CHIP_SELECT, cs, NULL);
|
||||
}
|
||||
|
||||
void u8g_SetResetLow(u8g_t *u8g, u8g_dev_t *dev)
|
||||
{
|
||||
dev->com_fn(u8g, U8G_COM_MSG_RESET, 0, NULL);
|
||||
}
|
||||
|
||||
void u8g_SetResetHigh(u8g_t *u8g, u8g_dev_t *dev)
|
||||
{
|
||||
dev->com_fn(u8g, U8G_COM_MSG_RESET, 1, NULL);
|
||||
}
|
||||
|
||||
|
||||
void u8g_SetAddress(u8g_t *u8g, u8g_dev_t *dev, uint8_t address)
|
||||
{
|
||||
dev->com_fn(u8g, U8G_COM_MSG_ADDRESS, address, NULL);
|
||||
}
|
||||
|
||||
uint8_t u8g_WriteByte(u8g_t *u8g, u8g_dev_t *dev, uint8_t val)
|
||||
{
|
||||
return dev->com_fn(u8g, U8G_COM_MSG_WRITE_BYTE, val, NULL);
|
||||
}
|
||||
|
||||
uint8_t u8g_WriteSequence(u8g_t *u8g, u8g_dev_t *dev, uint8_t cnt, uint8_t *seq)
|
||||
{
|
||||
return dev->com_fn(u8g, U8G_COM_MSG_WRITE_SEQ, cnt, seq);
|
||||
}
|
||||
|
||||
uint8_t u8g_WriteSequenceP(u8g_t *u8g, u8g_dev_t *dev, uint8_t cnt, const uint8_t *seq)
|
||||
{
|
||||
return dev->com_fn(u8g, U8G_COM_MSG_WRITE_SEQ_P, cnt, (void *)seq);
|
||||
}
|
||||
|
||||
/*
|
||||
sequence := { direct_value | escape_sequence }
|
||||
direct_value := 0..254
|
||||
escape_sequence := value_255 | sequence_end | delay | adr | cs | not_used
|
||||
value_255 := 255 255
|
||||
sequence_end = 255 254
|
||||
delay := 255 0..127
|
||||
adr := 255 0x0e0 .. 0x0ef
|
||||
cs := 255 0x0d0 .. 0x0df
|
||||
not_used := 255 101..254
|
||||
|
||||
#define U8G_ESC_DLY(x) 255, ((x) & 0x7f)
|
||||
#define U8G_ESC_CS(x) 255, (0xd0 | ((x)&0x0f))
|
||||
#define U8G_ESC_ADR(x) 255, (0xe0 | ((x)&0x0f))
|
||||
#define U8G_ESC_VCC(x) 255, (0xbe | ((x)&0x01))
|
||||
#define U8G_ESC_END 255, 254
|
||||
#define U8G_ESC_255 255, 255
|
||||
#define U8G_ESC_RST(x) 255, (0xc0 | ((x)&0x0f))
|
||||
|
||||
*/
|
||||
uint8_t u8g_WriteEscSeqP(u8g_t *u8g, u8g_dev_t *dev, const uint8_t *esc_seq)
|
||||
{
|
||||
uint8_t is_escape = 0;
|
||||
uint8_t value;
|
||||
for(;;)
|
||||
{
|
||||
value = u8g_pgm_read(esc_seq);
|
||||
if ( is_escape == 0 )
|
||||
{
|
||||
if ( value != 255 )
|
||||
{
|
||||
if ( u8g_WriteByte(u8g, dev, value) == 0 )
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
is_escape = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( value == 255 )
|
||||
{
|
||||
if ( u8g_WriteByte(u8g, dev, value) == 0 )
|
||||
return 0;
|
||||
}
|
||||
else if ( value == 254 )
|
||||
{
|
||||
break;
|
||||
}
|
||||
else if ( value >= 0x0f0 )
|
||||
{
|
||||
/* not yet used, do nothing */
|
||||
}
|
||||
else if ( value >= 0xe0 )
|
||||
{
|
||||
u8g_SetAddress(u8g, dev, value & 0x0f);
|
||||
}
|
||||
else if ( value >= 0xd0 )
|
||||
{
|
||||
u8g_SetChipSelect(u8g, dev, value & 0x0f);
|
||||
}
|
||||
else if ( value >= 0xc0 )
|
||||
{
|
||||
u8g_SetResetLow(u8g, dev);
|
||||
value &= 0x0f;
|
||||
value <<= 4;
|
||||
value+=2;
|
||||
u8g_Delay(value);
|
||||
u8g_SetResetHigh(u8g, dev);
|
||||
u8g_Delay(value);
|
||||
}
|
||||
else if ( value >= 0xbe )
|
||||
{
|
||||
/* not yet implemented */
|
||||
/* u8g_SetVCC(u8g, dev, value & 0x01); */
|
||||
}
|
||||
else if ( value <= 127 )
|
||||
{
|
||||
u8g_Delay(value);
|
||||
}
|
||||
is_escape = 0;
|
||||
}
|
||||
esc_seq++;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
@ -0,0 +1,94 @@
|
||||
/*
|
||||
|
||||
u8g_com_api_16gr.c
|
||||
|
||||
Extension of the com api for devices with 16 graylevels (4 bit per pixel).
|
||||
This should fit to the 8h and 16h architectures (pb8v1, pb8v2, pb16v1, pb16v2),
|
||||
mainly intended for SSD OLEDs
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
/* interpret b as a monochrome bit pattern, write value 15 for high bit and value 0 for a low bit */
|
||||
/* topbit (msb) is sent last */
|
||||
/* example: b = 0x083 will send 0xff, 0x00, 0x00, 0xf0 */
|
||||
uint8_t u8g_WriteByteBWTo16GrDevice(u8g_t *u8g, u8g_dev_t *dev, uint8_t b)
|
||||
{
|
||||
static uint8_t buf[4];
|
||||
static uint8_t map[4] = { 0, 0x00f, 0x0f0, 0x0ff };
|
||||
buf [3] = map[b & 3];
|
||||
b>>=2;
|
||||
buf [2] = map[b & 3];
|
||||
b>>=2;
|
||||
buf [1] = map[b & 3];
|
||||
b>>=2;
|
||||
buf [0] = map[b & 3];
|
||||
return dev->com_fn(u8g, U8G_COM_MSG_WRITE_SEQ, 4, buf);
|
||||
}
|
||||
|
||||
uint8_t u8g_WriteSequenceBWTo16GrDevice(u8g_t *u8g, u8g_dev_t *dev, uint8_t cnt, uint8_t *ptr)
|
||||
{
|
||||
do
|
||||
{
|
||||
if ( u8g_WriteByteBWTo16GrDevice(u8g, dev, *ptr++) == 0 )
|
||||
return 0;
|
||||
cnt--;
|
||||
} while( cnt != 0 );
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* interpret b as a 4L bit pattern, write values 0x000, 0x004, 0x008, 0x00c */
|
||||
uint8_t u8g_WriteByte4LTo16GrDevice(u8g_t *u8g, u8g_dev_t *dev, uint8_t b)
|
||||
{
|
||||
//static uint8_t map[16] = { 0x000, 0x004, 0x008, 0x00c, 0x040, 0x044, 0x048, 0x04c, 0x080, 0x084, 0x088, 0x08c, 0x0c0, 0x0c4, 0x0c8, 0x0cc};
|
||||
//static uint8_t map[16] = { 0x000, 0x004, 0x00a, 0x00f, 0x040, 0x044, 0x04a, 0x04f, 0x0a0, 0x0a4, 0x0aa, 0x0af, 0x0f0, 0x0f4, 0x0fa, 0x0ff};
|
||||
static uint8_t map[16] = { 0x000, 0x040, 0x0a0, 0x0f0, 0x004, 0x044, 0x0a4, 0x0f4, 0x00a, 0x04a, 0x0aa, 0x0fa, 0x00f, 0x04f, 0x0af, 0x0ff};
|
||||
uint8_t bb;
|
||||
bb = b;
|
||||
bb &= 15;
|
||||
b>>=4;
|
||||
dev->com_fn(u8g, U8G_COM_MSG_WRITE_BYTE, map[bb], NULL);
|
||||
return dev->com_fn(u8g, U8G_COM_MSG_WRITE_BYTE, map[b], NULL);
|
||||
}
|
||||
|
||||
uint8_t u8g_WriteSequence4LTo16GrDevice(u8g_t *u8g, u8g_dev_t *dev, uint8_t cnt, uint8_t *ptr)
|
||||
{
|
||||
do
|
||||
{
|
||||
if ( u8g_WriteByte4LTo16GrDevice(u8g, dev, *ptr++) == 0 )
|
||||
return 0;
|
||||
cnt--;
|
||||
} while( cnt != 0 );
|
||||
return 1;
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
/*
|
||||
|
||||
u8g_com_arduino_common.c
|
||||
|
||||
shared procedures for the arduino communication procedures
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#if defined(ARDUINO)
|
||||
|
||||
#if ARDUINO < 100
|
||||
#include <WProgram.h>
|
||||
#else
|
||||
#include <Arduino.h>
|
||||
#endif
|
||||
|
||||
void u8g_com_arduino_digital_write(u8g_t *u8g, uint8_t pin_index, uint8_t value)
|
||||
{
|
||||
uint8_t pin;
|
||||
pin = u8g->pin_list[pin_index];
|
||||
if ( pin != U8G_PIN_NONE )
|
||||
digitalWrite(pin, value);
|
||||
}
|
||||
|
||||
/* this procedure does not set the RW pin */
|
||||
void u8g_com_arduino_assign_pin_output_high(u8g_t *u8g)
|
||||
{
|
||||
uint8_t i;
|
||||
/* skip the RW pin, which is the last pin in the list */
|
||||
for( i = 0; i < U8G_PIN_LIST_LEN-1; i++ )
|
||||
{
|
||||
if ( u8g->pin_list[i] != U8G_PIN_NONE )
|
||||
{
|
||||
pinMode(u8g->pin_list[i], OUTPUT);
|
||||
digitalWrite(u8g->pin_list[i], HIGH);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -0,0 +1,245 @@
|
||||
/*
|
||||
|
||||
u8g_arduino_fast_parallel.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
PIN_D0 8
|
||||
PIN_D1 9
|
||||
PIN_D2 10
|
||||
PIN_D3 11
|
||||
PIN_D4 4
|
||||
PIN_D5 5
|
||||
PIN_D6 6
|
||||
PIN_D7 7
|
||||
|
||||
PIN_CS1 14
|
||||
PIN_CS2 15
|
||||
PIN_RW 16
|
||||
PIN_DI 17
|
||||
PIN_EN 18
|
||||
|
||||
u8g_Init8Bit(u8g, dev, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, cs2, di, rw, reset)
|
||||
u8g_Init8Bit(u8g, dev, 8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16, U8G_PIN_NONE)
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#if defined(ARDUINO)
|
||||
|
||||
#if ARDUINO < 100
|
||||
//#include <WProgram.h>
|
||||
#include <wiring_private.h>
|
||||
#include <pins_arduino.h>
|
||||
#else
|
||||
#include <Arduino.h>
|
||||
#endif
|
||||
|
||||
|
||||
#define PIN_D0 8
|
||||
#define PIN_D1 9
|
||||
#define PIN_D2 10
|
||||
#define PIN_D3 11
|
||||
#define PIN_D4 4
|
||||
#define PIN_D5 5
|
||||
#define PIN_D6 6
|
||||
#define PIN_D7 7
|
||||
|
||||
#define PIN_CS1 14
|
||||
#define PIN_CS2 15
|
||||
#define PIN_RW 16
|
||||
#define PIN_DI 17
|
||||
#define PIN_EN 18
|
||||
|
||||
//#define PIN_RESET
|
||||
|
||||
|
||||
#if defined(__PIC32MX)
|
||||
/* CHIPKIT PIC32 */
|
||||
static volatile uint32_t *u8g_data_port[8];
|
||||
static uint32_t u8g_data_mask[8];
|
||||
#else
|
||||
static volatile uint8_t *u8g_data_port[8];
|
||||
static uint8_t u8g_data_mask[8];
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
static void u8g_com_arduino_fast_parallel_init(u8g_t *u8g)
|
||||
{
|
||||
u8g_data_port[0] = portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D0]));
|
||||
u8g_data_mask[0] = digitalPinToBitMask(u8g->pin_list[U8G_PI_D0]);
|
||||
u8g_data_port[1] = portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D1]));
|
||||
u8g_data_mask[1] = digitalPinToBitMask(u8g->pin_list[U8G_PI_D1]);
|
||||
u8g_data_port[2] = portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D2]));
|
||||
u8g_data_mask[2] = digitalPinToBitMask(u8g->pin_list[U8G_PI_D2]);
|
||||
u8g_data_port[3] = portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D3]));
|
||||
u8g_data_mask[3] = digitalPinToBitMask(u8g->pin_list[U8G_PI_D3]);
|
||||
|
||||
u8g_data_port[4] = portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D4]));
|
||||
u8g_data_mask[4] = digitalPinToBitMask(u8g->pin_list[U8G_PI_D4]);
|
||||
u8g_data_port[5] = portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D5]));
|
||||
u8g_data_mask[5] = digitalPinToBitMask(u8g->pin_list[U8G_PI_D5]);
|
||||
u8g_data_port[6] = portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D6]));
|
||||
u8g_data_mask[6] = digitalPinToBitMask(u8g->pin_list[U8G_PI_D6]);
|
||||
u8g_data_port[7] = portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D7]));
|
||||
u8g_data_mask[7] = digitalPinToBitMask(u8g->pin_list[U8G_PI_D7]);
|
||||
}
|
||||
|
||||
void u8g_com_arduino_fast_write_data_pin(uint8_t pin, uint8_t val)
|
||||
{
|
||||
if ( val != 0 )
|
||||
*u8g_data_port[pin] |= u8g_data_mask[pin];
|
||||
else
|
||||
*u8g_data_port[pin] &= ~u8g_data_mask[pin];
|
||||
}
|
||||
|
||||
|
||||
void u8g_com_arduino_fast_parallel_write(u8g_t *u8g, uint8_t val)
|
||||
{
|
||||
u8g_com_arduino_fast_write_data_pin( 0, val&1 );
|
||||
val >>= 1;
|
||||
u8g_com_arduino_fast_write_data_pin( 1, val&1 );
|
||||
val >>= 1;
|
||||
u8g_com_arduino_fast_write_data_pin( 2, val&1 );
|
||||
val >>= 1;
|
||||
u8g_com_arduino_fast_write_data_pin( 3, val&1 );
|
||||
val >>= 1;
|
||||
|
||||
u8g_com_arduino_fast_write_data_pin( 4, val&1 );
|
||||
val >>= 1;
|
||||
u8g_com_arduino_fast_write_data_pin( 5, val&1 );
|
||||
val >>= 1;
|
||||
u8g_com_arduino_fast_write_data_pin( 6, val&1 );
|
||||
val >>= 1;
|
||||
u8g_com_arduino_fast_write_data_pin( 7, val&1 );
|
||||
val >>= 1;
|
||||
|
||||
/* EN cycle time must be 1 micro second */
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_EN, HIGH);
|
||||
u8g_MicroDelay(); /* delay by 1000ns, reference: ST7920: 140ns, SBN1661: 100ns */
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_EN, LOW);
|
||||
u8g_10MicroDelay(); /* ST7920 commands: 72us */
|
||||
u8g_10MicroDelay(); /* ST7920 commands: 72us */
|
||||
}
|
||||
|
||||
|
||||
uint8_t u8g_com_arduino_fast_parallel_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_COM_MSG_INIT:
|
||||
u8g_com_arduino_fast_parallel_init(u8g);
|
||||
/* setup the RW pin as output and force it to low */
|
||||
if ( u8g->pin_list[U8G_PI_RW] != U8G_PIN_NONE )
|
||||
{
|
||||
pinMode(u8g->pin_list[U8G_PI_RW], OUTPUT);
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_RW, LOW);
|
||||
}
|
||||
/* set all pins (except RW pin) */
|
||||
u8g_com_arduino_assign_pin_output_high(u8g);
|
||||
break;
|
||||
case U8G_COM_MSG_STOP:
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_CHIP_SELECT:
|
||||
if ( arg_val == 0 )
|
||||
{
|
||||
/* disable */
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_CS1, HIGH);
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_CS2, HIGH);
|
||||
}
|
||||
else if ( arg_val == 1 )
|
||||
{
|
||||
/* enable */
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_CS1, LOW);
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_CS2, HIGH);
|
||||
}
|
||||
else if ( arg_val == 2 )
|
||||
{
|
||||
/* enable */
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_CS1, HIGH);
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_CS2, LOW);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* enable */
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_CS1, LOW);
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_CS2, LOW);
|
||||
}
|
||||
break;
|
||||
case U8G_COM_MSG_WRITE_BYTE:
|
||||
u8g_com_arduino_fast_parallel_write(u8g, arg_val);
|
||||
break;
|
||||
case U8G_COM_MSG_WRITE_SEQ:
|
||||
{
|
||||
register uint8_t *ptr = arg_ptr;
|
||||
while( arg_val > 0 )
|
||||
{
|
||||
u8g_com_arduino_fast_parallel_write(u8g, *ptr++);
|
||||
arg_val--;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case U8G_COM_MSG_WRITE_SEQ_P:
|
||||
{
|
||||
register uint8_t *ptr = arg_ptr;
|
||||
while( arg_val > 0 )
|
||||
{
|
||||
u8g_com_arduino_fast_parallel_write(u8g, u8g_pgm_read(ptr));
|
||||
ptr++;
|
||||
arg_val--;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case U8G_COM_MSG_ADDRESS: /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_DI, arg_val);
|
||||
break;
|
||||
case U8G_COM_MSG_RESET:
|
||||
if ( u8g->pin_list[U8G_PI_RESET] != U8G_PIN_NONE )
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_RESET, arg_val);
|
||||
break;
|
||||
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
|
||||
uint8_t u8g_com_arduino_fast_parallel_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
#endif /* ARDUINO */
|
||||
|
@ -0,0 +1,191 @@
|
||||
/*
|
||||
|
||||
u8g_com_arduino_hw_spi.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#if defined(ARDUINO)
|
||||
|
||||
#if defined(__AVR__)
|
||||
|
||||
#include <avr/interrupt.h>
|
||||
#include <avr/io.h>
|
||||
|
||||
#if ARDUINO < 100
|
||||
#include <WProgram.h>
|
||||
|
||||
/* fixed pins */
|
||||
#if defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__) // Sanguino.cc board
|
||||
#define PIN_SCK 7
|
||||
#define PIN_MISO 6
|
||||
#define PIN_MOSI 5
|
||||
#define PIN_CS 4
|
||||
#else // Arduino Board
|
||||
#define PIN_SCK 13
|
||||
#define PIN_MISO 12
|
||||
#define PIN_MOSI 11
|
||||
#define PIN_CS 10
|
||||
#endif // (__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)
|
||||
|
||||
#else
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
/* use Arduino pin definitions */
|
||||
#define PIN_SCK SCK
|
||||
#define PIN_MISO MISO
|
||||
#define PIN_MOSI MOSI
|
||||
#define PIN_CS SS
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
//static uint8_t u8g_spi_out(uint8_t data) U8G_NOINLINE;
|
||||
static uint8_t u8g_spi_out(uint8_t data)
|
||||
{
|
||||
/* unsigned char x = 100; */
|
||||
/* send data */
|
||||
SPDR = data;
|
||||
/* wait for transmission */
|
||||
while (!(SPSR & (1<<SPIF)))
|
||||
;
|
||||
/* clear the SPIF flag by reading SPDR */
|
||||
return SPDR;
|
||||
}
|
||||
|
||||
|
||||
uint8_t u8g_com_arduino_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_COM_MSG_STOP:
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_INIT:
|
||||
u8g_com_arduino_assign_pin_output_high(u8g);
|
||||
pinMode(PIN_SCK, OUTPUT);
|
||||
digitalWrite(PIN_SCK, LOW);
|
||||
pinMode(PIN_MOSI, OUTPUT);
|
||||
digitalWrite(PIN_MOSI, LOW);
|
||||
/* pinMode(PIN_MISO, INPUT); */
|
||||
|
||||
pinMode(PIN_CS, OUTPUT); /* system chip select for the atmega board */
|
||||
digitalWrite(PIN_CS, HIGH);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
SPR1 SPR0
|
||||
0 0 fclk/4
|
||||
0 1 fclk/16
|
||||
1 0 fclk/64
|
||||
1 1 fclk/128
|
||||
*/
|
||||
SPCR = 0;
|
||||
SPCR = (1<<SPE) | (1<<MSTR)|(0<<SPR1)|(1<<SPR0)|(0<<CPOL)|(0<<CPHA);
|
||||
#ifdef U8G_HW_SPI_2X
|
||||
SPSR = (1 << SPI2X); /* double speed, issue 89 */
|
||||
#endif
|
||||
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_ADDRESS: /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_A0, arg_val);
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_CHIP_SELECT:
|
||||
if ( arg_val == 0 )
|
||||
{
|
||||
/* disable */
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_CS, HIGH);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* enable */
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_SCK, LOW);
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_CS, LOW);
|
||||
}
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_RESET:
|
||||
if ( u8g->pin_list[U8G_PI_RESET] != U8G_PIN_NONE )
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_RESET, arg_val);
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_WRITE_BYTE:
|
||||
u8g_spi_out(arg_val);
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_WRITE_SEQ:
|
||||
{
|
||||
register uint8_t *ptr = arg_ptr;
|
||||
while( arg_val > 0 )
|
||||
{
|
||||
u8g_spi_out(*ptr++);
|
||||
arg_val--;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case U8G_COM_MSG_WRITE_SEQ_P:
|
||||
{
|
||||
register uint8_t *ptr = arg_ptr;
|
||||
while( arg_val > 0 )
|
||||
{
|
||||
u8g_spi_out(u8g_pgm_read(ptr));
|
||||
ptr++;
|
||||
arg_val--;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* #elif defined(__18CXX) || defined(__PIC32MX) */
|
||||
|
||||
#else /* __AVR__ */
|
||||
|
||||
#endif /* __AVR__ */
|
||||
|
||||
#else /* ARDUINO */
|
||||
|
||||
uint8_t u8g_com_arduino_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif /* ARDUINO */
|
||||
|
@ -0,0 +1,221 @@
|
||||
/*
|
||||
|
||||
u8g_arduino_no_en_parallel.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2012, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
PIN_D0 8
|
||||
PIN_D1 9
|
||||
PIN_D2 10
|
||||
PIN_D3 11
|
||||
PIN_D4 4
|
||||
PIN_D5 5
|
||||
PIN_D6 6
|
||||
PIN_D7 7
|
||||
|
||||
PIN_CS1 14
|
||||
PIN_CS2 15
|
||||
PIN_RW 16
|
||||
PIN_DI 17
|
||||
PIN_EN 18
|
||||
|
||||
u8g_Init8Bit(u8g, dev, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, cs2, di, rw, reset)
|
||||
u8g_Init8Bit(u8g, dev, 8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16, U8G_PIN_NONE)
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#if defined(ARDUINO)
|
||||
|
||||
#if ARDUINO < 100
|
||||
//#include <WProgram.h>
|
||||
#include <wiring_private.h>
|
||||
#include <pins_arduino.h>
|
||||
#else
|
||||
#include <Arduino.h>
|
||||
#endif
|
||||
|
||||
//#define PIN_RESET
|
||||
|
||||
#if defined(__PIC32MX)
|
||||
/* CHIPKIT PIC32 */
|
||||
static volatile uint32_t *u8g_data_port[8];
|
||||
static uint32_t u8g_data_mask[8];
|
||||
#else
|
||||
static volatile uint8_t *u8g_data_port[8];
|
||||
static uint8_t u8g_data_mask[8];
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
static void u8g_com_arduino_no_en_parallel_init(u8g_t *u8g)
|
||||
{
|
||||
u8g_data_port[0] = portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D0]));
|
||||
u8g_data_mask[0] = digitalPinToBitMask(u8g->pin_list[U8G_PI_D0]);
|
||||
u8g_data_port[1] = portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D1]));
|
||||
u8g_data_mask[1] = digitalPinToBitMask(u8g->pin_list[U8G_PI_D1]);
|
||||
u8g_data_port[2] = portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D2]));
|
||||
u8g_data_mask[2] = digitalPinToBitMask(u8g->pin_list[U8G_PI_D2]);
|
||||
u8g_data_port[3] = portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D3]));
|
||||
u8g_data_mask[3] = digitalPinToBitMask(u8g->pin_list[U8G_PI_D3]);
|
||||
|
||||
u8g_data_port[4] = portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D4]));
|
||||
u8g_data_mask[4] = digitalPinToBitMask(u8g->pin_list[U8G_PI_D4]);
|
||||
u8g_data_port[5] = portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D5]));
|
||||
u8g_data_mask[5] = digitalPinToBitMask(u8g->pin_list[U8G_PI_D5]);
|
||||
u8g_data_port[6] = portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D6]));
|
||||
u8g_data_mask[6] = digitalPinToBitMask(u8g->pin_list[U8G_PI_D6]);
|
||||
u8g_data_port[7] = portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D7]));
|
||||
u8g_data_mask[7] = digitalPinToBitMask(u8g->pin_list[U8G_PI_D7]);
|
||||
}
|
||||
|
||||
void u8g_com_arduino_no_en_write_data_pin(uint8_t pin, uint8_t val)
|
||||
{
|
||||
if ( val != 0 )
|
||||
*u8g_data_port[pin] |= u8g_data_mask[pin];
|
||||
else
|
||||
*u8g_data_port[pin] &= ~u8g_data_mask[pin];
|
||||
}
|
||||
|
||||
|
||||
void u8g_com_arduino_no_en_parallel_write(u8g_t *u8g, uint8_t val)
|
||||
{
|
||||
u8g_com_arduino_no_en_write_data_pin( 0, val&1 );
|
||||
val >>= 1;
|
||||
u8g_com_arduino_no_en_write_data_pin( 1, val&1 );
|
||||
val >>= 1;
|
||||
u8g_com_arduino_no_en_write_data_pin( 2, val&1 );
|
||||
val >>= 1;
|
||||
u8g_com_arduino_no_en_write_data_pin( 3, val&1 );
|
||||
val >>= 1;
|
||||
|
||||
u8g_com_arduino_no_en_write_data_pin( 4, val&1 );
|
||||
val >>= 1;
|
||||
u8g_com_arduino_no_en_write_data_pin( 5, val&1 );
|
||||
val >>= 1;
|
||||
u8g_com_arduino_no_en_write_data_pin( 6, val&1 );
|
||||
val >>= 1;
|
||||
u8g_com_arduino_no_en_write_data_pin( 7, val&1 );
|
||||
val >>= 1;
|
||||
|
||||
/* EN cycle time must be 1 micro second, digitalWrite is slow enough to do this */
|
||||
if ( u8g->pin_list[U8G_PI_CS_STATE] == 1 )
|
||||
{
|
||||
u8g_MicroDelay();
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_CS1, HIGH);
|
||||
u8g_MicroDelay();
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_CS1, LOW);
|
||||
u8g_MicroDelay();
|
||||
}
|
||||
else if ( u8g->pin_list[U8G_PI_CS_STATE] == 2 )
|
||||
{
|
||||
u8g_MicroDelay();
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_CS2, HIGH);
|
||||
u8g_MicroDelay();
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_CS2, LOW);
|
||||
u8g_MicroDelay();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
uint8_t u8g_com_arduino_no_en_parallel_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_COM_MSG_INIT:
|
||||
u8g_com_arduino_no_en_parallel_init(u8g);
|
||||
/* setup the RW pin as output and force it to low */
|
||||
if ( u8g->pin_list[U8G_PI_RW] != U8G_PIN_NONE )
|
||||
{
|
||||
pinMode(u8g->pin_list[U8G_PI_RW], OUTPUT);
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_RW, LOW);
|
||||
}
|
||||
/* set all pins (except RW pin) */
|
||||
u8g_com_arduino_assign_pin_output_high(u8g);
|
||||
break;
|
||||
case U8G_COM_MSG_STOP:
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_CHIP_SELECT:
|
||||
/*
|
||||
0: nothing selected
|
||||
1: CS1 will be used as enable line
|
||||
2: CS2 will be used as enable line
|
||||
this will be used in the u8g_com_arduino_no_en_parallel_write() procedure
|
||||
*/
|
||||
u8g->pin_list[U8G_PI_CS_STATE] = arg_val;
|
||||
break;
|
||||
case U8G_COM_MSG_WRITE_BYTE:
|
||||
u8g_com_arduino_no_en_parallel_write(u8g, arg_val);
|
||||
break;
|
||||
case U8G_COM_MSG_WRITE_SEQ:
|
||||
{
|
||||
register uint8_t *ptr = arg_ptr;
|
||||
while( arg_val > 0 )
|
||||
{
|
||||
u8g_com_arduino_no_en_parallel_write(u8g, *ptr++);
|
||||
arg_val--;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case U8G_COM_MSG_WRITE_SEQ_P:
|
||||
{
|
||||
register uint8_t *ptr = arg_ptr;
|
||||
while( arg_val > 0 )
|
||||
{
|
||||
u8g_com_arduino_no_en_parallel_write(u8g, u8g_pgm_read(ptr));
|
||||
ptr++;
|
||||
arg_val--;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case U8G_COM_MSG_ADDRESS: /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_DI, arg_val);
|
||||
break;
|
||||
case U8G_COM_MSG_RESET:
|
||||
if ( u8g->pin_list[U8G_PI_RESET] != U8G_PIN_NONE )
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_RESET, arg_val);
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
|
||||
uint8_t u8g_com_arduino_no_en_parallel_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
#endif /* ARDUINO */
|
||||
|
@ -0,0 +1,187 @@
|
||||
/*
|
||||
|
||||
u8g_arduino_parallel.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
PIN_D0 8
|
||||
PIN_D1 9
|
||||
PIN_D2 10
|
||||
PIN_D3 11
|
||||
PIN_D4 4
|
||||
PIN_D5 5
|
||||
PIN_D6 6
|
||||
PIN_D7 7
|
||||
|
||||
PIN_CS1 14
|
||||
PIN_CS2 15
|
||||
PIN_RW 16
|
||||
PIN_DI 17
|
||||
PIN_EN 18
|
||||
|
||||
u8g_Init8Bit(u8g, dev, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, cs2, di, rw, reset)
|
||||
u8g_Init8Bit(u8g, dev, 8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16, U8G_PIN_NONE)
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
|
||||
#if defined(ARDUINO)
|
||||
|
||||
#if ARDUINO < 100
|
||||
#include <WProgram.h>
|
||||
#else
|
||||
#include <Arduino.h>
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void u8g_com_arduino_parallel_write(u8g_t *u8g, uint8_t val)
|
||||
{
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_D0, val&1);
|
||||
val >>= 1;
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_D1, val&1);
|
||||
val >>= 1;
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_D2, val&1);
|
||||
val >>= 1;
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_D3, val&1);
|
||||
val >>= 1;
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_D4, val&1);
|
||||
val >>= 1;
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_D5, val&1);
|
||||
val >>= 1;
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_D6, val&1);
|
||||
val >>= 1;
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_D7, val&1);
|
||||
|
||||
/* EN cycle time must be 1 micro second, digitalWrite is slow enough to do this */
|
||||
//u8g_Delay(1);
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_EN, HIGH);
|
||||
//u8g_Delay(1);
|
||||
u8g_MicroDelay(); /* delay by 1000ns, reference: ST7920: 140ns, SBN1661: 100ns */
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_EN, LOW);
|
||||
u8g_10MicroDelay(); /* ST7920 commands: 72us */
|
||||
//u8g_Delay(2);
|
||||
}
|
||||
|
||||
|
||||
uint8_t u8g_com_arduino_parallel_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_COM_MSG_INIT:
|
||||
/* setup the RW pin as output and force it to low */
|
||||
if ( u8g->pin_list[U8G_PI_RW] != U8G_PIN_NONE )
|
||||
{
|
||||
pinMode(u8g->pin_list[U8G_PI_RW], OUTPUT);
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_RW, LOW);
|
||||
}
|
||||
/* set all pins (except RW pin) */
|
||||
u8g_com_arduino_assign_pin_output_high(u8g);
|
||||
break;
|
||||
case U8G_COM_MSG_STOP:
|
||||
break;
|
||||
case U8G_COM_MSG_CHIP_SELECT:
|
||||
if ( arg_val == 0 )
|
||||
{
|
||||
/* disable */
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_CS1, HIGH);
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_CS2, HIGH);
|
||||
}
|
||||
else if ( arg_val == 1 )
|
||||
{
|
||||
/* enable */
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_CS1, LOW);
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_CS2, HIGH);
|
||||
}
|
||||
else if ( arg_val == 2 )
|
||||
{
|
||||
/* enable */
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_CS1, HIGH);
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_CS2, LOW);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* enable */
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_CS1, LOW);
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_CS2, LOW);
|
||||
}
|
||||
break;
|
||||
case U8G_COM_MSG_WRITE_BYTE:
|
||||
u8g_com_arduino_parallel_write(u8g, arg_val);
|
||||
break;
|
||||
case U8G_COM_MSG_WRITE_SEQ:
|
||||
{
|
||||
register uint8_t *ptr = arg_ptr;
|
||||
while( arg_val > 0 )
|
||||
{
|
||||
u8g_com_arduino_parallel_write(u8g, *ptr++);
|
||||
arg_val--;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case U8G_COM_MSG_WRITE_SEQ_P:
|
||||
{
|
||||
register uint8_t *ptr = arg_ptr;
|
||||
while( arg_val > 0 )
|
||||
{
|
||||
u8g_com_arduino_parallel_write(u8g, u8g_pgm_read(ptr));
|
||||
ptr++;
|
||||
arg_val--;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case U8G_COM_MSG_ADDRESS: /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_DI, arg_val);
|
||||
break;
|
||||
case U8G_COM_MSG_RESET:
|
||||
if ( u8g->pin_list[U8G_PI_RESET] != U8G_PIN_NONE )
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_RESET, arg_val);
|
||||
break;
|
||||
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
|
||||
uint8_t u8g_com_arduino_parallel_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif /* ARDUINO */
|
||||
|
@ -0,0 +1,168 @@
|
||||
/*
|
||||
|
||||
u8g_arduino_port_d_wr.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
Assumes PORTD for 8 bit data transfer.
|
||||
EN is assumed to be a low active write signal (WR)
|
||||
|
||||
ILI9325D_320x240 from iteadstudio.com
|
||||
RS=19, WR=18, CS=17, RST=16
|
||||
|
||||
|
||||
u8g_Init8Bit(u8g, dev, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, cs2, di, rw, reset)
|
||||
u8g_Init8Bit(u8g, dev, 8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16, U8G_PIN_NONE)
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
|
||||
#if defined(ARDUINO) && defined(PORTD)
|
||||
|
||||
#if ARDUINO < 100
|
||||
#include <WProgram.h>
|
||||
#else
|
||||
#include <Arduino.h>
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static void u8g_com_arduino_port_d_8bit_wr(u8g_t *u8g, uint8_t val)
|
||||
{
|
||||
PORTD = val;
|
||||
|
||||
/* WR cycle time must be 1 micro second, digitalWrite is slow enough to do this */
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_EN, LOW);
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_EN, HIGH);
|
||||
}
|
||||
|
||||
|
||||
uint8_t u8g_com_arduino_port_d_wr_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
|
||||
{
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_COM_MSG_INIT:
|
||||
|
||||
#ifdef UCSR0B
|
||||
UCSR0B = 0; // disable USART 0
|
||||
#endif
|
||||
DDRD = 0x0ff;
|
||||
PORTD = 0x0ff;
|
||||
|
||||
/* setup the RW pin as output and force it to low */
|
||||
if ( u8g->pin_list[U8G_PI_RW] != U8G_PIN_NONE )
|
||||
{
|
||||
pinMode(u8g->pin_list[U8G_PI_RW], OUTPUT);
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_RW, HIGH);
|
||||
}
|
||||
/* set all pins (except RW pin) */
|
||||
u8g_com_arduino_assign_pin_output_high(u8g);
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_EN, HIGH);
|
||||
break;
|
||||
case U8G_COM_MSG_STOP:
|
||||
break;
|
||||
case U8G_COM_MSG_CHIP_SELECT:
|
||||
if ( arg_val == 0 )
|
||||
{
|
||||
/* disable */
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_CS1, HIGH);
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_CS2, HIGH);
|
||||
}
|
||||
else if ( arg_val == 1 )
|
||||
{
|
||||
/* enable */
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_CS1, LOW);
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_CS2, HIGH);
|
||||
}
|
||||
else if ( arg_val == 2 )
|
||||
{
|
||||
/* enable */
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_CS1, HIGH);
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_CS2, LOW);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* enable */
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_CS1, LOW);
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_CS2, LOW);
|
||||
}
|
||||
break;
|
||||
case U8G_COM_MSG_WRITE_BYTE:
|
||||
u8g_com_arduino_port_d_8bit_wr(u8g, arg_val);
|
||||
break;
|
||||
case U8G_COM_MSG_WRITE_SEQ:
|
||||
{
|
||||
register uint8_t *ptr = arg_ptr;
|
||||
while( arg_val > 0 )
|
||||
{
|
||||
u8g_com_arduino_port_d_8bit_wr(u8g, *ptr++);
|
||||
arg_val--;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case U8G_COM_MSG_WRITE_SEQ_P:
|
||||
{
|
||||
register uint8_t *ptr = arg_ptr;
|
||||
while( arg_val > 0 )
|
||||
{
|
||||
u8g_com_arduino_port_d_8bit_wr(u8g, u8g_pgm_read(ptr));
|
||||
ptr++;
|
||||
arg_val--;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case U8G_COM_MSG_ADDRESS: /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_DI, arg_val);
|
||||
break;
|
||||
case U8G_COM_MSG_RESET:
|
||||
if ( u8g->pin_list[U8G_PI_RESET] != U8G_PIN_NONE )
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_RESET, arg_val);
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
|
||||
uint8_t u8g_com_arduino_port_d_wr_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif /* ARDUINO && PORTD */
|
||||
|
@ -0,0 +1,201 @@
|
||||
/*
|
||||
|
||||
u8g_com_arduino_ssd_i2c.c
|
||||
|
||||
com interface for arduino (AND atmega) and the SSDxxxx chip (SOLOMON) variant
|
||||
I2C protocol
|
||||
|
||||
ToDo: Rename this to u8g_com_avr_ssd_i2c.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2012, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
Special pin usage:
|
||||
U8G_PI_I2C_OPTION additional options
|
||||
U8G_PI_A0_STATE used to store the last value of the command/data register selection
|
||||
U8G_PI_SET_A0 1: Signal request to update I2C device with new A0_STATE, 0: Do nothing, A0_STATE matches I2C device
|
||||
U8G_PI_SCL clock line (NOT USED)
|
||||
U8G_PI_SDA data line (NOT USED)
|
||||
|
||||
U8G_PI_RESET reset line (currently disabled, see below)
|
||||
|
||||
Protocol:
|
||||
SLA, Cmd/Data Selection, Arguments
|
||||
The command/data register is selected by a special instruction byte, which is sent after SLA
|
||||
|
||||
The continue bit is always 0 so that a (re)start is equired for the change from cmd to/data mode
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define I2C_SLA (0x3c*2)
|
||||
//#define I2C_CMD_MODE 0x080
|
||||
#define I2C_CMD_MODE 0x000
|
||||
#define I2C_DATA_MODE 0x040
|
||||
|
||||
|
||||
uint8_t u8g_com_arduino_ssd_start_sequence(u8g_t *u8g)
|
||||
{
|
||||
/* are we requested to set the a0 state? */
|
||||
if ( u8g->pin_list[U8G_PI_SET_A0] == 0 )
|
||||
return 1;
|
||||
|
||||
/* setup bus, might be a repeated start */
|
||||
if ( u8g_i2c_start(I2C_SLA) == 0 )
|
||||
return 0;
|
||||
if ( u8g->pin_list[U8G_PI_A0_STATE] == 0 )
|
||||
{
|
||||
if ( u8g_i2c_send_byte(I2C_CMD_MODE) == 0 )
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( u8g_i2c_send_byte(I2C_DATA_MODE) == 0 )
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
u8g->pin_list[U8G_PI_SET_A0] = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint8_t u8g_com_arduino_ssd_i2c_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_COM_MSG_INIT:
|
||||
//u8g_com_arduino_digital_write(u8g, U8G_PI_SCL, HIGH);
|
||||
//u8g_com_arduino_digital_write(u8g, U8G_PI_SDA, HIGH);
|
||||
//u8g->pin_list[U8G_PI_A0_STATE] = 0; /* inital RS state: unknown mode */
|
||||
|
||||
u8g_i2c_init(u8g->pin_list[U8G_PI_I2C_OPTION]);
|
||||
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_STOP:
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_RESET:
|
||||
/* Currently disabled, but it could be enable. Previous restrictions have been removed */
|
||||
/* u8g_com_arduino_digital_write(u8g, U8G_PI_RESET, arg_val); */
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_CHIP_SELECT:
|
||||
u8g->pin_list[U8G_PI_A0_STATE] = 0;
|
||||
u8g->pin_list[U8G_PI_SET_A0] = 1; /* force a0 to set again, also forces start condition */
|
||||
if ( arg_val == 0 )
|
||||
{
|
||||
/* disable chip, send stop condition */
|
||||
u8g_i2c_stop();
|
||||
}
|
||||
else
|
||||
{
|
||||
/* enable, do nothing: any byte writing will trigger the i2c start */
|
||||
}
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_WRITE_BYTE:
|
||||
//u8g->pin_list[U8G_PI_SET_A0] = 1;
|
||||
if ( u8g_com_arduino_ssd_start_sequence(u8g) == 0 )
|
||||
return u8g_i2c_stop(), 0;
|
||||
if ( u8g_i2c_send_byte(arg_val) == 0 )
|
||||
return u8g_i2c_stop(), 0;
|
||||
// u8g_i2c_stop();
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_WRITE_SEQ:
|
||||
//u8g->pin_list[U8G_PI_SET_A0] = 1;
|
||||
if ( u8g_com_arduino_ssd_start_sequence(u8g) == 0 )
|
||||
return u8g_i2c_stop(), 0;
|
||||
{
|
||||
register uint8_t *ptr = arg_ptr;
|
||||
while( arg_val > 0 )
|
||||
{
|
||||
if ( u8g_i2c_send_byte(*ptr++) == 0 )
|
||||
return u8g_i2c_stop(), 0;
|
||||
arg_val--;
|
||||
}
|
||||
}
|
||||
// u8g_i2c_stop();
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_WRITE_SEQ_P:
|
||||
//u8g->pin_list[U8G_PI_SET_A0] = 1;
|
||||
if ( u8g_com_arduino_ssd_start_sequence(u8g) == 0 )
|
||||
return u8g_i2c_stop(), 0;
|
||||
{
|
||||
register uint8_t *ptr = arg_ptr;
|
||||
while( arg_val > 0 )
|
||||
{
|
||||
if ( u8g_i2c_send_byte(u8g_pgm_read(ptr)) == 0 )
|
||||
return 0;
|
||||
ptr++;
|
||||
arg_val--;
|
||||
}
|
||||
}
|
||||
// u8g_i2c_stop();
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_ADDRESS: /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
|
||||
u8g->pin_list[U8G_PI_A0_STATE] = arg_val;
|
||||
u8g->pin_list[U8G_PI_SET_A0] = 1; /* force a0 to set again */
|
||||
|
||||
#ifdef OLD_CODE
|
||||
if ( i2c_state != 0 )
|
||||
{
|
||||
u8g_i2c_stop();
|
||||
i2c_state = 0;
|
||||
}
|
||||
|
||||
if ( u8g_com_arduino_ssd_start_sequence(arg_val) == 0 )
|
||||
return 0;
|
||||
|
||||
/* setup bus, might be a repeated start */
|
||||
/*
|
||||
if ( u8g_i2c_start(I2C_SLA) == 0 )
|
||||
return 0;
|
||||
if ( arg_val == 0 )
|
||||
{
|
||||
i2c_state = 1;
|
||||
|
||||
if ( u8g_i2c_send_byte(I2C_CMD_MODE) == 0 )
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
i2c_state = 2;
|
||||
if ( u8g_i2c_send_byte(I2C_DATA_MODE) == 0 )
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
@ -0,0 +1,220 @@
|
||||
/*
|
||||
|
||||
u8g_com_arduino_st7920_hw_spi.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
A special HW SPI interface for ST7920 controller
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#if defined(ARDUINO)
|
||||
|
||||
#if ARDUINO < 100
|
||||
#include <WProgram.h>
|
||||
#include "wiring_private.h"
|
||||
#include "pins_arduino.h"
|
||||
|
||||
#else
|
||||
#include <Arduino.h>
|
||||
#include "wiring_private.h"
|
||||
#endif
|
||||
|
||||
#if defined(__AVR__)
|
||||
#define U8G_ARDUINO_ATMEGA_HW_SPI
|
||||
|
||||
/* remove the definition for attiny */
|
||||
#if __AVR_ARCH__ == 2
|
||||
#undef U8G_ATMEGA_HW_SPI
|
||||
#endif
|
||||
#if __AVR_ARCH__ == 25
|
||||
#undef U8G_ATMEGA_HW_SPI
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(U8G_ARDUINO_ATMEGA_HW_SPI)
|
||||
|
||||
#include <avr/interrupt.h>
|
||||
#include <avr/io.h>
|
||||
|
||||
static uint8_t u8g_arduino_st7920_hw_spi_shift_out(u8g_t *u8g, uint8_t val) U8G_NOINLINE;
|
||||
static uint8_t u8g_arduino_st7920_hw_spi_shift_out(u8g_t *u8g, uint8_t val)
|
||||
{
|
||||
/* send data */
|
||||
SPDR = val;
|
||||
/* wait for transmission */
|
||||
while (!(SPSR & (1<<SPIF)))
|
||||
;
|
||||
/* clear the SPIF flag by reading SPDR */
|
||||
return SPDR;
|
||||
}
|
||||
|
||||
|
||||
static void u8g_com_arduino_st7920_write_byte_hw_spi(u8g_t *u8g, uint8_t rs, uint8_t val) U8G_NOINLINE;
|
||||
static void u8g_com_arduino_st7920_write_byte_hw_spi(u8g_t *u8g, uint8_t rs, uint8_t val)
|
||||
{
|
||||
uint8_t i;
|
||||
|
||||
if ( rs == 0 )
|
||||
{
|
||||
/* command */
|
||||
u8g_arduino_st7920_hw_spi_shift_out(u8g, 0x0f8);
|
||||
}
|
||||
else if ( rs == 1 )
|
||||
{
|
||||
/* data */
|
||||
u8g_arduino_st7920_hw_spi_shift_out(u8g, 0x0fa);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* do nothing, keep same state */
|
||||
}
|
||||
|
||||
u8g_arduino_st7920_hw_spi_shift_out(u8g, val & 0x0f0);
|
||||
u8g_arduino_st7920_hw_spi_shift_out(u8g, val << 4);
|
||||
|
||||
for( i = 0; i < 4; i++ )
|
||||
u8g_10MicroDelay();
|
||||
}
|
||||
|
||||
|
||||
uint8_t u8g_com_arduino_st7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_COM_MSG_INIT:
|
||||
u8g_com_arduino_assign_pin_output_high(u8g);
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_CS, LOW);
|
||||
|
||||
DDRB |= _BV(3); /* D0, MOSI */
|
||||
DDRB |= _BV(5); /* SCK */
|
||||
DDRB |= _BV(2); /* slave select */
|
||||
|
||||
PORTB &= ~_BV(3); /* D0, MOSI = 0 */
|
||||
PORTB &= ~_BV(5); /* SCK = 0 */
|
||||
|
||||
/*
|
||||
SPR1 SPR0
|
||||
0 0 fclk/4
|
||||
0 1 fclk/16
|
||||
1 0 fclk/64
|
||||
1 1 fclk/128
|
||||
*/
|
||||
SPCR = 0;
|
||||
|
||||
/* 20 Dez 2012: set CPOL and CPHA to 1 !!! */
|
||||
SPCR = (1<<SPE) | (1<<MSTR)|(0<<SPR1)|(0<<SPR0)|(1<<CPOL)|(1<<CPHA);
|
||||
#ifdef U8G_HW_SPI_2X
|
||||
SPSR = (1 << SPI2X); /* double speed, issue 89 */
|
||||
#endif
|
||||
u8g->pin_list[U8G_PI_A0_STATE] = 0; /* inital RS state: command mode */
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_STOP:
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_RESET:
|
||||
if ( u8g->pin_list[U8G_PI_RESET] != U8G_PIN_NONE )
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_RESET, arg_val);
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_CHIP_SELECT:
|
||||
if ( arg_val == 0 )
|
||||
{
|
||||
/* disable, note: the st7920 has an active high chip select */
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_CS, LOW);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* enable */
|
||||
//u8g_com_arduino_digital_write(u8g, U8G_PI_SCK, LOW);
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_CS, HIGH);
|
||||
}
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_WRITE_BYTE:
|
||||
u8g_com_arduino_st7920_write_byte_hw_spi(u8g, u8g->pin_list[U8G_PI_A0_STATE], arg_val);
|
||||
// u8g->pin_list[U8G_PI_A0_STATE] = 2;
|
||||
//u8g_arduino_sw_spi_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK], arg_val);
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_WRITE_SEQ:
|
||||
{
|
||||
register uint8_t *ptr = arg_ptr;
|
||||
while( arg_val > 0 )
|
||||
{
|
||||
u8g_com_arduino_st7920_write_byte_hw_spi(u8g, u8g->pin_list[U8G_PI_A0_STATE], *ptr++);
|
||||
// u8g->pin_list[U8G_PI_A0_STATE] = 2;
|
||||
arg_val--;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_WRITE_SEQ_P:
|
||||
{
|
||||
register uint8_t *ptr = arg_ptr;
|
||||
while( arg_val > 0 )
|
||||
{
|
||||
u8g_com_arduino_st7920_write_byte_hw_spi(u8g, u8g->pin_list[U8G_PI_A0_STATE], u8g_pgm_read(ptr) );
|
||||
// u8g->pin_list[U8G_PI_A0_STATE] = 2;
|
||||
ptr++;
|
||||
arg_val--;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_ADDRESS: /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
|
||||
u8g->pin_list[U8G_PI_A0_STATE] = arg_val;
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
uint8_t u8g_com_arduino_st7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#else /* ARDUINO */
|
||||
|
||||
uint8_t u8g_com_arduino_st7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif /* ARDUINO */
|
||||
|
@ -0,0 +1,295 @@
|
||||
/*
|
||||
|
||||
u8g_com_arduino_st7920_spi.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
A special SPI interface for ST7920 controller
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#if defined(ARDUINO)
|
||||
|
||||
#if ARDUINO < 100
|
||||
#include <WProgram.h>
|
||||
#include "wiring_private.h"
|
||||
#include "pins_arduino.h"
|
||||
|
||||
#else
|
||||
#include <Arduino.h>
|
||||
#include "wiring_private.h"
|
||||
#endif
|
||||
|
||||
#if defined(__AVR__)
|
||||
|
||||
uint8_t u8g_bitData, u8g_bitNotData;
|
||||
uint8_t u8g_bitClock, u8g_bitNotClock;
|
||||
volatile uint8_t *u8g_outData;
|
||||
volatile uint8_t *u8g_outClock;
|
||||
|
||||
static void u8g_com_arduino_init_shift_out(uint8_t dataPin, uint8_t clockPin)
|
||||
{
|
||||
u8g_outData = portOutputRegister(digitalPinToPort(dataPin));
|
||||
u8g_outClock = portOutputRegister(digitalPinToPort(clockPin));
|
||||
u8g_bitData = digitalPinToBitMask(dataPin);
|
||||
u8g_bitClock = digitalPinToBitMask(clockPin);
|
||||
|
||||
u8g_bitNotClock = u8g_bitClock;
|
||||
u8g_bitNotClock ^= 0x0ff;
|
||||
|
||||
u8g_bitNotData = u8g_bitData;
|
||||
u8g_bitNotData ^= 0x0ff;
|
||||
}
|
||||
|
||||
static void u8g_com_arduino_do_shift_out_msb_first(uint8_t val) U8G_NOINLINE;
|
||||
static void u8g_com_arduino_do_shift_out_msb_first(uint8_t val)
|
||||
{
|
||||
uint8_t cnt = 8;
|
||||
uint8_t bitData = u8g_bitData;
|
||||
uint8_t bitNotData = u8g_bitNotData;
|
||||
uint8_t bitClock = u8g_bitClock;
|
||||
uint8_t bitNotClock = u8g_bitNotClock;
|
||||
volatile uint8_t *outData = u8g_outData;
|
||||
volatile uint8_t *outClock = u8g_outClock;
|
||||
do
|
||||
{
|
||||
if ( val & 128 )
|
||||
*outData |= bitData;
|
||||
else
|
||||
*outData &= bitNotData;
|
||||
|
||||
/*
|
||||
*outClock |= bitClock;
|
||||
val <<= 1;
|
||||
cnt--;
|
||||
*outClock &= bitNotClock;
|
||||
*/
|
||||
|
||||
val <<= 1;
|
||||
*outClock &= bitNotClock;
|
||||
cnt--;
|
||||
// removed micro delays, because AVRs are too slow and the delay is not required
|
||||
//u8g_MicroDelay();
|
||||
*outClock |= bitClock;
|
||||
//u8g_MicroDelay();
|
||||
} while( cnt != 0 );
|
||||
}
|
||||
|
||||
#elif defined(__18CXX) || defined(__PIC32MX)
|
||||
|
||||
uint16_t dog_bitData, dog_bitNotData;
|
||||
uint16_t dog_bitClock, dog_bitNotClock;
|
||||
volatile uint32_t *dog_outData;
|
||||
volatile uint32_t *dog_outClock;
|
||||
volatile uint32_t dog_pic32_spi_tmp;
|
||||
|
||||
static void u8g_com_arduino_init_shift_out(uint8_t dataPin, uint8_t clockPin)
|
||||
{
|
||||
dog_outData = portOutputRegister(digitalPinToPort(dataPin));
|
||||
dog_outClock = portOutputRegister(digitalPinToPort(clockPin));
|
||||
dog_bitData = digitalPinToBitMask(dataPin);
|
||||
dog_bitClock = digitalPinToBitMask(clockPin);
|
||||
|
||||
dog_bitNotClock = dog_bitClock;
|
||||
dog_bitNotClock ^= 0x0ffff;
|
||||
|
||||
dog_bitNotData = dog_bitData;
|
||||
dog_bitNotData ^= 0x0ffff;
|
||||
}
|
||||
|
||||
static void u8g_com_arduino_do_shift_out_msb_first(uint8_t val)
|
||||
{
|
||||
uint8_t cnt = 8;
|
||||
do
|
||||
{
|
||||
if ( val & 128 )
|
||||
*dog_outData |= dog_bitData;
|
||||
else
|
||||
*dog_outData &= dog_bitNotData;
|
||||
val <<= 1;
|
||||
//u8g_MicroDelay();
|
||||
//*dog_outClock |= dog_bitClock;
|
||||
*dog_outClock &= dog_bitNotClock;
|
||||
cnt--;
|
||||
u8g_MicroDelay();
|
||||
//*dog_outClock &= dog_bitNotClock;
|
||||
*dog_outClock |= dog_bitClock;
|
||||
u8g_MicroDelay();
|
||||
|
||||
} while( cnt != 0 );
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
/* default interface, Arduino DUE (__arm__) */
|
||||
|
||||
uint8_t u8g_data_pin;
|
||||
uint8_t u8g_clock_pin;
|
||||
|
||||
static void u8g_com_arduino_init_shift_out(uint8_t dataPin, uint8_t clockPin)
|
||||
{
|
||||
u8g_data_pin = dataPin;
|
||||
u8g_clock_pin = clockPin;
|
||||
}
|
||||
|
||||
static void u8g_com_arduino_do_shift_out_msb_first(uint8_t val)
|
||||
{
|
||||
uint8_t cnt = 8;
|
||||
do
|
||||
{
|
||||
if ( val & 128 )
|
||||
digitalWrite(u8g_data_pin, HIGH);
|
||||
else
|
||||
digitalWrite(u8g_data_pin, LOW);
|
||||
val <<= 1;
|
||||
//u8g_MicroDelay();
|
||||
digitalWrite(u8g_clock_pin, LOW);
|
||||
cnt--;
|
||||
u8g_MicroDelay();
|
||||
digitalWrite(u8g_clock_pin, HIGH);
|
||||
u8g_MicroDelay();
|
||||
} while( cnt != 0 );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
static void u8g_com_arduino_st7920_write_byte(uint8_t rs, uint8_t val)
|
||||
{
|
||||
uint8_t i;
|
||||
|
||||
if ( rs == 0 )
|
||||
{
|
||||
/* command */
|
||||
u8g_com_arduino_do_shift_out_msb_first(0x0f8);
|
||||
}
|
||||
else if ( rs == 1 )
|
||||
{
|
||||
/* data */
|
||||
u8g_com_arduino_do_shift_out_msb_first(0x0fa);
|
||||
}
|
||||
|
||||
u8g_com_arduino_do_shift_out_msb_first(val & 0x0f0);
|
||||
u8g_com_arduino_do_shift_out_msb_first(val << 4);
|
||||
|
||||
for( i = 0; i < 4; i++ )
|
||||
u8g_10MicroDelay();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t u8g_com_arduino_st7920_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_COM_MSG_INIT:
|
||||
u8g_com_arduino_assign_pin_output_high(u8g);
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_CS, LOW);
|
||||
// u8g_com_arduino_digital_write(u8g, U8G_PI_SCK, LOW);
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_SCK, HIGH);
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_MOSI, LOW);
|
||||
u8g_com_arduino_init_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK]);
|
||||
u8g->pin_list[U8G_PI_A0_STATE] = 0; /* inital RS state: command mode */
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_STOP:
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_RESET:
|
||||
if ( u8g->pin_list[U8G_PI_RESET] != U8G_PIN_NONE )
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_RESET, arg_val);
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_CHIP_SELECT:
|
||||
if ( arg_val == 0 )
|
||||
{
|
||||
/* disable, note: the st7920 has an active high chip select */
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_CS, LOW);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* enable */
|
||||
//u8g_com_arduino_digital_write(u8g, U8G_PI_SCK, HIGH);
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_CS, HIGH);
|
||||
}
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_WRITE_BYTE:
|
||||
u8g_com_arduino_st7920_write_byte( u8g->pin_list[U8G_PI_A0_STATE], arg_val);
|
||||
//u8g->pin_list[U8G_PI_A0_STATE] = 2;
|
||||
//u8g_arduino_sw_spi_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK], arg_val);
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_WRITE_SEQ:
|
||||
{
|
||||
register uint8_t *ptr = arg_ptr;
|
||||
while( arg_val > 0 )
|
||||
{
|
||||
u8g_com_arduino_st7920_write_byte(u8g->pin_list[U8G_PI_A0_STATE], *ptr++);
|
||||
//u8g->pin_list[U8G_PI_A0_STATE] = 2;
|
||||
arg_val--;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_WRITE_SEQ_P:
|
||||
{
|
||||
register uint8_t *ptr = arg_ptr;
|
||||
while( arg_val > 0 )
|
||||
{
|
||||
u8g_com_arduino_st7920_write_byte(u8g->pin_list[U8G_PI_A0_STATE], u8g_pgm_read(ptr) );
|
||||
//u8g->pin_list[U8G_PI_A0_STATE] = 2;
|
||||
ptr++;
|
||||
arg_val--;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_ADDRESS: /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
|
||||
u8g->pin_list[U8G_PI_A0_STATE] = arg_val;
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
#else /* ARDUINO */
|
||||
|
||||
uint8_t u8g_com_arduino_st7920_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif /* ARDUINO */
|
||||
|
@ -0,0 +1,144 @@
|
||||
/*
|
||||
|
||||
u8g_arduino_std_sw_spi.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
|
||||
#if defined(ARDUINO)
|
||||
|
||||
#if ARDUINO < 100
|
||||
#include <WProgram.h>
|
||||
#else
|
||||
#include <Arduino.h>
|
||||
#endif
|
||||
|
||||
void u8g_arduino_sw_spi_shift_out(uint8_t dataPin, uint8_t clockPin, uint8_t val)
|
||||
{
|
||||
uint8_t i = 8;
|
||||
do
|
||||
{
|
||||
if ( val & 128 )
|
||||
digitalWrite(dataPin, HIGH);
|
||||
else
|
||||
digitalWrite(dataPin, LOW);
|
||||
val <<= 1;
|
||||
u8g_MicroDelay(); /* 23 Sep 2012 */
|
||||
//delay(1);
|
||||
digitalWrite(clockPin, HIGH);
|
||||
u8g_MicroDelay(); /* 23 Sep 2012 */
|
||||
//delay(1);
|
||||
digitalWrite(clockPin, LOW);
|
||||
u8g_MicroDelay(); /* 23 Sep 2012 */
|
||||
//delay(1);
|
||||
i--;
|
||||
} while( i != 0 );
|
||||
}
|
||||
|
||||
uint8_t u8g_com_arduino_std_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_COM_MSG_INIT:
|
||||
u8g_com_arduino_assign_pin_output_high(u8g);
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_SCK, LOW);
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_MOSI, LOW);
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_STOP:
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_RESET:
|
||||
if ( u8g->pin_list[U8G_PI_RESET] != U8G_PIN_NONE )
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_RESET, arg_val);
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_CHIP_SELECT:
|
||||
if ( arg_val == 0 )
|
||||
{
|
||||
/* disable */
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_CS, HIGH);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* enable */
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_SCK, LOW);
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_CS, LOW);
|
||||
}
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_WRITE_BYTE:
|
||||
u8g_arduino_sw_spi_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK], arg_val);
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_WRITE_SEQ:
|
||||
{
|
||||
register uint8_t *ptr = arg_ptr;
|
||||
while( arg_val > 0 )
|
||||
{
|
||||
u8g_arduino_sw_spi_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK], *ptr++);
|
||||
arg_val--;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_WRITE_SEQ_P:
|
||||
{
|
||||
register uint8_t *ptr = arg_ptr;
|
||||
while( arg_val > 0 )
|
||||
{
|
||||
u8g_arduino_sw_spi_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK], u8g_pgm_read(ptr));
|
||||
ptr++;
|
||||
arg_val--;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_ADDRESS: /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_A0, arg_val);
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
#else /* ARDUINO */
|
||||
|
||||
uint8_t u8g_com_arduino_std_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif /* ARDUINO */
|
||||
|
@ -0,0 +1,239 @@
|
||||
/*
|
||||
|
||||
u8g_arduino_sw_spi.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#if defined(ARDUINO)
|
||||
|
||||
#if ARDUINO < 100
|
||||
#include <WProgram.h>
|
||||
#include "wiring_private.h"
|
||||
#include "pins_arduino.h"
|
||||
|
||||
#else
|
||||
#include <Arduino.h>
|
||||
#include "wiring_private.h"
|
||||
#endif
|
||||
|
||||
#if defined(__AVR__)
|
||||
|
||||
uint8_t u8g_bitData, u8g_bitNotData;
|
||||
uint8_t u8g_bitClock, u8g_bitNotClock;
|
||||
volatile uint8_t *u8g_outData;
|
||||
volatile uint8_t *u8g_outClock;
|
||||
|
||||
static void u8g_com_arduino_init_shift_out(uint8_t dataPin, uint8_t clockPin)
|
||||
{
|
||||
u8g_outData = portOutputRegister(digitalPinToPort(dataPin));
|
||||
u8g_outClock = portOutputRegister(digitalPinToPort(clockPin));
|
||||
u8g_bitData = digitalPinToBitMask(dataPin);
|
||||
u8g_bitClock = digitalPinToBitMask(clockPin);
|
||||
|
||||
u8g_bitNotClock = u8g_bitClock;
|
||||
u8g_bitNotClock ^= 0x0ff;
|
||||
|
||||
u8g_bitNotData = u8g_bitData;
|
||||
u8g_bitNotData ^= 0x0ff;
|
||||
}
|
||||
|
||||
static void u8g_com_arduino_do_shift_out_msb_first(uint8_t val) U8G_NOINLINE;
|
||||
static void u8g_com_arduino_do_shift_out_msb_first(uint8_t val)
|
||||
{
|
||||
uint8_t cnt = 8;
|
||||
uint8_t bitData = u8g_bitData;
|
||||
uint8_t bitNotData = u8g_bitNotData;
|
||||
uint8_t bitClock = u8g_bitClock;
|
||||
uint8_t bitNotClock = u8g_bitNotClock;
|
||||
volatile uint8_t *outData = u8g_outData;
|
||||
volatile uint8_t *outClock = u8g_outClock;
|
||||
do
|
||||
{
|
||||
if ( val & 128 )
|
||||
*outData |= bitData;
|
||||
else
|
||||
*outData &= bitNotData;
|
||||
|
||||
*outClock |= bitClock;
|
||||
val <<= 1;
|
||||
cnt--;
|
||||
*outClock &= bitNotClock;
|
||||
} while( cnt != 0 );
|
||||
}
|
||||
|
||||
#elif defined(__18CXX) || defined(__PIC32MX)
|
||||
|
||||
uint16_t dog_bitData, dog_bitNotData;
|
||||
uint16_t dog_bitClock, dog_bitNotClock;
|
||||
volatile uint32_t *dog_outData;
|
||||
volatile uint32_t *dog_outClock;
|
||||
volatile uint32_t dog_pic32_spi_tmp;
|
||||
|
||||
static void u8g_com_arduino_init_shift_out(uint8_t dataPin, uint8_t clockPin)
|
||||
{
|
||||
dog_outData = portOutputRegister(digitalPinToPort(dataPin));
|
||||
dog_outClock = portOutputRegister(digitalPinToPort(clockPin));
|
||||
dog_bitData = digitalPinToBitMask(dataPin);
|
||||
dog_bitClock = digitalPinToBitMask(clockPin);
|
||||
|
||||
dog_bitNotClock = dog_bitClock;
|
||||
dog_bitNotClock ^= 0x0ffff;
|
||||
|
||||
dog_bitNotData = dog_bitData;
|
||||
dog_bitNotData ^= 0x0ffff;
|
||||
}
|
||||
|
||||
static void u8g_com_arduino_do_shift_out_msb_first(uint8_t val)
|
||||
{
|
||||
uint8_t cnt = 8;
|
||||
do
|
||||
{
|
||||
if ( val & 128 )
|
||||
*dog_outData |= dog_bitData;
|
||||
else
|
||||
*dog_outData &= dog_bitNotData;
|
||||
val <<= 1;
|
||||
/*
|
||||
There must be some delay here. However
|
||||
fetching the adress dog_outClock is enough delay, so
|
||||
do not place dog_outClock in a local variable. This will
|
||||
break the procedure
|
||||
*/
|
||||
*dog_outClock |= dog_bitClock;
|
||||
cnt--;
|
||||
*dog_outClock &= dog_bitNotClock;
|
||||
/*
|
||||
little additional delay after clk pulse, done by 3x32bit reads
|
||||
from I/O. Optimized for PIC32 with 80 MHz.
|
||||
*/
|
||||
dog_pic32_spi_tmp = *dog_outClock;
|
||||
dog_pic32_spi_tmp = *dog_outClock;
|
||||
dog_pic32_spi_tmp = *dog_outClock;
|
||||
} while( cnt != 0 );
|
||||
}
|
||||
|
||||
#else
|
||||
/* empty interface */
|
||||
|
||||
static void u8g_com_arduino_init_shift_out(uint8_t dataPin, uint8_t clockPin)
|
||||
{
|
||||
}
|
||||
|
||||
static void u8g_com_arduino_do_shift_out_msb_first(uint8_t val)
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
uint8_t u8g_com_arduino_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_COM_MSG_INIT:
|
||||
u8g_com_arduino_assign_pin_output_high(u8g);
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_SCK, LOW);
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_MOSI, LOW);
|
||||
u8g_com_arduino_init_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK]);
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_STOP:
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_RESET:
|
||||
if ( u8g->pin_list[U8G_PI_RESET] != U8G_PIN_NONE )
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_RESET, arg_val);
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_CHIP_SELECT:
|
||||
if ( arg_val == 0 )
|
||||
{
|
||||
/* disable */
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_CS, HIGH);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* enable */
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_SCK, LOW);
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_CS, LOW);
|
||||
}
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_WRITE_BYTE:
|
||||
u8g_com_arduino_do_shift_out_msb_first( arg_val );
|
||||
//u8g_arduino_sw_spi_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK], arg_val);
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_WRITE_SEQ:
|
||||
{
|
||||
register uint8_t *ptr = arg_ptr;
|
||||
while( arg_val > 0 )
|
||||
{
|
||||
u8g_com_arduino_do_shift_out_msb_first(*ptr++);
|
||||
// u8g_arduino_sw_spi_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK], *ptr++);
|
||||
arg_val--;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_WRITE_SEQ_P:
|
||||
{
|
||||
register uint8_t *ptr = arg_ptr;
|
||||
while( arg_val > 0 )
|
||||
{
|
||||
u8g_com_arduino_do_shift_out_msb_first( u8g_pgm_read(ptr) );
|
||||
//u8g_arduino_sw_spi_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK], u8g_pgm_read(ptr));
|
||||
ptr++;
|
||||
arg_val--;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_ADDRESS: /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_A0, arg_val);
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
#else /* ARDUINO */
|
||||
|
||||
uint8_t u8g_com_arduino_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif /* ARDUINO */
|
||||
|
@ -0,0 +1,385 @@
|
||||
/*
|
||||
|
||||
u8g_com_arduino_t6963.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
PIN_D0 8
|
||||
PIN_D1 9
|
||||
PIN_D2 10
|
||||
PIN_D3 11
|
||||
PIN_D4 4
|
||||
PIN_D5 5
|
||||
PIN_D6 6
|
||||
PIN_D7 7
|
||||
|
||||
PIN_CS 14
|
||||
PIN_A0 15
|
||||
PIN_RESET 16
|
||||
PIN_WR 17
|
||||
PIN_RD 18
|
||||
|
||||
u8g_InitRW8Bit(u8g, dev, d0, d1, d2, d3, d4, d5, d6, d7, cs, a0, wr, rd, reset)
|
||||
u8g_InitRW8Bit(u8g, dev, 8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16)
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#if defined(ARDUINO)
|
||||
|
||||
#if ARDUINO < 100
|
||||
//#include <WProgram.h>
|
||||
#include <wiring_private.h>
|
||||
#include <pins_arduino.h>
|
||||
#else
|
||||
#include <Arduino.h>
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(__PIC32MX)
|
||||
/* CHIPKIT PIC32 */
|
||||
static volatile uint32_t *u8g_output_data_port[8];
|
||||
static volatile uint32_t *u8g_input_data_port[8];
|
||||
static volatile uint32_t *u8g_mode_port[8];
|
||||
static uint32_t u8g_data_mask[8];
|
||||
#else
|
||||
static volatile uint8_t *u8g_output_data_port[8];
|
||||
static volatile uint8_t *u8g_input_data_port[8];
|
||||
static volatile uint8_t *u8g_mode_port[8];
|
||||
static uint8_t u8g_data_mask[8];
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
static void u8g_com_arduino_t6963_init(u8g_t *u8g)
|
||||
{
|
||||
u8g_output_data_port[0] = portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D0]));
|
||||
u8g_input_data_port[0] = portInputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D0]));
|
||||
u8g_mode_port[0] = portModeRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D0]));
|
||||
u8g_data_mask[0] = digitalPinToBitMask(u8g->pin_list[U8G_PI_D0]);
|
||||
|
||||
u8g_output_data_port[1] = portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D1]));
|
||||
u8g_input_data_port[1] = portInputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D1]));
|
||||
u8g_mode_port[1] = portModeRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D1]));
|
||||
u8g_data_mask[1] = digitalPinToBitMask(u8g->pin_list[U8G_PI_D1]);
|
||||
|
||||
u8g_output_data_port[2] = portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D2]));
|
||||
u8g_input_data_port[2] = portInputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D2]));
|
||||
u8g_mode_port[2] = portModeRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D2]));
|
||||
u8g_data_mask[2] = digitalPinToBitMask(u8g->pin_list[U8G_PI_D2]);
|
||||
|
||||
u8g_output_data_port[3] = portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D3]));
|
||||
u8g_input_data_port[3] = portInputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D3]));
|
||||
u8g_mode_port[3] = portModeRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D3]));
|
||||
u8g_data_mask[3] = digitalPinToBitMask(u8g->pin_list[U8G_PI_D3]);
|
||||
|
||||
u8g_output_data_port[4] = portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D4]));
|
||||
u8g_input_data_port[4] = portInputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D4]));
|
||||
u8g_mode_port[4] = portModeRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D4]));
|
||||
u8g_data_mask[4] = digitalPinToBitMask(u8g->pin_list[U8G_PI_D4]);
|
||||
|
||||
u8g_output_data_port[5] = portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D5]));
|
||||
u8g_input_data_port[5] = portInputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D5]));
|
||||
u8g_mode_port[5] = portModeRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D5]));
|
||||
u8g_data_mask[5] = digitalPinToBitMask(u8g->pin_list[U8G_PI_D5]);
|
||||
|
||||
u8g_output_data_port[6] = portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D6]));
|
||||
u8g_input_data_port[6] = portInputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D6]));
|
||||
u8g_mode_port[6] = portModeRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D6]));
|
||||
u8g_data_mask[6] = digitalPinToBitMask(u8g->pin_list[U8G_PI_D6]);
|
||||
|
||||
u8g_output_data_port[7] = portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D7]));
|
||||
u8g_input_data_port[7] = portInputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D7]));
|
||||
u8g_mode_port[7] = portModeRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D7]));
|
||||
u8g_data_mask[7] = digitalPinToBitMask(u8g->pin_list[U8G_PI_D7]);
|
||||
}
|
||||
|
||||
static void u8g_com_arduino_t6963_write_data_pin(uint8_t pin, uint8_t val)
|
||||
{
|
||||
if ( val != 0 )
|
||||
*u8g_output_data_port[pin] |= u8g_data_mask[pin];
|
||||
else
|
||||
*u8g_output_data_port[pin] &= ~u8g_data_mask[pin];
|
||||
}
|
||||
|
||||
static void u8g_com_arduino_t6963_set_port_output(void)
|
||||
{
|
||||
uint8_t i;
|
||||
for( i = 0; i < 8; i++ )
|
||||
{
|
||||
#if defined(__PIC32MX)
|
||||
/* CHIPKIT PIC32 */
|
||||
*u8g_mode_port[i] |= u8g_data_mask[i];
|
||||
#elif defined(__AVR__)
|
||||
*u8g_mode_port[i] |= u8g_data_mask[i];
|
||||
#else
|
||||
/* TODO: use generic Arduino API */
|
||||
*u8g_mode_port[i] |= u8g_data_mask[i];
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static void u8g_com_arduino_t6963_set_port_input(void)
|
||||
{
|
||||
uint8_t i;
|
||||
for( i = 0; i < 8; i++ )
|
||||
{
|
||||
#if defined(__PIC32MX)
|
||||
/* CHIPKIT PIC32 */
|
||||
*u8g_mode_port[i] &= ~u8g_data_mask[i];
|
||||
#elif defined(__AVR__)
|
||||
/* avr */
|
||||
*u8g_mode_port[i] &= ~u8g_data_mask[i];
|
||||
*u8g_output_data_port[i] &= ~u8g_data_mask[i]; // no pullup
|
||||
#else
|
||||
/* TODO: use generic Arduino API */
|
||||
*u8g_mode_port[i] &= ~u8g_data_mask[i];
|
||||
*u8g_output_data_port[i] &= ~u8g_data_mask[i]; // no pullup
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void u8g_com_arduino_t6963_write(u8g_t *u8g, uint8_t val)
|
||||
{
|
||||
u8g_com_arduino_t6963_write_data_pin( 0, val&1 );
|
||||
val >>= 1;
|
||||
u8g_com_arduino_t6963_write_data_pin( 1, val&1 );
|
||||
val >>= 1;
|
||||
u8g_com_arduino_t6963_write_data_pin( 2, val&1 );
|
||||
val >>= 1;
|
||||
u8g_com_arduino_t6963_write_data_pin( 3, val&1 );
|
||||
val >>= 1;
|
||||
|
||||
u8g_com_arduino_t6963_write_data_pin( 4, val&1 );
|
||||
val >>= 1;
|
||||
u8g_com_arduino_t6963_write_data_pin( 5, val&1 );
|
||||
val >>= 1;
|
||||
u8g_com_arduino_t6963_write_data_pin( 6, val&1 );
|
||||
val >>= 1;
|
||||
u8g_com_arduino_t6963_write_data_pin( 7, val&1 );
|
||||
val >>= 1;
|
||||
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_WR, 0);
|
||||
u8g_MicroDelay(); /* 80ns, reference: t6963 datasheet */
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_WR, 1);
|
||||
u8g_MicroDelay(); /* 10ns, reference: t6963 datasheet */
|
||||
}
|
||||
|
||||
static uint8_t u8g_com_arduino_t6963_read(u8g_t *u8g)
|
||||
{
|
||||
uint8_t val = 0;
|
||||
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_RD, 0);
|
||||
u8g_MicroDelay(); /* 150ns, reference: t6963 datasheet */
|
||||
|
||||
/* only read bits 0, 1 and 3 */
|
||||
if ( (*u8g_input_data_port[3] & u8g_data_mask[3]) != 0 )
|
||||
val++;
|
||||
val <<= 1;
|
||||
val <<= 1;
|
||||
if ( (*u8g_input_data_port[1] & u8g_data_mask[1]) != 0 )
|
||||
val++;
|
||||
val <<= 1;
|
||||
if ( (*u8g_input_data_port[0] & u8g_data_mask[0]) != 0 )
|
||||
val++;
|
||||
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_RD, 1);
|
||||
u8g_MicroDelay(); /* 10ns, reference: t6963 datasheet */
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
#define U8G_STATUS_TIMEOUT 50
|
||||
|
||||
static uint8_t u8g_com_arduino_t6963_until_01_ok(u8g_t *u8g)
|
||||
{
|
||||
long x;
|
||||
|
||||
u8g_com_arduino_t6963_set_port_input();
|
||||
x = millis();
|
||||
x += U8G_STATUS_TIMEOUT;
|
||||
|
||||
for(;;)
|
||||
{
|
||||
if ( (u8g_com_arduino_t6963_read(u8g) & 3) == 3 )
|
||||
break;
|
||||
if ( x < millis() )
|
||||
return 0;
|
||||
}
|
||||
u8g_com_arduino_t6963_set_port_output();
|
||||
return 1;
|
||||
}
|
||||
|
||||
static uint8_t u8g_com_arduino_t6963_until_3_ok(u8g_t *u8g)
|
||||
{
|
||||
long x;
|
||||
|
||||
u8g_com_arduino_t6963_set_port_input();
|
||||
x = millis();
|
||||
x += U8G_STATUS_TIMEOUT;
|
||||
|
||||
for(;;)
|
||||
{
|
||||
if ( (u8g_com_arduino_t6963_read(u8g) & 8) == 8 )
|
||||
break;
|
||||
if ( x < millis() )
|
||||
return 0;
|
||||
}
|
||||
u8g_com_arduino_t6963_set_port_output();
|
||||
return 1;
|
||||
}
|
||||
|
||||
static uint8_t u8g_com_arduino_t6963_write_cmd(u8g_t *u8g, uint8_t val)
|
||||
{
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_A0, 1);
|
||||
if ( u8g_com_arduino_t6963_until_01_ok(u8g) == 0 )
|
||||
return 0;
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_A0, 1);
|
||||
u8g_com_arduino_t6963_write(u8g, val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static uint8_t u8g_com_arduino_t6963_write_data(u8g_t *u8g, uint8_t val)
|
||||
{
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_A0, 1);
|
||||
if ( u8g_com_arduino_t6963_until_01_ok(u8g) == 0 )
|
||||
return 0;
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_A0, 0);
|
||||
u8g_com_arduino_t6963_write(u8g, val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static uint8_t u8g_com_arduino_t6963_write_auto_data(u8g_t *u8g, uint8_t val)
|
||||
{
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_A0, 1);
|
||||
if ( u8g_com_arduino_t6963_until_3_ok(u8g) == 0 )
|
||||
return 0;
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_A0, 0);
|
||||
u8g_com_arduino_t6963_write(u8g, val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
uint8_t u8g_com_arduino_t6963_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_COM_MSG_INIT:
|
||||
u8g->pin_list[U8G_PI_A0_STATE] = 0;
|
||||
u8g_com_arduino_t6963_init(u8g);
|
||||
/* setup the RW (equal to WR) pin as output and force it to high */
|
||||
if ( u8g->pin_list[U8G_PI_WR] != U8G_PIN_NONE )
|
||||
{
|
||||
pinMode(u8g->pin_list[U8G_PI_WR], OUTPUT);
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_WR, HIGH);
|
||||
}
|
||||
/* set all pins (except WR pin) */
|
||||
u8g_com_arduino_assign_pin_output_high(u8g);
|
||||
break;
|
||||
case U8G_COM_MSG_STOP:
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_CHIP_SELECT:
|
||||
if ( arg_val == 0 )
|
||||
{
|
||||
/* disable, active low chip select */
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_CS, HIGH);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* enable */
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_CS, LOW);
|
||||
}
|
||||
break;
|
||||
case U8G_COM_MSG_WRITE_BYTE:
|
||||
if ( u8g->pin_list[U8G_PI_A0_STATE] == 0 )
|
||||
{
|
||||
u8g_com_arduino_t6963_write_data(u8g, arg_val);
|
||||
}
|
||||
else
|
||||
{
|
||||
u8g_com_arduino_t6963_write_cmd(u8g, arg_val);
|
||||
}
|
||||
break;
|
||||
case U8G_COM_MSG_WRITE_SEQ:
|
||||
{
|
||||
register uint8_t *ptr = arg_ptr;
|
||||
u8g_com_arduino_t6963_write_cmd(u8g, 0x0b0); /* auto write */
|
||||
while( arg_val > 0 )
|
||||
{
|
||||
if ( u8g_com_arduino_t6963_write_auto_data(u8g, *ptr++) == 0 )
|
||||
break;
|
||||
arg_val--;
|
||||
}
|
||||
u8g_com_arduino_t6963_write_cmd(u8g, 0x0b2); /* auto reset */
|
||||
}
|
||||
break;
|
||||
case U8G_COM_MSG_WRITE_SEQ_P:
|
||||
{
|
||||
register uint8_t *ptr = arg_ptr;
|
||||
u8g_com_arduino_t6963_write_cmd(u8g, 0x0b0); /* auto write */
|
||||
while( arg_val > 0 )
|
||||
{
|
||||
if ( u8g_com_arduino_t6963_write_auto_data(u8g, u8g_pgm_read(ptr)) == 0 )
|
||||
break;
|
||||
ptr++;
|
||||
arg_val--;
|
||||
}
|
||||
u8g_com_arduino_t6963_write_cmd(u8g, 0x0b2); /* auto reset */
|
||||
}
|
||||
break;
|
||||
case U8G_COM_MSG_ADDRESS: /* define cmd (arg_val = 1) or data mode (arg_val = 0) */
|
||||
u8g->pin_list[U8G_PI_A0_STATE] = arg_val;
|
||||
//u8g_com_arduino_digital_write(u8g, U8G_PI_DI, arg_val);
|
||||
break;
|
||||
case U8G_COM_MSG_RESET:
|
||||
if ( u8g->pin_list[U8G_PI_RESET] != U8G_PIN_NONE )
|
||||
u8g_com_arduino_digital_write(u8g, U8G_PI_RESET, arg_val);
|
||||
break;
|
||||
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
|
||||
uint8_t u8g_com_arduino_t6963_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
#endif /* ARDUINO */
|
||||
|
@ -0,0 +1,174 @@
|
||||
/*
|
||||
|
||||
u8g_com_atmega_hw_spi.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2012, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
Assumes, that
|
||||
MOSI is at PORTB, Pin 3
|
||||
and
|
||||
SCK is at PORTB, Pin 5
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
|
||||
#if defined(__AVR__)
|
||||
#define U8G_ATMEGA_HW_SPI
|
||||
|
||||
/* remove the definition for attiny */
|
||||
#if __AVR_ARCH__ == 2
|
||||
#undef U8G_ATMEGA_HW_SPI
|
||||
#endif
|
||||
#if __AVR_ARCH__ == 25
|
||||
#undef U8G_ATMEGA_HW_SPI
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(U8G_ATMEGA_HW_SPI)
|
||||
|
||||
#include <avr/interrupt.h>
|
||||
#include <avr/io.h>
|
||||
|
||||
|
||||
static uint8_t u8g_atmega_spi_out(uint8_t data)
|
||||
{
|
||||
/* unsigned char x = 100; */
|
||||
/* send data */
|
||||
SPDR = data;
|
||||
/* wait for transmission */
|
||||
while (!(SPSR & (1<<SPIF)))
|
||||
;
|
||||
/* clear the SPIF flag by reading SPDR */
|
||||
return SPDR;
|
||||
}
|
||||
|
||||
|
||||
uint8_t u8g_com_atmega_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_COM_MSG_STOP:
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_INIT:
|
||||
|
||||
u8g_SetPIOutput(u8g, U8G_PI_CS);
|
||||
u8g_SetPIOutput(u8g, U8G_PI_A0);
|
||||
|
||||
DDRB |= _BV(3); /* D0, MOSI */
|
||||
DDRB |= _BV(5); /* SCK */
|
||||
DDRB |= _BV(2); /* slave select */
|
||||
|
||||
PORTB &= ~_BV(3); /* D0, MOSI = 0 */
|
||||
PORTB &= ~_BV(5); /* SCK = 0 */
|
||||
u8g_SetPILevel(u8g, U8G_PI_CS, 1);
|
||||
|
||||
/*
|
||||
SPR1 SPR0
|
||||
0 0 fclk/4 x
|
||||
0 1 fclk/16
|
||||
1 0 fclk/64
|
||||
1 1 fclk/128
|
||||
*/
|
||||
SPCR = 0;
|
||||
SPCR = (1<<SPE) | (1<<MSTR)|(0<<SPR1)|(0<<SPR0)|(0<<CPOL)|(0<<CPHA);
|
||||
#ifdef U8G_HW_SPI_2X
|
||||
SPSR = (1 << SPI2X); /* double speed, issue 89 */
|
||||
#endif
|
||||
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_ADDRESS: /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
|
||||
u8g_SetPILevel(u8g, U8G_PI_A0, arg_val);
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_CHIP_SELECT:
|
||||
|
||||
if ( arg_val == 0 )
|
||||
{
|
||||
/* disable */
|
||||
u8g_SetPILevel(u8g, U8G_PI_CS, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
PORTB &= ~_BV(5); /* SCK = 0 */
|
||||
/* enable */
|
||||
u8g_SetPILevel(u8g, U8G_PI_CS, 0); /* CS = 0 (low active) */
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_RESET:
|
||||
u8g_SetPILevel(u8g, U8G_PI_RESET, arg_val);
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_WRITE_BYTE:
|
||||
u8g_atmega_spi_out(arg_val);
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_WRITE_SEQ:
|
||||
{
|
||||
register uint8_t *ptr = arg_ptr;
|
||||
while( arg_val > 0 )
|
||||
{
|
||||
u8g_atmega_spi_out(*ptr++);
|
||||
arg_val--;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case U8G_COM_MSG_WRITE_SEQ_P:
|
||||
{
|
||||
register uint8_t *ptr = arg_ptr;
|
||||
while( arg_val > 0 )
|
||||
{
|
||||
u8g_atmega_spi_out(u8g_pgm_read(ptr));
|
||||
ptr++;
|
||||
arg_val--;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
uint8_t u8g_com_atmega_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -0,0 +1,183 @@
|
||||
/*
|
||||
|
||||
u8g_atmega_parallel.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2012, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
PIN_D0 8
|
||||
PIN_D1 9
|
||||
PIN_D2 10
|
||||
PIN_D3 11
|
||||
PIN_D4 4
|
||||
PIN_D5 5
|
||||
PIN_D6 6
|
||||
PIN_D7 7
|
||||
|
||||
PIN_CS1 14
|
||||
PIN_CS2 15
|
||||
PIN_RW 16
|
||||
PIN_DI 17
|
||||
PIN_EN 18
|
||||
|
||||
u8g_Init8Bit(u8g, dev, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, cs2, di, rw, reset)
|
||||
u8g_Init8Bit(u8g, dev, 8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16, U8G_PIN_NONE)
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#if defined(__AVR__)
|
||||
|
||||
static void u8g_com_atmega_parallel_write(u8g_t *u8g, uint8_t val) U8G_NOINLINE;
|
||||
static void u8g_com_atmega_parallel_write(u8g_t *u8g, uint8_t val)
|
||||
{
|
||||
|
||||
u8g_SetPILevel(u8g, U8G_PI_D0, val&1);
|
||||
val >>= 1;
|
||||
u8g_SetPILevel(u8g, U8G_PI_D1, val&1);
|
||||
val >>= 1;
|
||||
u8g_SetPILevel(u8g, U8G_PI_D2, val&1);
|
||||
val >>= 1;
|
||||
u8g_SetPILevel(u8g, U8G_PI_D3, val&1);
|
||||
val >>= 1;
|
||||
u8g_SetPILevel(u8g, U8G_PI_D4, val&1);
|
||||
val >>= 1;
|
||||
u8g_SetPILevel(u8g, U8G_PI_D5, val&1);
|
||||
val >>= 1;
|
||||
u8g_SetPILevel(u8g, U8G_PI_D6, val&1);
|
||||
val >>= 1;
|
||||
u8g_SetPILevel(u8g, U8G_PI_D7, val&1);
|
||||
|
||||
/* EN cycle time must be 1 micro second */
|
||||
u8g_SetPILevel(u8g, U8G_PI_EN, 1);
|
||||
u8g_MicroDelay(); /* delay by 1000ns, reference: ST7920: 140ns, SBN1661: 100ns */
|
||||
u8g_SetPILevel(u8g, U8G_PI_EN, 0);
|
||||
u8g_10MicroDelay(); /* ST7920 commands: 72us */
|
||||
u8g_10MicroDelay(); /* ST7920 commands: 72us */
|
||||
}
|
||||
|
||||
|
||||
uint8_t u8g_com_atmega_parallel_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_COM_MSG_INIT:
|
||||
/* setup the RW pin as output and force it to low */
|
||||
u8g_SetPIOutput(u8g, U8G_PI_RW);
|
||||
u8g_SetPILevel(u8g, U8G_PI_RW, 0);
|
||||
|
||||
u8g_SetPIOutput(u8g, U8G_PI_D0);
|
||||
u8g_SetPIOutput(u8g, U8G_PI_D1);
|
||||
u8g_SetPIOutput(u8g, U8G_PI_D2);
|
||||
u8g_SetPIOutput(u8g, U8G_PI_D3);
|
||||
u8g_SetPIOutput(u8g, U8G_PI_D4);
|
||||
u8g_SetPIOutput(u8g, U8G_PI_D5);
|
||||
u8g_SetPIOutput(u8g, U8G_PI_D6);
|
||||
u8g_SetPIOutput(u8g, U8G_PI_D7);
|
||||
u8g_SetPIOutput(u8g, U8G_PI_EN);
|
||||
u8g_SetPIOutput(u8g, U8G_PI_CS1);
|
||||
u8g_SetPIOutput(u8g, U8G_PI_CS2);
|
||||
u8g_SetPIOutput(u8g, U8G_PI_DI);
|
||||
u8g_SetPILevel(u8g, U8G_PI_CS1, 1);
|
||||
u8g_SetPILevel(u8g, U8G_PI_CS2, 1);
|
||||
|
||||
break;
|
||||
case U8G_COM_MSG_STOP:
|
||||
break;
|
||||
case U8G_COM_MSG_CHIP_SELECT:
|
||||
if ( arg_val == 0 )
|
||||
{
|
||||
/* disable */
|
||||
u8g_SetPILevel(u8g, U8G_PI_CS1, 1);
|
||||
u8g_SetPILevel(u8g, U8G_PI_CS2, 1);
|
||||
}
|
||||
else if ( arg_val == 1 )
|
||||
{
|
||||
/* enable */
|
||||
u8g_SetPILevel(u8g, U8G_PI_CS1, 0);
|
||||
u8g_SetPILevel(u8g, U8G_PI_CS2, 1);
|
||||
}
|
||||
else if ( arg_val == 2 )
|
||||
{
|
||||
/* enable */
|
||||
u8g_SetPILevel(u8g, U8G_PI_CS1, 1);
|
||||
u8g_SetPILevel(u8g, U8G_PI_CS2, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* enable */
|
||||
u8g_SetPILevel(u8g, U8G_PI_CS1, 0);
|
||||
u8g_SetPILevel(u8g, U8G_PI_CS2, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_COM_MSG_WRITE_BYTE:
|
||||
u8g_com_atmega_parallel_write(u8g, arg_val);
|
||||
break;
|
||||
case U8G_COM_MSG_WRITE_SEQ:
|
||||
{
|
||||
register uint8_t *ptr = arg_ptr;
|
||||
while( arg_val > 0 )
|
||||
{
|
||||
u8g_com_atmega_parallel_write(u8g, *ptr++);
|
||||
arg_val--;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case U8G_COM_MSG_WRITE_SEQ_P:
|
||||
{
|
||||
register uint8_t *ptr = arg_ptr;
|
||||
while( arg_val > 0 )
|
||||
{
|
||||
u8g_com_atmega_parallel_write(u8g, u8g_pgm_read(ptr));
|
||||
ptr++;
|
||||
arg_val--;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case U8G_COM_MSG_ADDRESS: /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
|
||||
u8g_SetPILevel(u8g, U8G_PI_DI, arg_val);
|
||||
break;
|
||||
case U8G_COM_MSG_RESET:
|
||||
u8g_SetPILevel(u8g, U8G_PI_RESET, arg_val);
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
uint8_t u8g_com_atmega_parallel_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif /* ARDUINO */
|
||||
|
@ -0,0 +1,205 @@
|
||||
/*
|
||||
|
||||
u8g_com_atmega_st7920_hw_spi.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
A special SPI interface for ST7920 controller with HW SPI Support
|
||||
|
||||
Assumes, that
|
||||
MOSI is at PORTB, Pin 3
|
||||
and
|
||||
SCK is at PORTB, Pin 5
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#if defined(__AVR__)
|
||||
#define U8G_ATMEGA_HW_SPI
|
||||
|
||||
/* remove the definition for attiny */
|
||||
#if __AVR_ARCH__ == 2
|
||||
#undef U8G_ATMEGA_HW_SPI
|
||||
#endif
|
||||
#if __AVR_ARCH__ == 25
|
||||
#undef U8G_ATMEGA_HW_SPI
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(U8G_ATMEGA_HW_SPI)
|
||||
|
||||
#include <avr/interrupt.h>
|
||||
#include <avr/io.h>
|
||||
|
||||
static uint8_t u8g_atmega_st7920_hw_spi_shift_out(u8g_t *u8g, uint8_t val) U8G_NOINLINE;
|
||||
static uint8_t u8g_atmega_st7920_hw_spi_shift_out(u8g_t *u8g, uint8_t val)
|
||||
{
|
||||
/* send data */
|
||||
SPDR = val;
|
||||
/* wait for transmission */
|
||||
while (!(SPSR & (1<<SPIF)))
|
||||
;
|
||||
/* clear the SPIF flag by reading SPDR */
|
||||
return SPDR;
|
||||
}
|
||||
|
||||
|
||||
static void u8g_com_atmega_st7920_write_byte_hw_spi(u8g_t *u8g, uint8_t rs, uint8_t val) U8G_NOINLINE;
|
||||
static void u8g_com_atmega_st7920_write_byte_hw_spi(u8g_t *u8g, uint8_t rs, uint8_t val)
|
||||
{
|
||||
uint8_t i;
|
||||
|
||||
if ( rs == 0 )
|
||||
{
|
||||
/* command */
|
||||
u8g_atmega_st7920_hw_spi_shift_out(u8g, 0x0f8);
|
||||
}
|
||||
else if ( rs == 1 )
|
||||
{
|
||||
/* data */
|
||||
u8g_atmega_st7920_hw_spi_shift_out(u8g, 0x0fa);
|
||||
}
|
||||
|
||||
u8g_atmega_st7920_hw_spi_shift_out(u8g, val & 0x0f0);
|
||||
u8g_atmega_st7920_hw_spi_shift_out(u8g, val << 4);
|
||||
|
||||
for( i = 0; i < 4; i++ )
|
||||
u8g_10MicroDelay();
|
||||
}
|
||||
|
||||
|
||||
uint8_t u8g_com_atmega_st7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_COM_MSG_INIT:
|
||||
u8g_SetPIOutput(u8g, U8G_PI_CS);
|
||||
//u8g_SetPIOutput(u8g, U8G_PI_A0);
|
||||
|
||||
DDRB |= _BV(3); /* D0, MOSI */
|
||||
DDRB |= _BV(5); /* SCK */
|
||||
DDRB |= _BV(2); /* slave select */
|
||||
|
||||
PORTB &= ~_BV(3); /* D0, MOSI = 0 */
|
||||
PORTB &= ~_BV(5); /* SCK = 0 */
|
||||
u8g_SetPILevel(u8g, U8G_PI_CS, 1);
|
||||
|
||||
/*
|
||||
SPR1 SPR0
|
||||
0 0 fclk/4
|
||||
0 1 fclk/16
|
||||
1 0 fclk/64
|
||||
1 1 fclk/128
|
||||
*/
|
||||
SPCR = 0;
|
||||
|
||||
/* maybe set CPOL and CPHA to 1 */
|
||||
/* 20 Dez 2012: did set CPOL and CPHA to 1 in Arduino variant! */
|
||||
SPCR = (1<<SPE) | (1<<MSTR)|(0<<SPR1)|(0<<SPR0)|(0<<CPOL)|(0<<CPHA);
|
||||
#ifdef U8G_HW_SPI_2X
|
||||
SPSR = (1 << SPI2X); /* double speed, issue 89 */
|
||||
#endif
|
||||
u8g->pin_list[U8G_PI_A0_STATE] = 0; /* inital RS state: command mode */
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_STOP:
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_RESET:
|
||||
u8g_SetPILevel(u8g, U8G_PI_RESET, arg_val);
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_ADDRESS: /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
|
||||
u8g->pin_list[U8G_PI_A0_STATE] = arg_val;
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_CHIP_SELECT:
|
||||
if ( arg_val == 0 )
|
||||
{
|
||||
/* disable, note: the st7920 has an active high chip select */
|
||||
u8g_SetPILevel(u8g, U8G_PI_CS, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* u8g_SetPILevel(u8g, U8G_PI_SCK, 0 ); */
|
||||
/* enable */
|
||||
u8g_SetPILevel(u8g, U8G_PI_CS, 1); /* CS = 1 (high active) */
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case U8G_COM_MSG_WRITE_BYTE:
|
||||
u8g_com_atmega_st7920_write_byte_hw_spi(u8g, u8g->pin_list[U8G_PI_A0_STATE], arg_val);
|
||||
//u8g->pin_list[U8G_PI_A0_STATE] = 2;
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_WRITE_SEQ:
|
||||
{
|
||||
register uint8_t *ptr = arg_ptr;
|
||||
while( arg_val > 0 )
|
||||
{
|
||||
u8g_com_atmega_st7920_write_byte_hw_spi(u8g, u8g->pin_list[U8G_PI_A0_STATE], *ptr++);
|
||||
//u8g->pin_list[U8G_PI_A0_STATE] = 2;
|
||||
arg_val--;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_WRITE_SEQ_P:
|
||||
{
|
||||
register uint8_t *ptr = arg_ptr;
|
||||
while( arg_val > 0 )
|
||||
{
|
||||
u8g_com_atmega_st7920_write_byte_hw_spi(u8g, u8g->pin_list[U8G_PI_A0_STATE], u8g_pgm_read(ptr));
|
||||
//u8g->pin_list[U8G_PI_A0_STATE] = 2;
|
||||
ptr++;
|
||||
arg_val--;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
|
||||
uint8_t u8g_com_atmega_st7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -0,0 +1,170 @@
|
||||
/*
|
||||
|
||||
u8g_com_atmega_st7920_spi.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
A special SPI interface for ST7920 controller
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#if defined(__AVR__)
|
||||
|
||||
static void u8g_atmega_st7920_sw_spi_shift_out(u8g_t *u8g, uint8_t val) U8G_NOINLINE;
|
||||
static void u8g_atmega_st7920_sw_spi_shift_out(u8g_t *u8g, uint8_t val)
|
||||
{
|
||||
uint8_t i = 8;
|
||||
do
|
||||
{
|
||||
u8g_SetPILevel(u8g, U8G_PI_MOSI, val & 128 );
|
||||
val <<= 1;
|
||||
u8g_SetPILevel(u8g, U8G_PI_SCK, 1 );
|
||||
u8g_MicroDelay(); /* 15 Aug 2012: added for high speed uC */
|
||||
u8g_SetPILevel(u8g, U8G_PI_SCK, 0 );
|
||||
u8g_MicroDelay(); /* 15 Aug 2012: added for high speed uC */
|
||||
i--;
|
||||
} while( i != 0 );
|
||||
}
|
||||
|
||||
static void u8g_com_atmega_st7920_write_byte(u8g_t *u8g, uint8_t rs, uint8_t val) U8G_NOINLINE;
|
||||
static void u8g_com_atmega_st7920_write_byte(u8g_t *u8g, uint8_t rs, uint8_t val)
|
||||
{
|
||||
uint8_t i;
|
||||
|
||||
if ( rs == 0 )
|
||||
{
|
||||
/* command */
|
||||
u8g_atmega_st7920_sw_spi_shift_out(u8g, 0x0f8);
|
||||
}
|
||||
else if ( rs == 1 )
|
||||
{
|
||||
/* data */
|
||||
u8g_atmega_st7920_sw_spi_shift_out(u8g, 0x0fa);
|
||||
}
|
||||
|
||||
u8g_atmega_st7920_sw_spi_shift_out(u8g, val & 0x0f0);
|
||||
u8g_atmega_st7920_sw_spi_shift_out(u8g, val << 4);
|
||||
|
||||
for( i = 0; i < 4; i++ )
|
||||
u8g_10MicroDelay();
|
||||
}
|
||||
|
||||
|
||||
uint8_t u8g_com_atmega_st7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_COM_MSG_INIT:
|
||||
u8g_SetPIOutput(u8g, U8G_PI_SCK);
|
||||
u8g_SetPIOutput(u8g, U8G_PI_MOSI);
|
||||
/* u8g_SetPIOutput(u8g, U8G_PI_A0); */
|
||||
u8g_SetPIOutput(u8g, U8G_PI_CS);
|
||||
u8g_SetPIOutput(u8g, U8G_PI_RESET);
|
||||
|
||||
u8g_SetPILevel(u8g, U8G_PI_SCK, 0 );
|
||||
u8g_SetPILevel(u8g, U8G_PI_MOSI, 0 );
|
||||
u8g_SetPILevel(u8g, U8G_PI_CS, 0 );
|
||||
/* u8g_SetPILevel(u8g, U8G_PI_A0, 0); */
|
||||
|
||||
u8g->pin_list[U8G_PI_A0_STATE] = 0; /* inital RS state: command mode */
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_STOP:
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_RESET:
|
||||
u8g_SetPILevel(u8g, U8G_PI_RESET, arg_val);
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_ADDRESS: /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
|
||||
u8g->pin_list[U8G_PI_A0_STATE] = arg_val;
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_CHIP_SELECT:
|
||||
if ( arg_val == 0 )
|
||||
{
|
||||
/* disable, note: the st7920 has an active high chip select */
|
||||
u8g_SetPILevel(u8g, U8G_PI_CS, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* u8g_SetPILevel(u8g, U8G_PI_SCK, 0 ); */
|
||||
/* enable */
|
||||
u8g_SetPILevel(u8g, U8G_PI_CS, 1); /* CS = 1 (high active) */
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case U8G_COM_MSG_WRITE_BYTE:
|
||||
u8g_com_atmega_st7920_write_byte(u8g, u8g->pin_list[U8G_PI_A0_STATE], arg_val);
|
||||
u8g->pin_list[U8G_PI_A0_STATE] = 2;
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_WRITE_SEQ:
|
||||
{
|
||||
register uint8_t *ptr = arg_ptr;
|
||||
while( arg_val > 0 )
|
||||
{
|
||||
u8g_com_atmega_st7920_write_byte(u8g, u8g->pin_list[U8G_PI_A0_STATE], *ptr++);
|
||||
u8g->pin_list[U8G_PI_A0_STATE] = 2;
|
||||
arg_val--;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_WRITE_SEQ_P:
|
||||
{
|
||||
register uint8_t *ptr = arg_ptr;
|
||||
while( arg_val > 0 )
|
||||
{
|
||||
u8g_com_atmega_st7920_write_byte(u8g, u8g->pin_list[U8G_PI_A0_STATE], u8g_pgm_read(ptr));
|
||||
u8g->pin_list[U8G_PI_A0_STATE] = 2;
|
||||
ptr++;
|
||||
arg_val--;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
|
||||
uint8_t u8g_com_atmega_st7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -0,0 +1,141 @@
|
||||
/*
|
||||
|
||||
u8g_com_atmega_sw_spi.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2012, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#if defined(__AVR__)
|
||||
|
||||
static void u8g_atmega_sw_spi_shift_out(u8g_t *u8g, uint8_t val) U8G_NOINLINE;
|
||||
static void u8g_atmega_sw_spi_shift_out(u8g_t *u8g, uint8_t val)
|
||||
{
|
||||
uint8_t i = 8;
|
||||
do
|
||||
{
|
||||
u8g_SetPILevel(u8g, U8G_PI_MOSI, val & 128 );
|
||||
val <<= 1;
|
||||
u8g_SetPILevel(u8g, U8G_PI_SCK, 1 );
|
||||
u8g_MicroDelay(); /* 15 Aug 2012: added for high speed uC */
|
||||
u8g_SetPILevel(u8g, U8G_PI_SCK, 0 );
|
||||
u8g_MicroDelay(); /* 15 Aug 2012: added for high speed uC */
|
||||
i--;
|
||||
} while( i != 0 );
|
||||
}
|
||||
|
||||
uint8_t u8g_com_atmega_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_COM_MSG_INIT:
|
||||
u8g_SetPIOutput(u8g, U8G_PI_SCK);
|
||||
u8g_SetPIOutput(u8g, U8G_PI_MOSI);
|
||||
u8g_SetPIOutput(u8g, U8G_PI_A0);
|
||||
u8g_SetPIOutput(u8g, U8G_PI_CS);
|
||||
u8g_SetPIOutput(u8g, U8G_PI_RESET);
|
||||
|
||||
u8g_SetPILevel(u8g, U8G_PI_SCK, 0 );
|
||||
u8g_SetPILevel(u8g, U8G_PI_MOSI, 0 );
|
||||
u8g_SetPILevel(u8g, U8G_PI_CS, 1 );
|
||||
u8g_SetPILevel(u8g, U8G_PI_A0, 0);
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_STOP:
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_ADDRESS: /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
|
||||
u8g_SetPILevel(u8g, U8G_PI_A0, arg_val);
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_CHIP_SELECT:
|
||||
|
||||
if ( arg_val == 0 )
|
||||
{
|
||||
/* disable */
|
||||
u8g_SetPILevel(u8g, U8G_PI_CS, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
u8g_SetPILevel(u8g, U8G_PI_SCK, 0 );
|
||||
/* enable */
|
||||
u8g_SetPILevel(u8g, U8G_PI_CS, 0); /* CS = 0 (low active) */
|
||||
}
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_RESET:
|
||||
u8g_SetPILevel(u8g, U8G_PI_RESET, arg_val);
|
||||
break;
|
||||
|
||||
|
||||
case U8G_COM_MSG_WRITE_BYTE:
|
||||
u8g_atmega_sw_spi_shift_out(u8g, arg_val);
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_WRITE_SEQ:
|
||||
{
|
||||
register uint8_t *ptr = arg_ptr;
|
||||
while( arg_val > 0 )
|
||||
{
|
||||
u8g_atmega_sw_spi_shift_out(u8g, *ptr++);
|
||||
arg_val--;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_WRITE_SEQ_P:
|
||||
{
|
||||
register uint8_t *ptr = arg_ptr;
|
||||
while( arg_val > 0 )
|
||||
{
|
||||
u8g_atmega_sw_spi_shift_out(u8g, u8g_pgm_read(ptr));
|
||||
ptr++;
|
||||
arg_val--;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
|
||||
uint8_t u8g_com_atmega_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -0,0 +1,249 @@
|
||||
/*
|
||||
|
||||
u8g_com_i2c.c
|
||||
|
||||
generic i2c interface
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
static uint8_t u8g_i2c_err_code;
|
||||
|
||||
/*
|
||||
position values
|
||||
1: start condition
|
||||
2: sla transfer
|
||||
*/
|
||||
static uint8_t u8g_i2c_err_pos;
|
||||
|
||||
|
||||
void u8g_i2c_clear_error(void)
|
||||
{
|
||||
u8g_i2c_err_code = U8G_I2C_ERR_NONE;
|
||||
u8g_i2c_err_pos = 0;
|
||||
}
|
||||
|
||||
uint8_t u8g_i2c_get_error(void)
|
||||
{
|
||||
return u8g_i2c_err_code;
|
||||
}
|
||||
|
||||
uint8_t u8g_i2c_get_err_pos(void)
|
||||
{
|
||||
return u8g_i2c_err_pos;
|
||||
}
|
||||
|
||||
static void u8g_i2c_set_error(uint8_t code, uint8_t pos)
|
||||
{
|
||||
if ( u8g_i2c_err_code > 0 )
|
||||
return;
|
||||
u8g_i2c_err_code |= code;
|
||||
u8g_i2c_err_pos = pos;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if defined(__AVR__)
|
||||
#define U8G_ATMEGA_HW_TWI
|
||||
|
||||
/* remove the definition for attiny */
|
||||
#if __AVR_ARCH__ == 2
|
||||
#undef U8G_ATMEGA_HW_TWI
|
||||
#endif
|
||||
#if __AVR_ARCH__ == 25
|
||||
#undef U8G_ATMEGA_HW_TWI
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(U8G_ATMEGA_HW_TWI)
|
||||
|
||||
#include <avr/io.h>
|
||||
#include <util/twi.h>
|
||||
|
||||
|
||||
|
||||
void u8g_i2c_init(uint8_t options)
|
||||
{
|
||||
/*
|
||||
TWBR: bit rate register
|
||||
TWSR: status register (contains preselector bits)
|
||||
|
||||
prescalar
|
||||
0 1
|
||||
1 4
|
||||
2 16
|
||||
3 64
|
||||
|
||||
f = F_CPU/(16+2*TWBR*prescalar)
|
||||
|
||||
F_CPU = 16MHz
|
||||
TWBR = 152;
|
||||
TWSR = 0;
|
||||
--> 50KHz
|
||||
|
||||
TWBR = 72;
|
||||
TWSR = 0;
|
||||
--> 100KHz
|
||||
|
||||
F_CPU/(2*100000)-8 --> calculate TWBR value for 100KHz
|
||||
*/
|
||||
TWSR = 0;
|
||||
TWBR = F_CPU/(2*100000)-8;
|
||||
u8g_i2c_clear_error();
|
||||
}
|
||||
|
||||
uint8_t u8g_i2c_wait(uint8_t mask, uint8_t pos)
|
||||
{
|
||||
volatile uint16_t cnt = 2000; /* timout value should be > 280 for 50KHz Bus and 16 Mhz CPU, however the start condition might need longer */
|
||||
while( !(TWCR & mask) )
|
||||
{
|
||||
if ( cnt == 0 )
|
||||
{
|
||||
u8g_i2c_set_error(U8G_I2C_ERR_TIMEOUT, pos);
|
||||
return 0; /* error */
|
||||
}
|
||||
cnt--;
|
||||
}
|
||||
return 1; /* all ok */
|
||||
}
|
||||
|
||||
/* sla includes all 8 bits (with r/w bit), assums master transmit */
|
||||
uint8_t u8g_i2c_start(uint8_t sla)
|
||||
{
|
||||
register uint8_t status;
|
||||
|
||||
/* send start */
|
||||
TWCR = _BV(TWINT) | _BV(TWSTA) | _BV(TWEN);
|
||||
|
||||
/* wait */
|
||||
if ( u8g_i2c_wait(_BV(TWINT), 1) == 0 )
|
||||
return 0;
|
||||
|
||||
status = TW_STATUS;
|
||||
|
||||
/* check status after start */
|
||||
if ( status != TW_START && status != TW_REP_START )
|
||||
{
|
||||
u8g_i2c_set_error(U8G_I2C_ERR_BUS, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* set slave address */
|
||||
TWDR = sla;
|
||||
|
||||
/* enable sla transfer */
|
||||
TWCR = _BV(TWINT) | _BV(TWEN);
|
||||
|
||||
/* wait */
|
||||
if ( u8g_i2c_wait(_BV(TWINT), 2) == 0 )
|
||||
return 0;
|
||||
status = TW_STATUS;
|
||||
|
||||
/* check status after sla */
|
||||
if ( status != TW_MT_SLA_ACK )
|
||||
{
|
||||
u8g_i2c_set_error(U8G_I2C_ERR_BUS, 2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint8_t u8g_i2c_send_byte(uint8_t data)
|
||||
{
|
||||
register uint8_t status;
|
||||
TWDR = data;
|
||||
TWCR = _BV(TWINT) | _BV(TWEN);
|
||||
if ( u8g_i2c_wait(_BV(TWINT), 3) == 0 )
|
||||
return 0;
|
||||
status = TW_STATUS;
|
||||
|
||||
if ( status != TW_MT_DATA_ACK )
|
||||
{
|
||||
u8g_i2c_set_error(U8G_I2C_ERR_BUS, 3);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void u8g_i2c_stop(void)
|
||||
{
|
||||
/* write stop */
|
||||
TWCR = _BV(TWINT) | _BV(TWEN) | _BV(TWSTO);
|
||||
|
||||
/* no error is checked for the stop condition */
|
||||
u8g_i2c_wait(_BV(TWSTO), 4);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
void twi_send(uint8_t adr, uint8_t data1, uint8_t data2)
|
||||
{
|
||||
u8g_i2c_start(adr<<1);
|
||||
u8g_i2c_send_byte(data1);
|
||||
u8g_i2c_send_byte(data2);
|
||||
u8g_i2c_stop();
|
||||
}
|
||||
*/
|
||||
|
||||
#else
|
||||
|
||||
/* empty interface */
|
||||
|
||||
void u8g_i2c_init(uint8_t options)
|
||||
{
|
||||
u8g_i2c_clear_error();
|
||||
}
|
||||
|
||||
uint8_t u8g_i2c_wait(uint8_t mask, uint8_t pos)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint8_t u8g_i2c_start(uint8_t sla)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
uint8_t u8g_i2c_send_byte(uint8_t data)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void u8g_i2c_stop(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -0,0 +1,218 @@
|
||||
/*
|
||||
|
||||
u8g_com_io.c
|
||||
|
||||
abstraction layer for low level i/o
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2012, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#if defined(__AVR__)
|
||||
|
||||
#include <avr/interrupt.h>
|
||||
#include <avr/io.h>
|
||||
|
||||
typedef volatile uint8_t * IO_PTR;
|
||||
|
||||
/* create internal pin number */
|
||||
uint8_t u8g_Pin(uint8_t port, uint8_t bitpos)
|
||||
{
|
||||
port <<= 3;
|
||||
port += bitpos;
|
||||
return port;
|
||||
}
|
||||
|
||||
const IO_PTR u8g_avr_ddr_P[] PROGMEM = {
|
||||
#ifdef DDRA
|
||||
&DDRA,
|
||||
#else
|
||||
0,
|
||||
#endif
|
||||
&DDRB,
|
||||
#ifdef DDRC
|
||||
&DDRC,
|
||||
#ifdef DDRD
|
||||
&DDRD,
|
||||
#ifdef DDRE
|
||||
&DDRE,
|
||||
#ifdef DDRF
|
||||
&DDRF,
|
||||
#ifdef DDRG
|
||||
&DDRG,
|
||||
#ifdef DDRH
|
||||
&DDRH,
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
const IO_PTR u8g_avr_port_P[] PROGMEM = {
|
||||
#ifdef PORTA
|
||||
&PORTA,
|
||||
#else
|
||||
0,
|
||||
#endif
|
||||
&PORTB,
|
||||
#ifdef PORTC
|
||||
&PORTC,
|
||||
#ifdef PORTD
|
||||
&PORTD,
|
||||
#ifdef PORTE
|
||||
&PORTE,
|
||||
#ifdef PORTF
|
||||
&PORTF,
|
||||
#ifdef PORTG
|
||||
&PORTG,
|
||||
#ifdef PORTH
|
||||
&PORTH,
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
||||
const IO_PTR u8g_avr_pin_P[] PROGMEM = {
|
||||
#ifdef PINA
|
||||
&PINA,
|
||||
#else
|
||||
0,
|
||||
#endif
|
||||
&PINB,
|
||||
#ifdef PINC
|
||||
&PINC,
|
||||
#ifdef PIND
|
||||
&PIND,
|
||||
#ifdef PINE
|
||||
&PINE,
|
||||
#ifdef PINF
|
||||
&PINF,
|
||||
#ifdef PING
|
||||
&PING,
|
||||
#ifdef PINH
|
||||
&PINH,
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
||||
static volatile uint8_t *u8g_get_avr_io_ptr(const IO_PTR *base, uint8_t offset)
|
||||
{
|
||||
volatile uint8_t * tmp;
|
||||
base += offset;
|
||||
memcpy_P(&tmp, base, sizeof(volatile uint8_t * PROGMEM));
|
||||
return tmp;
|
||||
}
|
||||
|
||||
/* set direction to output of the specified pin (internal pin number) */
|
||||
void u8g_SetPinOutput(uint8_t internal_pin_number)
|
||||
{
|
||||
*u8g_get_avr_io_ptr(u8g_avr_ddr_P, internal_pin_number>>3) |= _BV(internal_pin_number&7);
|
||||
}
|
||||
|
||||
void u8g_SetPinInput(uint8_t internal_pin_number)
|
||||
{
|
||||
*u8g_get_avr_io_ptr(u8g_avr_ddr_P, internal_pin_number>>3) &= ~_BV(internal_pin_number&7);
|
||||
}
|
||||
|
||||
void u8g_SetPinLevel(uint8_t internal_pin_number, uint8_t level)
|
||||
{
|
||||
volatile uint8_t * tmp = u8g_get_avr_io_ptr(u8g_avr_port_P, internal_pin_number>>3);
|
||||
|
||||
if ( level == 0 )
|
||||
*tmp &= ~_BV(internal_pin_number&7);
|
||||
else
|
||||
*tmp |= _BV(internal_pin_number&7);
|
||||
}
|
||||
|
||||
uint8_t u8g_GetPinLevel(uint8_t internal_pin_number)
|
||||
{
|
||||
volatile uint8_t * tmp = u8g_get_avr_io_ptr(u8g_avr_pin_P, internal_pin_number>>3);
|
||||
if ( ((*tmp) & _BV(internal_pin_number&7)) != 0 )
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
uint8_t u8g_Pin(uint8_t port, uint8_t bitpos)
|
||||
{
|
||||
port <<= 3;
|
||||
port += bitpos;
|
||||
return port;
|
||||
}
|
||||
|
||||
void u8g_SetPinOutput(uint8_t internal_pin_number)
|
||||
{
|
||||
}
|
||||
|
||||
void u8g_SetPinInput(uint8_t internal_pin_number)
|
||||
{
|
||||
}
|
||||
|
||||
void u8g_SetPinLevel(uint8_t internal_pin_number, uint8_t level)
|
||||
{
|
||||
}
|
||||
|
||||
uint8_t u8g_GetPinLevel(uint8_t internal_pin_number)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
void u8g_SetPIOutput(u8g_t *u8g, uint8_t pi)
|
||||
{
|
||||
uint8_t pin;
|
||||
pin = u8g->pin_list[pi];
|
||||
if ( pin != U8G_PIN_NONE )
|
||||
u8g_SetPinOutput(pin);
|
||||
}
|
||||
|
||||
void u8g_SetPILevel(u8g_t *u8g, uint8_t pi, uint8_t level)
|
||||
{
|
||||
uint8_t pin;
|
||||
pin = u8g->pin_list[pi];
|
||||
if ( pin != U8G_PIN_NONE )
|
||||
u8g_SetPinLevel(pin, level);
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
/*
|
||||
|
||||
u8g_com_null.c
|
||||
|
||||
communication null device
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
uint8_t u8g_com_null_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_COM_MSG_INIT:
|
||||
break;
|
||||
case U8G_COM_MSG_STOP:
|
||||
break;
|
||||
|
||||
|
||||
case U8G_COM_MSG_CHIP_SELECT:
|
||||
/* arg_val contains the chip number, which should be enabled */
|
||||
break;
|
||||
|
||||
|
||||
case U8G_COM_MSG_WRITE_BYTE:
|
||||
break;
|
||||
case U8G_COM_MSG_WRITE_SEQ:
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
@ -0,0 +1,99 @@
|
||||
/*
|
||||
|
||||
u8g_cursor.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
void u8g_SetCursorFont(u8g_t *u8g, const u8g_pgm_uint8_t *cursor_font)
|
||||
{
|
||||
u8g->cursor_font = cursor_font;
|
||||
}
|
||||
|
||||
void u8g_SetCursorStyle(u8g_t *u8g, uint8_t encoding)
|
||||
{
|
||||
u8g->cursor_encoding = encoding;
|
||||
}
|
||||
|
||||
void u8g_SetCursorColor(u8g_t *u8g, uint8_t fg, uint8_t bg)
|
||||
{
|
||||
u8g->cursor_bg_color = bg;
|
||||
u8g->cursor_fg_color = fg;
|
||||
}
|
||||
|
||||
void u8g_SetCursorPos(u8g_t *u8g, u8g_uint_t cursor_x, u8g_uint_t cursor_y)
|
||||
{
|
||||
u8g->cursor_x = cursor_x;
|
||||
u8g->cursor_y = cursor_y;
|
||||
}
|
||||
|
||||
void u8g_EnableCursor(u8g_t *u8g)
|
||||
{
|
||||
u8g->cursor_fn = u8g_DrawCursor;
|
||||
}
|
||||
|
||||
void u8g_DisableCursor(u8g_t *u8g)
|
||||
{
|
||||
u8g->cursor_fn = (u8g_draw_cursor_fn)0;
|
||||
}
|
||||
|
||||
void u8g_DrawCursor(u8g_t *u8g)
|
||||
{
|
||||
const u8g_pgm_uint8_t *font;
|
||||
uint8_t color;
|
||||
uint8_t encoding = u8g->cursor_encoding;
|
||||
|
||||
/* get current values */
|
||||
color = u8g_GetColorIndex(u8g);
|
||||
font = u8g->font;
|
||||
|
||||
/* draw cursor */
|
||||
u8g->font = u8g->cursor_font;
|
||||
encoding++;
|
||||
u8g_SetColorIndex(u8g, u8g->cursor_bg_color);
|
||||
/* 27. Jan 2013: replaced call to u8g_DrawGlyph with call to u8g_draw_glyph */
|
||||
/* required, because y adjustment should not happen to the cursor fonts */
|
||||
u8g_draw_glyph(u8g, u8g->cursor_x, u8g->cursor_y, encoding);
|
||||
encoding--;
|
||||
u8g_SetColorIndex(u8g, u8g->cursor_fg_color);
|
||||
/* 27. Jan 2013: replaced call to u8g_DrawGlyph with call to u8g_draw_glyph */
|
||||
/* required, because y adjustment should not happen to the cursor fonts */
|
||||
/* u8g_DrawGlyph(u8g, u8g->cursor_x, u8g->cursor_y, encoding); */
|
||||
u8g_draw_glyph(u8g, u8g->cursor_x, u8g->cursor_y, encoding);
|
||||
|
||||
/* restore previous values */
|
||||
u8g->font = font;
|
||||
u8g_SetColorIndex(u8g, color);
|
||||
}
|
||||
|
@ -0,0 +1,215 @@
|
||||
/*
|
||||
|
||||
u8g_delay.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
/*==== Part 1: Derive suitable delay procedure ====*/
|
||||
|
||||
#if defined(ARDUINO)
|
||||
# if defined(__AVR__)
|
||||
# define USE_AVR_DELAY
|
||||
# elif defined(__PIC32MX)
|
||||
# define USE_PIC32_DELAY
|
||||
# elif defined(__arm__) /* Arduino Due */
|
||||
# define USE_ARDUINO_DELAY
|
||||
# else
|
||||
# define USE_ARDUINO_DELAY
|
||||
# endif
|
||||
#elif defined(__AVR__)
|
||||
# define USE_AVR_DELAY
|
||||
#elif defined(__18CXX)
|
||||
# define USE_PIC18_DELAY
|
||||
#else
|
||||
# define USE_DUMMY_DELAY
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/*==== Part 2: Definition of the delay procedures ====*/
|
||||
|
||||
/*== AVR Delay ==*/
|
||||
|
||||
#if defined(USE_AVR_DELAY)
|
||||
#include <avr/interrupt.h>
|
||||
#include <avr/io.h>
|
||||
#include <util/delay.h>
|
||||
|
||||
/*
|
||||
Delay by the provided number of milliseconds.
|
||||
Thus, a 16 bit value will allow a delay of 0..65 seconds
|
||||
Makes use of the _delay_loop_2
|
||||
|
||||
_delay_loop_2 will do a delay of n * 4 prozessor cycles.
|
||||
with f = F_CPU cycles per second,
|
||||
n = f / (1000 * 4 )
|
||||
with f = 16000000 the result is 4000
|
||||
with f = 1000000 the result is 250
|
||||
|
||||
the millisec loop, gcc requires the following overhead:
|
||||
- movev 1
|
||||
- subwi 2x2
|
||||
- bne i 2
|
||||
==> 7 cycles
|
||||
==> must be devided by 4, rounded up 7/4 = 2
|
||||
*/
|
||||
void u8g_Delay(uint16_t val)
|
||||
{
|
||||
/* old version did a call to the arduino lib: delay(val); */
|
||||
while( val != 0 )
|
||||
{
|
||||
_delay_loop_2( (F_CPU / 4000 ) -2);
|
||||
val--;
|
||||
}
|
||||
}
|
||||
|
||||
/* delay by one micro second */
|
||||
void u8g_MicroDelay(void)
|
||||
{
|
||||
#if (F_CPU / 4000000 ) > 0
|
||||
_delay_loop_2( (F_CPU / 4000000 ) );
|
||||
#endif
|
||||
}
|
||||
|
||||
/* delay by 10 micro seconds */
|
||||
void u8g_10MicroDelay(void)
|
||||
{
|
||||
#if (F_CPU / 400000 ) > 0
|
||||
_delay_loop_2( (F_CPU / 400000 ) );
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*== Delay for PIC18 (not tested) ==*/
|
||||
|
||||
#if defined(USE_PIC18_DELAY)
|
||||
#include <delays.h>
|
||||
#define GetSystemClock() (64000000ul) // Hz
|
||||
#define GetInstructionClock() (GetSystemClock()/4)
|
||||
|
||||
void u8g_Delay(uint16_t val)
|
||||
{/*
|
||||
unsigned int _iTemp = (val);
|
||||
while(_iTemp--)
|
||||
Delay1KTCYx((GetInstructionClock()+999999)/1000000);
|
||||
*/
|
||||
}
|
||||
void u8g_MicroDelay(void)
|
||||
{
|
||||
/* not implemented */
|
||||
}
|
||||
void u8g_10MicroDelay(void)
|
||||
{
|
||||
/* not implemented */
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*== Arduino Delay ==*/
|
||||
#if defined(USE_ARDUINO_DELAY)
|
||||
void u8g_Delay(uint16_t val)
|
||||
{
|
||||
delay(val);
|
||||
}
|
||||
void u8g_MicroDelay(void)
|
||||
{
|
||||
delayMicroseconds(1);
|
||||
}
|
||||
void u8g_10MicroDelay(void)
|
||||
{
|
||||
delayMicroseconds(10);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(USE_PIC32_DELAY)
|
||||
/*
|
||||
Assume chipkit here with F_CPU correctly defined
|
||||
The problem was, that u8g_Delay() is called within the constructor.
|
||||
It seems that the chipkit is not fully setup at this time, so a
|
||||
call to delay() will not work. So here is my own implementation.
|
||||
|
||||
*/
|
||||
#define CPU_COUNTS_PER_SECOND (F_CPU/2UL)
|
||||
#define TICKS_PER_MILLISECOND (CPU_COUNTS_PER_SECOND/1000UL)
|
||||
#include "plib.h"
|
||||
void u8g_Delay(uint16_t val)
|
||||
{
|
||||
uint32_t d;
|
||||
uint32_t s;
|
||||
d = val;
|
||||
d *= TICKS_PER_MILLISECOND;
|
||||
s = ReadCoreTimer();
|
||||
while ( (uint32_t)(ReadCoreTimer() - s) < d )
|
||||
;
|
||||
}
|
||||
|
||||
void u8g_MicroDelay(void)
|
||||
{
|
||||
uint32_t d;
|
||||
uint32_t s;
|
||||
d = TICKS_PER_MILLISECOND/1000;
|
||||
s = ReadCoreTimer();
|
||||
while ( (uint32_t)(ReadCoreTimer() - s) < d )
|
||||
;
|
||||
}
|
||||
|
||||
void u8g_10MicroDelay(void)
|
||||
{
|
||||
uint32_t d;
|
||||
uint32_t s;
|
||||
d = TICKS_PER_MILLISECOND/100;
|
||||
s = ReadCoreTimer();
|
||||
while ( (uint32_t)(ReadCoreTimer() - s) < d )
|
||||
;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*== Any other systems: Dummy Delay ==*/
|
||||
#if defined(USE_DUMMY_DELAY)
|
||||
void u8g_Delay(uint16_t val)
|
||||
{
|
||||
/* do not know how to delay... */
|
||||
}
|
||||
void u8g_MicroDelay(void)
|
||||
{
|
||||
}
|
||||
void u8g_10MicroDelay(void)
|
||||
{
|
||||
}
|
||||
#endif
|
@ -0,0 +1,92 @@
|
||||
/*
|
||||
|
||||
u8g_dev_flipdisc.c
|
||||
|
||||
1-Bit (BW) Driver for flip disc matrix
|
||||
2x 7 pixel height
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define WIDTH 28
|
||||
#define HEIGHT 14
|
||||
#define PAGE_HEIGHT 14
|
||||
|
||||
/*
|
||||
Write data to the flip disc matrix.
|
||||
This procedure must be implemented by the user.
|
||||
Arguments:
|
||||
id: Id for the matrix. Currently always 0.
|
||||
page: A page has a height of 14 pixel. For a matrix with HEIGHT == 14 this will be always 0
|
||||
width: The width of the flip disc matrix. Always equal to WIDTH
|
||||
row1: first data line (7 pixel per byte)
|
||||
row2: first data line (7 pixel per byte)
|
||||
*/
|
||||
void writeFlipDiscMatrix(uint8_t id, uint8_t page, uint8_t width, uint8_t *row1, uint8_t *row2);
|
||||
|
||||
|
||||
|
||||
void (*u8g_write_flip_disc_matrix)(uint8_t id, uint8_t page, uint8_t width, uint8_t *row1, uint8_t *row2);
|
||||
|
||||
void u8g_SetFlipDiscCallback(u8g_t *u8g, void (*cb)(uint8_t id, uint8_t page, uint8_t width, uint8_t *row1, uint8_t *row2))
|
||||
{
|
||||
u8g_write_flip_disc_matrix = cb;
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_flipdisc_2x7_bw_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
/* current page: pb->p.page */
|
||||
/* ptr to the buffer: pb->buf */
|
||||
|
||||
(*u8g_write_flip_disc_matrix)(0, pb->p.page, WIDTH, pb->buf, pb->buf+WIDTH);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb14v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_flipdisc_2x7_bw_buf[WIDTH*2] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_dev_flipdisc_2x7_bw_pb = { {16, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_flipdisc_2x7_bw_buf};
|
||||
u8g_dev_t u8g_dev_flipdisc_2x7 = { u8g_dev_flipdisc_2x7_bw_fn, &u8g_dev_flipdisc_2x7_bw_pb, u8g_com_null_fn };
|
@ -0,0 +1,130 @@
|
||||
/*
|
||||
|
||||
u8g_dev_gprof.c
|
||||
|
||||
Device for performance measurement with gprof.
|
||||
Does not write any data, but uses a buffer.
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
|
||||
#define WIDTH 128
|
||||
#define HEIGHT 64
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
uint8_t u8g_dev_gprof_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
|
||||
|
||||
uint8_t u8g_pb_dev_gprof_buf[WIDTH];
|
||||
u8g_pb_t u8g_pb_dev_gprof = { {PAGE_HEIGHT, HEIGHT, 0, 0, 0}, WIDTH, u8g_pb_dev_gprof_buf };
|
||||
|
||||
u8g_dev_t u8g_dev_gprof = { u8g_dev_gprof_fn, &u8g_pb_dev_gprof, NULL };
|
||||
|
||||
uint8_t u8g_dev_gprof_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_FIRST:
|
||||
u8g_pb_Clear(pb);
|
||||
u8g_page_First(&(pb->p));
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
/*
|
||||
{
|
||||
uint8_t i, j;
|
||||
uint8_t page_height;
|
||||
page_height = pb->p.page_y1;
|
||||
page_height -= pb->p.page_y0;
|
||||
page_height++;
|
||||
for( j = 0; j < page_height; j++ )
|
||||
{
|
||||
printf("%02d ", j);
|
||||
for( i = 0; i < WIDTH; i++ )
|
||||
{
|
||||
if ( (u8g_pb_dev_stdout_buf[i] & (1<<j)) != 0 )
|
||||
printf("#");
|
||||
else
|
||||
printf(".");
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
*/
|
||||
if ( u8g_page_Next(&(pb->p)) == 0 )
|
||||
{
|
||||
//printf("\n");
|
||||
return 0;
|
||||
}
|
||||
u8g_pb_Clear(pb);
|
||||
break;
|
||||
#ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
|
||||
case U8G_DEV_MSG_IS_BBX_INTERSECTION:
|
||||
{
|
||||
u8g_dev_arg_bbx_t *bbx = (u8g_dev_arg_bbx_t *)arg;
|
||||
u8g_uint_t x2, y2;
|
||||
|
||||
y2 = bbx->y;
|
||||
y2 += bbx->h;
|
||||
y2--;
|
||||
|
||||
if ( u8g_pb_IsYIntersection(pb, bbx->y, y2) == 0 )
|
||||
return 0;
|
||||
|
||||
/* maybe this one can be skiped... probability is very high to have an intersection, so it would be ok to always return 1 */
|
||||
x2 = bbx->x;
|
||||
x2 += bbx->w;
|
||||
x2--;
|
||||
|
||||
if ( u8g_pb_IsXIntersection(pb, bbx->x, x2) == 0 )
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
#endif
|
||||
case U8G_DEV_MSG_GET_PAGE_BOX:
|
||||
u8g_pb_GetPageBox(pb, (u8g_box_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_COLOR_INDEX:
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_XY_CB:
|
||||
break;
|
||||
}
|
||||
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
@ -0,0 +1,326 @@
|
||||
/*
|
||||
|
||||
u8g_dev_ili9325d_320x240.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
Color format
|
||||
Red: 5 Bit
|
||||
Green: 6 Bit
|
||||
Blue: 5 Bit
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define WIDTH 240
|
||||
|
||||
#if defined(U8G_16BIT)
|
||||
#define HEIGHT 320
|
||||
#else
|
||||
/* if the user tries to compile the 8Bit version of the lib, then restrict the height to something which fits to 8Bit */
|
||||
#define HEIGHT 240
|
||||
#endif
|
||||
#define PAGE_HEIGHT 4
|
||||
|
||||
|
||||
/*
|
||||
reference board for this device:
|
||||
http://iteadstudio.com/store/index.php?main_page=product_info&cPath=57_58&products_id=55
|
||||
documentation:
|
||||
http://iteadstudio.com/Downloadfile/ITDB02_material.rar
|
||||
datasheet
|
||||
http://www.newhavendisplay.com/app_notes/ILI9325D.pdf
|
||||
other libs
|
||||
http://henningkarlsen.com/electronics/library.php
|
||||
init sequence
|
||||
http://code.google.com/p/itdb02/, ITDB02.cpp, iteadstudio.com
|
||||
*/
|
||||
|
||||
static const uint8_t u8g_dev_ili9325d_320x240_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
U8G_ESC_RST(15), /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
U8G_ESC_RST(15), /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
|
||||
|
||||
//U8G_ESC_ADR(0), 0x000, 0x0E5, /* only used for none D version: set SRAM internal timing */
|
||||
//U8G_ESC_ADR(1), 0x078, 0x0f0,
|
||||
U8G_ESC_ADR(0), 0x000, 0x001, /* Driver Output Control, bits 8 & 10 */
|
||||
U8G_ESC_ADR(1), 0x001, 0x000,
|
||||
U8G_ESC_ADR(0), 0x000, 0x002, /* LCD Driving Wave Control, bit 9: Set line inversion */
|
||||
U8G_ESC_ADR(1), 0x002, 0x000, /* ITDB02 none D verion: 0x007, 0x000 */
|
||||
U8G_ESC_ADR(0), 0x000, 0x003, /* Entry Mode, GRAM write direction and BGR=1 */
|
||||
U8G_ESC_ADR(1), 0x010, 0x030,
|
||||
U8G_ESC_ADR(0), 0x000, 0x004, /* Resize register */
|
||||
U8G_ESC_ADR(1), 0x000, 0x000,
|
||||
U8G_ESC_ADR(0), 0x000, 0x008, /* Display Control 2: set the back porch and front porch */
|
||||
U8G_ESC_ADR(1), 0x002, 0x007,
|
||||
|
||||
U8G_ESC_ADR(0), 0x000, 0x009, /* Display Control 3 */
|
||||
U8G_ESC_ADR(1), 0x000, 0x000,
|
||||
|
||||
U8G_ESC_ADR(0), 0x000, 0x00a, /* Display Control 4: FMARK */
|
||||
U8G_ESC_ADR(1), 0x000, 0x000,
|
||||
U8G_ESC_ADR(0), 0x000, 0x00c, /* RGB Display Interface Control 1 */
|
||||
U8G_ESC_ADR(1), 0x000, 0x000,
|
||||
U8G_ESC_ADR(0), 0x000, 0x00d, /* Frame Maker Position */
|
||||
U8G_ESC_ADR(1), 0x000, 0x000,
|
||||
U8G_ESC_ADR(0), 0x000, 0x00f, /* RGB Display Interface Control 2 */
|
||||
U8G_ESC_ADR(1), 0x000, 0x000,
|
||||
U8G_ESC_ADR(0), 0x000, 0x010, /* Power Control 1: SAP, BT[3:0], AP, DSTB, SLP, STB */
|
||||
U8G_ESC_ADR(1), 0x000, 0x000,
|
||||
U8G_ESC_ADR(0), 0x000, 0x011, /* Power Control 2: DC1[2:0], DC0[2:0], VC[2:0] */
|
||||
U8G_ESC_ADR(1), 0x000, 0x007,
|
||||
U8G_ESC_ADR(0), 0x000, 0x012, /* Power Control 3: VREG1OUT voltage */
|
||||
U8G_ESC_ADR(1), 0x000, 0x000,
|
||||
U8G_ESC_ADR(0), 0x000, 0x013, /* Power Control 4: VDV[4:0] for VCOM amplitude */
|
||||
U8G_ESC_ADR(1), 0x000, 0x000,
|
||||
U8G_ESC_ADR(0), 0x000, 0x007, /* Display Control 1: Operate, but do not display */
|
||||
U8G_ESC_ADR(1), 0x000, 0x001,
|
||||
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */ /* ITDB02 none D verion: 50ms */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
|
||||
U8G_ESC_ADR(0), 0x000, 0x010, /* Power Control 1: SAP, BT[3:0], AP, DSTB, SLP, STB */
|
||||
U8G_ESC_ADR(1), 0x016, 0x090, /* ITDB02 none D verion: 0x010, 0x090 */
|
||||
U8G_ESC_ADR(0), 0x000, 0x011, /* Power Control 2: SAP, BT[3:0], AP, DSTB, SLP, STB */
|
||||
U8G_ESC_ADR(1), 0x002, 0x027,
|
||||
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
|
||||
U8G_ESC_ADR(0), 0x000, 0x012, /* Power Control 3: VCI: External, VCI*1.80 */
|
||||
U8G_ESC_ADR(1), 0x000, 0x00d, /* ITDB02 none D verion: 0x000, 0x01f */
|
||||
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
|
||||
U8G_ESC_ADR(0), 0x000, 0x013, /* Power Control 4: VDV[4:0] for VCOM amplitude */
|
||||
U8G_ESC_ADR(1), 0x012, 0x000, /* ITDB02 none D verion: 0x015, 0x000 */
|
||||
U8G_ESC_ADR(0), 0x000, 0x029, /* Power Control 7 */
|
||||
U8G_ESC_ADR(1), 0x000, 0x00a, /* ITDB02 none D verion: 0x000, 0x027 */
|
||||
U8G_ESC_ADR(0), 0x000, 0x02b, /* Frame Rate: 83 */
|
||||
U8G_ESC_ADR(1), 0x000, 0x00d,
|
||||
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
|
||||
U8G_ESC_ADR(0), 0x000, 0x020, /* Horizontal GRAM Address Set */
|
||||
U8G_ESC_ADR(1), 0x000, 0x000,
|
||||
U8G_ESC_ADR(0), 0x000, 0x021, /* Vertical GRAM Address Set */
|
||||
U8G_ESC_ADR(1), 0x000, 0x000,
|
||||
|
||||
/* gamma control */
|
||||
U8G_ESC_ADR(0), 0x000, 0x030,
|
||||
U8G_ESC_ADR(1), 0x000, 0x000,
|
||||
U8G_ESC_ADR(0), 0x000, 0x031,
|
||||
U8G_ESC_ADR(1), 0x004, 0x004,
|
||||
U8G_ESC_ADR(0), 0x000, 0x032,
|
||||
U8G_ESC_ADR(1), 0x000, 0x003,
|
||||
U8G_ESC_ADR(0), 0x000, 0x035,
|
||||
U8G_ESC_ADR(1), 0x004, 0x005,
|
||||
U8G_ESC_ADR(0), 0x000, 0x036,
|
||||
U8G_ESC_ADR(1), 0x008, 0x008,
|
||||
U8G_ESC_ADR(0), 0x000, 0x037,
|
||||
U8G_ESC_ADR(1), 0x004, 0x007,
|
||||
U8G_ESC_ADR(0), 0x000, 0x038,
|
||||
U8G_ESC_ADR(1), 0x003, 0x003,
|
||||
U8G_ESC_ADR(0), 0x000, 0x039,
|
||||
U8G_ESC_ADR(1), 0x007, 0x007,
|
||||
U8G_ESC_ADR(0), 0x000, 0x03c,
|
||||
U8G_ESC_ADR(1), 0x005, 0x004,
|
||||
U8G_ESC_ADR(0), 0x000, 0x03d,
|
||||
U8G_ESC_ADR(1), 0x008, 0x008,
|
||||
|
||||
U8G_ESC_ADR(0), 0x000, 0x050, /* Horizontal GRAM Start Address */
|
||||
U8G_ESC_ADR(1), 0x000, 0x000,
|
||||
U8G_ESC_ADR(0), 0x000, 0x051, /* Horizontal GRAM End Address: 239 */
|
||||
U8G_ESC_ADR(1), 0x000, 0x0EF,
|
||||
U8G_ESC_ADR(0), 0x000, 0x052, /* Vertical GRAM Start Address */
|
||||
U8G_ESC_ADR(1), 0x000, 0x000,
|
||||
U8G_ESC_ADR(0), 0x000, 0x053, /* Vertical GRAM End Address: 319 */
|
||||
U8G_ESC_ADR(1), 0x001, 0x03F,
|
||||
|
||||
U8G_ESC_ADR(0), 0x000, 0x060, /* Driver Output Control 2 */
|
||||
U8G_ESC_ADR(1), 0x0a7, 0x000,
|
||||
U8G_ESC_ADR(0), 0x000, 0x061, /* Base Image Display Control: NDL,VLE, REV */
|
||||
U8G_ESC_ADR(1), 0x000, 0x001,
|
||||
U8G_ESC_ADR(0), 0x000, 0x06a, /* Vertical Scroll Control */
|
||||
U8G_ESC_ADR(1), 0x000, 0x000,
|
||||
|
||||
U8G_ESC_ADR(0), 0x000, 0x080, /* Partial Image 1 Display Position */
|
||||
U8G_ESC_ADR(1), 0x000, 0x000,
|
||||
U8G_ESC_ADR(0), 0x000, 0x081, /* Partial Image 1 RAM Start Address */
|
||||
U8G_ESC_ADR(1), 0x000, 0x000,
|
||||
U8G_ESC_ADR(0), 0x000, 0x082, /* Partial Image 1 RAM End Address */
|
||||
U8G_ESC_ADR(1), 0x000, 0x000,
|
||||
U8G_ESC_ADR(0), 0x000, 0x083, /* Partial Image 2 Display Position */
|
||||
U8G_ESC_ADR(1), 0x000, 0x000,
|
||||
U8G_ESC_ADR(0), 0x000, 0x084, /* Partial Image 2 RAM Start Address */
|
||||
U8G_ESC_ADR(1), 0x000, 0x000,
|
||||
U8G_ESC_ADR(0), 0x000, 0x085, /* Partial Image 2 RAM End Address */
|
||||
U8G_ESC_ADR(1), 0x000, 0x000,
|
||||
|
||||
U8G_ESC_ADR(0), 0x000, 0x090, /* Panel Interface Control 1 */
|
||||
U8G_ESC_ADR(1), 0x000, 0x010,
|
||||
U8G_ESC_ADR(0), 0x000, 0x092, /* Panel Interface Control 2 */
|
||||
U8G_ESC_ADR(1), 0x000, 0x000, /* 0x006, 0x000 */
|
||||
|
||||
U8G_ESC_ADR(0), 0x000, 0x007, /* Display Control 1: Operate, display ON */
|
||||
U8G_ESC_ADR(1), 0x001, 0x033,
|
||||
|
||||
U8G_ESC_DLY(10), /* delay 10 ms */
|
||||
|
||||
/* write test pattern */
|
||||
U8G_ESC_ADR(0), 0x000, 0x020, /* Horizontal GRAM Address Set */
|
||||
U8G_ESC_ADR(1), 0x000, 0x000,
|
||||
U8G_ESC_ADR(0), 0x000, 0x021, /* Vertical GRAM Address Set */
|
||||
U8G_ESC_ADR(1), 0x000, 0x010,
|
||||
U8G_ESC_ADR(0), 0x000, 0x022, /* Write Data to GRAM */
|
||||
U8G_ESC_ADR(1), 0x0fe, 0x0fe,
|
||||
0x000, 0x000,
|
||||
0x0fe, 0x0fe,
|
||||
0x000, 0x000,
|
||||
0x0fe, 0x0fe,
|
||||
0x000, 0x000,
|
||||
0x0fe, 0x0fe,
|
||||
0x000, 0x000,
|
||||
0x0fe, 0x0fe,
|
||||
0x000, 0x000,
|
||||
0x0fe, 0x0fe,
|
||||
0x000, 0x000,
|
||||
0x0fe, 0x0fe,
|
||||
0x000, 0x000,
|
||||
0x0fe, 0x0fe,
|
||||
0x000, 0x000,
|
||||
0x0fe, 0x0fe,
|
||||
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static const uint8_t u8g_dev_ili9325d_320x240_page_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
U8G_ESC_ADR(0), 0x000, 0x020, /* Horizontal GRAM Address Set */
|
||||
U8G_ESC_ADR(1), 0x000, 0x000,
|
||||
U8G_ESC_ADR(0), 0x000, 0x021, /* Vertical GRAM Address Set */
|
||||
U8G_ESC_ADR(1),
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
/* convert the internal RGB 332 to 65K high byte */
|
||||
static uint8_t u8g_dev_ili9325d_get_65K_high_byte(uint8_t color)
|
||||
{
|
||||
uint8_t h;
|
||||
h = color;
|
||||
h &= 0x0e0;
|
||||
h |= h>>3;
|
||||
h &= 0x0f8;
|
||||
color>>=2;
|
||||
color &= 7;
|
||||
h |= color;
|
||||
return h;
|
||||
}
|
||||
|
||||
/* convert the internal RGB 332 to 65K high byte */
|
||||
static uint8_t u8g_dev_ili9325d_get_65K_low_byte(uint8_t color)
|
||||
{
|
||||
uint8_t l;
|
||||
l = color;
|
||||
l <<= 3;
|
||||
color &= 3;
|
||||
color <<= 1;
|
||||
l |= color;
|
||||
return l;
|
||||
}
|
||||
|
||||
|
||||
uint8_t u8g_dev_ili9325d_320x240_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev);
|
||||
//for(;;)
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ili9325d_320x240_init_seq);
|
||||
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
uint8_t i;
|
||||
uint16_t y, j;
|
||||
uint8_t *ptr;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
y = pb->p.page_y0;
|
||||
ptr = pb->buf;
|
||||
for( i = 0; i < pb->p.page_height; i ++ )
|
||||
{
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ili9325d_320x240_page_seq);
|
||||
u8g_WriteByte(u8g, dev, y >> 8 ); /* display ram (cursor) address high byte */
|
||||
u8g_WriteByte(u8g, dev, y & 255 ); /* display ram (cursor) address low byte */
|
||||
|
||||
u8g_SetAddress(u8g, dev, 0); /* cmd mode */
|
||||
u8g_WriteByte(u8g, dev, 0 );
|
||||
u8g_WriteByte(u8g, dev, 0x022 ); /* start gram data */
|
||||
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
|
||||
for( j = 0; j < pb->width; j++ )
|
||||
{
|
||||
u8g_WriteByte(u8g, dev, u8g_dev_ili9325d_get_65K_high_byte(*ptr) );
|
||||
u8g_WriteByte(u8g, dev, u8g_dev_ili9325d_get_65K_low_byte(*ptr) );
|
||||
|
||||
ptr++;
|
||||
}
|
||||
y++;
|
||||
}
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return u8g_dev_pb8h8_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
uint8_t u8g_ili9325d_320x240_8h8_buf[WIDTH*PAGE_HEIGHT] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_ili9325d_320x240_8h8_pb U8G_NOCOMMON = { {PAGE_HEIGHT, HEIGHT, 0, 0, 0}, WIDTH, u8g_ili9325d_320x240_8h8_buf};
|
||||
u8g_dev_t u8g_dev_ili9325d_320x240_8bit U8G_NOCOMMON = { u8g_dev_ili9325d_320x240_fn, &u8g_ili9325d_320x240_8h8_pb, u8g_com_arduino_port_d_wr_fn };
|
||||
//u8g_dev_t u8g_dev_ili9325d_320x240_8bit = { u8g_dev_ili9325d_320x240_fn, &u8g_ili9325d_320x240_8h8_pb, u8g_com_arduino_parallel_fn };
|
||||
|
||||
//U8G_PB_DEV(u8g_dev_ili9325d_320x240_8bit, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ili9325d_320x240_fn, U8G_COM_PARALLEL);
|
||||
|
||||
|
@ -0,0 +1,110 @@
|
||||
/*
|
||||
|
||||
u8g_dev_ks0108_128x64.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
ADDRESS = 0 (Command Mode)
|
||||
0x03f Display On
|
||||
0x0c0 Start Display at line 0
|
||||
0x040 | y write to y address (y:0..63)
|
||||
0x0b8 | x write to page [0..7]
|
||||
|
||||
|
||||
u8g_Init8Bit(u8g, dev, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, cs2, di, rw, reset)
|
||||
u8g_Init8Bit(u8g, dev, 8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16, U8G_PIN_NONE)
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define WIDTH 128
|
||||
#define HEIGHT 64
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
static const uint8_t u8g_dev_ks0108_128x64_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip 1 */
|
||||
0x03f, /* display on */
|
||||
0x0c0, /* start at line 0 */
|
||||
U8G_ESC_DLY(20), /* delay 20 ms */
|
||||
U8G_ESC_CS(2), /* enable chip 2 */
|
||||
0x03f, /* display on */
|
||||
0x0c0, /* start at line 0 */
|
||||
U8G_ESC_DLY(20), /* delay 20 ms */
|
||||
U8G_ESC_CS(0), /* disable all chips */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
uint8_t u8g_dev_ks0108_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ks0108_128x64_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
u8g_SetAddress(u8g, dev, 0); /* command mode */
|
||||
u8g_SetChipSelect(u8g, dev, 2);
|
||||
u8g_WriteByte(u8g, dev, 0x0b8 | pb->p.page); /* select current page (KS0108b) */
|
||||
u8g_WriteByte(u8g, dev, 0x040 ); /* set address 0 */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, 64, pb->buf);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
|
||||
u8g_SetAddress(u8g, dev, 0); /* command mode */
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_WriteByte(u8g, dev, 0x0b8 | pb->p.page); /* select current page (KS0108b) */
|
||||
u8g_WriteByte(u8g, dev, 0x040 ); /* set address 0 */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, 64, 64+(uint8_t *)pb->buf);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
U8G_PB_DEV(u8g_dev_ks0108_128x64, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ks0108_128x64_fn, U8G_COM_PARALLEL);
|
||||
U8G_PB_DEV(u8g_dev_ks0108_128x64_fast, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ks0108_128x64_fn, U8G_COM_FAST_PARALLEL);
|
||||
|
||||
|
@ -0,0 +1,147 @@
|
||||
/*
|
||||
|
||||
u8g_dev_lc7981_160x80.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define WIDTH 160
|
||||
#define HEIGHT 80
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
|
||||
/*
|
||||
code ideas:
|
||||
https://github.com/vsergeev/embedded-drivers/tree/master/avr-lc7981
|
||||
data sheets:
|
||||
http://www.lcd-module.de/eng/pdf/zubehoer/lc7981.pdf
|
||||
http://www.lcd-module.de/pdf/grafik/w160-6.pdf
|
||||
*/
|
||||
|
||||
static const uint8_t u8g_dev_lc7981_160x80_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
U8G_ESC_RST(15), /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x000, /* mode register */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x032, /* display on (bit 5), master mode on (bit 4), graphics mode on (bit 1)*/
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x001, /* character/bits per pixel pitch */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x007, /* 8 bits per pixel */
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x002, /* number of chars/byte width of the screen */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
WIDTH/8-1, /* 8 bits per pixel */
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x003, /* time division */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x07f, /* */
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x008, /* display start low */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x000, /* */
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x009, /* display start high */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x000, /* */
|
||||
|
||||
U8G_ESC_DLY(10), /* delay 10 ms */
|
||||
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_lc7981_160x80_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_lc7981_160x80_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
uint8_t y, i;
|
||||
uint16_t disp_ram_adr;
|
||||
uint8_t *ptr;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
u8g_SetAddress(u8g, dev, 1); /* cmd mode */
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
y = pb->p.page_y0;
|
||||
ptr = pb->buf;
|
||||
disp_ram_adr = WIDTH/8;
|
||||
disp_ram_adr *= y;
|
||||
for( i = 0; i < 8; i ++ )
|
||||
{
|
||||
u8g_SetAddress(u8g, dev, 1); /* cmd mode */
|
||||
u8g_WriteByte(u8g, dev, 0x00a ); /* display ram (cursor) address low byte */
|
||||
u8g_SetAddress(u8g, dev, 0); /* data mode */
|
||||
u8g_WriteByte(u8g, dev, disp_ram_adr & 0x0ff );
|
||||
|
||||
u8g_SetAddress(u8g, dev, 1); /* cmd mode */
|
||||
u8g_WriteByte(u8g, dev, 0x00b ); /* display ram (cursor) address hight byte */
|
||||
u8g_SetAddress(u8g, dev, 0); /* data mode */
|
||||
u8g_WriteByte(u8g, dev, disp_ram_adr >> 8 );
|
||||
|
||||
u8g_SetAddress(u8g, dev, 1); /* cmd mode */
|
||||
u8g_WriteByte(u8g, dev, 0x00c ); /* write data */
|
||||
u8g_SetAddress(u8g, dev, 0); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, WIDTH/8, ptr);
|
||||
ptr += WIDTH/8;
|
||||
disp_ram_adr += WIDTH/8;
|
||||
}
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return u8g_dev_pb8h1f_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
U8G_PB_DEV(u8g_dev_lc7981_160x80_8bit, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_lc7981_160x80_fn, U8G_COM_FAST_PARALLEL);
|
||||
|
||||
|
@ -0,0 +1,145 @@
|
||||
/*
|
||||
|
||||
u8g_dev_lc7981_240x128.c
|
||||
|
||||
Hitachi Display SP14N002
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2012, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define WIDTH 240
|
||||
#define HEIGHT 128
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
|
||||
/*
|
||||
http://www.mark-products.com/graphics.htm#240x128%20Pixel%20Format
|
||||
*/
|
||||
|
||||
static const uint8_t u8g_dev_lc7981_240x128_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
U8G_ESC_RST(15), /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x000, /* mode register */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x032, /* display on (bit 5), master mode on (bit 4), graphics mode on (bit 1)*/
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x001, /* character/bits per pixel pitch */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x007, /* 8 bits per pixel */
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x002, /* number of chars/byte width of the screen */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
WIDTH/8-1, /* 8 bits per pixel */
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x003, /* time division */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x07f, /* */
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x008, /* display start low */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x000, /* */
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x009, /* display start high */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x000, /* */
|
||||
|
||||
U8G_ESC_DLY(10), /* delay 10 ms */
|
||||
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_lc7981_240x128_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_lc7981_240x128_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
uint8_t y, i;
|
||||
uint16_t disp_ram_adr;
|
||||
uint8_t *ptr;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
u8g_SetAddress(u8g, dev, 1); /* cmd mode */
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
y = pb->p.page_y0;
|
||||
ptr = pb->buf;
|
||||
disp_ram_adr = WIDTH/8;
|
||||
disp_ram_adr *= y;
|
||||
for( i = 0; i < 8; i ++ )
|
||||
{
|
||||
u8g_SetAddress(u8g, dev, 1); /* cmd mode */
|
||||
u8g_WriteByte(u8g, dev, 0x00a ); /* display ram (cursor) address low byte */
|
||||
u8g_SetAddress(u8g, dev, 0); /* data mode */
|
||||
u8g_WriteByte(u8g, dev, disp_ram_adr & 0x0ff );
|
||||
|
||||
u8g_SetAddress(u8g, dev, 1); /* cmd mode */
|
||||
u8g_WriteByte(u8g, dev, 0x00b ); /* display ram (cursor) address hight byte */
|
||||
u8g_SetAddress(u8g, dev, 0); /* data mode */
|
||||
u8g_WriteByte(u8g, dev, disp_ram_adr >> 8 );
|
||||
|
||||
u8g_SetAddress(u8g, dev, 1); /* cmd mode */
|
||||
u8g_WriteByte(u8g, dev, 0x00c ); /* write data */
|
||||
u8g_SetAddress(u8g, dev, 0); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, WIDTH/8, ptr);
|
||||
ptr += WIDTH/8;
|
||||
disp_ram_adr += WIDTH/8;
|
||||
}
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return u8g_dev_pb8h1f_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
U8G_PB_DEV(u8g_dev_lc7981_240x128_8bit, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_lc7981_240x128_fn, U8G_COM_FAST_PARALLEL);
|
||||
|
||||
|
@ -0,0 +1,145 @@
|
||||
/*
|
||||
|
||||
u8g_dev_lc7981_240x64.c
|
||||
|
||||
Tested with Nan Ya LM_J6_003_
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2012, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define WIDTH 240
|
||||
#define HEIGHT 64
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
|
||||
/*
|
||||
http://www.mark-products.com/graphics.htm#240x64%20Pixel%20Format
|
||||
*/
|
||||
|
||||
static const uint8_t u8g_dev_lc7981_240x64_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
U8G_ESC_RST(15), /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x000, /* mode register */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x032, /* display on (bit 5), master mode on (bit 4), graphics mode on (bit 1)*/
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x001, /* character/bits per pixel pitch */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x007, /* 8 bits per pixel */
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x002, /* number of chars/byte width of the screen */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
WIDTH/8-1, /* 8 bits per pixel */
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x003, /* time division */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x07f, /* */
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x008, /* display start low */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x000, /* */
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x009, /* display start high */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x000, /* */
|
||||
|
||||
U8G_ESC_DLY(10), /* delay 10 ms */
|
||||
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_lc7981_240x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_lc7981_240x64_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
uint8_t y, i;
|
||||
uint16_t disp_ram_adr;
|
||||
uint8_t *ptr;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
u8g_SetAddress(u8g, dev, 1); /* cmd mode */
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
y = pb->p.page_y0;
|
||||
ptr = pb->buf;
|
||||
disp_ram_adr = WIDTH/8;
|
||||
disp_ram_adr *= y;
|
||||
for( i = 0; i < 8; i ++ )
|
||||
{
|
||||
u8g_SetAddress(u8g, dev, 1); /* cmd mode */
|
||||
u8g_WriteByte(u8g, dev, 0x00a ); /* display ram (cursor) address low byte */
|
||||
u8g_SetAddress(u8g, dev, 0); /* data mode */
|
||||
u8g_WriteByte(u8g, dev, disp_ram_adr & 0x0ff );
|
||||
|
||||
u8g_SetAddress(u8g, dev, 1); /* cmd mode */
|
||||
u8g_WriteByte(u8g, dev, 0x00b ); /* display ram (cursor) address hight byte */
|
||||
u8g_SetAddress(u8g, dev, 0); /* data mode */
|
||||
u8g_WriteByte(u8g, dev, disp_ram_adr >> 8 );
|
||||
|
||||
u8g_SetAddress(u8g, dev, 1); /* cmd mode */
|
||||
u8g_WriteByte(u8g, dev, 0x00c ); /* write data */
|
||||
u8g_SetAddress(u8g, dev, 0); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, WIDTH/8, ptr);
|
||||
ptr += WIDTH/8;
|
||||
disp_ram_adr += WIDTH/8;
|
||||
}
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return u8g_dev_pb8h1f_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
U8G_PB_DEV(u8g_dev_lc7981_240x64_8bit, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_lc7981_240x64_fn, U8G_COM_FAST_PARALLEL);
|
||||
|
||||
|
@ -0,0 +1,145 @@
|
||||
/*
|
||||
|
||||
u8g_dev_lc7981_320x64.c
|
||||
|
||||
Note: Requires 16 bit mode (Must be enabled in u8g.h)
|
||||
|
||||
Tested with Varitronix MGLS32064-03.pdf
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2012, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define WIDTH 320
|
||||
#define HEIGHT 64
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
|
||||
/*
|
||||
http://www.gaw.ru/pdf/lcd/lcm/Varitronix/graf/MGLS32064-03.pdf
|
||||
*/
|
||||
|
||||
static const uint8_t u8g_dev_lc7981_320x64_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
U8G_ESC_RST(15), /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x000, /* mode register */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x032, /* display on (bit 5), master mode on (bit 4), graphics mode on (bit 1)*/
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x001, /* character/bits per pixel pitch */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x007, /* 8 bits per pixel */
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x002, /* number of chars/byte width of the screen */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
WIDTH/8-1, /* 8 bits per pixel */
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x003, /* time division */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x07f, /* */
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x008, /* display start low */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x000, /* */
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x009, /* display start high */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x000, /* */
|
||||
|
||||
U8G_ESC_DLY(10), /* delay 10 ms */
|
||||
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_lc7981_320x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_lc7981_320x64_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
uint8_t y, i;
|
||||
uint16_t disp_ram_adr;
|
||||
uint8_t *ptr;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
u8g_SetAddress(u8g, dev, 1); /* cmd mode */
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
y = pb->p.page_y0;
|
||||
ptr = pb->buf;
|
||||
disp_ram_adr = WIDTH/8;
|
||||
disp_ram_adr *= y;
|
||||
for( i = 0; i < 8; i ++ )
|
||||
{
|
||||
u8g_SetAddress(u8g, dev, 1); /* cmd mode */
|
||||
u8g_WriteByte(u8g, dev, 0x00a ); /* display ram (cursor) address low byte */
|
||||
u8g_SetAddress(u8g, dev, 0); /* data mode */
|
||||
u8g_WriteByte(u8g, dev, disp_ram_adr & 0x0ff );
|
||||
|
||||
u8g_SetAddress(u8g, dev, 1); /* cmd mode */
|
||||
u8g_WriteByte(u8g, dev, 0x00b ); /* display ram (cursor) address hight byte */
|
||||
u8g_SetAddress(u8g, dev, 0); /* data mode */
|
||||
u8g_WriteByte(u8g, dev, disp_ram_adr >> 8 );
|
||||
|
||||
u8g_SetAddress(u8g, dev, 1); /* cmd mode */
|
||||
u8g_WriteByte(u8g, dev, 0x00c ); /* write data */
|
||||
u8g_SetAddress(u8g, dev, 0); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, WIDTH/8, ptr);
|
||||
ptr += WIDTH/8;
|
||||
disp_ram_adr += WIDTH/8;
|
||||
}
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return u8g_dev_pb8h1f_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
U8G_PB_DEV(u8g_dev_lc7981_320x64_8bit, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_lc7981_320x64_fn, U8G_COM_FAST_PARALLEL);
|
@ -0,0 +1,67 @@
|
||||
/*
|
||||
|
||||
u8g_dev_null.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
uint8_t u8g_dev_null(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_SET_8PIXEL: /* most often used command */
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_PIXEL:
|
||||
break;
|
||||
case U8G_DEV_MSG_INIT:
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_FIRST:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
break;
|
||||
#ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
|
||||
case U8G_DEV_MSG_IS_BBX_INTERSECTION:
|
||||
return 1;
|
||||
#endif
|
||||
case U8G_DEV_MSG_GET_PAGE_BOX:
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_COLOR_INDEX:
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_XY_CB:
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
@ -0,0 +1,110 @@
|
||||
/*
|
||||
|
||||
u8g_dev_pcd8544_84x48.c
|
||||
|
||||
Display: Nokia 84x48
|
||||
|
||||
Status: Tested with PCF8812 Display
|
||||
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define WIDTH 84
|
||||
#define HEIGHT 48
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
|
||||
static const uint8_t u8g_dev_pcd8544_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x021, /* activate chip (PD=0), horizontal increment (V=0), enter extended command set (H=1) */
|
||||
0x006, /* temp. control: b10 = 2 */
|
||||
0x013, /* bias system 1:48 */
|
||||
0x0c0, /* medium Vop */
|
||||
0x020, /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
|
||||
0x00c, /* display on, normal operation */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x020, /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
|
||||
0x00d, /* display on, invert */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x020, /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
|
||||
0x00c, /* display on, normal */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_pcd8544_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_pcd8544_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
u8g_SetAddress(u8g, dev, 0); /* command mode */
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_WriteByte(u8g, dev, 0x020 ); /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
|
||||
u8g_WriteByte(u8g, dev, 0x080 ); /* set X address */
|
||||
u8g_WriteByte(u8g, dev, 0x040 | pb->p.page); /* set Y address */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
|
||||
return 0;
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
/* the contrast adjustment does not work, needs to be analysed */
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_WriteByte(u8g, dev, 0x021); /* command mode, extended function set */
|
||||
u8g_WriteByte(u8g, dev, 0x080 | ( (*(uint8_t *)arg) >> 1 ) );
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
|
||||
U8G_PB_DEV(u8g_dev_pcd8544_84x48_sw_spi , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_pcd8544_fn, U8G_COM_SW_SPI);
|
||||
|
@ -0,0 +1,123 @@
|
||||
/*
|
||||
|
||||
u8g_dev_pcf8812_96x65.c
|
||||
|
||||
Display: Nokia 96x65
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
|
||||
om6206 comaptible to pcf8812 ?
|
||||
|
||||
Status: Tested
|
||||
|
||||
|
||||
Display Controller Seen in
|
||||
LPH7366 (9 pins, 84x48) PCD8544 Nokia 5110 / 5120 / 5130 / 5160 / 6110 / 6150
|
||||
LPH7677 (8 pins, 84x48) PCD8544 Nokia 3210
|
||||
LPH7779 (8 pins, 84x48) PCD8544 Nokia 3310 / 3315 / 3330 / 3110, also 3410?
|
||||
??? PCD8544 Nokia 5110 / 6110
|
||||
LPH7690 ? (96x65) PCF8455/OM6202 Nokia 3410
|
||||
LPH7690 ? (96x65?) SED1565/S1D15605 Nokia 7110 / 3510?
|
||||
LPH7690 ??? Nokia 6210
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define WIDTH 96
|
||||
#define HEIGHT 65
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
|
||||
static const uint8_t u8g_dev_pcf8812_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x021, /* activate chip (PD=0), horizontal increment (V=0), enter extended command set (H=1) */
|
||||
0x006, /* temp. control: b10 = 2 */
|
||||
0x013, /* bias system 1:48 */
|
||||
0x080 | 0x040, /* medium Vop */
|
||||
0x020, /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
|
||||
0x00c, /* display on, normal operation */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x020, /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
|
||||
0x00d, /* display on, invert */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x020, /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
|
||||
0x00c, /* display on, normal */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_pcf8812_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_pcf8812_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
u8g_SetAddress(u8g, dev, 0); /* command mode */
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_WriteByte(u8g, dev, 0x020 ); /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
|
||||
u8g_WriteByte(u8g, dev, 0x080 ); /* set X address */
|
||||
u8g_WriteByte(u8g, dev, 0x040 | pb->p.page); /* set Y address */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
|
||||
return 0;
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
/* the contrast adjustment does not work, needs to be analysed */
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_WriteByte(u8g, dev, 0x021); /* command mode, extended function set */
|
||||
u8g_WriteByte(u8g, dev, 0x080 | ( (*(uint8_t *)arg) >> 1 ) );
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
/* u8g_com_arduino_sw_spi_fn does not work, too fast??? */
|
||||
U8G_PB_DEV(u8g_dev_pcf8812_96x65_sw_spi , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_pcf8812_fn, U8G_COM_SW_SPI);
|
@ -0,0 +1,107 @@
|
||||
/*
|
||||
|
||||
u8g_dev_sbn1661_122x32.c
|
||||
|
||||
WG12232 display with 2xSBN1661 / SED1520 controller (122x32 display)
|
||||
At the moment only available in the Arduino Environment
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define WIDTH 122
|
||||
#define HEIGHT 32
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
|
||||
static const uint8_t u8g_dev_sbn1661_122x32_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(15), /* do reset low pulse with (15*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip 1 */
|
||||
0x0af, /* display on */
|
||||
0x0c0, /* display start at line 0 */
|
||||
0x0a0, /* a0: ADC forward, a1: ADC reverse */
|
||||
0x0a9, /* a8: 1/16, a9: 1/32 duty */
|
||||
U8G_ESC_CS(2), /* enable chip 2 */
|
||||
0x0af, /* display on */
|
||||
0x0c0, /* display start at line 0 */
|
||||
0x0a0, /* a0: ADC forward, a1: ADC reverse */
|
||||
0x0a9, /* a8: 1/16, a9: 1/32 duty */
|
||||
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
|
||||
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_sbn1661_122x32_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_sbn1661_122x32_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
u8g_SetAddress(u8g, dev, 0); /* command mode */
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_WriteByte(u8g, dev, 0x0b8 | pb->p.page); /* select current page (SBN1661/SED1520) */
|
||||
u8g_WriteByte(u8g, dev, 0x000 ); /* set X address */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, WIDTH/2, pb->buf);
|
||||
|
||||
u8g_SetAddress(u8g, dev, 0); /* command mode */
|
||||
u8g_SetChipSelect(u8g, dev, 2);
|
||||
u8g_WriteByte(u8g, dev, 0x0b8 | pb->p.page); /* select current page (SBN1661/SED1520) */
|
||||
u8g_WriteByte(u8g, dev, 0x000 ); /* set X address */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, WIDTH/2, WIDTH/2+(uint8_t *)pb->buf);
|
||||
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
break;
|
||||
}
|
||||
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
/* u8g_com_arduino_sw_spi_fn does not work, too fast??? */
|
||||
U8G_PB_DEV(u8g_dev_sbn1661_122x32 , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_sbn1661_122x32_fn, u8g_com_arduino_no_en_parallel_fn);
|
@ -0,0 +1,247 @@
|
||||
/*
|
||||
|
||||
u8g_dev_ssd1306_128x32.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
23 Feb 2013: Fixed, Issue 147
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define WIDTH 128
|
||||
#define HEIGHT 32
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
|
||||
/* init sequence adafruit 128x32 OLED (NOT TESTED) */
|
||||
static const uint8_t u8g_dev_ssd1306_128x32_adafruit1_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
|
||||
0x0ae, /* display off, sleep mode */
|
||||
0x0d5, 0x080, /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
||||
0x0a8, 0x03f, /* */
|
||||
|
||||
0x0d3, 0x000, /* */
|
||||
|
||||
0x040, /* start line */
|
||||
|
||||
0x08d, 0x010, /* [1] charge pump setting (p62): 0x014 enable, 0x010 disable */
|
||||
|
||||
0x020, 0x000, /* */
|
||||
0x0a1, /* segment remap a0/a1*/
|
||||
0x0c8, /* c0: scan dir normal, c8: reverse */
|
||||
0x0da, 0x012, /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
|
||||
0x081, 0x09f, /* [1] set contrast control */
|
||||
0x0d9, 0x022, /* [1] pre-charge period 0x022/f1*/
|
||||
0x0db, 0x040, /* vcomh deselect level */
|
||||
|
||||
0x02e, /* 2012-05-27: Deactivate scroll */
|
||||
0x0a4, /* output ram to display */
|
||||
0x0a6, /* none inverted normal display mode */
|
||||
0x0af, /* display on */
|
||||
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
/* init sequence adafruit 128x32 OLED (NOT TESTED) */
|
||||
static const uint8_t u8g_dev_ssd1306_128x32_adafruit2_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
|
||||
0x0ae, /* display off, sleep mode */
|
||||
0x0d5, 0x080, /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
||||
0x0a8, 0x03f, /* */
|
||||
|
||||
0x0d3, 0x000, /* */
|
||||
|
||||
0x040, /* start line */
|
||||
|
||||
0x08d, 0x014, /* [2] charge pump setting (p62): 0x014 enable, 0x010 disable */
|
||||
|
||||
0x020, 0x000, /* */
|
||||
0x0a1, /* segment remap a0/a1*/
|
||||
0x0c8, /* c0: scan dir normal, c8: reverse */
|
||||
0x0da, 0x012, /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
|
||||
0x081, 0x0cf, /* [2] set contrast control */
|
||||
0x0d9, 0x0f1, /* [2] pre-charge period 0x022/f1*/
|
||||
0x0db, 0x040, /* vcomh deselect level */
|
||||
|
||||
0x02e, /* 2012-05-27: Deactivate scroll */
|
||||
0x0a4, /* output ram to display */
|
||||
0x0a6, /* none inverted normal display mode */
|
||||
0x0af, /* display on */
|
||||
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
/* init sequence adafruit 128x32 OLED (TESTED - WORKING 23.02.13), like adafruit3, but with page addressing mode */
|
||||
static const uint8_t u8g_dev_ssd1306_128x32_adafruit3_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
|
||||
0x0ae, /* display off, sleep mode */
|
||||
0x0d5, 0x080, /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
||||
0x0a8, 0x01f, /* Feb 23, 2013: 128x32 OLED: 0x01f, 128x64 OLED 0x03f */
|
||||
|
||||
0x0d3, 0x000, /* */
|
||||
|
||||
0x040, /* start line */
|
||||
|
||||
0x08d, 0x014, /* [2] charge pump setting (p62): 0x014 enable, 0x010 disable */
|
||||
|
||||
0x020, 0x002, /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5), Feb 23, 2013: 128x32 OLED: 0x002, 128x64 OLED 0x012 */
|
||||
0x0a1, /* segment remap a0/a1*/
|
||||
0x0c8, /* c0: scan dir normal, c8: reverse */
|
||||
0x0da, 0x002, /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
|
||||
0x081, 0x0cf, /* [2] set contrast control */
|
||||
0x0d9, 0x0f1, /* [2] pre-charge period 0x022/f1*/
|
||||
0x0db, 0x040, /* vcomh deselect level */
|
||||
|
||||
0x02e, /* 2012-05-27: Deactivate scroll */
|
||||
0x0a4, /* output ram to display */
|
||||
0x0a6, /* none inverted normal display mode */
|
||||
0x0af, /* display on */
|
||||
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
/* init sequence Univision datasheet (NOT TESTED) */
|
||||
static const uint8_t u8g_dev_ssd1306_128x32_univision_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
|
||||
0x0ae, /* display off, sleep mode */
|
||||
0x0d5, 0x080, /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
||||
0x0a8, 0x03f, /* multiplex ratio */
|
||||
0x0d3, 0x000, /* display offset */
|
||||
0x040, /* start line */
|
||||
0x08d, 0x010, /* charge pump setting (p62): 0x014 enable, 0x010 disable */
|
||||
0x0a1, /* segment remap a0/a1*/
|
||||
0x0c8, /* c0: scan dir normal, c8: reverse */
|
||||
0x0da, 0x012, /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
|
||||
0x081, 0x09f, /* set contrast control */
|
||||
0x0d9, 0x022, /* pre-charge period */
|
||||
0x0db, 0x040, /* vcomh deselect level */
|
||||
0x022, 0x000, /* page addressing mode WRONG: 3 byte cmd! */
|
||||
0x0a4, /* output ram to display */
|
||||
0x0a6, /* none inverted normal display mode */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
/* select one init sequence here */
|
||||
//define u8g_dev_ssd1306_128x32_init_seq u8g_dev_ssd1306_128x32_univision_init_seq
|
||||
//define u8g_dev_ssd1306_128x32_init_seq u8g_dev_ssd1306_128x32_adafruit1_init_seq
|
||||
//define u8g_dev_ssd1306_128x32_init_seq u8g_dev_ssd1306_128x32_adafruit2_init_seq
|
||||
#define u8g_dev_ssd1306_128x32_init_seq u8g_dev_ssd1306_128x32_adafruit3_init_seq
|
||||
|
||||
|
||||
static const uint8_t u8g_dev_ssd1306_128x32_data_start[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x010, /* set upper 4 bit of the col adr. to 0 */
|
||||
0x000, /* set lower 4 bit of the col adr. to 4 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_ssd13xx_sleep_on[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0ae, /* display off */
|
||||
U8G_ESC_CS(1), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_ssd13xx_sleep_off[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
U8G_ESC_CS(1), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_ssd1306_128x32_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1306_128x32_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1306_128x32_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | pb->p.page); /* select current page (SSD1306) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
|
||||
return 0;
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
U8G_PB_DEV(u8g_dev_ssd1306_128x32_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_128x32_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_ssd1306_128x32_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_128x32_fn, U8G_COM_HW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_ssd1306_128x32_i2c, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_128x32_fn, U8G_COM_SSD_I2C);
|
||||
|
@ -0,0 +1,237 @@
|
||||
/*
|
||||
|
||||
u8g_dev_ssd1306_128x64.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define WIDTH 128
|
||||
#define HEIGHT 64
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
/* init sequence adafruit 128x64 OLED (NOT TESTED) */
|
||||
static const uint8_t u8g_dev_ssd1306_128x64_adafruit1_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
|
||||
0x0ae, /* display off, sleep mode */
|
||||
0x0d5, 0x080, /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
||||
0x0a8, 0x03f, /* */
|
||||
|
||||
0x0d3, 0x000, /* */
|
||||
|
||||
0x040, /* start line */
|
||||
|
||||
0x08d, 0x010, /* [1] charge pump setting (p62): 0x014 enable, 0x010 disable */
|
||||
|
||||
0x020, 0x000, /* */
|
||||
0x0a1, /* segment remap a0/a1*/
|
||||
0x0c8, /* c0: scan dir normal, c8: reverse */
|
||||
0x0da, 0x012, /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
|
||||
0x081, 0x09f, /* [1] set contrast control */
|
||||
0x0d9, 0x022, /* [1] pre-charge period 0x022/f1*/
|
||||
0x0db, 0x040, /* vcomh deselect level */
|
||||
|
||||
0x02e, /* 2012-05-27: Deactivate scroll */
|
||||
0x0a4, /* output ram to display */
|
||||
0x0a6, /* none inverted normal display mode */
|
||||
0x0af, /* display on */
|
||||
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
/* init sequence adafruit 128x64 OLED (NOT TESTED) */
|
||||
static const uint8_t u8g_dev_ssd1306_128x64_adafruit2_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
|
||||
0x0ae, /* display off, sleep mode */
|
||||
0x0d5, 0x080, /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
||||
0x0a8, 0x03f, /* */
|
||||
|
||||
0x0d3, 0x000, /* */
|
||||
|
||||
0x040, /* start line */
|
||||
|
||||
0x08d, 0x014, /* [2] charge pump setting (p62): 0x014 enable, 0x010 disable */
|
||||
|
||||
0x020, 0x000, /* */
|
||||
0x0a1, /* segment remap a0/a1*/
|
||||
0x0c8, /* c0: scan dir normal, c8: reverse */
|
||||
0x0da, 0x012, /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
|
||||
0x081, 0x0cf, /* [2] set contrast control */
|
||||
0x0d9, 0x0f1, /* [2] pre-charge period 0x022/f1*/
|
||||
0x0db, 0x040, /* vcomh deselect level */
|
||||
|
||||
0x02e, /* 2012-05-27: Deactivate scroll */
|
||||
0x0a4, /* output ram to display */
|
||||
0x0a6, /* none inverted normal display mode */
|
||||
0x0af, /* display on */
|
||||
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
/* init sequence adafruit 128x64 OLED (NOT TESTED), like adafruit3, but with page addressing mode */
|
||||
static const uint8_t u8g_dev_ssd1306_128x64_adafruit3_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
|
||||
0x0ae, /* display off, sleep mode */
|
||||
0x0d5, 0x080, /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
||||
0x0a8, 0x03f, /* */
|
||||
|
||||
0x0d3, 0x000, /* */
|
||||
|
||||
0x040, /* start line */
|
||||
|
||||
0x08d, 0x014, /* [2] charge pump setting (p62): 0x014 enable, 0x010 disable */
|
||||
|
||||
0x020, 0x002, /* 2012-05-27: page addressing mode */
|
||||
0x0a1, /* segment remap a0/a1*/
|
||||
0x0c8, /* c0: scan dir normal, c8: reverse */
|
||||
0x0da, 0x012, /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
|
||||
0x081, 0x0cf, /* [2] set contrast control */
|
||||
0x0d9, 0x0f1, /* [2] pre-charge period 0x022/f1*/
|
||||
0x0db, 0x040, /* vcomh deselect level */
|
||||
|
||||
0x02e, /* 2012-05-27: Deactivate scroll */
|
||||
0x0a4, /* output ram to display */
|
||||
0x0a6, /* none inverted normal display mode */
|
||||
0x0af, /* display on */
|
||||
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
/* init sequence Univision datasheet (NOT TESTED) */
|
||||
static const uint8_t u8g_dev_ssd1306_128x64_univision_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
|
||||
0x0ae, /* display off, sleep mode */
|
||||
0x0d5, 0x080, /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
||||
0x0a8, 0x03f, /* multiplex ratio */
|
||||
0x0d3, 0x000, /* display offset */
|
||||
0x040, /* start line */
|
||||
0x08d, 0x010, /* charge pump setting (p62): 0x014 enable, 0x010 disable */
|
||||
0x0a1, /* segment remap a0/a1*/
|
||||
0x0c8, /* c0: scan dir normal, c8: reverse */
|
||||
0x0da, 0x012, /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
|
||||
0x081, 0x09f, /* set contrast control */
|
||||
0x0d9, 0x022, /* pre-charge period */
|
||||
0x0db, 0x040, /* vcomh deselect level */
|
||||
0x022, 0x000, /* page addressing mode WRONG: 3 byte cmd! */
|
||||
0x0a4, /* output ram to display */
|
||||
0x0a6, /* none inverted normal display mode */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
/* select one init sequence here */
|
||||
//#define u8g_dev_ssd1306_128x64_init_seq u8g_dev_ssd1306_128x64_univision_init_seq
|
||||
//#define u8g_dev_ssd1306_128x64_init_seq u8g_dev_ssd1306_128x64_adafruit1_init_seq
|
||||
//#define u8g_dev_ssd1306_128x64_init_seq u8g_dev_ssd1306_128x64_adafruit2_init_seq
|
||||
#define u8g_dev_ssd1306_128x64_init_seq u8g_dev_ssd1306_128x64_adafruit3_init_seq
|
||||
|
||||
|
||||
static const uint8_t u8g_dev_ssd1306_128x64_data_start[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x010, /* set upper 4 bit of the col adr to 0 */
|
||||
0x000, /* set lower 4 bit of the col adr to 4 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_ssd13xx_sleep_on[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0ae, /* display off */
|
||||
U8G_ESC_CS(1), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_ssd13xx_sleep_off[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
U8G_ESC_CS(1), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_ssd1306_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1306_128x64_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1306_128x64_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | pb->p.page); /* select current page (SSD1306) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
|
||||
return 0;
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
U8G_PB_DEV(u8g_dev_ssd1306_128x64_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_128x64_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_ssd1306_128x64_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_128x64_fn, U8G_COM_HW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_ssd1306_128x64_i2c, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_128x64_fn, U8G_COM_SSD_I2C);
|
@ -0,0 +1,144 @@
|
||||
/*
|
||||
|
||||
u8g_dev_ssd1309_128x64.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2012, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define WIDTH 128
|
||||
#define HEIGHT 64
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
|
||||
/* ssd1309 ini sequence*/
|
||||
static const uint8_t u8g_dev_ssd1309_128x64_init_seq[] PROGMEM={
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
|
||||
0xfd,0x12, /*Command Lock */
|
||||
0xae, /*Set Display Off */
|
||||
0xd5,0xa0, /*set Display Clock Divide Ratio/Oscillator Frequency */
|
||||
0xa8,0x3f, /*Set Multiplex Ratio */
|
||||
0x3d,0x00, /*Set Display Offset*/
|
||||
0x40, /*Set Display Start Line*/
|
||||
0xa1, /*Set Segment Re-Map*/
|
||||
0xc8, /*Set COM Output Scan Direction*/
|
||||
0xda,0x12, /*Set COM Pins Hardware Configuration*/
|
||||
0x81,0xdf, /*Set Current Control */
|
||||
0xd9,0x82, /*Set Pre-Charge Period */
|
||||
0xdb,0x34, /*Set VCOMH Deselect Level */
|
||||
0xa4, /*Set Entire Display On/Off */
|
||||
0xa6, /*Set Normal/Inverse Display*/
|
||||
U8G_ESC_VCC(1), /*Power up VCC & Stabilized */
|
||||
U8G_ESC_DLY(50),
|
||||
0xaf, /*Set Display On */
|
||||
U8G_ESC_DLY(50),
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
/* select one init sequence here */
|
||||
#define u8g_dev_ssd1309_128x64_init_seq u8g_dev_ssd1309_128x64_init_seq
|
||||
|
||||
|
||||
static const uint8_t u8g_dev_ssd1309_128x64_data_start[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x010, /* set upper 4 bit of the col adr to 0 */
|
||||
0x000, /* set lower 4 bit of the col adr to 4 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_ssd13xx_sleep_on[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0ae, /* display off */
|
||||
U8G_ESC_CS(1), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_ssd13xx_sleep_off[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
U8G_ESC_CS(1), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_ssd1309_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1309_128x64_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1309_128x64_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | pb->p.page); /* select current page (SSD1306) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
|
||||
return 0;
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
U8G_PB_DEV(u8g_dev_ssd1309_128x64_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1309_128x64_fn, U8G_COM_HW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_ssd1309_128x64_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1309_128x64_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_ssd1309_128x64_i2c, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1309_128x64_fn, U8G_COM_SSD_I2C);
|
||||
|
||||
|
@ -0,0 +1,334 @@
|
||||
/*
|
||||
|
||||
u8g_dev_ssd1322_nhd31oled_bw.c
|
||||
|
||||
1-Bit (BW) Driver for SSD1322 Controller (OLED Display)
|
||||
Tested with NHD-3.12-25664
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2012, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
SSD130x Monochrom OLED Controller
|
||||
SSD131x Character OLED Controller
|
||||
SSD132x Graylevel OLED Controller
|
||||
SSD1331 Color OLED Controller
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
/* width must be multiple of 8, largest value is 248 unless u8g 16 bit mode is enabled */
|
||||
#if defined(U8G_16BIT)
|
||||
#define WIDTH 256
|
||||
#else
|
||||
#define WIDTH 248
|
||||
#endif
|
||||
#define HEIGHT 64
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
/*
|
||||
http://www.newhavendisplay.com/app_notes/OLED_25664.txt
|
||||
http://www.newhavendisplay.com/forum/viewtopic.php?f=15&t=3758
|
||||
*/
|
||||
|
||||
static const uint8_t u8g_dev_ssd1322_1bit_nhd_312_init_seq[] PROGMEM = {
|
||||
U8G_ESC_DLY(10), /* delay 10 ms */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0fd, /* lock command */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x012, /* unlock */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0ae, /* display off, sleep mode */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0b3,
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x091, /* set display clock divide ratio/oscillator frequency (set clock as 80 frames/sec) */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0ca, /* multiplex ratio */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x03f, /* 1/64 Duty (0x0F~0x3F) */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0a2,
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x000, /* display offset, shift mapping ram counter */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0a1,
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x000, /* display start line */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0a0, /* Set Re-Map / Dual COM Line Mode */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x014, /* was 0x014 */
|
||||
0x011, /* was 0x011 */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0ab,
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x001, /* Enable Internal VDD Regulator */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0b4, /* Display Enhancement A */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x0a0,
|
||||
0x005|0x0fd,
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0c1, /* contrast */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x09f,
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0c7, /* Set Scale Factor of Segment Output Current Control */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x00f,
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0b9, /* linear gray scale */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0b1, /* Phase 1 (Reset) & Phase 2 (Pre-Charge) Period Adjustment */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x0e2,
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0d1, /* Display Enhancement B */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x082|0x020,
|
||||
0x020,
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0bb, /* precharge voltage */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x01f,
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0b6, /* precharge period */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x008,
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0be, /* vcomh */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x007,
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0a6, /* normal display */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0a9, /* exit partial display */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0af, /* display on */
|
||||
|
||||
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_ssd1322_1bit_nhd_312_prepare_page_seq[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x015, /* column address... */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x01c, /* start at column 0 */
|
||||
0x05b, /* end column */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x075, /* row address... */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static void u8g_dev_ssd1322_1bit_prepare_row(u8g_t *u8g, u8g_dev_t *dev, uint8_t delta_row)
|
||||
{
|
||||
uint8_t row = ((u8g_pb_t *)(dev->dev_mem))->p.page;
|
||||
|
||||
row *= ((u8g_pb_t *)(dev->dev_mem))->p.page_height;
|
||||
row += delta_row;
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1322_1bit_nhd_312_prepare_page_seq);
|
||||
|
||||
u8g_WriteByte(u8g, dev, row); /* start at the selected row */
|
||||
u8g_WriteByte(u8g, dev, row+1); /* end within the selected row */
|
||||
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode mode */
|
||||
u8g_WriteByte(u8g, dev, 0x05c); /* write to ram */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
}
|
||||
|
||||
static const uint8_t u8g_dev_ssd13xx_sleep_on[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0ae, /* display off */
|
||||
U8G_ESC_CS(1), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_ssd13xx_sleep_off[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
U8G_ESC_CS(1), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
uint8_t u8g_dev_ssd1322_nhd31oled_bw_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1322_1bit_nhd_312_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
uint8_t i;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
uint8_t *p = pb->buf;
|
||||
u8g_uint_t cnt;
|
||||
cnt = pb->width;
|
||||
cnt >>= 3;
|
||||
|
||||
for( i = 0; i < pb->p.page_height; i++ )
|
||||
{
|
||||
u8g_dev_ssd1322_1bit_prepare_row(u8g, dev, i); /* this will also enable chip select */
|
||||
#if !defined(U8G_16BIT)
|
||||
u8g_WriteByte(u8g, dev, 0x0ff);
|
||||
u8g_WriteByte(u8g, dev, 0x0ff);
|
||||
#endif
|
||||
u8g_WriteSequenceBWTo16GrDevice(u8g, dev, cnt, p);
|
||||
#if !defined(U8G_16BIT)
|
||||
u8g_WriteByte(u8g, dev, 0x0ff);
|
||||
u8g_WriteByte(u8g, dev, 0x0ff);
|
||||
#endif
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
p+=cnt;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
break;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb8h1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
|
||||
uint8_t u8g_dev_ssd1322_nhd31oled_2x_bw_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1322_1bit_nhd_312_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
uint8_t i;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
uint8_t *p = pb->buf;
|
||||
u8g_uint_t cnt;
|
||||
cnt = pb->width;
|
||||
cnt >>= 3;
|
||||
|
||||
for( i = 0; i < pb->p.page_height; i++ )
|
||||
{
|
||||
u8g_dev_ssd1322_1bit_prepare_row(u8g, dev, i); /* this will also enable chip select */
|
||||
#if !defined(U8G_16BIT)
|
||||
u8g_WriteByte(u8g, dev, 0x0ff);
|
||||
u8g_WriteByte(u8g, dev, 0x0ff);
|
||||
#endif
|
||||
u8g_WriteSequenceBWTo16GrDevice(u8g, dev, cnt, p);
|
||||
#if !defined(U8G_16BIT)
|
||||
u8g_WriteByte(u8g, dev, 0x0ff);
|
||||
u8g_WriteByte(u8g, dev, 0x0ff);
|
||||
#endif
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
p+=cnt;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
break;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb16h1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
|
||||
U8G_PB_DEV(u8g_dev_ssd1322_nhd31oled_bw_sw_spi , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1322_nhd31oled_bw_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_ssd1322_nhd31oled_bw_hw_spi , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1322_nhd31oled_bw_fn, U8G_COM_HW_SPI);
|
||||
|
||||
#define DWIDTH (WIDTH*2)
|
||||
uint8_t u8g_dev_ssd1322_nhd31oled_2x_bw_buf[DWIDTH] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_dev_ssd1322_nhd31oled_2x_bw_pb = { {16, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_ssd1322_nhd31oled_2x_bw_buf};
|
||||
u8g_dev_t u8g_dev_ssd1322_nhd31oled_2x_bw_sw_spi = { u8g_dev_ssd1322_nhd31oled_2x_bw_fn, &u8g_dev_ssd1322_nhd31oled_2x_bw_pb, U8G_COM_SW_SPI };
|
||||
u8g_dev_t u8g_dev_ssd1322_nhd31oled_2x_bw_hw_spi = { u8g_dev_ssd1322_nhd31oled_2x_bw_fn, &u8g_dev_ssd1322_nhd31oled_2x_bw_pb, U8G_COM_HW_SPI };
|
||||
|
@ -0,0 +1,333 @@
|
||||
/*
|
||||
|
||||
u8g_dev_ssd1322_nhd31oled_gr.c
|
||||
|
||||
2-Bit (4L) Driver for SSD1322 Controller (OLED Display)
|
||||
Tested with NHD-3.12-25664
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2012, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
SSD130x Monochrom OLED Controller
|
||||
SSD131x Character OLED Controller
|
||||
SSD132x Graylevel OLED Controller
|
||||
SSD1331 Color OLED Controller
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
/* width must be multiple of 8, largest value is 248 unless u8g 16 bit mode is enabled */
|
||||
#if defined(U8G_16BIT)
|
||||
#define WIDTH 256
|
||||
#else
|
||||
#define WIDTH 248
|
||||
#endif
|
||||
#define HEIGHT 64
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
/*
|
||||
http://www.newhavendisplay.com/app_notes/OLED_25664.txt
|
||||
http://www.newhavendisplay.com/forum/viewtopic.php?f=15&t=3758
|
||||
*/
|
||||
|
||||
static const uint8_t u8g_dev_ssd1322_2bit_nhd_312_init_seq[] PROGMEM = {
|
||||
U8G_ESC_DLY(10), /* delay 10 ms */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0fd, /* lock command */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x012, /* unlock */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0ae, /* display off, sleep mode */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0b3,
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x091, /* set display clock divide ratio/oscillator frequency (set clock as 80 frames/sec) */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0ca, /* multiplex ratio */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x03f, /* 1/64 Duty (0x0F~0x3F) */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0a2,
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x000, /* display offset, shift mapping ram counter */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0a1,
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x000, /* display start line */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0a0, /* Set Re-Map / Dual COM Line Mode */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x014, /* was 0x014 */
|
||||
0x011, /* was 0x011 */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0ab,
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x001, /* Enable Internal VDD Regulator */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0b4, /* Display Enhancement A */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x0a0,
|
||||
0x005|0x0fd,
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0c1, /* contrast */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x09f,
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0c7, /* Set Scale Factor of Segment Output Current Control */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x00f,
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0b9, /* linear gray scale */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0b1, /* Phase 1 (Reset) & Phase 2 (Pre-Charge) Period Adjustment */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x0e2,
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0d1, /* Display Enhancement B */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x082|0x020,
|
||||
0x020,
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0bb, /* precharge voltage */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x01f,
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0b6, /* precharge period */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x008,
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0be, /* vcomh */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x007,
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0a6, /* normal display */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0a9, /* exit partial display */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0af, /* display on */
|
||||
|
||||
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_ssd1322_2bit_nhd_312_prepare_page_seq[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x015, /* column address... */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x01c, /* start at column 0 */
|
||||
0x05b, /* end column */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x075, /* row address... */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static void u8g_dev_ssd1322_2bit_prepare_row(u8g_t *u8g, u8g_dev_t *dev, uint8_t delta_row)
|
||||
{
|
||||
uint8_t row = ((u8g_pb_t *)(dev->dev_mem))->p.page;
|
||||
|
||||
row *= ((u8g_pb_t *)(dev->dev_mem))->p.page_height;
|
||||
row += delta_row;
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1322_2bit_nhd_312_prepare_page_seq);
|
||||
|
||||
u8g_WriteByte(u8g, dev, row); /* start at the selected row */
|
||||
u8g_WriteByte(u8g, dev, row+1); /* end within the selected row */
|
||||
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode mode */
|
||||
u8g_WriteByte(u8g, dev, 0x05c); /* write to ram */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
}
|
||||
|
||||
static const uint8_t u8g_dev_ssd13xx_sleep_on[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0ae, /* display off */
|
||||
U8G_ESC_CS(1), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_ssd13xx_sleep_off[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
U8G_ESC_CS(1), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_ssd1322_nhd31oled_gr_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1322_2bit_nhd_312_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
uint8_t i;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
uint8_t *p = pb->buf;
|
||||
u8g_uint_t cnt;
|
||||
cnt = pb->width;
|
||||
cnt >>= 2;
|
||||
|
||||
for( i = 0; i < pb->p.page_height; i++ )
|
||||
{
|
||||
u8g_dev_ssd1322_2bit_prepare_row(u8g, dev, i); /* this will also enable chip select */
|
||||
#if !defined(U8G_16BIT)
|
||||
u8g_WriteByte(u8g, dev, 0x00);
|
||||
u8g_WriteByte(u8g, dev, 0x00);
|
||||
#endif
|
||||
u8g_WriteSequence4LTo16GrDevice(u8g, dev, cnt, p);
|
||||
#if !defined(U8G_16BIT)
|
||||
u8g_WriteByte(u8g, dev, 0x00);
|
||||
u8g_WriteByte(u8g, dev, 0x00);
|
||||
#endif
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
p+=cnt;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
break;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb8h2_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
|
||||
uint8_t u8g_dev_ssd1322_nhd31oled_2x_gr_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1322_2bit_nhd_312_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
uint8_t i;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
uint8_t *p = pb->buf;
|
||||
u8g_uint_t cnt;
|
||||
cnt = pb->width;
|
||||
cnt >>= 3;
|
||||
|
||||
for( i = 0; i < pb->p.page_height; i++ )
|
||||
{
|
||||
u8g_dev_ssd1322_2bit_prepare_row(u8g, dev, i); /* this will also enable chip select */
|
||||
#if !defined(U8G_16BIT)
|
||||
u8g_WriteByte(u8g, dev, 0x00);
|
||||
u8g_WriteByte(u8g, dev, 0x00);
|
||||
#endif
|
||||
u8g_WriteSequence4LTo16GrDevice(u8g, dev, cnt, p);
|
||||
#if !defined(U8G_16BIT)
|
||||
u8g_WriteByte(u8g, dev, 0x00);
|
||||
u8g_WriteByte(u8g, dev, 0x00);
|
||||
#endif
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
p+=cnt;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
break;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb16h2_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
|
||||
U8G_PB_DEV(u8g_dev_ssd1322_nhd31oled_gr_sw_spi , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1322_nhd31oled_gr_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_ssd1322_nhd31oled_gr_hw_spi , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1322_nhd31oled_gr_fn, U8G_COM_HW_SPI);
|
||||
|
||||
#define DWIDTH (WIDTH*2)
|
||||
uint8_t u8g_dev_ssd1322_nhd31oled_2x_gr_buf[DWIDTH] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_dev_ssd1322_nhd31oled_2x_gr_pb = { {16, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_ssd1322_nhd31oled_2x_gr_buf};
|
||||
u8g_dev_t u8g_dev_ssd1322_nhd31oled_2x_gr_sw_spi = { u8g_dev_ssd1322_nhd31oled_2x_gr_fn, &u8g_dev_ssd1322_nhd31oled_2x_gr_pb, U8G_COM_SW_SPI };
|
||||
u8g_dev_t u8g_dev_ssd1322_nhd31oled_2x_gr_hw_spi = { u8g_dev_ssd1322_nhd31oled_2x_gr_fn, &u8g_dev_ssd1322_nhd31oled_2x_gr_pb, U8G_COM_HW_SPI };
|
||||
|
@ -0,0 +1,263 @@
|
||||
/*
|
||||
|
||||
u8g_dev_ssd1325_nhd27oled_bw.c
|
||||
|
||||
1-Bit (BW) Driver for SSD1325 Controller (OLED Display)
|
||||
Tested with NHD-2.7-12864UCY3
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
SSD130x Monochrom OLED Controller
|
||||
SSD131x Character OLED Controller
|
||||
SSD132x Graylevel OLED Controller
|
||||
SSD1331 Color OLED Controller
|
||||
|
||||
*/
|
||||
|
||||
#ifdef OBSOLETE_CODE
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define WIDTH 128
|
||||
#define HEIGHT 64
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
/* http://www.newhavendisplay.com/app_notes/OLED_2_7_12864.txt */
|
||||
static const uint8_t u8g_dev_ssd1325_1bit_nhd_27_12864ucy3_init_seq[] PROGMEM = {
|
||||
U8G_ESC_DLY(10), /* delay 10 ms */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0ae, /* display off, sleep mode */
|
||||
0x0b3, 0x091, /* set display clock divide ratio/oscillator frequency (set clock as 135 frames/sec) */
|
||||
0x0a8, 0x03f, /* multiplex ratio: 0x03f * 1/64 duty */
|
||||
0x0a2, 0x04c, /* display offset, shift mapping ram counter */
|
||||
0x0a1, 0x000, /* display start line */
|
||||
0x0ad, 0x002, /* master configuration: disable embedded DC-DC, enable internal VCOMH */
|
||||
0x0a0, 0x056, /* remap configuration, vertical address increment, enable nibble remap (upper nibble is left) */
|
||||
0x086, /* full current range (0x084, 0x085, 0x086) */
|
||||
0x0b8, /* set gray scale table */
|
||||
0x01, 0x011, 0x022, 0x032, 0x043, 0x054, 0x065, 0x076,
|
||||
0x081, 0x070, /* contrast, brightness, 0..128, Newhaven: 0x040 */
|
||||
0x0b2, 0x051, /* frame frequency (row period) */
|
||||
0x0b1, 0x055, /* phase length */
|
||||
0x0bc, 0x010, /* pre-charge voltage level */
|
||||
0x0b4, 0x002, /* set pre-charge compensation level (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
|
||||
0x0b0, 0x028, /* enable pre-charge compensation (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
|
||||
0x0be, 0x01c, /* VCOMH voltage */
|
||||
0x0bf, 0x002|0x00d, /* VSL voltage level (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
|
||||
0x0a5, /* all pixel on */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a4, /* normal display mode */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_ssd1325_1bit_nhd_27_12864ucy3_prepare_page_seq[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x015, /* column address... */
|
||||
0x000, /* start at column 0 */
|
||||
0x03f, /* end at column 63 (which is y == 127), because there are two pixel in one column */
|
||||
0x075, /* row address... */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static void u8g_dev_ssd1325_1bit_prepare_page(u8g_t *u8g, u8g_dev_t *dev)
|
||||
{
|
||||
uint8_t page = ((u8g_pb_t *)(dev->dev_mem))->p.page;
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1325_1bit_nhd_27_12864ucy3_prepare_page_seq);
|
||||
|
||||
page <<= 3;
|
||||
u8g_WriteByte(u8g, dev, page); /* start at the selected page */
|
||||
page += 7;
|
||||
u8g_WriteByte(u8g, dev, page); /* end within the selected page */
|
||||
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
}
|
||||
|
||||
static void u8g_dev_ssd1325_1bit_2x_prepare_page(u8g_t *u8g, u8g_dev_t *dev, uint8_t is_odd)
|
||||
{
|
||||
uint8_t page = ((u8g_pb_t *)(dev->dev_mem))->p.page;
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1325_1bit_nhd_27_12864ucy3_prepare_page_seq);
|
||||
|
||||
page <<= 1;
|
||||
page += is_odd;
|
||||
|
||||
page <<= 3;
|
||||
u8g_WriteByte(u8g, dev, page); /* start at the selected page */
|
||||
page += 7;
|
||||
u8g_WriteByte(u8g, dev, page); /* end within the selected page */
|
||||
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
}
|
||||
|
||||
/* assumes row autoincrement and activated nibble remap */
|
||||
#ifdef OLD
|
||||
static void _OLD_u8g_dev_ssd1325_1bit_write_16_pixel(u8g_t *u8g, u8g_dev_t *dev, uint8_t left, uint8_t right)
|
||||
{
|
||||
uint8_t d, cnt;
|
||||
cnt = 8;
|
||||
do
|
||||
{
|
||||
d = 0;
|
||||
if ( left & 1 )
|
||||
d |= 0x0f0;
|
||||
if ( right & 1 )
|
||||
d |= 0x00f;
|
||||
u8g_WriteByte(u8g, dev, d);
|
||||
left >>= 1;
|
||||
right >>= 1;
|
||||
cnt--;
|
||||
}while ( cnt > 0 );
|
||||
}
|
||||
#endif
|
||||
|
||||
static void u8g_dev_ssd1325_1bit_write_16_pixel(u8g_t *u8g, u8g_dev_t *dev, uint8_t left, uint8_t right)
|
||||
{
|
||||
uint8_t d, cnt;
|
||||
static uint8_t buf[8];
|
||||
cnt = 8;
|
||||
do
|
||||
{
|
||||
d = 0;
|
||||
if ( left & 128 )
|
||||
d |= 0x0f0;
|
||||
if ( right & 128 )
|
||||
d |= 0x00f;
|
||||
cnt--;
|
||||
buf[cnt] = d;
|
||||
left <<= 1;
|
||||
right <<= 1;
|
||||
}while ( cnt > 0 );
|
||||
u8g_WriteSequence(u8g, dev, 8, buf);
|
||||
}
|
||||
|
||||
static void u8g_dev_ssd1325_1bit_write_buffer(u8g_t *u8g, u8g_dev_t *dev, uint8_t is_odd)
|
||||
{
|
||||
uint8_t cnt, left, right;
|
||||
uint8_t *ptr;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
ptr = pb->buf;
|
||||
cnt = pb->width;
|
||||
if ( is_odd )
|
||||
ptr += cnt;
|
||||
cnt >>= 1;
|
||||
do
|
||||
{
|
||||
left = *ptr++;
|
||||
right = *ptr++;
|
||||
u8g_dev_ssd1325_1bit_write_16_pixel(u8g, dev, left, right);
|
||||
cnt--;
|
||||
} while( cnt > 0 );
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_ssd1325_nhd27oled_bw_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1325_1bit_nhd_27_12864ucy3_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_dev_ssd1325_1bit_prepare_page(u8g, dev);
|
||||
u8g_dev_ssd1325_1bit_write_buffer(u8g, dev, 0);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
break;
|
||||
}
|
||||
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_ssd1325_nhd27oled_2x_bw_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1325_1bit_nhd_27_12864ucy3_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_dev_ssd1325_1bit_2x_prepare_page(u8g, dev, 0);
|
||||
u8g_dev_ssd1325_1bit_write_buffer(u8g, dev, 0);
|
||||
u8g_dev_ssd1325_1bit_2x_prepare_page(u8g, dev, 1);
|
||||
u8g_dev_ssd1325_1bit_write_buffer(u8g, dev, 1);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
break;
|
||||
}
|
||||
return u8g_dev_pb16v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
/* disabled, see bw_new.c */
|
||||
/*
|
||||
U8G_PB_DEV(u8g_dev_ssd1325_nhd27oled_bw_sw_spi , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1325_nhd27oled_bw_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_ssd1325_nhd27oled_bw_hw_spi , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1325_nhd27oled_bw_fn, U8G_COM_HW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_ssd1325_nhd27oled_bw_parallel , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1325_nhd27oled_bw_fn, U8G_COM_FAST_PARALLEL);
|
||||
*/
|
||||
|
||||
/*
|
||||
uint8_t u8g_dev_ssd1325_nhd27oled_2x_bw_buf[WIDTH*2] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_dev_ssd1325_nhd27oled_2x_bw_pb = { {16, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_ssd1325_nhd27oled_2x_bw_buf};
|
||||
u8g_dev_t u8g_dev_ssd1325_nhd27oled_2x_bw_sw_spi = { u8g_dev_ssd1325_nhd27oled_2x_bw_fn, &u8g_dev_ssd1325_nhd27oled_2x_bw_pb, U8G_COM_SW_SPI };
|
||||
u8g_dev_t u8g_dev_ssd1325_nhd27oled_2x_bw_hw_spi = { u8g_dev_ssd1325_nhd27oled_2x_bw_fn, &u8g_dev_ssd1325_nhd27oled_2x_bw_pb, U8G_COM_HW_SPI };
|
||||
u8g_dev_t u8g_dev_ssd1325_nhd27oled_2x_bw_parallel = { u8g_dev_ssd1325_nhd27oled_2x_bw_fn, &u8g_dev_ssd1325_nhd27oled_2x_bw_pb, U8G_COM_FAST_PARALLEL };
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
@ -0,0 +1,232 @@
|
||||
/*
|
||||
|
||||
u8g_dev_ssd1325_nhd27oled_bw.c
|
||||
|
||||
1-Bit (BW) Driver for SSD1325 Controller (OLED Display)
|
||||
Horizontal architecture, completly rewritten
|
||||
Tested with NHD-2.7-12864UCY3
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2012, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
SSD130x Monochrom OLED Controller
|
||||
SSD131x Character OLED Controller
|
||||
SSD132x Graylevel OLED Controller
|
||||
SSD1331 Color OLED Controller
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
/* width must be multiple of 8, largest value is 248 unless u8g 16 bit mode is enabled */
|
||||
#define WIDTH 128
|
||||
#define HEIGHT 64
|
||||
|
||||
/* http://www.newhavendisplay.com/app_notes/OLED_2_7_12864.txt */
|
||||
static const uint8_t u8g_dev_ssd1325_nhd_27_12864_init_seq[] PROGMEM = {
|
||||
U8G_ESC_DLY(10), /* delay 10 ms */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0ae, /* display off, sleep mode */
|
||||
0x0b3, 0x091, /* set display clock divide ratio/oscillator frequency (set clock as 135 frames/sec) */
|
||||
0x0a8, 0x03f, /* multiplex ratio: 0x03f * 1/64 duty */
|
||||
0x0a2, 0x04c, /* display offset, shift mapping ram counter */
|
||||
0x0a1, 0x000, /* display start line */
|
||||
0x0ad, 0x002, /* master configuration: disable embedded DC-DC, enable internal VCOMH */
|
||||
0x0a0, 0x052, /* remap configuration, horizontal address increment (bit 2 = 0), enable nibble remap (upper nibble is left, bit 1 = 1) */
|
||||
0x086, /* full current range (0x084, 0x085, 0x086) */
|
||||
0x0b8, /* set gray scale table */
|
||||
0x01, 0x011, 0x022, 0x032, 0x043, 0x054, 0x065, 0x076,
|
||||
|
||||
0x081, 0x070, /* contrast, brightness, 0..128, Newhaven: 0x040 */
|
||||
0x0b2, 0x051, /* frame frequency (row period) */
|
||||
0x0b1, 0x055, /* phase length */
|
||||
0x0bc, 0x010, /* pre-charge voltage level */
|
||||
0x0b4, 0x002, /* set pre-charge compensation level (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
|
||||
0x0b0, 0x028, /* enable pre-charge compensation (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
|
||||
0x0be, 0x01c, /* VCOMH voltage */
|
||||
0x0bf, 0x002|0x00d, /* VSL voltage level (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
|
||||
0x0a4, /* normal display mode */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_ssd1325_prepare_row_seq[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x015, /* column address... */
|
||||
0x000, /* start at column 0 */
|
||||
0x03f, /* end at column 63 (which is y == 127), because there are two pixel in one column */
|
||||
0x075, /* row address... */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static void u8g_dev_ssd1325_prepare_row(u8g_t *u8g, u8g_dev_t *dev, uint8_t delta_row)
|
||||
{
|
||||
uint8_t row = ((u8g_pb_t *)(dev->dev_mem))->p.page;
|
||||
|
||||
row *= ((u8g_pb_t *)(dev->dev_mem))->p.page_height;
|
||||
row += delta_row;
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1325_prepare_row_seq);
|
||||
|
||||
u8g_WriteByte(u8g, dev, row); /* start at the selected row */
|
||||
u8g_WriteByte(u8g, dev, row+1); /* end within the selected row */
|
||||
|
||||
//u8g_SetAddress(u8g, dev, 0); /* instruction mode mode */
|
||||
//u8g_WriteByte(u8g, dev, 0x05c); /* write to ram */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
}
|
||||
|
||||
static const uint8_t u8g_dev_ssd13xx_sleep_on[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0ae, /* display off */
|
||||
U8G_ESC_CS(1), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_ssd13xx_sleep_off[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
U8G_ESC_CS(1), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static uint8_t u8g_dev_ssd1325_nhd27oled_bw_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
//case U8G_DEV_MSG_IS_BBX_INTERSECTION:
|
||||
// return u8g_pb_IsIntersection((u8g_pb_t *)(dev->dev_mem), (u8g_dev_arg_bbx_t *)arg);
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1325_nhd_27_12864_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
uint8_t i;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
uint8_t *p = pb->buf;
|
||||
u8g_uint_t cnt;
|
||||
cnt = pb->width;
|
||||
cnt >>= 3;
|
||||
|
||||
for( i = 0; i < pb->p.page_height; i++ )
|
||||
{
|
||||
u8g_dev_ssd1325_prepare_row(u8g, dev, i); /* this will also enable chip select */
|
||||
u8g_WriteSequenceBWTo16GrDevice(u8g, dev, cnt, p);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
p+=cnt;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
break;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb8h1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
static uint8_t u8g_dev_ssd1325_nhd27oled_2x_bw_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1325_nhd_27_12864_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
uint8_t i;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
uint8_t *p = pb->buf;
|
||||
u8g_uint_t cnt;
|
||||
cnt = pb->width;
|
||||
cnt >>= 3;
|
||||
|
||||
for( i = 0; i < pb->p.page_height; i++ )
|
||||
{
|
||||
u8g_dev_ssd1325_prepare_row(u8g, dev, i); /* this will also enable chip select */
|
||||
u8g_WriteSequenceBWTo16GrDevice(u8g, dev, cnt, p);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
p+=cnt;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
break;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb16h1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
|
||||
|
||||
U8G_PB_DEV(u8g_dev_ssd1325_nhd27oled_bw_sw_spi , WIDTH, HEIGHT, 8, u8g_dev_ssd1325_nhd27oled_bw_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_ssd1325_nhd27oled_bw_hw_spi , WIDTH, HEIGHT, 8, u8g_dev_ssd1325_nhd27oled_bw_fn, U8G_COM_HW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_ssd1325_nhd27oled_bw_parallel , WIDTH, HEIGHT, 8, u8g_dev_ssd1325_nhd27oled_bw_fn, U8G_COM_FAST_PARALLEL);
|
||||
|
||||
uint8_t u8g_dev_ssd1325_nhd27oled_2x_bw_buf[WIDTH*2] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_dev_ssd1325_nhd27oled_2x_bw_pb = { {16, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_ssd1325_nhd27oled_2x_bw_buf};
|
||||
u8g_dev_t u8g_dev_ssd1325_nhd27oled_2x_bw_sw_spi = { u8g_dev_ssd1325_nhd27oled_2x_bw_fn, &u8g_dev_ssd1325_nhd27oled_2x_bw_pb, U8G_COM_SW_SPI };
|
||||
u8g_dev_t u8g_dev_ssd1325_nhd27oled_2x_bw_hw_spi = { u8g_dev_ssd1325_nhd27oled_2x_bw_fn, &u8g_dev_ssd1325_nhd27oled_2x_bw_pb, U8G_COM_HW_SPI };
|
||||
u8g_dev_t u8g_dev_ssd1325_nhd27oled_2x_bw_parallel = { u8g_dev_ssd1325_nhd27oled_2x_bw_fn, &u8g_dev_ssd1325_nhd27oled_2x_bw_pb, U8G_COM_FAST_PARALLEL };
|
||||
|
@ -0,0 +1,255 @@
|
||||
/*
|
||||
|
||||
u8g_dev_ssd1325_nhd27oled_gr.c
|
||||
|
||||
2-Bit (gray level) Driver for SSD1325 Controller (OLED Display)
|
||||
Tested with NHD-2.7-12864UCY3
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
SSD130x Monochrom OLED Controller
|
||||
SSD131x Character OLED Controller
|
||||
SSD132x Graylevel OLED Controller
|
||||
SSD1331 Color OLED Controller
|
||||
|
||||
*/
|
||||
|
||||
#ifdef OBSOLETE_CODE
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define WIDTH 128
|
||||
#define HEIGHT 64
|
||||
|
||||
/* http://www.newhavendisplay.com/app_notes/OLED_2_7_12864.txt */
|
||||
static const uint8_t u8g_dev_ssd1325_2bit_nhd_27_12864ucy3_init_seq[] PROGMEM = {
|
||||
U8G_ESC_DLY(10), /* delay 10 ms */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0ae, /* display off, sleep mode */
|
||||
0x0b3, 0x091, /* set display clock divide ratio/oscillator frequency (set clock as 135 frames/sec) */
|
||||
0x0a8, 0x03f, /* multiplex ratio: 0x03f * 1/64 duty */
|
||||
0x0a2, 0x04c, /* display offset, shift mapping ram counter */
|
||||
0x0a1, 0x000, /* display start line */
|
||||
0x0ad, 0x002, /* master configuration: disable embedded DC-DC, enable internal VCOMH */
|
||||
0x0a0, 0x056, /* remap configuration, vertical address increment, enable nibble remap (upper nibble is left) */
|
||||
0x086, /* full current range (0x084, 0x085, 0x086) */
|
||||
0x0b8, /* set gray scale table */
|
||||
//0x01, 0x011, 0x022, 0x032, 0x043, 0x054, 0x065, 0x076,
|
||||
0x01, 0x011, 0x022, 0x032, 0x043, 0x054, 0x077, 0x077, // 4L mode uses 0, 2, 4, 7
|
||||
0x081, 0x070, /* contrast, brightness, 0..128, Newhaven: 0x040 */
|
||||
0x0b2, 0x051, /* frame frequency (row period) */
|
||||
0x0b1, 0x055, /* phase length */
|
||||
0x0bc, 0x010, /* pre-charge voltage level */
|
||||
0x0b4, 0x002, /* set pre-charge compensation level (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
|
||||
0x0b0, 0x028, /* enable pre-charge compensation (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
|
||||
0x0be, 0x01c, /* VCOMH voltage */
|
||||
0x0bf, 0x002|0x00d, /* VSL voltage level (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
|
||||
0x0a5, /* all pixel on */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a4, /* normal display mode */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_ssd1325_2bit_nhd_27_12864ucy3_prepare_page_seq[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x015, /* column address... */
|
||||
0x000, /* start at column 0 */
|
||||
0x03f, /* end at column 63 (which is y == 127), because there are two pixel in one column */
|
||||
0x075, /* row address... */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static void u8g_dev_ssd1325_2bit_prepare_page(u8g_t *u8g, u8g_dev_t *dev)
|
||||
{
|
||||
uint8_t page = ((u8g_pb_t *)(dev->dev_mem))->p.page;
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1325_2bit_nhd_27_12864ucy3_prepare_page_seq);
|
||||
|
||||
page <<= 2;
|
||||
u8g_WriteByte(u8g, dev, page); /* start at the selected page */
|
||||
page += 3;
|
||||
u8g_WriteByte(u8g, dev, page); /* end within the selected page */
|
||||
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
}
|
||||
|
||||
static void u8g_dev_ssd1325_2bit_2x_prepare_page(u8g_t *u8g, u8g_dev_t *dev, uint8_t is_odd)
|
||||
{
|
||||
uint8_t page = ((u8g_pb_t *)(dev->dev_mem))->p.page;
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1325_2bit_nhd_27_12864ucy3_prepare_page_seq);
|
||||
|
||||
page <<= 1;
|
||||
page += is_odd;
|
||||
|
||||
|
||||
page <<= 2;
|
||||
u8g_WriteByte(u8g, dev, page); /* start at the selected page */
|
||||
page += 3;
|
||||
u8g_WriteByte(u8g, dev, page); /* end within the selected page */
|
||||
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
}
|
||||
|
||||
/* assumes row autoincrement and activated nibble remap */
|
||||
static void u8g_dev_ssd1325_2bit_write_4_pixel(u8g_t *u8g, u8g_dev_t *dev, uint8_t left, uint8_t right)
|
||||
{
|
||||
uint8_t d, tmp, cnt;
|
||||
cnt = 4;
|
||||
do
|
||||
{
|
||||
d = left;
|
||||
d &= 3;
|
||||
d <<= 4;
|
||||
tmp = right;
|
||||
tmp &= 3;
|
||||
d |= tmp;
|
||||
d <<= 2;
|
||||
u8g_WriteByte(u8g, dev, d);
|
||||
left >>= 2;
|
||||
right >>= 2;
|
||||
cnt--;
|
||||
}while ( cnt > 0 );
|
||||
}
|
||||
|
||||
static void u8g_dev_ssd1325_2bit_write_buffer(u8g_t *u8g, u8g_dev_t *dev)
|
||||
{
|
||||
uint8_t cnt, left, right;
|
||||
uint8_t *ptr;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
cnt = pb->width;
|
||||
cnt >>= 1;
|
||||
ptr = pb->buf;
|
||||
do
|
||||
{
|
||||
left = *ptr++;
|
||||
right = *ptr++;
|
||||
u8g_dev_ssd1325_2bit_write_4_pixel(u8g, dev, left, right);
|
||||
cnt--;
|
||||
} while( cnt > 0 );
|
||||
}
|
||||
|
||||
static void u8g_dev_ssd1325_2bit_2x_write_buffer(u8g_t *u8g, u8g_dev_t *dev, uint8_t is_odd)
|
||||
{
|
||||
uint8_t cnt, left, right;
|
||||
uint8_t *ptr;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
ptr = pb->buf;
|
||||
cnt = pb->width;
|
||||
if ( is_odd )
|
||||
ptr += cnt;
|
||||
cnt >>= 1;
|
||||
do
|
||||
{
|
||||
left = *ptr++;
|
||||
right = *ptr++;
|
||||
u8g_dev_ssd1325_2bit_write_4_pixel(u8g, dev, left, right);
|
||||
cnt--;
|
||||
} while( cnt > 0 );
|
||||
}
|
||||
|
||||
static uint8_t u8g_dev_ssd1325_nhd27oled_gr_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1325_2bit_nhd_27_12864ucy3_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_dev_ssd1325_2bit_prepare_page(u8g, dev);
|
||||
u8g_dev_ssd1325_2bit_write_buffer(u8g, dev);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb8v2_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
static uint8_t u8g_dev_ssd1325_nhd27oled_2x_gr_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1325_2bit_nhd_27_12864ucy3_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_dev_ssd1325_2bit_2x_prepare_page(u8g, dev, 0);
|
||||
u8g_dev_ssd1325_2bit_2x_write_buffer(u8g, dev, 0);
|
||||
u8g_dev_ssd1325_2bit_2x_prepare_page(u8g, dev, 1);
|
||||
u8g_dev_ssd1325_2bit_2x_write_buffer(u8g, dev, 1);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb16v2_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
//U8G_PB_DEV(u8g_dev_ssd1325_nhd27oled_gr_sw_spi , WIDTH, HEIGHT, 4, u8g_dev_ssd1325_nhd27oled_gr_fn, U8G_COM_SW_SPI);
|
||||
//U8G_PB_DEV(u8g_dev_ssd1325_nhd27oled_gr_hw_spi , WIDTH, HEIGHT, 4, u8g_dev_ssd1325_nhd27oled_gr_fn, U8G_COM_HW_SPI);
|
||||
|
||||
//uint8_t u8g_dev_ssd1325_nhd27oled_2x_buf[WIDTH*2] U8G_NOCOMMON ;
|
||||
//u8g_pb_t u8g_dev_ssd1325_nhd27oled_2x_pb = { {8, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_ssd1325_nhd27oled_2x_buf};
|
||||
//u8g_dev_t u8g_dev_ssd1325_nhd27oled_2x_gr_sw_spi = { u8g_dev_ssd1325_nhd27oled_2x_gr_fn, &u8g_dev_ssd1325_nhd27oled_2x_pb, U8G_COM_SW_SPI };
|
||||
//u8g_dev_t u8g_dev_ssd1325_nhd27oled_2x_gr_hw_spi = { u8g_dev_ssd1325_nhd27oled_2x_gr_fn, &u8g_dev_ssd1325_nhd27oled_2x_pb, U8G_COM_HW_SPI };
|
||||
|
||||
|
||||
#endif /* OBSOLETE_CODE */
|
@ -0,0 +1,227 @@
|
||||
/*
|
||||
|
||||
u8g_dev_ssd1325_nhd27oled_gr.c
|
||||
|
||||
2-Bit (gray level) Driver for SSD1325 Controller (OLED Display)
|
||||
Rewritten with new architecture
|
||||
Tested with NHD-2.7-12864UCY3
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
SSD130x Monochrom OLED Controller
|
||||
SSD131x Character OLED Controller
|
||||
SSD132x Graylevel OLED Controller
|
||||
SSD1331 Color OLED Controller
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define WIDTH 128
|
||||
#define HEIGHT 64
|
||||
|
||||
/* http://www.newhavendisplay.com/app_notes/OLED_2_7_12864.txt */
|
||||
static const uint8_t u8g_dev_ssd1325_2bit_nhd_27_12864ucy3_init_seq[] PROGMEM = {
|
||||
U8G_ESC_DLY(10), /* delay 10 ms */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0ae, /* display off, sleep mode */
|
||||
0x0b3, 0x091, /* set display clock divide ratio/oscillator frequency (set clock as 135 frames/sec) */
|
||||
0x0a8, 0x03f, /* multiplex ratio: 0x03f * 1/64 duty */
|
||||
0x0a2, 0x04c, /* display offset, shift mapping ram counter */
|
||||
0x0a1, 0x000, /* display start line */
|
||||
0x0ad, 0x002, /* master configuration: disable embedded DC-DC, enable internal VCOMH */
|
||||
0x0a0, 0x052, /* remap configuration, horizontal address increment (bit 2 = 0), enable nibble remap (upper nibble is left, bit 1 = 1), old values: 0x0a0 0x0a6 */
|
||||
0x086, /* full current range (0x084, 0x085, 0x086) */
|
||||
0x0b8, /* set gray scale table */
|
||||
//0x01, 0x011, 0x022, 0x032, 0x043, 0x054, 0x065, 0x076,
|
||||
0x01, 0x011, 0x022, 0x032, 0x043, 0x054, 0x077, 0x077, // 4L mode uses 0, 2, 4, 7
|
||||
0x081, 0x070, /* contrast, brightness, 0..128, Newhaven: 0x040 */
|
||||
0x0b2, 0x051, /* frame frequency (row period) */
|
||||
0x0b1, 0x055, /* phase length */
|
||||
0x0bc, 0x010, /* pre-charge voltage level */
|
||||
0x0b4, 0x002, /* set pre-charge compensation level (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
|
||||
0x0b0, 0x028, /* enable pre-charge compensation (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
|
||||
0x0be, 0x01c, /* VCOMH voltage */
|
||||
0x0bf, 0x002|0x00d, /* VSL voltage level (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
|
||||
0x0a4, /* normal display mode */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_ssd1325_2bit_nhd_27_12864ucy3_prepare_page_seq[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x015, /* column address... */
|
||||
0x000, /* start at column 0 */
|
||||
0x03f, /* end at column 63 (which is y == 127), because there are two pixel in one column */
|
||||
0x075, /* row address... */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static void u8g_dev_ssd1325_gr_prepare_row(u8g_t *u8g, u8g_dev_t *dev, uint8_t delta_row)
|
||||
{
|
||||
uint8_t row = ((u8g_pb_t *)(dev->dev_mem))->p.page;
|
||||
|
||||
row *= ((u8g_pb_t *)(dev->dev_mem))->p.page_height;
|
||||
row += delta_row;
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1325_2bit_nhd_27_12864ucy3_prepare_page_seq);
|
||||
|
||||
u8g_WriteByte(u8g, dev, row); /* start at the selected row */
|
||||
u8g_WriteByte(u8g, dev, row+1); /* end within the selected row */
|
||||
|
||||
//u8g_SetAddress(u8g, dev, 0); /* instruction mode mode */
|
||||
//u8g_WriteByte(u8g, dev, 0x05c); /* write to ram */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
}
|
||||
|
||||
static const uint8_t u8g_dev_ssd13xx_sleep_on[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0ae, /* display off */
|
||||
U8G_ESC_CS(1), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_ssd13xx_sleep_off[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
U8G_ESC_CS(1), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
|
||||
static uint8_t u8g_dev_ssd1325_nhd27oled_gr_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1325_2bit_nhd_27_12864ucy3_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
uint8_t i;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
uint8_t *p = pb->buf;
|
||||
u8g_uint_t cnt;
|
||||
cnt = pb->width;
|
||||
cnt >>= 2;
|
||||
|
||||
for( i = 0; i < pb->p.page_height; i++ )
|
||||
{
|
||||
u8g_dev_ssd1325_gr_prepare_row(u8g, dev, i); /* this will also enable chip select */
|
||||
u8g_WriteSequence4LTo16GrDevice(u8g, dev, cnt, p);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
p+=cnt;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb8h2_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static uint8_t u8g_dev_ssd1325_nhd27oled_2x_gr_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1325_2bit_nhd_27_12864ucy3_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
uint8_t i;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
uint8_t *p = pb->buf;
|
||||
u8g_uint_t cnt;
|
||||
cnt = pb->width;
|
||||
cnt >>= 2;
|
||||
|
||||
for( i = 0; i < pb->p.page_height; i++ )
|
||||
{
|
||||
u8g_dev_ssd1325_gr_prepare_row(u8g, dev, i); /* this will also enable chip select */
|
||||
u8g_WriteSequence4LTo16GrDevice(u8g, dev, cnt, p);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
p+=cnt;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb16h2_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
U8G_PB_DEV(u8g_dev_ssd1325_nhd27oled_gr_sw_spi , WIDTH, HEIGHT, 4, u8g_dev_ssd1325_nhd27oled_gr_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_ssd1325_nhd27oled_gr_hw_spi , WIDTH, HEIGHT, 4, u8g_dev_ssd1325_nhd27oled_gr_fn, U8G_COM_HW_SPI);
|
||||
|
||||
uint8_t u8g_dev_ssd1325_nhd27oled_2x_buf[WIDTH*2] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_dev_ssd1325_nhd27oled_2x_pb = { {8, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_ssd1325_nhd27oled_2x_buf};
|
||||
u8g_dev_t u8g_dev_ssd1325_nhd27oled_2x_gr_sw_spi = { u8g_dev_ssd1325_nhd27oled_2x_gr_fn, &u8g_dev_ssd1325_nhd27oled_2x_pb, U8G_COM_SW_SPI };
|
||||
u8g_dev_t u8g_dev_ssd1325_nhd27oled_2x_gr_hw_spi = { u8g_dev_ssd1325_nhd27oled_2x_gr_fn, &u8g_dev_ssd1325_nhd27oled_2x_pb, U8G_COM_HW_SPI };
|
@ -0,0 +1,299 @@
|
||||
/*
|
||||
|
||||
u8g_dev_ssd1327_96x96_gr.c
|
||||
|
||||
2-Bit (graylevel) Driver for SSD1327 Controller (OLED Display)
|
||||
Tested with Seedstudio 96x96 Oled (LY120)
|
||||
http://www.seeedstudio.com/wiki/index.php?title=Twig_-_OLED_96x96
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2012, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
SSD130x Monochrom OLED Controller
|
||||
SSD131x Character OLED Controller
|
||||
SSD132x Graylevel OLED Controller
|
||||
SSD1331 Color OLED Controller
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define WIDTH 96
|
||||
#define HEIGHT 96
|
||||
#define XOFFSET 8
|
||||
|
||||
/*
|
||||
http://www.seeedstudio.com/wiki/index.php?title=Twig_-_OLED_96x96
|
||||
*/
|
||||
static const uint8_t u8g_dev_ssd1327_2bit_96x96_init_seq[] PROGMEM = {
|
||||
U8G_ESC_DLY(10), /* delay 10 ms */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0fd, 0x012, /* unlock display, usually not required because the display is unlocked after reset */
|
||||
0x0ae, /* display off, sleep mode */
|
||||
0x0a8, 0x05f, /* multiplex ratio: 0x05f * 1/64 duty */
|
||||
0x0a1, 0x000, /* display start line */
|
||||
0x0a2, 0x060, /* display offset, shift mapping ram counter */
|
||||
//0x0a2, 0x04c, /* NHD: display offset, shift mapping ram counter */
|
||||
0x0a0, 0x046, /* remap configuration, vertical address increment, enable nibble remap (upper nibble is left) */
|
||||
//0x0a0, 0x056, /* NHD: remap configuration, vertical address increment, enable nibble remap (upper nibble is left) */
|
||||
0x0ab, 0x001, /* Enable internal VDD regulator (RESET) */
|
||||
0x081, 0x053, /* contrast, brightness, 0..128, Newhaven: 0x040, LY120 0x053, 0x070 seems also ok */
|
||||
0x0b1, 0x051, /* phase length */
|
||||
0x0b3, 0x001, /* set display clock divide ratio/oscillator frequency */
|
||||
0x0b9, /* use linear lookup table */
|
||||
#if 0
|
||||
0x0b8, /* set gray scale table */
|
||||
//0x01, 0x011, 0x022, 0x032, 0x043, 0x054, 0x065, 0x076,
|
||||
0x01, 0x011, 0x022, 0x032, 0x043, 0x054, 0x077, 0x077, // 4L mode uses 0, 2, 4, 7
|
||||
#endif
|
||||
0x0bc, 0x008, /* pre-charge voltage level */
|
||||
0x0be, 0x007, /* VCOMH voltage */
|
||||
0x0b6, 0x001, /* second precharge */
|
||||
0x0d5, 0x062, /* enable second precharge, internal vsl (bit0 = 0) */
|
||||
|
||||
#if 0
|
||||
// the following commands are not used by the SeeedGrayOLED sequence */
|
||||
0x0ad, 0x002, /* master configuration: disable embedded DC-DC, enable internal VCOMH */
|
||||
0x086, /* full current range (0x084, 0x085, 0x086) */
|
||||
0x0b2, 0x051, /* frame frequency (row period) */
|
||||
0x0b4, 0x002, /* set pre-charge compensation level (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
|
||||
0x0b0, 0x028, /* enable pre-charge compensation (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
|
||||
0x0bf, 0x002|0x00d, /* VSL voltage level (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
|
||||
#endif
|
||||
|
||||
0x0a5, /* all pixel on */
|
||||
//0x02e, /* no scroll (according to SeeedGrayOLED sequence) */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a4, /* normal display mode */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a5, /* all pixel on */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a4, /* normal display mode */
|
||||
|
||||
0x015, /* column address... */
|
||||
0x008, /* start at column 8, special for the LY120 ??? */
|
||||
0x037, /* end at column 55, note: there are two pixel in one column */
|
||||
|
||||
0x075, /* row address... */
|
||||
0x008,
|
||||
0x05f,
|
||||
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x000f, 0x000f, 0x0000, 0x0000, 0x000f,0x000f,0x0000,0x0000,
|
||||
0x000f, 0x000f, 0x0000, 0x0000, 0x000f,0x000f,0x0000,0x0000,
|
||||
0x000f, 0x000f, 0x0000, 0x0000, 0x000f,0x000f,0x0000,0x0000,
|
||||
0x000f, 0x000f, 0x0000, 0x0000, 0x000f,0x000f,0x0000,0x0000,
|
||||
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_ssd1327_2bit_96x96_prepare_page_seq[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x015, /* column address... */
|
||||
XOFFSET, /* start at column 8, special for the LY120 ??? */
|
||||
0x037, /* end at column 55, note: there are two pixel in one column */
|
||||
0x075, /* row address... */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static void u8g_dev_ssd1327_2bit_prepare_page(u8g_t *u8g, u8g_dev_t *dev)
|
||||
{
|
||||
uint8_t page = ((u8g_pb_t *)(dev->dev_mem))->p.page;
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1327_2bit_96x96_prepare_page_seq);
|
||||
|
||||
page <<= 2;
|
||||
u8g_WriteByte(u8g, dev, page); /* start at the selected page */
|
||||
page += 3;
|
||||
u8g_WriteByte(u8g, dev, page); /* end within the selected page */
|
||||
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
}
|
||||
|
||||
static void u8g_dev_ssd1327_2bit_2x_prepare_page(u8g_t *u8g, u8g_dev_t *dev, uint8_t is_odd)
|
||||
{
|
||||
uint8_t page = ((u8g_pb_t *)(dev->dev_mem))->p.page;
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1327_2bit_96x96_prepare_page_seq);
|
||||
|
||||
page <<= 1;
|
||||
page += is_odd;
|
||||
|
||||
page <<= 2;
|
||||
u8g_WriteByte(u8g, dev, page); /* start at the selected page */
|
||||
page += 3;
|
||||
u8g_WriteByte(u8g, dev, page); /* end within the selected page */
|
||||
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
}
|
||||
|
||||
/* assumes row autoincrement and activated nibble remap */
|
||||
static void u8g_dev_ssd1327_2bit_write_4_pixel(u8g_t *u8g, u8g_dev_t *dev, uint8_t left, uint8_t right)
|
||||
{
|
||||
uint8_t d, tmp, cnt;
|
||||
static uint8_t buf[4];
|
||||
buf[0] = 0;
|
||||
buf[1] = 0;
|
||||
buf[2] = 0;
|
||||
buf[3] = 0;
|
||||
cnt = 0;
|
||||
do
|
||||
{
|
||||
if ( left == 0 && right == 0 )
|
||||
break;
|
||||
d = left;
|
||||
d &= 3;
|
||||
d <<= 4;
|
||||
tmp = right;
|
||||
tmp &= 3;
|
||||
d |= tmp;
|
||||
d <<= 2;
|
||||
buf[cnt] = d;
|
||||
left >>= 2;
|
||||
right >>= 2;
|
||||
cnt++;
|
||||
}while ( cnt < 4 );
|
||||
u8g_WriteSequence(u8g, dev, 4, buf);
|
||||
}
|
||||
|
||||
static void u8g_dev_ssd1327_2bit_write_buffer(u8g_t *u8g, u8g_dev_t *dev)
|
||||
{
|
||||
uint8_t cnt, left, right;
|
||||
uint8_t *ptr;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
cnt = pb->width;
|
||||
cnt >>= 1;
|
||||
ptr = pb->buf;
|
||||
do
|
||||
{
|
||||
left = *ptr++;
|
||||
right = *ptr++;
|
||||
u8g_dev_ssd1327_2bit_write_4_pixel(u8g, dev, left, right);
|
||||
cnt--;
|
||||
} while( cnt > 0 );
|
||||
}
|
||||
|
||||
static void u8g_dev_ssd1327_2bit_2x_write_buffer(u8g_t *u8g, u8g_dev_t *dev, uint8_t is_odd)
|
||||
{
|
||||
uint8_t cnt, left, right;
|
||||
uint8_t *ptr;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
ptr = pb->buf;
|
||||
cnt = pb->width;
|
||||
if ( is_odd )
|
||||
ptr += cnt;
|
||||
cnt >>= 1;
|
||||
do
|
||||
{
|
||||
left = *ptr++;
|
||||
right = *ptr++;
|
||||
u8g_dev_ssd1327_2bit_write_4_pixel(u8g, dev, left, right);
|
||||
cnt--;
|
||||
} while( cnt > 0 );
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_ssd1327_96x96_gr_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1327_2bit_96x96_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_dev_ssd1327_2bit_prepare_page(u8g, dev);
|
||||
u8g_dev_ssd1327_2bit_write_buffer(u8g, dev);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb8v2_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_ssd1327_96x96_2x_gr_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1327_2bit_96x96_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_dev_ssd1327_2bit_2x_prepare_page(u8g, dev, 0);
|
||||
u8g_dev_ssd1327_2bit_2x_write_buffer(u8g, dev, 0);
|
||||
u8g_dev_ssd1327_2bit_2x_prepare_page(u8g, dev, 1);
|
||||
u8g_dev_ssd1327_2bit_2x_write_buffer(u8g, dev, 1);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb16v2_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
U8G_PB_DEV(u8g_dev_ssd1327_96x96_gr_sw_spi , WIDTH, HEIGHT, 4, u8g_dev_ssd1327_96x96_gr_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_ssd1327_96x96_gr_hw_spi , WIDTH, HEIGHT, 4, u8g_dev_ssd1327_96x96_gr_fn, U8G_COM_HW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_ssd1327_96x96_gr_i2c , WIDTH, HEIGHT, 4, u8g_dev_ssd1327_96x96_gr_fn, U8G_COM_SSD_I2C);
|
||||
|
||||
#define DWIDTH (2*WIDTH)
|
||||
uint8_t u8g_dev_ssd1327_96x96_2x_buf[DWIDTH] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_dev_ssd1327_96x96_2x_pb = { {8, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_ssd1327_96x96_2x_buf};
|
||||
u8g_dev_t u8g_dev_ssd1327_96x96_2x_gr_sw_spi = { u8g_dev_ssd1327_96x96_2x_gr_fn, &u8g_dev_ssd1327_96x96_2x_pb, U8G_COM_SW_SPI };
|
||||
u8g_dev_t u8g_dev_ssd1327_96x96_2x_gr_hw_spi = { u8g_dev_ssd1327_96x96_2x_gr_fn, &u8g_dev_ssd1327_96x96_2x_pb, U8G_COM_HW_SPI };
|
||||
u8g_dev_t u8g_dev_ssd1327_96x96_2x_gr_i2c = { u8g_dev_ssd1327_96x96_2x_gr_fn, &u8g_dev_ssd1327_96x96_2x_pb, U8G_COM_SSD_I2C };
|
||||
|
@ -0,0 +1,153 @@
|
||||
/*
|
||||
|
||||
u8g_dev_st7565_64128n.c (Displaytech)
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define WIDTH 128
|
||||
#define HEIGHT 64
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
/* init sequence from https://github.com/adafruit/ST7565-LCD/blob/master/ST7565/ST7565.cpp */
|
||||
static const uint8_t u8g_dev_st7565_64128n_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
U8G_ESC_RST(15), /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
|
||||
|
||||
0x0A2, /* 0x0a2: LCD bias 1/9 (according to Displaytech 64128N datasheet) */
|
||||
0x0A0, /* Normal ADC Select (according to Displaytech 64128N datasheet) */
|
||||
|
||||
0x0c8, /* common output mode: set scan direction normal operation/SHL Select, 0x0c0 --> SHL = 0, normal, 0x0c8 --> SHL = 1 */
|
||||
0x040, /* Display start line for Displaytech 64128N */
|
||||
|
||||
0x028 | 0x04, /* power control: turn on voltage converter */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
|
||||
0x028 | 0x06, /* power control: turn on voltage regulator */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
|
||||
0x028 | 0x07, /* power control: turn on voltage follower */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
|
||||
0x010, /* Set V0 voltage resistor ratio. Setting for controlling brightness of Displaytech 64128N */
|
||||
|
||||
0x0a6, /* display normal, bit val 0: LCD pixel off. */
|
||||
|
||||
0x081, /* set contrast */
|
||||
0x01e, /* Contrast value. Setting for controlling brightness of Displaytech 64128N */
|
||||
|
||||
|
||||
0x0af, /* display on */
|
||||
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a5, /* display all points, ST7565 */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a4, /* normal display */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_st7565_64128n_data_start[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x010, /* set upper 4 bit of the col adr to 0x10 */
|
||||
0x000, /* set lower 4 bit of the col adr to 0x00. Changed for DisplayTech 64128N */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_st7565_64128n_sleep_on[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0ac, /* static indicator off */
|
||||
0x000, /* indicator register set (not sure if this is required) */
|
||||
0x0ae, /* display off */
|
||||
0x0a5, /* all points on */
|
||||
U8G_ESC_CS(1), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_st7565_64128n_sleep_off[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0a4, /* all points off */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
U8G_ESC_CS(1), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_st7565_64128n_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_64128n_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_64128n_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | pb->p.page); /* select current page (ST7565R) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
|
||||
return 0;
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_64128n_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_64128n_sleep_off);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
U8G_PB_DEV(u8g_dev_st7565_64128n_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7565_64128n_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_st7565_64128n_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7565_64128n_fn, U8G_COM_HW_SPI);
|
||||
|
@ -0,0 +1,140 @@
|
||||
/*
|
||||
|
||||
u8g_dev_st7565_dogm128.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define WIDTH 128
|
||||
#define HEIGHT 64
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
const uint8_t u8g_dev_st7565_dogm128_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
|
||||
0x040, /* set display start line */
|
||||
0x0a1, /* ADC set to reverse */
|
||||
0x0c0, /* common output mode: set scan direction normal operation */
|
||||
0x0a6, /* display normal (none reverse) */
|
||||
0x0a2, /* LCD bias 1/9 */
|
||||
0x02f, /* all power control circuits on */
|
||||
0x0f8, /* set booster ratio to */
|
||||
0x000, /* 4x */
|
||||
0x027, /* set V0 voltage resistor ratio to large */
|
||||
0x081, /* set contrast */
|
||||
0x018, /* contrast value, EA default: 0x016 */
|
||||
0x0ac, /* indicator */
|
||||
0x000, /* disable */
|
||||
0x0a4, /* normal display (not all on) */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_st7565_dogm128_data_start[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x010, /* set upper 4 bit of the col adr to 0 */
|
||||
0x000, /* set lower 4 bit of the col adr to 0 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_st7565_dogm128_sleep_on[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0ac, /* static indicator off */
|
||||
0x000, /* indicator register set (not sure if this is required) */
|
||||
0x0ae, /* display off */
|
||||
0x0a5, /* all points on */
|
||||
U8G_ESC_CS(1), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_st7565_dogm128_sleep_off[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0a4, /* all points off */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
U8G_ESC_CS(1), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_st7565_dogm128_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_dogm128_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_dogm128_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | pb->p.page); /* select current page (ST7565R) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
|
||||
return 0;
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_dogm128_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_dogm128_sleep_off);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
U8G_PB_DEV(u8g_dev_st7565_dogm128_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7565_dogm128_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_st7565_dogm128_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7565_dogm128_fn, U8G_COM_HW_SPI);
|
||||
|
||||
|
@ -0,0 +1,157 @@
|
||||
/*
|
||||
|
||||
u8g_dev_st7565_dogm132.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define WIDTH 132
|
||||
#define HEIGHT 32
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
static const uint8_t u8g_dev_st7565_dogm132_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
|
||||
0x040, /* set display start line to 0 */
|
||||
0x0a1, /* ADC set to reverse */
|
||||
0x0c0, /* common output mode */
|
||||
0x0a6, /* display normal, bit val 0: LCD pixel off. */
|
||||
0x0a2, /* LCD bias 1/9 */
|
||||
0x02f, /* all power control circuits on */
|
||||
0x0f8, /* set booster ratio to */
|
||||
0x000, /* 4x */
|
||||
0x023, /* set V0 voltage resistor ratio to large */
|
||||
0x081, /* set contrast */
|
||||
0x01f, /* contrast value, EA default: 0x01f */
|
||||
0x0ac, /* indicator */
|
||||
0x000, /* disable */
|
||||
0x0af, /* display on */
|
||||
|
||||
#ifdef OBSOLETE_DOGM128
|
||||
0x040, /* set display start line */
|
||||
0x0c8, /* set scan direction inverse operation */
|
||||
0x0a2, /* LCD bias 1/9 */
|
||||
0x02f, /* all power control circuits on */
|
||||
0x0f8, /* set booster ratio to */
|
||||
0x000, /* 4x */
|
||||
0x027, /* set V0 voltage resistor ratio to large */
|
||||
0x081, /* set contrast */
|
||||
0x018, /* contrast value, EA default: 0x016 */
|
||||
0x0ac, /* indicator */
|
||||
0x000, /* disable */
|
||||
0x0af, /* display on */
|
||||
#endif
|
||||
|
||||
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a5, /* display all points, ST7565 */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a4, /* normal display */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_st7565_dogm132_data_start[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x010, /* set upper 4 bit of the col adr to 0 */
|
||||
0x000, /* set lower 4 bit of the col adr to 0 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_st7565_dogm132_sleep_on[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0ac, /* static indicator off */
|
||||
0x000, /* indicator register set (not sure if this is required) */
|
||||
0x0ae, /* display off */
|
||||
0x0a5, /* all points on */
|
||||
U8G_ESC_CS(1), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_st7565_dogm132_sleep_off[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0a4, /* all points off */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
U8G_ESC_CS(1), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_st7565_dogm132_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_dogm132_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_dogm132_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | pb->p.page); /* select current page (ST7565R) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
|
||||
return 0;
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_dogm132_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_dogm132_sleep_off);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
U8G_PB_DEV(u8g_dev_st7565_dogm132_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7565_dogm132_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_st7565_dogm132_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7565_dogm132_fn, U8G_COM_HW_SPI);
|
@ -0,0 +1,157 @@
|
||||
/*
|
||||
|
||||
u8g_dev_st7565_lm6059.c (Adafruit display)
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define WIDTH 128
|
||||
#define HEIGHT 64
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
/* init sequence from https://github.com/adafruit/ST7565-LCD/blob/master/ST7565/ST7565.cpp */
|
||||
static const uint8_t u8g_dev_st7565_lm6059_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
U8G_ESC_RST(15), /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
|
||||
|
||||
0x0a3, /* 0x0a2: LCD bias 1/9 (suggested for the LM6063), 0x0a3: Used by Adafruit, 0x0a2 does not work */
|
||||
/* the LM6059 vs LM6063, ADC and SHL have inverted settings */
|
||||
0x0a0, /* 0x0a1: ADC set to normal (suggested for the LM6059), 0x0a0: Used by Adafruit -> normal mode */
|
||||
0x0c8, /* common output mode: set scan direction normal operation/SHL Select, 0x0c0 --> SHL = 0, normal, 0x0c8 --> SHL = 1 */
|
||||
0x060, /* set display start line */
|
||||
|
||||
0x028 | 0x04, /* power control: turn on voltage converter */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
|
||||
0x028 | 0x06, /* power control: turn on voltage regulator */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
|
||||
0x028 | 0x07, /* power control: turn on voltage follower */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
|
||||
0x026, /* set V0 voltage resistor ratio to 6 (Adafruit Value, no info from LM6063 Manual) */
|
||||
|
||||
0x0a6, /* display normal, bit val 0: LCD pixel off. */
|
||||
|
||||
0x081, /* set contrast */
|
||||
0x018, /* contrast value*/
|
||||
|
||||
/*0x0ac,*/ /* indicator */
|
||||
/*0x000,*/ /* disable */
|
||||
|
||||
0x0af, /* display on */
|
||||
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a5, /* display all points, ST7565 */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a4, /* normal display */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_st7565_lm6059_data_start[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x010, /* set upper 4 bit of the col adr to 0 */
|
||||
0x001, /* set lower 4 bit of the col adr */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_st7565_lm6059_sleep_on[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0ac, /* static indicator off */
|
||||
0x000, /* indicator register set (not sure if this is required) */
|
||||
0x0ae, /* display off */
|
||||
0x0a5, /* all points on */
|
||||
U8G_ESC_CS(1), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_st7565_lm6059_sleep_off[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0a4, /* all points off */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
U8G_ESC_CS(1), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
uint8_t u8g_dev_st7565_lm6059_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_lm6059_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_lm6059_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | pb->p.page); /* select current page (ST7565R) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
|
||||
return 0;
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_lm6059_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_lm6059_sleep_off);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
U8G_PB_DEV(u8g_dev_st7565_lm6059_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7565_lm6059_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_st7565_lm6059_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7565_lm6059_fn, U8G_COM_HW_SPI);
|
||||
|
||||
|
@ -0,0 +1,188 @@
|
||||
/*
|
||||
|
||||
u8g_dev_st7565_lm6063.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define WIDTH 128
|
||||
#define HEIGHT 64
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
#ifdef OLD_ADAFRUIT_CODE
|
||||
static const uint8_t OLD_u8g_dev_st7565_lm6063_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
|
||||
0x040, /* set display start line */
|
||||
0x0a1, /* ADC set to reverse */
|
||||
0x0c8, /* common output mode: set scan direction normal operation/SHL Select / 17 Jan: seems to be a bug, must be 0x0c0 */
|
||||
0x0a6, /* display normal, bit val 0: LCD pixel off. */
|
||||
0x0a2, /* LCD bias 1/9 */
|
||||
0x02f, /* all power control circuits on */
|
||||
/*0x0f8,*/ /* set booster ratio to */
|
||||
/*0x000, */ /* 4x */
|
||||
/*0x027,*/ /* set V0 voltage resistor ratio to large */
|
||||
0x081, /* set contrast */
|
||||
0x018, /* contrast value*/
|
||||
0x0ac, /* indicator */
|
||||
0x000, /* disable */
|
||||
0x0af, /* display on */
|
||||
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a5, /* display all points, ST7565 */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a4, /* normal display */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
#endif
|
||||
|
||||
/* init sequence from https://github.com/adafruit/ST7565-LCD/blob/master/ST7565/ST7565.cpp */
|
||||
static const uint8_t u8g_dev_st7565_lm6063_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
U8G_ESC_RST(15), /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
|
||||
|
||||
0x0a3, /* 0x0a2: LCD bias 1/9 (suggested for the LM6063), 0x0a3: Used by Adafruit */
|
||||
0x0a1, /* 0x0a1: ADC set to reverse (suggested for the LM6063), 0x0a0: Used by Adafruit -> normal mode */
|
||||
0x0c0, /* common output mode: set scan direction normal operation/SHL Select, 0x0c0 --> SHL = 0, normal, 0x0c8 --> SHL = 1 */
|
||||
0x040, /* set display start line */
|
||||
|
||||
0x028 | 0x04, /* power control: turn on voltage converter */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
|
||||
0x028 | 0x06, /* power control: turn on voltage regulator */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
|
||||
0x028 | 0x07, /* power control: turn on voltage follower */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
|
||||
0x026, /* set V0 voltage resistor ratio to 6 (Adafruit Value, no info from LM6063 Manual) */
|
||||
|
||||
0x0a6, /* display normal, bit val 0: LCD pixel off. */
|
||||
|
||||
0x081, /* set contrast */
|
||||
0x018, /* contrast value*/
|
||||
|
||||
/*0x0ac,*/ /* indicator */
|
||||
/*0x000,*/ /* disable */
|
||||
|
||||
0x0af, /* display on */
|
||||
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a5, /* display all points, ST7565 */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a4, /* normal display */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_st7565_lm6063_data_start[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x010, /* set upper 4 bit of the col adr to 0 */
|
||||
0x000, /* set lower 4 bit of the col adr to 0 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_st7565_st7565_sleep_on[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0ac, /* static indicator off */
|
||||
0x000, /* indicator register set (not sure if this is required) */
|
||||
0x0ae, /* display off */
|
||||
0x0a5, /* all points on */
|
||||
U8G_ESC_CS(1), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_st7565_st7565_sleep_off[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0a4, /* all points off */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
U8G_ESC_CS(1), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
uint8_t u8g_dev_st7565_lm6063_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_lm6063_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_lm6063_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | pb->p.page); /* select current page (ST7565R) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
|
||||
return 0;
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_st7565_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_st7565_sleep_off);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
U8G_PB_DEV(u8g_dev_st7565_lm6063_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7565_lm6063_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_st7565_lm6063_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7565_lm6063_fn, U8G_COM_HW_SPI);
|
||||
|
||||
|
@ -0,0 +1,143 @@
|
||||
/*
|
||||
|
||||
u8g_dev_st7565_nhd_c12832.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define WIDTH 128
|
||||
#define HEIGHT 32
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
static const uint8_t u8g_dev_st7565_c12832_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
|
||||
0x040, /* set display start line to 0 */
|
||||
0x0a0, /* ADC set, values: a0=normal, a1=reverse */
|
||||
0x0c8, /* common output mode: c0=normal, c8=reverse */
|
||||
0x0a6, /* display normal, bit val 0: LCD pixel off. */
|
||||
0x0a2, /* LCD bias 1/9 */
|
||||
0x02f, /* all power control circuits on */
|
||||
0x0f8, /* set booster ratio to */
|
||||
0x000, /* 4x */
|
||||
0x023, /* set V0 voltage resistor ratio to large */
|
||||
0x081, /* set contrast */
|
||||
0x00a, /* contrast value */
|
||||
0x0ac, /* indicator */
|
||||
0x000, /* disable */
|
||||
0x0af, /* display on */
|
||||
|
||||
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a5, /* display all points, ST7565 */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a4, /* normal display */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_st7565_c12832_data_start[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x010, /* set upper 4 bit of the col adr to 0 */
|
||||
0x000, /* set lower 4 bit of the col adr to 0 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_st7565_c12832_sleep_on[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0ac, /* static indicator off */
|
||||
0x000, /* indicator register set (not sure if this is required) */
|
||||
0x0ae, /* display off */
|
||||
0x0a5, /* all points on */
|
||||
U8G_ESC_CS(1), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_st7565_c12832_sleep_off[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0a4, /* all points off */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
U8G_ESC_CS(1), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_st7565_c12832_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_c12832_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_c12832_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | pb->p.page); /* select current page (ST7565R) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
|
||||
return 0;
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_c12832_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_c12832_sleep_off);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
U8G_PB_DEV(u8g_dev_st7565_nhd_c12832_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7565_c12832_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_st7565_nhd_c12832_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7565_c12832_fn, U8G_COM_HW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_st7565_nhd_c12832_parallel, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7565_c12832_fn, U8G_COM_PARALLEL);
|
@ -0,0 +1,145 @@
|
||||
/*
|
||||
|
||||
u8g_dev_st7565_nhd_c12864.c
|
||||
|
||||
Support for the NHD-C12864A1Z-FSB-FBW (Newhaven Display)
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2012, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define WIDTH 128
|
||||
#define HEIGHT 64
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
const uint8_t u8g_dev_st7565_nhd_c12864_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(10), /* do reset low pulse with (10*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
|
||||
0x040, /* set display start line */
|
||||
0x0a1, /* ADC set to reverse */
|
||||
0x0c0, /* common output mode: set scan direction normal operation */
|
||||
0x0a6, /* display normal, bit val 0: LCD pixel off. */
|
||||
0x0a2, /* LCD bias 1/9 */
|
||||
0x02f, /* all power control circuits on */
|
||||
0x0f8, /* set booster ratio to */
|
||||
0x000, /* 4x */
|
||||
0x027, /* set V0 voltage resistor ratio to large */
|
||||
0x081, /* set contrast */
|
||||
0x008, /* contrast: 0x008 is a good value for NHD C12864, Nov 2012: User reports that 0x1a is much better */
|
||||
0x0ac, /* indicator */
|
||||
0x000, /* disable */
|
||||
0x0af, /* display on */
|
||||
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a5, /* display all points, ST7565 */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a4, /* normal display */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_st7565_nhd_c12864_data_start[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x010, /* set upper 4 bit of the col adr to 0 */
|
||||
0x004, /* set lower 4 bit of the col adr to 4 (NHD C12864) */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_st7565_c12864_sleep_on[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0ac, /* static indicator off */
|
||||
0x000, /* indicator register set (not sure if this is required) */
|
||||
0x0ae, /* display off */
|
||||
0x0a5, /* all points on */
|
||||
U8G_ESC_CS(1), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_st7565_c12864_sleep_off[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0a4, /* all points off */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
U8G_ESC_CS(1), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_st7565_nhd_c12864_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_nhd_c12864_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_nhd_c12864_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | pb->p.page); /* select current page (ST7565R) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
|
||||
return 0;
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_c12864_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_c12864_sleep_off);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
U8G_PB_DEV(u8g_dev_st7565_nhd_c12864_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7565_nhd_c12864_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_st7565_nhd_c12864_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7565_nhd_c12864_fn, U8G_COM_HW_SPI);
|
||||
|
||||
|
@ -0,0 +1,420 @@
|
||||
/*
|
||||
|
||||
u8g_dev_st7687_c144mvgd.c (1.44" TFT)
|
||||
|
||||
Status: Started, but not finished
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2012, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define WIDTH 128
|
||||
#define HEIGHT 128
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
|
||||
#ifdef FIRST_VERSION
|
||||
/*
|
||||
see also: read.pudn.com/downloads115/sourcecode/app/484503/LCM_Display.c__.htm
|
||||
http://en.pudn.com/downloads115/sourcecode/app/detail484503_en.html
|
||||
*/
|
||||
|
||||
static const uint8_t u8g_dev_st7687_c144mvgd_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
U8G_ESC_RST(15), /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
|
||||
|
||||
0x001, /* A0=0, SW reset */
|
||||
U8G_ESC_DLY(200), /* delay 200 ms */
|
||||
|
||||
0x0d7, /* EEPROM data auto re-load control */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x09f, /* ARD = 1 */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
|
||||
0x0e0, /* EEPROM control in */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x000, /* */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
|
||||
#ifdef NOT_REQUIRED
|
||||
0x0fa, /* EEPROM function selection 8.1.66 */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x000, /* */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
#endif
|
||||
|
||||
0x0e3, /* Read from EEPROM, 8.1.55 */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
|
||||
0x0e1, /* EEPROM control out, 8.1.53 */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
|
||||
//0x028, /* display off */
|
||||
0x011, /* Sleep out & booster on */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
|
||||
0x0c0, /* Vop setting, 8.1.42 */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x000, /* */
|
||||
0x001, /* 3.6 + 256*0.04 = 13.84 Volt */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
|
||||
0x0c3, /* Bias selection, 8.1.45 */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x003,
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
0x0c4, /* Booster setting 8.1.46 */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x007,
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
0x0c5, /* ??? */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x001,
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
0x0cb, /* FV3 with Booster x2 control, 8.1.47 */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x001,
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
0x036, /* Memory data access control, 8.1.28 */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x080,
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
0x0b5, /* N-line control, 8.1.37 */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x089,
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
|
||||
0x0d0, /* Analog circuit setting, 8.1.49 */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x01d,
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
0x0b7, /* Com/Seg Scan Direction, 8.1.38 */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x040,
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
0x025, /* Write contrast, 8.1.17 */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x03f,
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
0x03a, /* Interface pixel format, 8.1.32 */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x004, /* 3: 12 bit per pixel Type A, 4: 12 bit Type B, 5: 16bit per pixel */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
0x0b0, /* Display Duty setting, 8.1.34 */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x07f,
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
0x0f0, /* Frame Freq. in Temp range A,B,C and D, 8.1.59 */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x007,
|
||||
0x00c,
|
||||
0x00c,
|
||||
0x015,
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
0x0f9, /* Frame RGB Value, 8.1.65 */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x000,
|
||||
0x005,
|
||||
0x008,
|
||||
0x00a,
|
||||
0x00c,
|
||||
0x00e,
|
||||
0x010,
|
||||
0x011,
|
||||
0x012,
|
||||
0x013,
|
||||
0x014,
|
||||
0x015,
|
||||
0x016,
|
||||
0x018,
|
||||
0x01a,
|
||||
0x01b,
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
0x0f9, /* Frame RGB Value, 8.1.65 */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x000,
|
||||
0x000,
|
||||
0x000,
|
||||
0x000,
|
||||
0x033,
|
||||
0x055,
|
||||
0x055,
|
||||
0x055,
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
0x029, /* display on */
|
||||
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
/*
|
||||
http://www.waitingforfriday.com/images/e/e3/FTM144D01N_test.zip
|
||||
*/
|
||||
|
||||
static const uint8_t u8g_dev_st7687_c144mvgd_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
U8G_ESC_RST(15), /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
|
||||
|
||||
0x011, /* Sleep out & booster on */
|
||||
U8G_ESC_DLY(5), /* delay 5 ms */
|
||||
|
||||
0x03a, /* Interface pixel format, 8.1.32 */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x004, /* 3: 12 bit per pixel Type A, 4: 12 bit Type B, 5: 16bit per pixel */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
|
||||
0x026, /* SET_GAMMA_CURVE */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x004,
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
0x0f2, /* GAM_R_SEL */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x001, /* enable gamma adj */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
|
||||
0x0e0, /* POSITIVE_GAMMA_CORRECT */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x3f,
|
||||
0x25,
|
||||
0x1c,
|
||||
0x1e,
|
||||
0x20,
|
||||
0x12,
|
||||
0x2a,
|
||||
0x90,
|
||||
0x24,
|
||||
0x11,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
0x0e1, /* NEGATIVE_GAMMA_CORRECT */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x20,
|
||||
0x20,
|
||||
0x20,
|
||||
0x20,
|
||||
0x05,
|
||||
0x00,
|
||||
0x15,
|
||||
0xa7,
|
||||
0x3d,
|
||||
0x18,
|
||||
0x25,
|
||||
0x2a,
|
||||
0x2b,
|
||||
0x2b,
|
||||
0x3a,
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
0x0b1, /* FRAME_RATE_CONTROL1 */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x008, /* DIVA = 8 */
|
||||
0x008, /* VPA = 8 */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
|
||||
0x0b4, /* DISPLAY_INVERSION */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x007, /* NLA = 1, NLB = 1, NLC = 1 (all on Frame Inversion) */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
0x0c0, /* POWER_CONTROL1 */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x00a, /* VRH = 10: GVDD = 4.30 */
|
||||
0x002, /* VC = 2: VCI1 = 2.65 */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
0x0c1, /* POWER_CONTROL2 */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x002, /* BT = 2: AVDD = 2xVCI1, VCL = -1xVCI1, VGH = 5xVCI1, VGL = -2xVCI1 */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
0x0c5, /* VCOM_CONTROL1 */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x050, /* VMH = 80: VCOMH voltage = 4.5 */
|
||||
0x05b, /* VML = 91: VCOML voltage = -0.225 */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
0x0c7, /* VCOM_OFFSET_CONTROL */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x040, /* nVM = 0, VMF = 64: VCOMH output = VMH, VCOML output = VML */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
0x02a, /* SET_COLUMN_ADDRESS */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x000, /* */
|
||||
0x000, /* */
|
||||
0x000, /* */
|
||||
0x07f, /* */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
0x02b, /* SET_PAGE_ADDRESS */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x000, /* */
|
||||
0x000, /* */
|
||||
0x000, /* */
|
||||
0x07f, /* */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
0x036, /* SET_ADDRESS_MODE */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x000, /* Select display orientation */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
|
||||
0x029, /* display on */
|
||||
|
||||
0x02c, /* write start */
|
||||
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
/* calculate bytes for Type B 4096 color display */
|
||||
static uint8_t get_byte_1(uint8_t v)
|
||||
{
|
||||
v >>= 4;
|
||||
v &= 0x0e;
|
||||
return v;
|
||||
}
|
||||
|
||||
static uint8_t get_byte_2(uint8_t v)
|
||||
{
|
||||
uint8_t w;
|
||||
w = v;
|
||||
w &= 3;
|
||||
w = (w<<2) | w;
|
||||
v <<= 3;
|
||||
v &= 0x0e0;
|
||||
w |= v;
|
||||
return w;
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_st7687_c144mvgd_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7687_c144mvgd_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
uint8_t y, i, j;
|
||||
uint8_t *ptr;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
u8g_SetAddress(u8g, dev, 0); /* cmd mode */
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
y = pb->p.page_y0;
|
||||
ptr = pb->buf;
|
||||
|
||||
u8g_SetAddress(u8g, dev, 0); /* cmd mode */
|
||||
u8g_WriteByte(u8g, dev, 0x02a ); /* Column address set 8.1.20 */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteByte(u8g, dev, 0x000 ); /* x0 */
|
||||
u8g_WriteByte(u8g, dev, WIDTH-1 ); /* x1 */
|
||||
u8g_SetAddress(u8g, dev, 0); /* cmd mode */
|
||||
u8g_WriteByte(u8g, dev, 0x02b ); /* Row address set 8.1.21 */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteByte(u8g, dev, y ); /* y0 */
|
||||
u8g_WriteByte(u8g, dev, y+PAGE_HEIGHT-1 ); /* y1 */
|
||||
u8g_SetAddress(u8g, dev, 0); /* cmd mode */
|
||||
u8g_WriteByte(u8g, dev, 0x02c ); /* Memory write 8.1.22 */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
|
||||
for( i = 0; i < PAGE_HEIGHT; i ++ )
|
||||
{
|
||||
|
||||
for( j = 0; j < WIDTH; j ++ )
|
||||
{
|
||||
u8g_WriteByte(u8g, dev, get_byte_1(*ptr) );
|
||||
u8g_WriteByte(u8g, dev, get_byte_2(*ptr) );
|
||||
ptr++;
|
||||
}
|
||||
}
|
||||
u8g_SetAddress(u8g, dev, 0); /* cmd mode */
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return u8g_dev_pb8h8_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
|
||||
uint8_t u8g_st7687_c144mvgd_8h8_buf[WIDTH*8] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_st7687_c144mvgd_8h8_pb = { {8, HEIGHT, 0, 0, 0}, WIDTH, u8g_st7687_c144mvgd_8h8_buf};
|
||||
|
||||
u8g_dev_t u8g_dev_st7687_c144mvgd_sw_spi = { u8g_dev_st7687_c144mvgd_fn, &u8g_st7687_c144mvgd_8h8_pb, u8g_com_arduino_sw_spi_fn };
|
||||
|
||||
u8g_dev_t u8g_dev_st7687_c144mvgd_8bit = { u8g_dev_st7687_c144mvgd_fn, &u8g_st7687_c144mvgd_8h8_pb, U8G_COM_PARALLEL };
|
@ -0,0 +1,171 @@
|
||||
/*
|
||||
|
||||
u8g_dev_st7565_128x64.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define WIDTH 128
|
||||
#define HEIGHT 64
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
|
||||
/* init sequence from https://github.com/adafruit/ST7565-LCD/blob/master/ST7565/ST7565.cpp */
|
||||
static const uint8_t u8g_dev_st7920_128x64_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(15), /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
|
||||
U8G_ESC_DLY(100), /* 8 Dez 2012: additional delay 100 ms because of reset*/
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
|
||||
0x038, /* 8 Bit interface (DL=1), basic instruction set (RE=0) */
|
||||
0x00c, /* display on, cursor & blink off; 0x08: all off */
|
||||
0x006, /* Entry mode: Cursor move to right ,DDRAM address counter (AC) plus 1, no shift */
|
||||
0x002, /* disable scroll, enable CGRAM adress */
|
||||
0x001, /* clear RAM, needs 1.6 ms */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_st7920_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7920_128x64_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
uint8_t y, i;
|
||||
uint8_t *ptr;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
u8g_SetAddress(u8g, dev, 0); /* cmd mode */
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
y = pb->p.page_y0;
|
||||
ptr = pb->buf;
|
||||
for( i = 0; i < 8; i ++ )
|
||||
{
|
||||
u8g_SetAddress(u8g, dev, 0); /* cmd mode */
|
||||
u8g_WriteByte(u8g, dev, 0x03e ); /* enable extended mode */
|
||||
|
||||
if ( y < 32 )
|
||||
{
|
||||
u8g_WriteByte(u8g, dev, 0x080 | y ); /* y pos */
|
||||
u8g_WriteByte(u8g, dev, 0x080 ); /* set x pos to 0*/
|
||||
}
|
||||
else
|
||||
{
|
||||
u8g_WriteByte(u8g, dev, 0x080 | (y-32) ); /* y pos */
|
||||
u8g_WriteByte(u8g, dev, 0x080 | 8); /* set x pos to 64*/
|
||||
}
|
||||
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, WIDTH/8, ptr);
|
||||
ptr += WIDTH/8;
|
||||
y++;
|
||||
}
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return u8g_dev_pb8h1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_st7920_128x64_4x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7920_128x64_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
uint8_t y, i;
|
||||
uint8_t *ptr;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
u8g_SetAddress(u8g, dev, 0); /* cmd mode */
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
y = pb->p.page_y0;
|
||||
ptr = pb->buf;
|
||||
for( i = 0; i < 32; i ++ )
|
||||
{
|
||||
u8g_SetAddress(u8g, dev, 0); /* cmd mode */
|
||||
u8g_WriteByte(u8g, dev, 0x03e ); /* enable extended mode */
|
||||
|
||||
if ( y < 32 )
|
||||
{
|
||||
u8g_WriteByte(u8g, dev, 0x080 | y ); /* y pos */
|
||||
u8g_WriteByte(u8g, dev, 0x080 ); /* set x pos to 0*/
|
||||
}
|
||||
else
|
||||
{
|
||||
u8g_WriteByte(u8g, dev, 0x080 | (y-32) ); /* y pos */
|
||||
u8g_WriteByte(u8g, dev, 0x080 | 8); /* set x pos to 64*/
|
||||
}
|
||||
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, WIDTH/8, ptr);
|
||||
ptr += WIDTH/8;
|
||||
y++;
|
||||
}
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return u8g_dev_pb32h1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
U8G_PB_DEV(u8g_dev_st7920_128x64_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7920_128x64_fn, U8G_COM_ST7920_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_st7920_128x64_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7920_128x64_fn, U8G_COM_ST7920_HW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_st7920_128x64_8bit, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7920_128x64_fn, U8G_COM_FAST_PARALLEL);
|
||||
|
||||
#define QWIDTH (WIDTH*4)
|
||||
uint8_t u8g_dev_st7920_128x64_4x_buf[QWIDTH] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_dev_st7920_128x64_4x_pb = { {32, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_st7920_128x64_4x_buf};
|
||||
u8g_dev_t u8g_dev_st7920_128x64_4x_sw_spi = { u8g_dev_st7920_128x64_4x_fn, &u8g_dev_st7920_128x64_4x_pb, U8G_COM_ST7920_SW_SPI };
|
||||
u8g_dev_t u8g_dev_st7920_128x64_4x_hw_spi = { u8g_dev_st7920_128x64_4x_fn, &u8g_dev_st7920_128x64_4x_pb, U8G_COM_ST7920_HW_SPI };
|
||||
u8g_dev_t u8g_dev_st7920_128x64_4x_8bit = { u8g_dev_st7920_128x64_4x_fn, &u8g_dev_st7920_128x64_4x_pb, U8G_COM_FAST_PARALLEL };
|
||||
|
||||
|
@ -0,0 +1,151 @@
|
||||
/*
|
||||
|
||||
u8g_dev_st7920_192x32.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define WIDTH 192
|
||||
#define HEIGHT 32
|
||||
|
||||
|
||||
/* init sequence from https://github.com/adafruit/ST7565-LCD/blob/master/ST7565/ST7565.cpp */
|
||||
static const uint8_t u8g_dev_st7920_192x32_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(15), /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
|
||||
U8G_ESC_DLY(100), /* 8 Dez 2012: additional delay 100 ms because of reset*/
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
|
||||
0x038, /* 8 Bit interface (DL=1), basic instruction set (RE=0) */
|
||||
0x00c, /* display on, cursor & blink off; 0x08: all off */
|
||||
0x006, /* Entry mode: Cursor move to right ,DDRAM address counter (AC) plus 1, no shift */
|
||||
0x002, /* disable scroll, enable CGRAM adress */
|
||||
0x001, /* clear RAM, needs 1.6 ms */
|
||||
U8G_ESC_DLY(100), /* delay 10 ms */
|
||||
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_st7920_192x32_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7920_192x32_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
uint8_t y, i;
|
||||
uint8_t *ptr;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
u8g_SetAddress(u8g, dev, 0); /* cmd mode */
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
y = pb->p.page_y0;
|
||||
ptr = pb->buf;
|
||||
for( i = 0; i < 8; i ++ )
|
||||
{
|
||||
u8g_SetAddress(u8g, dev, 0); /* cmd mode */
|
||||
u8g_WriteByte(u8g, dev, 0x03e ); /* enable extended mode */
|
||||
u8g_WriteByte(u8g, dev, 0x080 | y ); /* y pos */
|
||||
u8g_WriteByte(u8g, dev, 0x080 ); /* set x pos to 0*/
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, WIDTH/8, ptr);
|
||||
ptr += WIDTH/8;
|
||||
y++;
|
||||
}
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return u8g_dev_pb8h1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_st7920_192x32_4x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7920_192x32_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
uint8_t y, i;
|
||||
uint8_t *ptr;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
u8g_SetAddress(u8g, dev, 0); /* cmd mode */
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
y = pb->p.page_y0;
|
||||
ptr = pb->buf;
|
||||
for( i = 0; i < 32; i ++ )
|
||||
{
|
||||
u8g_SetAddress(u8g, dev, 0); /* cmd mode */
|
||||
u8g_WriteByte(u8g, dev, 0x03e ); /* enable extended mode */
|
||||
u8g_WriteByte(u8g, dev, 0x080 | y ); /* y pos */
|
||||
u8g_WriteByte(u8g, dev, 0x080 ); /* set x pos to 0*/
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, WIDTH/8, ptr);
|
||||
ptr += WIDTH/8;
|
||||
y++;
|
||||
}
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return u8g_dev_pb32h1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
|
||||
U8G_PB_DEV(u8g_dev_st7920_192x32_sw_spi, WIDTH, HEIGHT, 8, u8g_dev_st7920_192x32_fn, U8G_COM_ST7920_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_st7920_192x32_hw_spi, WIDTH, HEIGHT, 8, u8g_dev_st7920_192x32_fn, U8G_COM_ST7920_HW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_st7920_192x32_8bit, WIDTH, HEIGHT, 8, u8g_dev_st7920_192x32_fn, U8G_COM_FAST_PARALLEL);
|
||||
|
||||
|
||||
#define QWIDTH (WIDTH*4)
|
||||
uint8_t u8g_dev_st7920_192x32_4x_buf[QWIDTH] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_dev_st7920_192x32_4x_pb = { {32, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_st7920_192x32_4x_buf};
|
||||
u8g_dev_t u8g_dev_st7920_192x32_4x_sw_spi = { u8g_dev_st7920_192x32_4x_fn, &u8g_dev_st7920_192x32_4x_pb, U8G_COM_ST7920_SW_SPI };
|
||||
u8g_dev_t u8g_dev_st7920_192x32_4x_hw_spi = { u8g_dev_st7920_192x32_4x_fn, &u8g_dev_st7920_192x32_4x_pb, U8G_COM_ST7920_HW_SPI };
|
||||
u8g_dev_t u8g_dev_st7920_192x32_4x_8bit = { u8g_dev_st7920_192x32_4x_fn, &u8g_dev_st7920_192x32_4x_pb, U8G_COM_FAST_PARALLEL };
|
||||
|
@ -0,0 +1,154 @@
|
||||
/*
|
||||
|
||||
u8g_dev_st7920_202x32.c
|
||||
tested with CFAG20232
|
||||
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define WIDTH 202
|
||||
#define HEIGHT 32
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
|
||||
/* init sequence from https://github.com/adafruit/ST7565-LCD/blob/master/ST7565/ST7565.cpp */
|
||||
static const uint8_t u8g_dev_st7920_202x32_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(15), /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
|
||||
U8G_ESC_DLY(100), /* 8 Dez 2012: additional delay 100 ms because of reset*/
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
|
||||
0x038, /* 8 Bit interface (DL=1), basic instruction set (RE=0) */
|
||||
0x00c, /* display on, cursor & blink off; 0x08: all off */
|
||||
0x006, /* Entry mode: Cursor move to right ,DDRAM address counter (AC) plus 1, no shift */
|
||||
0x002, /* disable scroll, enable CGRAM adress */
|
||||
0x001, /* clear RAM, needs 1.6 ms */
|
||||
U8G_ESC_DLY(100), /* delay 10 ms */
|
||||
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_st7920_202x32_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7920_202x32_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
uint8_t y, i;
|
||||
uint8_t *ptr;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
u8g_SetAddress(u8g, dev, 0); /* cmd mode */
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
y = pb->p.page_y0;
|
||||
ptr = pb->buf;
|
||||
for( i = 0; i < 8; i ++ )
|
||||
{
|
||||
u8g_SetAddress(u8g, dev, 0); /* cmd mode */
|
||||
u8g_WriteByte(u8g, dev, 0x03e ); /* enable extended mode */
|
||||
u8g_WriteByte(u8g, dev, 0x080 | y ); /* y pos */
|
||||
u8g_WriteByte(u8g, dev, 0x080 ); /* set x pos to 0*/
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, WIDTH/8, ptr);
|
||||
ptr += WIDTH/8;
|
||||
y++;
|
||||
}
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return u8g_dev_pb8h1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_st7920_202x32_4x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7920_202x32_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
uint8_t y, i;
|
||||
uint8_t *ptr;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
u8g_SetAddress(u8g, dev, 0); /* cmd mode */
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
y = pb->p.page_y0;
|
||||
ptr = pb->buf;
|
||||
for( i = 0; i < 32; i ++ )
|
||||
{
|
||||
u8g_SetAddress(u8g, dev, 0); /* cmd mode */
|
||||
u8g_WriteByte(u8g, dev, 0x03e ); /* enable extended mode */
|
||||
u8g_WriteByte(u8g, dev, 0x080 | y ); /* y pos */
|
||||
u8g_WriteByte(u8g, dev, 0x080 ); /* set x pos to 0*/
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, WIDTH/8, ptr);
|
||||
ptr += WIDTH/8;
|
||||
y++;
|
||||
}
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return u8g_dev_pb32h1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
|
||||
U8G_PB_DEV(u8g_dev_st7920_202x32_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7920_202x32_fn, U8G_COM_ST7920_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_st7920_202x32_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7920_202x32_fn, U8G_COM_ST7920_HW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_st7920_202x32_8bit, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7920_202x32_fn, U8G_COM_FAST_PARALLEL);
|
||||
|
||||
#define QWIDTH (WIDTH*4)
|
||||
uint8_t u8g_dev_st7920_202x32_4x_buf[QWIDTH] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_dev_st7920_202x32_4x_pb = { {32, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_st7920_202x32_4x_buf};
|
||||
u8g_dev_t u8g_dev_st7920_202x32_4x_sw_spi = { u8g_dev_st7920_202x32_4x_fn, &u8g_dev_st7920_202x32_4x_pb, U8G_COM_ST7920_SW_SPI };
|
||||
u8g_dev_t u8g_dev_st7920_202x32_4x_hw_spi = { u8g_dev_st7920_202x32_4x_fn, &u8g_dev_st7920_202x32_4x_pb, U8G_COM_ST7920_HW_SPI };
|
||||
u8g_dev_t u8g_dev_st7920_202x32_4x_8bit = { u8g_dev_st7920_202x32_4x_fn, &u8g_dev_st7920_202x32_4x_pb, U8G_COM_FAST_PARALLEL };
|
||||
|
||||
|
@ -0,0 +1,191 @@
|
||||
/*
|
||||
|
||||
u8g_dev_t6963_128x64.c
|
||||
|
||||
Tested with Varitronix MGLS240128TZ
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2013, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
Application Notes for the MGLS 240x128
|
||||
www.baso.no/content/pdf/T6963C_Application.pdf
|
||||
|
||||
Hitachi App Notes:
|
||||
https://www.sparkfun.com/datasheets/LCD/Monochrome/AN-029-Toshiba_T6963C.pdf
|
||||
|
||||
Notes:
|
||||
The font selection pins should generate the 8x8 font.
|
||||
For the MGLS240128TZ only FS1 is available on pin 18.
|
||||
FS1 must be low to generate the 8x8 font.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define WIDTH 128
|
||||
#define HEIGHT 64
|
||||
#define PAGE_HEIGHT 16
|
||||
|
||||
|
||||
/* text is not used, so settings are not relevant */
|
||||
static const uint8_t u8g_dev_t6963_128x64_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
U8G_ESC_RST(15), /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
|
||||
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x000, /* low byte */
|
||||
0x000, /* height byte */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x021, /* set cursor position */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x000, /* low byte */
|
||||
0x000, /* height byte */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x022, /* set offset */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x000, /* low byte */
|
||||
0x000, /* height byte */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x040, /* text home */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
WIDTH/8, /* low byte */
|
||||
0x000, /* height byte */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x041, /* text columns */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x000, /* low byte */
|
||||
0x000, /* height byte */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x042, /* graphics home */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
WIDTH/8, /* low byte */
|
||||
0x000, /* height byte */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x043, /* graphics columns */
|
||||
|
||||
// mode set
|
||||
// 0x080: Internal CG, OR Mode
|
||||
// 0x081: Internal CG, EXOR Mode
|
||||
// 0x083: Internal CG, AND Mode
|
||||
// 0x088: External CG, OR Mode
|
||||
// 0x089: External CG, EXOR Mode
|
||||
// 0x08B: External CG, AND Mode
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x080, /* mode register: OR Mode, Internal Character Mode */
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
// display mode
|
||||
// 0x090: Display off
|
||||
// 0x094: Graphic off, text on, cursor off, blink off
|
||||
// 0x096: Graphic off, text on, cursor on, blink off
|
||||
// 0x097: Graphic off, text on, cursor on, blink on
|
||||
// 0x098: Graphic on, text off, cursor off, blink off
|
||||
// 0x09a: Graphic on, text off, cursor on, blink off
|
||||
// ...
|
||||
// 0x09c: Graphic on, text on, cursor off, blink off
|
||||
// 0x09f: Graphic on, text on, cursor on, blink on
|
||||
0x098, /* mode register: Display Mode, Graphics on, Text off, Cursor off */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x000, /* low byte */
|
||||
0x000, /* height byte */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x024, /* set adr pointer */
|
||||
|
||||
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_t6963_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_t6963_128x64_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
uint8_t y, i;
|
||||
uint16_t disp_ram_adr;
|
||||
uint8_t *ptr;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
|
||||
u8g_SetAddress(u8g, dev, 0); /* data mode */
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
y = pb->p.page_y0;
|
||||
ptr = pb->buf;
|
||||
disp_ram_adr = WIDTH/8;
|
||||
disp_ram_adr *= y;
|
||||
for( i = 0; i < PAGE_HEIGHT; i ++ )
|
||||
{
|
||||
u8g_SetAddress(u8g, dev, 0); /* data mode */
|
||||
u8g_WriteByte(u8g, dev, disp_ram_adr&255 ); /* address low byte */
|
||||
u8g_WriteByte(u8g, dev, disp_ram_adr>>8 ); /* address hight byte */
|
||||
u8g_SetAddress(u8g, dev, 1); /* cmd mode */
|
||||
u8g_WriteByte(u8g, dev, 0x024 ); /* set adr ptr */
|
||||
|
||||
u8g_WriteSequence(u8g, dev, WIDTH/8, ptr);
|
||||
|
||||
ptr += WIDTH/8;
|
||||
disp_ram_adr += WIDTH/8;
|
||||
}
|
||||
u8g_SetAddress(u8g, dev, 0); /* data mode */
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return u8g_dev_pb16h1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
// U8G_PB_DEV(u8g_dev_t6963_128x64_8bit, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_t6963_128x64_fn, U8G_COM_T6963);
|
||||
|
||||
uint8_t u8g_dev_t6963_128x64_2x_bw_buf[WIDTH/8*PAGE_HEIGHT] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_dev_t6963_128x64_2x_bw_pb = { {PAGE_HEIGHT, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_t6963_128x64_2x_bw_buf};
|
||||
u8g_dev_t u8g_dev_t6963_128x64_8bit = { u8g_dev_t6963_128x64_fn, &u8g_dev_t6963_128x64_2x_bw_pb, U8G_COM_T6963 };
|
||||
|
||||
|
@ -0,0 +1,195 @@
|
||||
/*
|
||||
|
||||
u8g_dev_t6963_240x128.c
|
||||
|
||||
Tested with Varitronix MGLS240128TZ
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2013, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
Application Notes for the MGLS 240x128
|
||||
www.baso.no/content/pdf/T6963C_Application.pdf
|
||||
|
||||
Hitachi App Notes:
|
||||
https://www.sparkfun.com/datasheets/LCD/Monochrome/AN-029-Toshiba_T6963C.pdf
|
||||
|
||||
Notes:
|
||||
The font selection pins should generate the 8x8 font.
|
||||
For the MGLS240128TZ only FS1 is available on pin 18.
|
||||
FS1 must be low to generate the 8x8 font.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define WIDTH 240
|
||||
#define HEIGHT 128
|
||||
#define PAGE_HEIGHT 16
|
||||
|
||||
|
||||
/*
|
||||
http://www.mark-products.com/graphics.htm#240x64%20Pixel%20Format
|
||||
*/
|
||||
|
||||
/* text is not used, so settings are not relevant */
|
||||
static const uint8_t u8g_dev_t6963_240x128_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
U8G_ESC_RST(15), /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
|
||||
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x000, /* low byte */
|
||||
0x000, /* height byte */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x021, /* set cursor position */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x000, /* low byte */
|
||||
0x000, /* height byte */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x022, /* set offset */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x000, /* low byte */
|
||||
0x000, /* height byte */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x040, /* text home */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
WIDTH/8, /* low byte */
|
||||
0x000, /* height byte */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x041, /* text columns */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x000, /* low byte */
|
||||
0x000, /* height byte */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x042, /* graphics home */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
WIDTH/8, /* low byte */
|
||||
0x000, /* height byte */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x043, /* graphics columns */
|
||||
|
||||
// mode set
|
||||
// 0x080: Internal CG, OR Mode
|
||||
// 0x081: Internal CG, EXOR Mode
|
||||
// 0x083: Internal CG, AND Mode
|
||||
// 0x088: External CG, OR Mode
|
||||
// 0x089: External CG, EXOR Mode
|
||||
// 0x08B: External CG, AND Mode
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x080, /* mode register: OR Mode, Internal Character Mode */
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
// display mode
|
||||
// 0x090: Display off
|
||||
// 0x094: Graphic off, text on, cursor off, blink off
|
||||
// 0x096: Graphic off, text on, cursor on, blink off
|
||||
// 0x097: Graphic off, text on, cursor on, blink on
|
||||
// 0x098: Graphic on, text off, cursor off, blink off
|
||||
// 0x09a: Graphic on, text off, cursor on, blink off
|
||||
// ...
|
||||
// 0x09c: Graphic on, text on, cursor off, blink off
|
||||
// 0x09f: Graphic on, text on, cursor on, blink on
|
||||
0x098, /* mode register: Display Mode, Graphics on, Text off, Cursor off */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x000, /* low byte */
|
||||
0x000, /* height byte */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x024, /* set adr pointer */
|
||||
|
||||
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_t6963_240x128_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_t6963_240x128_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
uint8_t y, i;
|
||||
uint16_t disp_ram_adr;
|
||||
uint8_t *ptr;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
|
||||
u8g_SetAddress(u8g, dev, 0); /* data mode */
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
y = pb->p.page_y0;
|
||||
ptr = pb->buf;
|
||||
disp_ram_adr = WIDTH/8;
|
||||
disp_ram_adr *= y;
|
||||
for( i = 0; i < PAGE_HEIGHT; i ++ )
|
||||
{
|
||||
u8g_SetAddress(u8g, dev, 0); /* data mode */
|
||||
u8g_WriteByte(u8g, dev, disp_ram_adr&255 ); /* address low byte */
|
||||
u8g_WriteByte(u8g, dev, disp_ram_adr>>8 ); /* address hight byte */
|
||||
u8g_SetAddress(u8g, dev, 1); /* cmd mode */
|
||||
u8g_WriteByte(u8g, dev, 0x024 ); /* set adr ptr */
|
||||
|
||||
u8g_WriteSequence(u8g, dev, WIDTH/8, ptr);
|
||||
|
||||
ptr += WIDTH/8;
|
||||
disp_ram_adr += WIDTH/8;
|
||||
}
|
||||
u8g_SetAddress(u8g, dev, 0); /* data mode */
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return u8g_dev_pb16h1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
// U8G_PB_DEV(u8g_dev_t6963_240x128_8bit, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_t6963_240x128_fn, U8G_COM_T6963);
|
||||
|
||||
uint8_t u8g_dev_t6963_240x128_2x_bw_buf[WIDTH/8*PAGE_HEIGHT] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_dev_t6963_240x128_2x_bw_pb = { {PAGE_HEIGHT, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_t6963_240x128_2x_bw_buf};
|
||||
u8g_dev_t u8g_dev_t6963_240x128_8bit = { u8g_dev_t6963_240x128_fn, &u8g_dev_t6963_240x128_2x_bw_pb, U8G_COM_T6963 };
|
||||
|
||||
|
@ -0,0 +1,195 @@
|
||||
/*
|
||||
|
||||
u8g_dev_t6963_240x64.c
|
||||
|
||||
Tested with Varitronix MGLS240128TZ
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2013, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
Application Notes for the MGLS 240x128
|
||||
www.baso.no/content/pdf/T6963C_Application.pdf
|
||||
|
||||
Hitachi App Notes:
|
||||
https://www.sparkfun.com/datasheets/LCD/Monochrome/AN-029-Toshiba_T6963C.pdf
|
||||
|
||||
Notes:
|
||||
The font selection pins should generate the 8x8 font.
|
||||
For the MGLS240128TZ only FS1 is available on pin 18.
|
||||
FS1 must be low to generate the 8x8 font.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define WIDTH 240
|
||||
#define HEIGHT 64
|
||||
#define PAGE_HEIGHT 16
|
||||
|
||||
|
||||
/*
|
||||
http://www.mark-products.com/graphics.htm#240x64%20Pixel%20Format
|
||||
*/
|
||||
|
||||
/* text is not used, so settings are not relevant */
|
||||
static const uint8_t u8g_dev_t6963_240x64_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
U8G_ESC_RST(15), /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
|
||||
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x000, /* low byte */
|
||||
0x000, /* height byte */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x021, /* set cursor position */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x000, /* low byte */
|
||||
0x000, /* height byte */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x022, /* set offset */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x000, /* low byte */
|
||||
0x000, /* height byte */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x040, /* text home */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
WIDTH/8, /* low byte */
|
||||
0x000, /* height byte */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x041, /* text columns */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x000, /* low byte */
|
||||
0x000, /* height byte */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x042, /* graphics home */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
WIDTH/8, /* low byte */
|
||||
0x000, /* height byte */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x043, /* graphics columns */
|
||||
|
||||
// mode set
|
||||
// 0x080: Internal CG, OR Mode
|
||||
// 0x081: Internal CG, EXOR Mode
|
||||
// 0x083: Internal CG, AND Mode
|
||||
// 0x088: External CG, OR Mode
|
||||
// 0x089: External CG, EXOR Mode
|
||||
// 0x08B: External CG, AND Mode
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x080, /* mode register: OR Mode, Internal Character Mode */
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
// display mode
|
||||
// 0x090: Display off
|
||||
// 0x094: Graphic off, text on, cursor off, blink off
|
||||
// 0x096: Graphic off, text on, cursor on, blink off
|
||||
// 0x097: Graphic off, text on, cursor on, blink on
|
||||
// 0x098: Graphic on, text off, cursor off, blink off
|
||||
// 0x09a: Graphic on, text off, cursor on, blink off
|
||||
// ...
|
||||
// 0x09c: Graphic on, text on, cursor off, blink off
|
||||
// 0x09f: Graphic on, text on, cursor on, blink on
|
||||
0x098, /* mode register: Display Mode, Graphics on, Text off, Cursor off */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x000, /* low byte */
|
||||
0x000, /* height byte */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x024, /* set adr pointer */
|
||||
|
||||
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_t6963_240x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_t6963_240x64_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
uint8_t y, i;
|
||||
uint16_t disp_ram_adr;
|
||||
uint8_t *ptr;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
|
||||
u8g_SetAddress(u8g, dev, 0); /* data mode */
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
y = pb->p.page_y0;
|
||||
ptr = pb->buf;
|
||||
disp_ram_adr = WIDTH/8;
|
||||
disp_ram_adr *= y;
|
||||
for( i = 0; i < PAGE_HEIGHT; i ++ )
|
||||
{
|
||||
u8g_SetAddress(u8g, dev, 0); /* data mode */
|
||||
u8g_WriteByte(u8g, dev, disp_ram_adr&255 ); /* address low byte */
|
||||
u8g_WriteByte(u8g, dev, disp_ram_adr>>8 ); /* address hight byte */
|
||||
u8g_SetAddress(u8g, dev, 1); /* cmd mode */
|
||||
u8g_WriteByte(u8g, dev, 0x024 ); /* set adr ptr */
|
||||
|
||||
u8g_WriteSequence(u8g, dev, WIDTH/8, ptr);
|
||||
|
||||
ptr += WIDTH/8;
|
||||
disp_ram_adr += WIDTH/8;
|
||||
}
|
||||
u8g_SetAddress(u8g, dev, 0); /* data mode */
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return u8g_dev_pb16h1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
// U8G_PB_DEV(u8g_dev_t6963_240x64_8bit, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_t6963_240x64_fn, U8G_COM_T6963);
|
||||
|
||||
uint8_t u8g_dev_t6963_240x64_2x_bw_buf[WIDTH/8*PAGE_HEIGHT] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_dev_t6963_240x64_2x_bw_pb = { {PAGE_HEIGHT, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_t6963_240x64_2x_bw_buf};
|
||||
u8g_dev_t u8g_dev_t6963_240x64_8bit = { u8g_dev_t6963_240x64_fn, &u8g_dev_t6963_240x64_2x_bw_pb, U8G_COM_T6963 };
|
||||
|
||||
|
@ -0,0 +1,115 @@
|
||||
/*
|
||||
|
||||
u8g_dev_tls8204_84x48.c
|
||||
|
||||
Display: Nokia 84x48
|
||||
|
||||
Status: Tested with TLS8204V12 Display by Olimex MOD-LCD3310
|
||||
|
||||
Contributed: http://code.google.com/p/u8glib/issues/detail?id=126
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define WIDTH 84
|
||||
#define HEIGHT 48
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
|
||||
static const uint8_t u8g_dev_tls8204_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x021, /* activate chip (PD=0), horizontal increment (V=0), enter extended command set (H=1) */
|
||||
0x006, /* temp. control: b10 = 2 */
|
||||
0x04 | !!((66-1)&(1u<<6)),
|
||||
0x40 | ((66-2) & ((1u<<6)-1)),
|
||||
0x013, /* bias system 1:48 */
|
||||
0x0c0, /* medium Vop */
|
||||
0x020, /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
|
||||
0x00c, /* display on, normal operation */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x020, /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
|
||||
0x00d, /* display on, invert */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x020, /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
|
||||
0x00c, /* display on, normal */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
uint8_t u8g_dev_tls8204_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_tls8204_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
u8g_SetAddress(u8g, dev, 0); /* command mode */
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_WriteByte(u8g, dev, 0x020 ); /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
|
||||
u8g_WriteByte(u8g, dev, 0x080 ); /* set X address */
|
||||
u8g_WriteByte(u8g, dev, 0x040 | pb->p.page); /* set Y address */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
|
||||
return 0;
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
/* the contrast adjustment does not work, needs to be analysed */
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_WriteByte(u8g, dev, 0x021); /* command mode, extended function set */
|
||||
u8g_WriteByte(u8g, dev, 0x080 | ( (*(uint8_t *)arg) >> 1 ) );
|
||||
u8g_WriteByte(u8g, dev, 0x020); /* command mode, extended function set */
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
|
||||
U8G_PB_DEV(u8g_dev_tls8204_84x48_sw_spi , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_tls8204_fn, U8G_COM_SW_SPI);
|
||||
|
@ -0,0 +1,290 @@
|
||||
/*
|
||||
|
||||
u8g_dev_uc1610_dogxl160.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define WIDTH 160
|
||||
#define HEIGHT 104
|
||||
|
||||
static const uint8_t u8g_dev_uc1610_dogxl160_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0f1, /* set display height-1 */
|
||||
0x067, /* */
|
||||
0x0c0, /* SEG & COM normal */
|
||||
0x040, /* set display start line */
|
||||
0x050, /* */
|
||||
0x02b, /* set panelloading */
|
||||
0x0eb, /* set bias 1/2 */
|
||||
0x081, /* set contrast */
|
||||
0x05f, /* */
|
||||
0x089, /* set auto increment */
|
||||
0x0a6, /* normal pixel mode */
|
||||
0x0d3, /* 0xd3=40% RMS separation for gray levels */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a5, /* display all points, ST7565, UC1610 */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a4, /* normal display */
|
||||
|
||||
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_uc1610_dogxl160_data_start[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x010, /* set upper 4 bit of the col adr to 0 */
|
||||
0x000, /* set lower 4 bit of the col adr to 0 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static uint8_t u8g_dev_1to2(uint8_t n)
|
||||
{
|
||||
register uint8_t a,b,c;
|
||||
a = n;
|
||||
a &= 1;
|
||||
n <<= 1;
|
||||
b = n;
|
||||
b &= 4;
|
||||
n <<= 1;
|
||||
c = n;
|
||||
c &= 16;
|
||||
n <<= 1;
|
||||
n &= 64;
|
||||
n |= a;
|
||||
n |= b;
|
||||
n |= c;
|
||||
n |= n << 1;
|
||||
return n;
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_uc1610_dogxl160_bw_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1610_dogxl160_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
int i;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1610_dogxl160_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x060 | (pb->p.page*2) ); /* select current page 1/2 (UC1610) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
for( i = 0; i < WIDTH; i++ )
|
||||
{
|
||||
u8g_WriteByte(u8g, dev, u8g_dev_1to2( ((uint8_t *)(pb->buf))[i] ) );
|
||||
}
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1610_dogxl160_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x060 | (pb->p.page*2+1) ); /* select current page 2/2 (UC1610) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
for( i = 0; i < WIDTH; i++ )
|
||||
{
|
||||
u8g_WriteByte(u8g, dev, u8g_dev_1to2( ((uint8_t *)(pb->buf))[i] >> 4 ) );
|
||||
}
|
||||
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_uc1610_dogxl160_gr_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1610_dogxl160_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1610_dogxl160_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x060 | (pb->p.page) ); /* select current page (UC1610) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
|
||||
return 0;
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb8v2_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_uc1610_dogxl160_2x_bw_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1610_dogxl160_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
int i;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1610_dogxl160_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x060 | (pb->p.page*4) ); /* select current page 1/2 (UC1610) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
for( i = 0; i < WIDTH; i++ )
|
||||
{
|
||||
u8g_WriteByte(u8g, dev, u8g_dev_1to2( ((uint8_t *)(pb->buf))[i] ) );
|
||||
}
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1610_dogxl160_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x060 | (pb->p.page*4+1) ); /* select current page 2/2 (UC1610) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
for( i = 0; i < WIDTH; i++ )
|
||||
{
|
||||
u8g_WriteByte(u8g, dev, u8g_dev_1to2( ((uint8_t *)(pb->buf))[i] >> 4 ) );
|
||||
}
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1610_dogxl160_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x060 | (pb->p.page*4+2) ); /* select current page 1/2 (UC1610) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
for( i = 0; i < WIDTH; i++ )
|
||||
{
|
||||
u8g_WriteByte(u8g, dev, u8g_dev_1to2( ((uint8_t *)(pb->buf+WIDTH))[i] ) );
|
||||
}
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1610_dogxl160_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x060 | (pb->p.page*4+3) ); /* select current page 2/2 (UC1610) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
for( i = 0; i < WIDTH; i++ )
|
||||
{
|
||||
u8g_WriteByte(u8g, dev, u8g_dev_1to2( ((uint8_t *)(pb->buf+WIDTH))[i] >> 4 ) );
|
||||
}
|
||||
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb16v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_uc1610_dogxl160_2x_gr_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1610_dogxl160_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1610_dogxl160_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x060 | (pb->p.page*2) ); /* select current page (UC1610) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
if ( u8g_WriteSequence(u8g, dev, WIDTH, pb->buf) == 0 )
|
||||
return 0;
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1610_dogxl160_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x060 | (pb->p.page*2+1) ); /* select current page (UC1610) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
if ( u8g_WriteSequence(u8g, dev, WIDTH, pb->buf+WIDTH) == 0 )
|
||||
return 0;
|
||||
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb16v2_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
U8G_PB_DEV(u8g_dev_uc1610_dogxl160_bw_sw_spi, WIDTH, HEIGHT, 8, u8g_dev_uc1610_dogxl160_bw_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_uc1610_dogxl160_bw_hw_spi, WIDTH, HEIGHT, 8, u8g_dev_uc1610_dogxl160_bw_fn, U8G_COM_HW_SPI);
|
||||
|
||||
U8G_PB_DEV(u8g_dev_uc1610_dogxl160_gr_sw_spi, WIDTH, HEIGHT, 4, u8g_dev_uc1610_dogxl160_gr_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_uc1610_dogxl160_gr_hw_spi, WIDTH, HEIGHT, 4, u8g_dev_uc1610_dogxl160_gr_fn, U8G_COM_HW_SPI);
|
||||
|
||||
uint8_t u8g_dev_uc1610_dogxl160_2x_bw_buf[WIDTH*2] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_dev_uc1610_dogxl160_2x_bw_pb = { {16, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_uc1610_dogxl160_2x_bw_buf};
|
||||
u8g_dev_t u8g_dev_uc1610_dogxl160_2x_bw_sw_spi = { u8g_dev_uc1610_dogxl160_2x_bw_fn, &u8g_dev_uc1610_dogxl160_2x_bw_pb, U8G_COM_SW_SPI };
|
||||
u8g_dev_t u8g_dev_uc1610_dogxl160_2x_bw_hw_spi = { u8g_dev_uc1610_dogxl160_2x_bw_fn, &u8g_dev_uc1610_dogxl160_2x_bw_pb, U8G_COM_HW_SPI };
|
||||
|
||||
uint8_t u8g_dev_uc1610_dogxl160_2x_gr_buf[WIDTH*2] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_dev_uc1610_dogxl160_2x_gr_pb = { {8, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_uc1610_dogxl160_2x_gr_buf};
|
||||
u8g_dev_t u8g_dev_uc1610_dogxl160_2x_gr_sw_spi = { u8g_dev_uc1610_dogxl160_2x_gr_fn, &u8g_dev_uc1610_dogxl160_2x_gr_pb, U8G_COM_SW_SPI };
|
||||
u8g_dev_t u8g_dev_uc1610_dogxl160_2x_gr_hw_spi = { u8g_dev_uc1610_dogxl160_2x_gr_fn, &u8g_dev_uc1610_dogxl160_2x_gr_pb, U8G_COM_HW_SPI };
|
@ -0,0 +1,113 @@
|
||||
/*
|
||||
|
||||
u8g_dev_uc1701_dogs102.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define WIDTH 102
|
||||
#define HEIGHT 64
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
static const uint8_t u8g_dev_dogs102_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x040, /* set display start line to 0 */
|
||||
0x0a1, /* ADC set to reverse */
|
||||
0x0c0, /* common output mode */
|
||||
0x0a6, /* display normal, bit val 0: LCD pixel off. */
|
||||
0x0a2, /* LCD bias 1/9 */
|
||||
0x02f, /* all power control circuits on */
|
||||
0x027, /* regulator, booster and follower */
|
||||
0x081, /* set contrast */
|
||||
0x00e, /* contrast value, EA default: 0x010, previous value for S102: 0x0e */
|
||||
0x0fa, /* Set Temp compensation */
|
||||
0x090, /* 0.11 deg/c WP Off WC Off*/
|
||||
0x0a4, /* normal display */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a5, /* display all points, ST7565, UC1610 */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a4, /* normal display */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_dogs102_data_start[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x010, /* set upper 4 bit of the col adr to 0 */
|
||||
0x000, /* set lower 4 bit of the col adr to 0 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_dogs102_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_dogs102_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_dogs102_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | pb->p.page); /* select current page (ST7565R) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
|
||||
return 0;
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
U8G_PB_DEV(u8g_dev_uc1701_dogs102_sw_spi , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_dogs102_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_uc1701_dogs102_hw_spi , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_dogs102_fn, U8G_COM_HW_SPI);
|
||||
|
||||
|
@ -0,0 +1,114 @@
|
||||
/*
|
||||
|
||||
u8g_dev_uc1701_mini12864.c (dealextreme)
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define WIDTH 128
|
||||
#define HEIGHT 64
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
static const uint8_t u8g_dev_uc1701_mini12864_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
|
||||
0x040, /* set display start line to 0 */
|
||||
0x0a0, /* ADC set to reverse */
|
||||
0x0c8, /* common output mode */
|
||||
0x0a6, /* display normal, bit val 0: LCD pixel off. */
|
||||
0x0a2, /* LCD bias 1/9 */
|
||||
0x02f, /* all power control circuits on */
|
||||
0x0f8, /* set booster ratio to */
|
||||
0x000, /* 4x */
|
||||
0x023, /* set V0 voltage resistor ratio to large */
|
||||
0x081, /* set contrast */
|
||||
0x027, /* contrast value */
|
||||
0x0ac, /* indicator */
|
||||
0x000, /* disable */
|
||||
0x0af, /* display on */
|
||||
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a5, /* display all points, ST7565 */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a4, /* normal display */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_uc1701_mini12864_data_start[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x010, /* set upper 4 bit of the col adr to 0 */
|
||||
0x000, /* set lower 4 bit of the col adr to 4 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_uc1701_mini12864_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1701_mini12864_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1701_mini12864_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | pb->p.page); /* select current page */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
|
||||
return 0;
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
U8G_PB_DEV(u8g_dev_uc1701_mini12864_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_uc1701_mini12864_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_uc1701_mini12864_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_uc1701_mini12864_fn, U8G_COM_HW_SPI);
|
@ -0,0 +1,100 @@
|
||||
/*
|
||||
|
||||
u8g_ellipse.c
|
||||
|
||||
Utility to draw empty and filled ellipses.
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, bjthom@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
Addition to the U8G Library as of 02/29/12
|
||||
Adapted from Bresenham's Algorithm and the following websites:
|
||||
http://free.pages.at/easyfilter/bresenham.html
|
||||
http://homepage.smc.edu/kennedy_john/belipse.pdf
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
|
||||
#ifdef WORK_IN_PROGRESS
|
||||
|
||||
void u8g_DrawEllipseRect(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t x1, u8g_uint_t y1)
|
||||
{
|
||||
int a = abs(x1 - x0);
|
||||
int b = abs(y1 - y0); //get diameters
|
||||
int b1 = b&1;
|
||||
long dx = 4*(1-a)*b*b;
|
||||
long dy = 4*(b1+1)*a*a;
|
||||
long err = dx+dy+b1*a*a;
|
||||
long e2;
|
||||
|
||||
if (x0 > x1) { x0 = x1; x1 += a; }
|
||||
if (y0 > y1) { y0 = y1; }
|
||||
y0 += (b+1)/2;
|
||||
y1 = y0-b1;
|
||||
a *= 8*a;
|
||||
b1 = 8*b*b;
|
||||
|
||||
do {
|
||||
u8g_DrawPixel(u8g, x1, y0);
|
||||
u8g_DrawPixel(u8g, x0, y0);
|
||||
u8g_DrawPixel(u8g, x0, y1);
|
||||
u8g_DrawPixel(u8g, x1, y1);
|
||||
e2 = 2*err;
|
||||
if (e2 >= dx) {
|
||||
x0++;
|
||||
x1--;
|
||||
err += dx += b1;
|
||||
}
|
||||
if (e2 <= dy) {
|
||||
y0++;
|
||||
y1--;
|
||||
err += dy += a;
|
||||
}
|
||||
} while (x0 <= x1);
|
||||
|
||||
while (y0-y1 < b) {
|
||||
u8g_DrawPixel(u8g, x0-1, y0);
|
||||
u8g_DrawPixel(u8g, x1+1, y0++);
|
||||
u8g_DrawPixel(u8g, x0-1, y1);
|
||||
u8g_DrawPixel(u8g, x1+1, y1--);
|
||||
}
|
||||
}
|
||||
|
||||
void u8g_DrawEllipse(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t xr, u8g_uint_t yr)
|
||||
{
|
||||
u8g_DrawPixel(u8g, x0, y0+yr);
|
||||
u8g_DrawPixel(u8g, x0, y0-yr);
|
||||
u8g_DrawPixel(u8g, x0+xr, y0);
|
||||
u8g_DrawPixel(u8g, x0-xr, y0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -0,0 +1,1422 @@
|
||||
/*
|
||||
|
||||
u8g_font.c
|
||||
|
||||
U8G Font High Level Interface
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
/* font api */
|
||||
|
||||
/* pointer to the start adress of the glyph, points to progmem area */
|
||||
typedef void * u8g_glyph_t;
|
||||
|
||||
/* size of the font data structure, there is no struct or class... */
|
||||
#define U8G_FONT_DATA_STRUCT_SIZE 17
|
||||
|
||||
/*
|
||||
... instead the fields of the font data structure are accessed directly by offset
|
||||
font information
|
||||
offset
|
||||
0 font format
|
||||
1 FONTBOUNDINGBOX width unsigned
|
||||
2 FONTBOUNDINGBOX height unsigned
|
||||
3 FONTBOUNDINGBOX x-offset signed
|
||||
4 FONTBOUNDINGBOX y-offset signed
|
||||
5 capital A height unsigned
|
||||
6 start 'A'
|
||||
8 start 'a'
|
||||
10 encoding start
|
||||
11 encoding end
|
||||
12 descent 'g' negative: below baseline
|
||||
13 font max ascent
|
||||
14 font min decent negative: below baseline
|
||||
15 font xascent
|
||||
16 font xdecent negative: below baseline
|
||||
|
||||
*/
|
||||
|
||||
/* use case: What is the width and the height of the minimal box into which string s fints? */
|
||||
void u8g_font_GetStrSize(const void *font, const char *s, u8g_uint_t *width, u8g_uint_t *height);
|
||||
void u8g_font_GetStrSizeP(const void *font, const char *s, u8g_uint_t *width, u8g_uint_t *height);
|
||||
|
||||
/* use case: lower left edge of a minimal box is known, what is the correct x, y position for the string draw procedure */
|
||||
void u8g_font_AdjustXYToDraw(const void *font, const char *s, u8g_uint_t *x, u8g_uint_t *y);
|
||||
void u8g_font_AdjustXYToDrawP(const void *font, const char *s, u8g_uint_t *x, u8g_uint_t *y);
|
||||
|
||||
/* use case: Baseline origin known, return minimal box */
|
||||
void u8g_font_GetStrMinBox(u8g_t *u8g, const void *font, const char *s, u8g_uint_t *x, u8g_uint_t *y, u8g_uint_t *width, u8g_uint_t *height);
|
||||
|
||||
/* procedures */
|
||||
|
||||
/*========================================================================*/
|
||||
/* low level byte and word access */
|
||||
|
||||
/* removed NOINLINE, because it leads to smaller code, might also be faster */
|
||||
//static uint8_t u8g_font_get_byte(const u8g_fntpgm_uint8_t *font, uint8_t offset) U8G_NOINLINE;
|
||||
static uint8_t u8g_font_get_byte(const u8g_fntpgm_uint8_t *font, uint8_t offset)
|
||||
{
|
||||
font += offset;
|
||||
return u8g_pgm_read( (u8g_pgm_uint8_t *)font );
|
||||
}
|
||||
|
||||
static uint16_t u8g_font_get_word(const u8g_fntpgm_uint8_t *font, uint8_t offset) U8G_NOINLINE;
|
||||
static uint16_t u8g_font_get_word(const u8g_fntpgm_uint8_t *font, uint8_t offset)
|
||||
{
|
||||
uint16_t pos;
|
||||
font += offset;
|
||||
pos = u8g_pgm_read( (u8g_pgm_uint8_t *)font );
|
||||
font++;
|
||||
pos <<= 8;
|
||||
pos += u8g_pgm_read( (u8g_pgm_uint8_t *)font);
|
||||
return pos;
|
||||
}
|
||||
|
||||
/*========================================================================*/
|
||||
/* direct access on the font */
|
||||
|
||||
static uint8_t u8g_font_GetFormat(const u8g_fntpgm_uint8_t *font) U8G_NOINLINE;
|
||||
static uint8_t u8g_font_GetFormat(const u8g_fntpgm_uint8_t *font)
|
||||
{
|
||||
return u8g_font_get_byte(font, 0);
|
||||
}
|
||||
|
||||
static uint8_t u8g_font_GetFontGlyphStructureSize(const u8g_fntpgm_uint8_t *font) U8G_NOINLINE;
|
||||
static uint8_t u8g_font_GetFontGlyphStructureSize(const u8g_fntpgm_uint8_t *font)
|
||||
{
|
||||
switch(u8g_font_GetFormat(font))
|
||||
{
|
||||
case 0: return 6;
|
||||
case 1: return 3;
|
||||
}
|
||||
return 3;
|
||||
}
|
||||
|
||||
static uint8_t u8g_font_GetBBXWidth(const void *font)
|
||||
{
|
||||
return u8g_font_get_byte(font, 1);
|
||||
}
|
||||
|
||||
static uint8_t u8g_font_GetBBXHeight(const void *font)
|
||||
{
|
||||
return u8g_font_get_byte(font, 2);
|
||||
}
|
||||
|
||||
static int8_t u8g_font_GetBBXOffX(const void *font)
|
||||
{
|
||||
return u8g_font_get_byte(font, 3);
|
||||
}
|
||||
|
||||
static int8_t u8g_font_GetBBXOffY(const void *font)
|
||||
{
|
||||
return u8g_font_get_byte(font, 4);
|
||||
}
|
||||
|
||||
uint8_t u8g_font_GetCapitalAHeight(const void *font)
|
||||
{
|
||||
return u8g_font_get_byte(font, 5);
|
||||
}
|
||||
|
||||
uint16_t u8g_font_GetEncoding65Pos(const void *font) U8G_NOINLINE;
|
||||
uint16_t u8g_font_GetEncoding65Pos(const void *font)
|
||||
{
|
||||
return u8g_font_get_word(font, 6);
|
||||
}
|
||||
|
||||
uint16_t u8g_font_GetEncoding97Pos(const void *font) U8G_NOINLINE;
|
||||
uint16_t u8g_font_GetEncoding97Pos(const void *font)
|
||||
{
|
||||
return u8g_font_get_word(font, 8);
|
||||
}
|
||||
|
||||
uint8_t u8g_font_GetFontStartEncoding(const void *font)
|
||||
{
|
||||
return u8g_font_get_byte(font, 10);
|
||||
}
|
||||
|
||||
uint8_t u8g_font_GetFontEndEncoding(const void *font)
|
||||
{
|
||||
return u8g_font_get_byte(font, 11);
|
||||
}
|
||||
|
||||
int8_t u8g_font_GetLowerGDescent(const void *font)
|
||||
{
|
||||
return u8g_font_get_byte(font, 12);
|
||||
}
|
||||
|
||||
int8_t u8g_font_GetFontAscent(const void *font)
|
||||
{
|
||||
return u8g_font_get_byte(font, 13);
|
||||
}
|
||||
|
||||
int8_t u8g_font_GetFontDescent(const void *font)
|
||||
{
|
||||
return u8g_font_get_byte(font, 14);
|
||||
}
|
||||
|
||||
int8_t u8g_font_GetFontXAscent(const void *font)
|
||||
{
|
||||
return u8g_font_get_byte(font, 15);
|
||||
}
|
||||
|
||||
int8_t u8g_font_GetFontXDescent(const void *font)
|
||||
{
|
||||
return u8g_font_get_byte(font, 16);
|
||||
}
|
||||
|
||||
|
||||
/* return the data start for a font and the glyph pointer */
|
||||
static uint8_t *u8g_font_GetGlyphDataStart(const void *font, u8g_glyph_t g)
|
||||
{
|
||||
return ((u8g_fntpgm_uint8_t *)g) + u8g_font_GetFontGlyphStructureSize(font);
|
||||
}
|
||||
|
||||
/* calculate the overall length of the font, only used to create the picture for the google wiki */
|
||||
size_t u8g_font_GetSize(const void *font)
|
||||
{
|
||||
uint8_t *p = (uint8_t *)(font);
|
||||
uint8_t font_format = u8g_font_GetFormat(font);
|
||||
uint8_t data_structure_size = u8g_font_GetFontGlyphStructureSize(font);
|
||||
uint8_t start, end;
|
||||
uint8_t i;
|
||||
uint8_t mask = 255;
|
||||
|
||||
start = u8g_font_GetFontStartEncoding(font);
|
||||
end = u8g_font_GetFontEndEncoding(font);
|
||||
|
||||
if ( font_format == 1 )
|
||||
mask = 15;
|
||||
|
||||
p += U8G_FONT_DATA_STRUCT_SIZE; /* skip font general information */
|
||||
|
||||
i = start;
|
||||
for(;;)
|
||||
{
|
||||
if ( u8g_pgm_read((u8g_pgm_uint8_t *)(p)) == 255 )
|
||||
{
|
||||
p += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
p += u8g_pgm_read( ((u8g_pgm_uint8_t *)(p)) + 2 ) & mask;
|
||||
p += data_structure_size;
|
||||
}
|
||||
if ( i == end )
|
||||
break;
|
||||
i++;
|
||||
}
|
||||
|
||||
return p - (uint8_t *)font;
|
||||
}
|
||||
|
||||
/*========================================================================*/
|
||||
/* u8g interface, font access */
|
||||
|
||||
uint8_t u8g_GetFontBBXWidth(u8g_t *u8g)
|
||||
{
|
||||
return u8g_font_GetBBXWidth(u8g->font);
|
||||
}
|
||||
|
||||
uint8_t u8g_GetFontBBXHeight(u8g_t *u8g)
|
||||
{
|
||||
return u8g_font_GetBBXHeight(u8g->font);
|
||||
}
|
||||
|
||||
int8_t u8g_GetFontBBXOffX(u8g_t *u8g) U8G_NOINLINE;
|
||||
int8_t u8g_GetFontBBXOffX(u8g_t *u8g)
|
||||
{
|
||||
return u8g_font_GetBBXOffX(u8g->font);
|
||||
}
|
||||
|
||||
int8_t u8g_GetFontBBXOffY(u8g_t *u8g) U8G_NOINLINE;
|
||||
int8_t u8g_GetFontBBXOffY(u8g_t *u8g)
|
||||
{
|
||||
return u8g_font_GetBBXOffY(u8g->font);
|
||||
}
|
||||
|
||||
uint8_t u8g_GetFontCapitalAHeight(u8g_t *u8g) U8G_NOINLINE;
|
||||
uint8_t u8g_GetFontCapitalAHeight(u8g_t *u8g)
|
||||
{
|
||||
return u8g_font_GetCapitalAHeight(u8g->font);
|
||||
}
|
||||
|
||||
/*========================================================================*/
|
||||
/* glyph handling */
|
||||
|
||||
static void u8g_CopyGlyphDataToCache(u8g_t *u8g, u8g_glyph_t g)
|
||||
{
|
||||
uint8_t tmp;
|
||||
switch( u8g_font_GetFormat(u8g->font) )
|
||||
{
|
||||
case 0:
|
||||
/*
|
||||
format 0
|
||||
glyph information
|
||||
offset
|
||||
0 BBX width unsigned
|
||||
1 BBX height unsigned
|
||||
2 data size unsigned (BBX width + 7)/8 * BBX height
|
||||
3 DWIDTH signed
|
||||
4 BBX xoffset signed
|
||||
5 BBX yoffset signed
|
||||
byte 0 == 255 indicates empty glyph
|
||||
*/
|
||||
u8g->glyph_width = u8g_pgm_read( ((u8g_pgm_uint8_t *)g) + 0 );
|
||||
u8g->glyph_height = u8g_pgm_read( ((u8g_pgm_uint8_t *)g) + 1 );
|
||||
u8g->glyph_dx = u8g_pgm_read( ((u8g_pgm_uint8_t *)g) + 3 );
|
||||
u8g->glyph_x = u8g_pgm_read( ((u8g_pgm_uint8_t *)g) + 4 );
|
||||
u8g->glyph_y = u8g_pgm_read( ((u8g_pgm_uint8_t *)g) + 5 );
|
||||
break;
|
||||
case 1:
|
||||
default:
|
||||
/*
|
||||
format 1
|
||||
0 BBX xoffset signed --> upper 4 Bit
|
||||
0 BBX yoffset signed --> lower 4 Bit
|
||||
1 BBX width unsigned --> upper 4 Bit
|
||||
1 BBX height unsigned --> lower 4 Bit
|
||||
2 data size unsigned -(BBX width + 7)/8 * BBX height --> lower 4 Bit
|
||||
2 DWIDTH signed --> upper 4 Bit
|
||||
byte 0 == 255 indicates empty glyph
|
||||
*/
|
||||
|
||||
tmp = u8g_pgm_read( ((u8g_pgm_uint8_t *)g) + 0 );
|
||||
u8g->glyph_y = tmp & 15;
|
||||
u8g->glyph_y-=2;
|
||||
tmp >>= 4;
|
||||
u8g->glyph_x = tmp;
|
||||
|
||||
tmp = u8g_pgm_read( ((u8g_pgm_uint8_t *)g) + 1 );
|
||||
u8g->glyph_height = tmp & 15;
|
||||
tmp >>= 4;
|
||||
u8g->glyph_width = tmp;
|
||||
|
||||
tmp = u8g_pgm_read( ((u8g_pgm_uint8_t *)g) + 2 );
|
||||
tmp >>= 4;
|
||||
u8g->glyph_dx = tmp;
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//void u8g_FillEmptyGlyphCache(u8g_t *u8g) U8G_NOINLINE;
|
||||
static void u8g_FillEmptyGlyphCache(u8g_t *u8g)
|
||||
{
|
||||
u8g->glyph_dx = 0;
|
||||
u8g->glyph_width = 0;
|
||||
u8g->glyph_height = 0;
|
||||
u8g->glyph_x = 0;
|
||||
u8g->glyph_y = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
Find (with some speed optimization) and return a pointer to the glyph data structure
|
||||
Also uncompress (format 1) and copy the content of the data structure to the u8g structure
|
||||
*/
|
||||
u8g_glyph_t u8g_GetGlyph(u8g_t *u8g, uint8_t requested_encoding)
|
||||
{
|
||||
uint8_t *p = (uint8_t *)(u8g->font);
|
||||
uint8_t font_format = u8g_font_GetFormat(u8g->font);
|
||||
uint8_t data_structure_size = u8g_font_GetFontGlyphStructureSize(u8g->font);
|
||||
uint8_t start, end;
|
||||
uint16_t pos;
|
||||
uint8_t i;
|
||||
uint8_t mask = 255;
|
||||
|
||||
if ( font_format == 1 )
|
||||
mask = 15;
|
||||
|
||||
start = u8g_font_GetFontStartEncoding(u8g->font);
|
||||
end = u8g_font_GetFontEndEncoding(u8g->font);
|
||||
|
||||
pos = u8g_font_GetEncoding97Pos(u8g->font);
|
||||
if ( requested_encoding >= 97 && pos > 0 )
|
||||
{
|
||||
p+= pos;
|
||||
start = 97;
|
||||
}
|
||||
else
|
||||
{
|
||||
pos = u8g_font_GetEncoding65Pos(u8g->font);
|
||||
if ( requested_encoding >= 65 && pos > 0 )
|
||||
{
|
||||
p+= pos;
|
||||
start = 65;
|
||||
}
|
||||
else
|
||||
p += U8G_FONT_DATA_STRUCT_SIZE; /* skip font general information */
|
||||
}
|
||||
|
||||
if ( requested_encoding > end )
|
||||
{
|
||||
u8g_FillEmptyGlyphCache(u8g);
|
||||
return NULL; /* not found */
|
||||
}
|
||||
|
||||
i = start;
|
||||
if ( i <= end )
|
||||
{
|
||||
for(;;)
|
||||
{
|
||||
if ( u8g_pgm_read((u8g_pgm_uint8_t *)(p)) == 255 )
|
||||
{
|
||||
p += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( i == requested_encoding )
|
||||
{
|
||||
u8g_CopyGlyphDataToCache(u8g, p);
|
||||
return p;
|
||||
}
|
||||
p += u8g_pgm_read( ((u8g_pgm_uint8_t *)(p)) + 2 ) & mask;
|
||||
p += data_structure_size;
|
||||
}
|
||||
if ( i == end )
|
||||
break;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
u8g_FillEmptyGlyphCache(u8g);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
uint8_t u8g_IsGlyph(u8g_t *u8g, uint8_t requested_encoding)
|
||||
{
|
||||
if ( u8g_GetGlyph(u8g, requested_encoding) != NULL )
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int8_t u8g_GetGlyphDeltaX(u8g_t *u8g, uint8_t requested_encoding)
|
||||
{
|
||||
if ( u8g_GetGlyph(u8g, requested_encoding) == NULL )
|
||||
return 0; /* should never happen, so return something */
|
||||
return u8g->glyph_dx;
|
||||
}
|
||||
|
||||
|
||||
/*========================================================================*/
|
||||
/* glyph drawing procedures */
|
||||
|
||||
#ifdef OBSOLETE
|
||||
/*
|
||||
Draw a glyph
|
||||
x,y: left baseline position of the glyph
|
||||
*/
|
||||
int8_t u8g_DrawGlyphDir(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_t encoding)
|
||||
{
|
||||
u8g_glyph_t g;
|
||||
uint8_t w, h, i, j;
|
||||
const u8g_pgm_uint8_t *data;
|
||||
uint8_t bytes_per_line;
|
||||
u8g_uint_t ix, iy;
|
||||
|
||||
g = u8g_GetGlyph(u8g, encoding);
|
||||
if ( g == NULL )
|
||||
return 0;
|
||||
w = u8g->glyph_width;
|
||||
h = u8g->glyph_height;
|
||||
|
||||
bytes_per_line = w;
|
||||
bytes_per_line += 7;
|
||||
bytes_per_line /= 8;
|
||||
|
||||
data = u8g_font_GetGlyphDataStart(u8g->font, g);
|
||||
|
||||
switch(dir)
|
||||
{
|
||||
case 0:
|
||||
x += u8g->glyph_x;
|
||||
y -= u8g->glyph_y;
|
||||
y--;
|
||||
//u8g_DrawFrame(u8g, x, y-h+1, w, h);
|
||||
if ( u8g_IsBBXIntersection(u8g, x, y-h+1, w, h) == 0 )
|
||||
return u8g->glyph_dx;
|
||||
|
||||
iy = y;
|
||||
iy -= h;
|
||||
iy++;
|
||||
|
||||
for( j = 0; j < h; j++ )
|
||||
{
|
||||
ix = x;
|
||||
for( i = 0; i < bytes_per_line; i++ )
|
||||
{
|
||||
u8g_Draw8Pixel(u8g, ix, iy, dir, u8g_pgm_read(data));
|
||||
data++;
|
||||
ix+=8;
|
||||
}
|
||||
iy++;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
x += u8g->glyph_y;
|
||||
x++;
|
||||
y += u8g->glyph_x;
|
||||
//printf("enc %d, dir %d, x %d, y %d, w %d, h %d\n", encoding, dir, x, y, w, h);
|
||||
//u8g_DrawFrame(u8g, x, y, h, w);
|
||||
if ( u8g_IsBBXIntersection(u8g, x, y, h, w) == 0 )
|
||||
return u8g->glyph_dx;
|
||||
|
||||
ix = x;
|
||||
ix += h;
|
||||
ix--;
|
||||
for( j = 0; j < h; j++ )
|
||||
{
|
||||
iy = y;
|
||||
for( i = 0; i < bytes_per_line; i++ )
|
||||
{
|
||||
u8g_Draw8Pixel(u8g, ix, iy, dir, u8g_pgm_read(data));
|
||||
data++;
|
||||
iy+=8;
|
||||
}
|
||||
ix--;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
x -= u8g->glyph_x;
|
||||
y += u8g->glyph_y;
|
||||
y++;
|
||||
if ( u8g_IsBBXIntersection(u8g, x-w-1, y, w, h) == 0 )
|
||||
return u8g->glyph_dx;
|
||||
|
||||
iy = y;
|
||||
iy += h;
|
||||
iy--;
|
||||
for( j = 0; j < h; j++ )
|
||||
{
|
||||
ix = x;
|
||||
for( i = 0; i < bytes_per_line; i++ )
|
||||
{
|
||||
u8g_Draw8Pixel(u8g, ix, iy, dir, u8g_pgm_read(data));
|
||||
data++;
|
||||
ix-=8;
|
||||
}
|
||||
iy--;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
x -= u8g->glyph_y;
|
||||
x--;
|
||||
y -= u8g->glyph_x;
|
||||
|
||||
if ( u8g_IsBBXIntersection(u8g, x-h-1, y-w-1, h, w) == 0 )
|
||||
return u8g->glyph_dx;
|
||||
|
||||
ix = x;
|
||||
ix -= h;
|
||||
ix++;
|
||||
|
||||
for( j = 0; j < h; j++ )
|
||||
{
|
||||
iy = y;
|
||||
for( i = 0; i < bytes_per_line; i++ )
|
||||
{
|
||||
u8g_Draw8Pixel(u8g, ix, iy, dir, u8g_pgm_read(data));
|
||||
data++;
|
||||
iy-=8;
|
||||
}
|
||||
ix++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return u8g->glyph_dx;
|
||||
}
|
||||
#endif
|
||||
|
||||
int8_t u8g_draw_glyph(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t encoding)
|
||||
{
|
||||
const u8g_pgm_uint8_t *data;
|
||||
uint8_t w, h;
|
||||
uint8_t i, j;
|
||||
u8g_uint_t ix, iy;
|
||||
|
||||
{
|
||||
u8g_glyph_t g = u8g_GetGlyph(u8g, encoding);
|
||||
if ( g == NULL )
|
||||
return 0;
|
||||
data = u8g_font_GetGlyphDataStart(u8g->font, g);
|
||||
}
|
||||
|
||||
w = u8g->glyph_width;
|
||||
h = u8g->glyph_height;
|
||||
|
||||
x += u8g->glyph_x;
|
||||
y -= u8g->glyph_y;
|
||||
y--;
|
||||
|
||||
if ( u8g_IsBBXIntersection(u8g, x, y-h+1, w, h) == 0 )
|
||||
return u8g->glyph_dx;
|
||||
|
||||
/* now, w is reused as bytes per line */
|
||||
w += 7;
|
||||
w /= 8;
|
||||
|
||||
iy = y;
|
||||
iy -= h;
|
||||
iy++;
|
||||
|
||||
for( j = 0; j < h; j++ )
|
||||
{
|
||||
ix = x;
|
||||
for( i = 0; i < w; i++ )
|
||||
{
|
||||
u8g_Draw8Pixel(u8g, ix, iy, 0, u8g_pgm_read(data));
|
||||
data++;
|
||||
ix+=8;
|
||||
}
|
||||
iy++;
|
||||
}
|
||||
return u8g->glyph_dx;
|
||||
}
|
||||
|
||||
int8_t u8g_DrawGlyph(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t encoding)
|
||||
{
|
||||
y += u8g->font_calc_vref(u8g);
|
||||
return u8g_draw_glyph(u8g, x, y, encoding);
|
||||
}
|
||||
|
||||
int8_t u8g_draw_glyph90(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t encoding)
|
||||
{
|
||||
const u8g_pgm_uint8_t *data;
|
||||
uint8_t w, h;
|
||||
uint8_t i, j;
|
||||
u8g_uint_t ix, iy;
|
||||
|
||||
{
|
||||
u8g_glyph_t g = u8g_GetGlyph(u8g, encoding);
|
||||
if ( g == NULL )
|
||||
return 0;
|
||||
data = u8g_font_GetGlyphDataStart(u8g->font, g);
|
||||
}
|
||||
|
||||
w = u8g->glyph_width;
|
||||
h = u8g->glyph_height;
|
||||
|
||||
x += u8g->glyph_y;
|
||||
x++;
|
||||
y += u8g->glyph_x;
|
||||
|
||||
if ( u8g_IsBBXIntersection(u8g, x, y, h, w) == 0 )
|
||||
return u8g->glyph_dx;
|
||||
|
||||
/* now, w is reused as bytes per line */
|
||||
w += 7;
|
||||
w /= 8;
|
||||
|
||||
ix = x;
|
||||
ix += h;
|
||||
ix--;
|
||||
for( j = 0; j < h; j++ )
|
||||
{
|
||||
iy = y;
|
||||
for( i = 0; i < w; i++ )
|
||||
{
|
||||
u8g_Draw8Pixel(u8g, ix, iy, 1, u8g_pgm_read(data));
|
||||
data++;
|
||||
iy+=8;
|
||||
}
|
||||
ix--;
|
||||
}
|
||||
return u8g->glyph_dx;
|
||||
}
|
||||
|
||||
int8_t u8g_DrawGlyph90(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t encoding)
|
||||
{
|
||||
x -= u8g->font_calc_vref(u8g);
|
||||
return u8g_draw_glyph90(u8g, x, y, encoding);
|
||||
}
|
||||
|
||||
|
||||
int8_t u8g_draw_glyph180(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t encoding)
|
||||
{
|
||||
const u8g_pgm_uint8_t *data;
|
||||
uint8_t w, h;
|
||||
uint8_t i, j;
|
||||
u8g_uint_t ix, iy;
|
||||
|
||||
{
|
||||
u8g_glyph_t g = u8g_GetGlyph(u8g, encoding);
|
||||
if ( g == NULL )
|
||||
return 0;
|
||||
data = u8g_font_GetGlyphDataStart(u8g->font, g);
|
||||
}
|
||||
|
||||
w = u8g->glyph_width;
|
||||
h = u8g->glyph_height;
|
||||
|
||||
x -= u8g->glyph_x;
|
||||
y += u8g->glyph_y;
|
||||
y++;
|
||||
|
||||
if ( u8g_IsBBXIntersection(u8g, x-(w-1), y, w, h) == 0 )
|
||||
return u8g->glyph_dx;
|
||||
|
||||
/* now, w is reused as bytes per line */
|
||||
w += 7;
|
||||
w /= 8;
|
||||
|
||||
iy = y;
|
||||
iy += h;
|
||||
iy--;
|
||||
for( j = 0; j < h; j++ )
|
||||
{
|
||||
ix = x;
|
||||
for( i = 0; i < w; i++ )
|
||||
{
|
||||
u8g_Draw8Pixel(u8g, ix, iy, 2, u8g_pgm_read(data));
|
||||
data++;
|
||||
ix-=8;
|
||||
}
|
||||
iy--;
|
||||
}
|
||||
return u8g->glyph_dx;
|
||||
}
|
||||
|
||||
int8_t u8g_DrawGlyph180(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t encoding)
|
||||
{
|
||||
y -= u8g->font_calc_vref(u8g);
|
||||
return u8g_draw_glyph180(u8g, x, y, encoding);
|
||||
}
|
||||
|
||||
|
||||
int8_t u8g_draw_glyph270(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t encoding)
|
||||
{
|
||||
const u8g_pgm_uint8_t *data;
|
||||
uint8_t w, h;
|
||||
uint8_t i, j;
|
||||
u8g_uint_t ix, iy;
|
||||
|
||||
{
|
||||
u8g_glyph_t g = u8g_GetGlyph(u8g, encoding);
|
||||
if ( g == NULL )
|
||||
return 0;
|
||||
data = u8g_font_GetGlyphDataStart(u8g->font, g);
|
||||
}
|
||||
|
||||
w = u8g->glyph_width;
|
||||
h = u8g->glyph_height;
|
||||
|
||||
x -= u8g->glyph_y;
|
||||
x--;
|
||||
y -= u8g->glyph_x;
|
||||
|
||||
if ( u8g_IsBBXIntersection(u8g, x-(h-1), y-(w-1), h, w) == 0 )
|
||||
return u8g->glyph_dx;
|
||||
|
||||
|
||||
/* now, w is reused as bytes per line */
|
||||
w += 7;
|
||||
w /= 8;
|
||||
|
||||
ix = x;
|
||||
ix -= h;
|
||||
ix++;
|
||||
|
||||
for( j = 0; j < h; j++ )
|
||||
{
|
||||
iy = y;
|
||||
for( i = 0; i < w; i++ )
|
||||
{
|
||||
u8g_Draw8Pixel(u8g, ix, iy, 3, u8g_pgm_read(data));
|
||||
data++;
|
||||
iy-=8;
|
||||
}
|
||||
ix++;
|
||||
}
|
||||
return u8g->glyph_dx;
|
||||
}
|
||||
|
||||
int8_t u8g_DrawGlyph270(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t encoding)
|
||||
{
|
||||
x += u8g->font_calc_vref(u8g);
|
||||
return u8g_draw_glyph270(u8g, x, y, encoding);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef OBSOLETE
|
||||
/*
|
||||
Draw a glyph
|
||||
x,y: lower left corner of the font bounding box
|
||||
*/
|
||||
int8_t u8g_DrawGlyphFontBBX(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_t encoding)
|
||||
{
|
||||
/* TODO: apply "dir" */
|
||||
x -= u8g_GetFontBBXOffX(u8g);
|
||||
y += u8g_GetFontBBXOffY(u8g);
|
||||
return u8g_DrawGlyphDir(u8g, x, y, dir, encoding);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*========================================================================*/
|
||||
/* string drawing procedures */
|
||||
|
||||
|
||||
u8g_uint_t u8g_DrawStr(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const char *s)
|
||||
{
|
||||
u8g_uint_t t = 0;
|
||||
int8_t d;
|
||||
|
||||
//u8g_uint_t u8g_GetStrWidth(u8g, s);
|
||||
//u8g_font_GetFontAscent(u8g->font)-u8g_font_GetFontDescent(u8g->font);
|
||||
|
||||
y += u8g->font_calc_vref(u8g);
|
||||
|
||||
while( *s != '\0' )
|
||||
{
|
||||
d = u8g_draw_glyph(u8g, x, y, *s);
|
||||
x += d;
|
||||
t += d;
|
||||
s++;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
u8g_uint_t u8g_DrawStr90(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const char *s)
|
||||
{
|
||||
u8g_uint_t t = 0;
|
||||
int8_t d;
|
||||
|
||||
x -= u8g->font_calc_vref(u8g);
|
||||
|
||||
while( *s != '\0' )
|
||||
{
|
||||
d = u8g_draw_glyph90(u8g, x, y, *s);
|
||||
y += d;
|
||||
t += d;
|
||||
s++;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
u8g_uint_t u8g_DrawStr180(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const char *s)
|
||||
{
|
||||
u8g_uint_t t = 0;
|
||||
int8_t d;
|
||||
|
||||
y -= u8g->font_calc_vref(u8g);
|
||||
|
||||
while( *s != '\0' )
|
||||
{
|
||||
d = u8g_draw_glyph180(u8g, x, y, *s);
|
||||
x -= d;
|
||||
t += d;
|
||||
s++;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
u8g_uint_t u8g_DrawStr270(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const char *s)
|
||||
{
|
||||
u8g_uint_t t = 0;
|
||||
int8_t d;
|
||||
|
||||
x += u8g->font_calc_vref(u8g);
|
||||
|
||||
while( *s != '\0' )
|
||||
{
|
||||
d = u8g_draw_glyph270(u8g, x, y, *s);
|
||||
y -= d;
|
||||
t += d;
|
||||
s++;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
u8g_uint_t u8g_DrawStrDir(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t dir, const char *s)
|
||||
{
|
||||
switch(dir)
|
||||
{
|
||||
case 0:
|
||||
return u8g_DrawStr(u8g, x, y, s);
|
||||
case 1:
|
||||
return u8g_DrawStr90(u8g, x, y, s);
|
||||
case 2:
|
||||
return u8g_DrawStr180(u8g, x, y, s);
|
||||
case 3:
|
||||
return u8g_DrawStr270(u8g, x, y, s);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
u8g_uint_t u8g_DrawStrP(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const u8g_pgm_uint8_t *s)
|
||||
{
|
||||
u8g_uint_t t = 0;
|
||||
int8_t d;
|
||||
uint8_t c;
|
||||
|
||||
y += u8g->font_calc_vref(u8g);
|
||||
|
||||
for(;;)
|
||||
{
|
||||
c = u8g_pgm_read(s);
|
||||
if ( c == '\0' )
|
||||
break;
|
||||
d = u8g_draw_glyph(u8g, x, y, c);
|
||||
x += d;
|
||||
t += d;
|
||||
s++;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
u8g_uint_t u8g_DrawStr90P(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const u8g_pgm_uint8_t *s)
|
||||
{
|
||||
u8g_uint_t t = 0;
|
||||
int8_t d;
|
||||
|
||||
x -= u8g->font_calc_vref(u8g);
|
||||
|
||||
while( *s != '\0' )
|
||||
{
|
||||
d = u8g_DrawGlyph90(u8g, x, y, u8g_pgm_read(s));
|
||||
y += d;
|
||||
t += d;
|
||||
s++;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
u8g_uint_t u8g_DrawStr180P(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const u8g_pgm_uint8_t *s)
|
||||
{
|
||||
u8g_uint_t t = 0;
|
||||
int8_t d;
|
||||
|
||||
y -= u8g->font_calc_vref(u8g);
|
||||
|
||||
while( *s != '\0' )
|
||||
{
|
||||
d = u8g_DrawGlyph180(u8g, x, y, u8g_pgm_read(s));
|
||||
x -= d;
|
||||
t += d;
|
||||
s++;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
u8g_uint_t u8g_DrawStr270P(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, const u8g_pgm_uint8_t *s)
|
||||
{
|
||||
u8g_uint_t t = 0;
|
||||
int8_t d;
|
||||
|
||||
x += u8g->font_calc_vref(u8g);
|
||||
|
||||
while( *s != '\0' )
|
||||
{
|
||||
d = u8g_DrawGlyph270(u8g, x, y, u8g_pgm_read(s));
|
||||
y -= d;
|
||||
t += d;
|
||||
s++;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
u8g_uint_t u8g_DrawStrFontBBX(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t dir, const char *s)
|
||||
{
|
||||
x -= u8g_GetFontBBXOffX(u8g);
|
||||
y += u8g_GetFontBBXOffY(u8g);
|
||||
return u8g_DrawStrDir(u8g, x, y, dir, s);
|
||||
}
|
||||
|
||||
/* still used by picgen.c, dir argument is ignored */
|
||||
int8_t u8g_DrawGlyphFontBBX(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_t encoding)
|
||||
{
|
||||
x -= u8g_GetFontBBXOffX(u8g);
|
||||
y += u8g_GetFontBBXOffY(u8g);
|
||||
u8g_draw_glyph(u8g, x, y, encoding);
|
||||
}
|
||||
|
||||
|
||||
/*========================================================================*/
|
||||
/* set ascent/descent for reference point calculation */
|
||||
|
||||
void u8g_UpdateRefHeight(u8g_t *u8g)
|
||||
{
|
||||
uint16_t ls;
|
||||
if ( u8g->font == NULL )
|
||||
return;
|
||||
if ( u8g->font_height_mode == U8G_FONT_HEIGHT_MODE_TEXT )
|
||||
{
|
||||
u8g->font_ref_ascent = u8g_font_GetCapitalAHeight(u8g->font);
|
||||
u8g->font_ref_descent = u8g_font_GetLowerGDescent(u8g->font);
|
||||
}
|
||||
else if ( u8g->font_height_mode == U8G_FONT_HEIGHT_MODE_XTEXT )
|
||||
{
|
||||
u8g->font_ref_ascent = u8g_font_GetFontXAscent(u8g->font);
|
||||
u8g->font_ref_descent = u8g_font_GetFontXDescent(u8g->font);
|
||||
}
|
||||
else
|
||||
{
|
||||
u8g->font_ref_ascent = u8g_font_GetFontAscent(u8g->font);
|
||||
u8g->font_ref_descent = u8g_font_GetFontDescent(u8g->font);
|
||||
}
|
||||
|
||||
ls = u8g->font_ref_ascent - u8g->font_ref_descent;
|
||||
if ( u8g->font_line_spacing_factor != 64 )
|
||||
{
|
||||
ls &= 255;
|
||||
ls *= u8g->font_line_spacing_factor;
|
||||
ls >>= 6;
|
||||
}
|
||||
u8g->line_spacing = ls;
|
||||
}
|
||||
|
||||
void u8g_SetFontRefHeightText(u8g_t *u8g)
|
||||
{
|
||||
u8g->font_height_mode = U8G_FONT_HEIGHT_MODE_TEXT;
|
||||
u8g_UpdateRefHeight(u8g);
|
||||
}
|
||||
|
||||
void u8g_SetFontRefHeightExtendedText(u8g_t *u8g)
|
||||
{
|
||||
u8g->font_height_mode = U8G_FONT_HEIGHT_MODE_XTEXT;
|
||||
u8g_UpdateRefHeight(u8g);
|
||||
}
|
||||
|
||||
|
||||
void u8g_SetFontRefHeightAll(u8g_t *u8g)
|
||||
{
|
||||
u8g->font_height_mode = U8G_FONT_HEIGHT_MODE_ALL;
|
||||
u8g_UpdateRefHeight(u8g);
|
||||
}
|
||||
|
||||
/* factor = 64: linespaceing == ascent and descent */
|
||||
void u8g_SetFontLineSpacingFactor(u8g_t *u8g, uint8_t factor)
|
||||
{
|
||||
u8g->font_line_spacing_factor = factor;
|
||||
u8g_UpdateRefHeight(u8g);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*========================================================================*/
|
||||
/* callback procedures to correct the y position */
|
||||
|
||||
u8g_uint_t u8g_font_calc_vref_font(u8g_t *u8g)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void u8g_SetFontPosBaseline(u8g_t *u8g)
|
||||
{
|
||||
u8g->font_calc_vref = u8g_font_calc_vref_font;
|
||||
}
|
||||
|
||||
|
||||
u8g_uint_t u8g_font_calc_vref_bottom(u8g_t *u8g)
|
||||
{
|
||||
/* y += (u8g_uint_t)(u8g_int_t)(u8g->font_ref_descent); */
|
||||
return (u8g_uint_t)(u8g_int_t)(u8g->font_ref_descent);
|
||||
}
|
||||
|
||||
void u8g_SetFontPosBottom(u8g_t *u8g)
|
||||
{
|
||||
u8g->font_calc_vref = u8g_font_calc_vref_bottom;
|
||||
}
|
||||
|
||||
u8g_uint_t u8g_font_calc_vref_top(u8g_t *u8g)
|
||||
{
|
||||
u8g_uint_t tmp;
|
||||
/* reference pos is one pixel above the upper edge of the reference glyph */
|
||||
|
||||
/*
|
||||
y += (u8g_uint_t)(u8g_int_t)(u8g->font_ref_ascent);
|
||||
y++;
|
||||
*/
|
||||
tmp = (u8g_uint_t)(u8g_int_t)(u8g->font_ref_ascent);
|
||||
tmp++;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
void u8g_SetFontPosTop(u8g_t *u8g)
|
||||
{
|
||||
u8g->font_calc_vref = u8g_font_calc_vref_top;
|
||||
}
|
||||
|
||||
u8g_uint_t u8g_font_calc_vref_center(u8g_t *u8g)
|
||||
{
|
||||
int8_t tmp;
|
||||
tmp = u8g->font_ref_ascent;
|
||||
tmp -= u8g->font_ref_descent;
|
||||
tmp /= 2;
|
||||
tmp += u8g->font_ref_descent;
|
||||
/* y += (u8g_uint_t)(u8g_int_t)(tmp); */
|
||||
return tmp;
|
||||
}
|
||||
|
||||
void u8g_SetFontPosCenter(u8g_t *u8g)
|
||||
{
|
||||
u8g->font_calc_vref = u8g_font_calc_vref_center;
|
||||
}
|
||||
|
||||
/*========================================================================*/
|
||||
/* string pixel width calculation */
|
||||
|
||||
char u8g_font_get_char(const void *s)
|
||||
{
|
||||
return *(const char *)(s);
|
||||
}
|
||||
|
||||
char u8g_font_get_charP(const void *s)
|
||||
{
|
||||
return u8g_pgm_read(s);
|
||||
}
|
||||
|
||||
typedef char (*u8g_font_get_char_fn)(const void *s);
|
||||
|
||||
|
||||
u8g_uint_t u8g_font_calc_str_pixel_width(u8g_t *u8g, const char *s, u8g_font_get_char_fn get_char )
|
||||
{
|
||||
u8g_uint_t w;
|
||||
uint8_t enc;
|
||||
|
||||
/* reset the total minimal width to zero, this will be expanded during calculation */
|
||||
w = 0;
|
||||
|
||||
enc = get_char(s);
|
||||
|
||||
/* check for empty string, width is already 0 */
|
||||
if ( enc == '\0' )
|
||||
{
|
||||
return w;
|
||||
}
|
||||
|
||||
/* get the glyph information of the first char. This must be valid, because we already checked for the empty string */
|
||||
/* if *s is not inside the font, then the cached parameters of the glyph are all zero */
|
||||
u8g_GetGlyph(u8g, enc);
|
||||
|
||||
/* strlen(s) == 1: width = width(s[0]) */
|
||||
/* strlen(s) == 2: width = - offx(s[0]) + deltax(s[0]) + offx(s[1]) + width(s[1]) */
|
||||
/* strlen(s) == 3: width = - offx(s[0]) + deltax(s[0]) + deltax(s[1]) + offx(s[2]) + width(s[2]) */
|
||||
|
||||
/* assume that the string has size 2 or more, than start with negative offset-x */
|
||||
/* for string with size 1, this will be nullified after the loop */
|
||||
w = -u8g->glyph_x;
|
||||
for(;;)
|
||||
{
|
||||
|
||||
/* check and stop if the end of the string is reached */
|
||||
s++;
|
||||
if ( get_char(s) == '\0' )
|
||||
break;
|
||||
|
||||
/* if there are still more characters, add the delta to the next glyph */
|
||||
w += u8g->glyph_dx;
|
||||
|
||||
/* store the encoding in a local variable, used also after the for(;;) loop */
|
||||
enc = get_char(s);
|
||||
|
||||
/* load the next glyph information */
|
||||
u8g_GetGlyph(u8g, enc);
|
||||
}
|
||||
|
||||
/* finally calculate the width of the last char */
|
||||
/* here is another exception, if the last char is a black, use the dx value instead */
|
||||
if ( enc != ' ' )
|
||||
{
|
||||
/* if g was not updated in the for loop (strlen() == 1), then the initial offset x gets removed */
|
||||
w += u8g->glyph_width;
|
||||
w += u8g->glyph_x;
|
||||
}
|
||||
else
|
||||
{
|
||||
w += u8g->glyph_dx;
|
||||
}
|
||||
|
||||
|
||||
return w;
|
||||
}
|
||||
|
||||
u8g_uint_t u8g_GetStrPixelWidth(u8g_t *u8g, const char *s)
|
||||
{
|
||||
return u8g_font_calc_str_pixel_width(u8g, s, u8g_font_get_char);
|
||||
}
|
||||
|
||||
u8g_uint_t u8g_GetStrPixelWidthP(u8g_t *u8g, const u8g_pgm_uint8_t *s)
|
||||
{
|
||||
return u8g_font_calc_str_pixel_width(u8g, (const char *)s, u8g_font_get_charP);
|
||||
}
|
||||
|
||||
int8_t u8g_GetStrX(u8g_t *u8g, const char *s)
|
||||
{
|
||||
u8g_GetGlyph(u8g, *s);
|
||||
return u8g->glyph_x;
|
||||
}
|
||||
|
||||
int8_t u8g_GetStrXP(u8g_t *u8g, const u8g_pgm_uint8_t *s)
|
||||
{
|
||||
u8g_GetGlyph(u8g, u8g_pgm_read(s));
|
||||
return u8g->glyph_x;
|
||||
}
|
||||
|
||||
/*========================================================================*/
|
||||
/* string width calculation */
|
||||
|
||||
u8g_uint_t u8g_GetStrWidth(u8g_t *u8g, const char *s)
|
||||
{
|
||||
u8g_uint_t w;
|
||||
uint8_t encoding;
|
||||
|
||||
/* reset the total width to zero, this will be expanded during calculation */
|
||||
w = 0;
|
||||
|
||||
for(;;)
|
||||
{
|
||||
encoding = *s;
|
||||
if ( encoding == 0 )
|
||||
break;
|
||||
|
||||
/* load glyph information */
|
||||
u8g_GetGlyph(u8g, encoding);
|
||||
w += u8g->glyph_dx;
|
||||
|
||||
/* goto next char */
|
||||
s++;
|
||||
}
|
||||
|
||||
return w;
|
||||
}
|
||||
|
||||
|
||||
u8g_uint_t u8g_GetStrWidthP(u8g_t *u8g, const u8g_pgm_uint8_t *s)
|
||||
{
|
||||
u8g_uint_t w;
|
||||
uint8_t encoding;
|
||||
|
||||
/* reset the total width to zero, this will be expanded during calculation */
|
||||
w = 0;
|
||||
|
||||
for(;;)
|
||||
{
|
||||
encoding = u8g_pgm_read(s);
|
||||
if ( encoding == 0 )
|
||||
break;
|
||||
|
||||
/* load glyph information */
|
||||
u8g_GetGlyph(u8g, encoding);
|
||||
w += u8g->glyph_dx;
|
||||
|
||||
/* goto next char */
|
||||
s++;
|
||||
}
|
||||
|
||||
return w;
|
||||
}
|
||||
|
||||
|
||||
/*========================================================================*/
|
||||
/* calculation of font/glyph/string characteristics */
|
||||
|
||||
|
||||
/*
|
||||
Description:
|
||||
Calculate parameter for the minimal bounding box on a given string
|
||||
Output
|
||||
buf->y_min extend of the lower left edge if the string below (y_min<0) or above (y_min>0) baseline (descent)
|
||||
buf->y_max extend of the upper left edge if the string below (y_min<0) or above (y_min>0) baseline (ascent)
|
||||
buf->w the width of the string
|
||||
*/
|
||||
struct u8g_str_size_struct
|
||||
{
|
||||
int8_t y_min; /* descent */
|
||||
int8_t y_max; /* ascent */
|
||||
int8_t x, y; /* the reference point of the font (negated!) */
|
||||
u8g_uint_t w; /* width of the overall string */
|
||||
};
|
||||
typedef struct u8g_str_size_struct u8g_str_size_t;
|
||||
|
||||
static void u8g_font_calc_str_min_box(u8g_t *u8g, const char *s, u8g_str_size_t *buf)
|
||||
{
|
||||
/* u8g_glyph_t g; */
|
||||
int8_t tmp;
|
||||
|
||||
/* reset the total minimal width to zero, this will be expanded during calculation */
|
||||
buf->w = 0;
|
||||
|
||||
/* check for empty string, width is already 0, but also reset y_min and y_max to 0 */
|
||||
if ( *s == '\0' )
|
||||
{
|
||||
buf->y_min = 0;
|
||||
buf->y_max = 0;
|
||||
buf->x = 0;
|
||||
buf->y = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
/* reset y_min to the largest possible value. Later we search for the smallest value */
|
||||
/* y_min contains the position [pixel] of the lower left edge of the glyph above (y_min>0) or below (y_min<0) baseline */
|
||||
buf->y_min = 127;
|
||||
/* reset y_max to the smallest possible value. Later we search for the highest value */
|
||||
/* y_max contains the position [pixel] of the upper left edge of the glyph above (y_max>0) or below (y_max<0) baseline */
|
||||
buf->y_max = -128;
|
||||
|
||||
/* get the glyph information of the first char. This must be valid, because we already checked for the empty string */
|
||||
u8g_GetGlyph(u8g, *s);
|
||||
|
||||
/* strlen(s) == 1: width = width(s[0]) */
|
||||
/* strlen(s) == 2: width = - offx(s[0]) + deltax(s[0]) + offx(s[1]) + width(s[1]) */
|
||||
/* strlen(s) == 3: width = - offx(s[0]) + deltax(s[0]) + deltax(s[1]) + offx(s[2]) + width(s[2]) */
|
||||
|
||||
/* assume that the string has size 2 or more, than start with negative offset-x */
|
||||
/* for string with size 1, this will be nullified after the loop */
|
||||
// buf->w = - u8g_font_GetGlyphBBXOffX(u8g->font, g);
|
||||
buf->w = - u8g->glyph_x;
|
||||
|
||||
/* Also copy the position of the first glyph. This is the reference point of the string (negated) */
|
||||
buf->x = u8g->glyph_x;
|
||||
buf->y = u8g->glyph_y;
|
||||
|
||||
for(;;)
|
||||
{
|
||||
|
||||
/* calculated y position of the upper left corner (y_max) and lower left corner (y_min) of the string */
|
||||
/* relative to the base line */
|
||||
|
||||
tmp = u8g->glyph_y;
|
||||
if ( buf->y_min > tmp )
|
||||
buf->y_min = tmp;
|
||||
|
||||
tmp +=u8g->glyph_height;
|
||||
if ( buf->y_max < tmp )
|
||||
buf->y_max = tmp;
|
||||
|
||||
/* check and stop if the end of the string is reached */
|
||||
s++;
|
||||
if ( *s == '\0' )
|
||||
break;
|
||||
|
||||
/* if there are still more characters, add the delta to the next glyph */
|
||||
buf->w += u8g->glyph_dx;
|
||||
|
||||
/* load the next glyph information */
|
||||
u8g_GetGlyph(u8g, *s);
|
||||
}
|
||||
|
||||
/* finally calculate the width of the last char */
|
||||
/* if g was not updated in the for loop (strlen() == 1), then the initial offset x gets removed */
|
||||
buf->w += u8g->glyph_width;
|
||||
// buf->w += u8g_font_GetGlyphBBXOffX(u8g->font, g);
|
||||
|
||||
buf->w += u8g->glyph_x;
|
||||
}
|
||||
|
||||
/* calculate minimal box */
|
||||
void u8g_font_box_min(u8g_t *u8g, const char *s, u8g_str_size_t *buf)
|
||||
{
|
||||
u8g_font_calc_str_min_box(u8g, s, buf);
|
||||
}
|
||||
|
||||
/* calculate gA box, but do not calculate the overall width */
|
||||
void u8g_font_box_left_gA(u8g_t *u8g, const char *s, u8g_str_size_t *buf)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/* calculate gA box, including overall width */
|
||||
void u8g_font_box_all_gA(u8g_t *u8g, const char *s, u8g_str_size_t *buf)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void u8g_font_get_str_box_fill_args(u8g_t *u8g, const char *s, u8g_str_size_t *buf, u8g_uint_t *x, u8g_uint_t *y, u8g_uint_t *width, u8g_uint_t *height)
|
||||
{
|
||||
/*
|
||||
u8g_glyph_t g;
|
||||
g =
|
||||
*/
|
||||
u8g_GetGlyph(u8g, *s);
|
||||
*x += u8g->glyph_x;
|
||||
*width = buf->w;
|
||||
*y -= buf->y_max;
|
||||
/* +1 because y_max is a height, this compensates the next step */
|
||||
//*y += 1;
|
||||
/* because the reference point is one below the string, this compensates the previous step */
|
||||
//*y -= 1;
|
||||
*height = buf->y_max;
|
||||
*height -= buf->y_min;
|
||||
}
|
||||
|
||||
|
||||
void u8g_GetStrMinBox(u8g_t *u8g, const char *s, u8g_uint_t *x, u8g_uint_t *y, u8g_uint_t *width, u8g_uint_t *height)
|
||||
{
|
||||
u8g_str_size_t buf;
|
||||
|
||||
if ( *s == '\0' )
|
||||
{
|
||||
*width= 0;
|
||||
*height = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
u8g_font_calc_str_min_box(u8g, s, &buf);
|
||||
u8g_font_get_str_box_fill_args(u8g, s, &buf, x, y, width, height);
|
||||
}
|
||||
|
||||
|
||||
void u8g_GetStrAMinBox(u8g_t *u8g, const char *s, u8g_uint_t *x, u8g_uint_t *y, u8g_uint_t *width, u8g_uint_t *height)
|
||||
{
|
||||
u8g_str_size_t buf;
|
||||
uint8_t cap_a;
|
||||
|
||||
if ( *s == '\0' )
|
||||
{
|
||||
*width= 0;
|
||||
*height = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
cap_a = u8g_font_GetCapitalAHeight(u8g->font);
|
||||
u8g_font_calc_str_min_box(u8g, s, &buf);
|
||||
if ( buf.y_max < cap_a )
|
||||
buf.y_max = cap_a;
|
||||
u8g_font_get_str_box_fill_args(u8g, s, &buf, x, y, width, height);
|
||||
}
|
||||
|
||||
void u8g_SetFont(u8g_t *u8g, const u8g_fntpgm_uint8_t *font)
|
||||
{
|
||||
if ( u8g->font != font )
|
||||
{
|
||||
u8g->font = font;
|
||||
u8g_UpdateRefHeight(u8g);
|
||||
u8g_SetFontPosBaseline(u8g);
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,81 @@
|
||||
/*
|
||||
|
||||
u8g_line.h
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2012, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
void u8g_DrawLine(u8g_t *u8g, u8g_uint_t x1, u8g_uint_t y1, u8g_uint_t x2, u8g_uint_t y2)
|
||||
{
|
||||
u8g_uint_t tmp;
|
||||
u8g_uint_t x,y;
|
||||
u8g_uint_t dx, dy;
|
||||
u8g_int_t err;
|
||||
u8g_int_t ystep;
|
||||
|
||||
uint8_t swapxy = 0;
|
||||
|
||||
/* no BBX intersection check at the moment, should be added... */
|
||||
|
||||
if ( x1 > x2 ) dx = x1-x2; else dx = x2-x1;
|
||||
if ( y1 > y2 ) dy = y1-y2; else dy = y2-y1;
|
||||
|
||||
if ( dy > dx )
|
||||
{
|
||||
swapxy = 1;
|
||||
tmp = dx; dx =dy; dy = tmp;
|
||||
tmp = x1; x1 =y1; y1 = tmp;
|
||||
tmp = x2; x2 =y2; y2 = tmp;
|
||||
}
|
||||
if ( x1 > x2 )
|
||||
{
|
||||
tmp = x1; x1 =x2; x2 = tmp;
|
||||
tmp = y1; y1 =y2; y2 = tmp;
|
||||
}
|
||||
err = dx >> 1;
|
||||
if ( y2 > y1 ) ystep = 1; else ystep = -1;
|
||||
y = y1;
|
||||
for( x = x1; x <= x2; x++ )
|
||||
{
|
||||
if ( swapxy == 0 )
|
||||
u8g_DrawPixel(u8g, x, y);
|
||||
else
|
||||
u8g_DrawPixel(u8g, y, x);
|
||||
err -= (uint8_t)dy;
|
||||
if ( err < 0 )
|
||||
{
|
||||
y += (u8g_uint_t)ystep;
|
||||
err += (u8g_uint_t)dx;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,456 @@
|
||||
/*
|
||||
|
||||
u8g_ll_api.c
|
||||
|
||||
low level api
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include "u8g.h"
|
||||
|
||||
uint8_t u8g_call_dev_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
return dev->dev_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
/*====================================================================*/
|
||||
|
||||
uint8_t u8g_InitLL(u8g_t *u8g, u8g_dev_t *dev)
|
||||
{
|
||||
uint8_t r;
|
||||
u8g->state_cb(U8G_STATE_MSG_BACKUP_ENV);
|
||||
r = u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_INIT, NULL);
|
||||
u8g->state_cb(U8G_STATE_MSG_BACKUP_U8G);
|
||||
u8g->state_cb(U8G_STATE_MSG_RESTORE_ENV);
|
||||
return r;
|
||||
}
|
||||
|
||||
void u8g_FirstPageLL(u8g_t *u8g, u8g_dev_t *dev)
|
||||
{
|
||||
u8g->state_cb(U8G_STATE_MSG_BACKUP_ENV);
|
||||
u8g->state_cb(U8G_STATE_MSG_RESTORE_U8G);
|
||||
u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_PAGE_FIRST, NULL);
|
||||
u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_GET_PAGE_BOX, &(u8g->current_page));
|
||||
u8g->state_cb(U8G_STATE_MSG_RESTORE_ENV);
|
||||
}
|
||||
|
||||
uint8_t u8g_NextPageLL(u8g_t *u8g, u8g_dev_t *dev)
|
||||
{
|
||||
uint8_t r;
|
||||
u8g->state_cb(U8G_STATE_MSG_BACKUP_ENV);
|
||||
u8g->state_cb(U8G_STATE_MSG_RESTORE_U8G);
|
||||
r = u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_PAGE_NEXT, NULL);
|
||||
if ( r != 0 )
|
||||
{
|
||||
u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_GET_PAGE_BOX, &(u8g->current_page));
|
||||
}
|
||||
u8g->state_cb(U8G_STATE_MSG_RESTORE_ENV);
|
||||
return r;
|
||||
}
|
||||
|
||||
uint8_t u8g_SetContrastLL(u8g_t *u8g, u8g_dev_t *dev, uint8_t contrast)
|
||||
{
|
||||
return u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_CONTRAST, &contrast);
|
||||
}
|
||||
|
||||
void u8g_DrawPixelLL(u8g_t *u8g, u8g_dev_t *dev, u8g_uint_t x, u8g_uint_t y)
|
||||
{
|
||||
u8g_dev_arg_pixel_t *arg = &(u8g->arg_pixel);
|
||||
arg->x = x;
|
||||
arg->y = y;
|
||||
u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_SET_PIXEL, arg);
|
||||
}
|
||||
|
||||
void u8g_Draw8PixelLL(u8g_t *u8g, u8g_dev_t *dev, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_t pixel)
|
||||
{
|
||||
u8g_dev_arg_pixel_t *arg = &(u8g->arg_pixel);
|
||||
arg->x = x;
|
||||
arg->y = y;
|
||||
arg->dir = dir;
|
||||
arg->pixel = pixel;
|
||||
u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_SET_8PIXEL, arg);
|
||||
}
|
||||
|
||||
#ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
|
||||
uint8_t u8g_IsBBXIntersectionLL(u8g_t *u8g, u8g_dev_t *dev, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h)
|
||||
{
|
||||
return u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_IS_BBX_INTERSECTION, &arg);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
u8g_uint_t u8g_GetWidthLL(u8g_t *u8g, u8g_dev_t *dev)
|
||||
{
|
||||
u8g_uint_t r;
|
||||
u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_GET_WIDTH, &r);
|
||||
return r;
|
||||
}
|
||||
|
||||
u8g_uint_t u8g_GetHeightLL(u8g_t *u8g, u8g_dev_t *dev)
|
||||
{
|
||||
u8g_uint_t r;
|
||||
u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_GET_HEIGHT, &r);
|
||||
return r;
|
||||
}
|
||||
|
||||
u8g_uint_t u8g_GetModeLL(u8g_t *u8g, u8g_dev_t *dev)
|
||||
{
|
||||
return u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_GET_MODE, NULL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*====================================================================*/
|
||||
|
||||
void u8g_UpdateDimension(u8g_t *u8g)
|
||||
{
|
||||
u8g->width = u8g_GetWidthLL(u8g, u8g->dev);
|
||||
u8g->height = u8g_GetHeightLL(u8g, u8g->dev);
|
||||
u8g->mode = u8g_GetModeLL(u8g, u8g->dev);
|
||||
/* 9 Dec 2012: u8g_scale.c requires update of current page */
|
||||
u8g_call_dev_fn(u8g, u8g->dev, U8G_DEV_MSG_GET_PAGE_BOX, &(u8g->current_page));
|
||||
}
|
||||
|
||||
static void u8g_init_data(u8g_t *u8g)
|
||||
{
|
||||
uint8_t i;
|
||||
u8g->font = NULL;
|
||||
u8g->cursor_font = NULL;
|
||||
u8g->cursor_bg_color = 0;
|
||||
u8g->cursor_fg_color = 1;
|
||||
u8g->cursor_encoding = 34;
|
||||
u8g->cursor_fn = (u8g_draw_cursor_fn)0;
|
||||
|
||||
for( i = 0; i < U8G_PIN_LIST_LEN; i++ )
|
||||
u8g->pin_list[i] = U8G_PIN_NONE;
|
||||
|
||||
u8g_SetColorIndex(u8g, 1);
|
||||
|
||||
u8g_SetFontPosBaseline(u8g);
|
||||
|
||||
u8g->font_height_mode = U8G_FONT_HEIGHT_MODE_XTEXT;
|
||||
u8g->font_ref_ascent = 0;
|
||||
u8g->font_ref_descent = 0;
|
||||
u8g->font_line_spacing_factor = 64; /* 64 = 1.0, 77 = 1.2 line spacing factor */
|
||||
u8g->line_spacing = 0;
|
||||
|
||||
u8g->state_cb = u8g_state_dummy_cb;
|
||||
|
||||
}
|
||||
|
||||
uint8_t u8g_Begin(u8g_t *u8g)
|
||||
{
|
||||
/* call and init low level driver and com device */
|
||||
if ( u8g_InitLL(u8g, u8g->dev) == 0 )
|
||||
return 0;
|
||||
/* fetch width and height from the low level */
|
||||
u8g_UpdateDimension(u8g);
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint8_t u8g_Init(u8g_t *u8g, u8g_dev_t *dev)
|
||||
{
|
||||
u8g_init_data(u8g);
|
||||
u8g->dev = dev;
|
||||
|
||||
/* On the Arduino Environment this will lead to two calls to u8g_Begin(), the following line will be called first (by U8glib constructors) */
|
||||
/* if - in future releases - this is removed, then still call u8g_UpdateDimension() */
|
||||
/* if Arduino call u8g_UpdateDimension else u8g_Begin */
|
||||
/* issue 146 */
|
||||
return u8g_Begin(u8g);
|
||||
}
|
||||
|
||||
uint8_t u8g_InitSPI(u8g_t *u8g, u8g_dev_t *dev, uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset)
|
||||
{
|
||||
|
||||
/* fill data structure with some suitable values */
|
||||
u8g_init_data(u8g);
|
||||
u8g->dev = dev;
|
||||
|
||||
/* assign user pins */
|
||||
u8g->pin_list[U8G_PI_SCK] = sck;
|
||||
u8g->pin_list[U8G_PI_MOSI] = mosi;
|
||||
u8g->pin_list[U8G_PI_CS] = cs;
|
||||
u8g->pin_list[U8G_PI_A0] = a0;
|
||||
u8g->pin_list[U8G_PI_RESET] = reset;
|
||||
|
||||
/* On the Arduino Environment this will lead to two calls to u8g_Begin(), the following line will be called first (by U8glib constructors) */
|
||||
/* if - in future releases - this is removed, then still call u8g_UpdateDimension() */
|
||||
/* if Arduino call u8g_UpdateDimension else u8g_Begin */
|
||||
/* issue 146 */
|
||||
return u8g_Begin(u8g);
|
||||
}
|
||||
|
||||
uint8_t u8g_InitHWSPI(u8g_t *u8g, u8g_dev_t *dev, uint8_t cs, uint8_t a0, uint8_t reset)
|
||||
{
|
||||
/* fill data structure with some suitable values */
|
||||
u8g_init_data(u8g);
|
||||
u8g->dev = dev;
|
||||
|
||||
|
||||
/* assign user pins */
|
||||
u8g->pin_list[U8G_PI_CS] = cs;
|
||||
u8g->pin_list[U8G_PI_A0] = a0;
|
||||
u8g->pin_list[U8G_PI_RESET] = reset;
|
||||
|
||||
return u8g_Begin(u8g);
|
||||
}
|
||||
|
||||
uint8_t u8g_InitI2C(u8g_t *u8g, u8g_dev_t *dev, uint8_t options)
|
||||
{
|
||||
/* fill data structure with some suitable values */
|
||||
u8g_init_data(u8g);
|
||||
u8g->dev = dev;
|
||||
|
||||
u8g->pin_list[U8G_PI_I2C_OPTION] = options;
|
||||
|
||||
return u8g_Begin(u8g);
|
||||
}
|
||||
|
||||
|
||||
uint8_t u8g_Init8BitFixedPort(u8g_t *u8g, u8g_dev_t *dev, uint8_t en, uint8_t cs, uint8_t di, uint8_t rw, uint8_t reset)
|
||||
{
|
||||
|
||||
/* fill data structure with some suitable values */
|
||||
u8g_init_data(u8g);
|
||||
u8g->dev = dev;
|
||||
|
||||
/* assign user pins */
|
||||
|
||||
u8g->pin_list[U8G_PI_EN] = en;
|
||||
u8g->pin_list[U8G_PI_CS] = cs;
|
||||
u8g->pin_list[U8G_PI_DI] = di;
|
||||
u8g->pin_list[U8G_PI_RW] = rw;
|
||||
u8g->pin_list[U8G_PI_RESET] = reset;
|
||||
|
||||
return u8g_Begin(u8g);
|
||||
}
|
||||
|
||||
uint8_t u8g_Init8Bit(u8g_t *u8g, u8g_dev_t *dev, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7,
|
||||
uint8_t en, uint8_t cs1, uint8_t cs2, uint8_t di, uint8_t rw, uint8_t reset)
|
||||
{
|
||||
|
||||
/* fill data structure with some suitable values */
|
||||
u8g_init_data(u8g);
|
||||
u8g->dev = dev;
|
||||
|
||||
/* assign user pins */
|
||||
|
||||
u8g->pin_list[U8G_PI_D0] = d0;
|
||||
u8g->pin_list[U8G_PI_D1] = d1;
|
||||
u8g->pin_list[U8G_PI_D2] = d2;
|
||||
u8g->pin_list[U8G_PI_D3] = d3;
|
||||
u8g->pin_list[U8G_PI_D4] = d4;
|
||||
u8g->pin_list[U8G_PI_D5] = d5;
|
||||
u8g->pin_list[U8G_PI_D6] = d6;
|
||||
u8g->pin_list[U8G_PI_D7] = d7;
|
||||
|
||||
u8g->pin_list[U8G_PI_EN] = en;
|
||||
u8g->pin_list[U8G_PI_CS1] = cs1;
|
||||
u8g->pin_list[U8G_PI_CS2] = cs2;
|
||||
u8g->pin_list[U8G_PI_DI] = di;
|
||||
u8g->pin_list[U8G_PI_RW] = rw;
|
||||
u8g->pin_list[U8G_PI_RESET] = reset;
|
||||
|
||||
return u8g_Begin(u8g);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
PIN_D0 8
|
||||
PIN_D1 9
|
||||
PIN_D2 10
|
||||
PIN_D3 11
|
||||
PIN_D4 4
|
||||
PIN_D5 5
|
||||
PIN_D6 6
|
||||
PIN_D7 7
|
||||
|
||||
PIN_CS 14
|
||||
PIN_A0 15
|
||||
PIN_RESET 16
|
||||
PIN_WR 17
|
||||
PIN_RD 18
|
||||
|
||||
u8g_InitRW8Bit(u8g, dev, d0, d1, d2, d3, d4, d5, d6, d7, cs, a0, wr, rd, reset)
|
||||
u8g_InitRW8Bit(u8g, dev, 8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16)
|
||||
|
||||
*/
|
||||
|
||||
uint8_t u8g_InitRW8Bit(u8g_t *u8g, u8g_dev_t *dev, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7,
|
||||
uint8_t cs, uint8_t a0, uint8_t wr, uint8_t rd, uint8_t reset)
|
||||
{
|
||||
|
||||
/* fill data structure with some suitable values */
|
||||
u8g_init_data(u8g);
|
||||
u8g->dev = dev;
|
||||
|
||||
/* assign user pins */
|
||||
|
||||
u8g->pin_list[U8G_PI_D0] = d0;
|
||||
u8g->pin_list[U8G_PI_D1] = d1;
|
||||
u8g->pin_list[U8G_PI_D2] = d2;
|
||||
u8g->pin_list[U8G_PI_D3] = d3;
|
||||
u8g->pin_list[U8G_PI_D4] = d4;
|
||||
u8g->pin_list[U8G_PI_D5] = d5;
|
||||
u8g->pin_list[U8G_PI_D6] = d6;
|
||||
u8g->pin_list[U8G_PI_D7] = d7;
|
||||
|
||||
u8g->pin_list[U8G_PI_CS] = cs;
|
||||
u8g->pin_list[U8G_PI_A0] = a0;
|
||||
u8g->pin_list[U8G_PI_WR] = wr;
|
||||
u8g->pin_list[U8G_PI_RD] = rd;
|
||||
u8g->pin_list[U8G_PI_RESET] = reset;
|
||||
|
||||
return u8g_Begin(u8g);
|
||||
}
|
||||
|
||||
void u8g_FirstPage(u8g_t *u8g)
|
||||
{
|
||||
u8g_FirstPageLL(u8g, u8g->dev);
|
||||
}
|
||||
|
||||
uint8_t u8g_NextPage(u8g_t *u8g)
|
||||
{
|
||||
if ( u8g->cursor_fn != (u8g_draw_cursor_fn)0 )
|
||||
{
|
||||
u8g->cursor_fn(u8g);
|
||||
}
|
||||
return u8g_NextPageLL(u8g, u8g->dev);
|
||||
}
|
||||
|
||||
uint8_t u8g_SetContrast(u8g_t *u8g, uint8_t contrast)
|
||||
{
|
||||
return u8g_SetContrastLL(u8g, u8g->dev, contrast);
|
||||
}
|
||||
|
||||
void u8g_SleepOn(u8g_t *u8g)
|
||||
{
|
||||
u8g_call_dev_fn(u8g, u8g->dev, U8G_DEV_MSG_SLEEP_ON, NULL);
|
||||
}
|
||||
|
||||
void u8g_SleepOff(u8g_t *u8g)
|
||||
{
|
||||
u8g_call_dev_fn(u8g, u8g->dev, U8G_DEV_MSG_SLEEP_OFF, NULL);
|
||||
}
|
||||
|
||||
|
||||
void u8g_DrawPixel(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y)
|
||||
{
|
||||
u8g_DrawPixelLL(u8g, u8g->dev, x, y);
|
||||
}
|
||||
|
||||
void u8g_Draw8Pixel(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_t pixel)
|
||||
{
|
||||
u8g_Draw8PixelLL(u8g, u8g->dev, x, y, dir, pixel);
|
||||
}
|
||||
|
||||
/* u8g_IsBBXIntersection() has been moved to u8g_clip.c */
|
||||
#ifdef OBSOLETE_CODE
|
||||
uint8_t u8g_IsBBXIntersection(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h)
|
||||
{
|
||||
/* new code */
|
||||
u8g_dev_arg_bbx_t arg;
|
||||
arg.x = x;
|
||||
arg.y = y;
|
||||
arg.w = w;
|
||||
arg.h = h;
|
||||
return u8g_is_box_bbx_intersection(&(u8g->current_page), &arg);
|
||||
|
||||
/* old code */
|
||||
//return u8g_IsBBXIntersectionLL(u8g, u8g->dev, x, y, w, h);
|
||||
}
|
||||
#endif
|
||||
|
||||
void u8g_SetColorIndex(u8g_t *u8g, uint8_t idx)
|
||||
{
|
||||
u8g->arg_pixel.color = idx;
|
||||
/*u8g->color_index = idx; */ /* must be removed */
|
||||
}
|
||||
|
||||
uint8_t u8g_GetColorIndex(u8g_t *u8g)
|
||||
{
|
||||
return u8g->arg_pixel.color;
|
||||
}
|
||||
|
||||
uint8_t u8g_GetDefaultForegroundColor(u8g_t *u8g)
|
||||
{
|
||||
uint8_t mode;
|
||||
mode = u8g_GetMode(u8g);
|
||||
if ( mode == U8G_MODE_R3G3B2 )
|
||||
return 255; /* white */
|
||||
else if ( u8g_GetMode(u8g) == U8G_MODE_GRAY2BIT )
|
||||
return 3; /* max intensity */
|
||||
else /* if ( u8g.getMode() == U8G_MODE_BW ) */
|
||||
return 1; /* pixel on */
|
||||
return 1;
|
||||
}
|
||||
|
||||
void u8g_SetDefaultForegroundColor(u8g_t *u8g)
|
||||
{
|
||||
u8g_SetColorIndex(u8g, u8g_GetDefaultForegroundColor(u8g));
|
||||
}
|
||||
|
||||
uint8_t u8g_GetDefaultBackgroundColor(u8g_t *u8g)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void u8g_SetDefaultBackgroundColor(u8g_t *u8g)
|
||||
{
|
||||
u8g_SetColorIndex(u8g, u8g_GetDefaultBackgroundColor(u8g)); /* pixel on / black */
|
||||
}
|
||||
|
||||
uint8_t u8g_GetDefaultMidColor(u8g_t *u8g)
|
||||
{
|
||||
uint8_t mode;
|
||||
mode = u8g_GetMode(u8g);
|
||||
if ( mode == U8G_MODE_R3G3B2 )
|
||||
return 0x06d; /* gray: 01101101 */
|
||||
else if ( u8g_GetMode(u8g) == U8G_MODE_GRAY2BIT )
|
||||
return 1; /* low mid intensity */
|
||||
else /* if ( u8g.getMode() == U8G_MODE_BW ) */
|
||||
return 1; /* pixel on */
|
||||
return 1; /* default */
|
||||
}
|
||||
|
||||
void u8g_SetDefaultMidColor(u8g_t *u8g)
|
||||
{
|
||||
u8g_SetColorIndex(u8g, u8g_GetDefaultMidColor(u8g));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,81 @@
|
||||
/*
|
||||
|
||||
u8g_page.c
|
||||
|
||||
page helper functions, only called by the dev handler.
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
/*
|
||||
setup page count structure
|
||||
conditions: page_height <= total_height
|
||||
*/
|
||||
void u8g_page_Init(u8g_page_t *p, u8g_uint_t page_height, u8g_uint_t total_height )
|
||||
{
|
||||
p->page_height = page_height;
|
||||
p->total_height = total_height;
|
||||
p->page = 0;
|
||||
u8g_page_First(p);
|
||||
}
|
||||
|
||||
void u8g_page_First(u8g_page_t *p)
|
||||
{
|
||||
p->page_y0 = 0;
|
||||
p->page_y1 = p->page_height;
|
||||
p->page_y1--;
|
||||
p->page = 0;
|
||||
}
|
||||
|
||||
uint8_t u8g_page_Next(u8g_page_t * p)
|
||||
{
|
||||
register u8g_uint_t y1;
|
||||
p->page_y0 += p->page_height;
|
||||
if ( p->page_y0 >= p->total_height )
|
||||
return 0;
|
||||
p->page++;
|
||||
y1 = p->page_y1;
|
||||
y1 += p->page_height;
|
||||
if ( y1 >= p->total_height )
|
||||
{
|
||||
y1 = p->total_height;
|
||||
y1--;
|
||||
}
|
||||
p->page_y1 = y1;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
@ -0,0 +1,191 @@
|
||||
/*
|
||||
|
||||
u8g_pb.c
|
||||
|
||||
common procedures for the page buffer
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
void u8g_pb_Clear(u8g_pb_t *b)
|
||||
{
|
||||
uint8_t *ptr = (uint8_t *)b->buf;
|
||||
uint8_t *end_ptr = ptr;
|
||||
end_ptr += b->width;
|
||||
do
|
||||
{
|
||||
*ptr++ = 0;
|
||||
} while( ptr != end_ptr );
|
||||
}
|
||||
|
||||
/* the following procedure does not work. why? Can be checked with descpic */
|
||||
/*
|
||||
void u8g_pb_Clear(u8g_pb_t *b)
|
||||
{
|
||||
uint8_t *ptr = (uint8_t *)b->buf;
|
||||
uint8_t cnt = b->width;
|
||||
do
|
||||
{
|
||||
*ptr++ = 0;
|
||||
cnt--;
|
||||
} while( cnt != 0 );
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
intersection assumptions:
|
||||
a1 <= a2 is always true
|
||||
*/
|
||||
/*
|
||||
minimized version
|
||||
---1----0 1 b1 <= a2 && b1 > b2
|
||||
-----1--0 1 b2 >= a1 && b1 > b2
|
||||
---1-1--- 1 b1 <= a2 && b2 >= a1
|
||||
*/
|
||||
/*
|
||||
uint8_t u8g_pb8v1_IsYIntersection___Old(u8g_pb_t *b, u8g_uint_t v0, u8g_uint_t v1)
|
||||
{
|
||||
uint8_t c0, c1, c;
|
||||
c0 = v0 <= b->p.page_y1;
|
||||
c1 = v1 >= b->p.page_y0;
|
||||
c = v0 > v1;
|
||||
if ( c0 && c1 ) return 1;
|
||||
if ( c0 && c ) return 1;
|
||||
if ( c1 && c ) return 1;
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
uint8_t u8g_pb_IsYIntersection(u8g_pb_t *pb, u8g_uint_t v0, u8g_uint_t v1)
|
||||
{
|
||||
uint8_t c1, c2, c3, tmp;
|
||||
c1 = v0 <= pb->p.page_y1;
|
||||
c2 = v1 >= pb->p.page_y0;
|
||||
c3 = v0 > v1;
|
||||
/*
|
||||
if ( c1 && c2 )
|
||||
return 1;
|
||||
if ( c1 && c3 )
|
||||
return 1;
|
||||
if ( c2 && c3 )
|
||||
return 1;
|
||||
return 0;
|
||||
*/
|
||||
|
||||
tmp = c1;
|
||||
c1 &= c2;
|
||||
c2 &= c3;
|
||||
c3 &= tmp;
|
||||
c1 |= c2;
|
||||
c1 |= c3;
|
||||
return c1 & 1;
|
||||
}
|
||||
|
||||
|
||||
uint8_t u8g_pb_IsXIntersection(u8g_pb_t *b, u8g_uint_t v0, u8g_uint_t v1)
|
||||
{
|
||||
uint8_t /*c0, c1, */ c2, c3;
|
||||
/*
|
||||
conditions: b->p.page_y0 < b->p.page_y1
|
||||
there are no restriction on v0 and v1. If v0 > v1, then warp around unsigned is assumed
|
||||
*/
|
||||
/*
|
||||
c0 = v0 < 0;
|
||||
c1 = v1 < 0;
|
||||
*/
|
||||
c2 = v0 > b->width;
|
||||
c3 = v1 > b->width;
|
||||
/*if ( c0 && c1 ) return 0;*/
|
||||
if ( c2 && c3 ) return 0;
|
||||
/*if ( c1 && c2 ) return 0;*/
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint8_t u8g_pb_IsIntersection(u8g_pb_t *pb, u8g_dev_arg_bbx_t *bbx)
|
||||
{
|
||||
u8g_uint_t tmp;
|
||||
|
||||
tmp = bbx->y;
|
||||
tmp += bbx->h;
|
||||
tmp--;
|
||||
|
||||
if ( u8g_pb_IsYIntersection(pb, bbx->y, tmp) == 0 )
|
||||
return 0;
|
||||
|
||||
/* maybe this one can be skiped... probability is very high to have an intersection, so it would be ok to always return 1 */
|
||||
tmp = bbx->x;
|
||||
tmp += bbx->w;
|
||||
tmp--;
|
||||
|
||||
return u8g_pb_IsXIntersection(pb, bbx->x, tmp);
|
||||
}
|
||||
|
||||
void u8g_pb_GetPageBox(u8g_pb_t *pb, u8g_box_t *box)
|
||||
{
|
||||
box->x0 = 0;
|
||||
box->y0 = pb->p.page_y0;
|
||||
box->x1 = pb->width;
|
||||
box->x1--;
|
||||
box->y1 = pb->p.page_y1;
|
||||
}
|
||||
|
||||
|
||||
uint8_t u8g_pb_Is8PixelVisible(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
|
||||
{
|
||||
u8g_uint_t v0, v1;
|
||||
v0 = arg_pixel->y;
|
||||
v1 = v0;
|
||||
switch( arg_pixel->dir )
|
||||
{
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
v1 += 8; /* this is independent from the page height */
|
||||
break;
|
||||
case 2:
|
||||
break;
|
||||
case 3:
|
||||
v0 -= 8;
|
||||
break;
|
||||
}
|
||||
return u8g_pb_IsYIntersection(b, v0, v1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t u8g_pb_WriteBuffer(u8g_pb_t *b, u8g_t *u8g, u8g_dev_t *dev)
|
||||
{
|
||||
return u8g_WriteSequence(u8g, dev, b->width, b->buf);
|
||||
}
|
||||
|
@ -0,0 +1,200 @@
|
||||
/*
|
||||
|
||||
u8g_pb14v1.c
|
||||
|
||||
14bit height monochrom (1 bit) page buffer,
|
||||
byte has vertical orientation, 7 bits per byte
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
#include <string.h>
|
||||
|
||||
|
||||
void u8g_pb14v1_Init(u8g_pb_t *b, void *buf, u8g_uint_t width) U8G_NOINLINE;
|
||||
void u8g_pb14v1_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index) U8G_NOINLINE;
|
||||
void u8g_pb14v1_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t * const arg_pixel) U8G_NOINLINE ;
|
||||
void u8g_pb14v1_Set8PixelStd(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel) U8G_NOINLINE;
|
||||
|
||||
|
||||
void u8g_pb14v1_Clear(u8g_pb_t *b)
|
||||
{
|
||||
uint8_t *ptr = (uint8_t *)b->buf;
|
||||
uint8_t *end_ptr = ptr;
|
||||
end_ptr += b->width*2;
|
||||
do
|
||||
{
|
||||
*ptr++ = 0;
|
||||
} while( ptr != end_ptr );
|
||||
}
|
||||
|
||||
/* Obsolete, usually set by the init of the structure */
|
||||
void u8g_pb14v1_Init(u8g_pb_t *b, void *buf, u8g_uint_t width)
|
||||
{
|
||||
b->buf = buf;
|
||||
b->width = width;
|
||||
u8g_pb14v1_Clear(b);
|
||||
}
|
||||
|
||||
void u8g_pb14v1_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index)
|
||||
{
|
||||
register uint8_t mask;
|
||||
uint8_t *ptr = b->buf;
|
||||
|
||||
y -= b->p.page_y0;
|
||||
if ( y >= 7 )
|
||||
{
|
||||
ptr += b->width;
|
||||
y -= 7;
|
||||
}
|
||||
mask = 1;
|
||||
mask <<= y;
|
||||
ptr += x;
|
||||
if ( color_index )
|
||||
{
|
||||
*ptr |= mask;
|
||||
}
|
||||
else
|
||||
{
|
||||
mask ^=0xff;
|
||||
*ptr &= mask;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void u8g_pb14v1_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t * const arg_pixel)
|
||||
{
|
||||
if ( arg_pixel->y < b->p.page_y0 )
|
||||
return;
|
||||
if ( arg_pixel->y > b->p.page_y1 )
|
||||
return;
|
||||
if ( arg_pixel->x >= b->width )
|
||||
return;
|
||||
u8g_pb14v1_set_pixel(b, arg_pixel->x, arg_pixel->y, arg_pixel->color);
|
||||
}
|
||||
|
||||
void u8g_pb14v1_Set8PixelStd(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
|
||||
{
|
||||
register uint8_t pixel = arg_pixel->pixel;
|
||||
do
|
||||
{
|
||||
if ( pixel & 128 )
|
||||
{
|
||||
u8g_pb14v1_SetPixel(b, arg_pixel);
|
||||
}
|
||||
switch( arg_pixel->dir )
|
||||
{
|
||||
case 0: arg_pixel->x++; break;
|
||||
case 1: arg_pixel->y++; break;
|
||||
case 2: arg_pixel->x--; break;
|
||||
case 3: arg_pixel->y--; break;
|
||||
}
|
||||
pixel <<= 1;
|
||||
} while( pixel != 0 );
|
||||
}
|
||||
|
||||
|
||||
void u8g_pb14v1_Set8PixelOpt2(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
|
||||
{
|
||||
register uint8_t pixel = arg_pixel->pixel;
|
||||
u8g_uint_t dx = 0;
|
||||
u8g_uint_t dy = 0;
|
||||
|
||||
switch( arg_pixel->dir )
|
||||
{
|
||||
case 0: dx++; break;
|
||||
case 1: dy++; break;
|
||||
case 2: dx--; break;
|
||||
case 3: dy--; break;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
if ( pixel & 128 )
|
||||
u8g_pb14v1_SetPixel(b, arg_pixel);
|
||||
arg_pixel->x += dx;
|
||||
arg_pixel->y += dy;
|
||||
pixel <<= 1;
|
||||
} while( pixel != 0 );
|
||||
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_pb14v1_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_SET_8PIXEL:
|
||||
if ( u8g_pb_Is8PixelVisible(pb, (u8g_dev_arg_pixel_t *)arg) )
|
||||
u8g_pb14v1_Set8PixelOpt2(pb, (u8g_dev_arg_pixel_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_PIXEL:
|
||||
u8g_pb14v1_SetPixel(pb, (u8g_dev_arg_pixel_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_INIT:
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_FIRST:
|
||||
u8g_pb14v1_Clear(pb);
|
||||
u8g_page_First(&(pb->p));
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
if ( u8g_page_Next(&(pb->p)) == 0 )
|
||||
return 0;
|
||||
u8g_pb14v1_Clear(pb);
|
||||
break;
|
||||
#ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
|
||||
case U8G_DEV_MSG_IS_BBX_INTERSECTION:
|
||||
return u8g_pb_IsIntersection(pb, (u8g_dev_arg_bbx_t *)arg);
|
||||
#endif
|
||||
case U8G_DEV_MSG_GET_PAGE_BOX:
|
||||
u8g_pb_GetPageBox(pb, (u8g_box_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_WIDTH:
|
||||
*((u8g_uint_t *)arg) = pb->width;
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_HEIGHT:
|
||||
*((u8g_uint_t *)arg) = pb->p.total_height;
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_COLOR_INDEX:
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_XY_CB:
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_MODE:
|
||||
return U8G_MODE_BW;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,213 @@
|
||||
/*
|
||||
|
||||
u8g_pb16h1.c
|
||||
|
||||
2x 8bit height monochrom (1 bit) page buffer
|
||||
byte has horizontal orientation
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2012, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
total buffer size is limited to 2*256 bytes because of the calculation inside the set pixel procedure
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
#include <string.h>
|
||||
|
||||
|
||||
void u8g_pb16h1_Init(u8g_pb_t *b, void *buf, u8g_uint_t width) U8G_NOINLINE;
|
||||
void u8g_pb16h1_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index) U8G_NOINLINE;
|
||||
void u8g_pb16h1_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t * const arg_pixel) U8G_NOINLINE ;
|
||||
void u8g_pb16h1_Set8PixelStd(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel) U8G_NOINLINE;
|
||||
uint8_t u8g_dev_pb8h1_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
|
||||
|
||||
void u8g_pb16h1_Clear(u8g_pb_t *b)
|
||||
{
|
||||
uint8_t *ptr = (uint8_t *)b->buf;
|
||||
uint8_t *end_ptr = ptr;
|
||||
end_ptr += b->width*2;
|
||||
do
|
||||
{
|
||||
*ptr++ = 0;
|
||||
} while( ptr != end_ptr );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void u8g_pb16h1_Init(u8g_pb_t *b, void *buf, u8g_uint_t width)
|
||||
{
|
||||
b->buf = buf;
|
||||
b->width = width;
|
||||
u8g_pb16h1_Clear(b);
|
||||
}
|
||||
|
||||
|
||||
/* limitation: total buffer must not exceed 2*256 bytes */
|
||||
void u8g_pb16h1_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index)
|
||||
{
|
||||
register uint8_t mask;
|
||||
u8g_uint_t tmp;
|
||||
uint8_t *ptr = b->buf;
|
||||
|
||||
y -= b->p.page_y0;
|
||||
if ( y >= 8 )
|
||||
{
|
||||
ptr += b->width;
|
||||
y &= 0x07;
|
||||
}
|
||||
tmp = b->width;
|
||||
tmp >>= 3;
|
||||
tmp *= (uint8_t)y;
|
||||
ptr += tmp;
|
||||
|
||||
mask = 0x080;
|
||||
mask >>= x & 7;
|
||||
x >>= 3;
|
||||
ptr += x;
|
||||
if ( color_index )
|
||||
{
|
||||
*ptr |= mask;
|
||||
}
|
||||
else
|
||||
{
|
||||
mask ^=0xff;
|
||||
*ptr &= mask;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void u8g_pb16h1_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t * const arg_pixel)
|
||||
{
|
||||
if ( arg_pixel->y < b->p.page_y0 )
|
||||
return;
|
||||
if ( arg_pixel->y > b->p.page_y1 )
|
||||
return;
|
||||
if ( arg_pixel->x >= b->width )
|
||||
return;
|
||||
u8g_pb16h1_set_pixel(b, arg_pixel->x, arg_pixel->y, arg_pixel->color);
|
||||
}
|
||||
|
||||
void u8g_pb16h1_Set8PixelStd(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
|
||||
{
|
||||
register uint8_t pixel = arg_pixel->pixel;
|
||||
do
|
||||
{
|
||||
if ( pixel & 128 )
|
||||
{
|
||||
u8g_pb16h1_SetPixel(b, arg_pixel);
|
||||
}
|
||||
switch( arg_pixel->dir )
|
||||
{
|
||||
case 0: arg_pixel->x++; break;
|
||||
case 1: arg_pixel->y++; break;
|
||||
case 2: arg_pixel->x--; break;
|
||||
case 3: arg_pixel->y--; break;
|
||||
}
|
||||
pixel <<= 1;
|
||||
} while( pixel != 0 );
|
||||
}
|
||||
|
||||
void u8g_pb16h1_Set8PixelOpt2(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
|
||||
{
|
||||
register uint8_t pixel = arg_pixel->pixel;
|
||||
u8g_uint_t dx = 0;
|
||||
u8g_uint_t dy = 0;
|
||||
|
||||
switch( arg_pixel->dir )
|
||||
{
|
||||
case 0: dx++; break;
|
||||
case 1: dy++; break;
|
||||
case 2: dx--; break;
|
||||
case 3: dy--; break;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
if ( pixel & 128 )
|
||||
u8g_pb16h1_SetPixel(b, arg_pixel);
|
||||
arg_pixel->x += dx;
|
||||
arg_pixel->y += dy;
|
||||
pixel <<= 1;
|
||||
} while( pixel != 0 );
|
||||
}
|
||||
|
||||
|
||||
uint8_t u8g_dev_pb16h1_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_SET_8PIXEL:
|
||||
if ( u8g_pb_Is8PixelVisible(pb, (u8g_dev_arg_pixel_t *)arg) )
|
||||
u8g_pb16h1_Set8PixelOpt2(pb, (u8g_dev_arg_pixel_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_PIXEL:
|
||||
u8g_pb16h1_SetPixel(pb, (u8g_dev_arg_pixel_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_INIT:
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_FIRST:
|
||||
u8g_pb16h1_Clear(pb);
|
||||
u8g_page_First(&(pb->p));
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
if ( u8g_page_Next(&(pb->p)) == 0 )
|
||||
return 0;
|
||||
u8g_pb16h1_Clear(pb);
|
||||
break;
|
||||
#ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
|
||||
case U8G_DEV_MSG_IS_BBX_INTERSECTION:
|
||||
return u8g_pb_IsIntersection(pb, (u8g_dev_arg_bbx_t *)arg);
|
||||
#endif
|
||||
case U8G_DEV_MSG_GET_PAGE_BOX:
|
||||
u8g_pb_GetPageBox(pb, (u8g_box_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_WIDTH:
|
||||
*((u8g_uint_t *)arg) = pb->width;
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_HEIGHT:
|
||||
*((u8g_uint_t *)arg) = pb->p.total_height;
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_COLOR_INDEX:
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_XY_CB:
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_MODE:
|
||||
return U8G_MODE_BW;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,182 @@
|
||||
/*
|
||||
|
||||
u8g_pb16h2.c
|
||||
|
||||
2 bit per pixel page buffer
|
||||
byte has horizontal orientation
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
#include <string.h>
|
||||
|
||||
void u8g_pb16h2_Clear(u8g_pb_t *b)
|
||||
{
|
||||
uint8_t *ptr = (uint8_t *)b->buf;
|
||||
uint8_t *end_ptr = ptr;
|
||||
|
||||
/* two bits per pixel, 16 bits height --> 8 pixel --> 4 pixel per byte */
|
||||
end_ptr += b->width;
|
||||
end_ptr += b->width;
|
||||
|
||||
do
|
||||
{
|
||||
*ptr++ = 0;
|
||||
} while( ptr != end_ptr );
|
||||
}
|
||||
|
||||
void u8g_pb16h2_Init(u8g_pb_t *b, void *buf, u8g_uint_t width)
|
||||
{
|
||||
b->buf = buf;
|
||||
b->width = width;
|
||||
u8g_pb16h2_Clear(b);
|
||||
}
|
||||
|
||||
static void u8g_pb16h2_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index) U8G_NOINLINE;
|
||||
static void u8g_pb16h2_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index)
|
||||
{
|
||||
register uint8_t mask;
|
||||
register uint16_t tmp;
|
||||
|
||||
uint8_t *ptr = b->buf;
|
||||
|
||||
y -= b->p.page_y0;
|
||||
|
||||
tmp = b->width;
|
||||
tmp >>= 2;
|
||||
tmp *= (uint8_t)y;
|
||||
ptr += tmp;
|
||||
|
||||
tmp = x;
|
||||
tmp >>= 2;
|
||||
ptr += tmp;
|
||||
|
||||
tmp = x;
|
||||
tmp &= 3;
|
||||
tmp <<= 1;
|
||||
mask = 3;
|
||||
mask <<= tmp;
|
||||
mask = ~mask;
|
||||
color_index &= 3;
|
||||
color_index <<= tmp;
|
||||
|
||||
*ptr &= mask;
|
||||
*ptr |= color_index;
|
||||
}
|
||||
|
||||
|
||||
void u8g_pb16h2_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t * const arg_pixel)
|
||||
{
|
||||
if ( arg_pixel->y < b->p.page_y0 )
|
||||
return;
|
||||
if ( arg_pixel->y > b->p.page_y1 )
|
||||
return;
|
||||
if ( arg_pixel->x >= b->width )
|
||||
return;
|
||||
u8g_pb16h2_set_pixel(b, arg_pixel->x, arg_pixel->y, arg_pixel->color);
|
||||
}
|
||||
|
||||
|
||||
void u8g_pb16h2_Set8PixelStd(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
|
||||
{
|
||||
register uint8_t pixel = arg_pixel->pixel;
|
||||
do
|
||||
{
|
||||
if ( pixel & 128 )
|
||||
{
|
||||
u8g_pb16h2_SetPixel(b, arg_pixel);
|
||||
}
|
||||
switch( arg_pixel->dir )
|
||||
{
|
||||
case 0: arg_pixel->x++; break;
|
||||
case 1: arg_pixel->y++; break;
|
||||
case 2: arg_pixel->x--; break;
|
||||
case 3: arg_pixel->y--; break;
|
||||
}
|
||||
pixel <<= 1;
|
||||
} while( pixel != 0 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t u8g_dev_pb16h2_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_SET_8PIXEL:
|
||||
if ( u8g_pb_Is8PixelVisible(pb, (u8g_dev_arg_pixel_t *)arg) )
|
||||
{
|
||||
u8g_pb16h2_Set8PixelStd(pb, (u8g_dev_arg_pixel_t *)arg);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_PIXEL:
|
||||
u8g_pb16h2_SetPixel(pb, (u8g_dev_arg_pixel_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_INIT:
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_FIRST:
|
||||
u8g_page_First(&(pb->p));
|
||||
u8g_pb16h2_Clear(pb);
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
if ( u8g_page_Next(&(pb->p)) == 0 )
|
||||
return 0;
|
||||
u8g_pb16h2_Clear(pb);
|
||||
break;
|
||||
#ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
|
||||
case U8G_DEV_MSG_IS_BBX_INTERSECTION:
|
||||
return u8g_pb_IsIntersection(pb, (u8g_dev_arg_bbx_t *)arg);
|
||||
#endif
|
||||
case U8G_DEV_MSG_GET_PAGE_BOX:
|
||||
u8g_pb_GetPageBox(pb, (u8g_box_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_WIDTH:
|
||||
*((u8g_uint_t *)arg) = pb->width;
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_HEIGHT:
|
||||
*((u8g_uint_t *)arg) = pb->p.total_height;
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_COLOR_INDEX:
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_XY_CB:
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_MODE:
|
||||
return U8G_MODE_GRAY2BIT;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,200 @@
|
||||
/*
|
||||
|
||||
u8g_pb16v1.c
|
||||
|
||||
16bit height monochrom (1 bit) page buffer
|
||||
byte has vertical orientation
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
#include <string.h>
|
||||
|
||||
|
||||
void u8g_pb16v1_Init(u8g_pb_t *b, void *buf, u8g_uint_t width) U8G_NOINLINE;
|
||||
void u8g_pb16v1_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index) U8G_NOINLINE;
|
||||
void u8g_pb16v1_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t * const arg_pixel) U8G_NOINLINE ;
|
||||
void u8g_pb16v1_Set8PixelStd(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel) U8G_NOINLINE;
|
||||
|
||||
|
||||
void u8g_pb16v1_Clear(u8g_pb_t *b)
|
||||
{
|
||||
uint8_t *ptr = (uint8_t *)b->buf;
|
||||
uint8_t *end_ptr = ptr;
|
||||
end_ptr += b->width*2;
|
||||
do
|
||||
{
|
||||
*ptr++ = 0;
|
||||
} while( ptr != end_ptr );
|
||||
}
|
||||
|
||||
/* Obsolete, usually set by the init of the structure */
|
||||
void u8g_pb16v1_Init(u8g_pb_t *b, void *buf, u8g_uint_t width)
|
||||
{
|
||||
b->buf = buf;
|
||||
b->width = width;
|
||||
u8g_pb16v1_Clear(b);
|
||||
}
|
||||
|
||||
void u8g_pb16v1_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index)
|
||||
{
|
||||
register uint8_t mask;
|
||||
uint8_t *ptr = b->buf;
|
||||
|
||||
y -= b->p.page_y0;
|
||||
if ( y >= 8 )
|
||||
{
|
||||
ptr += b->width;
|
||||
y &= 0x07;
|
||||
}
|
||||
mask = 1;
|
||||
mask <<= y;
|
||||
ptr += x;
|
||||
if ( color_index )
|
||||
{
|
||||
*ptr |= mask;
|
||||
}
|
||||
else
|
||||
{
|
||||
mask ^=0xff;
|
||||
*ptr &= mask;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void u8g_pb16v1_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t * const arg_pixel)
|
||||
{
|
||||
if ( arg_pixel->y < b->p.page_y0 )
|
||||
return;
|
||||
if ( arg_pixel->y > b->p.page_y1 )
|
||||
return;
|
||||
if ( arg_pixel->x >= b->width )
|
||||
return;
|
||||
u8g_pb16v1_set_pixel(b, arg_pixel->x, arg_pixel->y, arg_pixel->color);
|
||||
}
|
||||
|
||||
void u8g_pb16v1_Set8PixelStd(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
|
||||
{
|
||||
register uint8_t pixel = arg_pixel->pixel;
|
||||
do
|
||||
{
|
||||
if ( pixel & 128 )
|
||||
{
|
||||
u8g_pb16v1_SetPixel(b, arg_pixel);
|
||||
}
|
||||
switch( arg_pixel->dir )
|
||||
{
|
||||
case 0: arg_pixel->x++; break;
|
||||
case 1: arg_pixel->y++; break;
|
||||
case 2: arg_pixel->x--; break;
|
||||
case 3: arg_pixel->y--; break;
|
||||
}
|
||||
pixel <<= 1;
|
||||
} while( pixel != 0 );
|
||||
}
|
||||
|
||||
|
||||
void u8g_pb16v1_Set8PixelOpt2(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
|
||||
{
|
||||
register uint8_t pixel = arg_pixel->pixel;
|
||||
u8g_uint_t dx = 0;
|
||||
u8g_uint_t dy = 0;
|
||||
|
||||
switch( arg_pixel->dir )
|
||||
{
|
||||
case 0: dx++; break;
|
||||
case 1: dy++; break;
|
||||
case 2: dx--; break;
|
||||
case 3: dy--; break;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
if ( pixel & 128 )
|
||||
u8g_pb16v1_SetPixel(b, arg_pixel);
|
||||
arg_pixel->x += dx;
|
||||
arg_pixel->y += dy;
|
||||
pixel <<= 1;
|
||||
} while( pixel != 0 );
|
||||
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_pb16v1_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_SET_8PIXEL:
|
||||
if ( u8g_pb_Is8PixelVisible(pb, (u8g_dev_arg_pixel_t *)arg) )
|
||||
u8g_pb16v1_Set8PixelOpt2(pb, (u8g_dev_arg_pixel_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_PIXEL:
|
||||
u8g_pb16v1_SetPixel(pb, (u8g_dev_arg_pixel_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_INIT:
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_FIRST:
|
||||
u8g_pb16v1_Clear(pb);
|
||||
u8g_page_First(&(pb->p));
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
if ( u8g_page_Next(&(pb->p)) == 0 )
|
||||
return 0;
|
||||
u8g_pb16v1_Clear(pb);
|
||||
break;
|
||||
#ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
|
||||
case U8G_DEV_MSG_IS_BBX_INTERSECTION:
|
||||
return u8g_pb_IsIntersection(pb, (u8g_dev_arg_bbx_t *)arg);
|
||||
#endif
|
||||
case U8G_DEV_MSG_GET_PAGE_BOX:
|
||||
u8g_pb_GetPageBox(pb, (u8g_box_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_WIDTH:
|
||||
*((u8g_uint_t *)arg) = pb->width;
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_HEIGHT:
|
||||
*((u8g_uint_t *)arg) = pb->p.total_height;
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_COLOR_INDEX:
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_XY_CB:
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_MODE:
|
||||
return U8G_MODE_BW;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,172 @@
|
||||
/*
|
||||
|
||||
u8g_pb16v2.c
|
||||
|
||||
16 bit height 2 bit per pixel page buffer
|
||||
byte has vertical orientation
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2012, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
#include <string.h>
|
||||
|
||||
|
||||
void u8g_pb16v2_Clear(u8g_pb_t *b)
|
||||
{
|
||||
uint8_t *ptr = (uint8_t *)b->buf;
|
||||
uint8_t *end_ptr = ptr;
|
||||
|
||||
/* two bits per pixel, 16 bits height --> 8 pixel --> 4 pixel per byte */
|
||||
end_ptr += b->width;
|
||||
end_ptr += b->width;
|
||||
|
||||
do
|
||||
{
|
||||
*ptr++ = 0;
|
||||
} while( ptr != end_ptr );
|
||||
}
|
||||
|
||||
void u8g_pb16v2Init(u8g_pb_t *b, void *buf, u8g_uint_t width)
|
||||
{
|
||||
b->buf = buf;
|
||||
b->width = width;
|
||||
u8g_pb16v2_Clear(b);
|
||||
}
|
||||
|
||||
void u8g_pb16v2_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index)
|
||||
{
|
||||
register uint8_t mask;
|
||||
uint8_t *ptr = b->buf;
|
||||
y -= b->p.page_y0;
|
||||
if ( y >= 4 )
|
||||
{
|
||||
ptr += b->width;
|
||||
}
|
||||
mask = 0x03;
|
||||
y &= 0x03;
|
||||
y <<= 1;
|
||||
mask <<= y;
|
||||
mask ^=0xff;
|
||||
color_index &= 3;
|
||||
color_index <<= y;
|
||||
ptr += x;
|
||||
*ptr &= mask;
|
||||
*ptr |= color_index;
|
||||
}
|
||||
|
||||
|
||||
void u8g_pb16v2_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t * const arg_pixel)
|
||||
{
|
||||
if ( arg_pixel->y < b->p.page_y0 )
|
||||
return;
|
||||
if ( arg_pixel->y > b->p.page_y1 )
|
||||
return;
|
||||
if ( arg_pixel->x >= b->width )
|
||||
return;
|
||||
u8g_pb16v2_set_pixel(b, arg_pixel->x, arg_pixel->y, arg_pixel->color);
|
||||
}
|
||||
|
||||
|
||||
void u8g_pb16v2_Set8PixelStd(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
|
||||
{
|
||||
register uint8_t pixel = arg_pixel->pixel;
|
||||
do
|
||||
{
|
||||
if ( pixel & 128 )
|
||||
{
|
||||
u8g_pb16v2_SetPixel(b, arg_pixel);
|
||||
}
|
||||
switch( arg_pixel->dir )
|
||||
{
|
||||
case 0: arg_pixel->x++; break;
|
||||
case 1: arg_pixel->y++; break;
|
||||
case 2: arg_pixel->x--; break;
|
||||
case 3: arg_pixel->y--; break;
|
||||
}
|
||||
pixel <<= 1;
|
||||
} while( pixel != 0 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t u8g_dev_pb16v2_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_SET_8PIXEL:
|
||||
if ( u8g_pb_Is8PixelVisible(pb, (u8g_dev_arg_pixel_t *)arg) )
|
||||
{
|
||||
u8g_pb16v2_Set8PixelStd(pb, (u8g_dev_arg_pixel_t *)arg);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_PIXEL:
|
||||
u8g_pb16v2_SetPixel(pb, (u8g_dev_arg_pixel_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_INIT:
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_FIRST:
|
||||
u8g_pb16v2_Clear(pb);
|
||||
u8g_page_First(&(pb->p));
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
if ( u8g_page_Next(&(pb->p)) == 0 )
|
||||
return 0;
|
||||
u8g_pb16v2_Clear(pb);
|
||||
break;
|
||||
#ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
|
||||
case U8G_DEV_MSG_IS_BBX_INTERSECTION:
|
||||
return u8g_pb_IsIntersection(pb, (u8g_dev_arg_bbx_t *)arg);
|
||||
#endif
|
||||
case U8G_DEV_MSG_GET_PAGE_BOX:
|
||||
u8g_pb_GetPageBox(pb, (u8g_box_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_WIDTH:
|
||||
*((u8g_uint_t *)arg) = pb->width;
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_HEIGHT:
|
||||
*((u8g_uint_t *)arg) = pb->p.total_height;
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_COLOR_INDEX:
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_XY_CB:
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_MODE:
|
||||
return U8G_MODE_GRAY2BIT;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,208 @@
|
||||
/*
|
||||
|
||||
u8g_pb32h1.c
|
||||
|
||||
2x 8bit height monochrom (1 bit) page buffer
|
||||
byte has horizontal orientation
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2012, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
total buffer size is limited to 2*256 bytes because of the calculation inside the set pixel procedure
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
#include <string.h>
|
||||
|
||||
|
||||
void u8g_pb32h1_Init(u8g_pb_t *b, void *buf, u8g_uint_t width) U8G_NOINLINE;
|
||||
void u8g_pb32h1_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index) U8G_NOINLINE;
|
||||
void u8g_pb32h1_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t * const arg_pixel) U8G_NOINLINE ;
|
||||
void u8g_pb32h1_Set8PixelStd(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel) U8G_NOINLINE;
|
||||
uint8_t u8g_dev_pb8h1_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
|
||||
|
||||
void u8g_pb32h1_Clear(u8g_pb_t *b)
|
||||
{
|
||||
uint8_t *ptr = (uint8_t *)b->buf;
|
||||
uint8_t *end_ptr = ptr;
|
||||
end_ptr += b->width*4;
|
||||
do
|
||||
{
|
||||
*ptr++ = 0;
|
||||
} while( ptr != end_ptr );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void u8g_pb32h1_Init(u8g_pb_t *b, void *buf, u8g_uint_t width)
|
||||
{
|
||||
b->buf = buf;
|
||||
b->width = width;
|
||||
u8g_pb32h1_Clear(b);
|
||||
}
|
||||
|
||||
|
||||
/* limitation: total buffer must not exceed 2*256 bytes */
|
||||
void u8g_pb32h1_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index)
|
||||
{
|
||||
register uint8_t mask;
|
||||
uint16_t tmp;
|
||||
uint8_t *ptr = b->buf;
|
||||
|
||||
y -= b->p.page_y0;
|
||||
tmp = b->width;
|
||||
tmp >>= 3;
|
||||
tmp *= y;
|
||||
ptr += tmp;
|
||||
|
||||
mask = 0x080;
|
||||
mask >>= x & 7;
|
||||
x >>= 3;
|
||||
ptr += x;
|
||||
if ( color_index )
|
||||
{
|
||||
*ptr |= mask;
|
||||
}
|
||||
else
|
||||
{
|
||||
mask ^=0xff;
|
||||
*ptr &= mask;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void u8g_pb32h1_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t * const arg_pixel)
|
||||
{
|
||||
if ( arg_pixel->y < b->p.page_y0 )
|
||||
return;
|
||||
if ( arg_pixel->y > b->p.page_y1 )
|
||||
return;
|
||||
if ( arg_pixel->x >= b->width )
|
||||
return;
|
||||
u8g_pb32h1_set_pixel(b, arg_pixel->x, arg_pixel->y, arg_pixel->color);
|
||||
}
|
||||
|
||||
void u8g_pb32h1_Set8PixelStd(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
|
||||
{
|
||||
register uint8_t pixel = arg_pixel->pixel;
|
||||
do
|
||||
{
|
||||
if ( pixel & 128 )
|
||||
{
|
||||
u8g_pb32h1_SetPixel(b, arg_pixel);
|
||||
}
|
||||
switch( arg_pixel->dir )
|
||||
{
|
||||
case 0: arg_pixel->x++; break;
|
||||
case 1: arg_pixel->y++; break;
|
||||
case 2: arg_pixel->x--; break;
|
||||
case 3: arg_pixel->y--; break;
|
||||
}
|
||||
pixel <<= 1;
|
||||
} while( pixel != 0 );
|
||||
}
|
||||
|
||||
void u8g_pb32h1_Set8PixelOpt2(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
|
||||
{
|
||||
register uint8_t pixel = arg_pixel->pixel;
|
||||
u8g_uint_t dx = 0;
|
||||
u8g_uint_t dy = 0;
|
||||
|
||||
switch( arg_pixel->dir )
|
||||
{
|
||||
case 0: dx++; break;
|
||||
case 1: dy++; break;
|
||||
case 2: dx--; break;
|
||||
case 3: dy--; break;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
if ( pixel & 128 )
|
||||
u8g_pb32h1_SetPixel(b, arg_pixel);
|
||||
arg_pixel->x += dx;
|
||||
arg_pixel->y += dy;
|
||||
pixel <<= 1;
|
||||
} while( pixel != 0 );
|
||||
}
|
||||
|
||||
|
||||
uint8_t u8g_dev_pb32h1_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_SET_8PIXEL:
|
||||
if ( u8g_pb_Is8PixelVisible(pb, (u8g_dev_arg_pixel_t *)arg) )
|
||||
u8g_pb32h1_Set8PixelOpt2(pb, (u8g_dev_arg_pixel_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_PIXEL:
|
||||
u8g_pb32h1_SetPixel(pb, (u8g_dev_arg_pixel_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_INIT:
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_FIRST:
|
||||
u8g_pb32h1_Clear(pb);
|
||||
u8g_page_First(&(pb->p));
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
if ( u8g_page_Next(&(pb->p)) == 0 )
|
||||
return 0;
|
||||
u8g_pb32h1_Clear(pb);
|
||||
break;
|
||||
#ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
|
||||
case U8G_DEV_MSG_IS_BBX_INTERSECTION:
|
||||
return u8g_pb_IsIntersection(pb, (u8g_dev_arg_bbx_t *)arg);
|
||||
#endif
|
||||
case U8G_DEV_MSG_GET_PAGE_BOX:
|
||||
u8g_pb_GetPageBox(pb, (u8g_box_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_WIDTH:
|
||||
*((u8g_uint_t *)arg) = pb->width;
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_HEIGHT:
|
||||
*((u8g_uint_t *)arg) = pb->p.total_height;
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_COLOR_INDEX:
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_XY_CB:
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_MODE:
|
||||
return U8G_MODE_BW;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,389 @@
|
||||
/*
|
||||
|
||||
u8g_pb8h1.c
|
||||
|
||||
8bit height monochrom (1 bit) page buffer
|
||||
byte has horizontal orientation
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
total buffer size is limited to 256 bytes because of the calculation inside the set pixel procedure
|
||||
|
||||
23. Sep 2012: Bug with down procedure, see FPS 1st page --> fixed (bug located in u8g_clip.c)
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __unix__
|
||||
#include <assert.h>
|
||||
#endif
|
||||
|
||||
/* NEW_CODE disabled, because the performance increase was too slow and not worth compared */
|
||||
/* to the increase of code size */
|
||||
/* #define NEW_CODE */
|
||||
|
||||
#ifdef __unix__
|
||||
void *u8g_buf_lower_limit;
|
||||
void *u8g_buf_upper_limit;
|
||||
#endif
|
||||
|
||||
void u8g_pb8h1_Init(u8g_pb_t *b, void *buf, u8g_uint_t width) U8G_NOINLINE;
|
||||
void u8g_pb8h1_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index) U8G_NOINLINE;
|
||||
void u8g_pb8h1_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t * const arg_pixel) U8G_NOINLINE ;
|
||||
void u8g_pb8h1_Set8PixelStd(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel) U8G_NOINLINE;
|
||||
uint8_t u8g_dev_pb8h1_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
|
||||
|
||||
|
||||
#ifdef NEW_CODE
|
||||
struct u8g_pb_h1_struct
|
||||
{
|
||||
u8g_uint_t x;
|
||||
u8g_uint_t y;
|
||||
uint8_t *ptr;
|
||||
uint8_t mask;
|
||||
uint8_t line_byte_len;
|
||||
uint8_t cnt;
|
||||
};
|
||||
|
||||
static uint8_t u8g_pb8h1_bitmask[8] = { 0x080, 0x040, 0x020, 0x010, 0x008, 0x004, 0x002, 0x001 };
|
||||
|
||||
static void u8g_pb8h1_state_right(struct u8g_pb_h1_struct *s) U8G_NOINLINE;
|
||||
static void u8g_pb8h1_state_right(struct u8g_pb_h1_struct *s)
|
||||
{
|
||||
register u8g_uint_t x;
|
||||
x = s->x;
|
||||
x++;
|
||||
s->x = x;
|
||||
x &= 7;
|
||||
s->mask = u8g_pb8h1_bitmask[x];
|
||||
if ( x == 0 )
|
||||
s->ptr++;
|
||||
}
|
||||
|
||||
static void u8g_pb8h1_state_left(struct u8g_pb_h1_struct *s)
|
||||
{
|
||||
register u8g_uint_t x;
|
||||
x = s->x;
|
||||
x--;
|
||||
s->x = x;
|
||||
x &= 7;
|
||||
s->mask = u8g_pb8h1_bitmask[x];
|
||||
if ( x == 7 )
|
||||
s->ptr--;
|
||||
}
|
||||
|
||||
static void u8g_pb8h1_state_down(struct u8g_pb_h1_struct *s)
|
||||
{
|
||||
s->y++;
|
||||
s->ptr += s->line_byte_len;
|
||||
}
|
||||
|
||||
static void u8g_pb8h1_state_up(struct u8g_pb_h1_struct *s)
|
||||
{
|
||||
s->y--;
|
||||
s->ptr -= s->line_byte_len;
|
||||
}
|
||||
|
||||
static void u8g_pb8h1_state_init(struct u8g_pb_h1_struct *s, u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y) U8G_NOINLINE;
|
||||
static void u8g_pb8h1_state_init(struct u8g_pb_h1_struct *s, u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y)
|
||||
{
|
||||
u8g_uint_t tmp;
|
||||
|
||||
uint8_t *ptr = b->buf;
|
||||
|
||||
s->x = x;
|
||||
s->y = y;
|
||||
|
||||
y -= b->p.page_y0;
|
||||
|
||||
tmp = b->width;
|
||||
tmp >>= 3;
|
||||
s->line_byte_len = tmp;
|
||||
|
||||
/* assume negative y values, can be down to -7, subtract this from the pointer and add correction of 8 to y */
|
||||
ptr -= tmp*8;
|
||||
y+=8;
|
||||
/* it is important that the result of tmp*y can be 16 bit value also for 8 bit mode */
|
||||
ptr += tmp*y;
|
||||
|
||||
s->mask = u8g_pb8h1_bitmask[x & 7];
|
||||
|
||||
/* assume negative x values (to -7), subtract 8 pixel from the pointer and add 8 to x */
|
||||
ptr--;
|
||||
x += 8;
|
||||
x >>= 3;
|
||||
ptr += x;
|
||||
s->ptr = ptr;
|
||||
}
|
||||
|
||||
static void u8g_pb8h1_state_set_pixel(struct u8g_pb_h1_struct *s, uint8_t color_index) U8G_NOINLINE;
|
||||
static void u8g_pb8h1_state_set_pixel(struct u8g_pb_h1_struct *s, uint8_t color_index)
|
||||
{
|
||||
|
||||
#ifdef __unix__
|
||||
assert( s->ptr >= u8g_buf_lower_limit );
|
||||
assert( s->ptr < u8g_buf_upper_limit );
|
||||
#endif
|
||||
|
||||
if ( color_index )
|
||||
{
|
||||
*s->ptr |= s->mask;
|
||||
}
|
||||
else
|
||||
{
|
||||
uint8_t mask = s->mask;
|
||||
mask ^=0xff;
|
||||
*s->ptr &= mask;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void u8g_pb8h1_Init(u8g_pb_t *b, void *buf, u8g_uint_t width)
|
||||
{
|
||||
b->buf = buf;
|
||||
b->width = width;
|
||||
u8g_pb_Clear(b);
|
||||
}
|
||||
|
||||
/* limitation: total buffer must not exceed 256 bytes */
|
||||
void u8g_pb8h1_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index)
|
||||
{
|
||||
#ifdef NEW_CODE
|
||||
struct u8g_pb_h1_struct s;
|
||||
u8g_pb8h1_state_init(&s, b, x, y);
|
||||
u8g_pb8h1_state_set_pixel(&s, color_index);
|
||||
|
||||
// u8g_pb8h1_state_up(&s);
|
||||
// if ( s.y > b->p.page_y1 )
|
||||
// return;
|
||||
// if ( s.x > b->width )
|
||||
// return;
|
||||
// u8g_pb8h1_state_set_pixel(&s, color_index);
|
||||
#else
|
||||
register uint8_t mask;
|
||||
u8g_uint_t tmp;
|
||||
uint8_t *ptr = b->buf;
|
||||
|
||||
y -= b->p.page_y0;
|
||||
tmp = b->width;
|
||||
tmp >>= 3;
|
||||
tmp *= (uint8_t)y;
|
||||
ptr += tmp;
|
||||
|
||||
mask = 0x080;
|
||||
mask >>= x & 7;
|
||||
x >>= 3;
|
||||
ptr += x;
|
||||
if ( color_index )
|
||||
{
|
||||
*ptr |= mask;
|
||||
}
|
||||
else
|
||||
{
|
||||
mask ^=0xff;
|
||||
*ptr &= mask;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void u8g_pb8h1_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t * const arg_pixel)
|
||||
{
|
||||
if ( arg_pixel->y < b->p.page_y0 )
|
||||
return;
|
||||
if ( arg_pixel->y > b->p.page_y1 )
|
||||
return;
|
||||
if ( arg_pixel->x >= b->width )
|
||||
return;
|
||||
u8g_pb8h1_set_pixel(b, arg_pixel->x, arg_pixel->y, arg_pixel->color);
|
||||
}
|
||||
|
||||
void u8g_pb8h1_Set8PixelStd(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
|
||||
{
|
||||
register uint8_t pixel = arg_pixel->pixel;
|
||||
do
|
||||
{
|
||||
if ( pixel & 128 )
|
||||
{
|
||||
u8g_pb8h1_SetPixel(b, arg_pixel);
|
||||
}
|
||||
switch( arg_pixel->dir )
|
||||
{
|
||||
case 0: arg_pixel->x++; break;
|
||||
case 1: arg_pixel->y++; break;
|
||||
case 2: arg_pixel->x--; break;
|
||||
case 3: arg_pixel->y--; break;
|
||||
}
|
||||
pixel <<= 1;
|
||||
} while( pixel != 0 );
|
||||
}
|
||||
|
||||
void u8g_pb8h1_Set8PixelOpt2(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
|
||||
{
|
||||
register uint8_t pixel = arg_pixel->pixel;
|
||||
u8g_uint_t dx = 0;
|
||||
u8g_uint_t dy = 0;
|
||||
|
||||
switch( arg_pixel->dir )
|
||||
{
|
||||
case 0: dx++; break;
|
||||
case 1: dy++; break;
|
||||
case 2: dx--; break;
|
||||
case 3: dy--; break;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
if ( pixel & 128 )
|
||||
u8g_pb8h1_SetPixel(b, arg_pixel);
|
||||
arg_pixel->x += dx;
|
||||
arg_pixel->y += dy;
|
||||
pixel <<= 1;
|
||||
} while( pixel != 0 );
|
||||
}
|
||||
|
||||
#ifdef NEW_CODE
|
||||
static void u8g_pb8h1_Set8PixelState(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
|
||||
{
|
||||
register uint8_t pixel = arg_pixel->pixel;
|
||||
struct u8g_pb_h1_struct s;
|
||||
uint8_t cnt;
|
||||
u8g_pb8h1_state_init(&s, b, arg_pixel->x, arg_pixel->y);
|
||||
cnt = 8;
|
||||
switch( arg_pixel->dir )
|
||||
{
|
||||
case 0:
|
||||
do
|
||||
{
|
||||
if ( s.x < b->width )
|
||||
if ( pixel & 128 )
|
||||
u8g_pb8h1_state_set_pixel(&s, arg_pixel->color);
|
||||
u8g_pb8h1_state_right(&s);
|
||||
pixel <<= 1;
|
||||
cnt--;
|
||||
} while( cnt > 0 && pixel != 0 );
|
||||
break;
|
||||
case 1:
|
||||
do
|
||||
{
|
||||
if ( s.y >= b->p.page_y0 )
|
||||
if ( s.y <= b->p.page_y1 )
|
||||
if ( pixel & 128 )
|
||||
u8g_pb8h1_state_set_pixel(&s, arg_pixel->color);
|
||||
u8g_pb8h1_state_down(&s);
|
||||
pixel <<= 1;
|
||||
cnt--;
|
||||
} while( cnt > 0 && pixel != 0 );
|
||||
break;
|
||||
case 2:
|
||||
do
|
||||
{
|
||||
if ( s.x < b->width )
|
||||
if ( pixel & 128 )
|
||||
u8g_pb8h1_state_set_pixel(&s, arg_pixel->color);
|
||||
u8g_pb8h1_state_left(&s);
|
||||
pixel <<= 1;
|
||||
cnt--;
|
||||
} while( cnt > 0 && pixel != 0 );
|
||||
break;
|
||||
case 3:
|
||||
do
|
||||
{
|
||||
if ( s.y >= b->p.page_y0 )
|
||||
if ( s.y <= b->p.page_y1 )
|
||||
if ( pixel & 128 )
|
||||
u8g_pb8h1_state_set_pixel(&s, arg_pixel->color);
|
||||
u8g_pb8h1_state_up(&s);
|
||||
pixel <<= 1;
|
||||
cnt--;
|
||||
} while( cnt > 0 && pixel != 0 );
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
uint8_t u8g_dev_pb8h1_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_SET_8PIXEL:
|
||||
#ifdef NEW_CODE
|
||||
if ( u8g_pb_Is8PixelVisible(pb, (u8g_dev_arg_pixel_t *)arg) )
|
||||
u8g_pb8h1_Set8PixelState(pb, (u8g_dev_arg_pixel_t *)arg);
|
||||
#else
|
||||
if ( u8g_pb_Is8PixelVisible(pb, (u8g_dev_arg_pixel_t *)arg) )
|
||||
u8g_pb8h1_Set8PixelOpt2(pb, (u8g_dev_arg_pixel_t *)arg);
|
||||
#endif
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_PIXEL:
|
||||
u8g_pb8h1_SetPixel(pb, (u8g_dev_arg_pixel_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_INIT:
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_FIRST:
|
||||
u8g_pb_Clear(pb);
|
||||
u8g_page_First(&(pb->p));
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
if ( u8g_page_Next(&(pb->p)) == 0 )
|
||||
return 0;
|
||||
u8g_pb_Clear(pb);
|
||||
break;
|
||||
#ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
|
||||
case U8G_DEV_MSG_IS_BBX_INTERSECTION:
|
||||
return u8g_pb_IsIntersection(pb, (u8g_dev_arg_bbx_t *)arg);
|
||||
#endif
|
||||
case U8G_DEV_MSG_GET_PAGE_BOX:
|
||||
u8g_pb_GetPageBox(pb, (u8g_box_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_WIDTH:
|
||||
*((u8g_uint_t *)arg) = pb->width;
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_HEIGHT:
|
||||
*((u8g_uint_t *)arg) = pb->p.total_height;
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_COLOR_INDEX:
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_XY_CB:
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_MODE:
|
||||
return U8G_MODE_BW;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,194 @@
|
||||
/*
|
||||
|
||||
u8g_pb8h1f.c
|
||||
|
||||
8bit height monochrom (1 bit) page buffer
|
||||
byte has horizontal orientation, same as u8g_pb8h1, but byte is flipped
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
total buffer size is limited to 256 bytes because of the calculation inside the set pixel procedure
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
#include <string.h>
|
||||
|
||||
|
||||
void u8g_pb8h1f_Init(u8g_pb_t *b, void *buf, u8g_uint_t width) U8G_NOINLINE;
|
||||
void u8g_pb8h1f_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index) U8G_NOINLINE;
|
||||
void u8g_pb8h1f_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t * const arg_pixel) U8G_NOINLINE ;
|
||||
void u8g_pb8h1f_Set8PixelStd(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel) U8G_NOINLINE;
|
||||
uint8_t u8g_dev_pb8h1f_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
|
||||
|
||||
|
||||
void u8g_pb8h1f_Init(u8g_pb_t *b, void *buf, u8g_uint_t width)
|
||||
{
|
||||
b->buf = buf;
|
||||
b->width = width;
|
||||
u8g_pb_Clear(b);
|
||||
}
|
||||
|
||||
/* limitation: total buffer must not exceed 256 bytes, 20 nov 2012: extended to >256 bytes */
|
||||
void u8g_pb8h1f_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index)
|
||||
{
|
||||
/*register uint8_t mask, tmp;*/
|
||||
register uint8_t mask;
|
||||
register u8g_uint_t tmp;
|
||||
uint8_t *ptr = b->buf;
|
||||
|
||||
y -= b->p.page_y0;
|
||||
tmp = b->width >> 3;
|
||||
tmp *= (uint8_t)y;
|
||||
ptr += tmp;
|
||||
|
||||
mask = 1;
|
||||
mask <<= x & 7;
|
||||
x >>= 3;
|
||||
ptr += x;
|
||||
if ( color_index )
|
||||
{
|
||||
*ptr |= mask;
|
||||
}
|
||||
else
|
||||
{
|
||||
mask ^=0xff;
|
||||
*ptr &= mask;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void u8g_pb8h1f_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t * const arg_pixel)
|
||||
{
|
||||
if ( arg_pixel->y < b->p.page_y0 )
|
||||
return;
|
||||
if ( arg_pixel->y > b->p.page_y1 )
|
||||
return;
|
||||
if ( arg_pixel->x >= b->width )
|
||||
return;
|
||||
u8g_pb8h1f_set_pixel(b, arg_pixel->x, arg_pixel->y, arg_pixel->color);
|
||||
}
|
||||
|
||||
void u8g_pb8h1f_Set8PixelStd(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
|
||||
{
|
||||
register uint8_t pixel = arg_pixel->pixel;
|
||||
do
|
||||
{
|
||||
if ( pixel & 128 )
|
||||
{
|
||||
u8g_pb8h1f_SetPixel(b, arg_pixel);
|
||||
}
|
||||
switch( arg_pixel->dir )
|
||||
{
|
||||
case 0: arg_pixel->x++; break;
|
||||
case 1: arg_pixel->y++; break;
|
||||
case 2: arg_pixel->x--; break;
|
||||
case 3: arg_pixel->y--; break;
|
||||
}
|
||||
pixel <<= 1;
|
||||
} while( pixel != 0 );
|
||||
}
|
||||
|
||||
void u8g_pb8h1f_Set8PixelOpt2(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
|
||||
{
|
||||
register uint8_t pixel = arg_pixel->pixel;
|
||||
u8g_uint_t dx = 0;
|
||||
u8g_uint_t dy = 0;
|
||||
|
||||
switch( arg_pixel->dir )
|
||||
{
|
||||
case 0: dx++; break;
|
||||
case 1: dy++; break;
|
||||
case 2: dx--; break;
|
||||
case 3: dy--; break;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
if ( pixel & 128 )
|
||||
u8g_pb8h1f_SetPixel(b, arg_pixel);
|
||||
arg_pixel->x += dx;
|
||||
arg_pixel->y += dy;
|
||||
pixel <<= 1;
|
||||
} while( pixel != 0 );
|
||||
}
|
||||
|
||||
|
||||
uint8_t u8g_dev_pb8h1f_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_SET_8PIXEL:
|
||||
if ( u8g_pb_Is8PixelVisible(pb, (u8g_dev_arg_pixel_t *)arg) )
|
||||
u8g_pb8h1f_Set8PixelOpt2(pb, (u8g_dev_arg_pixel_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_PIXEL:
|
||||
u8g_pb8h1f_SetPixel(pb, (u8g_dev_arg_pixel_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_INIT:
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_FIRST:
|
||||
u8g_pb_Clear(pb);
|
||||
u8g_page_First(&(pb->p));
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
if ( u8g_page_Next(&(pb->p)) == 0 )
|
||||
return 0;
|
||||
u8g_pb_Clear(pb);
|
||||
break;
|
||||
#ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
|
||||
case U8G_DEV_MSG_IS_BBX_INTERSECTION:
|
||||
return u8g_pb_IsIntersection(pb, (u8g_dev_arg_bbx_t *)arg);
|
||||
#endif
|
||||
case U8G_DEV_MSG_GET_PAGE_BOX:
|
||||
u8g_pb_GetPageBox(pb, (u8g_box_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_WIDTH:
|
||||
*((u8g_uint_t *)arg) = pb->width;
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_HEIGHT:
|
||||
*((u8g_uint_t *)arg) = pb->p.total_height;
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_COLOR_INDEX:
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_XY_CB:
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_MODE:
|
||||
return U8G_MODE_BW;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,167 @@
|
||||
/*
|
||||
|
||||
u8g_pb8h2.c
|
||||
|
||||
8bit height 2 bit per pixel page buffer
|
||||
byte has horizontal orientation
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
#include <string.h>
|
||||
|
||||
void u8g_pb8h2_Init(u8g_pb_t *b, void *buf, u8g_uint_t width)
|
||||
{
|
||||
b->buf = buf;
|
||||
b->width = width;
|
||||
u8g_pb_Clear(b);
|
||||
}
|
||||
|
||||
static void u8g_pb8h2_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index) U8G_NOINLINE;
|
||||
static void u8g_pb8h2_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index)
|
||||
{
|
||||
register uint8_t mask;
|
||||
register uint16_t tmp;
|
||||
|
||||
uint8_t *ptr = b->buf;
|
||||
|
||||
y -= b->p.page_y0;
|
||||
|
||||
tmp = b->width;
|
||||
tmp >>= 2;
|
||||
tmp *= (uint8_t)y;
|
||||
ptr += tmp;
|
||||
|
||||
tmp = x;
|
||||
tmp >>= 2;
|
||||
ptr += tmp;
|
||||
|
||||
tmp = x;
|
||||
tmp &= 3;
|
||||
tmp <<= 1;
|
||||
mask = 3;
|
||||
mask <<= tmp;
|
||||
mask = ~mask;
|
||||
color_index &= 3;
|
||||
color_index <<= tmp;
|
||||
|
||||
*ptr &= mask;
|
||||
*ptr |= color_index;
|
||||
}
|
||||
|
||||
|
||||
void u8g_pb8h2_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t * const arg_pixel)
|
||||
{
|
||||
if ( arg_pixel->y < b->p.page_y0 )
|
||||
return;
|
||||
if ( arg_pixel->y > b->p.page_y1 )
|
||||
return;
|
||||
if ( arg_pixel->x >= b->width )
|
||||
return;
|
||||
u8g_pb8h2_set_pixel(b, arg_pixel->x, arg_pixel->y, arg_pixel->color);
|
||||
}
|
||||
|
||||
|
||||
void u8g_pb8h2_Set8PixelStd(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
|
||||
{
|
||||
register uint8_t pixel = arg_pixel->pixel;
|
||||
do
|
||||
{
|
||||
if ( pixel & 128 )
|
||||
{
|
||||
u8g_pb8h2_SetPixel(b, arg_pixel);
|
||||
}
|
||||
switch( arg_pixel->dir )
|
||||
{
|
||||
case 0: arg_pixel->x++; break;
|
||||
case 1: arg_pixel->y++; break;
|
||||
case 2: arg_pixel->x--; break;
|
||||
case 3: arg_pixel->y--; break;
|
||||
}
|
||||
pixel <<= 1;
|
||||
} while( pixel != 0 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t u8g_dev_pb8h2_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_SET_8PIXEL:
|
||||
if ( u8g_pb_Is8PixelVisible(pb, (u8g_dev_arg_pixel_t *)arg) )
|
||||
{
|
||||
u8g_pb8h2_Set8PixelStd(pb, (u8g_dev_arg_pixel_t *)arg);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_PIXEL:
|
||||
u8g_pb8h2_SetPixel(pb, (u8g_dev_arg_pixel_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_INIT:
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_FIRST:
|
||||
u8g_pb_Clear(pb);
|
||||
u8g_page_First(&(pb->p));
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
if ( u8g_page_Next(&(pb->p)) == 0 )
|
||||
return 0;
|
||||
u8g_pb_Clear(pb);
|
||||
break;
|
||||
#ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
|
||||
case U8G_DEV_MSG_IS_BBX_INTERSECTION:
|
||||
return u8g_pb_IsIntersection(pb, (u8g_dev_arg_bbx_t *)arg);
|
||||
#endif
|
||||
case U8G_DEV_MSG_GET_PAGE_BOX:
|
||||
u8g_pb_GetPageBox(pb, (u8g_box_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_WIDTH:
|
||||
*((u8g_uint_t *)arg) = pb->width;
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_HEIGHT:
|
||||
*((u8g_uint_t *)arg) = pb->p.total_height;
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_COLOR_INDEX:
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_XY_CB:
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_MODE:
|
||||
return U8G_MODE_GRAY2BIT;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,179 @@
|
||||
/*
|
||||
|
||||
u8g_pb8h8.c
|
||||
|
||||
8 bits per pixel, horizontal
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2012, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
struct _u8g_pb_t
|
||||
{
|
||||
u8g_page_t p;
|
||||
u8g_uint_t width;
|
||||
void *buf;
|
||||
};
|
||||
typedef struct _u8g_pb_t u8g_pb_t;
|
||||
|
||||
|
||||
uint8_t u8g_index_color_8h8_buf[WIDTH*PAGE_HEIGHT] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_index_color_8h8_pb = { {PAGE_HEIGHT, HEIGHT, 0, 0, 0}, WIDTH, u8g_index_color_8h8_buff};
|
||||
u8g_dev_t name = { dev_fn, &u8g_index_color_8h8_pb, com_fn }
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define WIDTH_BITS 7
|
||||
#define WIDTH (1<<WIDTH_BITS)
|
||||
#define PAGE_HEIGHT_BITS 3
|
||||
#define PAGE_HEIGHT (1<<PAGE_HEIGHT_BITS)
|
||||
|
||||
void u8g_pb8h8_Clear(u8g_pb_t *b)
|
||||
{
|
||||
uint8_t *ptr = (uint8_t *)b->buf;
|
||||
uint8_t *end_ptr = ptr;
|
||||
uint8_t cnt = b->p.page_height;
|
||||
do
|
||||
{
|
||||
end_ptr += b->width;
|
||||
cnt--;
|
||||
} while( cnt > 0 );
|
||||
do
|
||||
{
|
||||
*ptr++ = 0;
|
||||
} while( ptr != end_ptr );
|
||||
}
|
||||
|
||||
|
||||
void u8g_pb8h8_Init(u8g_pb_t *b, void *buf, u8g_uint_t width)
|
||||
{
|
||||
b->buf = buf;
|
||||
b->width = width;
|
||||
u8g_pb8h8_Clear(b);
|
||||
}
|
||||
|
||||
static void u8g_pb8h8_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index)
|
||||
{
|
||||
uint16_t tmp;
|
||||
uint8_t *ptr = b->buf;
|
||||
y -= b->p.page_y0;
|
||||
tmp = y;
|
||||
tmp *= b->width;
|
||||
tmp += x;
|
||||
ptr += tmp;
|
||||
*ptr = color_index;
|
||||
}
|
||||
|
||||
void u8g_pb8h8_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t * const arg_pixel)
|
||||
{
|
||||
if ( arg_pixel->y < b->p.page_y0 )
|
||||
return;
|
||||
if ( arg_pixel->y > b->p.page_y1 )
|
||||
return;
|
||||
if ( arg_pixel->x >= b->width )
|
||||
return;
|
||||
u8g_pb8h8_set_pixel(b, arg_pixel->x, arg_pixel->y, arg_pixel->color);
|
||||
}
|
||||
|
||||
|
||||
void u8g_pb8h8_Set8Pixel(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
|
||||
{
|
||||
register uint8_t pixel = arg_pixel->pixel;
|
||||
u8g_uint_t dx = 0;
|
||||
u8g_uint_t dy = 0;
|
||||
|
||||
switch( arg_pixel->dir )
|
||||
{
|
||||
case 0: dx++; break;
|
||||
case 1: dy++; break;
|
||||
case 2: dx--; break;
|
||||
case 3: dy--; break;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
if ( pixel & 128 )
|
||||
u8g_pb8h8_SetPixel(b, arg_pixel);
|
||||
arg_pixel->x += dx;
|
||||
arg_pixel->y += dy;
|
||||
pixel <<= 1;
|
||||
} while( pixel != 0 );
|
||||
}
|
||||
|
||||
|
||||
uint8_t u8g_dev_pb8h8_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_SET_8PIXEL:
|
||||
if ( u8g_pb_Is8PixelVisible(pb, (u8g_dev_arg_pixel_t *)arg) )
|
||||
u8g_pb8h8_Set8Pixel(pb, (u8g_dev_arg_pixel_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_PIXEL:
|
||||
u8g_pb8h8_SetPixel(pb, (u8g_dev_arg_pixel_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_INIT:
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_FIRST:
|
||||
u8g_pb8h8_Clear(pb);
|
||||
u8g_page_First(&(pb->p));
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
if ( u8g_page_Next(&(pb->p)) == 0 )
|
||||
return 0;
|
||||
u8g_pb8h8_Clear(pb);
|
||||
break;
|
||||
#ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
|
||||
case U8G_DEV_MSG_IS_BBX_INTERSECTION:
|
||||
return u8g_pb_IsIntersection(pb, (u8g_dev_arg_bbx_t *)arg);
|
||||
#endif
|
||||
case U8G_DEV_MSG_GET_PAGE_BOX:
|
||||
u8g_pb_GetPageBox(pb, (u8g_box_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_WIDTH:
|
||||
*((u8g_uint_t *)arg) = pb->width;
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_HEIGHT:
|
||||
*((u8g_uint_t *)arg) = pb->p.total_height;
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_COLOR_INDEX:
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_XY_CB:
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_MODE:
|
||||
return U8G_MODE_R3G3B2;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
@ -0,0 +1,184 @@
|
||||
/*
|
||||
|
||||
u8g_pb8v1.c
|
||||
|
||||
8bit height monochrom (1 bit) page buffer
|
||||
byte has vertical orientation
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
#include <string.h>
|
||||
|
||||
|
||||
void u8g_pb8v1_Init(u8g_pb_t *b, void *buf, u8g_uint_t width) U8G_NOINLINE;
|
||||
void u8g_pb8v1_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index) U8G_NOINLINE;
|
||||
void u8g_pb8v1_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t * const arg_pixel) U8G_NOINLINE ;
|
||||
void u8g_pb8v1_Set8PixelStd(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel) U8G_NOINLINE;
|
||||
|
||||
/* Obsolete, usually set by the init of the structure */
|
||||
void u8g_pb8v1_Init(u8g_pb_t *b, void *buf, u8g_uint_t width)
|
||||
{
|
||||
b->buf = buf;
|
||||
b->width = width;
|
||||
u8g_pb_Clear(b);
|
||||
}
|
||||
|
||||
void u8g_pb8v1_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index)
|
||||
{
|
||||
register uint8_t mask;
|
||||
uint8_t *ptr = b->buf;
|
||||
|
||||
y -= b->p.page_y0;
|
||||
mask = 1;
|
||||
y &= 0x07;
|
||||
mask <<= y;
|
||||
ptr += x;
|
||||
if ( color_index )
|
||||
{
|
||||
*ptr |= mask;
|
||||
}
|
||||
else
|
||||
{
|
||||
mask ^=0xff;
|
||||
*ptr &= mask;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void u8g_pb8v1_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t * const arg_pixel)
|
||||
{
|
||||
if ( arg_pixel->y < b->p.page_y0 )
|
||||
return;
|
||||
if ( arg_pixel->y > b->p.page_y1 )
|
||||
return;
|
||||
if ( arg_pixel->x >= b->width )
|
||||
return;
|
||||
u8g_pb8v1_set_pixel(b, arg_pixel->x, arg_pixel->y, arg_pixel->color);
|
||||
}
|
||||
|
||||
void u8g_pb8v1_Set8PixelStd(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
|
||||
{
|
||||
register uint8_t pixel = arg_pixel->pixel;
|
||||
do
|
||||
{
|
||||
if ( pixel & 128 )
|
||||
{
|
||||
u8g_pb8v1_SetPixel(b, arg_pixel);
|
||||
}
|
||||
switch( arg_pixel->dir )
|
||||
{
|
||||
case 0: arg_pixel->x++; break;
|
||||
case 1: arg_pixel->y++; break;
|
||||
case 2: arg_pixel->x--; break;
|
||||
case 3: arg_pixel->y--; break;
|
||||
}
|
||||
pixel <<= 1;
|
||||
} while( pixel != 0 );
|
||||
}
|
||||
|
||||
|
||||
void u8g_pb8v1_Set8PixelOpt2(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
|
||||
{
|
||||
register uint8_t pixel = arg_pixel->pixel;
|
||||
u8g_uint_t dx = 0;
|
||||
u8g_uint_t dy = 0;
|
||||
|
||||
switch( arg_pixel->dir )
|
||||
{
|
||||
case 0: dx++; break;
|
||||
case 1: dy++; break;
|
||||
case 2: dx--; break;
|
||||
case 3: dy--; break;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
if ( pixel & 128 )
|
||||
u8g_pb8v1_SetPixel(b, arg_pixel);
|
||||
arg_pixel->x += dx;
|
||||
arg_pixel->y += dy;
|
||||
pixel <<= 1;
|
||||
} while( pixel != 0 );
|
||||
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_pb8v1_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_SET_8PIXEL:
|
||||
if ( u8g_pb_Is8PixelVisible(pb, (u8g_dev_arg_pixel_t *)arg) )
|
||||
u8g_pb8v1_Set8PixelOpt2(pb, (u8g_dev_arg_pixel_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_PIXEL:
|
||||
u8g_pb8v1_SetPixel(pb, (u8g_dev_arg_pixel_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_INIT:
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_FIRST:
|
||||
u8g_pb_Clear(pb);
|
||||
u8g_page_First(&(pb->p));
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
if ( u8g_page_Next(&(pb->p)) == 0 )
|
||||
return 0;
|
||||
u8g_pb_Clear(pb);
|
||||
break;
|
||||
#ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
|
||||
case U8G_DEV_MSG_IS_BBX_INTERSECTION:
|
||||
return u8g_pb_IsIntersection(pb, (u8g_dev_arg_bbx_t *)arg);
|
||||
#endif
|
||||
case U8G_DEV_MSG_GET_PAGE_BOX:
|
||||
u8g_pb_GetPageBox(pb, (u8g_box_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_WIDTH:
|
||||
*((u8g_uint_t *)arg) = pb->width;
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_HEIGHT:
|
||||
*((u8g_uint_t *)arg) = pb->p.total_height;
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_COLOR_INDEX:
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_XY_CB:
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_MODE:
|
||||
return U8G_MODE_BW;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,153 @@
|
||||
/*
|
||||
|
||||
u8g_pb8v2.c
|
||||
|
||||
8bit height 2 bit per pixel page buffer
|
||||
byte has vertical orientation
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
#include <string.h>
|
||||
|
||||
void u8g_pb8v2_Init(u8g_pb_t *b, void *buf, u8g_uint_t width)
|
||||
{
|
||||
b->buf = buf;
|
||||
b->width = width;
|
||||
u8g_pb_Clear(b);
|
||||
}
|
||||
|
||||
void u8g_pb8v2_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index)
|
||||
{
|
||||
register uint8_t mask;
|
||||
uint8_t *ptr = b->buf;
|
||||
y -= b->p.page_y0;
|
||||
mask = 0x03;
|
||||
y &= 0x03;
|
||||
y <<= 1;
|
||||
mask <<= y;
|
||||
mask ^=0xff;
|
||||
color_index &= 3;
|
||||
color_index <<= y;
|
||||
ptr += x;
|
||||
*ptr &= mask;
|
||||
*ptr |= color_index;
|
||||
}
|
||||
|
||||
|
||||
void u8g_pb8v2_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t * const arg_pixel)
|
||||
{
|
||||
if ( arg_pixel->y < b->p.page_y0 )
|
||||
return;
|
||||
if ( arg_pixel->y > b->p.page_y1 )
|
||||
return;
|
||||
if ( arg_pixel->x >= b->width )
|
||||
return;
|
||||
u8g_pb8v2_set_pixel(b, arg_pixel->x, arg_pixel->y, arg_pixel->color);
|
||||
}
|
||||
|
||||
|
||||
void u8g_pb8v2_Set8PixelStd(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
|
||||
{
|
||||
register uint8_t pixel = arg_pixel->pixel;
|
||||
do
|
||||
{
|
||||
if ( pixel & 128 )
|
||||
{
|
||||
u8g_pb8v2_SetPixel(b, arg_pixel);
|
||||
}
|
||||
switch( arg_pixel->dir )
|
||||
{
|
||||
case 0: arg_pixel->x++; break;
|
||||
case 1: arg_pixel->y++; break;
|
||||
case 2: arg_pixel->x--; break;
|
||||
case 3: arg_pixel->y--; break;
|
||||
}
|
||||
pixel <<= 1;
|
||||
} while( pixel != 0 );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t u8g_dev_pb8v2_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_SET_8PIXEL:
|
||||
if ( u8g_pb_Is8PixelVisible(pb, (u8g_dev_arg_pixel_t *)arg) )
|
||||
{
|
||||
u8g_pb8v2_Set8PixelStd(pb, (u8g_dev_arg_pixel_t *)arg);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_PIXEL:
|
||||
u8g_pb8v2_SetPixel(pb, (u8g_dev_arg_pixel_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_INIT:
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_FIRST:
|
||||
u8g_pb_Clear(pb);
|
||||
u8g_page_First(&(pb->p));
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
if ( u8g_page_Next(&(pb->p)) == 0 )
|
||||
return 0;
|
||||
u8g_pb_Clear(pb);
|
||||
break;
|
||||
#ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
|
||||
case U8G_DEV_MSG_IS_BBX_INTERSECTION:
|
||||
return u8g_pb_IsIntersection(pb, (u8g_dev_arg_bbx_t *)arg);
|
||||
#endif
|
||||
case U8G_DEV_MSG_GET_PAGE_BOX:
|
||||
u8g_pb_GetPageBox(pb, (u8g_box_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_WIDTH:
|
||||
*((u8g_uint_t *)arg) = pb->width;
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_HEIGHT:
|
||||
*((u8g_uint_t *)arg) = pb->p.total_height;
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_COLOR_INDEX:
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_XY_CB:
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_MODE:
|
||||
return U8G_MODE_GRAY2BIT;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,232 @@
|
||||
/*
|
||||
|
||||
u8g_rect.c
|
||||
|
||||
U8G high level interface for horizontal and vertical things
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
void u8g_draw_hline(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w)
|
||||
{
|
||||
uint8_t pixel = 0x0ff;
|
||||
while( w >= 8 )
|
||||
{
|
||||
u8g_Draw8Pixel(u8g, x, y, 0, pixel);
|
||||
w-=8;
|
||||
x+=8;
|
||||
}
|
||||
if ( w != 0 )
|
||||
{
|
||||
w ^=7;
|
||||
w++;
|
||||
pixel <<= w&7;
|
||||
u8g_Draw8Pixel(u8g, x, y, 0, pixel);
|
||||
}
|
||||
}
|
||||
|
||||
void u8g_draw_vline(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t h)
|
||||
{
|
||||
uint8_t pixel = 0x0ff;
|
||||
while( h >= 8 )
|
||||
{
|
||||
u8g_Draw8Pixel(u8g, x, y, 1, pixel);
|
||||
h-=8;
|
||||
y+=8;
|
||||
}
|
||||
if ( h != 0 )
|
||||
{
|
||||
h ^=7;
|
||||
h++;
|
||||
pixel <<= h&7;
|
||||
u8g_Draw8Pixel(u8g, x, y, 1, pixel);
|
||||
}
|
||||
}
|
||||
|
||||
void u8g_DrawHLine(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w)
|
||||
{
|
||||
if ( u8g_IsBBXIntersection(u8g, x, y, w, 1) == 0 )
|
||||
return;
|
||||
u8g_draw_hline(u8g, x, y, w);
|
||||
}
|
||||
|
||||
void u8g_DrawVLine(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w)
|
||||
{
|
||||
if ( u8g_IsBBXIntersection(u8g, x, y, 1, w) == 0 )
|
||||
return;
|
||||
u8g_draw_vline(u8g, x, y, w);
|
||||
}
|
||||
|
||||
/* restrictions: w > 0 && h > 0 */
|
||||
void u8g_DrawFrame(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h)
|
||||
{
|
||||
u8g_uint_t xtmp = x;
|
||||
|
||||
if ( u8g_IsBBXIntersection(u8g, x, y, w, h) == 0 )
|
||||
return;
|
||||
|
||||
|
||||
u8g_draw_hline(u8g, x, y, w);
|
||||
u8g_draw_vline(u8g, x, y, h);
|
||||
x+=w;
|
||||
x--;
|
||||
u8g_draw_vline(u8g, x, y, h);
|
||||
y+=h;
|
||||
y--;
|
||||
u8g_draw_hline(u8g, xtmp, y, w);
|
||||
}
|
||||
|
||||
void u8g_draw_box(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h)
|
||||
{
|
||||
do
|
||||
{
|
||||
u8g_draw_hline(u8g, x, y, w);
|
||||
y++;
|
||||
h--;
|
||||
} while( h != 0 );
|
||||
}
|
||||
|
||||
/* restrictions: h > 0 */
|
||||
void u8g_DrawBox(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h)
|
||||
{
|
||||
if ( u8g_IsBBXIntersection(u8g, x, y, w, h) == 0 )
|
||||
return;
|
||||
u8g_draw_box(u8g, x, y, w, h);
|
||||
}
|
||||
|
||||
|
||||
void u8g_DrawRFrame(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h, u8g_uint_t r)
|
||||
{
|
||||
u8g_uint_t xl, yu;
|
||||
|
||||
if ( u8g_IsBBXIntersection(u8g, x, y, w, h) == 0 )
|
||||
return;
|
||||
|
||||
xl = x;
|
||||
xl += r;
|
||||
yu = y;
|
||||
yu += r;
|
||||
|
||||
{
|
||||
u8g_uint_t yl, xr;
|
||||
|
||||
xr = x;
|
||||
xr += w;
|
||||
xr -= r;
|
||||
xr -= 1;
|
||||
|
||||
yl = y;
|
||||
yl += h;
|
||||
yl -= r;
|
||||
yl -= 1;
|
||||
|
||||
u8g_draw_circle(u8g, xl, yu, r, U8G_DRAW_UPPER_LEFT);
|
||||
u8g_draw_circle(u8g, xr, yu, r, U8G_DRAW_UPPER_RIGHT);
|
||||
u8g_draw_circle(u8g, xl, yl, r, U8G_DRAW_LOWER_LEFT);
|
||||
u8g_draw_circle(u8g, xr, yl, r, U8G_DRAW_LOWER_RIGHT);
|
||||
}
|
||||
|
||||
{
|
||||
u8g_uint_t ww, hh;
|
||||
|
||||
ww = w;
|
||||
ww -= r;
|
||||
ww -= r;
|
||||
ww -= 2;
|
||||
hh = h;
|
||||
hh -= r;
|
||||
hh -= r;
|
||||
hh -= 2;
|
||||
|
||||
xl++;
|
||||
yu++;
|
||||
h--;
|
||||
w--;
|
||||
u8g_draw_hline(u8g, xl, y, ww);
|
||||
u8g_draw_hline(u8g, xl, y+h, ww);
|
||||
u8g_draw_vline(u8g, x, yu, hh);
|
||||
u8g_draw_vline(u8g, x+w, yu, hh);
|
||||
}
|
||||
}
|
||||
|
||||
void u8g_DrawRBox(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h, u8g_uint_t r)
|
||||
{
|
||||
u8g_uint_t xl, yu;
|
||||
u8g_uint_t yl, xr;
|
||||
|
||||
if ( u8g_IsBBXIntersection(u8g, x, y, w, h) == 0 )
|
||||
return;
|
||||
|
||||
xl = x;
|
||||
xl += r;
|
||||
yu = y;
|
||||
yu += r;
|
||||
|
||||
xr = x;
|
||||
xr += w;
|
||||
xr -= r;
|
||||
xr -= 1;
|
||||
|
||||
yl = y;
|
||||
yl += h;
|
||||
yl -= r;
|
||||
yl -= 1;
|
||||
|
||||
u8g_draw_disc(u8g, xl, yu, r, U8G_DRAW_UPPER_LEFT);
|
||||
u8g_draw_disc(u8g, xr, yu, r, U8G_DRAW_UPPER_RIGHT);
|
||||
u8g_draw_disc(u8g, xl, yl, r, U8G_DRAW_LOWER_LEFT);
|
||||
u8g_draw_disc(u8g, xr, yl, r, U8G_DRAW_LOWER_RIGHT);
|
||||
|
||||
{
|
||||
u8g_uint_t ww, hh;
|
||||
|
||||
ww = w;
|
||||
ww -= r;
|
||||
ww -= r;
|
||||
ww -= 2;
|
||||
hh = h;
|
||||
hh -= r;
|
||||
hh -= r;
|
||||
hh -= 2;
|
||||
|
||||
xl++;
|
||||
yu++;
|
||||
h--;
|
||||
u8g_draw_box(u8g, xl, y, ww, r+1);
|
||||
u8g_draw_box(u8g, xl, yl, ww, r+1);
|
||||
//u8g_draw_hline(u8g, xl, y+h, ww);
|
||||
u8g_draw_box(u8g, x, yu, w, hh);
|
||||
//u8g_draw_vline(u8g, x+w, yu, hh);
|
||||
}
|
||||
}
|
@ -0,0 +1,398 @@
|
||||
/*
|
||||
|
||||
u8g_rot.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
uint8_t u8g_dev_rot90_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
|
||||
uint8_t u8g_dev_rot180_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
|
||||
uint8_t u8g_dev_rot270_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
|
||||
|
||||
u8g_dev_t u8g_dev_rot = { u8g_dev_rot90_fn, NULL, NULL };
|
||||
|
||||
|
||||
void u8g_UndoRotation(u8g_t *u8g)
|
||||
{
|
||||
if ( u8g->dev != &u8g_dev_rot )
|
||||
return;
|
||||
u8g->dev = u8g_dev_rot.dev_mem;
|
||||
u8g_UpdateDimension(u8g);
|
||||
}
|
||||
|
||||
void u8g_SetRot90(u8g_t *u8g)
|
||||
{
|
||||
if ( u8g->dev != &u8g_dev_rot )
|
||||
{
|
||||
u8g_dev_rot.dev_mem = u8g->dev;
|
||||
u8g->dev = &u8g_dev_rot;
|
||||
}
|
||||
u8g_dev_rot.dev_fn = u8g_dev_rot90_fn;
|
||||
u8g_UpdateDimension(u8g);
|
||||
}
|
||||
|
||||
void u8g_SetRot180(u8g_t *u8g)
|
||||
{
|
||||
if ( u8g->dev != &u8g_dev_rot )
|
||||
{
|
||||
u8g_dev_rot.dev_mem = u8g->dev;
|
||||
u8g->dev = &u8g_dev_rot;
|
||||
}
|
||||
u8g_dev_rot.dev_fn = u8g_dev_rot180_fn;
|
||||
u8g_UpdateDimension(u8g);
|
||||
}
|
||||
|
||||
void u8g_SetRot270(u8g_t *u8g)
|
||||
{
|
||||
if ( u8g->dev != &u8g_dev_rot )
|
||||
{
|
||||
u8g_dev_rot.dev_mem = u8g->dev;
|
||||
u8g->dev = &u8g_dev_rot;
|
||||
}
|
||||
u8g_dev_rot.dev_fn = u8g_dev_rot270_fn;
|
||||
u8g_UpdateDimension(u8g);
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_rot90_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
u8g_dev_t *rotation_chain = (u8g_dev_t *)(dev->dev_mem);
|
||||
switch(msg)
|
||||
{
|
||||
default:
|
||||
/*
|
||||
case U8G_DEV_MSG_INIT:
|
||||
case U8G_DEV_MSG_STOP:
|
||||
case U8G_DEV_MSG_PAGE_FIRST:
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
case U8G_DEV_MSG_SET_COLOR_INDEX:
|
||||
case U8G_DEV_MSG_SET_XY_CB:
|
||||
*/
|
||||
return u8g_call_dev_fn(u8g, rotation_chain, msg, arg);
|
||||
#ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
|
||||
case U8G_DEV_MSG_IS_BBX_INTERSECTION:
|
||||
{
|
||||
u8g_dev_arg_bbx_t *bbx = (u8g_dev_arg_bbx_t *)arg;
|
||||
u8g_uint_t x, y, tmp;
|
||||
|
||||
/* transform the reference point */
|
||||
y = bbx->x;
|
||||
x = u8g->height;
|
||||
/* x = u8g_GetWidthLL(u8g, rotation_chain); */
|
||||
x -= bbx->y;
|
||||
x--;
|
||||
|
||||
/* adjust point to be the uppler left corner again */
|
||||
x -= bbx->h;
|
||||
x++;
|
||||
|
||||
/* swap box dimensions */
|
||||
tmp = bbx->w;
|
||||
bbx->w = bbx->h;
|
||||
bbx->h = tmp;
|
||||
|
||||
/* store x,y */
|
||||
bbx->x = x;
|
||||
bbx->y = y;
|
||||
}
|
||||
return u8g_call_dev_fn(u8g, rotation_chain, msg, arg);
|
||||
#endif /* U8G_DEV_MSG_IS_BBX_INTERSECTION */
|
||||
case U8G_DEV_MSG_GET_PAGE_BOX:
|
||||
/* get page size from next device in the chain */
|
||||
u8g_call_dev_fn(u8g, rotation_chain, msg, arg);
|
||||
//printf("pre x: %3d..%3d y: %3d..%3d ", ((u8g_box_t *)arg)->x0, ((u8g_box_t *)arg)->x1, ((u8g_box_t *)arg)->y0, ((u8g_box_t *)arg)->y1);
|
||||
{
|
||||
u8g_box_t new_box;
|
||||
//new_box.x0 = u8g_GetHeightLL(u8g,rotation_chain) - ((u8g_box_t *)arg)->y1 - 1;
|
||||
//new_box.x1 = u8g_GetHeightLL(u8g,rotation_chain) - ((u8g_box_t *)arg)->y0 - 1;
|
||||
|
||||
new_box.x0 = ((u8g_box_t *)arg)->y0;
|
||||
new_box.x1 = ((u8g_box_t *)arg)->y1;
|
||||
new_box.y0 = ((u8g_box_t *)arg)->x0;
|
||||
new_box.y1 = ((u8g_box_t *)arg)->x1;
|
||||
*((u8g_box_t *)arg) = new_box;
|
||||
//printf("post x: %3d..%3d y: %3d..%3d\n", ((u8g_box_t *)arg)->x0, ((u8g_box_t *)arg)->x1, ((u8g_box_t *)arg)->y0, ((u8g_box_t *)arg)->y1);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_WIDTH:
|
||||
*((u8g_uint_t *)arg) = u8g_GetHeightLL(u8g,rotation_chain);
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_HEIGHT:
|
||||
*((u8g_uint_t *)arg) = u8g_GetWidthLL(u8g, rotation_chain);
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_PIXEL:
|
||||
{
|
||||
u8g_uint_t x, y;
|
||||
y = ((u8g_dev_arg_pixel_t *)arg)->x;
|
||||
x = u8g_GetWidthLL(u8g, rotation_chain);
|
||||
x -= ((u8g_dev_arg_pixel_t *)arg)->y;
|
||||
x--;
|
||||
((u8g_dev_arg_pixel_t *)arg)->x = x;
|
||||
((u8g_dev_arg_pixel_t *)arg)->y = y;
|
||||
}
|
||||
u8g_call_dev_fn(u8g, rotation_chain, msg, arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_8PIXEL:
|
||||
{
|
||||
u8g_uint_t x, y;
|
||||
//uint16_t x,y;
|
||||
y = ((u8g_dev_arg_pixel_t *)arg)->x;
|
||||
x = u8g_GetWidthLL(u8g, rotation_chain);
|
||||
x -= ((u8g_dev_arg_pixel_t *)arg)->y;
|
||||
x--;
|
||||
((u8g_dev_arg_pixel_t *)arg)->x = x;
|
||||
((u8g_dev_arg_pixel_t *)arg)->y = y;
|
||||
((u8g_dev_arg_pixel_t *)arg)->dir+=1;
|
||||
((u8g_dev_arg_pixel_t *)arg)->dir &= 3;
|
||||
}
|
||||
u8g_call_dev_fn(u8g, rotation_chain, msg, arg);
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_rot180_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
u8g_dev_t *rotation_chain = (u8g_dev_t *)(dev->dev_mem);
|
||||
switch(msg)
|
||||
{
|
||||
default:
|
||||
/*
|
||||
case U8G_DEV_MSG_INIT:
|
||||
case U8G_DEV_MSG_STOP:
|
||||
case U8G_DEV_MSG_PAGE_FIRST:
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
case U8G_DEV_MSG_SET_COLOR_INDEX:
|
||||
case U8G_DEV_MSG_SET_XY_CB:
|
||||
*/
|
||||
return u8g_call_dev_fn(u8g, rotation_chain, msg, arg);
|
||||
#ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
|
||||
case U8G_DEV_MSG_IS_BBX_INTERSECTION:
|
||||
{
|
||||
u8g_dev_arg_bbx_t *bbx = (u8g_dev_arg_bbx_t *)arg;
|
||||
u8g_uint_t x, y;
|
||||
|
||||
/* transform the reference point */
|
||||
//y = u8g_GetHeightLL(u8g, rotation_chain);
|
||||
y = u8g->height;
|
||||
y -= bbx->y;
|
||||
y--;
|
||||
|
||||
//x = u8g_GetWidthLL(u8g, rotation_chain);
|
||||
x = u8g->width;
|
||||
x -= bbx->x;
|
||||
x--;
|
||||
|
||||
/* adjust point to be the uppler left corner again */
|
||||
y -= bbx->h;
|
||||
y++;
|
||||
|
||||
x -= bbx->w;
|
||||
x++;
|
||||
|
||||
/* store x,y */
|
||||
bbx->x = x;
|
||||
bbx->y = y;
|
||||
}
|
||||
return u8g_call_dev_fn(u8g, rotation_chain, msg, arg);
|
||||
#endif /* U8G_DEV_MSG_IS_BBX_INTERSECTION */
|
||||
case U8G_DEV_MSG_GET_PAGE_BOX:
|
||||
/* get page size from next device in the chain */
|
||||
u8g_call_dev_fn(u8g, rotation_chain, msg, arg);
|
||||
//printf("pre x: %3d..%3d y: %3d..%3d ", ((u8g_box_t *)arg)->x0, ((u8g_box_t *)arg)->x1, ((u8g_box_t *)arg)->y0, ((u8g_box_t *)arg)->y1);
|
||||
{
|
||||
u8g_box_t new_box;
|
||||
|
||||
new_box.x0 = u8g_GetWidthLL(u8g,rotation_chain) - ((u8g_box_t *)arg)->x1 - 1;
|
||||
new_box.x1 = u8g_GetWidthLL(u8g,rotation_chain) - ((u8g_box_t *)arg)->x0 - 1;
|
||||
new_box.y0 = u8g_GetHeightLL(u8g,rotation_chain) - ((u8g_box_t *)arg)->y1 - 1;
|
||||
new_box.y1 = u8g_GetHeightLL(u8g,rotation_chain) - ((u8g_box_t *)arg)->y0 - 1;
|
||||
*((u8g_box_t *)arg) = new_box;
|
||||
//printf("post x: %3d..%3d y: %3d..%3d\n", ((u8g_box_t *)arg)->x0, ((u8g_box_t *)arg)->x1, ((u8g_box_t *)arg)->y0, ((u8g_box_t *)arg)->y1);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_WIDTH:
|
||||
*((u8g_uint_t *)arg) = u8g_GetWidthLL(u8g,rotation_chain);
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_HEIGHT:
|
||||
*((u8g_uint_t *)arg) = u8g_GetHeightLL(u8g, rotation_chain);
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_PIXEL:
|
||||
{
|
||||
u8g_uint_t x, y;
|
||||
|
||||
y = u8g_GetHeightLL(u8g, rotation_chain);
|
||||
y -= ((u8g_dev_arg_pixel_t *)arg)->y;
|
||||
y--;
|
||||
|
||||
x = u8g_GetWidthLL(u8g, rotation_chain);
|
||||
x -= ((u8g_dev_arg_pixel_t *)arg)->x;
|
||||
x--;
|
||||
|
||||
((u8g_dev_arg_pixel_t *)arg)->x = x;
|
||||
((u8g_dev_arg_pixel_t *)arg)->y = y;
|
||||
}
|
||||
u8g_call_dev_fn(u8g, rotation_chain, msg, arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_8PIXEL:
|
||||
{
|
||||
u8g_uint_t x, y;
|
||||
|
||||
y = u8g_GetHeightLL(u8g, rotation_chain);
|
||||
y -= ((u8g_dev_arg_pixel_t *)arg)->y;
|
||||
y--;
|
||||
|
||||
x = u8g_GetWidthLL(u8g, rotation_chain);
|
||||
x -= ((u8g_dev_arg_pixel_t *)arg)->x;
|
||||
x--;
|
||||
|
||||
((u8g_dev_arg_pixel_t *)arg)->x = x;
|
||||
((u8g_dev_arg_pixel_t *)arg)->y = y;
|
||||
((u8g_dev_arg_pixel_t *)arg)->dir+=2;
|
||||
((u8g_dev_arg_pixel_t *)arg)->dir &= 3;
|
||||
}
|
||||
u8g_call_dev_fn(u8g, rotation_chain, msg, arg);
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_rot270_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
u8g_dev_t *rotation_chain = (u8g_dev_t *)(dev->dev_mem);
|
||||
switch(msg)
|
||||
{
|
||||
default:
|
||||
/*
|
||||
case U8G_DEV_MSG_INIT:
|
||||
case U8G_DEV_MSG_STOP:
|
||||
case U8G_DEV_MSG_PAGE_FIRST:
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
case U8G_DEV_MSG_SET_COLOR_INDEX:
|
||||
case U8G_DEV_MSG_SET_XY_CB:
|
||||
*/
|
||||
return u8g_call_dev_fn(u8g, rotation_chain, msg, arg);
|
||||
#ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
|
||||
case U8G_DEV_MSG_IS_BBX_INTERSECTION:
|
||||
{
|
||||
u8g_dev_arg_bbx_t *bbx = (u8g_dev_arg_bbx_t *)arg;
|
||||
u8g_uint_t x, y, tmp;
|
||||
|
||||
/* transform the reference point */
|
||||
x = bbx->y;
|
||||
|
||||
y = u8g->width;
|
||||
/* y = u8g_GetHeightLL(u8g, rotation_chain); */
|
||||
y -= bbx->x;
|
||||
y--;
|
||||
|
||||
/* adjust point to be the uppler left corner again */
|
||||
y -= bbx->w;
|
||||
y++;
|
||||
|
||||
/* swap box dimensions */
|
||||
tmp = bbx->w;
|
||||
bbx->w = bbx->h;
|
||||
bbx->h = tmp;
|
||||
|
||||
/* store x,y */
|
||||
bbx->x = x;
|
||||
bbx->y = y;
|
||||
}
|
||||
return u8g_call_dev_fn(u8g, rotation_chain, msg, arg);
|
||||
#endif /* U8G_DEV_MSG_IS_BBX_INTERSECTION */
|
||||
case U8G_DEV_MSG_GET_PAGE_BOX:
|
||||
/* get page size from next device in the chain */
|
||||
u8g_call_dev_fn(u8g, rotation_chain, msg, arg);
|
||||
//printf("pre x: %3d..%3d y: %3d..%3d ", ((u8g_box_t *)arg)->x0, ((u8g_box_t *)arg)->x1, ((u8g_box_t *)arg)->y0, ((u8g_box_t *)arg)->y1);
|
||||
{
|
||||
u8g_box_t new_box;
|
||||
|
||||
new_box.x0 = u8g_GetHeightLL(u8g,rotation_chain) - ((u8g_box_t *)arg)->y1 - 1;
|
||||
new_box.x1 = u8g_GetHeightLL(u8g,rotation_chain) - ((u8g_box_t *)arg)->y0 - 1;
|
||||
new_box.y0 = u8g_GetWidthLL(u8g,rotation_chain) - ((u8g_box_t *)arg)->x1 - 1;
|
||||
new_box.y1 = u8g_GetWidthLL(u8g,rotation_chain) - ((u8g_box_t *)arg)->x0 - 1;
|
||||
*((u8g_box_t *)arg) = new_box;
|
||||
//printf("post x: %3d..%3d y: %3d..%3d\n", ((u8g_box_t *)arg)->x0, ((u8g_box_t *)arg)->x1, ((u8g_box_t *)arg)->y0, ((u8g_box_t *)arg)->y1);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_WIDTH:
|
||||
*((u8g_uint_t *)arg) = u8g_GetHeightLL(u8g,rotation_chain);
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_HEIGHT:
|
||||
*((u8g_uint_t *)arg) = u8g_GetWidthLL(u8g, rotation_chain);
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_PIXEL:
|
||||
{
|
||||
u8g_uint_t x, y;
|
||||
x = ((u8g_dev_arg_pixel_t *)arg)->y;
|
||||
|
||||
y = u8g_GetHeightLL(u8g, rotation_chain);
|
||||
y -= ((u8g_dev_arg_pixel_t *)arg)->x;
|
||||
y--;
|
||||
|
||||
/*
|
||||
x = u8g_GetWidthLL(u8g, rotation_chain);
|
||||
x -= ((u8g_dev_arg_pixel_t *)arg)->y;
|
||||
x--;
|
||||
*/
|
||||
((u8g_dev_arg_pixel_t *)arg)->x = x;
|
||||
((u8g_dev_arg_pixel_t *)arg)->y = y;
|
||||
}
|
||||
u8g_call_dev_fn(u8g, rotation_chain, msg, arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_8PIXEL:
|
||||
{
|
||||
u8g_uint_t x, y;
|
||||
x = ((u8g_dev_arg_pixel_t *)arg)->y;
|
||||
|
||||
y = u8g_GetHeightLL(u8g, rotation_chain);
|
||||
y -= ((u8g_dev_arg_pixel_t *)arg)->x;
|
||||
y--;
|
||||
|
||||
/*
|
||||
x = u8g_GetWidthLL(u8g, rotation_chain);
|
||||
x -= ((u8g_dev_arg_pixel_t *)arg)->y;
|
||||
x--;
|
||||
*/
|
||||
((u8g_dev_arg_pixel_t *)arg)->x = x;
|
||||
((u8g_dev_arg_pixel_t *)arg)->y = y;
|
||||
((u8g_dev_arg_pixel_t *)arg)->dir+=3;
|
||||
((u8g_dev_arg_pixel_t *)arg)->dir &= 3;
|
||||
}
|
||||
u8g_call_dev_fn(u8g, rotation_chain, msg, arg);
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
@ -0,0 +1,188 @@
|
||||
/*
|
||||
|
||||
u8g_scale.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2012, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
Scale screen by some constant factors. Usefull for making bigger fonts wiht less
|
||||
memory consumption
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
uint8_t u8g_dev_scale_2x2_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
|
||||
|
||||
|
||||
u8g_dev_t u8g_dev_scale = { u8g_dev_scale_2x2_fn, NULL, NULL };
|
||||
|
||||
void u8g_UndoScale(u8g_t *u8g)
|
||||
{
|
||||
if ( u8g->dev != &u8g_dev_scale )
|
||||
return;
|
||||
u8g->dev = u8g_dev_scale.dev_mem;
|
||||
u8g_UpdateDimension(u8g);
|
||||
}
|
||||
|
||||
void u8g_SetScale2x2(u8g_t *u8g)
|
||||
{
|
||||
if ( u8g->dev != &u8g_dev_scale )
|
||||
{
|
||||
u8g_dev_scale.dev_mem = u8g->dev;
|
||||
u8g->dev = &u8g_dev_scale;
|
||||
}
|
||||
u8g_dev_scale.dev_fn = u8g_dev_scale_2x2_fn;
|
||||
u8g_UpdateDimension(u8g);
|
||||
}
|
||||
|
||||
|
||||
uint8_t u8g_dev_scale_2x2_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
u8g_dev_t *chain = (u8g_dev_t *)(dev->dev_mem);
|
||||
uint8_t pixel;
|
||||
uint16_t scaled_pixel;
|
||||
uint8_t i;
|
||||
uint8_t dir;
|
||||
u8g_uint_t x, y, xx,yy;
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
default:
|
||||
return u8g_call_dev_fn(u8g, chain, msg, arg);
|
||||
case U8G_DEV_MSG_GET_WIDTH:
|
||||
*((u8g_uint_t *)arg) = u8g_GetWidthLL(u8g, chain) / 2;
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_HEIGHT:
|
||||
*((u8g_uint_t *)arg) = u8g_GetHeightLL(u8g, chain) / 2;
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_PAGE_BOX:
|
||||
/* get page size from next device in the chain */
|
||||
u8g_call_dev_fn(u8g, chain, msg, arg);
|
||||
((u8g_box_t *)arg)->x0 /= 2;
|
||||
((u8g_box_t *)arg)->x1 /= 2;
|
||||
((u8g_box_t *)arg)->y0 /= 2;
|
||||
((u8g_box_t *)arg)->y1 /= 2;
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SET_PIXEL:
|
||||
x = ((u8g_dev_arg_pixel_t *)arg)->x;
|
||||
x *= 2;
|
||||
y = ((u8g_dev_arg_pixel_t *)arg)->y;
|
||||
y *= 2;
|
||||
((u8g_dev_arg_pixel_t *)arg)->x = x;
|
||||
((u8g_dev_arg_pixel_t *)arg)->y = y;
|
||||
u8g_call_dev_fn(u8g, chain, msg, arg);
|
||||
x++;
|
||||
((u8g_dev_arg_pixel_t *)arg)->x = x;
|
||||
((u8g_dev_arg_pixel_t *)arg)->y = y;
|
||||
u8g_call_dev_fn(u8g, chain, msg, arg);
|
||||
y++;
|
||||
((u8g_dev_arg_pixel_t *)arg)->x = x;
|
||||
((u8g_dev_arg_pixel_t *)arg)->y = y;
|
||||
u8g_call_dev_fn(u8g, chain, msg, arg);
|
||||
x--;
|
||||
((u8g_dev_arg_pixel_t *)arg)->x = x;
|
||||
((u8g_dev_arg_pixel_t *)arg)->y = y;
|
||||
u8g_call_dev_fn(u8g, chain, msg, arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_8PIXEL:
|
||||
pixel = ((u8g_dev_arg_pixel_t *)arg)->pixel;
|
||||
dir = ((u8g_dev_arg_pixel_t *)arg)->dir;
|
||||
scaled_pixel = 0;
|
||||
for( i = 0; i < 8; i++ )
|
||||
{
|
||||
scaled_pixel<<=2;
|
||||
if ( pixel & 128 )
|
||||
{
|
||||
scaled_pixel |= 3;
|
||||
}
|
||||
pixel<<=1;
|
||||
}
|
||||
x = ((u8g_dev_arg_pixel_t *)arg)->x;
|
||||
x *= 2;
|
||||
xx = x;
|
||||
y = ((u8g_dev_arg_pixel_t *)arg)->y;
|
||||
y *= 2;
|
||||
yy = y;
|
||||
if ( ((u8g_dev_arg_pixel_t *)arg)->dir & 1 )
|
||||
{
|
||||
xx++;
|
||||
}
|
||||
else
|
||||
{
|
||||
yy++;
|
||||
}
|
||||
|
||||
((u8g_dev_arg_pixel_t *)arg)->pixel = scaled_pixel>>8;
|
||||
((u8g_dev_arg_pixel_t *)arg)->x = x;
|
||||
((u8g_dev_arg_pixel_t *)arg)->y = y;
|
||||
((u8g_dev_arg_pixel_t *)arg)->dir = dir;
|
||||
u8g_call_dev_fn(u8g, chain, msg, arg);
|
||||
|
||||
|
||||
((u8g_dev_arg_pixel_t *)arg)->x = xx;
|
||||
((u8g_dev_arg_pixel_t *)arg)->y = yy;
|
||||
((u8g_dev_arg_pixel_t *)arg)->dir = dir;
|
||||
u8g_call_dev_fn(u8g, chain, msg, arg);
|
||||
|
||||
((u8g_dev_arg_pixel_t *)arg)->pixel = scaled_pixel&255;
|
||||
//((u8g_dev_arg_pixel_t *)arg)->pixel = 0x00;
|
||||
switch(dir)
|
||||
{
|
||||
case 0:
|
||||
x+=8;
|
||||
xx+=8;
|
||||
break;
|
||||
case 1:
|
||||
y+=8;
|
||||
yy+=8;
|
||||
break;
|
||||
case 2:
|
||||
x-=8;
|
||||
xx-=8;
|
||||
break;
|
||||
case 3:
|
||||
y-=8;
|
||||
yy-=8;
|
||||
break;
|
||||
}
|
||||
((u8g_dev_arg_pixel_t *)arg)->x = x;
|
||||
((u8g_dev_arg_pixel_t *)arg)->y = y;
|
||||
((u8g_dev_arg_pixel_t *)arg)->dir = dir;
|
||||
u8g_call_dev_fn(u8g, chain, msg, arg);
|
||||
|
||||
((u8g_dev_arg_pixel_t *)arg)->x = xx;
|
||||
((u8g_dev_arg_pixel_t *)arg)->y = yy;
|
||||
((u8g_dev_arg_pixel_t *)arg)->dir = dir;
|
||||
u8g_call_dev_fn(u8g, chain, msg, arg);
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
@ -0,0 +1,102 @@
|
||||
/*
|
||||
|
||||
u8g_state.c
|
||||
|
||||
backup and restore hardware state
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
state callback: backup env U8G_STATE_MSG_BACKUP_ENV
|
||||
device callback: DEV_MSG_INIT
|
||||
state callback: backup u8g U8G_STATE_MSG_BACKUP_U8G
|
||||
state callback: restore env U8G_STATE_MSG_RESTORE_ENV
|
||||
|
||||
state callback: backup env U8G_STATE_MSG_BACKUP_ENV
|
||||
state callback: retore u8g U8G_STATE_MSG_RESTORE_U8G
|
||||
DEV_MSG_PAGE_FIRST or DEV_MSG_PAGE_NEXT
|
||||
state callback: restore env U8G_STATE_MSG_RESTORE_ENV
|
||||
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include "u8g.h"
|
||||
|
||||
void u8g_state_dummy_cb(uint8_t msg)
|
||||
{
|
||||
/* the dummy procedure does nothing */
|
||||
}
|
||||
|
||||
void u8g_SetHardwareBackup(u8g_t *u8g, u8g_state_cb backup_cb)
|
||||
{
|
||||
u8g->state_cb = backup_cb;
|
||||
/* in most cases the init message was already sent, so this will backup the */
|
||||
/* current u8g state */
|
||||
backup_cb(U8G_STATE_MSG_BACKUP_U8G);
|
||||
}
|
||||
|
||||
|
||||
/*===============================================================*/
|
||||
/* AVR */
|
||||
|
||||
#if defined(__AVR__)
|
||||
#define U8G_ATMEGA_HW_SPI
|
||||
|
||||
/* remove the definition for attiny */
|
||||
#if __AVR_ARCH__ == 2
|
||||
#undef U8G_ATMEGA_HW_SPI
|
||||
#endif
|
||||
#if __AVR_ARCH__ == 25
|
||||
#undef U8G_ATMEGA_HW_SPI
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(U8G_ATMEGA_HW_SPI)
|
||||
#include <avr/interrupt.h>
|
||||
static uint8_t u8g_state_avr_spi_memory[2];
|
||||
|
||||
void u8g_backup_avr_spi(uint8_t msg)
|
||||
{
|
||||
if ( U8G_STATE_MSG_IS_BACKUP(msg) )
|
||||
{
|
||||
u8g_state_avr_spi_memory[U8G_STATE_MSG_GET_IDX(msg)] = SPCR;
|
||||
}
|
||||
else
|
||||
{
|
||||
uint8_t tmp = SREG;
|
||||
cli();
|
||||
SPCR = 0;
|
||||
SPCR = u8g_state_avr_spi_memory[U8G_STATE_MSG_GET_IDX(msg)];
|
||||
SREG = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -0,0 +1,68 @@
|
||||
/*
|
||||
|
||||
u8g_u16toa.c
|
||||
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2012, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
const char *u8g_u16toap(char * dest, uint16_t v)
|
||||
{
|
||||
uint8_t pos;
|
||||
uint8_t d;
|
||||
uint16_t c;
|
||||
c = 10000;
|
||||
for( pos = 0; pos < 5; pos++ )
|
||||
{
|
||||
d = '0';
|
||||
while( v >= c )
|
||||
{
|
||||
v -= c;
|
||||
d++;
|
||||
}
|
||||
dest[pos] = d;
|
||||
c /= 10;
|
||||
}
|
||||
dest[5] = '\0';
|
||||
return dest;
|
||||
}
|
||||
|
||||
/* v = value, d = number of digits */
|
||||
const char *u8g_u16toa(uint16_t v, uint8_t d)
|
||||
{
|
||||
static char buf[6];
|
||||
d = 5-d;
|
||||
return u8g_u16toap(buf, v) + d;
|
||||
}
|
||||
|
@ -0,0 +1,68 @@
|
||||
/*
|
||||
|
||||
u8g_u8toa.c
|
||||
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
static const unsigned char u8g_u8toa_tab[3] = { 100, 10, 1 } ;
|
||||
const char *u8g_u8toap(char * dest, uint8_t v)
|
||||
{
|
||||
uint8_t pos;
|
||||
uint8_t d;
|
||||
uint8_t c;
|
||||
for( pos = 0; pos < 3; pos++ )
|
||||
{
|
||||
d = '0';
|
||||
c = *(u8g_u8toa_tab+pos);
|
||||
while( v >= c )
|
||||
{
|
||||
v -= c;
|
||||
d++;
|
||||
}
|
||||
dest[pos] = d;
|
||||
}
|
||||
dest[3] = '\0';
|
||||
return dest;
|
||||
}
|
||||
|
||||
/* v = value, d = number of digits */
|
||||
const char *u8g_u8toa(uint8_t v, uint8_t d)
|
||||
{
|
||||
static char buf[4];
|
||||
d = 3-d;
|
||||
return u8g_u8toap(buf, v) + d;
|
||||
}
|
||||
|
@ -0,0 +1,145 @@
|
||||
/*
|
||||
|
||||
u8g_virtual_screen.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2012, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
struct _u8g_vs_t
|
||||
{
|
||||
u8g_uint_t x;
|
||||
u8g_uint_t y;
|
||||
u8g_t *u8g;
|
||||
};
|
||||
typedef struct _u8g_vs_t u8g_vs_t;
|
||||
|
||||
#define U8g_VS_MAX 4
|
||||
uint8_t u8g_vs_cnt = 0;
|
||||
u8g_vs_t u8g_vs_list[U8g_VS_MAX];
|
||||
uint8_t u8g_vs_current;
|
||||
u8g_uint_t u8g_vs_width;
|
||||
u8g_uint_t u8g_vs_height;
|
||||
|
||||
uint8_t u8g_dev_vs_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
default:
|
||||
{
|
||||
uint8_t i;
|
||||
for( i = 0; i < u8g_vs_cnt; i++ )
|
||||
{
|
||||
u8g_call_dev_fn(u8g_vs_list[i].u8g, u8g_vs_list[i].u8g->dev, msg, arg);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
case U8G_DEV_MSG_PAGE_FIRST:
|
||||
u8g_vs_current = 0;
|
||||
if ( u8g_vs_cnt != 0 )
|
||||
return u8g_call_dev_fn(u8g_vs_list[u8g_vs_current].u8g, u8g_vs_list[u8g_vs_current].u8g->dev, msg, arg);
|
||||
return 0;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
uint8_t ret = 0;
|
||||
if ( u8g_vs_cnt != 0 )
|
||||
ret = u8g_call_dev_fn(u8g_vs_list[u8g_vs_current].u8g, u8g_vs_list[u8g_vs_current].u8g->dev, msg, arg);
|
||||
if ( ret != 0 )
|
||||
return ret;
|
||||
u8g_vs_current++; /* next device */
|
||||
if ( u8g_vs_current >= u8g_vs_cnt ) /* reached end? */
|
||||
return 0;
|
||||
return u8g_call_dev_fn(u8g_vs_list[u8g_vs_current].u8g, u8g_vs_list[u8g_vs_current].u8g->dev, U8G_DEV_MSG_PAGE_FIRST, arg);
|
||||
}
|
||||
return 0;
|
||||
case U8G_DEV_MSG_GET_WIDTH:
|
||||
*((u8g_uint_t *)arg) = u8g_vs_width;
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_HEIGHT:
|
||||
*((u8g_uint_t *)arg) = u8g_vs_height;
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_PAGE_BOX:
|
||||
if ( u8g_vs_current < u8g_vs_cnt )
|
||||
{
|
||||
u8g_call_dev_fn(u8g_vs_list[u8g_vs_current].u8g, u8g_vs_list[u8g_vs_current].u8g->dev, msg, arg);
|
||||
((u8g_box_t *)arg)->x0 += u8g_vs_list[u8g_vs_current].x;
|
||||
((u8g_box_t *)arg)->x1 += u8g_vs_list[u8g_vs_current].x;
|
||||
((u8g_box_t *)arg)->y0 += u8g_vs_list[u8g_vs_current].y;
|
||||
((u8g_box_t *)arg)->y1 += u8g_vs_list[u8g_vs_current].y;
|
||||
}
|
||||
else
|
||||
{
|
||||
((u8g_box_t *)arg)->x0 = 0;
|
||||
((u8g_box_t *)arg)->x1 = 0;
|
||||
((u8g_box_t *)arg)->y0 = 0;
|
||||
((u8g_box_t *)arg)->y1 = 0;
|
||||
}
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SET_PIXEL:
|
||||
case U8G_DEV_MSG_SET_8PIXEL:
|
||||
if ( u8g_vs_current < u8g_vs_cnt )
|
||||
{
|
||||
((u8g_dev_arg_pixel_t *)arg)->x -= u8g_vs_list[u8g_vs_current].x;
|
||||
((u8g_dev_arg_pixel_t *)arg)->y -= u8g_vs_list[u8g_vs_current].y;
|
||||
return u8g_call_dev_fn(u8g_vs_list[u8g_vs_current].u8g, u8g_vs_list[u8g_vs_current].u8g->dev, msg, arg);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
u8g_dev_t u8g_dev_vs = { u8g_dev_vs_fn, NULL, NULL };
|
||||
|
||||
void u8g_SetVirtualScreenDimension(u8g_t *vs_u8g, u8g_uint_t width, u8g_uint_t height)
|
||||
{
|
||||
if ( vs_u8g->dev != &u8g_dev_vs )
|
||||
return; /* abort if there is no a virtual screen device */
|
||||
u8g_vs_width = width;
|
||||
u8g_vs_height = height;
|
||||
}
|
||||
|
||||
uint8_t u8g_AddToVirtualScreen(u8g_t *vs_u8g, u8g_uint_t x, u8g_uint_t y, u8g_t *child_u8g)
|
||||
{
|
||||
if ( vs_u8g->dev != &u8g_dev_vs )
|
||||
return 0; /* abort if there is no a virtual screen device */
|
||||
if ( u8g_vs_cnt >= U8g_VS_MAX )
|
||||
return 0; /* maximum number of child u8g's reached */
|
||||
u8g_vs_list[u8g_vs_cnt].u8g = child_u8g;
|
||||
u8g_vs_list[u8g_vs_cnt].x = x;
|
||||
u8g_vs_list[u8g_vs_cnt].y = y;
|
||||
u8g_vs_cnt++;
|
||||
return 1;
|
||||
}
|
||||
|
@ -0,0 +1,9 @@
|
||||
|
||||
# Marlin AVR Core and platform.
|
||||
# ------------------------------
|
||||
|
||||
# For more info:
|
||||
# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification
|
||||
|
||||
name=Marlin AVR Boards
|
||||
version=1.5.6
|
@ -0,0 +1,411 @@
|
||||
/*
|
||||
pins_arduino.h - Pin definition functions for Arduino
|
||||
Part of Arduino - http://www.arduino.cc/
|
||||
|
||||
Copyright (c) 2007 David A. Mellis
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General
|
||||
Public License along with this library; if not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
Boston, MA 02111-1307 USA
|
||||
|
||||
$Id: wiring.h 249 2007-02-03 16:52:51Z mellis $
|
||||
*/
|
||||
|
||||
#ifndef Pins_Arduino_h
|
||||
#define Pins_Arduino_h
|
||||
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
#define NUM_DIGITAL_PINS 82
|
||||
#define NUM_ANALOG_INPUTS 16
|
||||
#define analogInputToDigitalPin(p) ((p < 16) ? (p) + 54 : -1)
|
||||
#define digitalPinHasPWM(p) (((p) >= 2 && (p) <= 13) || ((p) >= 44 && (p)<= 46))
|
||||
|
||||
static const uint8_t SS = 53;
|
||||
static const uint8_t MOSI = 51;
|
||||
static const uint8_t MISO = 50;
|
||||
static const uint8_t SCK = 52;
|
||||
|
||||
static const uint8_t SDA = 20;
|
||||
static const uint8_t SCL = 21;
|
||||
static const uint8_t LED_BUILTIN = 13;
|
||||
|
||||
static const uint8_t A0 = 54;
|
||||
static const uint8_t A1 = 55;
|
||||
static const uint8_t A2 = 56;
|
||||
static const uint8_t A3 = 57;
|
||||
static const uint8_t A4 = 58;
|
||||
static const uint8_t A5 = 59;
|
||||
static const uint8_t A6 = 60;
|
||||
static const uint8_t A7 = 61;
|
||||
static const uint8_t A8 = 62;
|
||||
static const uint8_t A9 = 63;
|
||||
static const uint8_t A10 = 64;
|
||||
static const uint8_t A11 = 65;
|
||||
static const uint8_t A12 = 66;
|
||||
static const uint8_t A13 = 67;
|
||||
static const uint8_t A14 = 68;
|
||||
static const uint8_t A15 = 69;
|
||||
|
||||
// A majority of the pins are NOT PCINTs, SO BE WARNED (i.e. you cannot use them as receive pins)
|
||||
// Only pins available for RECEIVE (TRANSMIT can be on any pin):
|
||||
// (I've deliberately left out pin mapping to the Hardware USARTs - seems senseless to me)
|
||||
// Pins: 10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69
|
||||
|
||||
#define digitalPinToPCICR(p) ( (((p) >= 10) && ((p) <= 13)) || \
|
||||
(((p) >= 50) && ((p) <= 53)) || \
|
||||
(((p) >= 62) && ((p) <= 69)) ? (&PCICR) : ((uint8_t *)0) )
|
||||
|
||||
#define digitalPinToPCICRbit(p) ( (((p) >= 10) && ((p) <= 13)) || (((p) >= 50) && ((p) <= 53)) ? 0 : \
|
||||
( (((p) >= 62) && ((p) <= 69)) ? 2 : \
|
||||
0 ) )
|
||||
|
||||
#define digitalPinToPCMSK(p) ( (((p) >= 10) && ((p) <= 13)) || (((p) >= 50) && ((p) <= 53)) ? (&PCMSK0) : \
|
||||
( (((p) >= 62) && ((p) <= 69)) ? (&PCMSK2) : \
|
||||
((uint8_t *)0) ) )
|
||||
|
||||
#define digitalPinToPCMSKbit(p) ( (((p) >= 10) && ((p) <= 13)) ? ((p) - 6) : \
|
||||
( ((p) == 50) ? 3 : \
|
||||
( ((p) == 51) ? 2 : \
|
||||
( ((p) == 52) ? 1 : \
|
||||
( ((p) == 53) ? 0 : \
|
||||
( (((p) >= 62) && ((p) <= 69)) ? ((p) - 62) : \
|
||||
0 ) ) ) ) ) )
|
||||
|
||||
#ifdef ARDUINO_MAIN
|
||||
|
||||
const uint16_t PROGMEM port_to_mode_PGM[] = {
|
||||
NOT_A_PORT,
|
||||
(uint16_t) &DDRA,
|
||||
(uint16_t) &DDRB,
|
||||
(uint16_t) &DDRC,
|
||||
(uint16_t) &DDRD,
|
||||
(uint16_t) &DDRE,
|
||||
(uint16_t) &DDRF,
|
||||
(uint16_t) &DDRG,
|
||||
(uint16_t) &DDRH,
|
||||
NOT_A_PORT,
|
||||
(uint16_t) &DDRJ,
|
||||
(uint16_t) &DDRK,
|
||||
(uint16_t) &DDRL,
|
||||
};
|
||||
|
||||
const uint16_t PROGMEM port_to_output_PGM[] = {
|
||||
NOT_A_PORT,
|
||||
(uint16_t) &PORTA,
|
||||
(uint16_t) &PORTB,
|
||||
(uint16_t) &PORTC,
|
||||
(uint16_t) &PORTD,
|
||||
(uint16_t) &PORTE,
|
||||
(uint16_t) &PORTF,
|
||||
(uint16_t) &PORTG,
|
||||
(uint16_t) &PORTH,
|
||||
NOT_A_PORT,
|
||||
(uint16_t) &PORTJ,
|
||||
(uint16_t) &PORTK,
|
||||
(uint16_t) &PORTL,
|
||||
};
|
||||
|
||||
const uint16_t PROGMEM port_to_input_PGM[] = {
|
||||
NOT_A_PIN,
|
||||
(uint16_t) &PINA,
|
||||
(uint16_t) &PINB,
|
||||
(uint16_t) &PINC,
|
||||
(uint16_t) &PIND,
|
||||
(uint16_t) &PINE,
|
||||
(uint16_t) &PINF,
|
||||
(uint16_t) &PING,
|
||||
(uint16_t) &PINH,
|
||||
NOT_A_PIN,
|
||||
(uint16_t) &PINJ,
|
||||
(uint16_t) &PINK,
|
||||
(uint16_t) &PINL,
|
||||
};
|
||||
|
||||
const uint8_t PROGMEM digital_pin_to_port_PGM[] = {
|
||||
// PORTLIST
|
||||
// -------------------------------------------
|
||||
PE , // PE 0 ** 0 ** USART0_RX
|
||||
PE , // PE 1 ** 1 ** USART0_TX
|
||||
PE , // PE 4 ** 2 ** PWM2
|
||||
PE , // PE 5 ** 3 ** PWM3
|
||||
PG , // PG 5 ** 4 ** PWM4
|
||||
PE , // PE 3 ** 5 ** PWM5
|
||||
PH , // PH 3 ** 6 ** PWM6
|
||||
PH , // PH 4 ** 7 ** PWM7
|
||||
PH , // PH 5 ** 8 ** PWM8
|
||||
PH , // PH 6 ** 9 ** PWM9
|
||||
PB , // PB 4 ** 10 ** PWM10
|
||||
PB , // PB 5 ** 11 ** PWM11
|
||||
PB , // PB 6 ** 12 ** PWM12
|
||||
PB , // PB 7 ** 13 ** PWM13
|
||||
PJ , // PJ 1 ** 14 ** USART3_TX
|
||||
PJ , // PJ 0 ** 15 ** USART3_RX
|
||||
PH , // PH 1 ** 16 ** USART2_TX
|
||||
PH , // PH 0 ** 17 ** USART2_RX
|
||||
PD , // PD 3 ** 18 ** USART1_TX
|
||||
PD , // PD 2 ** 19 ** USART1_RX
|
||||
PD , // PD 1 ** 20 ** I2C_SDA
|
||||
PD , // PD 0 ** 21 ** I2C_SCL
|
||||
PA , // PA 0 ** 22 ** D22
|
||||
PA , // PA 1 ** 23 ** D23
|
||||
PA , // PA 2 ** 24 ** D24
|
||||
PA , // PA 3 ** 25 ** D25
|
||||
PA , // PA 4 ** 26 ** D26
|
||||
PA , // PA 5 ** 27 ** D27
|
||||
PA , // PA 6 ** 28 ** D28
|
||||
PA , // PA 7 ** 29 ** D29
|
||||
PC , // PC 7 ** 30 ** D30
|
||||
PC , // PC 6 ** 31 ** D31
|
||||
PC , // PC 5 ** 32 ** D32
|
||||
PC , // PC 4 ** 33 ** D33
|
||||
PC , // PC 3 ** 34 ** D34
|
||||
PC , // PC 2 ** 35 ** D35
|
||||
PC , // PC 1 ** 36 ** D36
|
||||
PC , // PC 0 ** 37 ** D37
|
||||
PD , // PD 7 ** 38 ** D38
|
||||
PG , // PG 2 ** 39 ** D39
|
||||
PG , // PG 1 ** 40 ** D40
|
||||
PG , // PG 0 ** 41 ** D41
|
||||
PL , // PL 7 ** 42 ** D42
|
||||
PL , // PL 6 ** 43 ** D43
|
||||
PL , // PL 5 ** 44 ** D44
|
||||
PL , // PL 4 ** 45 ** D45
|
||||
PL , // PL 3 ** 46 ** D46
|
||||
PL , // PL 2 ** 47 ** D47
|
||||
PL , // PL 1 ** 48 ** D48
|
||||
PL , // PL 0 ** 49 ** D49
|
||||
PB , // PB 3 ** 50 ** SPI_MISO
|
||||
PB , // PB 2 ** 51 ** SPI_MOSI
|
||||
PB , // PB 1 ** 52 ** SPI_SCK
|
||||
PB , // PB 0 ** 53 ** SPI_SS
|
||||
PF , // PF 0 ** 54 ** A0
|
||||
PF , // PF 1 ** 55 ** A1
|
||||
PF , // PF 2 ** 56 ** A2
|
||||
PF , // PF 3 ** 57 ** A3
|
||||
PF , // PF 4 ** 58 ** A4
|
||||
PF , // PF 5 ** 59 ** A5
|
||||
PF , // PF 6 ** 60 ** A6
|
||||
PF , // PF 7 ** 61 ** A7
|
||||
PK , // PK 0 ** 62 ** A8
|
||||
PK , // PK 1 ** 63 ** A9
|
||||
PK , // PK 2 ** 64 ** A10
|
||||
PK , // PK 3 ** 65 ** A11
|
||||
PK , // PK 4 ** 66 ** A12
|
||||
PK , // PK 5 ** 67 ** A13
|
||||
PK , // PK 6 ** 68 ** A14
|
||||
PK , // PK 7 ** 69 ** A15
|
||||
PG , // PG 4 ** 70 ** D70
|
||||
PG , // PG 3 ** 71 ** D71
|
||||
PJ , // PJ 2 ** 72 ** D72
|
||||
PJ , // PJ 3 ** 73 ** D73
|
||||
PJ , // PJ 7 ** 74 ** D74
|
||||
PJ , // PJ 4 ** 75 ** D75
|
||||
PJ , // PJ 5 ** 76 ** D76
|
||||
PJ , // PJ 6 ** 77 ** D77
|
||||
PE , // PE 2 ** 78 ** D78
|
||||
PE , // PE 6 ** 79 ** D79
|
||||
PE , // PE 7 ** 80 ** D80
|
||||
PD , // PD 4 ** 81 ** D81
|
||||
PD , // PD 5 ** 82 ** D82
|
||||
PD , // PD 6 ** 83 ** D83
|
||||
PH , // PH 2 ** 84 ** D84
|
||||
PH , // PH 7 ** 85 ** D85
|
||||
};
|
||||
|
||||
const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = {
|
||||
// PIN IN PORT
|
||||
// -------------------------------------------
|
||||
_BV( 0 ) , // PE 0 ** 0 ** USART0_RX
|
||||
_BV( 1 ) , // PE 1 ** 1 ** USART0_TX
|
||||
_BV( 4 ) , // PE 4 ** 2 ** PWM2
|
||||
_BV( 5 ) , // PE 5 ** 3 ** PWM3
|
||||
_BV( 5 ) , // PG 5 ** 4 ** PWM4
|
||||
_BV( 3 ) , // PE 3 ** 5 ** PWM5
|
||||
_BV( 3 ) , // PH 3 ** 6 ** PWM6
|
||||
_BV( 4 ) , // PH 4 ** 7 ** PWM7
|
||||
_BV( 5 ) , // PH 5 ** 8 ** PWM8
|
||||
_BV( 6 ) , // PH 6 ** 9 ** PWM9
|
||||
_BV( 4 ) , // PB 4 ** 10 ** PWM10
|
||||
_BV( 5 ) , // PB 5 ** 11 ** PWM11
|
||||
_BV( 6 ) , // PB 6 ** 12 ** PWM12
|
||||
_BV( 7 ) , // PB 7 ** 13 ** PWM13
|
||||
_BV( 1 ) , // PJ 1 ** 14 ** USART3_TX
|
||||
_BV( 0 ) , // PJ 0 ** 15 ** USART3_RX
|
||||
_BV( 1 ) , // PH 1 ** 16 ** USART2_TX
|
||||
_BV( 0 ) , // PH 0 ** 17 ** USART2_RX
|
||||
_BV( 3 ) , // PD 3 ** 18 ** USART1_TX
|
||||
_BV( 2 ) , // PD 2 ** 19 ** USART1_RX
|
||||
_BV( 1 ) , // PD 1 ** 20 ** I2C_SDA
|
||||
_BV( 0 ) , // PD 0 ** 21 ** I2C_SCL
|
||||
_BV( 0 ) , // PA 0 ** 22 ** D22
|
||||
_BV( 1 ) , // PA 1 ** 23 ** D23
|
||||
_BV( 2 ) , // PA 2 ** 24 ** D24
|
||||
_BV( 3 ) , // PA 3 ** 25 ** D25
|
||||
_BV( 4 ) , // PA 4 ** 26 ** D26
|
||||
_BV( 5 ) , // PA 5 ** 27 ** D27
|
||||
_BV( 6 ) , // PA 6 ** 28 ** D28
|
||||
_BV( 7 ) , // PA 7 ** 29 ** D29
|
||||
_BV( 7 ) , // PC 7 ** 30 ** D30
|
||||
_BV( 6 ) , // PC 6 ** 31 ** D31
|
||||
_BV( 5 ) , // PC 5 ** 32 ** D32
|
||||
_BV( 4 ) , // PC 4 ** 33 ** D33
|
||||
_BV( 3 ) , // PC 3 ** 34 ** D34
|
||||
_BV( 2 ) , // PC 2 ** 35 ** D35
|
||||
_BV( 1 ) , // PC 1 ** 36 ** D36
|
||||
_BV( 0 ) , // PC 0 ** 37 ** D37
|
||||
_BV( 7 ) , // PD 7 ** 38 ** D38
|
||||
_BV( 2 ) , // PG 2 ** 39 ** D39
|
||||
_BV( 1 ) , // PG 1 ** 40 ** D40
|
||||
_BV( 0 ) , // PG 0 ** 41 ** D41
|
||||
_BV( 7 ) , // PL 7 ** 42 ** D42
|
||||
_BV( 6 ) , // PL 6 ** 43 ** D43
|
||||
_BV( 5 ) , // PL 5 ** 44 ** D44
|
||||
_BV( 4 ) , // PL 4 ** 45 ** D45
|
||||
_BV( 3 ) , // PL 3 ** 46 ** D46
|
||||
_BV( 2 ) , // PL 2 ** 47 ** D47
|
||||
_BV( 1 ) , // PL 1 ** 48 ** D48
|
||||
_BV( 0 ) , // PL 0 ** 49 ** D49
|
||||
_BV( 3 ) , // PB 3 ** 50 ** SPI_MISO
|
||||
_BV( 2 ) , // PB 2 ** 51 ** SPI_MOSI
|
||||
_BV( 1 ) , // PB 1 ** 52 ** SPI_SCK
|
||||
_BV( 0 ) , // PB 0 ** 53 ** SPI_SS
|
||||
_BV( 0 ) , // PF 0 ** 54 ** A0
|
||||
_BV( 1 ) , // PF 1 ** 55 ** A1
|
||||
_BV( 2 ) , // PF 2 ** 56 ** A2
|
||||
_BV( 3 ) , // PF 3 ** 57 ** A3
|
||||
_BV( 4 ) , // PF 4 ** 58 ** A4
|
||||
_BV( 5 ) , // PF 5 ** 59 ** A5
|
||||
_BV( 6 ) , // PF 6 ** 60 ** A6
|
||||
_BV( 7 ) , // PF 7 ** 61 ** A7
|
||||
_BV( 0 ) , // PK 0 ** 62 ** A8
|
||||
_BV( 1 ) , // PK 1 ** 63 ** A9
|
||||
_BV( 2 ) , // PK 2 ** 64 ** A10
|
||||
_BV( 3 ) , // PK 3 ** 65 ** A11
|
||||
_BV( 4 ) , // PK 4 ** 66 ** A12
|
||||
_BV( 5 ) , // PK 5 ** 67 ** A13
|
||||
_BV( 6 ) , // PK 6 ** 68 ** A14
|
||||
_BV( 7 ) , // PK 7 ** 69 ** A15
|
||||
_BV( 4 ) , // PG 4 ** 70 ** D70
|
||||
_BV( 3 ) , // PG 3 ** 71 ** D71
|
||||
_BV( 2 ) , // PJ 2 ** 72 ** D72
|
||||
_BV( 3 ) , // PJ 3 ** 73 ** D73
|
||||
_BV( 7 ) , // PJ 7 ** 74 ** D74
|
||||
_BV( 4 ) , // PJ 4 ** 75 ** D75
|
||||
_BV( 5 ) , // PJ 5 ** 76 ** D76
|
||||
_BV( 6 ) , // PJ 6 ** 77 ** D77
|
||||
_BV( 2 ) , // PE 2 ** 78 ** D78
|
||||
_BV( 6 ) , // PE 6 ** 79 ** D79
|
||||
_BV( 7 ) , // PE 7 ** 80 ** D80
|
||||
_BV( 4 ) , // PD 4 ** 81 ** D81
|
||||
_BV( 5 ) , // PD 5 ** 82 ** D82
|
||||
_BV( 6 ) , // PD 6 ** 83 ** D83
|
||||
_BV( 2 ) , // PH 2 ** 84 ** D84
|
||||
_BV( 7 ) , // PH 7 ** 85 ** D85
|
||||
};
|
||||
|
||||
const uint8_t PROGMEM digital_pin_to_timer_PGM[] = {
|
||||
// TIMERS
|
||||
// -------------------------------------------
|
||||
NOT_ON_TIMER , // PE 0 ** 0 ** USART0_RX
|
||||
NOT_ON_TIMER , // PE 1 ** 1 ** USART0_TX
|
||||
TIMER3B , // PE 4 ** 2 ** PWM2
|
||||
TIMER3C , // PE 5 ** 3 ** PWM3
|
||||
TIMER0B , // PG 5 ** 4 ** PWM4
|
||||
TIMER3A , // PE 3 ** 5 ** PWM5
|
||||
TIMER4A , // PH 3 ** 6 ** PWM6
|
||||
TIMER4B , // PH 4 ** 7 ** PWM7
|
||||
TIMER4C , // PH 5 ** 8 ** PWM8
|
||||
TIMER2B , // PH 6 ** 9 ** PWM9
|
||||
TIMER2A , // PB 4 ** 10 ** PWM10
|
||||
TIMER1A , // PB 5 ** 11 ** PWM11
|
||||
TIMER1B , // PB 6 ** 12 ** PWM12
|
||||
TIMER0A , // PB 7 ** 13 ** PWM13
|
||||
NOT_ON_TIMER , // PJ 1 ** 14 ** USART3_TX
|
||||
NOT_ON_TIMER , // PJ 0 ** 15 ** USART3_RX
|
||||
NOT_ON_TIMER , // PH 1 ** 16 ** USART2_TX
|
||||
NOT_ON_TIMER , // PH 0 ** 17 ** USART2_RX
|
||||
NOT_ON_TIMER , // PD 3 ** 18 ** USART1_TX
|
||||
NOT_ON_TIMER , // PD 2 ** 19 ** USART1_RX
|
||||
NOT_ON_TIMER , // PD 1 ** 20 ** I2C_SDA
|
||||
NOT_ON_TIMER , // PD 0 ** 21 ** I2C_SCL
|
||||
NOT_ON_TIMER , // PA 0 ** 22 ** D22
|
||||
NOT_ON_TIMER , // PA 1 ** 23 ** D23
|
||||
NOT_ON_TIMER , // PA 2 ** 24 ** D24
|
||||
NOT_ON_TIMER , // PA 3 ** 25 ** D25
|
||||
NOT_ON_TIMER , // PA 4 ** 26 ** D26
|
||||
NOT_ON_TIMER , // PA 5 ** 27 ** D27
|
||||
NOT_ON_TIMER , // PA 6 ** 28 ** D28
|
||||
NOT_ON_TIMER , // PA 7 ** 29 ** D29
|
||||
NOT_ON_TIMER , // PC 7 ** 30 ** D30
|
||||
NOT_ON_TIMER , // PC 6 ** 31 ** D31
|
||||
NOT_ON_TIMER , // PC 5 ** 32 ** D32
|
||||
NOT_ON_TIMER , // PC 4 ** 33 ** D33
|
||||
NOT_ON_TIMER , // PC 3 ** 34 ** D34
|
||||
NOT_ON_TIMER , // PC 2 ** 35 ** D35
|
||||
NOT_ON_TIMER , // PC 1 ** 36 ** D36
|
||||
NOT_ON_TIMER , // PC 0 ** 37 ** D37
|
||||
NOT_ON_TIMER , // PD 7 ** 38 ** D38
|
||||
NOT_ON_TIMER , // PG 2 ** 39 ** D39
|
||||
NOT_ON_TIMER , // PG 1 ** 40 ** D40
|
||||
NOT_ON_TIMER , // PG 0 ** 41 ** D41
|
||||
NOT_ON_TIMER , // PL 7 ** 42 ** D42
|
||||
NOT_ON_TIMER , // PL 6 ** 43 ** D43
|
||||
TIMER5C , // PL 5 ** 44 ** D44
|
||||
TIMER5B , // PL 4 ** 45 ** D45
|
||||
TIMER5A , // PL 3 ** 46 ** D46
|
||||
NOT_ON_TIMER , // PL 2 ** 47 ** D47
|
||||
NOT_ON_TIMER , // PL 1 ** 48 ** D48
|
||||
NOT_ON_TIMER , // PL 0 ** 49 ** D49
|
||||
NOT_ON_TIMER , // PB 3 ** 50 ** SPI_MISO
|
||||
NOT_ON_TIMER , // PB 2 ** 51 ** SPI_MOSI
|
||||
NOT_ON_TIMER , // PB 1 ** 52 ** SPI_SCK
|
||||
NOT_ON_TIMER , // PB 0 ** 53 ** SPI_SS
|
||||
NOT_ON_TIMER , // PF 0 ** 54 ** A0
|
||||
NOT_ON_TIMER , // PF 1 ** 55 ** A1
|
||||
NOT_ON_TIMER , // PF 2 ** 56 ** A2
|
||||
NOT_ON_TIMER , // PF 3 ** 57 ** A3
|
||||
NOT_ON_TIMER , // PF 4 ** 58 ** A4
|
||||
NOT_ON_TIMER , // PF 5 ** 59 ** A5
|
||||
NOT_ON_TIMER , // PF 6 ** 60 ** A6
|
||||
NOT_ON_TIMER , // PF 7 ** 61 ** A7
|
||||
NOT_ON_TIMER , // PK 0 ** 62 ** A8
|
||||
NOT_ON_TIMER , // PK 1 ** 63 ** A9
|
||||
NOT_ON_TIMER , // PK 2 ** 64 ** A10
|
||||
NOT_ON_TIMER , // PK 3 ** 65 ** A11
|
||||
NOT_ON_TIMER , // PK 4 ** 66 ** A12
|
||||
NOT_ON_TIMER , // PK 5 ** 67 ** A13
|
||||
NOT_ON_TIMER , // PK 6 ** 68 ** A14
|
||||
NOT_ON_TIMER , // PK 7 ** 69 ** A15
|
||||
NOT_ON_TIMER , // PG 4 ** 70 ** D70
|
||||
NOT_ON_TIMER , // PG 3 ** 71 ** D71
|
||||
NOT_ON_TIMER , // PJ 2 ** 72 ** D72
|
||||
NOT_ON_TIMER , // PJ 3 ** 73 ** D73
|
||||
NOT_ON_TIMER , // PJ 7 ** 74 ** D74
|
||||
NOT_ON_TIMER , // PJ 4 ** 75 ** D75
|
||||
NOT_ON_TIMER , // PJ 5 ** 76 ** D76
|
||||
NOT_ON_TIMER , // PJ 6 ** 77 ** D77
|
||||
NOT_ON_TIMER , // PE 2 ** 78 ** D78
|
||||
NOT_ON_TIMER , // PE 6 ** 79 ** D79
|
||||
NOT_ON_TIMER , // PE 7 ** 80 ** D80
|
||||
NOT_ON_TIMER , // PD 4 ** 81 ** D81
|
||||
NOT_ON_TIMER , // PD 5 ** 82 ** D82
|
||||
NOT_ON_TIMER , // PD 6 ** 83 ** D83
|
||||
NOT_ON_TIMER , // PH 2 ** 84 ** D84
|
||||
NOT_ON_TIMER , // PH 7 ** 85 ** D85
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
@ -0,0 +1,285 @@
|
||||
/*
|
||||
pins_arduino.h - Pin definition functions for Arduino
|
||||
Part of Arduino - http://www.arduino.cc/
|
||||
|
||||
Copyright (c) 2007 David A. Mellis
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General
|
||||
Public License along with this library; if not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
Boston, MA 02111-1307 USA
|
||||
|
||||
$Id: wiring.h 249 2007-02-03 16:52:51Z mellis $
|
||||
|
||||
Changelog
|
||||
-----------
|
||||
11/25/11 - ryan@ryanmsutton.com - Add pins for Sanguino 644P and 1284P
|
||||
07/15/12 - ryan@ryanmsutton.com - Updated for arduino0101
|
||||
*/
|
||||
|
||||
#ifndef Pins_Arduino_h
|
||||
#define Pins_Arduino_h
|
||||
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
#define NOT_A_PIN 0
|
||||
#define NOT_A_PORT 0
|
||||
|
||||
#define NOT_ON_TIMER 0
|
||||
#define TIMER0A 1
|
||||
#define TIMER0B 2
|
||||
#define TIMER1A 3
|
||||
#define TIMER1B 4
|
||||
#define TIMER2 5
|
||||
#define TIMER2A 6
|
||||
#define TIMER2B 7
|
||||
|
||||
#define TIMER3A 8
|
||||
#define TIMER3B 9
|
||||
#define TIMER3C 10
|
||||
#define TIMER4A 11
|
||||
#define TIMER4B 12
|
||||
#define TIMER4C 13
|
||||
#define TIMER5A 14
|
||||
#define TIMER5B 15
|
||||
#define TIMER5C 16
|
||||
|
||||
const static uint8_t SS = 4;
|
||||
const static uint8_t MOSI = 5;
|
||||
const static uint8_t MISO = 6;
|
||||
const static uint8_t SCK = 7;
|
||||
|
||||
static const uint8_t SDA = 17;
|
||||
static const uint8_t SCL = 16;
|
||||
static const uint8_t LED_BUILTIN = 13;
|
||||
|
||||
static const uint8_t A0 = 31;
|
||||
static const uint8_t A1 = 30;
|
||||
static const uint8_t A2 = 29;
|
||||
static const uint8_t A3 = 28;
|
||||
static const uint8_t A4 = 27;
|
||||
static const uint8_t A5 = 26;
|
||||
static const uint8_t A6 = 25;
|
||||
static const uint8_t A7 = 24;
|
||||
|
||||
// On the ATmega1280, the addresses of some of the port registers are
|
||||
// greater than 255, so we can't store them in uint8_t's.
|
||||
// extern const uint16_t PROGMEM port_to_mode_PGM[];
|
||||
// extern const uint16_t PROGMEM port_to_input_PGM[];
|
||||
// extern const uint16_t PROGMEM port_to_output_PGM[];
|
||||
|
||||
// extern const uint8_t PROGMEM digital_pin_to_port_PGM[];
|
||||
// extern const uint8_t PROGMEM digital_pin_to_bit_PGM[];
|
||||
// extern const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[];
|
||||
// extern const uint8_t PROGMEM digital_pin_to_timer_PGM[];
|
||||
|
||||
// ATMEL ATMEGA644P / SANGUINO
|
||||
//
|
||||
// +---\/---+
|
||||
// INT0 (D 0) PB0 1| |40 PA0 (AI 0 / D31)
|
||||
// INT1 (D 1) PB1 2| |39 PA1 (AI 1 / D30)
|
||||
// INT2 (D 2) PB2 3| |38 PA2 (AI 2 / D29)
|
||||
// PWM (D 3) PB3 4| |37 PA3 (AI 3 / D28)
|
||||
// PWM (D 4) PB4 5| |36 PA4 (AI 4 / D27)
|
||||
// MOSI (D 5) PB5 6| |35 PA5 (AI 5 / D26)
|
||||
// MISO (D 6) PB6 7| |34 PA6 (AI 6 / D25)
|
||||
// SCK (D 7) PB7 8| |33 PA7 (AI 7 / D24)
|
||||
// RST 9| |32 AREF
|
||||
// VCC 10| |31 GND
|
||||
// GND 11| |30 AVCC
|
||||
// XTAL2 12| |29 PC7 (D 23)
|
||||
// XTAL1 13| |28 PC6 (D 22)
|
||||
// RX0 (D 8) PD0 14| |27 PC5 (D 21) TDI
|
||||
// TX0 (D 9) PD1 15| |26 PC4 (D 20) TDO
|
||||
// RX1 (D 10) PD2 16| |25 PC3 (D 19) TMS
|
||||
// TX1 (D 11) PD3 17| |24 PC2 (D 18) TCK
|
||||
// PWM (D 12) PD4 18| |23 PC1 (D 17) SDA
|
||||
// PWM (D 13) PD5 19| |22 PC0 (D 16) SCL
|
||||
// PWM (D 14) PD6 20| |21 PD7 (D 15) PWM
|
||||
// +--------+
|
||||
//
|
||||
#define NUM_DIGITAL_PINS 24
|
||||
#define NUM_ANALOG_INPUTS 8
|
||||
#define analogInputToDigitalPin(p) ((p < 7) ? (p) + 24 : -1)
|
||||
|
||||
#define digitalPinHasPWM(p) ((p) == 3 || (p) == 4 || (p) == 12 || (p) == 13 || (p) == 14 || (p) == 15 )
|
||||
|
||||
#define digitalPinToPCICR(p) ( (((p) >= 0) && ((p) <= 31)) ? (&PCICR) : ((uint8_t *)0) )
|
||||
|
||||
#define digitalPinToPCICRbit(p) ( (((p) >= 24) && ((p) <= 31)) ? 0 : \
|
||||
( (((p) >= 0) && ((p) <= 7)) ? 1 : \
|
||||
( (((p) >= 16) && ((p) <= 23)) ? 2 : \
|
||||
( (((p) >= 8) && ((p) <= 15)) ? 3 : \
|
||||
0 ) ) ) )
|
||||
|
||||
#define digitalPinToPCMSK(p) ( (((p) >= 24) && ((p) <= 31)) ? (&PCMSK0) : \
|
||||
( (((p) >= 0) && ((p) <= 7)) ? (&PCMSK1) : \
|
||||
( (((p) >= 16) && ((p) <= 23)) ? (&PCMSK2) : \
|
||||
( (((p) >= 8) && ((p) <= 15)) ? (&PCMSK3) : \
|
||||
((uint8_t *)0) ) ) ) )
|
||||
|
||||
|
||||
#define digitalPinToPCMSKbit(p) ( (((p) >= 24) && ((p) <= 31)) ? (31 - (p)) : \
|
||||
( (((p) >= 0) && ((p) <= 7)) ? (p) : \
|
||||
( (((p) >= 16) && ((p) <= 23)) ? ((p) - 16) : \
|
||||
( (((p) >= 8) && ((p) <= 15)) ? ((p) - 8) : \
|
||||
0 ) ) ) )
|
||||
|
||||
#define PA 1
|
||||
#define PB 2
|
||||
#define PC 3
|
||||
#define PD 4
|
||||
#define PE 5
|
||||
#define PF 6
|
||||
#define PG 7
|
||||
#define PH 8
|
||||
#define PJ 10
|
||||
#define PK 11
|
||||
#define PL 12
|
||||
|
||||
#ifdef ARDUINO_MAIN
|
||||
// these arrays map port names (e.g. port B) to the
|
||||
// appropriate addresses for various functions (e.g. reading
|
||||
// and writing)
|
||||
const uint16_t PROGMEM port_to_mode_PGM[] =
|
||||
{
|
||||
NOT_A_PORT,
|
||||
(uint16_t) &DDRA,
|
||||
(uint16_t) &DDRB,
|
||||
(uint16_t) &DDRC,
|
||||
(uint16_t) &DDRD,
|
||||
};
|
||||
|
||||
const uint16_t PROGMEM port_to_output_PGM[] =
|
||||
{
|
||||
NOT_A_PORT,
|
||||
(uint16_t) &PORTA,
|
||||
(uint16_t) &PORTB,
|
||||
(uint16_t) &PORTC,
|
||||
(uint16_t) &PORTD,
|
||||
};
|
||||
const uint16_t PROGMEM port_to_input_PGM[] =
|
||||
{
|
||||
NOT_A_PORT,
|
||||
(uint16_t) &PINA,
|
||||
(uint16_t) &PINB,
|
||||
(uint16_t) &PINC,
|
||||
(uint16_t) &PIND,
|
||||
};
|
||||
const uint8_t PROGMEM digital_pin_to_port_PGM[] =
|
||||
{
|
||||
PB, /* 0 */
|
||||
PB,
|
||||
PB,
|
||||
PB,
|
||||
PB,
|
||||
PB,
|
||||
PB,
|
||||
PB,
|
||||
PD, /* 8 */
|
||||
PD,
|
||||
PD,
|
||||
PD,
|
||||
PD,
|
||||
PD,
|
||||
PD,
|
||||
PD,
|
||||
PC, /* 16 */
|
||||
PC,
|
||||
PC,
|
||||
PC,
|
||||
PC,
|
||||
PC,
|
||||
PC,
|
||||
PC,
|
||||
PA, /* 24 */
|
||||
PA,
|
||||
PA,
|
||||
PA,
|
||||
PA,
|
||||
PA,
|
||||
PA,
|
||||
PA /* 31 */
|
||||
};
|
||||
const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] =
|
||||
{
|
||||
_BV(0), /* 0, port B */
|
||||
_BV(1),
|
||||
_BV(2),
|
||||
_BV(3),
|
||||
_BV(4),
|
||||
_BV(5),
|
||||
_BV(6),
|
||||
_BV(7),
|
||||
_BV(0), /* 8, port D */
|
||||
_BV(1),
|
||||
_BV(2),
|
||||
_BV(3),
|
||||
_BV(4),
|
||||
_BV(5),
|
||||
_BV(6),
|
||||
_BV(7),
|
||||
_BV(0), /* 16, port C */
|
||||
_BV(1),
|
||||
_BV(2),
|
||||
_BV(3),
|
||||
_BV(4),
|
||||
_BV(5),
|
||||
_BV(6),
|
||||
_BV(7),
|
||||
_BV(7), /* 24, port A */
|
||||
_BV(6),
|
||||
_BV(5),
|
||||
_BV(4),
|
||||
_BV(3),
|
||||
_BV(2),
|
||||
_BV(1),
|
||||
_BV(0)
|
||||
};
|
||||
const uint8_t PROGMEM digital_pin_to_timer_PGM[] =
|
||||
{
|
||||
NOT_ON_TIMER, /* 0 - PB0 */
|
||||
NOT_ON_TIMER, /* 1 - PB1 */
|
||||
NOT_ON_TIMER, /* 2 - PB2 */
|
||||
TIMER0A, /* 3 - PB3 */
|
||||
TIMER0B, /* 4 - PB4 */
|
||||
NOT_ON_TIMER, /* 5 - PB5 */
|
||||
NOT_ON_TIMER, /* 6 - PB6 */
|
||||
NOT_ON_TIMER, /* 7 - PB7 */
|
||||
NOT_ON_TIMER, /* 8 - PD0 */
|
||||
NOT_ON_TIMER, /* 9 - PD1 */
|
||||
NOT_ON_TIMER, /* 10 - PD2 */
|
||||
NOT_ON_TIMER, /* 11 - PD3 */
|
||||
TIMER1B, /* 12 - PD4 */
|
||||
TIMER1A, /* 13 - PD5 */
|
||||
TIMER2B, /* 14 - PD6 */
|
||||
TIMER2A, /* 15 - PD7 */
|
||||
NOT_ON_TIMER, /* 16 - PC0 */
|
||||
NOT_ON_TIMER, /* 17 - PC1 */
|
||||
NOT_ON_TIMER, /* 18 - PC2 */
|
||||
NOT_ON_TIMER, /* 19 - PC3 */
|
||||
NOT_ON_TIMER, /* 20 - PC4 */
|
||||
NOT_ON_TIMER, /* 21 - PC5 */
|
||||
NOT_ON_TIMER, /* 22 - PC6 */
|
||||
NOT_ON_TIMER, /* 23 - PC7 */
|
||||
NOT_ON_TIMER, /* 24 - PA0 */
|
||||
NOT_ON_TIMER, /* 25 - PA1 */
|
||||
NOT_ON_TIMER, /* 26 - PA2 */
|
||||
NOT_ON_TIMER, /* 27 - PA3 */
|
||||
NOT_ON_TIMER, /* 28 - PA4 */
|
||||
NOT_ON_TIMER, /* 29 - PA5 */
|
||||
NOT_ON_TIMER, /* 30 - PA6 */
|
||||
NOT_ON_TIMER /* 31 - PA7 */
|
||||
};
|
||||
#endif
|
||||
#endif
|
Loading…
Reference in new issue