Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
b41667b8
Unverified
Commit
b41667b8
authored
Sep 15, 2018
by
Marcel Stör
Committed by
GitHub
Sep 15, 2018
Browse files
Master drop #2486
Dev -> Master Release 10
parents
f99f295d
0abb2617
Changes
235
Show whitespace changes
Inline
Side-by-side
app/u8glib/u8g_com_api_16gr.c
deleted
100644 → 0
View file @
f99f295d
/*
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
;
}
app/u8glib/u8g_com_i2c.c
deleted
100644 → 0
View file @
f99f295d
/*
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"
//#define U8G_I2C_WITH_NO_ACK
static
uint8_t
u8g_i2c_err_code
;
static
uint8_t
u8g_i2c_opt
;
/* U8G_I2C_OPT_NO_ACK, SAM: U8G_I2C_OPT_DEV_1 */
/*
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
;
}
#if defined(__AVR_XMEGA__)
#elif defined(__AVR__)
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
;
}
#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
TWBR = 12;
TWSR = 0;
--> 400KHz
F_CPU/(2*100000)-8 --> calculate TWBR value for 100KHz
*/
u8g_i2c_opt
=
options
;
TWSR
=
0
;
if
(
options
&
U8G_I2C_OPT_FAST
)
{
TWBR
=
F_CPU
/
(
2
*
400000
)
-
8
;
}
else
{
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
)
{
if
(
u8g_i2c_opt
&
U8G_I2C_OPT_NO_ACK
)
{
return
1
;
/* all ok */
}
else
{
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
;
if
(
u8g_i2c_opt
&
U8G_I2C_OPT_NO_ACK
)
{
/* do not check for ACK */
}
else
{
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
;
if
(
u8g_i2c_opt
&
U8G_I2C_OPT_NO_ACK
)
{
/* do not check for ACK */
}
else
{
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();
}
*/
#elif defined(ARDUINO) && defined(__SAM3X8E__)
/* Arduino Due */
#include "Arduino.h"
#include "sam.h"
/*
Controller
TWI0 TWCK0 PA18 A DUE PCB: SCL1
TWI0 TWD0 PA17 A DUE PCB: SDA1
TWI1 TWCK1 PB13 A DUE PCB: SCL 21
TWI1 TWD1 PB12 A DUE PCB: SDA 20
Arduino definitions
#define PIN_WIRE_SDA (20u)
#define PIN_WIRE_SCL (21u)
#define WIRE_INTERFACE TWI1
#define WIRE_INTERFACE_ID ID_TWI1
#define WIRE_ISR_HANDLER TWI1_Handler
#define PIN_WIRE1_SDA (70u)
#define PIN_WIRE1_SCL (71u)
#define WIRE1_INTERFACE TWI0
#define WIRE1_INTERFACE_ID ID_TWI0
#define WIRE1_ISR_HANDLER TWI0_Handler
*/
static
void
i2c_400KHz_delay
(
void
)
{
/* should be at least 4 */
/* should be 5 for 100KHz transfer speed */
/*
Arduino Due
0x NOP: 470KHz
4x NOP: 450KHz
8x NOP: 430KHz
16x NOP: 400KHz
*/
__NOP
();
__NOP
();
__NOP
();
__NOP
();
__NOP
();
__NOP
();
__NOP
();
__NOP
();
__NOP
();
__NOP
();
__NOP
();
__NOP
();
__NOP
();
__NOP
();
__NOP
();
__NOP
();
}
static
void
i2c_100KHz_delay
(
void
)
{
/*
1x u8g_MicroDelay() ca. 130KHz
2x u8g_MicroDelay() ca. 80KHz
*/
u8g_MicroDelay
();
u8g_MicroDelay
();
}
uint32_t
i2c_started
=
0
;
uint32_t
i2c_scl_pin
=
0
;
uint32_t
i2c_sda_pin
=
0
;
void
(
*
i2c_delay
)(
void
)
=
i2c_100KHz_delay
;
const
PinDescription
*
i2c_scl_pin_desc
;
const
PinDescription
*
i2c_sda_pin_desc
;
/* maybe this can be optimized */
static
void
i2c_init
(
void
)
{
i2c_sda_pin_desc
=
&
(
g_APinDescription
[
i2c_sda_pin
]);
i2c_scl_pin_desc
=
&
(
g_APinDescription
[
i2c_scl_pin
]);
pinMode
(
i2c_sda_pin
,
OUTPUT
);
digitalWrite
(
i2c_sda_pin
,
HIGH
);
pinMode
(
i2c_scl_pin
,
OUTPUT
);
digitalWrite
(
i2c_scl_pin
,
HIGH
);
PIO_Configure
(
i2c_sda_pin_desc
->
pPort
,
PIO_OUTPUT_0
,
i2c_sda_pin_desc
->
ulPin
,
PIO_OPENDRAIN
);
PIO_Configure
(
i2c_scl_pin_desc
->
pPort
,
PIO_OUTPUT_0
,
i2c_scl_pin_desc
->
ulPin
,
PIO_OPENDRAIN
);
PIO_Clear
(
i2c_sda_pin_desc
->
pPort
,
i2c_sda_pin_desc
->
ulPin
)
;
PIO_Clear
(
i2c_scl_pin_desc
->
pPort
,
i2c_scl_pin_desc
->
ulPin
)
;
PIO_Configure
(
i2c_sda_pin_desc
->
pPort
,
PIO_INPUT
,
i2c_sda_pin_desc
->
ulPin
,
PIO_DEFAULT
)
;
PIO_Configure
(
i2c_scl_pin_desc
->
pPort
,
PIO_INPUT
,
i2c_scl_pin_desc
->
ulPin
,
PIO_DEFAULT
)
;
i2c_delay
();
}
/* actually, the scl line is not observed, so this procedure does not return a value */
static
void
i2c_read_scl_and_delay
(
void
)
{
uint32_t
dwMask
=
i2c_scl_pin_desc
->
ulPin
;
//PIO_Configure( i2c_scl_pin_desc->pPort, PIO_INPUT, i2c_scl_pin_desc->ulPin, PIO_DEFAULT ) ;
//PIO_SetInput( i2c_scl_pin_desc->pPort, i2c_scl_pin_desc->ulPin, PIO_DEFAULT ) ;
/* set as input */
i2c_scl_pin_desc
->
pPort
->
PIO_ODR
=
dwMask
;
i2c_scl_pin_desc
->
pPort
->
PIO_PER
=
dwMask
;
i2c_delay
();
}
static
void
i2c_clear_scl
(
void
)
{
uint32_t
dwMask
=
i2c_scl_pin_desc
->
ulPin
;
/* set open collector and drive low */
//PIO_Configure( i2c_scl_pin_desc->pPort, PIO_OUTPUT_0, i2c_scl_pin_desc->ulPin, PIO_OPENDRAIN );
//PIO_SetOutput( i2c_scl_pin_desc->pPort, i2c_scl_pin_desc->ulPin, 0, 1, 0);
/* open drain, zero default output */
i2c_scl_pin_desc
->
pPort
->
PIO_MDER
=
dwMask
;
i2c_scl_pin_desc
->
pPort
->
PIO_CODR
=
dwMask
;
i2c_scl_pin_desc
->
pPort
->
PIO_OER
=
dwMask
;
i2c_scl_pin_desc
->
pPort
->
PIO_PER
=
dwMask
;
//PIO_Clear( i2c_scl_pin_desc->pPort, i2c_scl_pin_desc->ulPin) ;
}
static
uint8_t
i2c_read_sda
(
void
)
{
uint32_t
dwMask
=
i2c_sda_pin_desc
->
ulPin
;
//PIO_Configure( i2c_sda_pin_desc->pPort, PIO_INPUT, i2c_sda_pin_desc->ulPin, PIO_DEFAULT ) ;
//PIO_SetInput( i2c_sda_pin_desc->pPort, i2c_sda_pin_desc->ulPin, PIO_DEFAULT ) ;
/* set as input */
i2c_sda_pin_desc
->
pPort
->
PIO_ODR
=
dwMask
;
i2c_sda_pin_desc
->
pPort
->
PIO_PER
=
dwMask
;
return
1
;
}
static
void
i2c_clear_sda
(
void
)
{
uint32_t
dwMask
=
i2c_sda_pin_desc
->
ulPin
;
/* set open collector and drive low */
//PIO_Configure( i2c_sda_pin_desc->pPort, PIO_OUTPUT_0, i2c_sda_pin_desc->ulPin, PIO_OPENDRAIN );
//PIO_SetOutput( i2c_sda_pin_desc->pPort, i2c_sda_pin_desc->ulPin, 0, 1, 0);
/* open drain, zero default output */
i2c_sda_pin_desc
->
pPort
->
PIO_MDER
=
dwMask
;
i2c_sda_pin_desc
->
pPort
->
PIO_CODR
=
dwMask
;
i2c_sda_pin_desc
->
pPort
->
PIO_OER
=
dwMask
;
i2c_sda_pin_desc
->
pPort
->
PIO_PER
=
dwMask
;
//PIO_Clear( i2c_sda_pin_desc->pPort, i2c_sda_pin_desc->ulPin) ;
}
static
void
i2c_start
(
void
)
{
if
(
i2c_started
!=
0
)
{
/* if already started: do restart */
i2c_read_sda
();
/* SDA = 1 */
i2c_delay
();
i2c_read_scl_and_delay
();
}
i2c_read_sda
();
/*
if (i2c_read_sda() == 0)
{
// do something because arbitration is lost
}
*/
/* send the start condition, both lines go from 1 to 0 */
i2c_clear_sda
();
i2c_delay
();
i2c_clear_scl
();
i2c_started
=
1
;
}
static
void
i2c_stop
(
void
)
{
/* set SDA to 0 */
i2c_clear_sda
();
i2c_delay
();
/* now release all lines */
i2c_read_scl_and_delay
();
/* set SDA to 1 */
i2c_read_sda
();
i2c_delay
();
i2c_started
=
0
;
}
static
void
i2c_write_bit
(
uint8_t
val
)
{
if
(
val
)
i2c_read_sda
();
else
i2c_clear_sda
();
i2c_delay
();
i2c_read_scl_and_delay
();
i2c_clear_scl
();
}
static
uint8_t
i2c_read_bit
(
void
)
{
uint8_t
val
;
/* do not drive SDA */
i2c_read_sda
();
i2c_delay
();
i2c_read_scl_and_delay
();
val
=
i2c_read_sda
();
i2c_delay
();
i2c_clear_scl
();
return
val
;
}
static
uint8_t
i2c_write_byte
(
uint8_t
b
)
{
i2c_write_bit
(
b
&
128
);
i2c_write_bit
(
b
&
64
);
i2c_write_bit
(
b
&
32
);
i2c_write_bit
(
b
&
16
);
i2c_write_bit
(
b
&
8
);
i2c_write_bit
(
b
&
4
);
i2c_write_bit
(
b
&
2
);
i2c_write_bit
(
b
&
1
);
/* read ack from client */
/* 0: ack was given by client */
/* 1: nothing happend during ack cycle */
return
i2c_read_bit
();
}
void
u8g_i2c_init
(
uint8_t
options
)
{
u8g_i2c_opt
=
options
;
u8g_i2c_clear_error
();
if
(
u8g_i2c_opt
&
U8G_I2C_OPT_FAST
)
{
i2c_delay
=
i2c_400KHz_delay
;
}
else
{
i2c_delay
=
i2c_100KHz_delay
;
}
if
(
u8g_i2c_opt
&
U8G_I2C_OPT_DEV_1
)
{
i2c_scl_pin
=
PIN_WIRE1_SCL
;
i2c_sda_pin
=
PIN_WIRE1_SDA
;
//REG_PIOA_PDR = PIO_PB12A_TWD1 | PIO_PB13A_TWCK1;
}
else
{
i2c_scl_pin
=
PIN_WIRE_SCL
;
i2c_sda_pin
=
PIN_WIRE_SDA
;
//REG_PIOA_PDR = PIO_PA17A_TWD0 | PIO_PA18A_TWCK0;
}
i2c_init
();
}
/* sla includes also the r/w bit */
uint8_t
u8g_i2c_start
(
uint8_t
sla
)
{
i2c_start
();
i2c_write_byte
(
sla
);
return
1
;
}
uint8_t
u8g_i2c_send_byte
(
uint8_t
data
)
{
return
i2c_write_byte
(
data
);
}
void
u8g_i2c_stop
(
void
)
{
i2c_stop
();
}
#elif defined(U8G_RASPBERRY_PI)
#include <wiringPi.h>
#include <wiringPiI2C.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#define I2C_SLA 0x3c
static
int
fd
=-
1
;
static
uint8_t
i2cMode
=
0
;
void
u8g_i2c_init
(
uint8_t
options
)
{
u8g_i2c_clear_error
();
u8g_i2c_opt
=
options
;
if
(
wiringPiSetup
()
==
-
1
)
{
printf
(
"wiringPi-Error
\n
"
);
exit
(
1
);
}
fd
=
wiringPiI2CSetup
(
I2C_SLA
);
if
(
fd
<
0
)
{
printf
(
"Unable to open I2C device 0: %s
\n
"
,
strerror
(
errno
))
;
exit
(
1
)
;
}
//u8g_SetPIOutput(u8g, U8G_PI_RESET);
//u8g_SetPIOutput(u8g, U8G_PI_A0);
}
uint8_t
u8g_i2c_start
(
uint8_t
sla
)
{
u8g_i2c_send_mode
(
0
);
return
1
;
}
void
u8g_i2c_stop
(
void
)
{
}
uint8_t
u8g_i2c_send_mode
(
uint8_t
mode
)
{
i2cMode
=
mode
;
}
uint8_t
u8g_i2c_send_byte
(
uint8_t
data
)
{
wiringPiI2CWriteReg8
(
fd
,
i2cMode
,
data
);
return
1
;
}
uint8_t
u8g_i2c_wait
(
uint8_t
mask
,
uint8_t
pos
)
{
return
1
;
}
#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
app/u8glib/u8g_com_io.c
deleted
100644 → 0
View file @
f99f295d
/*
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.
Update for ATOMIC operation done (01 Jun 2013)
U8G_ATOMIC_OR(ptr, val)
U8G_ATOMIC_AND(ptr, val)
U8G_ATOMIC_START();
U8G_ATOMIC_END();
uint8_t u8g_Pin(uint8_t port, uint8_t bitpos) Convert to internal number: AVR: port*8+bitpos, ARM: port*16+bitpos
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)
*/
#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
;
}
#if defined(__AVR_XMEGA__)
const
IO_PTR
u8g_avr_ddr_P
[]
PROGMEM
=
{
#ifdef PORTA
&
PORTA
.
DIR
,
#else
0
,
#endif
&
PORTB
.
DIR
,
#ifdef PORTC
&
PORTC
.
DIR
,
#ifdef PORTD
&
PORTD
.
DIR
,
#ifdef PORTE
&
PORTE
.
DIR
,
#ifdef PORTF
&
PORTF
.
DIR
,
#ifdef PORTR
&
PORTR
.
DIR
,
#endif
#endif
#endif
#endif
#endif
};
const
IO_PTR
u8g_avr_port_P
[]
PROGMEM
=
{
#ifdef PORTA
&
PORTA
.
OUT
,
#else
0
,
#endif
&
PORTB
.
OUT
,
#ifdef PORTC
&
PORTC
.
OUT
,
#ifdef PORTD
&
PORTD
.
OUT
,
#ifdef PORTE
&
PORTE
.
OUT
,
#ifdef PORTF
&
PORTF
.
OUT
,
#ifdef PORTR
&
PORTR
.
OUT
,
#endif
#endif
#endif
#endif
#endif
};
const
IO_PTR
u8g_avr_pin_P
[]
PROGMEM
=
{
#ifdef PORTA
&
PORTA
.
IN
,
#else
0
,
#endif
&
PORTB
.
IN
,
#ifdef PORTC
&
PORTC
.
IN
,
#ifdef PORTD
&
PORTD
.
IN
,
#ifdef PORTE
&
PORTE
.
IN
,
#ifdef PORTF
&
PORTF
.
IN
,
#ifdef PORTR
&
PORTR
.
IN
,
#endif
#endif
#endif
#endif
#endif
};
#else
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
};
#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
)
{
U8G_ATOMIC_AND
(
tmp
,
~
_BV
(
internal_pin_number
&
7
));
// *tmp &= ~_BV(internal_pin_number&7);
}
else
{
U8G_ATOMIC_OR
(
tmp
,
_BV
(
internal_pin_number
&
7
));
//*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
;
}
#elif defined (__MSP430__)
#include <msp430.h>
typedef
volatile
uint8_t
*
IO_PTR
;
// MSP430 F5XXX / F6XXX series.
const
IO_PTR
u8g_msp_ddr_P
[]
PROGMEM
=
{
&
P1DIR
,
&
P2DIR
,
&
P3DIR
,
&
P4DIR
,
&
P5DIR
,
&
P6DIR
,
&
P7DIR
,
&
P8DIR
#if defined (__MSP430_HAS_PORT9_R__)
,
&
P9DIR
#if defined (__MSP430_HAS_PORT10_R__)
,
&
P10DIR
#endif
#endif
};
const
IO_PTR
u8g_msp_port_P
[]
PROGMEM
=
{
&
P1OUT
,
&
P2OUT
,
&
P3OUT
,
&
P4OUT
,
&
P5OUT
,
&
P6OUT
,
&
P7OUT
,
&
P8OUT
#if defined (__MSP430_HAS_PORT9_R__)
,
&
P9OUT
#if defined (__MSP430_HAS_PORT10_R__)
,
&
P10OUT
#endif
#endif
};
const
IO_PTR
u8g_msp_pin_P
[]
PROGMEM
=
{
&
P1IN
,
&
P2IN
,
&
P3IN
,
&
P4IN
,
&
P5IN
,
&
P6IN
,
&
P7IN
,
&
P8IN
#if defined (__MSP430_HAS_PORT9_R__)
,
&
P9IN
#if defined (__MSP430_HAS_PORT10_R__)
,
&
P10IN
#endif
#endif
};
uint8_t
u8g_Pin
(
uint8_t
port
,
uint8_t
bitpos
)
{
port
<<=
3
;
port
+=
bitpos
;
return
port
;
}
void
u8g_SetPinOutput
(
uint8_t
internal_pin_number
)
{
uint8_t
port
=
(
internal_pin_number
>>
3
)
-
1
;
uint8_t
output
=
1
<<
(
internal_pin_number
&
0x07
);
*
u8g_msp_ddr_P
[
port
]
|=
output
;
}
void
u8g_SetPinInput
(
uint8_t
internal_pin_number
)
{
uint8_t
port
=
(
internal_pin_number
>>
3
)
-
1
;
*
u8g_msp_ddr_P
[
port
]
&=
~
(
1
<<
(
internal_pin_number
&
0x07
));
}
void
u8g_SetPinLevel
(
uint8_t
internal_pin_number
,
uint8_t
level
)
{
uint8_t
port
=
(
internal_pin_number
>>
3
)
-
1
;
if
(
level
==
0
)
{
*
u8g_msp_port_P
[
port
]
&=
~
(
1
<<
(
internal_pin_number
&
0x07
));
}
else
{
*
u8g_msp_port_P
[
port
]
|=
(
1
<<
(
internal_pin_number
&
0x07
));
}
}
uint8_t
u8g_GetPinLevel
(
uint8_t
internal_pin_number
)
{
uint8_t
port
=
(
internal_pin_number
>>
3
)
-
1
;
uint8_t
tmp
=
*
u8g_msp_pin_P
[
port
];
if
(
tmp
&
(
1
<<
(
internal_pin_number
&
0x07
)))
{
return
1
;
}
return
0
;
}
#elif defined(U8G_RASPBERRY_PI)
#include <wiringPi.h>
//#include "/usr/local/include/wiringPi.h"
void
u8g_SetPinOutput
(
uint8_t
internal_pin_number
)
{
pinMode
(
internal_pin_number
,
OUTPUT
);
}
void
u8g_SetPinInput
(
uint8_t
internal_pin_number
)
{
pinMode
(
internal_pin_number
,
INPUT
);
}
void
u8g_SetPinLevel
(
uint8_t
internal_pin_number
,
uint8_t
level
)
{
digitalWrite
(
internal_pin_number
,
level
);
}
uint8_t
u8g_GetPinLevel
(
uint8_t
internal_pin_number
)
{
return
digitalRead
(
internal_pin_number
);
}
#else
/* convert "port" and "bitpos" to internal pin number */
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
#if defined(U8G_WITH_PINLIST)
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
);
}
#else
/* defined(U8G_WITH_PINLIST) */
void
u8g_SetPIOutput
(
u8g_t
*
u8g
,
uint8_t
pi
)
{
}
void
u8g_SetPILevel
(
u8g_t
*
u8g
,
uint8_t
pi
,
uint8_t
level
)
{
}
#endif
/* defined(U8G_WITH_PINLIST) */
app/u8glib/u8g_com_null.c
deleted
100644 → 0
View file @
f99f295d
/*
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
;
}
app/u8glib/u8g_cursor.c
deleted
100644 → 0
View file @
f99f295d
/*
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
);
}
app/u8glib/u8g_delay.c
deleted
100644 → 0
View file @
f99f295d
/*
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.
void u8g_Delay(uint16_t val) Delay by "val" milliseconds
void u8g_MicroDelay(void) Delay be one microsecond
void u8g_10MicroDelay(void) Delay by 10 microseconds
*/
#include "u8g.h"
/*==== Part 1: Derive suitable delay procedure ====*/
#if defined(ARDUINO)
# if ARDUINO < 100
# include <WProgram.h>
# else
# include <Arduino.h>
# endif
/* issue 353 */
#if defined(ARDUINO_ARCH_SAMD)
# include <delay.h>
#endif
# if defined(__AVR__)
# define USE_AVR_DELAY
# elif defined(__PIC32MX)
# define USE_PIC32_DELAY
# elif defined(__arm__)
/* Arduino Due & Teensy */
# define USE_ARDUINO_DELAY
# else
# define USE_ARDUINO_DELAY
# endif
#elif defined(_GNU_SOURCE)
# define USE_LINUX_DELAY
#elif defined(__MSP430__)
# define USE_MSP430_DELAY
#elif defined(U8G_RASPBERRY_PI)
# define USE_RASPBERRYPI_DELAY
#elif defined(__AVR__)
# define USE_AVR_DELAY
#elif defined(__18CXX)
# define USE_PIC18_DELAY
#elif defined(U8G_CYPRESS_PSOC5)
#define USE_PSOC5_DELAY
#elif defined(__arm__) || defined(__XTENSA__)
/* do not define anything, all procedures are expected to be defined outside u8glib */
/*
void u8g_Delay(uint16_t val);
void u8g_MicroDelay(void);
void u8g_10MicroDelay(void);
*/
#else
# define USE_DUMMY_DELAY
#endif
/*==== Part 2: Definition of the delay procedures ====*/
/*== Raspberry Pi Delay ==*/
#if defined (USE_RASPBERRYPI_DELAY)
#include <wiringPi.h>
//#include "/usr/local/include/wiringPi.h"
void
u8g_Delay
(
uint16_t
val
)
{
//delay(val);
//usleep((uint32_t)val*(uint32_t)1000);
delayMicroseconds
((
uint32_t
)
val
*
(
uint32_t
)
1000
);
}
void
u8g_MicroDelay
(
void
)
{
usleep
(
1
);
}
void
u8g_10MicroDelay
(
void
)
{
usleep
(
10
);
}
#endif
#if defined(USE_LINUX_DELAY)
void
u8g_Delay
(
uint16_t
val
)
{
//delay(val);
usleep
((
uint32_t
)
val
*
(
uint32_t
)
1000
);
}
void
u8g_MicroDelay
(
void
)
{
usleep
(
1
);
}
void
u8g_10MicroDelay
(
void
)
{
usleep
(
10
);
}
#endif
/*== 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
)
{
#if defined(__arm__)
delayMicroseconds
((
uint32_t
)
val
*
(
uint32_t
)
1000
);
#else
delay
(
val
);
#endif
}
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
#if defined(USE_MSP430_DELAY)
#include <msp430.h>
#ifndef F_CPU
#define F_CPU 1000000UL
#endif
void
u8g_Delay
(
uint16_t
val
)
{
int
t
;
for
(
t
=
0
;
t
<
val
;
t
++
)
{
__delay_cycles
(
F_CPU
/
1000UL
);
}
}
void
u8g_MicroDelay
(
void
)
{
__delay_cycles
(
F_CPU
/
1000000UL
);
}
void
u8g_10MicroDelay
(
void
)
{
__delay_cycles
(
F_CPU
/
100000UL
);
}
#endif
#if defined USE_PSOC5_DELAY
#include <project.h>
void
u8g_Delay
(
uint16_t
val
)
{
CyDelay
(
val
);};
void
u8g_MicroDelay
(
void
)
{
CyDelay
(
1
);};
void
u8g_10MicroDelay
(
void
)
{
CyDelay
(
10
);};
#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
app/u8glib/u8g_dev_a2_micro_printer.c
deleted
100644 → 0
View file @
f99f295d
/*
u8g_dev_a2_micro_printer_ds.c
Use DC2 bitmap command of the A2 Micro panel termal printer
double stroke
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.
*/
#include "u8g.h"
#define LINE_DELAY 40
uint8_t
u8g_dev_a2_micro_printer_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_SPI_CLK_CYCLE_NONE
);
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
);
y
=
pb
->
p
.
page_y0
;
ptr
=
pb
->
buf
;
u8g_WriteByte
(
u8g
,
dev
,
27
);
/* ESC */
u8g_WriteByte
(
u8g
,
dev
,
55
);
/* parameter command */
u8g_WriteByte
(
u8g
,
dev
,
7
);
/* Max printing dots,Unit(8dots),Default:7(64 dots) 8*(x+1)*/
u8g_WriteByte
(
u8g
,
dev
,
160
);
/* 3-255 Heating time,Unit(10us),Default:80(800us) */
u8g_WriteByte
(
u8g
,
dev
,
20
);
/* 0-255 Heating interval,Unit(10us),Default:2(20us)*/
u8g_WriteByte
(
u8g
,
dev
,
18
);
/* DC2 */
u8g_WriteByte
(
u8g
,
dev
,
42
);
/* * */
u8g_WriteByte
(
u8g
,
dev
,
pb
->
p
.
page_height
);
u8g_WriteByte
(
u8g
,
dev
,
pb
->
width
/
8
);
for
(
i
=
0
;
i
<
pb
->
p
.
page_height
;
i
++
)
{
for
(
j
=
0
;
j
<
pb
->
width
/
8
;
j
++
)
{
u8g_WriteByte
(
u8g
,
dev
,
*
ptr
);
ptr
++
;
}
u8g_Delay
(
u8g
,
LINE_DELAY
);
y
++
;
}
/* set parameters back to their default values */
u8g_WriteByte
(
u8g
,
dev
,
27
);
/* ESC */
u8g_WriteByte
(
u8g
,
dev
,
55
);
/* parameter command */
u8g_WriteByte
(
u8g
,
dev
,
7
);
/* Max printing dots,Unit(8dots),Default:7(64 dots) 8*(x+1)*/
u8g_WriteByte
(
u8g
,
dev
,
80
);
/* 3-255 Heating time,Unit(10us),Default:80(800us) */
u8g_WriteByte
(
u8g
,
dev
,
2
);
/* 0-255 Heating interval,Unit(10us),Default:2(20us)*/
}
break
;
}
return
u8g_dev_pb8h1_base_fn
(
u8g
,
dev
,
msg
,
arg
);
}
static
uint8_t
u8g_dev_expand4
(
uint8_t
val
)
{
uint8_t
a
,
b
,
c
,
d
;
a
=
val
&
1
;
b
=
(
val
&
2
)
<<
1
;
c
=
(
val
&
4
)
<<
2
;
d
=
(
val
&
8
)
<<
3
;
a
|=
b
;
a
|=
c
;
a
|=
d
;
a
|=
a
<<
1
;
return
a
;
}
uint8_t
u8g_dev_a2_micro_printer_double_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_SPI_CLK_CYCLE_NONE
);
break
;
case
U8G_DEV_MSG_STOP
:
break
;
case
U8G_DEV_MSG_PAGE_FIRST
:
{
//u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
//u8g_WriteByte(u8g, dev, 18); /* DC2 */
//u8g_WriteByte(u8g, dev, 42 ); /* * */
//u8g_WriteByte(u8g, dev, pb->p.total_height*2 );
//u8g_WriteByte(u8g, dev, pb->width/8*2 );
}
break
;
case
U8G_DEV_MSG_PAGE_NEXT
:
{
uint8_t
y
,
i
,
j
;
uint8_t
*
ptr
;
uint8_t
*
p2
;
u8g_pb_t
*
pb
=
(
u8g_pb_t
*
)(
dev
->
dev_mem
);
y
=
pb
->
p
.
page_y0
;
ptr
=
pb
->
buf
;
//u8g_WriteByte(u8g, dev, 18); /* DC2 */
//u8g_WriteByte(u8g, dev, 35 ); /* # */
//u8g_WriteByte(u8g, dev, 0x0ff ); /* max */
u8g_WriteByte
(
u8g
,
dev
,
27
);
/* ESC */
u8g_WriteByte
(
u8g
,
dev
,
55
);
/* parameter command */
u8g_WriteByte
(
u8g
,
dev
,
7
);
/* Max printing dots,Unit(8dots),Default:7(64 dots) 8*(x+1)*/
u8g_WriteByte
(
u8g
,
dev
,
160
);
/* 3-255 Heating time,Unit(10us),Default:80(800us) */
u8g_WriteByte
(
u8g
,
dev
,
20
);
/* 0-255 Heating interval,Unit(10us),Default:2(20us)*/
u8g_WriteByte
(
u8g
,
dev
,
18
);
/* DC2 */
u8g_WriteByte
(
u8g
,
dev
,
42
);
/* * */
u8g_WriteByte
(
u8g
,
dev
,
pb
->
p
.
page_height
*
2
);
u8g_WriteByte
(
u8g
,
dev
,
pb
->
width
/
8
*
2
);
for
(
i
=
0
;
i
<
pb
->
p
.
page_height
;
i
++
)
{
p2
=
ptr
;
for
(
j
=
0
;
j
<
pb
->
width
/
8
;
j
++
)
{
u8g_WriteByte
(
u8g
,
dev
,
u8g_dev_expand4
(
*
p2
>>
4
));
u8g_WriteByte
(
u8g
,
dev
,
u8g_dev_expand4
(
*
p2
&
15
));
p2
++
;
}
u8g_Delay
(
u8g
,
LINE_DELAY
);
p2
=
ptr
;
for
(
j
=
0
;
j
<
pb
->
width
/
8
;
j
++
)
{
u8g_WriteByte
(
u8g
,
dev
,
u8g_dev_expand4
(
*
p2
>>
4
));
u8g_WriteByte
(
u8g
,
dev
,
u8g_dev_expand4
(
*
p2
&
15
));
p2
++
;
}
u8g_Delay
(
u8g
,
LINE_DELAY
);
ptr
+=
pb
->
width
/
8
;
y
++
;
}
/* set parameters back to their default values */
u8g_WriteByte
(
u8g
,
dev
,
27
);
/* ESC */
u8g_WriteByte
(
u8g
,
dev
,
55
);
/* parameter command */
u8g_WriteByte
(
u8g
,
dev
,
7
);
/* Max printing dots,Unit(8dots),Default:7(64 dots) 8*(x+1)*/
u8g_WriteByte
(
u8g
,
dev
,
80
);
/* 3-255 Heating time,Unit(10us),Default:80(800us) */
u8g_WriteByte
(
u8g
,
dev
,
2
);
/* 0-255 Heating interval,Unit(10us),Default:2(20us)*/
}
break
;
}
return
u8g_dev_pb8h1_base_fn
(
u8g
,
dev
,
msg
,
arg
);
}
#if defined(U8G_16BIT)
U8G_PB_DEV
(
u8g_dev_a2_micro_printer_384x240
,
384
,
240
,
8
,
u8g_dev_a2_micro_printer_fn
,
u8g_com_null_fn
);
U8G_PB_DEV
(
u8g_dev_a2_micro_printer_192x360_ds
,
192
,
360
,
8
,
u8g_dev_a2_micro_printer_double_fn
,
u8g_com_null_fn
);
U8G_PB_DEV
(
u8g_dev_a2_micro_printer_192x720_ds
,
192
,
720
,
8
,
u8g_dev_a2_micro_printer_double_fn
,
u8g_com_null_fn
);
#else
U8G_PB_DEV
(
u8g_dev_a2_micro_printer_384x240
,
240
,
240
,
8
,
u8g_dev_a2_micro_printer_fn
,
u8g_com_null_fn
);
U8G_PB_DEV
(
u8g_dev_a2_micro_printer_192x360_ds
,
192
,
240
,
8
,
u8g_dev_a2_micro_printer_double_fn
,
u8g_com_null_fn
);
U8G_PB_DEV
(
u8g_dev_a2_micro_printer_192x720_ds
,
192
,
240
,
8
,
u8g_dev_a2_micro_printer_double_fn
,
u8g_com_null_fn
);
#endif
U8G_PB_DEV
(
u8g_dev_a2_micro_printer_192x120_ds
,
192
,
120
,
8
,
u8g_dev_a2_micro_printer_double_fn
,
u8g_com_null_fn
);
app/u8glib/u8g_dev_flipdisc_2x7.c
deleted
100644 → 0
View file @
f99f295d
/*
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
,
(
uint8_t
*
)(
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
};
app/u8glib/u8g_dev_gprof.c
deleted
100644 → 0
View file @
f99f295d
/*
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_ENTRY
:
break
;
case
U8G_DEV_MSG_SET_XY_CB
:
break
;
}
return
u8g_dev_pb8v1_base_fn
(
u8g
,
dev
,
msg
,
arg
);
}
app/u8glib/u8g_dev_ht1632.c
deleted
100644 → 0
View file @
f99f295d
/*
u8g_dev_ht1632.c
1-Bit (BW) Driver for HT1632 controller
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.
U8G_PIN_NONE can be used as argument
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)
{
...
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;
mapping
#define DATA_PIN --> U8G_PI_MOSI
#define WR_PIN --> U8G_PI_SCK
#define CS_PIN --> U8G_PI_CS
U8G_PI_A0 --> not used
U8G_PI_RESET --> not used
Usage:
u8g_InitSPI(&u8g, &u8g_dev_ht1632_24x16, WR_PIN, DATA_IN, CS_PIN, U8G_PIN_NONE, U8G_PIN_NONE)
*/
#include "u8g.h"
#define WIDTH 24
#define HEIGHT 16
#define PAGE_HEIGHT 16
/* http://forum.arduino.cc/index.php?topic=168537.0 */
#define HT1632_CMD_SYSDIS 0x00 // CMD= 0000-0000-x Turn off oscil
#define HT1632_CMD_SYSON 0x01 // CMD= 0000-0001-x Enable system oscil
#define HT1632_CMD_LEDOFF 0x02 // CMD= 0000-0010-x LED duty cycle gen off
#define HT1632_CMD_LEDON 0x03 // CMD= 0000-0011-x LEDs ON
#define HT1632_CMD_BLOFF 0x08 // CMD= 0000-1000-x Blink OFF
#define HT1632_CMD_BLON 0x09 // CMD= 0000-1001-x Blink On
#define HT1632_CMD_SLVMD 0x10 // CMD= 0001-00xx-x Slave Mode
#define HT1632_CMD_MSTMD 0x14 // CMD= 0001-01xx-x Master Mode
#define HT1632_CMD_RCCLK 0x18 // CMD= 0001-10xx-x Use on-chip clock
#define HT1632_CMD_EXTCLK 0x1C // CMD= 0001-11xx-x Use external clock
#define HT1632_CMD_COMS00 0x20 // CMD= 0010-ABxx-x commons options
#define HT1632_CMD_COMS01 0x24 // CMD= 0010-ABxx-x commons options
#define HT1632_CMD_COMS10 0x28 // CMD= 0010-ABxx-x commons options
#define HT1632_CMD_COMS11 0x2C // P-MOS OUTPUT AND 16COMMON OPTION
#define HT1632_CMD_PWM 0xA0 // CMD= 101x-PPPP-x PWM duty cycle
#define HT1632_ID_CMD 4
/* ID = 100 - Commands */
#define HT1632_ID_RD 6
/* ID = 110 - Read RAM */
#define HT1632_ID_WR 5
/* ID = 101 - Write RAM */
#define HT1632_ID_LEN 3 // IDs are 3 bits
#define HT1632_CMD_LEN 8 // CMDs are 8 bits
#define HT1632_DATA_LEN 8 // Data are 4*2 bits
#define HT1632_ADDR_LEN 7 // Address are 7 bits
#if defined(ARDUINO)
#if ARDUINO < 100
#include <WProgram.h>
#else
#include <Arduino.h>
#endif
//#define WR_PIN 3
//#define DATA_PIN 2
//#define CS_PIN 4
void
ht1632_write_data_MSB
(
u8g_t
*
u8g
,
uint8_t
cnt
,
uint8_t
data
,
uint8_t
extra
)
{
int8_t
i
;
uint8_t
data_pin
=
u8g
->
pin_list
[
U8G_PI_MOSI
];
uint8_t
wr_pin
=
u8g
->
pin_list
[
U8G_PI_SCK
];
for
(
i
=
cnt
-
1
;
i
>=
0
;
i
--
)
{
if
((
data
>>
i
)
&
1
)
{
digitalWrite
(
data_pin
,
HIGH
);
}
else
{
digitalWrite
(
data_pin
,
LOW
);
}
digitalWrite
(
wr_pin
,
LOW
);
u8g_MicroDelay
();
digitalWrite
(
wr_pin
,
HIGH
);
u8g_MicroDelay
();
}
// Send an extra bit
if
(
extra
)
{
digitalWrite
(
data_pin
,
HIGH
);
digitalWrite
(
wr_pin
,
LOW
);
u8g_MicroDelay
();
digitalWrite
(
wr_pin
,
HIGH
);
u8g_MicroDelay
();
}
}
void
ht1632_write_data
(
u8g_t
*
u8g
,
uint8_t
cnt
,
uint8_t
data
)
{
uint8_t
i
;
uint8_t
data_pin
=
u8g
->
pin_list
[
U8G_PI_MOSI
];
uint8_t
wr_pin
=
u8g
->
pin_list
[
U8G_PI_SCK
];
for
(
i
=
0
;
i
<
cnt
;
i
++
)
{
if
((
data
>>
i
)
&
1
)
{
digitalWrite
(
data_pin
,
HIGH
);
}
else
{
digitalWrite
(
data_pin
,
LOW
);
}
digitalWrite
(
wr_pin
,
LOW
);
u8g_MicroDelay
();
digitalWrite
(
wr_pin
,
HIGH
);
u8g_MicroDelay
();
}
}
void
ht1632_init
(
u8g_t
*
u8g
)
{
//uint8_t i;
uint8_t
data_pin
=
u8g
->
pin_list
[
U8G_PI_MOSI
];
uint8_t
wr_pin
=
u8g
->
pin_list
[
U8G_PI_SCK
];
uint8_t
cs_pin
=
u8g
->
pin_list
[
U8G_PI_CS
];
pinMode
(
data_pin
,
OUTPUT
);
pinMode
(
wr_pin
,
OUTPUT
);
pinMode
(
cs_pin
,
OUTPUT
);
digitalWrite
(
data_pin
,
HIGH
);
digitalWrite
(
wr_pin
,
HIGH
);
digitalWrite
(
cs_pin
,
HIGH
);
digitalWrite
(
cs_pin
,
LOW
);
/* init display once after startup */
ht1632_write_data_MSB
(
u8g
,
3
,
HT1632_ID_CMD
,
false
);
// IDs are 3 bits
ht1632_write_data_MSB
(
u8g
,
8
,
HT1632_CMD_SYSDIS
,
true
);
// 8 bits
ht1632_write_data_MSB
(
u8g
,
8
,
HT1632_CMD_SYSON
,
true
);
// 8 bits
ht1632_write_data_MSB
(
u8g
,
8
,
HT1632_CMD_COMS11
,
true
);
// 8 bits
ht1632_write_data_MSB
(
u8g
,
8
,
HT1632_CMD_LEDON
,
true
);
// 8 bits
ht1632_write_data_MSB
(
u8g
,
8
,
HT1632_CMD_BLOFF
,
true
);
// 8 bits
ht1632_write_data_MSB
(
u8g
,
8
,
HT1632_CMD_PWM
+
15
,
true
);
// 8 bits
digitalWrite
(
cs_pin
,
HIGH
);
/* removed following (debug) code */
/*
digitalWrite(cs_pin, LOW);
ht1632_write_data_MSB(u8g, 3, HT1632_ID_WR, false); // Send "write to display" command
ht1632_write_data_MSB(u8g, 7, 0, false);
for(i = 0; i<48; ++i)
{
ht1632_write_data(u8g, 8, 0xFF);
}
digitalWrite(cs_pin, HIGH);
*/
}
/*
page: 0=data contain lines 0..16, 1=data contain lines 16..32 (a 24x16 display will only have page 0)
cnt: width of the display
data: pointer to a buffer with 2*cnt bytes.
*/
void
ht1632_transfer_data
(
u8g_t
*
u8g
,
uint8_t
page
,
uint8_t
cnt
,
uint8_t
*
data
)
{
uint8_t
addr
;
uint8_t
cs_pin
=
u8g
->
pin_list
[
U8G_PI_CS
];
/* send data to the ht1632 */
digitalWrite
(
cs_pin
,
LOW
);
ht1632_write_data_MSB
(
u8g
,
3
,
HT1632_ID_WR
,
false
);
// Send "write to display" command
ht1632_write_data_MSB
(
u8g
,
7
,
page
*
2
*
cnt
,
false
);
// Operating in progressive addressing mode
for
(
addr
=
0
;
addr
<
cnt
;
addr
++
)
{
ht1632_write_data
(
u8g
,
8
,
data
[
addr
]);
ht1632_write_data
(
u8g
,
8
,
data
[
addr
+
cnt
]);
}
digitalWrite
(
cs_pin
,
HIGH
);
}
/* value is between 0...15 */
void
ht1632_set_contrast
(
u8g_t
*
u8g
,
uint8_t
value
)
{
uint8_t
cs_pin
=
u8g
->
pin_list
[
U8G_PI_CS
];
digitalWrite
(
cs_pin
,
LOW
);
ht1632_write_data_MSB
(
u8g
,
3
,
HT1632_ID_CMD
,
false
);
ht1632_write_data_MSB
(
u8g
,
8
,
HT1632_CMD_PWM
+
value
,
false
);
digitalWrite
(
cs_pin
,
HIGH
);
}
#else
void
ht1632_init
(
u8g_t
*
u8g
)
{
}
void
ht1632_transfer_data
(
u8g_t
*
u8g
,
uint8_t
page
,
uint8_t
cnt
,
uint8_t
*
data
)
{
}
void
ht1632_set_contrast
(
u8g_t
*
u8g
,
uint8_t
value
)
{
}
#endif
/* ARDUINO */
uint8_t
u8g_dev_ht1632_24x16_fn
(
u8g_t
*
u8g
,
u8g_dev_t
*
dev
,
uint8_t
msg
,
void
*
arg
)
{
switch
(
msg
)
{
case
U8G_DEV_MSG_INIT
:
ht1632_init
(
u8g
);
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 */
ht1632_transfer_data
(
u8g
,
pb
->
p
.
page
,
WIDTH
,
pb
->
buf
);
}
break
;
case
U8G_DEV_MSG_CONTRAST
:
/* values passed to SetContrast() are between 0 and 255, scale down to 0...15 */
ht1632_set_contrast
(
u8g
,
(
*
(
uint8_t
*
)
arg
)
>>
4
);
return
1
;
}
return
u8g_dev_pb16v1_base_fn
(
u8g
,
dev
,
msg
,
arg
);
}
uint8_t
u8g_dev_ht1632_24x16_buf
[
WIDTH
*
2
]
U8G_NOCOMMON
;
u8g_pb_t
u8g_dev_ht1632_24x16_pb
=
{
{
16
,
HEIGHT
,
0
,
0
,
0
},
WIDTH
,
u8g_dev_ht1632_24x16_buf
};
u8g_dev_t
u8g_dev_ht1632_24x16
=
{
u8g_dev_ht1632_24x16_fn
,
&
u8g_dev_ht1632_24x16_pb
,
u8g_com_null_fn
};
app/u8glib/u8g_dev_ili9325d_320x240.c
deleted
100644 → 0
View file @
f99f295d
/*
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
,
U8G_SPI_CLK_CYCLE_50NS
);
//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);
app/u8glib/u8g_dev_ks0108_128x64.c
deleted
100644 → 0
View file @
f99f295d
/*
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_SPI_CLK_CYCLE_NONE
);
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
);
app/u8glib/u8g_dev_lc7981_160x80.c
deleted
100644 → 0
View file @
f99f295d
/*
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 */
0x050
,
/* Oct 2015: Changed from 7f to 50 (1/80 duty cycle) */
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_SPI_CLK_CYCLE_NONE
);
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
);
app/u8glib/u8g_dev_lc7981_240x128.c
deleted
100644 → 0
View file @
f99f295d
/*
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_SPI_CLK_CYCLE_NONE
);
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
);
app/u8glib/u8g_dev_lc7981_240x64.c
deleted
100644 → 0
View file @
f99f295d
/*
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_SPI_CLK_CYCLE_NONE
);
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
);
app/u8glib/u8g_dev_lc7981_320x64.c
deleted
100644 → 0
View file @
f99f295d
/*
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"
#ifdef U8G_16BIT
#define WIDTH 320
#else
#define WIDTH 240
#endif
#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_SPI_CLK_CYCLE_NONE
);
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
);
app/u8glib/u8g_dev_ld7032_60x32.c
deleted
100644 → 0
View file @
f99f295d
/*
u8g_dev_ld7032_60x32.c
60x32 OLED 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 as 64, so that it is a multiple of 8 */
#define WIDTH 64
#define HEIGHT 32
#define PAGE_HEIGHT 8
static
const
uint8_t
u8g_dev_ld7032_60x32_init_seq
[]
PROGMEM
=
{
U8G_ESC_CS
(
0
),
/* disable chip */
U8G_ESC_ADR
(
0
),
/* instruction mode */
U8G_ESC_DLY
(
1
),
/* delay 1 ms */
U8G_ESC_RST
(
1
),
/* do reset low pulse with (1*16)+2 milliseconds */
U8G_ESC_CS
(
1
),
/* enable chip */
U8G_ESC_ADR
(
0
),
/* instruction mode */
0x002
,
/* Dot Matrix Display ON/OFF */
U8G_ESC_ADR
(
1
),
/* data mode */
0x001
,
/* ON */
U8G_ESC_ADR
(
0
),
/* instruction mode */
0x014
,
/* Dot Matrix Display Stand-by ON/OFF */
U8G_ESC_ADR
(
1
),
/* data mode */
0x000
,
/* ON */
U8G_ESC_ADR
(
0
),
/* instruction mode */
0x01a
,
/* Dot Matrix Frame Rate */
U8G_ESC_ADR
(
1
),
/* data mode */
0x004
,
/* special value for this OLED from manual */
U8G_ESC_ADR
(
0
),
/* instruction mode */
0x01d
,
/* Graphics Memory Writing Direction */
U8G_ESC_ADR
(
1
),
/* data mode */
0x000
,
/* reset default (right down, horizontal) */
U8G_ESC_ADR
(
0
),
/* instruction mode */
0x009
,
/* Display Direction */
U8G_ESC_ADR
(
1
),
/* data mode */
0x000
,
/* reset default (x,y: min --> max) */
U8G_ESC_ADR
(
0
),
/* instruction mode */
0x030
,
/* Display Size X */
U8G_ESC_ADR
(
1
),
/* data mode */
0x000
,
/* Column Start Output */
0x03b
,
/* Column End Output */
U8G_ESC_ADR
(
0
),
/* instruction mode */
0x032
,
/* Display Size Y */
U8G_ESC_ADR
(
1
),
/* data mode */
0x000
,
/* Row Start Output */
0x01f
,
/* Row End Output */
U8G_ESC_ADR
(
0
),
/* instruction mode */
0x010
,
/* Peak Pulse Width Set */
U8G_ESC_ADR
(
1
),
/* data mode */
0x000
,
/* 0 SCLK */
U8G_ESC_ADR
(
0
),
/* instruction mode */
0x016
,
/* Peak Pulse Delay Set */
U8G_ESC_ADR
(
1
),
/* data mode */
0x000
,
/* 0 SCLK */
U8G_ESC_ADR
(
0
),
/* instruction mode */
0x012
,
/* Dot Matrix Current Level Set */
U8G_ESC_ADR
(
1
),
/* data mode */
0x050
,
/* 0x050 * 1 uA = 80 uA */
U8G_ESC_ADR
(
0
),
/* instruction mode */
0x018
,
/* Pre-Charge Pulse Width */
U8G_ESC_ADR
(
1
),
/* data mode */
0x003
,
/* 3 SCLK */
U8G_ESC_ADR
(
0
),
/* instruction mode */
0x044
,
/* Pre-Charge Mode */
U8G_ESC_ADR
(
1
),
/* data mode */
0x002
,
/* Every Time */
U8G_ESC_ADR
(
0
),
/* instruction mode */
0x048
,
/* Row overlap timing */
U8G_ESC_ADR
(
1
),
/* data mode */
0x003
,
/* Pre-Charge + Peak Delay + Peak boot Timing */
U8G_ESC_ADR
(
0
),
/* instruction mode */
0x03f
,
/* VCC_R_SEL */
U8G_ESC_ADR
(
1
),
/* data mode */
0x011
,
/* ??? */
U8G_ESC_ADR
(
0
),
/* instruction mode */
0x03d
,
/* VSS selection */
U8G_ESC_ADR
(
1
),
/* data mode */
0x000
,
/* 2.8V */
U8G_ESC_ADR
(
0
),
/* instruction mode */
0x002
,
/* Dot Matrix Display ON/OFF */
U8G_ESC_ADR
(
1
),
/* data mode */
0x001
,
/* ON */
U8G_ESC_ADR
(
0
),
/* instruction mode */
0x008
,
/* write data */
U8G_ESC_CS
(
0
),
/* disable chip */
U8G_ESC_END
/* end of sequence */
};
/* use box commands to set start adr */
static
const
uint8_t
u8g_dev_ld7032_60x32_data_start
[]
PROGMEM
=
{
U8G_ESC_ADR
(
0
),
/* instruction mode */
U8G_ESC_CS
(
1
),
/* enable chip */
U8G_ESC_ADR
(
0
),
/* instruction mode */
0x034
,
/* box x start */
U8G_ESC_ADR
(
1
),
/* data mode */
0x000
,
/* 0 */
U8G_ESC_ADR
(
0
),
/* instruction mode */
0x035
,
/* box x end */
U8G_ESC_ADR
(
1
),
/* data mode */
0x007
,
/* */
U8G_ESC_ADR
(
0
),
/* instruction mode */
0x037
,
/* box y end */
U8G_ESC_ADR
(
1
),
/* data mode */
0x01f
,
/* */
U8G_ESC_ADR
(
0
),
/* instruction mode */
0x036
,
/* box y start */
U8G_ESC_ADR
(
1
),
/* data mode */
U8G_ESC_END
/* end of sequence */
};
static
const
uint8_t
u8g_dev_ld7032_60x32_sleep_on
[]
PROGMEM
=
{
U8G_ESC_ADR
(
0
),
/* instruction mode */
U8G_ESC_CS
(
1
),
/* enable chip */
/* ... */
U8G_ESC_CS
(
0
),
/* disable chip */
U8G_ESC_END
/* end of sequence */
};
static
const
uint8_t
u8g_dev_ld7032_60x32_sleep_off
[]
PROGMEM
=
{
U8G_ESC_ADR
(
0
),
/* instruction mode */
U8G_ESC_CS
(
1
),
/* enable chip */
/* ... */
U8G_ESC_DLY
(
50
),
/* delay 50 ms */
U8G_ESC_CS
(
0
),
/* disable chip */
U8G_ESC_END
/* end of sequence */
};
uint8_t
u8g_dev_ld7032_60x32_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_SPI_CLK_CYCLE_400NS
);
u8g_WriteEscSeqP
(
u8g
,
dev
,
u8g_dev_ld7032_60x32_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_ld7032_60x32_data_start
);
u8g_WriteByte
(
u8g
,
dev
,
pb
->
p
.
page_y0
);
/* y start */
u8g_SetAddress
(
u8g
,
dev
,
0
);
/* instruction mode */
u8g_WriteByte
(
u8g
,
dev
,
0x008
);
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_ld7032_60x32_sleep_on
);
return
1
;
case
U8G_DEV_MSG_SLEEP_OFF
:
u8g_WriteEscSeqP
(
u8g
,
dev
,
u8g_dev_ld7032_60x32_sleep_off
);
return
1
;
}
return
u8g_dev_pb8h1_base_fn
(
u8g
,
dev
,
msg
,
arg
);
}
U8G_PB_DEV
(
u8g_dev_ld7032_60x32_sw_spi
,
WIDTH
,
HEIGHT
,
PAGE_HEIGHT
,
u8g_dev_ld7032_60x32_fn
,
U8G_COM_SW_SPI
);
U8G_PB_DEV
(
u8g_dev_ld7032_60x32_hw_spi
,
WIDTH
,
HEIGHT
,
PAGE_HEIGHT
,
u8g_dev_ld7032_60x32_fn
,
U8G_COM_HW_SPI
);
U8G_PB_DEV
(
u8g_dev_ld7032_60x32_parallel
,
WIDTH
,
HEIGHT
,
PAGE_HEIGHT
,
u8g_dev_ld7032_60x32_fn
,
U8G_COM_PARALLEL
);
U8G_PB_DEV
(
u8g_dev_ld7032_60x32_hw_usart_spi
,
WIDTH
,
HEIGHT
,
PAGE_HEIGHT
,
u8g_dev_ld7032_60x32_fn
,
U8G_COM_HW_USART_SPI
);
app/u8glib/u8g_dev_null.c
deleted
100644 → 0
View file @
f99f295d
/*
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_ENTRY
:
break
;
case
U8G_DEV_MSG_SET_XY_CB
:
break
;
}
return
1
;
}
app/u8glib/u8g_dev_pcd8544_84x48.c
deleted
100644 → 0
View file @
f99f295d
/*
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 */
};
static
const
uint8_t
u8g_dev_pcd8544_sleep_on
[]
PROGMEM
=
{
U8G_ESC_ADR
(
0
),
/* instruction mode */
U8G_ESC_CS
(
1
),
/* enable chip */
0x020
,
/* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
0x00c
,
/* display on, normal */
U8G_ESC_CS
(
0
),
/* disable chip, bugfix 12 nov 2014 */
U8G_ESC_END
/* end of sequence */
};
static
const
uint8_t
u8g_dev_pcd8544_sleep_off
[]
PROGMEM
=
{
U8G_ESC_ADR
(
0
),
/* instruction mode */
U8G_ESC_CS
(
1
),
/* enable chip */
0x020
,
/* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
0x008
,
/* display blank */
0x024
,
/* power down (PD=1), horizontal increment (V=0), enter normal command set (H=0) */
U8G_ESC_DLY
(
50
),
/* delay 50 ms */
U8G_ESC_CS
(
0
),
/* disable chip, bugfix 12 nov 2014 */
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_SPI_CLK_CYCLE_400NS
);
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
;
case
U8G_DEV_MSG_SLEEP_ON
:
u8g_WriteEscSeqP
(
u8g
,
dev
,
u8g_dev_pcd8544_sleep_on
);
return
1
;
case
U8G_DEV_MSG_SLEEP_OFF
:
u8g_WriteEscSeqP
(
u8g
,
dev
,
u8g_dev_pcd8544_sleep_off
);
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
);
U8G_PB_DEV
(
u8g_dev_pcd8544_84x48_hw_spi
,
WIDTH
,
HEIGHT
,
PAGE_HEIGHT
,
u8g_dev_pcd8544_fn
,
U8G_COM_HW_SPI
);
app/u8glib/u8g_dev_pcf8812_96x65.c
deleted
100644 → 0
View file @
f99f295d
/*
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_SPI_CLK_CYCLE_400NS
);
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
;
/* mirrored output, not tested*/
/*
{
uint8_t i = pb->width;
while( i > 0 )
{
i--;
u8g_WriteByte(u8g, dev, ((unsigned char *)pb->buf)[i] );
}
}
*/
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
);
U8G_PB_DEV
(
u8g_dev_pcf8812_96x65_hw_spi
,
WIDTH
,
HEIGHT
,
PAGE_HEIGHT
,
u8g_dev_pcf8812_fn
,
U8G_COM_HW_SPI
);
Prev
1
2
3
4
5
6
7
8
9
10
…
12
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment