Fix up various spacing, comments, and typos
This commit is contained in:
parent
d45f19d385
commit
ca577c1638
|
@ -20,39 +20,37 @@
|
|||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
based on u8g_com_st7920_hw_spi.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
/**
|
||||
* Based on u8g_com_st7920_hw_spi.c
|
||||
*
|
||||
* Universal 8bit Graphics Library
|
||||
*
|
||||
* Copyright (c) 2011, olikraus@gmail.com
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef ARDUINO_ARCH_SAM
|
||||
|
|
|
@ -70,7 +70,7 @@ extern "C" void delay(const int msec) {
|
|||
}
|
||||
|
||||
// IO functions
|
||||
// As defined by Arduino INPUT(0x0), OUPUT(0x1), INPUT_PULLUP(0x2)
|
||||
// As defined by Arduino INPUT(0x0), OUTPUT(0x1), INPUT_PULLUP(0x2)
|
||||
void pinMode(const pin_t pin, const uint8_t mode) {
|
||||
if (!VALID_PIN(pin)) return;
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ uint8_t LPC1768_PIN_PIN(const uint8_t pin);
|
|||
#endif
|
||||
|
||||
// I/O functions
|
||||
// As defined by Arduino INPUT(0x0), OUPUT(0x1), INPUT_PULLUP(0x2)
|
||||
// As defined by Arduino INPUT(0x0), OUTPUT(0x1), INPUT_PULLUP(0x2)
|
||||
void pinMode_LCD(uint8_t pin, uint8_t mode) {
|
||||
#define LPC1768_PIN_PORT(pin) ((uint8_t)((pin >> 5) & 0b111))
|
||||
#define LPC1768_PIN_PIN(pin) ((uint8_t)(pin & 0b11111))
|
||||
|
|
|
@ -20,43 +20,39 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
|
||||
based on u8g_com_msp430_hw_spi.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2012, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
/**
|
||||
* Based on u8g_com_msp430_hw_spi.c
|
||||
*
|
||||
* Universal 8bit Graphics Library
|
||||
*
|
||||
* Copyright (c) 2011, olikraus@gmail.com
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#ifdef TARGET_LPC1768
|
||||
|
||||
//#include <inttypes.h>
|
||||
|
@ -79,11 +75,8 @@
|
|||
void spiSend(uint8_t b);
|
||||
void spiSend(const uint8_t* buf, size_t n);
|
||||
|
||||
|
||||
uint8_t u8g_com_HAL_LPC1768_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
uint8_t u8g_com_HAL_LPC1768_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) {
|
||||
switch (msg) {
|
||||
case U8G_COM_MSG_STOP:
|
||||
break;
|
||||
|
||||
|
|
|
@ -20,59 +20,59 @@
|
|||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Based on u8g_com_arduino_ssd_i2c.c
|
||||
*
|
||||
* COM interface for Arduino (AND ATmega) and the SSDxxxx chip (SOLOMON) variant
|
||||
* I2C protocol
|
||||
*
|
||||
* ToDo: Rename this to u8g_com_avr_ssd_i2c.c
|
||||
*
|
||||
* Universal 8bit Graphics Library
|
||||
*
|
||||
* Copyright (c) 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
based on u8g_com_arduino_ssd_i2c.c
|
||||
|
||||
com interface for arduino (AND atmega) and the SSDxxxx chip (SOLOMON) variant
|
||||
I2C protocol
|
||||
|
||||
ToDo: Rename this to u8g_com_avr_ssd_i2c.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2012, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
Special pin usage:
|
||||
U8G_PI_I2C_OPTION additional options
|
||||
U8G_PI_A0_STATE used to store the last value of the command/data register selection
|
||||
U8G_PI_SET_A0 1: Signal request to update I2C device with new A0_STATE, 0: Do nothing, A0_STATE matches I2C device
|
||||
U8G_PI_SCL clock line (NOT USED)
|
||||
U8G_PI_SDA data line (NOT USED)
|
||||
|
||||
U8G_PI_RESET reset line (currently disabled, see below)
|
||||
|
||||
Protocol:
|
||||
SLA, Cmd/Data Selection, Arguments
|
||||
The command/data register is selected by a special instruction byte, which is sent after SLA
|
||||
|
||||
The continue bit is always 0 so that a (re)start is equired for the change from cmd to/data mode
|
||||
/**
|
||||
* Special pin usage:
|
||||
* U8G_PI_I2C_OPTION additional options
|
||||
* U8G_PI_A0_STATE used to store the last value of the command/data register selection
|
||||
* U8G_PI_SET_A0 1: Signal request to update I2C device with new A0_STATE, 0: Do nothing, A0_STATE matches I2C device
|
||||
* U8G_PI_SCL clock line (NOT USED)
|
||||
* U8G_PI_SDA data line (NOT USED)
|
||||
*
|
||||
* U8G_PI_RESET reset line (currently disabled, see below)
|
||||
*
|
||||
* Protocol:
|
||||
* SLA, Cmd/Data Selection, Arguments
|
||||
* The command/data register is selected by a special instruction byte, which is sent after SLA
|
||||
*
|
||||
* The continue bit is always 0 so that a (re)start is equired for the change from cmd to/data mode
|
||||
*/
|
||||
|
||||
#ifdef TARGET_LPC1768
|
||||
|
@ -86,34 +86,25 @@
|
|||
|
||||
//#define U8G_I2C_OPT_FAST 16
|
||||
|
||||
uint8_t u8g_com_ssd_I2C_start_sequence(u8g_t *u8g)
|
||||
{
|
||||
uint8_t u8g_com_ssd_I2C_start_sequence(u8g_t *u8g) {
|
||||
/* are we requested to set the a0 state? */
|
||||
if ( u8g->pin_list[U8G_PI_SET_A0] == 0 )
|
||||
return 1;
|
||||
if (u8g->pin_list[U8G_PI_SET_A0] == 0) return 1;
|
||||
|
||||
/* setup bus, might be a repeated start */
|
||||
if (u8g_i2c_start(I2C_SLA) == 0)
|
||||
return 0;
|
||||
if ( u8g->pin_list[U8G_PI_A0_STATE] == 0 )
|
||||
{
|
||||
if ( u8g_i2c_send_byte(I2C_CMD_MODE) == 0 )
|
||||
return 0;
|
||||
if (u8g->pin_list[U8G_PI_A0_STATE] == 0 ) {
|
||||
if (u8g_i2c_send_byte(I2C_CMD_MODE) == 0) return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( u8g_i2c_send_byte(I2C_DATA_MODE) == 0 )
|
||||
else if (u8g_i2c_send_byte(I2C_DATA_MODE) == 0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
u8g->pin_list[U8G_PI_SET_A0] = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint8_t u8g_com_HAL_LPC1768_ssd_hw_i2c_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
uint8_t u8g_com_HAL_LPC1768_ssd_hw_i2c_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) {
|
||||
switch(msg) {
|
||||
case U8G_COM_MSG_INIT:
|
||||
//u8g_com_arduino_digital_write(u8g, U8G_PI_SCL, HIGH);
|
||||
//u8g_com_arduino_digital_write(u8g, U8G_PI_SDA, HIGH);
|
||||
|
@ -134,13 +125,11 @@
|
|||
case U8G_COM_MSG_CHIP_SELECT:
|
||||
u8g->pin_list[U8G_PI_A0_STATE] = 0;
|
||||
u8g->pin_list[U8G_PI_SET_A0] = 1; /* force a0 to set again, also forces start condition */
|
||||
if ( arg_val == 0 )
|
||||
{
|
||||
if (arg_val == 0 ) {
|
||||
/* disable chip, send stop condition */
|
||||
u8g_i2c_stop();
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
/* enable, do nothing: any byte writing will trigger the i2c start */
|
||||
}
|
||||
break;
|
||||
|
@ -154,11 +143,11 @@
|
|||
// u8g_i2c_stop();
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_WRITE_SEQ:
|
||||
case U8G_COM_MSG_WRITE_SEQ: {
|
||||
//u8g->pin_list[U8G_PI_SET_A0] = 1;
|
||||
if (u8g_com_ssd_I2C_start_sequence(u8g) == 0)
|
||||
return u8g_i2c_stop(), 0;
|
||||
{
|
||||
|
||||
register uint8_t *ptr = (uint8_t *)arg_ptr;
|
||||
while (arg_val > 0) {
|
||||
if (u8g_i2c_send_byte(*ptr++) == 0)
|
||||
|
@ -169,11 +158,11 @@
|
|||
// u8g_i2c_stop();
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_WRITE_SEQ_P:
|
||||
case U8G_COM_MSG_WRITE_SEQ_P: {
|
||||
//u8g->pin_list[U8G_PI_SET_A0] = 1;
|
||||
if (u8g_com_ssd_I2C_start_sequence(u8g) == 0)
|
||||
return u8g_i2c_stop(), 0;
|
||||
{
|
||||
|
||||
register uint8_t *ptr = (uint8_t *)arg_ptr;
|
||||
while (arg_val > 0) {
|
||||
if (u8g_i2c_send_byte(u8g_pgm_read(ptr)) == 0)
|
||||
|
@ -190,12 +179,10 @@
|
|||
u8g->pin_list[U8G_PI_SET_A0] = 1; /* force a0 to set again */
|
||||
|
||||
u8g_i2c_start(0); // send slave address and write bit
|
||||
if (arg_val)
|
||||
u8g_i2c_send_byte(0x40); // write to graphics DRAM mode
|
||||
else
|
||||
u8g_i2c_send_byte(0x80); //command mode
|
||||
u8g_i2c_send_byte(arg_val ? 0x40 : 0x80); // Write to ? Graphics DRAM mode : Command mode
|
||||
break;
|
||||
}
|
||||
|
||||
} // switch
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,46 +20,43 @@
|
|||
*
|
||||
*/
|
||||
|
||||
/* based on U8G2 code
|
||||
|
||||
u8x8_byte.c
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2016, 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.
|
||||
|
||||
|
||||
/**
|
||||
* Based on U8G2 code - u8x8_byte.c
|
||||
*
|
||||
* Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
*
|
||||
* Copyright (c) 2016, 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
software i2c,
|
||||
ignores ACK response (which is anyway not provided by some displays)
|
||||
also does not allow reading from the device
|
||||
/**
|
||||
* Software i2c,
|
||||
* ignores ACK response (which is anyway not provided by some displays)
|
||||
* also does not allow reading from the device
|
||||
*/
|
||||
|
||||
#ifdef TARGET_LPC1768
|
||||
|
@ -80,17 +77,13 @@ void delayMicroseconds(uint32_t us);
|
|||
//#define SPEED_400KHz 3
|
||||
//#define SPEED_100KHz 13
|
||||
|
||||
|
||||
// #define U8G_I2C_OPT_FAST 16
|
||||
|
||||
|
||||
|
||||
uint8_t SCL_pin_HAL_LPC1768_sw_I2C, SCL_port_HAL_LPC1768_sw_I2C, SDA_pin_HAL_LPC1768_sw_I2C, SDA_port_HAL_LPC1768_sw_I2C;
|
||||
|
||||
#define SPI_SPEED 2 //20: 200KHz 5:750KHz 2:3-4MHz
|
||||
|
||||
uint8_t u8g_i2c_send_byte_sw(uint8_t data) {
|
||||
{
|
||||
for (uint8_t i = 0; i < 9; i++) { // 1 extra bit for the ack/nak
|
||||
|
||||
if (val & 0x80)
|
||||
|
@ -118,14 +111,13 @@ uint8_t u8g_i2c_send_byte_sw(uint8_t data) {
|
|||
LPC_GPIO(SCL_port_HAL_LPC1768_sw_I2C)->FIOCLR = LPC_PIN(SCL_pin_HAL_LPC1768_sw_I2C);
|
||||
LPC_GPIO(SCL_port_HAL_LPC1768_sw_I2C)->FIOCLR = LPC_PIN(SCL_pin_HAL_LPC1768_sw_I2C);
|
||||
}
|
||||
val = val << 1;
|
||||
val <<= 1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
uint8_t u8g_i2c_start_sw(uint8_t sla) { // assert start condition and then send slave address with write bit
|
||||
{
|
||||
/* send the start condition, both lines go from 1 to 0 */
|
||||
|
||||
LPC_GPIO(SDA_port_HAL_LPC1768_sw_I2C)->FIOCLR = LPC_PIN(SDA_pin_HAL_LPC1768_sw_I2C);
|
||||
|
@ -143,43 +135,28 @@ uint8_t u8g_i2c_start_sw(uint8_t sla) { // assert start condition and then send
|
|||
}
|
||||
|
||||
|
||||
void u8g_i2c_stop_sw(void) {
|
||||
}
|
||||
void u8g_i2c_stop_sw(void) { }
|
||||
|
||||
void u8g_i2c_init_sw(uint8_t clock_option) {
|
||||
u8g_i2c_start(0); // send slave address and write bit
|
||||
}
|
||||
void u8g_i2c_init_sw(uint8_t clock_option) { u8g_i2c_start(0); } // send slave address and write bit
|
||||
|
||||
|
||||
|
||||
uint8_t u8g_com_ssd_I2C_start_sequence_sw(u8g_t *u8g)
|
||||
{
|
||||
uint8_t u8g_com_ssd_I2C_start_sequence_sw(u8g_t *u8g) {
|
||||
/* are we requested to set the a0 state? */
|
||||
if ( u8g->pin_list[U8G_PI_SET_A0] == 0 )
|
||||
return 1;
|
||||
if (u8g->pin_list[U8G_PI_SET_A0] == 0) return 1;
|
||||
|
||||
/* setup bus, might be a repeated start */
|
||||
if ( u8g_i2c_start(I2C_SLA) == 0 )
|
||||
return 0;
|
||||
if ( u8g->pin_list[U8G_PI_A0_STATE] == 0 )
|
||||
{
|
||||
if ( u8g_i2c_send_byte(I2C_CMD_MODE) == 0 )
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( u8g_i2c_send_byte(I2C_DATA_MODE) == 0 )
|
||||
return 0;
|
||||
if (u8g_i2c_start(I2C_SLA) == 0) return 0;
|
||||
if (u8g->pin_list[U8G_PI_A0_STATE] == 0) {
|
||||
if (u8g_i2c_send_byte(I2C_CMD_MODE) == 0) return 0;
|
||||
}
|
||||
else if (u8g_i2c_send_byte(I2C_DATA_MODE) == 0) return 0;
|
||||
|
||||
u8g->pin_list[U8G_PI_SET_A0] = 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint8_t u8g_com_HAL_LPC1768_ssd_sw_i2c_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
uint8_t u8g_com_HAL_LPC1768_ssd_sw_i2c_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) {
|
||||
switch (msg) {
|
||||
case U8G_COM_MSG_INIT:
|
||||
|
||||
#define LPC1768_PIN_PORT(pin) ((uint8_t)((pin >> 5) & 0b111))
|
||||
|
@ -188,8 +165,8 @@ void u8g_i2c_init_sw(uint8_t clock_option) {
|
|||
SCL_port_HAL_LPC1768_sw_I2C = LPC1768_PIN_PORT(u8g->pin_list[U8G_PI_SCL]);
|
||||
SDA_pin_HAL_LPC1768_sw_I2C = LPC1768_PIN_PIN(u8g->pin_list[U8G_PI_SDA]);
|
||||
SDA_port_HAL_LPC1768_sw_I2C = LPC1768_PIN_PORT(u8g->pin_list[U8G_PI_SDA]);
|
||||
// As defined by Arduino INPUT(0x0), OUPUT(0x1), INPUT_PULLUP(0x2)
|
||||
#define OUPUT 0x1
|
||||
// As defined by Arduino INPUT(0x0), OUTPUT(0x1), INPUT_PULLUP(0x2)
|
||||
#define OUTPUT 0x1
|
||||
u8g_SetPIOutput(u8g, U8G_PI_SCL);
|
||||
u8g_SetPIOutput(u8g, U8G_PI_SDA);
|
||||
if (U8G_PIN_NONE != u8g->pin_list[U8G_PI_CS]) u8g_SetPIOutput(u8g, U8G_PI_CS);
|
||||
|
@ -201,25 +178,21 @@ void u8g_i2c_init_sw(uint8_t clock_option) {
|
|||
//u8g->pin_list[U8G_PI_A0_STATE] = 0; /* inital RS state: unknown mode */
|
||||
|
||||
u8g_i2c_init_sw(u8g->pin_list[U8G_PI_I2C_OPTION]);
|
||||
u8g_com_ssd_I2C_start_sequence_sw((u8g);
|
||||
u8g_com_ssd_I2C_start_sequence_sw(u8g);
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_STOP:
|
||||
break;
|
||||
case U8G_COM_MSG_STOP: break;
|
||||
|
||||
case U8G_COM_MSG_RESET:
|
||||
break;
|
||||
case U8G_COM_MSG_RESET: break;
|
||||
|
||||
case U8G_COM_MSG_CHIP_SELECT:
|
||||
u8g->pin_list[U8G_PI_A0_STATE] = 0;
|
||||
u8g->pin_list[U8G_PI_SET_A0] = 1; /* force a0 to set again, also forces start condition */
|
||||
if ( arg_val == 0 )
|
||||
{
|
||||
if (arg_val == 0) {
|
||||
/* disable chip, send stop condition */
|
||||
u8g_i2c_stop_sw();
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
/* enable, do nothing: any byte writing will trigger the i2c start */
|
||||
}
|
||||
break;
|
||||
|
@ -233,11 +206,11 @@ void u8g_i2c_init_sw(uint8_t clock_option) {
|
|||
// u8g_i2c_stop();
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_WRITE_SEQ:
|
||||
case U8G_COM_MSG_WRITE_SEQ: {
|
||||
//u8g->pin_list[U8G_PI_SET_A0] = 1;
|
||||
if (u8g_com_ssd_I2C_start_sequence_sw(u8g) == 0)
|
||||
return u8g_i2c_stop_sw(), 0;
|
||||
{
|
||||
|
||||
register uint8_t *ptr = (uint8_t *)arg_ptr;
|
||||
while (arg_val > 0) {
|
||||
if (u8g_i2c_send_byte_sw(*ptr++) == 0)
|
||||
|
@ -248,15 +221,14 @@ void u8g_i2c_init_sw(uint8_t clock_option) {
|
|||
// u8g_i2c_stop();
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_WRITE_SEQ_P:
|
||||
case U8G_COM_MSG_WRITE_SEQ_P: {
|
||||
//u8g->pin_list[U8G_PI_SET_A0] = 1;
|
||||
if (u8g_com_ssd_I2C_start_sequence_sw(u8g) == 0)
|
||||
return u8g_i2c_stop_sw(), 0;
|
||||
{
|
||||
|
||||
register uint8_t *ptr = (uint8_t *)arg_ptr;
|
||||
while (arg_val > 0) {
|
||||
if ( u8g_i2c_send_byte_sw(u8g_pgm_read(ptr)) == 0 )
|
||||
return 0;
|
||||
if (u8g_i2c_send_byte_sw(u8g_pgm_read(ptr)) == 0) return 0;
|
||||
ptr++;
|
||||
arg_val--;
|
||||
}
|
||||
|
@ -267,12 +239,8 @@ void u8g_i2c_init_sw(uint8_t clock_option) {
|
|||
case U8G_COM_MSG_ADDRESS: /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
|
||||
u8g->pin_list[U8G_PI_A0_STATE] = arg_val;
|
||||
u8g->pin_list[U8G_PI_SET_A0] = 1; /* force a0 to set again */
|
||||
|
||||
u8g_i2c_start_sw(0); // send slave address and write bit
|
||||
if (arg_val)
|
||||
u8g_i2c_send_byte_sw(0x40); // write to graphics DRAM mode
|
||||
else
|
||||
u8g_i2c_send_byte_sw(0x80); //command mode
|
||||
u8g_i2c_send_byte_sw(arg_val ? 0x40 : 0x80); // Write to ? Graphics DRAM mode : Command mode
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
|
|
|
@ -20,39 +20,37 @@
|
|||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
based on u8g_com_LPC1768_st7920_hw_spi.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
/**
|
||||
* Based on u8g_com_LPC1768_st7920_hw_spi.c
|
||||
*
|
||||
* Universal 8bit Graphics Library
|
||||
*
|
||||
* Copyright (c) 2011, olikraus@gmail.com
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef TARGET_LPC1768
|
||||
|
|
|
@ -20,39 +20,37 @@
|
|||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
based on u8g_com_st7920_hw_spi.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
/**
|
||||
* Based on u8g_com_st7920_hw_spi.c
|
||||
*
|
||||
* Universal 8bit Graphics Library
|
||||
*
|
||||
* Copyright (c) 2011, olikraus@gmail.com
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef TARGET_LPC1768
|
||||
|
|
|
@ -20,39 +20,37 @@
|
|||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
adapted from u8g_com_std_sw_spi.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2015, 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.
|
||||
|
||||
/**
|
||||
* Based on u8g_com_std_sw_spi.c
|
||||
*
|
||||
* Universal 8bit Graphics Library
|
||||
*
|
||||
* Copyright (c) 2015, 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.
|
||||
*/
|
||||
|
||||
#ifdef TARGET_LPC1768
|
||||
|
@ -64,15 +62,12 @@
|
|||
|
||||
static uint8_t SPI_speed = 0;
|
||||
|
||||
static void u8g_sw_spi_HAL_LPC1768_shift_out(uint8_t dataPin, uint8_t clockPin, uint8_t val)
|
||||
{
|
||||
static void u8g_sw_spi_HAL_LPC1768_shift_out(uint8_t dataPin, uint8_t clockPin, uint8_t val) {
|
||||
swSpiTransfer(val, SPI_speed, clockPin, -1, dataPin);
|
||||
}
|
||||
|
||||
uint8_t u8g_com_HAL_LPC1768_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
uint8_t u8g_com_HAL_LPC1768_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) {
|
||||
switch(msg) {
|
||||
case U8G_COM_MSG_INIT:
|
||||
u8g_SetPIOutput(u8g, U8G_PI_SCK);
|
||||
u8g_SetPIOutput(u8g, U8G_PI_MOSI);
|
||||
|
|
|
@ -20,41 +20,37 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
|
||||
u8g_dev_ssd1306_128x64.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
/**
|
||||
* Based on u8g_dev_ssd1306_128x64.c
|
||||
*
|
||||
* Universal 8bit Graphics Library
|
||||
*
|
||||
* Copyright (c) 2015, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -85,43 +81,38 @@ uint8_t u8g_WriteEscSeqP_2_wire(u8g_t *u8g, u8g_dev_t *dev, const uint8_t *esc_s
|
|||
// The sh1106 is compatible to the ssd1306, but is 132x64. 128x64 display area is centered within
|
||||
// the 132x64.
|
||||
|
||||
|
||||
static const uint8_t u8g_dev_sh1106_128x64_data_start_2_wire[] PROGMEM = {
|
||||
0x010, // set upper 4 bit of the col adr to 0
|
||||
0x002, // set lower 4 bit of the col adr to 2 (centered display with ssd1306)
|
||||
U8G_ESC_END // end of sequence
|
||||
};
|
||||
|
||||
|
||||
static const uint8_t u8g_dev_sh1106_128x64_init_seq_2_wire[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), // initiate command mode
|
||||
0x0ae, /* display off, sleep mode */
|
||||
0x0a8, 0x03f, /* mux ratio */
|
||||
0x0d3, 0x00, /* display offset */
|
||||
0x040, /* start line */
|
||||
0x0a1, /* segment remap a0/a1*/
|
||||
0x0c8, /* c0: scan dir normal, c8: reverse */
|
||||
0x0da, 0x012, /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
|
||||
0x081, 0x0cf, /* [2] set contrast control */
|
||||
0x020, 0x002, /* 2012-05-27: page addressing mode */
|
||||
0x0AE, // display off, sleep mode
|
||||
0x0A8, 0x03F, // mux ratio
|
||||
0x0D3, 0x00, // display offset
|
||||
0x040, // start line
|
||||
0x0A1, // segment remap a0/a1
|
||||
0x0C8, // c0: scan dir normal, c8: reverse
|
||||
0x0DA, 0x012, // com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5)
|
||||
0x081, 0x0CF, // [2] set contrast control
|
||||
0x020, 0x002, // 2012-05-27: page addressing mode
|
||||
0x21, 2, 0x81, // set column range from 0 through 131
|
||||
0x22, 0, 7, // set page range from 0 through 7
|
||||
0x0d9, 0x0f1, /* [2] pre-charge period 0x022/f1*/
|
||||
0x0db, 0x040, /* vcomh deselect level */
|
||||
0x0a4, /* output ram to display */
|
||||
0x0a6, /* none inverted normal display mode */
|
||||
0x0d5, 0x080, /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
||||
0x08d, 0x014, /* [2] charge pump setting (p62): 0x014 enable, 0x010 disable */
|
||||
0x02e, /* 2012-05-27: Deactivate scroll */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
0x0D9, 0x0F1, // [2] pre-charge period 0x022/f1
|
||||
0x0DB, 0x040, // vcomh deselect level
|
||||
0x0A4, // output ram to display
|
||||
0x0A6, // none inverted normal display mode
|
||||
0x0D5, 0x080, // clock divide ratio (0x00=1) and oscillator frequency (0x8)
|
||||
0x08D, 0x014, // [2] charge pump setting (p62): 0x014 enable, 0x010 disable
|
||||
0x02E, // 2012-05-27: Deactivate scroll
|
||||
0x0AF, // display on
|
||||
U8G_ESC_END // end of sequence
|
||||
};
|
||||
|
||||
|
||||
uint8_t u8g_dev_sh1106_128x64_2x_2_wire_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
uint8_t u8g_dev_sh1106_128x64_2x_2_wire_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_300NS);
|
||||
u8g_WriteEscSeqP_2_wire(u8g, dev, u8g_dev_sh1106_128x64_init_seq_2_wire);
|
||||
|
@ -152,7 +143,6 @@ uint8_t u8g_dev_sh1106_128x64_2x_2_wire_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t m
|
|||
return u8g_dev_pb16v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
|
||||
uint8_t u8g_dev_sh1106_128x64_2x_i2c_2_wire_buf[WIDTH*2] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_dev_sh1106_128x64_2x_i2c_2_wire_pb = { {16, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_sh1106_128x64_2x_i2c_2_wire_buf};
|
||||
u8g_dev_t u8g_dev_sh1106_128x64_2x_i2c_2_wire = { u8g_dev_sh1106_128x64_2x_2_wire_fn, &u8g_dev_sh1106_128x64_2x_i2c_2_wire_pb, U8G_COM_SSD_I2C_HAL };
|
||||
|
@ -165,36 +155,32 @@ static const uint8_t u8g_dev_ssd1306_128x64_data_start_2_wire[] PROGMEM = {
|
|||
U8G_ESC_END // end of sequence
|
||||
};
|
||||
|
||||
|
||||
static const uint8_t u8g_dev_ssd1306_128x64_init_seq_2_wire[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), // initiate command mode
|
||||
0x0ae, /* display off, sleep mode */
|
||||
0x0a8, 0x03f, /* mux ratio */
|
||||
0x0d3, 0x00, /* display offset */
|
||||
0x040, /* start line */
|
||||
0x0a1, /* segment remap a0/a1*/
|
||||
0x0c8, /* c0: scan dir normal, c8: reverse */
|
||||
0x0da, 0x012, /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
|
||||
0x081, 0x0cf, /* [2] set contrast control */
|
||||
0x020, 0x002, /* 2012-05-27: page addressing mode */
|
||||
0x21, 0, 0x7f, // set column range from 0 through 127
|
||||
0x0AE, // display off, sleep mode
|
||||
0x0A8, 0x03F, // mux ratio
|
||||
0x0D3, 0x00, // display offset
|
||||
0x040, // start line
|
||||
0x0A1, // segment remap a0/a1
|
||||
0x0C8, // c0: scan dir normal, c8: reverse
|
||||
0x0DA, 0x012, // com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5)
|
||||
0x081, 0x0CF, // [2] set contrast control
|
||||
0x020, 0x002, // 2012-05-27: page addressing mode
|
||||
0x21, 0, 0x7F, // set column range from 0 through 127
|
||||
0x22, 0, 7, // set page range from 0 through 7
|
||||
0x0d9, 0x0f1, /* [2] pre-charge period 0x022/f1*/
|
||||
0x0db, 0x040, /* vcomh deselect level */
|
||||
0x0a4, /* output ram to display */
|
||||
0x0a6, /* none inverted normal display mode */
|
||||
0x0d5, 0x080, /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
||||
0x08d, 0x014, /* [2] charge pump setting (p62): 0x014 enable, 0x010 disable */
|
||||
0x02e, /* 2012-05-27: Deactivate scroll */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
0x0D9, 0x0F1, // [2] pre-charge period 0x022/f1
|
||||
0x0DB, 0x040, // vcomh deselect level
|
||||
0x0A4, // output ram to display
|
||||
0x0A6, // none inverted normal display mode
|
||||
0x0D5, 0x080, // clock divide ratio (0x00=1) and oscillator frequency (0x8)
|
||||
0x08D, 0x014, // [2] charge pump setting (p62): 0x014 enable, 0x010 disable
|
||||
0x02E, // 2012-05-27: Deactivate scroll
|
||||
0x0AF, // display on
|
||||
U8G_ESC_END // end of sequence
|
||||
};
|
||||
|
||||
|
||||
uint8_t u8g_dev_ssd1306_128x64_2x_2_wire_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
uint8_t u8g_dev_ssd1306_128x64_2x_2_wire_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_300NS);
|
||||
u8g_WriteEscSeqP_2_wire(u8g, dev, u8g_dev_ssd1306_128x64_init_seq_2_wire);
|
||||
|
@ -238,54 +224,42 @@ u8g_dev_t u8g_dev_ssd1306_128x64_2x_i2c_2_wire = { u8g_dev_ssd1306_128x64_2x_2_w
|
|||
|
||||
#define I2C_CMD_MODE 0x080
|
||||
|
||||
uint8_t u8g_WriteEscSeqP_2_wire(u8g_t *u8g, u8g_dev_t *dev, const uint8_t *esc_seq)
|
||||
{
|
||||
uint8_t u8g_WriteEscSeqP_2_wire(u8g_t *u8g, u8g_dev_t *dev, const uint8_t *esc_seq) {
|
||||
uint8_t is_escape = 0;
|
||||
uint8_t value;
|
||||
for(;;)
|
||||
{
|
||||
for(;;) {
|
||||
value = u8g_pgm_read(esc_seq);
|
||||
if ( is_escape == 0 )
|
||||
{
|
||||
if ( value != 255 )
|
||||
{
|
||||
if (is_escape == 0) {
|
||||
if (value != 255) {
|
||||
if (u8g_WriteByte(u8g, dev, value) == 0 )
|
||||
return 0;
|
||||
if (u8g_WriteByte(u8g, dev, I2C_CMD_MODE) == 0 )
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
is_escape = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( value == 255 )
|
||||
{
|
||||
else {
|
||||
if (value == 255) {
|
||||
if (u8g_WriteByte(u8g, dev, value) == 0 )
|
||||
return 0;
|
||||
if (u8g_WriteByte(u8g, dev, I2C_CMD_MODE) == 0 )
|
||||
return 0;
|
||||
}
|
||||
else if ( value == 254 )
|
||||
{
|
||||
else if (value == 254) {
|
||||
break;
|
||||
}
|
||||
else if ( value >= 0x0f0 )
|
||||
{
|
||||
else if (value >= 0x0f0) {
|
||||
/* not yet used, do nothing */
|
||||
}
|
||||
else if ( value >= 0xe0 )
|
||||
{
|
||||
else if (value >= 0xe0 ) {
|
||||
u8g_SetAddress(u8g, dev, value & 0x0f);
|
||||
}
|
||||
else if ( value >= 0xd0 )
|
||||
{
|
||||
else if (value >= 0xd0) {
|
||||
u8g_SetChipSelect(u8g, dev, value & 0x0f);
|
||||
}
|
||||
else if ( value >= 0xc0 )
|
||||
{
|
||||
else if (value >= 0xc0) {
|
||||
u8g_SetResetLow(u8g, dev);
|
||||
value &= 0x0f;
|
||||
value <<= 4;
|
||||
|
@ -294,13 +268,10 @@ uint8_t u8g_WriteEscSeqP_2_wire(u8g_t *u8g, u8g_dev_t *dev, const uint8_t *esc_s
|
|||
u8g_SetResetHigh(u8g, dev);
|
||||
u8g_Delay(value);
|
||||
}
|
||||
else if ( value >= 0xbe )
|
||||
{
|
||||
/* not yet implemented */
|
||||
else if (value >= 0xbe) { /* not yet implemented */
|
||||
/* u8g_SetVCC(u8g, dev, value & 0x01); */
|
||||
}
|
||||
else if ( value <= 127 )
|
||||
{
|
||||
else if (value <= 127) {
|
||||
u8g_Delay(value);
|
||||
}
|
||||
is_escape = 0;
|
||||
|
|
|
@ -20,41 +20,37 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
|
||||
u8g_dev_st7565_64128n_HAL.c (Displaytech)
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
/**
|
||||
* u8g_dev_st7565_64128n_HAL.c (Displaytech)
|
||||
*
|
||||
* Universal 8bit Graphics Library
|
||||
*
|
||||
* Copyright (c) 2011, olikraus@gmail.com
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
@ -71,78 +67,76 @@
|
|||
|
||||
/* init sequence from https://github.com/adafruit/ST7565-LCD/blob/master/ST7565/ST7565.cpp */
|
||||
static const uint8_t u8g_dev_st7565_64128n_HAL_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
U8G_ESC_RST(15), /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
|
||||
U8G_ESC_CS(0), // disable chip
|
||||
U8G_ESC_ADR(0), // instruction mode
|
||||
U8G_ESC_CS(1), // enable chip
|
||||
U8G_ESC_RST(15), // do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
|
||||
|
||||
0x0A2, /* 0x0a2: LCD bias 1/9 (according to Displaytech 64128N datasheet) */
|
||||
0x0A0, /* Normal ADC Select (according to Displaytech 64128N datasheet) */
|
||||
0x0A2, // 0x0a2: LCD bias 1/9 (according to Displaytech 64128N datasheet)
|
||||
0x0A0, // Normal ADC Select (according to Displaytech 64128N datasheet)
|
||||
|
||||
0x0c8, /* common output mode: set scan direction normal operation/SHL Select, 0x0c0 --> SHL = 0, normal, 0x0c8 --> SHL = 1 */
|
||||
0x040, /* Display start line for Displaytech 64128N */
|
||||
0x0c8, // common output mode: set scan direction normal operation/SHL Select, 0x0c0 --> SHL = 0, normal, 0x0c8 --> SHL = 1
|
||||
0x040, // Display start line for Displaytech 64128N
|
||||
|
||||
0x028 | 0x04, /* power control: turn on voltage converter */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
0x028 | 0x04, // power control: turn on voltage converter
|
||||
U8G_ESC_DLY(50), // delay 50 ms
|
||||
|
||||
0x028 | 0x06, /* power control: turn on voltage regulator */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
0x028 | 0x06, // power control: turn on voltage regulator
|
||||
U8G_ESC_DLY(50), // delay 50 ms
|
||||
|
||||
0x028 | 0x07, /* power control: turn on voltage follower */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
0x028 | 0x07, // power control: turn on voltage follower
|
||||
U8G_ESC_DLY(50), // delay 50 ms
|
||||
|
||||
0x010, /* Set V0 voltage resistor ratio. Setting for controlling brightness of Displaytech 64128N */
|
||||
0x010, // Set V0 voltage resistor ratio. Setting for controlling brightness of Displaytech 64128N
|
||||
|
||||
0x0a6, /* display normal, bit val 0: LCD pixel off. */
|
||||
0x0a6, // display normal, bit val 0: LCD pixel off.
|
||||
|
||||
0x081, /* set contrast */
|
||||
0x01e, /* Contrast value. Setting for controlling brightness of Displaytech 64128N */
|
||||
0x081, // set contrast
|
||||
0x01e, // Contrast value. Setting for controlling brightness of Displaytech 64128N
|
||||
|
||||
|
||||
0x0af, /* display on */
|
||||
0x0af, // display on
|
||||
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a5, /* display all points, ST7565 */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a4, /* normal display */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
U8G_ESC_DLY(100), // delay 100 ms
|
||||
0x0a5, // display all points, ST7565
|
||||
U8G_ESC_DLY(100), // delay 100 ms
|
||||
U8G_ESC_DLY(100), // delay 100 ms
|
||||
0x0a4, // normal display
|
||||
U8G_ESC_CS(0), // disable chip
|
||||
U8G_ESC_END // end of sequence
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_st7565_64128n_HAL_data_start[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x010, /* set upper 4 bit of the col adr to 0x10 */
|
||||
0x000, /* set lower 4 bit of the col adr to 0x00. Changed for DisplayTech 64128N */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
U8G_ESC_ADR(0), // instruction mode
|
||||
U8G_ESC_CS(1), // enable chip
|
||||
0x010, // set upper 4 bit of the col adr to 0x10
|
||||
0x000, // set lower 4 bit of the col adr to 0x00. Changed for DisplayTech 64128N
|
||||
U8G_ESC_END // end of sequence
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_st7565_64128n_HAL_sleep_on[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0ac, /* static indicator off */
|
||||
0x000, /* indicator register set (not sure if this is required) */
|
||||
0x0ae, /* display off */
|
||||
0x0a5, /* all points on */
|
||||
U8G_ESC_CS(0), /* disable chip, bugfix 12 nov 2014 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
U8G_ESC_ADR(0), // instruction mode
|
||||
U8G_ESC_CS(1), // enable chip
|
||||
0x0ac, // static indicator off
|
||||
0x000, // indicator register set (not sure if this is required)
|
||||
0x0ae, // display off
|
||||
0x0a5, // all points on
|
||||
U8G_ESC_CS(0), // disable chip, bugfix 12 nov 2014
|
||||
U8G_ESC_END // end of sequence
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_st7565_64128n_HAL_sleep_off[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0a4, /* all points off */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
U8G_ESC_CS(0), /* disable chip, bugfix 12 nov 2014 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
U8G_ESC_ADR(0), // instruction mode
|
||||
U8G_ESC_CS(1), // enable chip
|
||||
0x0a4, // all points off
|
||||
0x0af, // display on
|
||||
U8G_ESC_DLY(50), // delay 50 ms
|
||||
U8G_ESC_CS(0), // disable chip, bugfix 12 nov 2014
|
||||
U8G_ESC_END // end of sequence
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_st7565_64128n_HAL_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
uint8_t u8g_dev_st7565_64128n_HAL_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_st7565_64128n_HAL_init_seq);
|
||||
|
@ -176,10 +170,8 @@ uint8_t u8g_dev_st7565_64128n_HAL_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, vo
|
|||
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_st7565_64128n_HAL_2x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
uint8_t u8g_dev_st7565_64128n_HAL_2x_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_st7565_64128n_HAL_init_seq);
|
||||
|
|
|
@ -20,40 +20,37 @@
|
|||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
u8g_dev_st7920_128x64_HAL.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.
|
||||
|
||||
|
||||
/**
|
||||
* u8g_dev_st7920_128x64_HAL.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 "../../inc/MarlinConfig.h"
|
||||
|
@ -68,25 +65,24 @@
|
|||
#define HEIGHT 64
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
|
||||
/* init sequence from https://github.com/adafruit/ST7565-LCD/blob/master/ST7565/ST7565.cpp */
|
||||
static const uint8_t u8g_dev_st7920_128x64_HAL_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(15), /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
|
||||
U8G_ESC_DLY(100), /* 8 Dez 2012: additional delay 100 ms because of reset*/
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
U8G_ESC_CS(0), // disable chip
|
||||
U8G_ESC_ADR(0), // instruction mode
|
||||
U8G_ESC_RST(15), // do reset low pulse with (15*16)+2 milliseconds (=maximum delay)
|
||||
U8G_ESC_DLY(100), // 8 Dez 2012: additional delay 100 ms because of reset
|
||||
U8G_ESC_CS(1), // enable chip
|
||||
U8G_ESC_DLY(50), // delay 50 ms
|
||||
|
||||
0x038, /* 8 Bit interface (DL=1), basic instruction set (RE=0) */
|
||||
0x00c, /* display on, cursor & blink off; 0x08: all off */
|
||||
0x006, /* Entry mode: Cursor move to right ,DDRAM address counter (AC) plus 1, no shift */
|
||||
0x002, /* disable scroll, enable CGRAM adress */
|
||||
0x001, /* clear RAM, needs 1.6 ms */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x038, // 8 Bit interface (DL=1), basic instruction set (RE=0)
|
||||
0x00c, // display on, cursor & blink off; 0x08: all off
|
||||
0x006, // Entry mode: Cursor move to right ,DDRAM address counter (AC) plus 1, no shift
|
||||
0x002, // disable scroll, enable CGRAM adress
|
||||
0x001, // clear RAM, needs 1.6 ms
|
||||
U8G_ESC_DLY(100), // delay 100 ms
|
||||
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
U8G_ESC_CS(0), // disable chip
|
||||
U8G_ESC_END // end of sequence
|
||||
};
|
||||
|
||||
void clear_graphics_DRAM(u8g_t *u8g, u8g_dev_t *dev){
|
||||
|
@ -107,13 +103,10 @@ void clear_graphics_DRAM(u8g_t *u8g, u8g_dev_t *dev){
|
|||
u8g_WriteByte(u8g, dev, 0x0C); //display on, cursor+blink off
|
||||
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_st7920_128x64_HAL_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
uint8_t u8g_dev_st7920_128x64_HAL_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_st7920_128x64_HAL_init_seq);
|
||||
|
@ -130,18 +123,15 @@ uint8_t u8g_dev_st7920_128x64_HAL_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, vo
|
|||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
y = pb->p.page_y0;
|
||||
ptr = (uint8_t *)pb->buf;
|
||||
for( i = 0; i < 8; i ++ )
|
||||
{
|
||||
for (i = 0; i < 8; i ++) {
|
||||
u8g_SetAddress(u8g, dev, 0); /* cmd mode */
|
||||
u8g_WriteByte(u8g, dev, 0x03e ); /* enable extended mode */
|
||||
|
||||
if ( y < 32 )
|
||||
{
|
||||
if (y < 32) {
|
||||
u8g_WriteByte(u8g, dev, 0x080 | y ); /* y pos */
|
||||
u8g_WriteByte(u8g, dev, 0x080 ); /* set x pos to 0*/
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
u8g_WriteByte(u8g, dev, 0x080 | (y-32) ); /* y pos */
|
||||
u8g_WriteByte(u8g, dev, 0x080 | 8); /* set x pos to 64*/
|
||||
}
|
||||
|
@ -158,10 +148,8 @@ uint8_t u8g_dev_st7920_128x64_HAL_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, vo
|
|||
return u8g_dev_pb8h1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_st7920_128x64_HAL_4x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
uint8_t u8g_dev_st7920_128x64_HAL_4x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg) {
|
||||
switch(msg) {
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_400NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7920_128x64_HAL_init_seq);
|
||||
|
@ -180,18 +168,15 @@ uint8_t u8g_dev_st7920_128x64_HAL_4x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg,
|
|||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
y = pb->p.page_y0;
|
||||
ptr = (uint8_t *)pb->buf;
|
||||
for( i = 0; i < 32; i ++ )
|
||||
{
|
||||
for (i = 0; i < 32; i ++) {
|
||||
u8g_SetAddress(u8g, dev, 0); /* cmd mode */
|
||||
u8g_WriteByte(u8g, dev, 0x03e ); /* enable extended mode */
|
||||
|
||||
if ( y < 32 )
|
||||
{
|
||||
if (y < 32) {
|
||||
u8g_WriteByte(u8g, dev, 0x080 | y ); /* y pos */
|
||||
u8g_WriteByte(u8g, dev, 0x080 ); /* set x pos to 0*/
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
u8g_WriteByte(u8g, dev, 0x080 | (y-32) ); /* y pos */
|
||||
u8g_WriteByte(u8g, dev, 0x080 | 8); /* set x pos to 64*/
|
||||
}
|
||||
|
@ -215,11 +200,9 @@ uint8_t u8g_dev_st7920_128x64_HAL_4x_buf[QWIDTH] U8G_NOCOMMON ;
|
|||
u8g_pb_t u8g_dev_st7920_128x64_HAL_4x_pb = { {32, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_st7920_128x64_HAL_4x_buf};
|
||||
u8g_dev_t u8g_dev_st7920_128x64_HAL_4x_sw_spi = { u8g_dev_st7920_128x64_HAL_4x_fn, &u8g_dev_st7920_128x64_HAL_4x_pb, U8G_COM_ST7920_HAL_SW_SPI };
|
||||
|
||||
|
||||
U8G_PB_DEV(u8g_dev_st7920_128x64_HAL_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7920_128x64_HAL_fn, U8G_COM_ST7920_HAL_HW_SPI);
|
||||
u8g_dev_t u8g_dev_st7920_128x64_HAL_4x_hw_spi = { u8g_dev_st7920_128x64_HAL_4x_fn, &u8g_dev_st7920_128x64_HAL_4x_pb, U8G_COM_ST7920_HAL_HW_SPI };
|
||||
|
||||
|
||||
#if defined(U8G_HAL_LINKS) || defined(__SAM3X8E__)
|
||||
// Also use this device for HAL version of rrd class. This results in the same device being used
|
||||
// for the ST7920 for HAL systems no matter what is selected in ultralcd_impl_DOGM.h.
|
||||
|
|
Loading…
Reference in a new issue