Some library files got lost.
This commit is contained in:
95
Micropendous/libs/arduino/libraries/Ethernet/utility/spi.h
Normal file
95
Micropendous/libs/arduino/libraries/Ethernet/utility/spi.h
Normal file
@@ -0,0 +1,95 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
//AVR Mega168 SPI HAL
|
||||
#define BIT0 0x01
|
||||
#define BIT1 0x02
|
||||
#define BIT2 0x04
|
||||
#define BIT3 0x08
|
||||
#define BIT4 0x10
|
||||
#define BIT5 0x20
|
||||
#define BIT6 0x40
|
||||
#define BIT7 0x80
|
||||
|
||||
#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328__) || defined(__AVR_ATmega8__) || defined(__AVR_ATmega328P__)
|
||||
// Arduino
|
||||
#define SPI0_SS_BIT BIT2
|
||||
#define SPI0_SS_DDR DDRB
|
||||
#define SPI0_SS_PORT PORTB
|
||||
|
||||
#define SPI0_SCLK_BIT BIT5
|
||||
#define SPI0_SCLK_DDR DDRB
|
||||
#define SPI0_SCLK_PORT PORTB
|
||||
|
||||
#define SPI0_MOSI_BIT BIT3
|
||||
#define SPI0_MOSI_DDR DDRB
|
||||
#define SPI0_MOSI_PORT PORTB
|
||||
|
||||
#define SPI0_MISO_BIT BIT4
|
||||
#define SPI0_MISO_DDR DDRB
|
||||
#define SPI0_MISO_PORT PORTB
|
||||
#elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__)
|
||||
// Sanguino
|
||||
#define SPI0_SS_BIT BIT4
|
||||
#define SPI0_SS_DDR DDRB
|
||||
#define SPI0_SS_PORT PORTB
|
||||
|
||||
#define SPI0_SCLK_BIT BIT7
|
||||
#define SPI0_SCLK_DDR DDRB
|
||||
#define SPI0_SCLK_PORT PORTB
|
||||
|
||||
#define SPI0_MOSI_BIT BIT5
|
||||
#define SPI0_MOSI_DDR DDRB
|
||||
#define SPI0_MOSI_PORT PORTB
|
||||
|
||||
#define SPI0_MISO_BIT BIT6
|
||||
#define SPI0_MISO_DDR DDRB
|
||||
#define SPI0_MISO_PORT PORTB
|
||||
#elif defined(__AVR_AT90USB162__) || defined(__AVR_ATmega32U4__) || defined(__AVR_AT90USB646__) || defined(__AVR_ATmega32U6__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB647__) || defined(__AVR_ATmega1280__)
|
||||
// Arduino Mega and USB AVRs
|
||||
#define SPI0_SS_BIT BIT0
|
||||
#define SPI0_SS_DDR DDRB
|
||||
#define SPI0_SS_PORT PORTB
|
||||
|
||||
#define SPI0_SCLK_BIT BIT1
|
||||
#define SPI0_SCLK_DDR DDRB
|
||||
#define SPI0_SCLK_PORT PORTB
|
||||
|
||||
#define SPI0_MOSI_BIT BIT2
|
||||
#define SPI0_MOSI_DDR DDRB
|
||||
#define SPI0_MOSI_PORT PORTB
|
||||
|
||||
#define SPI0_MISO_BIT BIT3
|
||||
#define SPI0_MISO_DDR DDRB
|
||||
#define SPI0_MISO_PORT PORTB
|
||||
#else
|
||||
#error "Unknown chip, please edit me with SPI0 pin definitions"
|
||||
#endif
|
||||
|
||||
#define SPI0_WaitForReceive()
|
||||
#define SPI0_RxData() (SPDR)
|
||||
|
||||
#define SPI0_TxData(Data) (SPDR = Data)
|
||||
#define SPI0_WaitForSend() while( (SPSR & 0x80)==0x00 )
|
||||
|
||||
#define SPI0_SendByte(Data) SPI0_TxData(Data);SPI0_WaitForSend()
|
||||
#define SPI0_RecvBute() SPI0_RxData()
|
||||
|
||||
// PB4(MISO), PB3(MOSI), PB5(SCK), PB2(/SS) // CS=1, waiting for SPI start // SPI mode 0, 4MHz
|
||||
#define SPI0_Init() DDRB |= SPI0_SS_BIT|SPI0_SCLK_BIT|SPI0_MOSI_BIT;\
|
||||
PORTB |= SPI0_SS_BIT; PORTB &= ~(SPI0_SCLK_BIT|SPI0_MOSI_BIT);\
|
||||
SPCR = 0x50
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//IInChip SPI HAL
|
||||
#define IINCHIP_SpiInit SPI0_Init
|
||||
#define IINCHIP_SpiSendData SPI0_SendByte
|
||||
#define IINCHIP_SpiRecvData SPI0_RxData
|
||||
|
||||
#define IINCHIP_CS_BIT SPI0_SS_BIT
|
||||
#define IINCHIP_CS_DDR SPI0_SS_DDR
|
||||
#define IINCHIP_CS_PORT SPI0_SS_PORT
|
||||
|
||||
#define IINCHIP_CSInit() (IINCHIP_CS_DDR |= IINCHIP_CS_BIT)
|
||||
#define IINCHIP_CSon() (IINCHIP_CS_PORT |= IINCHIP_CS_BIT)
|
||||
#define IINCHIP_CSoff() (IINCHIP_CS_PORT &= ~IINCHIP_CS_BIT)
|
||||
//-----------------------------------------------------------------------------
|
||||
165
Micropendous/libs/arduino/libraries/Ethernet/utility/types.h
Normal file
165
Micropendous/libs/arduino/libraries/Ethernet/utility/types.h
Normal file
@@ -0,0 +1,165 @@
|
||||
/*
|
||||
*
|
||||
@file type.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _TYPE_H_
|
||||
#define _TYPE_H_
|
||||
|
||||
|
||||
/***************************************************
|
||||
* attribute for mcu ( types, ... )
|
||||
***************************************************/
|
||||
//#include "mcu_define.h"
|
||||
#define __MCU_AVR__ 1
|
||||
#define __MCU_TYPE__ __MCU_AVR__
|
||||
|
||||
//---- Refer "Rom File Maker Manual Vx.x.pdf"
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
#define _ENDIAN_LITTLE_ 0 /**< This must be defined if system is little-endian alignment */
|
||||
#define _ENDIAN_BIG_ 1
|
||||
#define SYSTEM_ENDIAN _ENDIAN_LITTLE_
|
||||
|
||||
#define MAX_SOCK_NUM 4 /**< Maxmium number of socket */
|
||||
#define CLK_CPU F_CPU /**< 8Mhz(for serial) */
|
||||
|
||||
/* ## __DEF_IINCHIP_xxx__ : define option for iinchip driver *****************/
|
||||
//#define __DEF_IINCHIP_DBG__ /* involve debug code in driver (socket.c) */
|
||||
//#define __DEF_IINCHIP_INT__ /**< involve interrupt service routine (socket.c) */
|
||||
//#define __DEF_IINCHIP_PPP__ /* involve pppoe routine (socket.c) */
|
||||
/* If it is defined, the source files(md5.h,md5.c) must be included in your project.
|
||||
Otherwize, the source files must be removed in your project. */
|
||||
|
||||
#define __DEF_IINCHIP_DIRECT_MODE__ 1
|
||||
#define __DEF_IINCHIP_INDIRECT_MODE__ 2
|
||||
#define __DEF_IINCHIP_SPI_MODE__ 3
|
||||
|
||||
//#define __DEF_IINCHIP_BUS__ __DEF_IINCHIP_DIRECT_MODE__
|
||||
//#define __DEF_IINCHIP_BUS__ __DEF_IINCHIP_INDIRECT_MODE__
|
||||
#define __DEF_IINCHIP_BUS__ __DEF_IINCHIP_SPI_MODE__ /*Enable SPI_mode*/
|
||||
|
||||
|
||||
/**
|
||||
@brief __DEF_IINCHIP_MAP_xxx__ : define memory map for iinchip
|
||||
*/
|
||||
#define __DEF_IINCHIP_MAP_BASE__ 0x8000
|
||||
#if (__DEF_IINCHIP_BUS__ == __DEF_IINCHIP_DIRECT_MODE__)
|
||||
#define COMMON_BASE __DEF_IINCHIP_MAP_BASE__
|
||||
#else
|
||||
#define COMMON_BASE 0x0000
|
||||
#endif
|
||||
#define __DEF_IINCHIP_MAP_TXBUF__ (COMMON_BASE + 0x4000) /* Internal Tx buffer address of the iinchip */
|
||||
#define __DEF_IINCHIP_MAP_RXBUF__ (COMMON_BASE + 0x6000) /* Internal Rx buffer address of the iinchip */
|
||||
|
||||
|
||||
#if (__MCU_TYPE__ == __MCU_AVR__)
|
||||
#ifdef __DEF_IINCHIP_INT__
|
||||
// iinchip use external interrupt 4
|
||||
#define IINCHIP_ISR_DISABLE() (EIMSK &= ~(0x10))
|
||||
#define IINCHIP_ISR_ENABLE() (EIMSK |= 0x10)
|
||||
#define IINCHIP_ISR_GET(X) (X = EIMSK)
|
||||
#define IINCHIP_ISR_SET(X) (EIMSK = X)
|
||||
#else
|
||||
#define IINCHIP_ISR_DISABLE()
|
||||
#define IINCHIP_ISR_ENABLE()
|
||||
#define IINCHIP_ISR_GET(X)
|
||||
#define IINCHIP_ISR_SET(X)
|
||||
#endif
|
||||
#else
|
||||
#error "unknown MCU type"
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL ((void *) 0)
|
||||
#endif
|
||||
|
||||
//typedef enum { false, true } bool;
|
||||
|
||||
#ifndef _SIZE_T
|
||||
#define _SIZE_T
|
||||
typedef unsigned int size_t;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The 8-bit signed data type.
|
||||
*/
|
||||
typedef char int8;
|
||||
/**
|
||||
* The volatile 8-bit signed data type.
|
||||
*/
|
||||
typedef volatile char vint8;
|
||||
/**
|
||||
* The 8-bit unsigned data type.
|
||||
*/
|
||||
typedef unsigned char uint8;
|
||||
/**
|
||||
* The volatile 8-bit unsigned data type.
|
||||
*/
|
||||
typedef volatile unsigned char vuint8;
|
||||
|
||||
/**
|
||||
* The 16-bit signed data type.
|
||||
*/
|
||||
typedef int int16;
|
||||
/**
|
||||
* The volatile 16-bit signed data type.
|
||||
*/
|
||||
typedef volatile int vint16;
|
||||
/**
|
||||
* The 16-bit unsigned data type.
|
||||
*/
|
||||
typedef unsigned int uint16;
|
||||
/**
|
||||
* The volatile 16-bit unsigned data type.
|
||||
*/
|
||||
typedef volatile unsigned int vuint16;
|
||||
/**
|
||||
* The 32-bit signed data type.
|
||||
*/
|
||||
typedef long int32;
|
||||
/**
|
||||
* The volatile 32-bit signed data type.
|
||||
*/
|
||||
typedef volatile long vint32;
|
||||
/**
|
||||
* The 32-bit unsigned data type.
|
||||
*/
|
||||
typedef unsigned long uint32;
|
||||
/**
|
||||
* The volatile 32-bit unsigned data type.
|
||||
*/
|
||||
typedef volatile unsigned long vuint32;
|
||||
|
||||
/* bsd */
|
||||
typedef uint8 u_char; /**< 8-bit value */
|
||||
typedef uint8 SOCKET;
|
||||
typedef uint16 u_short; /**< 16-bit value */
|
||||
typedef uint16 u_int; /**< 16-bit value */
|
||||
typedef uint32 u_long; /**< 32-bit value */
|
||||
|
||||
typedef union _un_l2cval {
|
||||
u_long lVal;
|
||||
u_char cVal[4];
|
||||
}un_l2cval;
|
||||
|
||||
typedef union _un_i2cval {
|
||||
u_int iVal;
|
||||
u_char cVal[2];
|
||||
}un_i2cval;
|
||||
|
||||
|
||||
/** global define */
|
||||
#define FW_VERSION 0x01010000 /* System F/W Version : 1.1.0.0 */
|
||||
#define HW_VERSION 0x01000000
|
||||
|
||||
|
||||
#define TX_RX_MAX_BUF_SIZE 2048
|
||||
#define TX_BUF 0x1100
|
||||
#define RX_BUF (TX_BUF+TX_RX_MAX_BUF_SIZE)
|
||||
|
||||
#define UART_DEVICE_CNT 1 /**< UART device number */
|
||||
/* #define SUPPORT_UART_ONE */
|
||||
|
||||
#endif /* _TYPE_H_ */
|
||||
1302
Micropendous/libs/arduino/libraries/Ethernet/utility/w5100.c
Normal file
1302
Micropendous/libs/arduino/libraries/Ethernet/utility/w5100.c
Normal file
File diff suppressed because it is too large
Load Diff
64
Micropendous/libs/arduino/libraries/ks0108/ArduinoIcon.h
Normal file
64
Micropendous/libs/arduino/libraries/ks0108/ArduinoIcon.h
Normal file
@@ -0,0 +1,64 @@
|
||||
/* ArduinoIcon.h bitmap file for GLCD library */
|
||||
/* Bitmap created from ArduinoIcon.bmp */
|
||||
/* Date: 2 Jul 2009 */
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
#ifndef ArduinoIcon_H
|
||||
#define ArduinoIcon_H
|
||||
|
||||
static uint8_t ArduinoIcon[] PROGMEM = {
|
||||
64, // width
|
||||
64, // height
|
||||
|
||||
/* page 0 (lines 0-7) */
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80,0x40,0x20,0x20,0x20,0x20,0x20,0x40,
|
||||
0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc0,0xe0,0xe0,0xe0,
|
||||
0xc0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
|
||||
/* page 1 (lines 8-15) */
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x1c,0x63,0x80,0x0,0x0,0x7f,0x3e,0x1c,0x8,0x0,
|
||||
0x80,0x63,0x1c,0x0,0x0,0x0,0x0,0x0,0x0,0xc0,0xf8,0xff,0xff,0x7f,0xf,0x7f,
|
||||
0xff,0xff,0xf8,0xc0,0x0,0x0,0x0,0x0,0x0,0x80,0x40,0x20,0x3f,0x20,0x40,0x80,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
|
||||
/* page 2 (lines 16-23) */
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc0,0x20,0x11,0x8a,0x8a,0x8a,0x8a,0x8a,0x11,
|
||||
0x20,0xc0,0x0,0x0,0x0,0x0,0x80,0xf0,0xfe,0xff,0xff,0xff,0xe3,0xe0,0xe0,0xe0,
|
||||
0xe3,0xff,0xff,0xff,0xfe,0xf0,0x80,0x0,0x0,0x81,0x42,0x24,0x24,0x24,0x42,0x85,
|
||||
0x28,0x20,0x38,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
|
||||
/* page 3 (lines 24-31) */
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x7,0x18,0x20,0x40,0x8f,0x88,0x88,0x88,0x8f,0x40,
|
||||
0x20,0x18,0x7,0x0,0x60,0xfc,0xff,0xff,0xbf,0x7,0x1,0x1,0x1,0x1,0x1,0x1,
|
||||
0x1,0x81,0x1,0x7,0x3f,0xff,0xff,0xfc,0x60,0x1,0x2,0x4,0xfc,0x24,0x22,0x21,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
|
||||
/* page 4 (lines 32-39) */
|
||||
0xc0,0x40,0x40,0x40,0x40,0x70,0xc,0x30,0xc0,0x0,0xc0,0x30,0xd,0x31,0xc0,0x0,
|
||||
0xc0,0x30,0x8,0x8,0x88,0x49,0x28,0x29,0x38,0x20,0x20,0x40,0x80,0x40,0x20,0x10,
|
||||
0x20,0x98,0x18,0xc0,0xc1,0x0,0x0,0x0,0x20,0x30,0x50,0x48,0x8f,0x80,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
|
||||
/* page 5 (lines 40-47) */
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3,0x0,0x0,0x0,0x0,0x0,0x1,
|
||||
0x0,0x0,0x1c,0x63,0x80,0x46,0x4a,0x52,0x62,0x52,0x4a,0x46,0x80,0x63,0x1c,0x2,
|
||||
0x1,0x10,0x11,0x0,0x0,0x0,0x0,0x0,0x8,0x8,0x14,0x14,0xa2,0xa2,0x41,0x41,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
|
||||
/* page 6 (lines 48-55) */
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x1,0x2,0x2,0xfe,0x2,0x2,0x1,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2,0x2,0x5,0xfd,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
|
||||
/* page 7 (lines 56-63) */
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x2,0xa,0xa,0x2b,0xa,0xa,0x2,0x0,0x0,0x0,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2,0x2,0xa,0x2b,0xa,0x2,0x2,0x0,
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0
|
||||
|
||||
};
|
||||
#endif
|
||||
166
Micropendous/libs/arduino/libraries/ks0108/Arial14.h
Normal file
166
Micropendous/libs/arduino/libraries/ks0108/Arial14.h
Normal file
@@ -0,0 +1,166 @@
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Arial_14
|
||||
*
|
||||
* created with FontCreator
|
||||
* written by F. Maximilian Thiele
|
||||
*
|
||||
* http://www.apetech.de/fontCreator
|
||||
* me@apetech.de
|
||||
*
|
||||
* File Name : Arial14.h
|
||||
* Date : 02.05.2008
|
||||
* Font size in bytes : 7788
|
||||
* Font width : 10
|
||||
* Font height : 14
|
||||
* Font first char : 32
|
||||
* Font last char : 128
|
||||
* Font used chars : 96
|
||||
*
|
||||
* The font data are defined as
|
||||
*
|
||||
* struct _FONT_ {
|
||||
* uint16_t font_Size_in_Bytes_over_all_included_Size_it_self;
|
||||
* uint8_t font_Width_in_Pixel_for_fixed_drawing;
|
||||
* uint8_t font_Height_in_Pixel_for_all_characters;
|
||||
* unit8_t font_First_Char;
|
||||
* uint8_t font_Char_Count;
|
||||
*
|
||||
* uint8_t font_Char_Widths[font_Last_Char - font_First_Char +1];
|
||||
* // for each character the separate width in pixels,
|
||||
* // characters < 128 have an implicit virtual right empty row
|
||||
*
|
||||
* uint8_t font_data[];
|
||||
* // bit field of all characters
|
||||
*/
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
#ifndef ARIAL_14_H
|
||||
#define ARIAL_14_H
|
||||
|
||||
#define ARIAL_14_WIDTH 10
|
||||
#define ARIAL_14_HEIGHT 14
|
||||
|
||||
static uint8_t Arial_14[] PROGMEM = {
|
||||
0x1E, 0x6C, // size
|
||||
0x0A, // width
|
||||
0x0E, // height
|
||||
0x20, // first char
|
||||
0x60, // char count
|
||||
|
||||
// char widths
|
||||
0x00, 0x01, 0x03, 0x08, 0x07, 0x0A, 0x08, 0x01, 0x03, 0x03,
|
||||
0x05, 0x07, 0x01, 0x04, 0x01, 0x04, 0x06, 0x03, 0x06, 0x06,
|
||||
0x07, 0x06, 0x06, 0x06, 0x06, 0x06, 0x01, 0x01, 0x06, 0x06,
|
||||
0x06, 0x06, 0x0D, 0x09, 0x07, 0x08, 0x08, 0x07, 0x07, 0x09,
|
||||
0x07, 0x01, 0x05, 0x08, 0x07, 0x09, 0x07, 0x09, 0x07, 0x09,
|
||||
0x08, 0x07, 0x07, 0x07, 0x09, 0x0D, 0x08, 0x09, 0x08, 0x02,
|
||||
0x04, 0x02, 0x05, 0x08, 0x02, 0x06, 0x06, 0x05, 0x06, 0x06,
|
||||
0x04, 0x06, 0x06, 0x01, 0x02, 0x06, 0x01, 0x09, 0x06, 0x06,
|
||||
0x06, 0x06, 0x04, 0x05, 0x04, 0x06, 0x07, 0x09, 0x06, 0x07,
|
||||
0x06, 0x03, 0x01, 0x03, 0x07, 0x07,
|
||||
|
||||
// font data
|
||||
0xFE, 0x14, // 33
|
||||
0x1E, 0x00, 0x1E, 0x00, 0x00, 0x00, // 34
|
||||
0x90, 0x90, 0xF8, 0x96, 0x90, 0xF8, 0x96, 0x90, 0x00, 0x1C, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, // 35
|
||||
0x18, 0x24, 0x22, 0xFF, 0x42, 0x42, 0x84, 0x08, 0x10, 0x10, 0x3C, 0x10, 0x08, 0x04, // 36
|
||||
0x1C, 0x22, 0x22, 0x1C, 0xC0, 0x30, 0x8C, 0x42, 0x40, 0x80, 0x00, 0x00, 0x10, 0x0C, 0x00, 0x00, 0x0C, 0x10, 0x10, 0x0C, // 37
|
||||
0x80, 0x5C, 0x22, 0x62, 0x92, 0x0C, 0x80, 0x00, 0x0C, 0x10, 0x10, 0x10, 0x10, 0x0C, 0x08, 0x10, // 38
|
||||
0x1E, 0x00, // 39
|
||||
0xF0, 0x0C, 0x02, 0x1C, 0x60, 0x80, // 40
|
||||
0x02, 0x0C, 0xF0, 0x80, 0x60, 0x1C, // 41
|
||||
0x04, 0x14, 0x0E, 0x14, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, // 42
|
||||
0x40, 0x40, 0x40, 0xF8, 0x40, 0x40, 0x40, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, // 43
|
||||
0x00, 0x70, // 44
|
||||
0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, // 45
|
||||
0x00, 0x10, // 46
|
||||
0x00, 0xC0, 0x38, 0x06, 0x18, 0x04, 0x00, 0x00, // 47
|
||||
0xFC, 0x02, 0x02, 0x02, 0x02, 0xFC, 0x0C, 0x10, 0x10, 0x10, 0x10, 0x0C, // 48
|
||||
0x08, 0x04, 0xFE, 0x00, 0x00, 0x1C, // 49
|
||||
0x0C, 0x02, 0x02, 0x82, 0x42, 0x3C, 0x10, 0x18, 0x14, 0x10, 0x10, 0x10, // 50
|
||||
0x0C, 0x02, 0x22, 0x22, 0x22, 0xDC, 0x0C, 0x10, 0x10, 0x10, 0x10, 0x0C, // 51
|
||||
0x80, 0x40, 0x30, 0x08, 0x04, 0xFE, 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x1C, 0x04, // 52
|
||||
0x38, 0x16, 0x12, 0x12, 0x12, 0xE2, 0x0C, 0x10, 0x10, 0x10, 0x18, 0x04, // 53
|
||||
0xF8, 0x44, 0x22, 0x22, 0x22, 0xC4, 0x0C, 0x10, 0x10, 0x10, 0x10, 0x0C, // 54
|
||||
0x02, 0x02, 0x02, 0xE2, 0x1A, 0x06, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, // 55
|
||||
0xDC, 0x22, 0x22, 0x22, 0x22, 0xDC, 0x0C, 0x10, 0x10, 0x10, 0x10, 0x0C, // 56
|
||||
0x3C, 0x42, 0x42, 0x42, 0x22, 0xFC, 0x08, 0x10, 0x10, 0x10, 0x08, 0x04, // 57
|
||||
0x08, 0x10, // 58
|
||||
0x08, 0x70, // 59
|
||||
0x40, 0xA0, 0xA0, 0x10, 0x10, 0x08, 0x00, 0x00, 0x00, 0x04, 0x04, 0x08, // 60
|
||||
0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 61
|
||||
0x08, 0x10, 0x10, 0xA0, 0xA0, 0x40, 0x08, 0x04, 0x04, 0x00, 0x00, 0x00, // 62
|
||||
0x0C, 0x02, 0x82, 0x42, 0x22, 0x1C, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, // 63
|
||||
0xE0, 0x18, 0x04, 0xC4, 0x22, 0x12, 0x12, 0x12, 0xA2, 0x72, 0x04, 0x08, 0xF0, 0x0C, 0x30, 0x40, 0x4C, 0x90, 0x90, 0x90, 0x88, 0x9C, 0x90, 0x50, 0x4C, 0x20, // 64
|
||||
0x00, 0x80, 0xE0, 0x9C, 0x82, 0x9C, 0xE0, 0x80, 0x00, 0x18, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x18, // 65
|
||||
0xFE, 0x22, 0x22, 0x22, 0x22, 0x22, 0xDC, 0x1C, 0x10, 0x10, 0x10, 0x10, 0x10, 0x0C, // 66
|
||||
0xF8, 0x04, 0x02, 0x02, 0x02, 0x02, 0x04, 0x08, 0x04, 0x08, 0x10, 0x10, 0x10, 0x10, 0x08, 0x04, // 67
|
||||
0xFE, 0x02, 0x02, 0x02, 0x02, 0x02, 0x04, 0xF8, 0x1C, 0x10, 0x10, 0x10, 0x10, 0x10, 0x08, 0x04, // 68
|
||||
0xFE, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x1C, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, // 69
|
||||
0xFE, 0x22, 0x22, 0x22, 0x22, 0x22, 0x02, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 70
|
||||
0xF8, 0x04, 0x02, 0x02, 0x02, 0x42, 0x42, 0x44, 0xC8, 0x04, 0x08, 0x10, 0x10, 0x10, 0x10, 0x10, 0x08, 0x04, // 71
|
||||
0xFE, 0x20, 0x20, 0x20, 0x20, 0x20, 0xFE, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, // 72
|
||||
0xFE, 0x1C, // 73
|
||||
0x00, 0x00, 0x00, 0x00, 0xFE, 0x0C, 0x10, 0x10, 0x10, 0x0C, // 74
|
||||
0xFE, 0x80, 0x40, 0x20, 0x50, 0x88, 0x04, 0x02, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x04, 0x08, 0x10, // 75
|
||||
0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, // 76
|
||||
0xFE, 0x0C, 0x30, 0xC0, 0x00, 0xC0, 0x30, 0x0C, 0xFE, 0x1C, 0x00, 0x00, 0x04, 0x18, 0x04, 0x00, 0x00, 0x1C, // 77
|
||||
0xFE, 0x04, 0x18, 0x60, 0x80, 0x00, 0xFE, 0x1C, 0x00, 0x00, 0x00, 0x04, 0x08, 0x1C, // 78
|
||||
0xF8, 0x04, 0x02, 0x02, 0x02, 0x02, 0x02, 0x04, 0xF8, 0x04, 0x08, 0x10, 0x10, 0x10, 0x10, 0x10, 0x08, 0x04, // 79
|
||||
0xFE, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3C, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 80
|
||||
0xF8, 0x04, 0x02, 0x02, 0x02, 0x02, 0x02, 0x04, 0xF8, 0x04, 0x08, 0x10, 0x10, 0x10, 0x14, 0x08, 0x1C, 0x10, // 81
|
||||
0xFE, 0x42, 0x42, 0x42, 0xC2, 0x42, 0x42, 0x3C, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x04, 0x08, 0x10, // 82
|
||||
0x1C, 0x22, 0x22, 0x22, 0x42, 0x42, 0x8C, 0x0C, 0x10, 0x10, 0x10, 0x10, 0x10, 0x0C, // 83
|
||||
0x02, 0x02, 0x02, 0xFE, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, // 84
|
||||
0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x04, 0x08, 0x10, 0x10, 0x10, 0x08, 0x04, // 85
|
||||
0x06, 0x18, 0x60, 0x80, 0x00, 0x80, 0x60, 0x18, 0x06, 0x00, 0x00, 0x00, 0x04, 0x18, 0x04, 0x00, 0x00, 0x00, // 86
|
||||
0x06, 0x38, 0xC0, 0x00, 0xC0, 0x3C, 0x02, 0x3C, 0xC0, 0x00, 0xC0, 0x38, 0x06, 0x00, 0x00, 0x04, 0x18, 0x04, 0x00, 0x00, 0x00, 0x04, 0x18, 0x04, 0x00, 0x00, // 87
|
||||
0x02, 0x0C, 0x90, 0x60, 0x60, 0x90, 0x0C, 0x02, 0x10, 0x0C, 0x00, 0x00, 0x00, 0x04, 0x0C, 0x10, // 88
|
||||
0x02, 0x04, 0x18, 0x20, 0xC0, 0x20, 0x18, 0x04, 0x02, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x00, // 89
|
||||
0x00, 0x02, 0x82, 0x42, 0x22, 0x1A, 0x06, 0x02, 0x10, 0x18, 0x14, 0x10, 0x10, 0x10, 0x10, 0x10, // 90
|
||||
0xFE, 0x02, 0xFC, 0x80, // 91
|
||||
0x06, 0x38, 0xC0, 0x00, 0x00, 0x00, 0x04, 0x18, // 92
|
||||
0x02, 0xFE, 0x80, 0xFC, // 93
|
||||
0x20, 0x1C, 0x02, 0x1C, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, // 94
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, // 95
|
||||
0x02, 0x04, 0x00, 0x00, // 96
|
||||
0x10, 0x88, 0x48, 0x48, 0x48, 0xF0, 0x0C, 0x10, 0x10, 0x10, 0x08, 0x1C, // 97
|
||||
0xFE, 0x10, 0x08, 0x08, 0x08, 0xF0, 0x1C, 0x08, 0x10, 0x10, 0x10, 0x0C, // 98
|
||||
0xF0, 0x08, 0x08, 0x08, 0x10, 0x0C, 0x10, 0x10, 0x10, 0x08, // 99
|
||||
0xF0, 0x08, 0x08, 0x08, 0x10, 0xFE, 0x0C, 0x10, 0x10, 0x10, 0x08, 0x1C, // 100
|
||||
0xF0, 0x48, 0x48, 0x48, 0x48, 0x70, 0x0C, 0x10, 0x10, 0x10, 0x10, 0x08, // 101
|
||||
0x08, 0xFC, 0x0A, 0x0A, 0x00, 0x1C, 0x00, 0x00, // 102
|
||||
0xF0, 0x08, 0x08, 0x08, 0x10, 0xF8, 0x4C, 0x90, 0x90, 0x90, 0x88, 0x7C, // 103
|
||||
0xFE, 0x10, 0x08, 0x08, 0x08, 0xF0, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x1C, // 104
|
||||
0xFA, 0x1C, // 105
|
||||
0x00, 0xFA, 0x80, 0x7C, // 106
|
||||
0xFE, 0x80, 0x40, 0xA0, 0x10, 0x08, 0x1C, 0x00, 0x00, 0x00, 0x0C, 0x10, // 107
|
||||
0xFE, 0x1C, // 108
|
||||
0xF8, 0x10, 0x08, 0x08, 0xF0, 0x10, 0x08, 0x08, 0xF0, 0x1C, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x1C, // 109
|
||||
0xF8, 0x10, 0x08, 0x08, 0x08, 0xF0, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x1C, // 110
|
||||
0xF0, 0x08, 0x08, 0x08, 0x08, 0xF0, 0x0C, 0x10, 0x10, 0x10, 0x10, 0x0C, // 111
|
||||
0xF8, 0x10, 0x08, 0x08, 0x08, 0xF0, 0xFC, 0x08, 0x10, 0x10, 0x10, 0x0C, // 112
|
||||
0xF0, 0x08, 0x08, 0x08, 0x10, 0xF8, 0x0C, 0x10, 0x10, 0x10, 0x08, 0xFC, // 113
|
||||
0xF8, 0x10, 0x08, 0x08, 0x1C, 0x00, 0x00, 0x00, // 114
|
||||
0x30, 0x48, 0x48, 0x48, 0x90, 0x08, 0x10, 0x10, 0x10, 0x0C, // 115
|
||||
0x08, 0xFE, 0x08, 0x08, 0x00, 0x1C, 0x10, 0x10, // 116
|
||||
0xF8, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x0C, 0x10, 0x10, 0x10, 0x08, 0x1C, // 117
|
||||
0x18, 0x60, 0x80, 0x00, 0x80, 0x60, 0x18, 0x00, 0x00, 0x04, 0x18, 0x04, 0x00, 0x00, // 118
|
||||
0x18, 0xE0, 0x00, 0xE0, 0x18, 0xE0, 0x00, 0xE0, 0x18, 0x00, 0x04, 0x18, 0x04, 0x00, 0x04, 0x18, 0x04, 0x00, // 119
|
||||
0x08, 0x30, 0xC0, 0xC0, 0x30, 0x08, 0x10, 0x0C, 0x00, 0x00, 0x0C, 0x10, // 120
|
||||
0x18, 0x60, 0x80, 0x00, 0x80, 0x60, 0x18, 0x00, 0x80, 0x8C, 0x70, 0x0C, 0x00, 0x00, // 121
|
||||
0x08, 0x08, 0x88, 0x68, 0x18, 0x08, 0x10, 0x18, 0x14, 0x10, 0x10, 0x10, // 122
|
||||
0x80, 0x7C, 0x02, 0x00, 0x7C, 0x80, // 123
|
||||
0xFE, 0xFC, // 124
|
||||
0x02, 0x7C, 0x80, 0x80, 0x7C, 0x00, // 125
|
||||
0x40, 0x20, 0x20, 0x60, 0x40, 0x40, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 126
|
||||
0xFC, 0x04, 0x04, 0x04, 0x04, 0x04, 0xFC, 0x1C, 0x10, 0x10, 0x10, 0x10, 0x10, 0x1C // 127
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,15 @@
|
||||
glcdbitmap.pde is a Processing sketch that creates a bitmap definition file that can be included in an Arduino sketch and displayed by the ks0108 GLCD library (requires version 2 or later)
|
||||
|
||||
The source bitmap must have a height and width no greater than the height and width of the LCD display and should be a black and white image (single bit per pixel)
|
||||
|
||||
Change the string variable sourceImage to the name of the bitmap file you want to convert. Bitmap images should be stored in a subdirectory called data.
|
||||
|
||||
The output will be a header file with the same base name as the source image with an extension of .h - this header file should be included in your sketch (see the example). The header file must either be copied to the directory that contains your Arduino sketch or to the ks0108 library directory.
|
||||
|
||||
The header will contain an array variable with the same basename as your source bmp file. This variable is passed to the method DrawBitmap
|
||||
|
||||
DrawBitmap takes four parameters, in addition to the array variable, it expects the x and y coordinates of the upper left hand position of the bitmap. The last parameter is the color to draw the pixes, this can be BLACK or WHITE.
|
||||
|
||||
The following line draws an image from a header file that has an array called ArduinoIcon. The left hand side (x axis) is offset 32 pixels, the y axis starts from the top (first line) of the display. The pixels that were black in the bmp file are painted to the LCD, pixels that were white are cleared.
|
||||
GLCD.DrawBitmap(ArduinoIcon, 32,0, BLACK);
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
@@ -0,0 +1,108 @@
|
||||
/**
|
||||
* glcdBitmap.
|
||||
*
|
||||
* Creates a bitmap definition file that can be included in an Arduino sketch
|
||||
* to display a bitmap image on a graphics LCD using the Arduino GLCD library.
|
||||
*
|
||||
* Created 6 Nov 2008 Copyright Michael Margolis 2008
|
||||
*/
|
||||
String sourceImage = "ArduinoIcon.bmp"; // change this to the name of your bitmap file
|
||||
PImage a;
|
||||
int[] aPixels;
|
||||
|
||||
void setup()
|
||||
{
|
||||
|
||||
noFill();
|
||||
stroke(255);
|
||||
frameRate(30);
|
||||
// load the image
|
||||
a = loadImage(sourceImage);
|
||||
if( a != null){
|
||||
size(a.width, a.height);
|
||||
aPixels = new int[width*height];
|
||||
for(int i=0; i<width*height; i++) {
|
||||
aPixels[i] = a.pixels[i];
|
||||
}
|
||||
// display the image
|
||||
loadPixels();
|
||||
for (int i=0; i<width*height; i++)
|
||||
pixels[i] = aPixels[i];
|
||||
updatePixels();
|
||||
writeFile(sourceImage);
|
||||
println("created header file for " + sourceImage);
|
||||
}
|
||||
}
|
||||
|
||||
void writeFile(String inFileName){
|
||||
String[] f = split(inFileName, '.');
|
||||
String baseName = f[0];
|
||||
|
||||
String outFileName = baseName + ".h";
|
||||
PrintWriter output;
|
||||
output = createWriter(outFileName);
|
||||
|
||||
output.println("/* " + outFileName + " bitmap file for GLCD library */");
|
||||
output.println("/* Bitmap created from " + inFileName + " */");
|
||||
String[] monthName = {"","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
|
||||
output.println("/* Date: " + day() + " " + monthName[month()] + " " + year() + " */" );
|
||||
output.println();
|
||||
|
||||
output.println("#include <inttypes.h>");
|
||||
output.println("#include <avr/pgmspace.h>");
|
||||
output.println();
|
||||
output.println("#ifndef " + baseName + "_H");
|
||||
output.println("#define " + baseName + "_H");
|
||||
|
||||
output.println();
|
||||
output.print("static uint8_t ");
|
||||
output.print(baseName);
|
||||
output.println("[] PROGMEM = {");
|
||||
|
||||
output.print(" ");
|
||||
output.print(a.width); // note width and height are bytes so 256 will be 0
|
||||
output.println(", // width");
|
||||
output.print(" ");
|
||||
output.print(a.height);
|
||||
output.println(", // height");
|
||||
for(int page=0; page < (a.height + 7)/8; page++) {
|
||||
output.println("\n /* page " + page + " (lines " + page*8 + "-" + (page*8+7) + ") */");
|
||||
output.print(" ");
|
||||
for(int x=0; x < a.width; x++){
|
||||
output.print( "0x" + Integer.toHexString(getValue(x,page))) ;
|
||||
if( (x == (a.width-1)) && (page == (((a.height +7)/8)-1)) )
|
||||
println("\n"); // this is the last element so new line instead of comma
|
||||
else
|
||||
output.print(","); // comma on all but last entry
|
||||
if( x % 16 == 15)
|
||||
output.print("\n ");
|
||||
}
|
||||
}
|
||||
output.print("\n};\n");
|
||||
output.println("#endif");
|
||||
|
||||
output.flush(); // Write the remaining data
|
||||
output.close(); // Finish the file
|
||||
|
||||
}
|
||||
int getValue( int x, int page){
|
||||
int val = 0;
|
||||
for( byte b=0; b < 8; b++){
|
||||
int y = page * 8 + b;
|
||||
int pos = y * a.width + x;
|
||||
if( aPixels[pos] != 0xffffffff ){
|
||||
val |= (1 << b); // here if color is not black
|
||||
}
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
void draw()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
150
Micropendous/libs/arduino/libraries/ks0108/SystemFont5x7.h
Normal file
150
Micropendous/libs/arduino/libraries/ks0108/SystemFont5x7.h
Normal file
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
*
|
||||
* System5x7
|
||||
*
|
||||
*
|
||||
* File Name : System5x7.h
|
||||
* Date : 28 Oct 2008
|
||||
* Font size in bytes : 470
|
||||
* Font width : 5
|
||||
* Font height : 7
|
||||
* Font first char : 32
|
||||
* Font last char : 127
|
||||
* Font used chars : 94
|
||||
*
|
||||
* The font data are defined as
|
||||
*
|
||||
* struct _FONT_ {
|
||||
* uint16_t font_Size_in_Bytes_over_all_included_Size_it_self;
|
||||
* uint8_t font_Width_in_Pixel_for_fixed_drawing;
|
||||
* uint8_t font_Height_in_Pixel_for_all_characters;
|
||||
* unit8_t font_First_Char;
|
||||
* uint8_t font_Char_Count;
|
||||
*
|
||||
* uint8_t font_Char_Widths[font_Last_Char - font_First_Char +1];
|
||||
* // for each character the separate width in pixels,
|
||||
* // characters < 128 have an implicit virtual right empty row
|
||||
*
|
||||
* uint8_t font_data[];
|
||||
* // bit field of all characters
|
||||
*/
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
#ifndef SYSTEM5x7_H
|
||||
#define SYSTEM5x7_H
|
||||
|
||||
#define SYSTEM5x7_WIDTH 5
|
||||
#define SYSTEM5x7_HEIGHT 7
|
||||
|
||||
static uint8_t System5x7[] PROGMEM = {
|
||||
0x0, 0x0, // size of zero indicates fixed width font, actual length is width * height
|
||||
0x05, // width
|
||||
0x07, // height
|
||||
0x20, // first char
|
||||
0x7f, // char count
|
||||
|
||||
// Fixed width; char width table not used !!!!
|
||||
|
||||
// font data
|
||||
0x00, 0x00, 0x00, 0x00, 0x00,// (space)
|
||||
0x00, 0x00, 0x5F, 0x00, 0x00,// !
|
||||
0x00, 0x07, 0x00, 0x07, 0x00,// "
|
||||
0x14, 0x7F, 0x14, 0x7F, 0x14,// #
|
||||
0x24, 0x2A, 0x7F, 0x2A, 0x12,// $
|
||||
0x23, 0x13, 0x08, 0x64, 0x62,// %
|
||||
0x36, 0x49, 0x55, 0x22, 0x50,// &
|
||||
0x00, 0x05, 0x03, 0x00, 0x00,// '
|
||||
0x00, 0x1C, 0x22, 0x41, 0x00,// (
|
||||
0x00, 0x41, 0x22, 0x1C, 0x00,// )
|
||||
0x08, 0x2A, 0x1C, 0x2A, 0x08,// *
|
||||
0x08, 0x08, 0x3E, 0x08, 0x08,// +
|
||||
0x00, 0x50, 0x30, 0x00, 0x00,// ,
|
||||
0x08, 0x08, 0x08, 0x08, 0x08,// -
|
||||
0x00, 0x60, 0x60, 0x00, 0x00,// .
|
||||
0x20, 0x10, 0x08, 0x04, 0x02,// /
|
||||
0x3E, 0x51, 0x49, 0x45, 0x3E,// 0
|
||||
0x00, 0x42, 0x7F, 0x40, 0x00,// 1
|
||||
0x42, 0x61, 0x51, 0x49, 0x46,// 2
|
||||
0x21, 0x41, 0x45, 0x4B, 0x31,// 3
|
||||
0x18, 0x14, 0x12, 0x7F, 0x10,// 4
|
||||
0x27, 0x45, 0x45, 0x45, 0x39,// 5
|
||||
0x3C, 0x4A, 0x49, 0x49, 0x30,// 6
|
||||
0x01, 0x71, 0x09, 0x05, 0x03,// 7
|
||||
0x36, 0x49, 0x49, 0x49, 0x36,// 8
|
||||
0x06, 0x49, 0x49, 0x29, 0x1E,// 9
|
||||
0x00, 0x36, 0x36, 0x00, 0x00,// :
|
||||
0x00, 0x56, 0x36, 0x00, 0x00,// ;
|
||||
0x00, 0x08, 0x14, 0x22, 0x41,// <
|
||||
0x14, 0x14, 0x14, 0x14, 0x14,// =
|
||||
0x41, 0x22, 0x14, 0x08, 0x00,// >
|
||||
0x02, 0x01, 0x51, 0x09, 0x06,// ?
|
||||
0x32, 0x49, 0x79, 0x41, 0x3E,// @
|
||||
0x7E, 0x11, 0x11, 0x11, 0x7E,// A
|
||||
0x7F, 0x49, 0x49, 0x49, 0x36,// B
|
||||
0x3E, 0x41, 0x41, 0x41, 0x22,// C
|
||||
0x7F, 0x41, 0x41, 0x22, 0x1C,// D
|
||||
0x7F, 0x49, 0x49, 0x49, 0x41,// E
|
||||
0x7F, 0x09, 0x09, 0x01, 0x01,// F
|
||||
0x3E, 0x41, 0x41, 0x51, 0x32,// G
|
||||
0x7F, 0x08, 0x08, 0x08, 0x7F,// H
|
||||
0x00, 0x41, 0x7F, 0x41, 0x00,// I
|
||||
0x20, 0x40, 0x41, 0x3F, 0x01,// J
|
||||
0x7F, 0x08, 0x14, 0x22, 0x41,// K
|
||||
0x7F, 0x40, 0x40, 0x40, 0x40,// L
|
||||
0x7F, 0x02, 0x04, 0x02, 0x7F,// M
|
||||
0x7F, 0x04, 0x08, 0x10, 0x7F,// N
|
||||
0x3E, 0x41, 0x41, 0x41, 0x3E,// O
|
||||
0x7F, 0x09, 0x09, 0x09, 0x06,// P
|
||||
0x3E, 0x41, 0x51, 0x21, 0x5E,// Q
|
||||
0x7F, 0x09, 0x19, 0x29, 0x46,// R
|
||||
0x46, 0x49, 0x49, 0x49, 0x31,// S
|
||||
0x01, 0x01, 0x7F, 0x01, 0x01,// T
|
||||
0x3F, 0x40, 0x40, 0x40, 0x3F,// U
|
||||
0x1F, 0x20, 0x40, 0x20, 0x1F,// V
|
||||
0x7F, 0x20, 0x18, 0x20, 0x7F,// W
|
||||
0x63, 0x14, 0x08, 0x14, 0x63,// X
|
||||
0x03, 0x04, 0x78, 0x04, 0x03,// Y
|
||||
0x61, 0x51, 0x49, 0x45, 0x43,// Z
|
||||
0x00, 0x00, 0x7F, 0x41, 0x41,// [
|
||||
0x02, 0x04, 0x08, 0x10, 0x20,// "\"
|
||||
0x41, 0x41, 0x7F, 0x00, 0x00,// ]
|
||||
0x04, 0x02, 0x01, 0x02, 0x04,// ^
|
||||
0x40, 0x40, 0x40, 0x40, 0x40,// _
|
||||
0x00, 0x01, 0x02, 0x04, 0x00,// `
|
||||
0x20, 0x54, 0x54, 0x54, 0x78,// a
|
||||
0x7F, 0x48, 0x44, 0x44, 0x38,// b
|
||||
0x38, 0x44, 0x44, 0x44, 0x20,// c
|
||||
0x38, 0x44, 0x44, 0x48, 0x7F,// d
|
||||
0x38, 0x54, 0x54, 0x54, 0x18,// e
|
||||
0x08, 0x7E, 0x09, 0x01, 0x02,// f
|
||||
0x08, 0x14, 0x54, 0x54, 0x3C,// g
|
||||
0x7F, 0x08, 0x04, 0x04, 0x78,// h
|
||||
0x00, 0x44, 0x7D, 0x40, 0x00,// i
|
||||
0x20, 0x40, 0x44, 0x3D, 0x00,// j
|
||||
0x00, 0x7F, 0x10, 0x28, 0x44,// k
|
||||
0x00, 0x41, 0x7F, 0x40, 0x00,// l
|
||||
0x7C, 0x04, 0x18, 0x04, 0x78,// m
|
||||
0x7C, 0x08, 0x04, 0x04, 0x78,// n
|
||||
0x38, 0x44, 0x44, 0x44, 0x38,// o
|
||||
0x7C, 0x14, 0x14, 0x14, 0x08,// p
|
||||
0x08, 0x14, 0x14, 0x18, 0x7C,// q
|
||||
0x7C, 0x08, 0x04, 0x04, 0x08,// r
|
||||
0x48, 0x54, 0x54, 0x54, 0x20,// s
|
||||
0x04, 0x3F, 0x44, 0x40, 0x20,// t
|
||||
0x3C, 0x40, 0x40, 0x20, 0x7C,// u
|
||||
0x1C, 0x20, 0x40, 0x20, 0x1C,// v
|
||||
0x3C, 0x40, 0x30, 0x40, 0x3C,// w
|
||||
0x44, 0x28, 0x10, 0x28, 0x44,// x
|
||||
0x0C, 0x50, 0x50, 0x50, 0x3C,// y
|
||||
0x44, 0x64, 0x54, 0x4C, 0x44,// z
|
||||
0x00, 0x08, 0x36, 0x41, 0x00,// {
|
||||
0x00, 0x00, 0x7F, 0x00, 0x00,// |
|
||||
0x00, 0x41, 0x36, 0x08, 0x00,// }
|
||||
0x08, 0x08, 0x2A, 0x1C, 0x08,// ->
|
||||
0x08, 0x1C, 0x2A, 0x08, 0x08 // <-
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* GLCDexample
|
||||
*
|
||||
* Basic test code for the Arduino KS0108 GLCD library.
|
||||
* This code exercises a range of graphic functions supported
|
||||
* by the library and is an example of its use.
|
||||
* It also gives an indication of performance, showing the
|
||||
* number of frames drawn per second.
|
||||
*/
|
||||
|
||||
#include <ks0108.h>
|
||||
#include "Arial14.h" // proportional font
|
||||
#include "SystemFont5x7.h" // system font
|
||||
#include "ArduinoIcon.h" // bitmap
|
||||
|
||||
unsigned long startMillis;
|
||||
unsigned int loops = 0;
|
||||
unsigned int iter = 0;
|
||||
|
||||
void setup(){
|
||||
delay(500); // allow time for LCD to reset
|
||||
GLCD.Init(NON_INVERTED); // initialise the library, non inverted writes pixels onto a clear screen
|
||||
GLCD.ClearScreen();
|
||||
GLCD.DrawBitmap(ArduinoIcon, 32,0, BLACK); //draw the bitmap at the given x,y position
|
||||
GLCD.SelectFont(System5x7); // switch to fixed width system font
|
||||
countdown(5);
|
||||
GLCD.ClearScreen();
|
||||
introScreen(); // show some intro stuff
|
||||
GLCD.ClearScreen();
|
||||
}
|
||||
|
||||
void introScreen(){
|
||||
GLCD.SelectFont(Arial_14); // you can also make your own fonts, see playground for details
|
||||
GLCD.GotoXY(20, 2);
|
||||
GLCD.Puts("GLCD version ");
|
||||
GLCD.PrintNumber(GLCD_VERSION);
|
||||
GLCD.DrawRoundRect(16,0,99,18, 5, BLACK); // rounded rectangle around text area
|
||||
GLCD.SelectFont(System5x7); // switch to fixed width system font
|
||||
showCharacters();
|
||||
countdown(5);
|
||||
}
|
||||
|
||||
void showCharacters(){
|
||||
byte line = 3; // start on the fourth line
|
||||
for(byte c = 32; c <=127; c++){
|
||||
if( (c-32) % 20 == 0)
|
||||
GLCD.CursorTo(1,line++); // CursorTo is used for fixed width system font
|
||||
GLCD.PutChar(c);
|
||||
}
|
||||
}
|
||||
|
||||
void drawSpinner(byte pos, byte x, byte y) {
|
||||
// this draws an object that appears to spin
|
||||
switch(pos % 8) {
|
||||
case 0 : GLCD.DrawLine( x, y-8, x, y+8, BLACK); break;
|
||||
case 1 : GLCD.DrawLine( x+3, y-7, x-3, y+7, BLACK); break;
|
||||
case 2 : GLCD.DrawLine( x+6, y-6, x-6, y+6, BLACK); break;
|
||||
case 3 : GLCD.DrawLine( x+7, y-3, x-7, y+3, BLACK); break;
|
||||
case 4 : GLCD.DrawLine( x+8, y, x-8, y, BLACK); break;
|
||||
case 5 : GLCD.DrawLine( x+7, y+3, x-7, y-3, BLACK); break;
|
||||
case 6 : GLCD.DrawLine( x+6, y+6, x-6, y-6, BLACK); break;
|
||||
case 7 : GLCD.DrawLine( x+3, y+7, x-3, y-7, BLACK); break;
|
||||
}
|
||||
}
|
||||
|
||||
void countdown(int count){
|
||||
while(count--){ // do countdown
|
||||
GLCD.CursorTo(0,1); // first column, second row (offset is from 0)
|
||||
GLCD.PutChar(count + '0');
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
|
||||
void loop(){ // run over and over again
|
||||
iter = 0;
|
||||
startMillis = millis();
|
||||
while( millis() - startMillis < 1000){ // loop for one second
|
||||
GLCD.DrawRect(0, 0, 64, 61, BLACK); // rectangle in left side of screen
|
||||
GLCD.DrawRoundRect(68, 0, 58, 61, 5, BLACK); // rounded rectangle around text area
|
||||
for(int i=0; i < 62; i += 4)
|
||||
GLCD.DrawLine(1,1,63,i, BLACK); // draw lines from upper left down right side of rectangle
|
||||
GLCD.DrawCircle(32,31,30,BLACK); // draw circle centered in the left side of screen
|
||||
GLCD.FillRect(92,40,16,16, WHITE); // clear previous spinner position
|
||||
drawSpinner(loops++,100,48); // draw new spinner position
|
||||
//GLCD.FillRect(24,txtLINE3,14,14, WHITE); // clear text area that will be drawn below
|
||||
GLCD.CursorTo(5,5); // locate curser for printing text
|
||||
GLCD.PrintNumber(++iter); // print current iteration at the current cursor position
|
||||
}
|
||||
// display number of iterations in one second
|
||||
GLCD.ClearScreen(); // clear the screen
|
||||
GLCD.CursorTo(14,2); // positon cursor
|
||||
GLCD.Puts("FPS= "); // print a text string
|
||||
GLCD.PrintNumber(iter); // print a number
|
||||
}
|
||||
43
Micropendous/libs/arduino/libraries/ks0108/keywords.txt
Normal file
43
Micropendous/libs/arduino/libraries/ks0108/keywords.txt
Normal file
@@ -0,0 +1,43 @@
|
||||
#######################################
|
||||
# Syntax Coloring Map For KS0108 GLCD
|
||||
#######################################
|
||||
|
||||
#######################################
|
||||
# Datatypes (KEYWORD1)
|
||||
#######################################
|
||||
|
||||
#######################################
|
||||
# Methods and Functions (KEYWORD2)
|
||||
#######################################
|
||||
Init KEYWORD2
|
||||
GotoXY KEYWORD2
|
||||
ClearScreen KEYWORD2
|
||||
DrawCircle KEYWORD2
|
||||
DrawLine KEYWORD2
|
||||
DrawVertLine KEYWORD2
|
||||
DrawHoriLine KEYWORD2
|
||||
DrawRect KEYWORD2
|
||||
DrawRoundRect KEYWORD2
|
||||
FillRect KEYWORD2
|
||||
InvertRect KEYWORD2
|
||||
SetInverted KEYWORD2
|
||||
SetDot KEYWORD2
|
||||
SelectFont KEYWORD2
|
||||
PutChar KEYWORD2
|
||||
Puts KEYWORD2
|
||||
Puts_P KEYWORD2
|
||||
PrintNumber KEYWORD2
|
||||
CursorTo KEYWORD2
|
||||
#######################################
|
||||
# Instances (KEYWORD2)
|
||||
#######################################
|
||||
|
||||
GLCD KEYWORD2
|
||||
|
||||
#######################################
|
||||
# Constants (LITERAL1)
|
||||
#######################################
|
||||
BLACK KEYWORD2
|
||||
WHITE KEYWORD2
|
||||
NON_INVERTED KEYWORD2
|
||||
INVERTED KEYWORD2
|
||||
734
Micropendous/libs/arduino/libraries/ks0108/ks0108.cpp
Normal file
734
Micropendous/libs/arduino/libraries/ks0108/ks0108.cpp
Normal file
@@ -0,0 +1,734 @@
|
||||
/*
|
||||
ks0108.cpp - Arduino library support for ks0108 and compatable graphic LCDs
|
||||
Copyright (c)2008 Michael Margolis All right reserved
|
||||
mailto:memargolis@hotmail.com?subject=KS0108_Library
|
||||
|
||||
The high level functions of this library are based on version 1.1 of ks0108 graphics routines
|
||||
written and copyright by Fabian Maximilian Thiele. His sitelink is dead but
|
||||
you can obtain a copy of his original work here:
|
||||
http://www.scienceprog.com/wp-content/uploads/2007/07/glcd_ks0108.zip
|
||||
|
||||
Code changes include conversion to an Arduino C++ library, rewriting the low level routines
|
||||
to read busy status flag and support a wider range of displays, adding more flexibility
|
||||
in port addressing and improvements in I/O speed. The interface has been made more Arduino friendly
|
||||
and some convenience functions added.
|
||||
|
||||
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.
|
||||
|
||||
Version: 1.0 - May 8 2008 - first release
|
||||
Version: 1.1 - Nov 7 2008 - restructured low level code to adapt to panel speed
|
||||
- moved chip and panel configuration into seperate header files
|
||||
- added fixed width system font
|
||||
Version: 2 - May 26 2009 - second release
|
||||
- added support for Mega and Sanguino, improved panel speed tolerance, added bitmap support
|
||||
|
||||
*/
|
||||
|
||||
extern "C" {
|
||||
#include <inttypes.h>
|
||||
#include <avr/io.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#include <wiring.h> // added 18 Sept 2008 for Arduino release 0012
|
||||
}
|
||||
|
||||
#define ksSOURCE
|
||||
#include "ks0108.h"
|
||||
|
||||
|
||||
#define EN_DELAY() asm volatile( "ldi r24, %0 \n\t" "subi r24, 0x1 \n\t" "and r24, r24 \n\t" "brne .-6 \n\t" ::"M" (EN_DELAY_VALUE) : "r24" )
|
||||
// the (EN_DELAY_VALUE) argument for the above delay is in ks-0108_panel.h
|
||||
|
||||
//#define GLCD_DEBUG // uncomment this if you want to slow down drawing to see how pixels are set
|
||||
|
||||
void ks0108::ClearPage(uint8_t page, uint8_t color){
|
||||
for(uint8_t x=0; x < DISPLAY_WIDTH; x++){
|
||||
GotoXY(x, page * 8);
|
||||
this->WriteData(color);
|
||||
}
|
||||
}
|
||||
|
||||
void ks0108::ClearScreen(uint8_t color){
|
||||
uint8_t page;
|
||||
for( page = 0; page < 8; page++){
|
||||
GotoXY(0, page * 8);
|
||||
ClearPage(page, color);
|
||||
}
|
||||
}
|
||||
|
||||
void ks0108::DrawLine(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2, uint8_t color) {
|
||||
uint8_t length, i, y, yAlt, xTmp, yTmp;
|
||||
int16_t m;
|
||||
//
|
||||
// vertical line
|
||||
//
|
||||
if(x1 == x2) {
|
||||
// x1|y1 must be the upper point
|
||||
if(y1 > y2) {
|
||||
yTmp = y1;
|
||||
y1 = y2;
|
||||
y2 = yTmp;
|
||||
}
|
||||
this->DrawVertLine(x1, y1, y2-y1, color);
|
||||
|
||||
//
|
||||
// horizontal line
|
||||
//
|
||||
} else if(y1 == y2) {
|
||||
// x1|y1 must be the left point
|
||||
if(x1 > x2) {
|
||||
xTmp = x1;
|
||||
x1 = x2;
|
||||
x2 = xTmp;
|
||||
}
|
||||
this->DrawHoriLine(x1, y1, x2-x1, color);
|
||||
|
||||
//
|
||||
// angled line :)
|
||||
//
|
||||
} else {
|
||||
// angle >= 45<34>
|
||||
if((y2-y1) >= (x2-x1) || (y1-y2) >= (x2-x1)) {
|
||||
// x1 must be smaller than x2
|
||||
if(x1 > x2) {
|
||||
xTmp = x1;
|
||||
yTmp = y1;
|
||||
x1 = x2;
|
||||
y1 = y2;
|
||||
x2 = xTmp;
|
||||
y2 = yTmp;
|
||||
}
|
||||
|
||||
length = x2-x1; // not really the length :)
|
||||
m = ((y2-y1)*200)/length;
|
||||
yAlt = y1;
|
||||
|
||||
for(i=0; i<=length; i++) {
|
||||
y = ((m*i)/200)+y1;
|
||||
|
||||
if((m*i)%200 >= 100)
|
||||
y++;
|
||||
else if((m*i)%200 <= -100)
|
||||
y--;
|
||||
|
||||
this->DrawLine(x1+i, yAlt, x1+i, y, color);
|
||||
|
||||
if(length <= (y2-y1) && y1 < y2)
|
||||
yAlt = y+1;
|
||||
else if(length <= (y1-y2) && y1 > y2)
|
||||
yAlt = y-1;
|
||||
else
|
||||
yAlt = y;
|
||||
}
|
||||
|
||||
// angle < 45<34>
|
||||
} else {
|
||||
// y1 must be smaller than y2
|
||||
if(y1 > y2) {
|
||||
xTmp = x1;
|
||||
yTmp = y1;
|
||||
x1 = x2;
|
||||
y1 = y2;
|
||||
x2 = xTmp;
|
||||
y2 = yTmp;
|
||||
}
|
||||
|
||||
length = y2-y1;
|
||||
m = ((x2-x1)*200)/length;
|
||||
yAlt = x1;
|
||||
|
||||
for(i=0; i<=length; i++) {
|
||||
y = ((m*i)/200)+x1;
|
||||
|
||||
if((m*i)%200 >= 100)
|
||||
y++;
|
||||
else if((m*i)%200 <= -100)
|
||||
y--;
|
||||
|
||||
this->DrawLine(yAlt, y1+i, y, y1+i, color);
|
||||
if(length <= (x2-x1) && x1 < x2)
|
||||
yAlt = y+1;
|
||||
else if(length <= (x1-x2) && x1 > x2)
|
||||
yAlt = y-1;
|
||||
else
|
||||
yAlt = y;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ks0108::DrawRect(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t color) {
|
||||
DrawHoriLine(x, y, width, color); // top
|
||||
DrawHoriLine(x, y+height, width, color); // bottom
|
||||
DrawVertLine(x, y, height, color); // left
|
||||
DrawVertLine(x+width, y, height, color); // right
|
||||
}
|
||||
|
||||
void ks0108::DrawRoundRect(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t radius, uint8_t color) {
|
||||
int16_t tSwitch, x1 = 0, y1 = radius;
|
||||
tSwitch = 3 - 2 * radius;
|
||||
|
||||
while (x1 <= y1) {
|
||||
this->SetDot(x+radius - x1, y+radius - y1, color);
|
||||
this->SetDot(x+radius - y1, y+radius - x1, color);
|
||||
|
||||
this->SetDot(x+width-radius + x1, y+radius - y1, color);
|
||||
this->SetDot(x+width-radius + y1, y+radius - x1, color);
|
||||
|
||||
this->SetDot(x+width-radius + x1, y+height-radius + y1, color);
|
||||
this->SetDot(x+width-radius + y1, y+height-radius + x1, color);
|
||||
|
||||
this->SetDot(x+radius - x1, y+height-radius + y1, color);
|
||||
this->SetDot(x+radius - y1, y+height-radius + x1, color);
|
||||
|
||||
if (tSwitch < 0) {
|
||||
tSwitch += (4 * x1 + 6);
|
||||
} else {
|
||||
tSwitch += (4 * (x1 - y1) + 10);
|
||||
y1--;
|
||||
}
|
||||
x1++;
|
||||
}
|
||||
|
||||
this->DrawHoriLine(x+radius, y, width-(2*radius), color); // top
|
||||
this->DrawHoriLine(x+radius, y+height, width-(2*radius), color); // bottom
|
||||
this->DrawVertLine(x, y+radius, height-(2*radius), color); // left
|
||||
this->DrawVertLine(x+width, y+radius, height-(2*radius), color); // right
|
||||
}
|
||||
|
||||
/*
|
||||
* Hardware-Functions
|
||||
*/
|
||||
void ks0108::FillRect(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t color) {
|
||||
uint8_t mask, pageOffset, h, i, data;
|
||||
height++;
|
||||
|
||||
pageOffset = y%8;
|
||||
y -= pageOffset;
|
||||
mask = 0xFF;
|
||||
if(height < 8-pageOffset) {
|
||||
mask >>= (8-height);
|
||||
h = height;
|
||||
} else {
|
||||
h = 8-pageOffset;
|
||||
}
|
||||
mask <<= pageOffset;
|
||||
|
||||
this->GotoXY(x, y);
|
||||
for(i=0; i<=width; i++) {
|
||||
data = this->ReadData();
|
||||
|
||||
if(color == BLACK) {
|
||||
data |= mask;
|
||||
} else {
|
||||
data &= ~mask;
|
||||
}
|
||||
|
||||
this->WriteData(data);
|
||||
}
|
||||
|
||||
while(h+8 <= height) {
|
||||
h += 8;
|
||||
y += 8;
|
||||
this->GotoXY(x, y);
|
||||
|
||||
for(i=0; i<=width; i++) {
|
||||
this->WriteData(color);
|
||||
}
|
||||
}
|
||||
|
||||
if(h < height) {
|
||||
mask = ~(0xFF << (height-h));
|
||||
this->GotoXY(x, y+8);
|
||||
|
||||
for(i=0; i<=width; i++) {
|
||||
data = this->ReadData();
|
||||
|
||||
if(color == BLACK) {
|
||||
data |= mask;
|
||||
} else {
|
||||
data &= ~mask;
|
||||
}
|
||||
|
||||
this->WriteData(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ks0108::InvertRect(uint8_t x, uint8_t y, uint8_t width, uint8_t height) {
|
||||
uint8_t mask, pageOffset, h, i, data, tmpData;
|
||||
height++;
|
||||
|
||||
pageOffset = y%8;
|
||||
y -= pageOffset;
|
||||
mask = 0xFF;
|
||||
if(height < 8-pageOffset) {
|
||||
mask >>= (8-height);
|
||||
h = height;
|
||||
} else {
|
||||
h = 8-pageOffset;
|
||||
}
|
||||
mask <<= pageOffset;
|
||||
|
||||
this->GotoXY(x, y);
|
||||
for(i=0; i<=width; i++) {
|
||||
data = this->ReadData();
|
||||
tmpData = ~data;
|
||||
data = (tmpData & mask) | (data & ~mask);
|
||||
this->WriteData(data);
|
||||
}
|
||||
|
||||
while(h+8 <= height) {
|
||||
h += 8;
|
||||
y += 8;
|
||||
this->GotoXY(x, y);
|
||||
|
||||
for(i=0; i<=width; i++) {
|
||||
data = this->ReadData();
|
||||
this->WriteData(~data);
|
||||
}
|
||||
}
|
||||
|
||||
if(h < height) {
|
||||
mask = ~(0xFF << (height-h));
|
||||
this->GotoXY(x, y+8);
|
||||
|
||||
for(i=0; i<=width; i++) {
|
||||
data = this->ReadData();
|
||||
tmpData = ~data;
|
||||
data = (tmpData & mask) | (data & ~mask);
|
||||
this->WriteData(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ks0108::SetInverted(boolean invert) { // changed type to boolean
|
||||
if(this->Inverted != invert) {
|
||||
this->InvertRect(0,0,DISPLAY_WIDTH-1,DISPLAY_HEIGHT-1);
|
||||
this->Inverted = invert;
|
||||
}
|
||||
}
|
||||
|
||||
void ks0108::SetDot(uint8_t x, uint8_t y, uint8_t color) {
|
||||
uint8_t data;
|
||||
|
||||
this->GotoXY(x, y-y%8); // read data from display memory
|
||||
|
||||
data = this->ReadData();
|
||||
if(color == BLACK) {
|
||||
data |= 0x01 << (y%8); // set dot
|
||||
} else {
|
||||
data &= ~(0x01 << (y%8)); // clear dot
|
||||
}
|
||||
this->WriteData(data); // write data back to display
|
||||
}
|
||||
|
||||
//
|
||||
// Font Functions
|
||||
//
|
||||
|
||||
uint8_t ReadPgmData(const uint8_t* ptr) { // note this is a static function
|
||||
return pgm_read_byte(ptr);
|
||||
}
|
||||
|
||||
void ks0108::SelectFont(const uint8_t* font,uint8_t color, FontCallback callback) {
|
||||
this->Font = font;
|
||||
this->FontRead = callback;
|
||||
this->FontColor = color;
|
||||
}
|
||||
|
||||
void ks0108::PrintNumber(long n){
|
||||
byte buf[10]; // prints up to 10 digits
|
||||
byte i=0;
|
||||
if(n==0)
|
||||
PutChar('0');
|
||||
else{
|
||||
if(n < 0){
|
||||
PutChar('-');
|
||||
n = -n;
|
||||
}
|
||||
while(n>0 && i <= 10){
|
||||
buf[i++] = n % 10; // n % base
|
||||
n /= 10; // n/= base
|
||||
}
|
||||
for(; i >0; i--)
|
||||
this->PutChar((char) (buf[i-1] < 10 ? '0' + buf[i-1] : 'A' + buf[i-1] - 10));
|
||||
}
|
||||
}
|
||||
|
||||
int ks0108::PutChar(char c) {
|
||||
uint8_t width = 0;
|
||||
uint8_t height = this->FontRead(this->Font+FONT_HEIGHT);
|
||||
uint8_t bytes = (height+7)/8;
|
||||
|
||||
uint8_t firstChar = this->FontRead(this->Font+FONT_FIRST_CHAR);
|
||||
uint8_t charCount = this->FontRead(this->Font+FONT_CHAR_COUNT);
|
||||
|
||||
uint16_t index = 0;
|
||||
uint8_t x = this->Coord.x, y = this->Coord.y;
|
||||
|
||||
if(c < firstChar || c >= (firstChar+charCount)) {
|
||||
return 1;
|
||||
}
|
||||
c-= firstChar;
|
||||
|
||||
if( this->FontRead(this->Font+FONT_LENGTH) == 0 && this->FontRead(this->Font+FONT_LENGTH+1) == 0) {
|
||||
// zero length is flag indicating fixed width font (array does not contain width data entries)
|
||||
width = this->FontRead(this->Font+FONT_FIXED_WIDTH);
|
||||
index = c*bytes*width+FONT_WIDTH_TABLE;
|
||||
}
|
||||
else{
|
||||
// variable width font, read width data, to get the index
|
||||
for(uint8_t i=0; i<c; i++) {
|
||||
index += this->FontRead(this->Font+FONT_WIDTH_TABLE+i);
|
||||
}
|
||||
index = index*bytes+charCount+FONT_WIDTH_TABLE;
|
||||
width = this->FontRead(this->Font+FONT_WIDTH_TABLE+c);
|
||||
}
|
||||
|
||||
// last but not least, draw the character
|
||||
for(uint8_t i=0; i<bytes; i++) {
|
||||
uint8_t page = i*width;
|
||||
for(uint8_t j=0; j<width; j++) {
|
||||
uint8_t data = this->FontRead(this->Font+index+page+j);
|
||||
|
||||
if(height > 8 && height < (i+1)*8) {
|
||||
data >>= (i+1)*8-height;
|
||||
}
|
||||
|
||||
if(this->FontColor == BLACK) {
|
||||
this->WriteData(data);
|
||||
} else {
|
||||
this->WriteData(~data);
|
||||
}
|
||||
}
|
||||
// 1px gap between chars
|
||||
if(this->FontColor == BLACK) {
|
||||
this->WriteData(0x00);
|
||||
} else {
|
||||
this->WriteData(0xFF);
|
||||
}
|
||||
this->GotoXY(x, this->Coord.y+8);
|
||||
}
|
||||
this->GotoXY(x+width+1, y);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ks0108::Puts(char* str) {
|
||||
int x = this->Coord.x;
|
||||
while(*str != 0) {
|
||||
if(*str == '\n') {
|
||||
this->GotoXY(x, this->Coord.y+this->FontRead(this->Font+FONT_HEIGHT));
|
||||
} else {
|
||||
this->PutChar(*str);
|
||||
}
|
||||
str++;
|
||||
}
|
||||
}
|
||||
|
||||
void ks0108::Puts_P(PGM_P str) {
|
||||
int x = this->Coord.x;
|
||||
while(pgm_read_byte(str) != 0) {
|
||||
if(pgm_read_byte(str) == '\n') {
|
||||
this->GotoXY(x, this->Coord.y+this->FontRead(this->Font+FONT_HEIGHT));
|
||||
} else {
|
||||
this->PutChar(pgm_read_byte(str));
|
||||
}
|
||||
str++;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t ks0108::CharWidth(char c) {
|
||||
uint8_t width = 0;
|
||||
uint8_t firstChar = this->FontRead(this->Font+FONT_FIRST_CHAR);
|
||||
uint8_t charCount = this->FontRead(this->Font+FONT_CHAR_COUNT);
|
||||
|
||||
// read width data
|
||||
if(c >= firstChar && c < (firstChar+charCount)) {
|
||||
c -= firstChar;
|
||||
width = this->FontRead(this->Font+FONT_WIDTH_TABLE+c)+1;
|
||||
}
|
||||
|
||||
return width;
|
||||
}
|
||||
|
||||
uint16_t ks0108::StringWidth(char* str) {
|
||||
uint16_t width = 0;
|
||||
|
||||
while(*str != 0) {
|
||||
width += this->CharWidth(*str++);
|
||||
}
|
||||
|
||||
return width;
|
||||
}
|
||||
|
||||
uint16_t ks0108::StringWidth_P(PGM_P str) {
|
||||
uint16_t width = 0;
|
||||
|
||||
while(pgm_read_byte(str) != 0) {
|
||||
width += this->CharWidth(pgm_read_byte(str++));
|
||||
}
|
||||
|
||||
return width;
|
||||
}
|
||||
|
||||
void ks0108::CursorTo( uint8_t x, uint8_t y){ // 0 based coordinates for fixed width fonts (i.e. systemFont5x7)
|
||||
GotoXY( x * (this->FontRead(this->Font+FONT_FIXED_WIDTH)+1),
|
||||
y * (this->FontRead(this->Font+FONT_HEIGHT)+1)
|
||||
) ;
|
||||
}
|
||||
|
||||
void ks0108::GotoXY(uint8_t x, uint8_t y) {
|
||||
uint8_t chip, cmd;
|
||||
|
||||
if( (x > DISPLAY_WIDTH-1) || (y > DISPLAY_HEIGHT-1) ) // exit if coordinates are not legal
|
||||
return;
|
||||
this->Coord.x = x; // save new coordinates
|
||||
this->Coord.y = y;
|
||||
|
||||
if(y/8 != this->Coord.page) {
|
||||
this->Coord.page = y/8;
|
||||
cmd = LCD_SET_PAGE | this->Coord.page; // set y address on all chips
|
||||
for(chip=0; chip < DISPLAY_WIDTH/CHIP_WIDTH; chip++){
|
||||
this->WriteCommand(cmd, chip);
|
||||
}
|
||||
}
|
||||
chip = this->Coord.x/CHIP_WIDTH;
|
||||
x = x % CHIP_WIDTH;
|
||||
cmd = LCD_SET_ADD | x;
|
||||
this->WriteCommand(cmd, chip); // set x address on active chip
|
||||
}
|
||||
|
||||
void ks0108::Init(boolean invert) {
|
||||
pinMode(D_I,OUTPUT);
|
||||
pinMode(R_W,OUTPUT);
|
||||
pinMode(EN,OUTPUT);
|
||||
pinMode(CSEL1,OUTPUT);
|
||||
pinMode(CSEL2,OUTPUT);
|
||||
|
||||
delay(10);
|
||||
|
||||
fastWriteLow(D_I);
|
||||
fastWriteLow(R_W);
|
||||
fastWriteLow(EN);
|
||||
|
||||
this->Coord.x = 0;
|
||||
this->Coord.y = 0;
|
||||
this->Coord.page = 0;
|
||||
|
||||
this->Inverted = invert;
|
||||
|
||||
for(uint8_t chip=0; chip < DISPLAY_WIDTH/CHIP_WIDTH; chip++){
|
||||
delay(10);
|
||||
this->WriteCommand(LCD_ON, chip); // power on
|
||||
this->WriteCommand(LCD_DISP_START, chip); // display start line = 0
|
||||
}
|
||||
delay(50);
|
||||
this->ClearScreen(invert ? BLACK : WHITE); // display clear
|
||||
this->GotoXY(0,0);
|
||||
}
|
||||
|
||||
__inline__ void ks0108::SelectChip(uint8_t chip) {
|
||||
//static uint8_t prevchip;
|
||||
if(chipSelect[chip] & 1)
|
||||
fastWriteHigh(CSEL1);
|
||||
else
|
||||
fastWriteLow(CSEL1);
|
||||
|
||||
if(chipSelect[chip] & 2)
|
||||
fastWriteHigh(CSEL2);
|
||||
else
|
||||
fastWriteLow(CSEL2);
|
||||
}
|
||||
|
||||
|
||||
void ks0108::WaitReady( uint8_t chip){
|
||||
// wait until LCD busy bit goes to zero
|
||||
|
||||
SelectChip(chip);
|
||||
lcdDataDir(0x00);
|
||||
fastWriteLow(D_I);
|
||||
fastWriteHigh(R_W);
|
||||
fastWriteHigh(EN);
|
||||
EN_DELAY();
|
||||
while(LCD_DATA_IN_HIGH & LCD_BUSY_FLAG)
|
||||
;
|
||||
fastWriteLow(EN);
|
||||
|
||||
|
||||
}
|
||||
|
||||
__inline__ void ks0108::Enable(void) {
|
||||
EN_DELAY();
|
||||
fastWriteHigh(EN); // EN high level width min 450 ns
|
||||
EN_DELAY();
|
||||
fastWriteLow(EN);
|
||||
//EN_DELAY(); // some displays may need this delay at the end of the enable pulse
|
||||
}
|
||||
|
||||
uint8_t ks0108::DoReadData(uint8_t first) {
|
||||
uint8_t data, chip;
|
||||
|
||||
chip = this->Coord.x/CHIP_WIDTH;
|
||||
this->WaitReady(chip);
|
||||
if(first){
|
||||
if(this->Coord.x % CHIP_WIDTH == 0 && chip > 0){ // todo , remove this test and call GotoXY always?
|
||||
this->GotoXY(this->Coord.x, this->Coord.y);
|
||||
this->WaitReady(chip);
|
||||
}
|
||||
}
|
||||
fastWriteHigh(D_I); // D/I = 1
|
||||
fastWriteHigh(R_W); // R/W = 1
|
||||
|
||||
fastWriteHigh(EN); // EN high level width: min. 450ns
|
||||
EN_DELAY();
|
||||
|
||||
#ifdef LCD_DATA_NIBBLES
|
||||
data = (LCD_DATA_IN_LOW & 0x0F) | (LCD_DATA_IN_HIGH & 0xF0);
|
||||
#else
|
||||
data = LCD_DATA_IN_LOW; // low and high nibbles on same port so read all 8 bits at once
|
||||
#endif
|
||||
fastWriteLow(EN);
|
||||
if(first == 0)
|
||||
this->GotoXY(this->Coord.x, this->Coord.y);
|
||||
if(this->Inverted)
|
||||
data = ~data;
|
||||
return data;
|
||||
}
|
||||
|
||||
inline uint8_t ks0108::ReadData(void) {
|
||||
this->DoReadData(1); // dummy read
|
||||
return this->DoReadData(0); // "real" read
|
||||
this->Coord.x++;
|
||||
}
|
||||
|
||||
void ks0108::WriteCommand(uint8_t cmd, uint8_t chip) {
|
||||
if(this->Coord.x % CHIP_WIDTH == 0 && chip > 0){ // todo , ignore address 0???
|
||||
EN_DELAY();
|
||||
}
|
||||
this->WaitReady(chip);
|
||||
fastWriteLow(D_I); // D/I = 0
|
||||
fastWriteLow(R_W); // R/W = 0
|
||||
lcdDataDir(0xFF);
|
||||
|
||||
EN_DELAY();
|
||||
lcdDataOut(cmd);
|
||||
this->Enable(); // enable
|
||||
EN_DELAY();
|
||||
EN_DELAY();
|
||||
lcdDataOut(0x00);
|
||||
}
|
||||
|
||||
void ks0108::WriteData(uint8_t data) {
|
||||
uint8_t displayData, yOffset, chip;
|
||||
//showHex("wrData",data);
|
||||
//showXY("wr", this->Coord.x,this->Coord.y);
|
||||
|
||||
#ifdef LCD_CMD_PORT
|
||||
uint8_t cmdPort;
|
||||
#endif
|
||||
|
||||
#ifdef GLCD_DEBUG
|
||||
volatile uint16_t i;
|
||||
for(i=0; i<5000; i++);
|
||||
#endif
|
||||
|
||||
if(this->Coord.x >= DISPLAY_WIDTH)
|
||||
return;
|
||||
chip = this->Coord.x/CHIP_WIDTH;
|
||||
this->WaitReady(chip);
|
||||
|
||||
|
||||
if(this->Coord.x % CHIP_WIDTH == 0 && chip > 0){ // todo , ignore address 0???
|
||||
this->GotoXY(this->Coord.x, this->Coord.y);
|
||||
}
|
||||
|
||||
fastWriteHigh(D_I); // D/I = 1
|
||||
fastWriteLow(R_W); // R/W = 0
|
||||
lcdDataDir(0xFF); // data port is output
|
||||
|
||||
yOffset = this->Coord.y%8;
|
||||
|
||||
if(yOffset != 0) {
|
||||
// first page
|
||||
#ifdef LCD_CMD_PORT
|
||||
cmdPort = LCD_CMD_PORT; // save command port
|
||||
#endif
|
||||
displayData = this->ReadData();
|
||||
#ifdef LCD_CMD_PORT
|
||||
LCD_CMD_PORT = cmdPort; // restore command port
|
||||
#else
|
||||
fastWriteHigh(D_I); // D/I = 1
|
||||
fastWriteLow(R_W); // R/W = 0
|
||||
SelectChip(chip);
|
||||
#endif
|
||||
lcdDataDir(0xFF); // data port is output
|
||||
|
||||
displayData |= data << yOffset;
|
||||
if(this->Inverted)
|
||||
displayData = ~displayData;
|
||||
lcdDataOut( displayData); // write data
|
||||
this->Enable(); // enable
|
||||
|
||||
// second page
|
||||
this->GotoXY(this->Coord.x, this->Coord.y+8);
|
||||
|
||||
displayData = this->ReadData();
|
||||
|
||||
#ifdef LCD_CMD_PORT
|
||||
LCD_CMD_PORT = cmdPort; // restore command port
|
||||
#else
|
||||
fastWriteHigh(D_I); // D/I = 1
|
||||
fastWriteLow(R_W); // R/W = 0
|
||||
SelectChip(chip);
|
||||
#endif
|
||||
lcdDataDir(0xFF); // data port is output
|
||||
|
||||
displayData |= data >> (8-yOffset);
|
||||
if(this->Inverted)
|
||||
displayData = ~displayData;
|
||||
lcdDataOut(displayData); // write data
|
||||
this->Enable(); // enable
|
||||
|
||||
this->GotoXY(this->Coord.x+1, this->Coord.y-8);
|
||||
}else
|
||||
{
|
||||
// just this code gets executed if the write is on a single page
|
||||
if(this->Inverted)
|
||||
data = ~data;
|
||||
EN_DELAY();
|
||||
lcdDataOut(data); // write data
|
||||
this->Enable(); // enable
|
||||
this->Coord.x++;
|
||||
//showXY("WrData",this->Coord.x, this->Coord.y);
|
||||
}
|
||||
}
|
||||
void ks0108::DrawBitmap(const uint8_t * bitmap, uint8_t x, uint8_t y, uint8_t color){
|
||||
uint8_t width, height;
|
||||
uint8_t i, j;
|
||||
|
||||
width = ReadPgmData(bitmap++);
|
||||
height = ReadPgmData(bitmap++);
|
||||
for(j = 0; j < height / 8; j++) {
|
||||
this->GotoXY(x, y + (j*8) );
|
||||
for(i = 0; i < width; i++) {
|
||||
uint8_t displayData = ReadPgmData(bitmap++);
|
||||
if(color == BLACK)
|
||||
this->WriteData(displayData);
|
||||
else
|
||||
this->WriteData(~displayData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// class wrapper
|
||||
|
||||
ks0108::ks0108(){
|
||||
this->Inverted=0;
|
||||
}
|
||||
|
||||
// Make one instance for the user
|
||||
ks0108 GLCD = ks0108();
|
||||
|
||||
184
Micropendous/libs/arduino/libraries/ks0108/ks0108.h
Normal file
184
Micropendous/libs/arduino/libraries/ks0108/ks0108.h
Normal file
@@ -0,0 +1,184 @@
|
||||
/*
|
||||
ks0108.h - Arduino library support for ks0108 and compatable graphic LCDs
|
||||
Copyright (c)2008 Michael Margolis All right reserved
|
||||
mailto:memargolis@hotmail.com?subject=KS0108_Library
|
||||
|
||||
The high level functions of this library are based on version 1.1 of ks0108 graphics routines
|
||||
written and copyright by Fabian Maximilian Thiele. His sitelink is dead but
|
||||
you can obtain a copy of his original work here:
|
||||
http://www.scienceprog.com/wp-content/uploads/2007/07/glcd_ks0108.zip
|
||||
|
||||
Code changes include conversion to an Arduino C++ library, rewriting the low level routines
|
||||
to read busy status flag and support a wider range of displays, adding more flexibility
|
||||
in port addressing and improvements in I/O speed. The interface has been made more Arduino friendly
|
||||
and some convenience functions added.
|
||||
|
||||
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.
|
||||
|
||||
Version: 1.0 - May 8 2008 - initial release
|
||||
Version: 1.0a - Sep 1 2008 - simplified command pin defines
|
||||
Version: 1.0b - Sep 18 2008 - replaced <wiring.h> with boolean typedef for rel 0012
|
||||
Version: 1.1 - Nov 7 2008 - restructured low level code to adapt to panel speed
|
||||
- moved chip and panel configuration into seperate header files
|
||||
- added fixed width system font
|
||||
Version: 2 - May 26 2009 - second release
|
||||
- added support for Mega and Sanguino, improved panel speed tolerance, added bitmap support
|
||||
|
||||
*/
|
||||
|
||||
#include <inttypes.h>
|
||||
typedef uint8_t boolean;
|
||||
typedef uint8_t byte;
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
#ifndef KS0108_H
|
||||
#define KS0108_H
|
||||
|
||||
#define GLCD_VERSION 2 // software version of this library
|
||||
|
||||
// Chip specific includes
|
||||
#if defined(__AVR_ATmega1280__)
|
||||
#include "ks0108_Mega.h" // include this for the Arduino Mega other ATmega1280 boards
|
||||
#elif defined (__AVR_ATmega644__) // TODO - check this define
|
||||
#include "ks0108_Sanguino.h" // include this for Sanguino or ATmega644 boards
|
||||
#elif defined(__AVR_ATmega32U4__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)
|
||||
#include "ks0108_USB_AVRs.h" // all the various USB AVRs: AT90USBxx, ATmegaXUY
|
||||
#else
|
||||
#include "ks0108_Arduino.h" // include this for the Arduino or other ATmega168 boards
|
||||
#endif
|
||||
|
||||
#include "ks0108_Panel.h" // this contains LCD panel specific configuration
|
||||
|
||||
|
||||
// macros for pasting port defines
|
||||
#define GLUE(a, b) a##b
|
||||
#define PORT(x) GLUE(PORT, x)
|
||||
#define PIN(x) GLUE(PIN, x)
|
||||
#define DDR(x) GLUE(DDR, x)
|
||||
|
||||
// paste together the port definitions if using nibbles
|
||||
#define LCD_DATA_IN_LOW PIN(LCD_DATA_LOW_NBL) // Data I/O Register, low nibble
|
||||
#define LCD_DATA_OUT_LOW PORT(LCD_DATA_LOW_NBL) // Data Output Register - low nibble
|
||||
#define LCD_DATA_DIR_LOW DDR(LCD_DATA_LOW_NBL) // Data Direction Register for Data Port, low nibble
|
||||
|
||||
#define LCD_DATA_IN_HIGH PIN(LCD_DATA_HIGH_NBL) // Data Input Register high nibble
|
||||
#define LCD_DATA_OUT_HIGH PORT(LCD_DATA_HIGH_NBL) // Data Output Register - high nibble
|
||||
#define LCD_DATA_DIR_HIGH DDR(LCD_DATA_HIGH_NBL) // Data Direction Register for Data Port, high nibble
|
||||
|
||||
#define lcdDataOut(_val_) LCD_DATA_OUT(_val_)
|
||||
#define lcdDataDir(_val_) LCD_DATA_DIR(_val_)
|
||||
|
||||
// macros to handle data output
|
||||
#ifdef LCD_DATA_NIBBLES // data is split over two ports
|
||||
#define LCD_DATA_OUT(_val_) \
|
||||
LCD_DATA_OUT_LOW = (LCD_DATA_OUT_LOW & 0xF0)| (_val_ & 0x0F); LCD_DATA_OUT_HIGH = (LCD_DATA_OUT_HIGH & 0x0F)| (_val_ & 0xF0);
|
||||
|
||||
#define LCD_DATA_DIR(_val_)\
|
||||
LCD_DATA_DIR_LOW = (LCD_DATA_DIR_LOW & 0xF0)| (_val_ & 0x0F); LCD_DATA_DIR_HIGH = (LCD_DATA_DIR_HIGH & 0x0F)| (_val_ & 0xF0);
|
||||
#else // all data on same port (low equals high)
|
||||
#define LCD_DATA_OUT(_val_) LCD_DATA_OUT_LOW = (_val_);
|
||||
#define LCD_DATA_DIR(_val_) LCD_DATA_DIR_LOW = (_val_);
|
||||
#endif
|
||||
|
||||
|
||||
// Commands
|
||||
#ifdef HD44102
|
||||
#define LCD_ON 0x39
|
||||
#define LCD_OFF 0x38
|
||||
#define LCD_DISP_START 0x3E // Display start page 0
|
||||
#else
|
||||
#define LCD_ON 0x3F
|
||||
#define LCD_OFF 0x3E
|
||||
#define LCD_DISP_START 0xC0
|
||||
#endif
|
||||
|
||||
#define LCD_SET_ADD 0x40
|
||||
#define LCD_SET_PAGE 0xB8
|
||||
|
||||
#define LCD_BUSY_FLAG 0x80
|
||||
|
||||
// Colors
|
||||
#define BLACK 0xFF
|
||||
#define WHITE 0x00
|
||||
|
||||
// useful user contants
|
||||
#define NON_INVERTED false
|
||||
#define INVERTED true
|
||||
|
||||
// Font Indices
|
||||
#define FONT_LENGTH 0
|
||||
#define FONT_FIXED_WIDTH 2
|
||||
#define FONT_HEIGHT 3
|
||||
#define FONT_FIRST_CHAR 4
|
||||
#define FONT_CHAR_COUNT 5
|
||||
#define FONT_WIDTH_TABLE 6
|
||||
|
||||
|
||||
// Uncomment for slow drawing
|
||||
// #define DEBUG
|
||||
|
||||
typedef struct {
|
||||
uint8_t x;
|
||||
uint8_t y;
|
||||
uint8_t page;
|
||||
} lcdCoord;
|
||||
|
||||
typedef uint8_t (*FontCallback)(const uint8_t*);
|
||||
|
||||
uint8_t ReadPgmData(const uint8_t* ptr); //Standard Read Callback
|
||||
|
||||
#define DrawVertLine(x, y, length, color) FillRect(x, y, 0, length, color)
|
||||
#define DrawHoriLine(x, y, length, color) FillRect(x, y, length, 0, color)
|
||||
#define DrawCircle(xCenter, yCenter, radius, color) DrawRoundRect(xCenter-radius, yCenter-radius, 2*radius, 2*radius, radius, color)
|
||||
#define ClearScreenX() FillRect(0, 0, (DISPLAY_WIDTH-1), (DISPLAY_HEIGHT-1), WHITE)
|
||||
#define ClearSysTextLine(_line) FillRect(0, (line*8), (DISPLAY_WIDTH-1), ((line*8)+ 7), WHITE )
|
||||
|
||||
class ks0108 // shell class for ks0108 glcd code
|
||||
{
|
||||
private:
|
||||
lcdCoord Coord;
|
||||
boolean Inverted;
|
||||
FontCallback FontRead;
|
||||
uint8_t FontColor;
|
||||
const uint8_t* Font;
|
||||
uint8_t ReadData(void);
|
||||
uint8_t DoReadData(uint8_t first);
|
||||
void WriteCommand(uint8_t cmd, uint8_t chip);
|
||||
void WriteData(uint8_t data); // experts can make this public but the functionality is not documented
|
||||
inline void Enable(void);
|
||||
inline void SelectChip(uint8_t chip);
|
||||
void WaitReady( uint8_t chip);
|
||||
public:
|
||||
ks0108();
|
||||
// Control functions
|
||||
void Init(boolean invert);
|
||||
void GotoXY(uint8_t x, uint8_t y);
|
||||
// Graphic Functions
|
||||
void ClearPage(uint8_t page, uint8_t color);
|
||||
void ClearScreen(uint8_t color = WHITE);
|
||||
void DrawLine(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2, uint8_t color);
|
||||
void DrawRect(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t color);
|
||||
void DrawRoundRect(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t radius, uint8_t color);
|
||||
void FillRect(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t color);
|
||||
void InvertRect(uint8_t x, uint8_t y, uint8_t width, uint8_t height);
|
||||
void SetInverted(boolean invert);
|
||||
void SetDot(uint8_t x, uint8_t y, uint8_t color);
|
||||
void DrawBitmap(const uint8_t * bitmap, uint8_t x, uint8_t y, uint8_t color);
|
||||
|
||||
// Font Functions
|
||||
void SelectFont(const uint8_t* font, uint8_t color=BLACK, FontCallback callback=ReadPgmData); // defualt arguments added, callback now last arg
|
||||
int PutChar(char c);
|
||||
void Puts(char* str);
|
||||
void Puts_P(PGM_P str);
|
||||
void PrintNumber(long n);
|
||||
void CursorTo( uint8_t x, uint8_t y); // 0 based coordinates for fixed width fonts (i.e. systemFont5x7)
|
||||
|
||||
uint8_t CharWidth(char c);
|
||||
uint16_t StringWidth(char* str);
|
||||
uint16_t StringWidth_P(PGM_P str);
|
||||
};
|
||||
|
||||
extern ks0108 GLCD;
|
||||
#endif
|
||||
66
Micropendous/libs/arduino/libraries/ks0108/ks0108_Arduino.h
Normal file
66
Micropendous/libs/arduino/libraries/ks0108/ks0108_Arduino.h
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
ks0108_Arduino.h - Arduino library support for ks0108 and compatable graphic LCDs
|
||||
Copyright (c)2008 Michael Margolis All right reserved
|
||||
|
||||
This is the configuration file for mapping Arduino (ATmega168) pins to the ks0108 Graphics LCD library
|
||||
|
||||
*/
|
||||
|
||||
#ifndef KS0108_CONFIG_H
|
||||
#define KS0108_CONFIG_H
|
||||
|
||||
/*********************************************************/
|
||||
/* Configuration for assigning LCD bits to Arduino Pins */
|
||||
/*********************************************************/
|
||||
/* Arduino pins used for Commands
|
||||
* default assignment uses the first five analog pins
|
||||
*/
|
||||
|
||||
#define CSEL1 14 // CS1 Bit // swap pin assignments with CSEL2 if left/right image is reversed
|
||||
#define CSEL2 15 // CS2 Bit
|
||||
|
||||
#define R_W 16 // R/W Bit
|
||||
#define D_I 17 // D/I Bit
|
||||
#define EN 18 // EN Bit
|
||||
//#define RES 19 // Reset Bit // uncomment this to contol LCD reset on this pin
|
||||
|
||||
/* option: uncomment the next line if all command pins are on the same port for slight speed & code size improvement */
|
||||
#define LCD_CMD_PORT PORTC // Command Output Register for pins 14-19
|
||||
|
||||
/* Arduino pins used for LCD Data
|
||||
* un-comment ONE of the following pin options that corresponds to the wiring of data bits 0-3
|
||||
*/
|
||||
#define dataPins8to11 // bits 0-3 assigned to arduino pins 8-11, bits 4-7 assigned to arduino pins 4-7
|
||||
//#define dataPins14to17 //bits 0-3 assigned to arduino pins 14-17, bits 4-7 assigned to arduino pins 4-7. (note command pins must be changed)
|
||||
//#define dataPins0to3 // bits 0-3 assigned to arduino pins 0-3 , bits 4-7 assigned to arduino pins 4-7, this is marginally the fastest option but its only available on runtime board without hardware rs232.
|
||||
|
||||
/* NOTE: all above options assume LCD data bits 4-7 are connected to arduino pins 4-7 */
|
||||
|
||||
/*******************************************************/
|
||||
/* end of Arduino configuration */
|
||||
/*******************************************************/
|
||||
|
||||
#ifndef dataPins0to3 // this is the only option on standard arduino where all data bits are on same port
|
||||
#define LCD_DATA_NIBBLES // if this is defined then data i/o is split into two operations
|
||||
#endif
|
||||
|
||||
// these macros map pins to ports using the defines above
|
||||
// the following should not be changed unless you really know what your doing
|
||||
#ifdef dataPins0to3
|
||||
#define LCD_DATA_LOW_NBL D // port for low nibble: D=pins 0-3
|
||||
#endif
|
||||
#ifdef dataPins14to17
|
||||
#define LCD_DATA_LOW_NBL C // port for low nibble: C=pins 14-17 (using this requires reasignment of command pins)
|
||||
#endif
|
||||
#ifdef dataPins8to11 // the following is the defualt setting
|
||||
#define LCD_DATA_LOW_NBL B // port for low nibble, B=pins 8-11
|
||||
#endif
|
||||
|
||||
#define LCD_DATA_HIGH_NBL D // port for high nibble: D=pins 4-7, B & C not available on std arduino
|
||||
|
||||
// macros to fast write data to pins known at compile time, this is over 30 times faster than digitalWrite
|
||||
#define fastWriteHigh(_pin_) ( _pin_ < 8 ? PORTD |= 1 << (_pin_ & 0x07) : ( _pin_ < 14 ? PORTB |= 1 << ((_pin_ -8) & 0x07) : PORTC |= 1 << ((_pin_ -14) & 0x07) ) )
|
||||
#define fastWriteLow(_pin_) ( _pin_ < 8 ? PORTD &= ~(1 << (_pin_ & 0x07)) : ( _pin_ < 14 ? PORTB &= ~(1 << ((_pin_ -8) & 0x07) ) : PORTC &= ~(1 << ((_pin_ -14) & 0x07) ) ) )
|
||||
|
||||
|
||||
#endif
|
||||
43
Micropendous/libs/arduino/libraries/ks0108/ks0108_Mega.h
Normal file
43
Micropendous/libs/arduino/libraries/ks0108/ks0108_Mega.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
ks0108_Arduino.h - Arduino library support for ks0108 and compatable graphic LCDs
|
||||
Copyright (c)2008 Michael Margolis All right reserved
|
||||
|
||||
This is the configuration file for mapping Arduino (ATmega168) pins to the ks0108 Graphics LCD library
|
||||
|
||||
*/
|
||||
|
||||
#ifndef KS0108_CONFIG_H
|
||||
#define KS0108_CONFIG_H
|
||||
|
||||
/*********************************************************/
|
||||
/* Configuration for assigning LCD bits to Arduino Pins */
|
||||
/*********************************************************/
|
||||
/* Arduino pins used for Commands - these must be within the range of 30-37
|
||||
*/
|
||||
|
||||
#define CSEL1 33 // CS1 Bit // swap pin assignments with CSEL2 if left/right image is reversed
|
||||
#define CSEL2 34 // CS2 Bit
|
||||
#define R_W 35 // R/W Bit
|
||||
#define D_I 36 // D/I Bit
|
||||
#define EN 37 // EN Bit
|
||||
|
||||
#define LCD_CMD_PORT PORTC // Command Output Register for pins 30-37
|
||||
|
||||
/* This version uses pins 22-29 for LCD Data */
|
||||
|
||||
/*******************************************************/
|
||||
/* end of Arduino configuration */
|
||||
/*******************************************************/
|
||||
|
||||
|
||||
// these macros map pins to ports using the defines above
|
||||
// the following should not be changed unless you really know what your doing
|
||||
#define LCD_DATA_LOW_NBL A // port for low nibble: A=pins 22-25
|
||||
#define LCD_DATA_HIGH_NBL A // port for high nibble: A=pins 26-29
|
||||
|
||||
// macros to fast write data to pins 30 - 37
|
||||
#define fastWriteHigh(_pin) (PORTC |= 1 << ((7-(_pin -30)) & 0x07))
|
||||
#define fastWriteLow(_pin) (PORTC &= ~(1 << ((7-(_pin -30)) & 0x07)))
|
||||
|
||||
|
||||
#endif
|
||||
41
Micropendous/libs/arduino/libraries/ks0108/ks0108_Panel.h
Normal file
41
Micropendous/libs/arduino/libraries/ks0108/ks0108_Panel.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
ks0108_Panel.h - Arduino library support for ks0108 and compatable graphic LCDs
|
||||
Copyright (c)2008 Michael Margolis All right reserved
|
||||
|
||||
This is the configuration file for LCD panel specific configuration
|
||||
|
||||
*/
|
||||
|
||||
#ifndef KS0108_PANEL_H
|
||||
#define KS0108_PANEL_H
|
||||
|
||||
/*********************************************************/
|
||||
/* Configuration for LCD panel specific configuration */
|
||||
/*********************************************************/
|
||||
#define DISPLAY_WIDTH 128
|
||||
#define DISPLAY_HEIGHT 64
|
||||
|
||||
// panel controller chips
|
||||
#define CHIP_WIDTH 64 // pixels per chip
|
||||
|
||||
// you can swap around the elements below if your display is reversed
|
||||
#ifdef ksSOURCE
|
||||
|
||||
#if (DISPLAY_WIDTH / CHIP_WIDTH == 2)
|
||||
byte chipSelect[] = {1,2}; // this is for 128 pixel displays
|
||||
#elif (DISPLAY_WIDTH / CHIP_WIDTH == 3)
|
||||
//byte chipSelect[] = {0, 1, 2}; // this is for 192 pixel displays
|
||||
byte chipSelect[] = {0, 2, 1}; // this is for 192 pixel displays on sanguino only
|
||||
#endif
|
||||
|
||||
#if (DISPLAY_WIDTH / CHIP_WIDTH == 2)
|
||||
#define DisableController(chip) fastWriteLow(CSEL1); fastWriteLow(CSEL2); // disable for 128 pixel panels
|
||||
#else
|
||||
#define DisableController(chip) fastWriteHigh(CSEL1); fastWriteHigh(CSEL2); // disable for 192 pixel panels
|
||||
#endif
|
||||
|
||||
#define EN_DELAY_VALUE 6 // this is the delay value that may need to be hand tuned for slow panels
|
||||
|
||||
#endif // ksSource defined to expose chipSelect only to cpp file
|
||||
|
||||
#endif
|
||||
59
Micropendous/libs/arduino/libraries/ks0108/ks0108_Sanguino.h
Normal file
59
Micropendous/libs/arduino/libraries/ks0108/ks0108_Sanguino.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
ks0108_Sanguino.h - Arduino library support for ks0108 and compatable graphic LCDs
|
||||
Copyright (c)2008 Michael Margolis All right reserved
|
||||
|
||||
This is the configuration file for mapping Sanguino (ATmega644) pins to the ks0108 Graphics LCD library
|
||||
*/
|
||||
|
||||
#ifndef KS0108_CONFIG_H
|
||||
#define KS0108_CONFIG_H
|
||||
|
||||
#define SANGUINO644
|
||||
/*******************************************************************************************/
|
||||
/* Sanguino/ ATmega644 defines */
|
||||
/*******************************************************************************************/
|
||||
// Command pins assignments:
|
||||
#define CSEL1 24 // CS1 Bit // swap pin assignments with CSEL2 if left/right image is reversed
|
||||
#define CSEL2 25 // CS2 Bit
|
||||
#define R_W 26 // R/W Bit
|
||||
#define D_I 27 // D/I Bit
|
||||
#define EN 28 // EN Bit
|
||||
|
||||
//all command pins are on the same port for slight speed & code size improvement
|
||||
#define LCD_CMD_PORT PORTC // Command Output Register for pins 16-23
|
||||
|
||||
// data pin assignments- on ATmega644 all data pins are assigned to the same port
|
||||
#define dataPins0to7 // bits 0-7 assigned to sanguino pins 0-7
|
||||
//#define dataPins8to15 // bits 0-7 assigned to sanguino pins 8-15 // note this conflicts with serial UART
|
||||
//#define dataPins16to23 // bits 0-7 assigned to sanguino pins 16-23
|
||||
//#define dataPins24to31 // bits 0-7 assigned to sanguino pins 24-31
|
||||
|
||||
/*******************************************************/
|
||||
/* end of Sanguino configuration */
|
||||
/*******************************************************/
|
||||
|
||||
// these macros map pins to ports using the defines above
|
||||
// the following should not be changed unless you really know what your doing
|
||||
#ifdef dataPins0to7
|
||||
#define LCD_DATA_LOW_NBL B // port B=pins 0-7 on ATmega466
|
||||
#define LCD_DATA_HIGH_NBL B // on ATmega644, high and low nibbles are on the same port
|
||||
#endif
|
||||
#ifdef dataPins8to15
|
||||
#define LCD_DATA_LOW_NBL D // port D=pins 8-15 (note serial UART uses 8 and 9)
|
||||
#define LCD_DATA_HIGH_NBL D
|
||||
#endif
|
||||
#ifdef dataPins16to23
|
||||
#define LCD_DATA_LOW_NBL C // port C=pins 16-23
|
||||
#define LCD_DATA_HIGH_NBL C
|
||||
#endif
|
||||
#ifdef dataPins24to31
|
||||
#define LCD_DATA_LOW_NBL A // port A=pins 24-31 (note these are the analog ports)
|
||||
#define LCD_DATA_HIGH_NBL A
|
||||
#endif
|
||||
|
||||
|
||||
// ATmega644 macros to fast write data to pins, this version only works for pins 0-23
|
||||
#define fastWriteHigh(_pin_) ( _pin_ < 8 ? PORTB |= 1 << (_pin_ & 0x07) : ( _pin_ < 16 ? PORTD |= 1 << ((_pin_ -8) & 0x07) : PORTC |= 1 << ((_pin_ -16) & 0x07) ) )
|
||||
#define fastWriteLow(_pin_) ( _pin_ < 8 ? PORTB &= ~(1 << (_pin_ & 0x07)) : ( _pin_ < 16 ? PORTD &= ~(1 << ((_pin_ -8) & 0x07) ) : PORTC &= ~(1 << ((_pin_ -16) & 0x07) ) ) )
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
ks0108_Arduino.h - Arduino library support for ks0108 and compatable graphic LCDs
|
||||
Copyright (c)2008 Michael Margolis All right reserved
|
||||
|
||||
This is the configuration file for mapping Arduino (ATmega168) pins to the ks0108 Graphics LCD library
|
||||
|
||||
*/
|
||||
|
||||
#ifndef KS0108_CONFIG_H
|
||||
#define KS0108_CONFIG_H
|
||||
|
||||
/*********************************************************/
|
||||
/* Configuration for assigning LCD bits to Arduino Pins */
|
||||
/*********************************************************/
|
||||
/* Arduino pins used for Commands - these must be within the range of 30-37
|
||||
*/
|
||||
|
||||
#define CSEL1 10 // CS1 Bit // swap pin assignments with CSEL2 if left/right image is reversed
|
||||
#define CSEL2 11 // CS2 Bit
|
||||
#define R_W 12 // R/W Bit
|
||||
#define D_I 13 // D/I Bit
|
||||
#define EN 14 // EN Bit
|
||||
|
||||
#define LCD_CMD_PORT PORTB // Command Output Register for pins 30-37
|
||||
|
||||
/* This version uses pins 22-29 for LCD Data */
|
||||
|
||||
/*******************************************************/
|
||||
/* end of Arduino configuration */
|
||||
/*******************************************************/
|
||||
|
||||
|
||||
// these macros map pins to ports using the defines above
|
||||
// the following should not be changed unless you really know what your doing
|
||||
#define LCD_DATA_LOW_NBL A // port for low nibble: A=pins 22-25
|
||||
#define LCD_DATA_HIGH_NBL A // port for high nibble: A=pins 26-29
|
||||
|
||||
// macros to fast write data to pins 30 - 37
|
||||
#define fastWriteHigh(_pin) (PORTC |= 1 << ((7-(_pin -30)) & 0x07))
|
||||
#define fastWriteLow(_pin) (PORTC &= ~(1 << ((7-(_pin -30)) & 0x07)))
|
||||
|
||||
|
||||
#endif
|
||||
78
Micropendous/libs/arduino/libraries/ks0108/readme.txt
Normal file
78
Micropendous/libs/arduino/libraries/ks0108/readme.txt
Normal file
@@ -0,0 +1,78 @@
|
||||
Installation
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
To install this library, just place this entire folder as a subfolder in your
|
||||
Arduino hardware/libraries folder.
|
||||
|
||||
When installed, this library should look like:
|
||||
|
||||
Arduino/hardware/libraries/ks0108 (this library's folder)
|
||||
Arduino/hardware/libraries/ks0108/ks0108.cpp (the library implementation file)
|
||||
Arduino/hardware/libraries/ks0108/ks0108.h (the library header file)
|
||||
Arduino/hardware/libraries/ks0108/ks0108_Panel.h (the Panel configuration header)
|
||||
Arduino/hardware/libraries/ks0108/ks0108_Arduino.h (header used to define pins for Atmega168/328)
|
||||
Arduino/hardware/libraries/ks0108/ks0108_Mega.h (header used to define pins for Mega)
|
||||
Arduino/hardware/libraries/ks0108/ks0108_Sanguino.h (header used to define pins for Sanguino) - untested
|
||||
Arduino/hardware/libraries/ks0108/SystemFont5x7.h (definition for 5x7 system fonmt)
|
||||
Arduino/hardware/libraries/ks0108/Arial14.h (the definition for 14 point Arial Font)
|
||||
Arduino/hardware/libraries/ks0108/keywords.txt (the syntax coloring file)
|
||||
Arduino/hardware/libraries/ks0108/examples (diectory containing the example test sketch)
|
||||
Arduino/hardware/libraries/ks0108/readme.txt (this file)
|
||||
|
||||
Building
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
After the files are copied into your library directory, check the wiring matches the pin configuration
|
||||
for your board. The defualt wiring is different for each of the three chip types:
|
||||
(see http://www.arduino.cc/playground/Code/GLCDks0108 for more info)
|
||||
|
||||
|
||||
ATmega168/328 uses configuration file: ks0108_Arduino.h
|
||||
LCD ARDUINO
|
||||
CSEL1 14 // CS1 Bit // swap with CSEL2 if left/right is reversed
|
||||
CSEL2 15 // CS2 Bit
|
||||
R_W 16 // R/W Bit
|
||||
D_I 17 // D/I Bit
|
||||
EN 18 // EN Bit
|
||||
|
||||
LCD data 0-3 8-11
|
||||
LCD data 4-7 4-7
|
||||
|
||||
Mega (ATmega1280) uses configuration file: ks0108_Mega.h
|
||||
|
||||
CSEL1 33 // CS1 Bit // swap with CSEL2 if left/right is reversed
|
||||
CSEL2 34 // CS2 Bit
|
||||
R_W 35 // R/W Bit
|
||||
D_I 36 // D/I Bit
|
||||
EN 37 // EN Bit
|
||||
|
||||
LCD data 0-7 22-29
|
||||
|
||||
Sanguino (ATmega644) uses configuration file: ks0108_Sanguino.h
|
||||
CSEL1 24 // CS1 Bit // swap pin assignments with CSEL2 if left/right image is reversed
|
||||
CSEL2 25 // CS2 Bit
|
||||
R_W 26 // R/W Bit
|
||||
D_I 27 // D/I Bit
|
||||
EN 28 // EN Bit
|
||||
|
||||
LCD data 0-7 16-23
|
||||
|
||||
Slow panels may need delays added to the panel panel configuraion file: ks0108_Panel.h
|
||||
change the number 6 to a higher number to make th delay longer :
|
||||
#define EN_DELAY_VALUE 6 // this is the delay value that may need to be hand tuned for slow panels
|
||||
If your panel has a different width or height you can change these two constants in this file:
|
||||
#define DISPLAY_WIDTH 128
|
||||
#define DISPLAY_HEIGHT 64
|
||||
|
||||
After a successful build of this library, a new file named 'ks0108.o' will appear
|
||||
in ks0108 library directory. If you make any changes to any of the files in the
|
||||
ks0108 directory you must delete ks0108.o before recompiling your sketch for the changes to be
|
||||
recognized by your sketch. The new "Test.o" with your code will appear after the next
|
||||
verify or compile (If there are no syntax errors in the changed code).
|
||||
|
||||
To use the library in a sketch, go to the Sketch | Import Library menu and
|
||||
select ks0108. This will add a corresponding line to the top of your sketch:
|
||||
#include <ks0108.h>. It will also add lines for all the font definitions you have
|
||||
in the ks0108 library directory. You should remove the includes for any fonts you
|
||||
don't use in a sketch, they use a lot of program memory.
|
||||
|
||||
Reference in New Issue
Block a user