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
1f759353
Commit
1f759353
authored
Nov 18, 2017
by
devsaurus
Browse files
remove u8g
parent
fd745e09
Changes
102
Show whitespace changes
Inline
Side-by-side
app/u8glib/u8g_dev_t6963_240x128.c
deleted
100644 → 0
View file @
fd745e09
/*
u8g_dev_t6963_240x128.c
Tested with Varitronix MGLS240128TZ
Universal 8bit Graphics Library
Copyright (c) 2013, olikraus@gmail.com
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or other
materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Application Notes for the MGLS 240x128
www.baso.no/content/pdf/T6963C_Application.pdf
Hitachi App Notes:
https://www.sparkfun.com/datasheets/LCD/Monochrome/AN-029-Toshiba_T6963C.pdf
Notes:
The font selection pins should generate the 8x8 font.
For the MGLS240128TZ only FS1 is available on pin 18.
FS1 must be low to generate the 8x8 font.
*/
#include "u8g.h"
#define WIDTH 240
#define HEIGHT 128
#define PAGE_HEIGHT 16
/*
http://www.mark-products.com/graphics.htm#240x64%20Pixel%20Format
*/
/* text is not used, so settings are not relevant */
static
const
uint8_t
u8g_dev_t6963_240x128_init_seq
[]
PROGMEM
=
{
U8G_ESC_CS
(
0
),
/* disable chip */
U8G_ESC_ADR
(
0
),
/* data mode */
U8G_ESC_RST
(
15
),
/* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
U8G_ESC_CS
(
1
),
/* enable chip */
U8G_ESC_DLY
(
50
),
/* delay 50 ms */
U8G_ESC_ADR
(
0
),
/* data mode */
0x000
,
/* low byte */
0x000
,
/* height byte */
U8G_ESC_ADR
(
1
),
/* instruction mode */
0x021
,
/* set cursor position */
U8G_ESC_ADR
(
0
),
/* data mode */
0x000
,
/* low byte */
0x000
,
/* height byte */
U8G_ESC_ADR
(
1
),
/* instruction mode */
0x022
,
/* set offset */
U8G_ESC_ADR
(
0
),
/* data mode */
0x000
,
/* low byte */
0x000
,
/* height byte */
U8G_ESC_ADR
(
1
),
/* instruction mode */
0x040
,
/* text home */
U8G_ESC_ADR
(
0
),
/* data mode */
WIDTH
/
8
,
/* low byte */
0x000
,
/* height byte */
U8G_ESC_ADR
(
1
),
/* instruction mode */
0x041
,
/* text columns */
U8G_ESC_ADR
(
0
),
/* data mode */
0x000
,
/* low byte */
0x000
,
/* height byte */
U8G_ESC_ADR
(
1
),
/* instruction mode */
0x042
,
/* graphics home */
U8G_ESC_ADR
(
0
),
/* data mode */
WIDTH
/
8
,
/* low byte */
0x000
,
/* height byte */
U8G_ESC_ADR
(
1
),
/* instruction mode */
0x043
,
/* graphics columns */
// mode set
// 0x080: Internal CG, OR Mode
// 0x081: Internal CG, EXOR Mode
// 0x083: Internal CG, AND Mode
// 0x088: External CG, OR Mode
// 0x089: External CG, EXOR Mode
// 0x08B: External CG, AND Mode
U8G_ESC_ADR
(
1
),
/* instruction mode */
0x080
,
/* mode register: OR Mode, Internal Character Mode */
U8G_ESC_ADR
(
1
),
/* instruction mode */
// display mode
// 0x090: Display off
// 0x094: Graphic off, text on, cursor off, blink off
// 0x096: Graphic off, text on, cursor on, blink off
// 0x097: Graphic off, text on, cursor on, blink on
// 0x098: Graphic on, text off, cursor off, blink off
// 0x09a: Graphic on, text off, cursor on, blink off
// ...
// 0x09c: Graphic on, text on, cursor off, blink off
// 0x09f: Graphic on, text on, cursor on, blink on
0x098
,
/* mode register: Display Mode, Graphics on, Text off, Cursor off */
U8G_ESC_ADR
(
0
),
/* data mode */
0x000
,
/* low byte */
0x000
,
/* height byte */
U8G_ESC_ADR
(
1
),
/* instruction mode */
0x024
,
/* set adr pointer */
U8G_ESC_DLY
(
100
),
/* delay 100 ms */
U8G_ESC_ADR
(
0
),
/* data mode */
U8G_ESC_CS
(
0
),
/* disable chip */
U8G_ESC_END
/* end of sequence */
};
uint8_t
u8g_dev_t6963_240x128_fn
(
u8g_t
*
u8g
,
u8g_dev_t
*
dev
,
uint8_t
msg
,
void
*
arg
)
{
switch
(
msg
)
{
case
U8G_DEV_MSG_INIT
:
u8g_InitCom
(
u8g
,
dev
,
U8G_SPI_CLK_CYCLE_NONE
);
u8g_WriteEscSeqP
(
u8g
,
dev
,
u8g_dev_t6963_240x128_init_seq
);
break
;
case
U8G_DEV_MSG_STOP
:
break
;
case
U8G_DEV_MSG_PAGE_NEXT
:
{
uint8_t
y
,
i
;
uint16_t
disp_ram_adr
;
uint8_t
*
ptr
;
u8g_pb_t
*
pb
=
(
u8g_pb_t
*
)(
dev
->
dev_mem
);
u8g_SetAddress
(
u8g
,
dev
,
0
);
/* data mode */
u8g_SetChipSelect
(
u8g
,
dev
,
1
);
y
=
pb
->
p
.
page_y0
;
ptr
=
pb
->
buf
;
disp_ram_adr
=
WIDTH
/
8
;
disp_ram_adr
*=
y
;
for
(
i
=
0
;
i
<
PAGE_HEIGHT
;
i
++
)
{
u8g_SetAddress
(
u8g
,
dev
,
0
);
/* data mode */
u8g_WriteByte
(
u8g
,
dev
,
disp_ram_adr
&
255
);
/* address low byte */
u8g_WriteByte
(
u8g
,
dev
,
disp_ram_adr
>>
8
);
/* address hight byte */
u8g_SetAddress
(
u8g
,
dev
,
1
);
/* cmd mode */
u8g_WriteByte
(
u8g
,
dev
,
0x024
);
/* set adr ptr */
u8g_WriteSequence
(
u8g
,
dev
,
WIDTH
/
8
,
ptr
);
ptr
+=
WIDTH
/
8
;
disp_ram_adr
+=
WIDTH
/
8
;
}
u8g_SetAddress
(
u8g
,
dev
,
0
);
/* data mode */
u8g_SetChipSelect
(
u8g
,
dev
,
0
);
}
break
;
}
return
u8g_dev_pb16h1_base_fn
(
u8g
,
dev
,
msg
,
arg
);
}
// U8G_PB_DEV(u8g_dev_t6963_240x128_8bit, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_t6963_240x128_fn, U8G_COM_T6963);
uint8_t
u8g_dev_t6963_240x128_2x_bw_buf
[
WIDTH
/
8
*
PAGE_HEIGHT
]
U8G_NOCOMMON
;
u8g_pb_t
u8g_dev_t6963_240x128_2x_bw_pb
=
{
{
PAGE_HEIGHT
,
HEIGHT
,
0
,
0
,
0
},
WIDTH
,
u8g_dev_t6963_240x128_2x_bw_buf
};
u8g_dev_t
u8g_dev_t6963_240x128_8bit
=
{
u8g_dev_t6963_240x128_fn
,
&
u8g_dev_t6963_240x128_2x_bw_pb
,
U8G_COM_T6963
};
app/u8glib/u8g_dev_t6963_240x64.c
deleted
100644 → 0
View file @
fd745e09
/*
u8g_dev_t6963_240x64.c
Tested with Varitronix MGLS240128TZ
Universal 8bit Graphics Library
Copyright (c) 2013, olikraus@gmail.com
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or other
materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Application Notes for the MGLS 240x128
www.baso.no/content/pdf/T6963C_Application.pdf
Hitachi App Notes:
https://www.sparkfun.com/datasheets/LCD/Monochrome/AN-029-Toshiba_T6963C.pdf
Notes:
The font selection pins should generate the 8x8 font.
For the MGLS240128TZ only FS1 is available on pin 18.
FS1 must be low to generate the 8x8 font.
*/
#include "u8g.h"
#define WIDTH 240
#define HEIGHT 64
#define PAGE_HEIGHT 16
/*
http://www.mark-products.com/graphics.htm#240x64%20Pixel%20Format
*/
/* text is not used, so settings are not relevant */
static
const
uint8_t
u8g_dev_t6963_240x64_init_seq
[]
PROGMEM
=
{
U8G_ESC_CS
(
0
),
/* disable chip */
U8G_ESC_ADR
(
0
),
/* data mode */
U8G_ESC_RST
(
15
),
/* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
U8G_ESC_CS
(
1
),
/* enable chip */
U8G_ESC_DLY
(
50
),
/* delay 50 ms */
U8G_ESC_ADR
(
0
),
/* data mode */
0x000
,
/* low byte */
0x000
,
/* height byte */
U8G_ESC_ADR
(
1
),
/* instruction mode */
0x021
,
/* set cursor position */
U8G_ESC_ADR
(
0
),
/* data mode */
0x000
,
/* low byte */
0x000
,
/* height byte */
U8G_ESC_ADR
(
1
),
/* instruction mode */
0x022
,
/* set offset */
U8G_ESC_ADR
(
0
),
/* data mode */
0x000
,
/* low byte */
0x000
,
/* height byte */
U8G_ESC_ADR
(
1
),
/* instruction mode */
0x040
,
/* text home */
U8G_ESC_ADR
(
0
),
/* data mode */
WIDTH
/
8
,
/* low byte */
0x000
,
/* height byte */
U8G_ESC_ADR
(
1
),
/* instruction mode */
0x041
,
/* text columns */
U8G_ESC_ADR
(
0
),
/* data mode */
0x000
,
/* low byte */
0x000
,
/* height byte */
U8G_ESC_ADR
(
1
),
/* instruction mode */
0x042
,
/* graphics home */
U8G_ESC_ADR
(
0
),
/* data mode */
WIDTH
/
8
,
/* low byte */
0x000
,
/* height byte */
U8G_ESC_ADR
(
1
),
/* instruction mode */
0x043
,
/* graphics columns */
// mode set
// 0x080: Internal CG, OR Mode
// 0x081: Internal CG, EXOR Mode
// 0x083: Internal CG, AND Mode
// 0x088: External CG, OR Mode
// 0x089: External CG, EXOR Mode
// 0x08B: External CG, AND Mode
U8G_ESC_ADR
(
1
),
/* instruction mode */
0x080
,
/* mode register: OR Mode, Internal Character Mode */
U8G_ESC_ADR
(
1
),
/* instruction mode */
// display mode
// 0x090: Display off
// 0x094: Graphic off, text on, cursor off, blink off
// 0x096: Graphic off, text on, cursor on, blink off
// 0x097: Graphic off, text on, cursor on, blink on
// 0x098: Graphic on, text off, cursor off, blink off
// 0x09a: Graphic on, text off, cursor on, blink off
// ...
// 0x09c: Graphic on, text on, cursor off, blink off
// 0x09f: Graphic on, text on, cursor on, blink on
0x098
,
/* mode register: Display Mode, Graphics on, Text off, Cursor off */
U8G_ESC_ADR
(
0
),
/* data mode */
0x000
,
/* low byte */
0x000
,
/* height byte */
U8G_ESC_ADR
(
1
),
/* instruction mode */
0x024
,
/* set adr pointer */
U8G_ESC_DLY
(
100
),
/* delay 100 ms */
U8G_ESC_ADR
(
0
),
/* data mode */
U8G_ESC_CS
(
0
),
/* disable chip */
U8G_ESC_END
/* end of sequence */
};
uint8_t
u8g_dev_t6963_240x64_fn
(
u8g_t
*
u8g
,
u8g_dev_t
*
dev
,
uint8_t
msg
,
void
*
arg
)
{
switch
(
msg
)
{
case
U8G_DEV_MSG_INIT
:
u8g_InitCom
(
u8g
,
dev
,
U8G_SPI_CLK_CYCLE_NONE
);
u8g_WriteEscSeqP
(
u8g
,
dev
,
u8g_dev_t6963_240x64_init_seq
);
break
;
case
U8G_DEV_MSG_STOP
:
break
;
case
U8G_DEV_MSG_PAGE_NEXT
:
{
uint8_t
y
,
i
;
uint16_t
disp_ram_adr
;
uint8_t
*
ptr
;
u8g_pb_t
*
pb
=
(
u8g_pb_t
*
)(
dev
->
dev_mem
);
u8g_SetAddress
(
u8g
,
dev
,
0
);
/* data mode */
u8g_SetChipSelect
(
u8g
,
dev
,
1
);
y
=
pb
->
p
.
page_y0
;
ptr
=
pb
->
buf
;
disp_ram_adr
=
WIDTH
/
8
;
disp_ram_adr
*=
y
;
for
(
i
=
0
;
i
<
PAGE_HEIGHT
;
i
++
)
{
u8g_SetAddress
(
u8g
,
dev
,
0
);
/* data mode */
u8g_WriteByte
(
u8g
,
dev
,
disp_ram_adr
&
255
);
/* address low byte */
u8g_WriteByte
(
u8g
,
dev
,
disp_ram_adr
>>
8
);
/* address hight byte */
u8g_SetAddress
(
u8g
,
dev
,
1
);
/* cmd mode */
u8g_WriteByte
(
u8g
,
dev
,
0x024
);
/* set adr ptr */
u8g_WriteSequence
(
u8g
,
dev
,
WIDTH
/
8
,
ptr
);
ptr
+=
WIDTH
/
8
;
disp_ram_adr
+=
WIDTH
/
8
;
}
u8g_SetAddress
(
u8g
,
dev
,
0
);
/* data mode */
u8g_SetChipSelect
(
u8g
,
dev
,
0
);
}
break
;
}
return
u8g_dev_pb16h1_base_fn
(
u8g
,
dev
,
msg
,
arg
);
}
// U8G_PB_DEV(u8g_dev_t6963_240x64_8bit, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_t6963_240x64_fn, U8G_COM_T6963);
uint8_t
u8g_dev_t6963_240x64_2x_bw_buf
[
WIDTH
/
8
*
PAGE_HEIGHT
]
U8G_NOCOMMON
;
u8g_pb_t
u8g_dev_t6963_240x64_2x_bw_pb
=
{
{
PAGE_HEIGHT
,
HEIGHT
,
0
,
0
,
0
},
WIDTH
,
u8g_dev_t6963_240x64_2x_bw_buf
};
u8g_dev_t
u8g_dev_t6963_240x64_8bit
=
{
u8g_dev_t6963_240x64_fn
,
&
u8g_dev_t6963_240x64_2x_bw_pb
,
U8G_COM_T6963
};
app/u8glib/u8g_dev_tls8204_84x48.c
deleted
100644 → 0
View file @
fd745e09
/*
u8g_dev_tls8204_84x48.c
Display: Nokia 84x48
Status: Tested with TLS8204V12 Display by Olimex MOD-LCD3310
Contributed: http://code.google.com/p/u8glib/issues/detail?id=126
Universal 8bit Graphics Library
Copyright (c) 2011, olikraus@gmail.com
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or other
materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "u8g.h"
#define WIDTH 84
#define HEIGHT 48
#define PAGE_HEIGHT 8
static
const
uint8_t
u8g_dev_tls8204_init_seq
[]
PROGMEM
=
{
U8G_ESC_CS
(
0
),
/* disable chip */
U8G_ESC_ADR
(
0
),
/* instruction mode */
U8G_ESC_RST
(
1
),
/* do reset low pulse with (1*16)+2 milliseconds */
U8G_ESC_CS
(
1
),
/* enable chip */
0x021
,
/* activate chip (PD=0), horizontal increment (V=0), enter extended command set (H=1) */
0x006
,
/* temp. control: b10 = 2 */
0x04
|
!!
((
66
-
1
)
&
(
1u
<<
6
)),
0x40
|
((
66
-
2
)
&
((
1u
<<
6
)
-
1
)),
0x013
,
/* bias system 1:48 */
0x0c0
,
/* medium Vop */
0x020
,
/* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
0x00c
,
/* display on, normal operation */
U8G_ESC_DLY
(
100
),
/* delay 100 ms */
0x020
,
/* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
0x00d
,
/* display on, invert */
U8G_ESC_DLY
(
100
),
/* delay 100 ms */
U8G_ESC_DLY
(
100
),
/* delay 100 ms */
0x020
,
/* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
0x00c
,
/* display on, normal */
U8G_ESC_DLY
(
100
),
/* delay 100 ms */
U8G_ESC_CS
(
0
),
/* disable chip */
U8G_ESC_END
/* end of sequence */
};
uint8_t
u8g_dev_tls8204_fn
(
u8g_t
*
u8g
,
u8g_dev_t
*
dev
,
uint8_t
msg
,
void
*
arg
)
{
switch
(
msg
)
{
case
U8G_DEV_MSG_INIT
:
u8g_InitCom
(
u8g
,
dev
,
U8G_SPI_CLK_CYCLE_400NS
);
u8g_WriteEscSeqP
(
u8g
,
dev
,
u8g_dev_tls8204_init_seq
);
break
;
case
U8G_DEV_MSG_STOP
:
break
;
case
U8G_DEV_MSG_PAGE_NEXT
:
{
u8g_pb_t
*
pb
=
(
u8g_pb_t
*
)(
dev
->
dev_mem
);
u8g_SetAddress
(
u8g
,
dev
,
0
);
/* command mode */
u8g_SetChipSelect
(
u8g
,
dev
,
1
);
u8g_WriteByte
(
u8g
,
dev
,
0x020
);
/* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
u8g_WriteByte
(
u8g
,
dev
,
0x080
);
/* set X address */
u8g_WriteByte
(
u8g
,
dev
,
0x040
|
pb
->
p
.
page
);
/* set Y address */
u8g_SetAddress
(
u8g
,
dev
,
1
);
/* data mode */
if
(
u8g_pb_WriteBuffer
(
pb
,
u8g
,
dev
)
==
0
)
return
0
;
u8g_SetChipSelect
(
u8g
,
dev
,
0
);
}
break
;
case
U8G_DEV_MSG_CONTRAST
:
/* the contrast adjustment does not work, needs to be analysed */
u8g_SetAddress
(
u8g
,
dev
,
0
);
/* instruction mode */
u8g_SetChipSelect
(
u8g
,
dev
,
1
);
u8g_WriteByte
(
u8g
,
dev
,
0x021
);
/* command mode, extended function set */
u8g_WriteByte
(
u8g
,
dev
,
0x080
|
(
(
*
(
uint8_t
*
)
arg
)
>>
1
)
);
u8g_WriteByte
(
u8g
,
dev
,
0x020
);
/* command mode, extended function set */
u8g_SetChipSelect
(
u8g
,
dev
,
0
);
return
1
;
}
return
u8g_dev_pb8v1_base_fn
(
u8g
,
dev
,
msg
,
arg
);
}
U8G_PB_DEV
(
u8g_dev_tls8204_84x48_sw_spi
,
WIDTH
,
HEIGHT
,
PAGE_HEIGHT
,
u8g_dev_tls8204_fn
,
U8G_COM_SW_SPI
);
app/u8glib/u8g_dev_uc1601_c128032.c
deleted
100644 → 0
View file @
fd745e09
/*
u8g_dev_uc1601_c128032.c
LCD-AG-C128032R-DIW W/KK E6 PBF from http://www.artronic.pl/o_produkcie.php?id=1343
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 WIDTH 128
#define HEIGHT 32
#define PAGE_HEIGHT 8
/* init sequence */
static
const
uint8_t
u8g_dev_uc1601_c128032_init_seq
[]
PROGMEM
=
{
U8G_ESC_CS
(
0
),
/* disable chip */
U8G_ESC_ADR
(
0
),
/* instruction mode */
U8G_ESC_CS
(
1
),
/* enable chip */
U8G_ESC_RST
(
15
),
/* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
0x0a3
,
/* 0x0a3: LCD bias 1/7 , 0x0a2: LCD bias 1/9 */
0x0a0
,
/* 0x0a0: ADC set to normal, 0x0a1 ADC set to inverted */
0x0c8
,
/* common output mode: set scan direction normal operation/SHL Select, 0x0c0 --> SHL = 0, normal, 0x0c8 --> SHL = 1 */
0x0c2
,
/* 22 May 2013: mirror x */
0x040
,
/* set display start line */
0x028
|
0x04
,
/* power control: turn on voltage converter */
U8G_ESC_DLY
(
50
),
/* delay 50 ms */
0x028
|
0x06
,
/* power control: turn on voltage regulator */
U8G_ESC_DLY
(
50
),
/* delay 50 ms */
0x028
|
0x07
,
/* power control: turn on voltage follower */
U8G_ESC_DLY
(
10
),
/* delay 10 ms */
0x020
|
0x06
,
/* set V0 voltage resistor ratio to 6 */
0x0af
,
/* display on */
//0x081, /* set contrast */
//0x018, /* contrast value*/
0x0a6
,
/* display normal, bit val 0: LCD pixel off. */
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_uc1601_c128032_data_start
[]
PROGMEM
=
{
U8G_ESC_ADR
(
0
),
/* instruction mode */
U8G_ESC_CS
(
1
),
/* enable chip */
0x010
,
/* set upper 4 bit of the col adr to 0 */
0x004
,
/* set lower 4 bit of the col adr */
U8G_ESC_END
/* end of sequence */
};
static
const
uint8_t
u8g_dev_uc1601_c128032_sleep_on
[]
PROGMEM
=
{
U8G_ESC_ADR
(
0
),
/* instruction mode */
U8G_ESC_CS
(
1
),
/* enable chip */
0x0ac
,
/* static indicator off */
0x000
,
/* indicator register set (not sure if this is required) */
0x0ae
,
/* display off */
0x0a5
,
/* all points on */
U8G_ESC_CS
(
1
),
/* disable chip */
U8G_ESC_END
/* end of sequence */
};
static
const
uint8_t
u8g_dev_uc1601_c128032_sleep_off
[]
PROGMEM
=
{
U8G_ESC_ADR
(
0
),
/* instruction mode */
U8G_ESC_CS
(
1
),
/* enable chip */
0x0a4
,
/* all points off */
0x0af
,
/* display on */
U8G_ESC_DLY
(
50
),
/* delay 50 ms */
U8G_ESC_CS
(
1
),
/* disable chip */
U8G_ESC_END
/* end of sequence */
};
uint8_t
u8g_dev_uc1601_c128032_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
(
u8g
,
dev
,
u8g_dev_uc1601_c128032_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_uc1601_c128032_data_start
);
u8g_WriteByte
(
u8g
,
dev
,
0x0b0
|
pb
->
p
.
page
);
/* select current page (UC1601) */
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_uc1601_c128032_sleep_on
);
return
1
;
case
U8G_DEV_MSG_SLEEP_OFF
:
u8g_WriteEscSeqP
(
u8g
,
dev
,
u8g_dev_uc1601_c128032_sleep_off
);
return
1
;
}
return
u8g_dev_pb8v1_base_fn
(
u8g
,
dev
,
msg
,
arg
);
}
uint8_t
u8g_dev_uc1601_c128032_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_300NS
);
u8g_WriteEscSeqP
(
u8g
,
dev
,
u8g_dev_uc1601_c128032_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_uc1601_c128032_data_start
);
u8g_WriteByte
(
u8g
,
dev
,
0x0b0
|
(
2
*
pb
->
p
.
page
));
/* select current page (UC1601) */
u8g_SetAddress
(
u8g
,
dev
,
1
);
/* data mode */
u8g_WriteSequence
(
u8g
,
dev
,
pb
->
width
,
pb
->
buf
);
u8g_SetChipSelect
(
u8g
,
dev
,
0
);
u8g_WriteEscSeqP
(
u8g
,
dev
,
u8g_dev_uc1601_c128032_data_start
);
u8g_WriteByte
(
u8g
,
dev
,
0x0b0
|
(
2
*
pb
->
p
.
page
+
1
));
/* select current page (UC1601) */
u8g_SetAddress
(
u8g
,
dev
,
1
);
/* data mode */
u8g_WriteSequence
(
u8g
,
dev
,
pb
->
width
,
(
uint8_t
*
)(
pb
->
buf
)
+
pb
->
width
);
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_uc1601_c128032_sleep_on
);
return
1
;
case
U8G_DEV_MSG_SLEEP_OFF
:
u8g_WriteEscSeqP
(
u8g
,
dev
,
u8g_dev_uc1601_c128032_sleep_off
);
return
1
;
}
return
u8g_dev_pb16v1_base_fn
(
u8g
,
dev
,
msg
,
arg
);
}
U8G_PB_DEV
(
u8g_dev_uc1601_c128032_sw_spi
,
WIDTH
,
HEIGHT
,
PAGE_HEIGHT
,
u8g_dev_uc1601_c128032_fn
,
U8G_COM_SW_SPI
);
U8G_PB_DEV
(
u8g_dev_uc1601_c128032_hw_spi
,
WIDTH
,
HEIGHT
,
PAGE_HEIGHT
,
u8g_dev_uc1601_c128032_fn
,
U8G_COM_HW_SPI
);
uint8_t
u8g_dev_uc1601_c128032_2x_buf
[
WIDTH
*
2
]
U8G_NOCOMMON
;
u8g_pb_t
u8g_dev_uc1601_c128032_2x_pb
=
{
{
16
,
HEIGHT
,
0
,
0
,
0
},
WIDTH
,
u8g_dev_uc1601_c128032_2x_buf
};
u8g_dev_t
u8g_dev_uc1601_c128032_2x_sw_spi
=
{
u8g_dev_uc1601_c128032_2x_fn
,
&
u8g_dev_uc1601_c128032_2x_pb
,
U8G_COM_SW_SPI
};
u8g_dev_t
u8g_dev_uc1601_c128032_2x_hw_spi
=
{
u8g_dev_uc1601_c128032_2x_fn
,
&
u8g_dev_uc1601_c128032_2x_pb
,
U8G_COM_HW_SPI
};
app/u8glib/u8g_dev_uc1608_240x128.c
deleted
100644 → 0
View file @
fd745e09
/*
u8g_dev_uc1608_240x128.c
Universal 8bit Graphics Library
Copyright (c) 2013, olikraus@gmail.com (original 240x64 library)
Modified by thieringpeti@gmail.com for Raystar rx240128 family displays
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.
*/
/*
Display: http://www.tme.eu/en/details/rx240128a-ghw/lcd-graphic-displays/raystar-optronics/
Connection: HW / SW SPI.
To get this display working, You need some extra capacitors:
connect 4.7uF caps between:
PIN1 & PIN2 VB1 +-
PIN3 & PIN4 VB0 -+
connect 0.1uF caps between:
VLCD and VSS
VBIAS and VSS
You can find some schematics with a 10M resistor parallellized with the VLCD capacitor.
Select 4-bit SPI mode.
Connect D7 (PIN9) To VDD (+3.3V)
Connect D1, D2, D4, D5, D6 to GND (PINS 10,11,12,14,15)
Connect WR0, WR1, BM0, BM1 to GND (PINS 17,18,22,23)
D0: (PIN16) AVR's SCK pin (HW SPI)
D3: (PIN13) AVR's MOSI pin (HW SPI)
CD: (PIN19) used as A0 in the library
CS: (PIN21) Connect to the defined CS pin, and You can re-use the HW SPI in different routines.
RST: (PIN20) optional reset, can be defined in the function, resets on initialization.
Adjust contrast if necessary. Default: 0x072.
*/
#include "u8g.h"
#define WIDTH 240
#define HEIGHT 128
#define PAGE_HEIGHT 8
/* see also ERC24064-1 for init sequence example */
static
const
uint8_t
u8g_dev_uc1608_240x128_init_seq
[]
PROGMEM
=
{
U8G_ESC_CS
(
1
),
/* disable chip (UC1608 has positive logic for CS) */
U8G_ESC_ADR
(
0
),
/* instruction mode */
U8G_ESC_RST
(
1
),
/* do reset low pulse with (15*16)+2 milliseconds */
U8G_ESC_CS
(
0
),
/* enable chip */
0x0e2
,
/* soft reset */
U8G_ESC_DLY
(
100
),
/* delay 100 ms */
U8G_ESC_DLY
(
100
),
/* delay 100 ms */
0x026
,
/* MUX rate and temperature compensation */
0x0c8
,
/* Map control, Bit 3: MY=1, Bit 2: MX=0, Bit 0: MSF =0 */
0x0eb
,
/* LCD bias Bits 0/1: 00=10.7 01=10.3, 10=12.0, 11=12.7*/
/* default 0x0ea for 240x128 */
0x081
,
/* set contrast (bits 0..5) and gain (bits 6/7) */
0x072
,
/* default for 240x128 displays: 0x072*/
0x02f
,
/* power on, Bit 2 PC2=1 (internal charge pump), Bits 0/1: cap of panel */
U8G_ESC_DLY
(
50
),
/* delay 50 ms */
0x040
,
/* set display start line to 0 */
0x090
,
/* no fixed lines */
0x089
,
/* RAM access control */
0x0af
,
/* disable sleep mode */
0x0a4
,
/* normal display */
0x0a5
,
/* display all points, ST7565, UC1610 */
// 0x0a7, /* inverse display */
0x0a6
,
/* normal display */
U8G_ESC_DLY
(
100
),
/* delay 100 ms */
0x0a4
,
/* normal display */
U8G_ESC_CS
(
1
),
/* disable chip */
U8G_ESC_END
/* end of sequence */
};
static
const
uint8_t
u8g_dev_uc1608_240x128_data_start
[]
PROGMEM
=
{
U8G_ESC_ADR
(
0
),
/* instruction mode */
U8G_ESC_CS
(
0
),
/* enable chip */
0x010
,
/* set upper 4 bit of the col adr to 0 (UC1608) */
0x000
,
/* set lower 4 bit of the col adr to 0 */
U8G_ESC_END
/* end of sequence */
};
uint8_t
u8g_dev_uc1608_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_300NS
);
u8g_WriteEscSeqP
(
u8g
,
dev
,
u8g_dev_uc1608_240x128_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_uc1608_240x128_data_start
);
u8g_WriteByte
(
u8g
,
dev
,
0x0b0
|
pb
->
p
.
page
);
/* select current page (UC1608) */
u8g_SetAddress
(
u8g
,
dev
,
1
);
/* data mode */
if
(
u8g_pb_WriteBuffer
(
pb
,
u8g
,
dev
)
==
0
)
return
0
;
u8g_SetChipSelect
(
u8g
,
dev
,
1
);
}
break
;
case
U8G_DEV_MSG_CONTRAST
:
u8g_SetChipSelect
(
u8g
,
dev
,
0
);
u8g_SetAddress
(
u8g
,
dev
,
0
);
/* instruction mode */
u8g_WriteByte
(
u8g
,
dev
,
0x081
);
u8g_WriteByte
(
u8g
,
dev
,
(
*
(
uint8_t
*
)
arg
)
>>
2
);
/* set contrast from, keep gain at 0 */
u8g_SetChipSelect
(
u8g
,
dev
,
1
);
return
1
;
}
return
u8g_dev_pb8v1_base_fn
(
u8g
,
dev
,
msg
,
arg
);
}
uint8_t
u8g_dev_uc1608_240x128_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_300NS
);
u8g_WriteEscSeqP
(
u8g
,
dev
,
u8g_dev_uc1608_240x128_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_uc1608_240x128_data_start
);
u8g_WriteByte
(
u8g
,
dev
,
0x0b0
|
(
2
*
pb
->
p
.
page
));
/* select current page (ST7565R) */
u8g_SetAddress
(
u8g
,
dev
,
1
);
/* data mode */
u8g_WriteSequence
(
u8g
,
dev
,
pb
->
width
,
pb
->
buf
);
u8g_SetChipSelect
(
u8g
,
dev
,
0
);
u8g_WriteEscSeqP
(
u8g
,
dev
,
u8g_dev_uc1608_240x128_data_start
);
u8g_WriteByte
(
u8g
,
dev
,
0x0b0
|
(
2
*
pb
->
p
.
page
+
1
));
/* select current page (ST7565R) */
u8g_SetAddress
(
u8g
,
dev
,
1
);
/* data mode */
u8g_WriteSequence
(
u8g
,
dev
,
pb
->
width
,
(
uint8_t
*
)(
pb
->
buf
)
+
pb
->
width
);
u8g_SetChipSelect
(
u8g
,
dev
,
0
);
}
break
;
case
U8G_DEV_MSG_CONTRAST
:
u8g_SetChipSelect
(
u8g
,
dev
,
1
);
u8g_SetAddress
(
u8g
,
dev
,
0
);
/* instruction mode */
u8g_WriteByte
(
u8g
,
dev
,
0x081
);
u8g_WriteByte
(
u8g
,
dev
,
(
*
(
uint8_t
*
)
arg
)
>>
2
);
u8g_SetChipSelect
(
u8g
,
dev
,
0
);
return
1
;
}
return
u8g_dev_pb16v1_base_fn
(
u8g
,
dev
,
msg
,
arg
);
}
U8G_PB_DEV
(
u8g_dev_uc1608_240x128_sw_spi
,
WIDTH
,
HEIGHT
,
PAGE_HEIGHT
,
u8g_dev_uc1608_240x128_fn
,
U8G_COM_SW_SPI
);
U8G_PB_DEV
(
u8g_dev_uc1608_240x128_hw_spi
,
WIDTH
,
HEIGHT
,
PAGE_HEIGHT
,
u8g_dev_uc1608_240x128_fn
,
U8G_COM_HW_SPI
);
uint8_t
u8g_dev_uc1608_240x128_2x_buf
[
WIDTH
*
2
]
U8G_NOCOMMON
;
u8g_pb_t
u8g_dev_uc1608_240x128_2x_pb
=
{
{
16
,
HEIGHT
,
0
,
0
,
0
},
WIDTH
,
u8g_dev_uc1608_240x128_2x_buf
};
u8g_dev_t
u8g_dev_uc1608_240x128_2x_sw_spi
=
{
u8g_dev_uc1608_240x128_2x_fn
,
&
u8g_dev_uc1608_240x128_2x_pb
,
U8G_COM_SW_SPI
};
u8g_dev_t
u8g_dev_uc1608_240x128_2x_hw_spi
=
{
u8g_dev_uc1608_240x128_2x_fn
,
&
u8g_dev_uc1608_240x128_2x_pb
,
U8G_COM_HW_SPI
};
app/u8glib/u8g_dev_uc1608_240x64.c
deleted
100644 → 0
View file @
fd745e09
/*
u8g_dev_uc1608_240x64.c
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 WIDTH 240
#define HEIGHT 64
#define PAGE_HEIGHT 8
/* see also ERC24064-1 for init sequence example */
static
const
uint8_t
u8g_dev_uc1608_240x64_init_seq
[]
PROGMEM
=
{
U8G_ESC_CS
(
1
),
/* disable chip (UC1608 has positive logic for CS) */
U8G_ESC_ADR
(
0
),
/* instruction mode */
U8G_ESC_RST
(
1
),
/* do reset low pulse with (15*16)+2 milliseconds */
U8G_ESC_CS
(
0
),
/* enable chip */
0x0e2
,
/* soft reset */
U8G_ESC_DLY
(
100
),
/* delay 100 ms */
U8G_ESC_DLY
(
100
),
/* delay 100 ms */
#if HEIGHT <= 96
0x023
,
/* Bit 0/1: Temp compenstation, Bit 2: Multiplex Rate 0=96, 1=128 */
#else
/* 30 Nov 2013: not tested */
0x027
,
/* Bit 0/1: Temp compenstation, Bit 2: Multiplex Rate 0=96, 1=128 */
#endif
0x0c8
,
/* Map control, Bit 3: MY=1, Bit 2: MX=0, Bit 0: MSF =0 */
0x0e8
,
/* LCD bias Bits 0/1: 00=10.7 01=10.3, 10=12.0, 11=12.7*/
0x081
,
/* set contrast (bits 0..5) and gain (bits 6/7) */
0x014
,
/* ECR24064-1 default: 0x040*/
0x02f
,
/* power on, Bit 2 PC2=1 (internal charge pump), Bits 0/1: cap of panel */
U8G_ESC_DLY
(
50
),
/* delay 50 ms */
0x040
,
/* set display start line to 0 */
0x090
,
/* no fixed lines */
0x089
,
/* RAM access control */
0x0af
,
/* disable sleep mode */
0x0a4
,
/* normal display */
0x0a5
,
/* display all points, ST7565, UC1610 */
U8G_ESC_DLY
(
100
),
/* delay 100 ms */
0x0a4
,
/* normal display */
U8G_ESC_CS
(
1
),
/* disable chip */
U8G_ESC_END
/* end of sequence */
};
static
const
uint8_t
u8g_dev_uc1608_240x64_data_start
[]
PROGMEM
=
{
U8G_ESC_ADR
(
0
),
/* instruction mode */
U8G_ESC_CS
(
0
),
/* enable chip */
0x010
,
/* set upper 4 bit of the col adr to 0 (UC1608) */
0x000
,
/* set lower 4 bit of the col adr to 0 */
U8G_ESC_END
/* end of sequence */
};
uint8_t
u8g_dev_uc1608_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_300NS
);
u8g_WriteEscSeqP
(
u8g
,
dev
,
u8g_dev_uc1608_240x64_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_uc1608_240x64_data_start
);
u8g_WriteByte
(
u8g
,
dev
,
0x0b0
|
pb
->
p
.
page
);
/* select current page (UC1608) */
u8g_SetAddress
(
u8g
,
dev
,
1
);
/* data mode */
if
(
u8g_pb_WriteBuffer
(
pb
,
u8g
,
dev
)
==
0
)
return
0
;
u8g_SetChipSelect
(
u8g
,
dev
,
1
);
}
break
;
case
U8G_DEV_MSG_CONTRAST
:
u8g_SetChipSelect
(
u8g
,
dev
,
0
);
u8g_SetAddress
(
u8g
,
dev
,
0
);
/* instruction mode */
u8g_WriteByte
(
u8g
,
dev
,
0x081
);
u8g_WriteByte
(
u8g
,
dev
,
(
*
(
uint8_t
*
)
arg
)
>>
2
);
/* set contrast from, keep gain at 0 */
u8g_SetChipSelect
(
u8g
,
dev
,
1
);
return
1
;
}
return
u8g_dev_pb8v1_base_fn
(
u8g
,
dev
,
msg
,
arg
);
}
uint8_t
u8g_dev_uc1608_240x64_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_300NS
);
u8g_WriteEscSeqP
(
u8g
,
dev
,
u8g_dev_uc1608_240x64_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_uc1608_240x64_data_start
);
u8g_WriteByte
(
u8g
,
dev
,
0x0b0
|
(
2
*
pb
->
p
.
page
));
/* select current page (ST7565R) */
u8g_SetAddress
(
u8g
,
dev
,
1
);
/* data mode */
u8g_WriteSequence
(
u8g
,
dev
,
pb
->
width
,
pb
->
buf
);
u8g_SetChipSelect
(
u8g
,
dev
,
0
);
u8g_WriteEscSeqP
(
u8g
,
dev
,
u8g_dev_uc1608_240x64_data_start
);
u8g_WriteByte
(
u8g
,
dev
,
0x0b0
|
(
2
*
pb
->
p
.
page
+
1
));
/* select current page (ST7565R) */
u8g_SetAddress
(
u8g
,
dev
,
1
);
/* data mode */
u8g_WriteSequence
(
u8g
,
dev
,
pb
->
width
,
(
uint8_t
*
)(
pb
->
buf
)
+
pb
->
width
);
u8g_SetChipSelect
(
u8g
,
dev
,
0
);
}
break
;
case
U8G_DEV_MSG_CONTRAST
:
u8g_SetChipSelect
(
u8g
,
dev
,
1
);
u8g_SetAddress
(
u8g
,
dev
,
0
);
/* instruction mode */
u8g_WriteByte
(
u8g
,
dev
,
0x081
);
u8g_WriteByte
(
u8g
,
dev
,
(
*
(
uint8_t
*
)
arg
)
>>
2
);
u8g_SetChipSelect
(
u8g
,
dev
,
0
);
return
1
;
}
return
u8g_dev_pb16v1_base_fn
(
u8g
,
dev
,
msg
,
arg
);
}
U8G_PB_DEV
(
u8g_dev_uc1608_240x64_sw_spi
,
WIDTH
,
HEIGHT
,
PAGE_HEIGHT
,
u8g_dev_uc1608_240x64_fn
,
U8G_COM_SW_SPI
);
U8G_PB_DEV
(
u8g_dev_uc1608_240x64_hw_spi
,
WIDTH
,
HEIGHT
,
PAGE_HEIGHT
,
u8g_dev_uc1608_240x64_fn
,
U8G_COM_HW_SPI
);
uint8_t
u8g_dev_uc1608_240x64_2x_buf
[
WIDTH
*
2
]
U8G_NOCOMMON
;
u8g_pb_t
u8g_dev_uc1608_240x64_2x_pb
=
{
{
16
,
HEIGHT
,
0
,
0
,
0
},
WIDTH
,
u8g_dev_uc1608_240x64_2x_buf
};
u8g_dev_t
u8g_dev_uc1608_240x64_2x_sw_spi
=
{
u8g_dev_uc1608_240x64_2x_fn
,
&
u8g_dev_uc1608_240x64_2x_pb
,
U8G_COM_SW_SPI
};
u8g_dev_t
u8g_dev_uc1608_240x64_2x_hw_spi
=
{
u8g_dev_uc1608_240x64_2x_fn
,
&
u8g_dev_uc1608_240x64_2x_pb
,
U8G_COM_HW_SPI
};
app/u8glib/u8g_dev_uc1610_dogxl160.c
deleted
100644 → 0
View file @
fd745e09
/*
u8g_dev_uc1610_dogxl160.c
Universal 8bit Graphics Library
Copyright (c) 2011, olikraus@gmail.com
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or other
materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "u8g.h"
#define WIDTH 160
#define HEIGHT 104
static
const
uint8_t
u8g_dev_uc1610_dogxl160_init_seq
[]
PROGMEM
=
{
U8G_ESC_CS
(
0
),
/* disable chip */
U8G_ESC_ADR
(
0
),
/* instruction mode */
U8G_ESC_RST
(
1
),
/* do reset low pulse with (1*16)+2 milliseconds */
U8G_ESC_CS
(
1
),
/* enable chip */
0x0f1
,
/* set display height-1 */
0x067
,
/* */
0x0c0
,
/* SEG & COM normal */
0x040
,
/* set display start line */
0x050
,
/* */
0x02b
,
/* set panelloading */
0x0eb
,
/* set bias 1/2 */
0x081
,
/* set contrast */
0x05f
,
/* */
0x089
,
/* set auto increment */
0x0a6
,
/* normal pixel mode */
0x0d3
,
/* 0xd3=40% RMS separation for gray levels */
0x0af
,
/* display on */
U8G_ESC_DLY
(
100
),
/* delay 100 ms */
0x0a5
,
/* display all points, ST7565, UC1610 */
U8G_ESC_DLY
(
100
),
/* delay 100 ms */
U8G_ESC_DLY
(
100
),
/* delay 100 ms */
0x0a4
,
/* normal display */
U8G_ESC_CS
(
0
),
/* disable chip */
U8G_ESC_END
/* end of sequence */
};
static
const
uint8_t
u8g_dev_uc1610_dogxl160_data_start
[]
PROGMEM
=
{
U8G_ESC_ADR
(
0
),
/* instruction mode */
U8G_ESC_CS
(
1
),
/* enable chip */
0x010
,
/* set upper 4 bit of the col adr to 0 */
0x000
,
/* set lower 4 bit of the col adr to 0 */
U8G_ESC_END
/* end of sequence */
};
static
uint8_t
u8g_dev_1to2
(
uint8_t
n
)
{
register
uint8_t
a
,
b
,
c
;
a
=
n
;
a
&=
1
;
n
<<=
1
;
b
=
n
;
b
&=
4
;
n
<<=
1
;
c
=
n
;
c
&=
16
;
n
<<=
1
;
n
&=
64
;
n
|=
a
;
n
|=
b
;
n
|=
c
;
n
|=
n
<<
1
;
return
n
;
}
uint8_t
u8g_dev_uc1610_dogxl160_bw_fn
(
u8g_t
*
u8g
,
u8g_dev_t
*
dev
,
uint8_t
msg
,
void
*
arg
)
{
switch
(
msg
)
{
case
U8G_DEV_MSG_INIT
:
u8g_InitCom
(
u8g
,
dev
,
U8G_SPI_CLK_CYCLE_300NS
);
u8g_WriteEscSeqP
(
u8g
,
dev
,
u8g_dev_uc1610_dogxl160_init_seq
);
break
;
case
U8G_DEV_MSG_STOP
:
break
;
case
U8G_DEV_MSG_PAGE_NEXT
:
{
int
i
;
u8g_pb_t
*
pb
=
(
u8g_pb_t
*
)(
dev
->
dev_mem
);
u8g_WriteEscSeqP
(
u8g
,
dev
,
u8g_dev_uc1610_dogxl160_data_start
);
u8g_WriteByte
(
u8g
,
dev
,
0x060
|
(
pb
->
p
.
page
*
2
)
);
/* select current page 1/2 (UC1610) */
u8g_SetAddress
(
u8g
,
dev
,
1
);
/* data mode */
for
(
i
=
0
;
i
<
WIDTH
;
i
++
)
{
u8g_WriteByte
(
u8g
,
dev
,
u8g_dev_1to2
(
((
uint8_t
*
)(
pb
->
buf
))[
i
]
)
);
}
u8g_WriteEscSeqP
(
u8g
,
dev
,
u8g_dev_uc1610_dogxl160_data_start
);
u8g_WriteByte
(
u8g
,
dev
,
0x060
|
(
pb
->
p
.
page
*
2
+
1
)
);
/* select current page 2/2 (UC1610) */
u8g_SetAddress
(
u8g
,
dev
,
1
);
/* data mode */
for
(
i
=
0
;
i
<
WIDTH
;
i
++
)
{
u8g_WriteByte
(
u8g
,
dev
,
u8g_dev_1to2
(
((
uint8_t
*
)(
pb
->
buf
))[
i
]
>>
4
)
);
}
u8g_SetChipSelect
(
u8g
,
dev
,
0
);
}
break
;
case
U8G_DEV_MSG_CONTRAST
:
u8g_SetChipSelect
(
u8g
,
dev
,
1
);
u8g_SetAddress
(
u8g
,
dev
,
0
);
/* instruction mode */
u8g_WriteByte
(
u8g
,
dev
,
0x081
);
u8g_WriteByte
(
u8g
,
dev
,
(
*
(
uint8_t
*
)
arg
)
>>
1
);
u8g_SetChipSelect
(
u8g
,
dev
,
0
);
return
1
;
}
return
u8g_dev_pb8v1_base_fn
(
u8g
,
dev
,
msg
,
arg
);
}
uint8_t
u8g_dev_uc1610_dogxl160_gr_fn
(
u8g_t
*
u8g
,
u8g_dev_t
*
dev
,
uint8_t
msg
,
void
*
arg
)
{
switch
(
msg
)
{
case
U8G_DEV_MSG_INIT
:
u8g_InitCom
(
u8g
,
dev
,
U8G_SPI_CLK_CYCLE_300NS
);
u8g_WriteEscSeqP
(
u8g
,
dev
,
u8g_dev_uc1610_dogxl160_init_seq
);
break
;
case
U8G_DEV_MSG_STOP
:
break
;
case
U8G_DEV_MSG_PAGE_NEXT
:
{
u8g_pb_t
*
pb
=
(
u8g_pb_t
*
)(
dev
->
dev_mem
);
u8g_WriteEscSeqP
(
u8g
,
dev
,
u8g_dev_uc1610_dogxl160_data_start
);
u8g_WriteByte
(
u8g
,
dev
,
0x060
|
(
pb
->
p
.
page
)
);
/* select current page (UC1610) */
u8g_SetAddress
(
u8g
,
dev
,
1
);
/* data mode */
if
(
u8g_pb_WriteBuffer
(
pb
,
u8g
,
dev
)
==
0
)
return
0
;
u8g_SetChipSelect
(
u8g
,
dev
,
0
);
}
break
;
case
U8G_DEV_MSG_CONTRAST
:
u8g_SetChipSelect
(
u8g
,
dev
,
1
);
u8g_SetAddress
(
u8g
,
dev
,
0
);
/* instruction mode */
u8g_WriteByte
(
u8g
,
dev
,
0x081
);
u8g_WriteByte
(
u8g
,
dev
,
(
*
(
uint8_t
*
)
arg
)
>>
1
);
u8g_SetChipSelect
(
u8g
,
dev
,
0
);
return
1
;
}
return
u8g_dev_pb8v2_base_fn
(
u8g
,
dev
,
msg
,
arg
);
}
uint8_t
u8g_dev_uc1610_dogxl160_2x_bw_fn
(
u8g_t
*
u8g
,
u8g_dev_t
*
dev
,
uint8_t
msg
,
void
*
arg
)
{
switch
(
msg
)
{
case
U8G_DEV_MSG_INIT
:
u8g_InitCom
(
u8g
,
dev
,
U8G_SPI_CLK_CYCLE_300NS
);
u8g_WriteEscSeqP
(
u8g
,
dev
,
u8g_dev_uc1610_dogxl160_init_seq
);
break
;
case
U8G_DEV_MSG_STOP
:
break
;
case
U8G_DEV_MSG_PAGE_NEXT
:
{
int
i
;
u8g_pb_t
*
pb
=
(
u8g_pb_t
*
)(
dev
->
dev_mem
);
u8g_WriteEscSeqP
(
u8g
,
dev
,
u8g_dev_uc1610_dogxl160_data_start
);
u8g_WriteByte
(
u8g
,
dev
,
0x060
|
(
pb
->
p
.
page
*
4
)
);
/* select current page 1/2 (UC1610) */
u8g_SetAddress
(
u8g
,
dev
,
1
);
/* data mode */
for
(
i
=
0
;
i
<
WIDTH
;
i
++
)
{
u8g_WriteByte
(
u8g
,
dev
,
u8g_dev_1to2
(
((
uint8_t
*
)(
pb
->
buf
))[
i
]
)
);
}
u8g_WriteEscSeqP
(
u8g
,
dev
,
u8g_dev_uc1610_dogxl160_data_start
);
u8g_WriteByte
(
u8g
,
dev
,
0x060
|
(
pb
->
p
.
page
*
4
+
1
)
);
/* select current page 2/2 (UC1610) */
u8g_SetAddress
(
u8g
,
dev
,
1
);
/* data mode */
for
(
i
=
0
;
i
<
WIDTH
;
i
++
)
{
u8g_WriteByte
(
u8g
,
dev
,
u8g_dev_1to2
(
((
uint8_t
*
)(
pb
->
buf
))[
i
]
>>
4
)
);
}
u8g_WriteEscSeqP
(
u8g
,
dev
,
u8g_dev_uc1610_dogxl160_data_start
);
u8g_WriteByte
(
u8g
,
dev
,
0x060
|
(
pb
->
p
.
page
*
4
+
2
)
);
/* select current page 1/2 (UC1610) */
u8g_SetAddress
(
u8g
,
dev
,
1
);
/* data mode */
for
(
i
=
0
;
i
<
WIDTH
;
i
++
)
{
u8g_WriteByte
(
u8g
,
dev
,
u8g_dev_1to2
(
((
uint8_t
*
)((
uint8_t
*
)(
pb
->
buf
)
+
WIDTH
))[
i
]
)
);
}
u8g_WriteEscSeqP
(
u8g
,
dev
,
u8g_dev_uc1610_dogxl160_data_start
);
u8g_WriteByte
(
u8g
,
dev
,
0x060
|
(
pb
->
p
.
page
*
4
+
3
)
);
/* select current page 2/2 (UC1610) */
u8g_SetAddress
(
u8g
,
dev
,
1
);
/* data mode */
for
(
i
=
0
;
i
<
WIDTH
;
i
++
)
{
u8g_WriteByte
(
u8g
,
dev
,
u8g_dev_1to2
(
((
uint8_t
*
)((
uint8_t
*
)(
pb
->
buf
)
+
WIDTH
))[
i
]
>>
4
)
);
}
u8g_SetChipSelect
(
u8g
,
dev
,
0
);
}
break
;
case
U8G_DEV_MSG_CONTRAST
:
u8g_SetChipSelect
(
u8g
,
dev
,
1
);
u8g_SetAddress
(
u8g
,
dev
,
0
);
/* instruction mode */
u8g_WriteByte
(
u8g
,
dev
,
0x081
);
u8g_WriteByte
(
u8g
,
dev
,
(
*
(
uint8_t
*
)
arg
)
>>
1
);
u8g_SetChipSelect
(
u8g
,
dev
,
0
);
return
1
;
}
return
u8g_dev_pb16v1_base_fn
(
u8g
,
dev
,
msg
,
arg
);
}
uint8_t
u8g_dev_uc1610_dogxl160_2x_gr_fn
(
u8g_t
*
u8g
,
u8g_dev_t
*
dev
,
uint8_t
msg
,
void
*
arg
)
{
switch
(
msg
)
{
case
U8G_DEV_MSG_INIT
:
u8g_InitCom
(
u8g
,
dev
,
U8G_SPI_CLK_CYCLE_300NS
);
u8g_WriteEscSeqP
(
u8g
,
dev
,
u8g_dev_uc1610_dogxl160_init_seq
);
break
;
case
U8G_DEV_MSG_STOP
:
break
;
case
U8G_DEV_MSG_PAGE_NEXT
:
{
u8g_pb_t
*
pb
=
(
u8g_pb_t
*
)(
dev
->
dev_mem
);
u8g_WriteEscSeqP
(
u8g
,
dev
,
u8g_dev_uc1610_dogxl160_data_start
);
u8g_WriteByte
(
u8g
,
dev
,
0x060
|
(
pb
->
p
.
page
*
2
)
);
/* select current page (UC1610) */
u8g_SetAddress
(
u8g
,
dev
,
1
);
/* data mode */
if
(
u8g_WriteSequence
(
u8g
,
dev
,
WIDTH
,
pb
->
buf
)
==
0
)
return
0
;
u8g_WriteEscSeqP
(
u8g
,
dev
,
u8g_dev_uc1610_dogxl160_data_start
);
u8g_WriteByte
(
u8g
,
dev
,
0x060
|
(
pb
->
p
.
page
*
2
+
1
)
);
/* select current page (UC1610) */
u8g_SetAddress
(
u8g
,
dev
,
1
);
/* data mode */
if
(
u8g_WriteSequence
(
u8g
,
dev
,
WIDTH
,
(
uint8_t
*
)(
pb
->
buf
)
+
WIDTH
)
==
0
)
return
0
;
u8g_SetChipSelect
(
u8g
,
dev
,
0
);
}
break
;
case
U8G_DEV_MSG_CONTRAST
:
u8g_SetChipSelect
(
u8g
,
dev
,
1
);
u8g_SetAddress
(
u8g
,
dev
,
0
);
/* instruction mode */
u8g_WriteByte
(
u8g
,
dev
,
0x081
);
u8g_WriteByte
(
u8g
,
dev
,
(
*
(
uint8_t
*
)
arg
)
>>
1
);
u8g_SetChipSelect
(
u8g
,
dev
,
0
);
return
1
;
}
return
u8g_dev_pb16v2_base_fn
(
u8g
,
dev
,
msg
,
arg
);
}
U8G_PB_DEV
(
u8g_dev_uc1610_dogxl160_bw_sw_spi
,
WIDTH
,
HEIGHT
,
8
,
u8g_dev_uc1610_dogxl160_bw_fn
,
U8G_COM_SW_SPI
);
U8G_PB_DEV
(
u8g_dev_uc1610_dogxl160_bw_hw_spi
,
WIDTH
,
HEIGHT
,
8
,
u8g_dev_uc1610_dogxl160_bw_fn
,
U8G_COM_HW_SPI
);
U8G_PB_DEV
(
u8g_dev_uc1610_dogxl160_gr_sw_spi
,
WIDTH
,
HEIGHT
,
4
,
u8g_dev_uc1610_dogxl160_gr_fn
,
U8G_COM_SW_SPI
);
U8G_PB_DEV
(
u8g_dev_uc1610_dogxl160_gr_hw_spi
,
WIDTH
,
HEIGHT
,
4
,
u8g_dev_uc1610_dogxl160_gr_fn
,
U8G_COM_HW_SPI
);
uint8_t
u8g_dev_uc1610_dogxl160_2x_bw_buf
[
WIDTH
*
2
]
U8G_NOCOMMON
;
u8g_pb_t
u8g_dev_uc1610_dogxl160_2x_bw_pb
=
{
{
16
,
HEIGHT
,
0
,
0
,
0
},
WIDTH
,
u8g_dev_uc1610_dogxl160_2x_bw_buf
};
u8g_dev_t
u8g_dev_uc1610_dogxl160_2x_bw_sw_spi
=
{
u8g_dev_uc1610_dogxl160_2x_bw_fn
,
&
u8g_dev_uc1610_dogxl160_2x_bw_pb
,
U8G_COM_SW_SPI
};
u8g_dev_t
u8g_dev_uc1610_dogxl160_2x_bw_hw_spi
=
{
u8g_dev_uc1610_dogxl160_2x_bw_fn
,
&
u8g_dev_uc1610_dogxl160_2x_bw_pb
,
U8G_COM_HW_SPI
};
uint8_t
u8g_dev_uc1610_dogxl160_2x_gr_buf
[
WIDTH
*
2
]
U8G_NOCOMMON
;
u8g_pb_t
u8g_dev_uc1610_dogxl160_2x_gr_pb
=
{
{
8
,
HEIGHT
,
0
,
0
,
0
},
WIDTH
,
u8g_dev_uc1610_dogxl160_2x_gr_buf
};
u8g_dev_t
u8g_dev_uc1610_dogxl160_2x_gr_sw_spi
=
{
u8g_dev_uc1610_dogxl160_2x_gr_fn
,
&
u8g_dev_uc1610_dogxl160_2x_gr_pb
,
U8G_COM_SW_SPI
};
u8g_dev_t
u8g_dev_uc1610_dogxl160_2x_gr_hw_spi
=
{
u8g_dev_uc1610_dogxl160_2x_gr_fn
,
&
u8g_dev_uc1610_dogxl160_2x_gr_pb
,
U8G_COM_HW_SPI
};
app/u8glib/u8g_dev_uc1611_dogm240.c
deleted
100644 → 0
View file @
fd745e09
/*
u8g_dev_uc1611_dogm240.c
Universal 8bit Graphics Library
Copyright (c) 2014, dev.menges.jonas@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
static
const
uint8_t
u8g_dev_uc1611_dogm240_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_DLY
(
200
),
U8G_ESC_CS
(
1
),
// enable chip
U8G_ESC_ADR
(
0
),
// instruction mode
0xe2
,
// system reset
U8G_ESC_DLY
(
1
),
0x2f
,
// enable internal charge pump
0xF1
,
// set last COM electrode
0x3F
,
// 64-1=63
0xF2
,
// set display start line
0x00
,
// 0
0xF3
,
// set display end line
0x3F
,
// 64-1=63
0x81
,
// set contrast (0-255)
0xB7
,
// 183
0xC0
,
// set view
//0x04, // topview
0x02
,
// bottomview
0xA3
,
// set line rate (9.4k)
0xE9
,
// set bias ratio (10)
0xA9
,
// enable display
0xD1
,
// set black and white mode
U8G_ESC_CS
(
0
),
// disable chip
U8G_ESC_END
// end of sequence
};
static
void
setPage
(
u8g_t
*
u8g
,
u8g_dev_t
*
dev
,
unsigned
char
page
)
{
u8g_WriteByte
(
u8g
,
dev
,
0x70
+
(
page
>>
4
));
u8g_WriteByte
(
u8g
,
dev
,
0x60
+
(
page
&
0x0F
));
}
static
const
uint8_t
u8g_dev_uc1611_dogm240_data_start
[]
PROGMEM
=
{
U8G_ESC_ADR
(
0
),
/* instruction mode */
U8G_ESC_CS
(
1
),
/* enable chip */
0x10
,
/* set upper 4 bit of the col adr to 0 */
0x00
,
/* set lower 4 bit of the col adr to 0 */
U8G_ESC_END
/* end of sequence */
};
uint8_t
u8g_dev_uc1611_dogm240_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
(
u8g
,
dev
,
u8g_dev_uc1611_dogm240_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_uc1611_dogm240_data_start
);
setPage
(
u8g
,
dev
,
pb
->
p
.
page
);
/* select current page (uc1611) */
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
,
0x81
);
/* 11 Jul 2015: bugfix, github issue 339 */
u8g_WriteByte
(
u8g
,
dev
,
(
*
(
uint8_t
*
)
arg
)
);
/* set contrast from, keep gain at 0 */
u8g_SetChipSelect
(
u8g
,
dev
,
0
);
return
1
;
}
return
u8g_dev_pb8v1_base_fn
(
u8g
,
dev
,
msg
,
arg
);
}
U8G_PB_DEV
(
u8g_dev_uc1611_dogm240_i2c
,
WIDTH
,
HEIGHT
,
PAGE_HEIGHT
,
u8g_dev_uc1611_dogm240_fn
,
U8G_COM_UC_I2C
);
U8G_PB_DEV
(
u8g_dev_uc1611_dogm240_sw_spi
,
WIDTH
,
HEIGHT
,
PAGE_HEIGHT
,
u8g_dev_uc1611_dogm240_fn
,
U8G_COM_SW_SPI
);
U8G_PB_DEV
(
u8g_dev_uc1611_dogm240_hw_spi
,
WIDTH
,
HEIGHT
,
PAGE_HEIGHT
,
u8g_dev_uc1611_dogm240_fn
,
U8G_COM_HW_SPI
);
U8G_PB_DEV
(
u8g_dev_uc1611_dogm240_8bit
,
WIDTH
,
HEIGHT
,
PAGE_HEIGHT
,
u8g_dev_uc1611_dogm240_fn
,
U8G_COM_FAST_PARALLEL
);
app/u8glib/u8g_dev_uc1611_dogxl240.c
deleted
100644 → 0
View file @
fd745e09
/*
u8g_dev_uc1611_dogxl240.c
Universal 8bit Graphics Library
Copyright (c) 2014, dev.menges.jonas@gmail.com, 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
static
const
uint8_t
u8g_dev_uc1611_dogxl240_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_DLY
(
200
),
U8G_ESC_CS
(
1
),
// enable chip
U8G_ESC_ADR
(
0
),
// instruction mode
0xe2
,
// system reset
U8G_ESC_DLY
(
1
),
0x2f
,
// enable internal charge pump
0xF1
,
// set last COM electrode
0x7F
,
// DOGXL240
0xF2
,
// set display start line
0x00
,
// 0
0xF3
,
// set display end line
0x7F
,
// DOGXL240
0x81
,
// set contrast (0-255)
0xAA
,
// DOGXL240
0xC0
,
// set view
//0x04, // topview
0x02
,
// bottomview
0xA3
,
// set line rate (9.4k)
0xE9
,
// set bias ratio (10)
0xA9
,
// enable display
0xD1
,
// set black and white mode
U8G_ESC_CS
(
0
),
// disable chip
U8G_ESC_END
// end of sequence
};
static
void
u8g_dev_dogxl240_set_page
(
u8g_t
*
u8g
,
u8g_dev_t
*
dev
,
unsigned
char
page
)
{
u8g_WriteByte
(
u8g
,
dev
,
0x70
);
u8g_WriteByte
(
u8g
,
dev
,
0x60
+
(
page
&
0x0F
));
}
static
const
uint8_t
u8g_dev_uc1611_dogxl240_data_start
[]
PROGMEM
=
{
U8G_ESC_ADR
(
0
),
/* instruction mode */
U8G_ESC_CS
(
1
),
/* enable chip */
0x10
,
/* set upper 4 bit of the col adr to 0 */
0x00
,
/* set lower 4 bit of the col adr to 0 */
U8G_ESC_END
/* end of sequence */
};
static
uint8_t
u8g_dev_uc1611_dogxl240_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
(
u8g
,
dev
,
u8g_dev_uc1611_dogxl240_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_uc1611_dogxl240_data_start
);
u8g_dev_dogxl240_set_page
(
u8g
,
dev
,
pb
->
p
.
page
);
/* select current page (uc1611) */
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
,
0x81
);
/* 11 Jul 2015: bugfix, github issue 339 */
u8g_WriteByte
(
u8g
,
dev
,
(
*
(
uint8_t
*
)
arg
)
);
/* set contrast from, keep gain at 0 */
u8g_SetChipSelect
(
u8g
,
dev
,
0
);
return
1
;
}
return
u8g_dev_pb8v1_base_fn
(
u8g
,
dev
,
msg
,
arg
);
}
U8G_PB_DEV
(
u8g_dev_uc1611_dogxl240_i2c
,
WIDTH
,
HEIGHT
,
PAGE_HEIGHT
,
u8g_dev_uc1611_dogxl240_fn
,
U8G_COM_UC_I2C
);
U8G_PB_DEV
(
u8g_dev_uc1611_dogxl240_sw_spi
,
WIDTH
,
HEIGHT
,
PAGE_HEIGHT
,
u8g_dev_uc1611_dogxl240_fn
,
U8G_COM_SW_SPI
);
U8G_PB_DEV
(
u8g_dev_uc1611_dogxl240_hw_spi
,
WIDTH
,
HEIGHT
,
PAGE_HEIGHT
,
u8g_dev_uc1611_dogxl240_fn
,
U8G_COM_HW_SPI
);
U8G_PB_DEV
(
u8g_dev_uc1611_dogxl240_8bit
,
WIDTH
,
HEIGHT
,
PAGE_HEIGHT
,
u8g_dev_uc1611_dogxl240_fn
,
U8G_COM_FAST_PARALLEL
);
app/u8glib/u8g_dev_uc1701_dogs102.c
deleted
100644 → 0
View file @
fd745e09
/*
u8g_dev_uc1701_dogs102.c
Universal 8bit Graphics Library
Copyright (c) 2011, olikraus@gmail.com
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or other
materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "u8g.h"
#define WIDTH 102
#define HEIGHT 64
#define PAGE_HEIGHT 8
static
const
uint8_t
u8g_dev_dogs102_init_seq
[]
PROGMEM
=
{
U8G_ESC_CS
(
0
),
/* disable chip */
U8G_ESC_ADR
(
0
),
/* instruction mode */
U8G_ESC_RST
(
1
),
/* do reset low pulse with (1*16)+2 milliseconds */
U8G_ESC_CS
(
1
),
/* enable chip */
0x0e2
,
/* soft reset */
0x040
,
/* set display start line to 0 */
0x0a1
,
/* ADC set to reverse */
0x0c0
,
/* common output mode */
0x0a6
,
/* display normal, bit val 0: LCD pixel off. */
0x0a2
,
/* LCD bias 1/9 */
0x02f
,
/* all power control circuits on */
0x027
,
/* regulator, booster and follower */
0x081
,
/* set contrast */
0x00e
,
/* contrast value, EA default: 0x010, previous value for S102: 0x0e */
0x0fa
,
/* Set Temp compensation */
0x090
,
/* 0.11 deg/c WP Off WC Off*/
0x0a4
,
/* normal display */
0x0af
,
/* display on */
U8G_ESC_DLY
(
100
),
/* delay 100 ms */
0x0a5
,
/* display all points, ST7565, UC1610 */
U8G_ESC_DLY
(
100
),
/* delay 100 ms */
U8G_ESC_DLY
(
100
),
/* delay 100 ms */
0x0a4
,
/* normal display */
U8G_ESC_CS
(
0
),
/* disable chip */
U8G_ESC_END
/* end of sequence */
};
static
const
uint8_t
u8g_dev_dogs102_data_start
[]
PROGMEM
=
{
U8G_ESC_ADR
(
0
),
/* instruction mode */
U8G_ESC_CS
(
1
),
/* enable chip */
0x010
,
/* set upper 4 bit of the col adr to 0 */
0x000
,
/* set lower 4 bit of the col adr to 0 */
U8G_ESC_END
/* end of sequence */
};
uint8_t
u8g_dev_dogs102_fn
(
u8g_t
*
u8g
,
u8g_dev_t
*
dev
,
uint8_t
msg
,
void
*
arg
)
{
switch
(
msg
)
{
case
U8G_DEV_MSG_INIT
:
u8g_InitCom
(
u8g
,
dev
,
U8G_SPI_CLK_CYCLE_300NS
);
u8g_WriteEscSeqP
(
u8g
,
dev
,
u8g_dev_dogs102_init_seq
);
break
;
case
U8G_DEV_MSG_STOP
:
break
;
case
U8G_DEV_MSG_PAGE_NEXT
:
{
u8g_pb_t
*
pb
=
(
u8g_pb_t
*
)(
dev
->
dev_mem
);
u8g_WriteEscSeqP
(
u8g
,
dev
,
u8g_dev_dogs102_data_start
);
u8g_WriteByte
(
u8g
,
dev
,
0x0b0
|
pb
->
p
.
page
);
/* select current page (ST7565R) */
u8g_SetAddress
(
u8g
,
dev
,
1
);
/* data mode */
if
(
u8g_pb_WriteBuffer
(
pb
,
u8g
,
dev
)
==
0
)
return
0
;
u8g_SetChipSelect
(
u8g
,
dev
,
0
);
}
break
;
case
U8G_DEV_MSG_CONTRAST
:
u8g_SetChipSelect
(
u8g
,
dev
,
1
);
u8g_SetAddress
(
u8g
,
dev
,
0
);
/* instruction mode */
u8g_WriteByte
(
u8g
,
dev
,
0x081
);
u8g_WriteByte
(
u8g
,
dev
,
(
*
(
uint8_t
*
)
arg
)
>>
2
);
u8g_SetChipSelect
(
u8g
,
dev
,
0
);
return
1
;
}
return
u8g_dev_pb8v1_base_fn
(
u8g
,
dev
,
msg
,
arg
);
}
uint8_t
u8g_dev_uc1701_dogs102_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_300NS
);
u8g_WriteEscSeqP
(
u8g
,
dev
,
u8g_dev_dogs102_init_seq
);
break
;
case
U8G_DEV_MSG_STOP
:
break
;
case
U8G_DEV_MSG_PAGE_NEXT
:
{
u8g_pb_t
*
pb
=
(
u8g_pb_t
*
)(
dev
->
dev_mem
);
u8g_WriteEscSeqP
(
u8g
,
dev
,
u8g_dev_dogs102_data_start
);
u8g_WriteByte
(
u8g
,
dev
,
0x0b0
|
(
2
*
pb
->
p
.
page
));
/* select current page (ST7565R) */
u8g_SetAddress
(
u8g
,
dev
,
1
);
/* data mode */
u8g_WriteSequence
(
u8g
,
dev
,
pb
->
width
,
pb
->
buf
);
u8g_SetChipSelect
(
u8g
,
dev
,
0
);
u8g_WriteEscSeqP
(
u8g
,
dev
,
u8g_dev_dogs102_data_start
);
u8g_WriteByte
(
u8g
,
dev
,
0x0b0
|
(
2
*
pb
->
p
.
page
+
1
));
/* select current page (ST7565R) */
u8g_SetAddress
(
u8g
,
dev
,
1
);
/* data mode */
u8g_WriteSequence
(
u8g
,
dev
,
pb
->
width
,
(
uint8_t
*
)(
pb
->
buf
)
+
pb
->
width
);
u8g_SetChipSelect
(
u8g
,
dev
,
0
);
}
break
;
case
U8G_DEV_MSG_CONTRAST
:
u8g_SetChipSelect
(
u8g
,
dev
,
1
);
u8g_SetAddress
(
u8g
,
dev
,
0
);
/* instruction mode */
u8g_WriteByte
(
u8g
,
dev
,
0x081
);
u8g_WriteByte
(
u8g
,
dev
,
(
*
(
uint8_t
*
)
arg
)
>>
2
);
u8g_SetChipSelect
(
u8g
,
dev
,
0
);
return
1
;
}
return
u8g_dev_pb16v1_base_fn
(
u8g
,
dev
,
msg
,
arg
);
}
U8G_PB_DEV
(
u8g_dev_uc1701_dogs102_sw_spi
,
WIDTH
,
HEIGHT
,
PAGE_HEIGHT
,
u8g_dev_dogs102_fn
,
U8G_COM_SW_SPI
);
U8G_PB_DEV
(
u8g_dev_uc1701_dogs102_hw_spi
,
WIDTH
,
HEIGHT
,
PAGE_HEIGHT
,
u8g_dev_dogs102_fn
,
U8G_COM_HW_SPI
);
uint8_t
u8g_dev_uc1701_dogs102_2x_buf
[
WIDTH
*
2
]
U8G_NOCOMMON
;
u8g_pb_t
u8g_dev_uc1701_dogs102_2x_pb
=
{
{
16
,
HEIGHT
,
0
,
0
,
0
},
WIDTH
,
u8g_dev_uc1701_dogs102_2x_buf
};
u8g_dev_t
u8g_dev_uc1701_dogs102_2x_sw_spi
=
{
u8g_dev_uc1701_dogs102_2x_fn
,
&
u8g_dev_uc1701_dogs102_2x_pb
,
U8G_COM_SW_SPI
};
u8g_dev_t
u8g_dev_uc1701_dogs102_2x_hw_spi
=
{
u8g_dev_uc1701_dogs102_2x_fn
,
&
u8g_dev_uc1701_dogs102_2x_pb
,
U8G_COM_HW_SPI
};
app/u8glib/u8g_dev_uc1701_mini12864.c
deleted
100644 → 0
View file @
fd745e09
/*
u8g_dev_uc1701_mini12864.c (dealextreme)
Universal 8bit Graphics Library
Copyright (c) 2011, olikraus@gmail.com
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or other
materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "u8g.h"
#define WIDTH 128
#define HEIGHT 64
#define PAGE_HEIGHT 8
static
const
uint8_t
u8g_dev_uc1701_mini12864_init_seq
[]
PROGMEM
=
{
U8G_ESC_CS
(
0
),
/* disable chip */
U8G_ESC_ADR
(
0
),
/* instruction mode */
U8G_ESC_RST
(
1
),
/* do reset low pulse with (1*16)+2 milliseconds */
U8G_ESC_CS
(
1
),
/* enable chip */
0x0e2
,
/* soft reset */
0x040
,
/* set display start line to 0 */
0x0a0
,
/* ADC set to reverse */
0x0c8
,
/* common output mode */
0x0a6
,
/* display normal, bit val 0: LCD pixel off. */
0x0a2
,
/* LCD bias 1/9 */
0x02f
,
/* all power control circuits on */
0x0f8
,
/* set booster ratio to */
0x000
,
/* 4x */
0x023
,
/* set V0 voltage resistor ratio to large */
0x081
,
/* set contrast */
0x027
,
/* contrast value */
0x0ac
,
/* indicator */
0x000
,
/* disable */
0x0af
,
/* display on */
U8G_ESC_DLY
(
100
),
/* delay 100 ms */
0x0a5
,
/* display all points, ST7565 */
U8G_ESC_DLY
(
100
),
/* delay 100 ms */
U8G_ESC_DLY
(
100
),
/* delay 100 ms */
0x0a4
,
/* normal display */
U8G_ESC_CS
(
0
),
/* disable chip */
U8G_ESC_END
/* end of sequence */
};
static
const
uint8_t
u8g_dev_uc1701_mini12864_data_start
[]
PROGMEM
=
{
U8G_ESC_ADR
(
0
),
/* instruction mode */
U8G_ESC_CS
(
1
),
/* enable chip */
0x010
,
/* set upper 4 bit of the col adr to 0 */
0x000
,
/* set lower 4 bit of the col adr to 4 */
U8G_ESC_END
/* end of sequence */
};
uint8_t
u8g_dev_uc1701_mini12864_fn
(
u8g_t
*
u8g
,
u8g_dev_t
*
dev
,
uint8_t
msg
,
void
*
arg
)
{
switch
(
msg
)
{
case
U8G_DEV_MSG_INIT
:
u8g_InitCom
(
u8g
,
dev
,
U8G_SPI_CLK_CYCLE_300NS
);
u8g_WriteEscSeqP
(
u8g
,
dev
,
u8g_dev_uc1701_mini12864_init_seq
);
break
;
case
U8G_DEV_MSG_STOP
:
break
;
case
U8G_DEV_MSG_PAGE_NEXT
:
{
u8g_pb_t
*
pb
=
(
u8g_pb_t
*
)(
dev
->
dev_mem
);
u8g_WriteEscSeqP
(
u8g
,
dev
,
u8g_dev_uc1701_mini12864_data_start
);
u8g_WriteByte
(
u8g
,
dev
,
0x0b0
|
pb
->
p
.
page
);
/* select current page */
u8g_SetAddress
(
u8g
,
dev
,
1
);
/* data mode */
if
(
u8g_pb_WriteBuffer
(
pb
,
u8g
,
dev
)
==
0
)
return
0
;
u8g_SetChipSelect
(
u8g
,
dev
,
0
);
}
break
;
case
U8G_DEV_MSG_CONTRAST
:
u8g_SetChipSelect
(
u8g
,
dev
,
1
);
u8g_SetAddress
(
u8g
,
dev
,
0
);
/* instruction mode */
u8g_WriteByte
(
u8g
,
dev
,
0x081
);
u8g_WriteByte
(
u8g
,
dev
,
(
*
(
uint8_t
*
)
arg
)
>>
2
);
u8g_SetChipSelect
(
u8g
,
dev
,
0
);
return
1
;
}
return
u8g_dev_pb8v1_base_fn
(
u8g
,
dev
,
msg
,
arg
);
}
uint8_t
u8g_dev_uc1701_mini12864_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_300NS
);
u8g_WriteEscSeqP
(
u8g
,
dev
,
u8g_dev_uc1701_mini12864_init_seq
);
break
;
case
U8G_DEV_MSG_STOP
:
break
;
case
U8G_DEV_MSG_PAGE_NEXT
:
{
u8g_pb_t
*
pb
=
(
u8g_pb_t
*
)(
dev
->
dev_mem
);
u8g_WriteEscSeqP
(
u8g
,
dev
,
u8g_dev_uc1701_mini12864_data_start
);
u8g_WriteByte
(
u8g
,
dev
,
0x0b0
|
(
2
*
pb
->
p
.
page
));
/* select current page */
u8g_SetAddress
(
u8g
,
dev
,
1
);
/* data mode */
u8g_WriteSequence
(
u8g
,
dev
,
pb
->
width
,
pb
->
buf
);
u8g_SetChipSelect
(
u8g
,
dev
,
0
);
u8g_WriteEscSeqP
(
u8g
,
dev
,
u8g_dev_uc1701_mini12864_data_start
);
u8g_WriteByte
(
u8g
,
dev
,
0x0b0
|
(
2
*
pb
->
p
.
page
+
1
));
/* select current page */
u8g_SetAddress
(
u8g
,
dev
,
1
);
/* data mode */
u8g_WriteSequence
(
u8g
,
dev
,
pb
->
width
,
(
uint8_t
*
)(
pb
->
buf
)
+
pb
->
width
);
u8g_SetChipSelect
(
u8g
,
dev
,
0
);
}
break
;
case
U8G_DEV_MSG_CONTRAST
:
u8g_SetChipSelect
(
u8g
,
dev
,
1
);
u8g_SetAddress
(
u8g
,
dev
,
0
);
/* instruction mode */
u8g_WriteByte
(
u8g
,
dev
,
0x081
);
u8g_WriteByte
(
u8g
,
dev
,
(
*
(
uint8_t
*
)
arg
)
>>
2
);
u8g_SetChipSelect
(
u8g
,
dev
,
0
);
return
1
;
}
return
u8g_dev_pb16v1_base_fn
(
u8g
,
dev
,
msg
,
arg
);
}
U8G_PB_DEV
(
u8g_dev_uc1701_mini12864_sw_spi
,
WIDTH
,
HEIGHT
,
PAGE_HEIGHT
,
u8g_dev_uc1701_mini12864_fn
,
U8G_COM_SW_SPI
);
U8G_PB_DEV
(
u8g_dev_uc1701_mini12864_hw_spi
,
WIDTH
,
HEIGHT
,
PAGE_HEIGHT
,
u8g_dev_uc1701_mini12864_fn
,
U8G_COM_HW_SPI
);
uint8_t
u8g_dev_uc1701_mini12864_2x_buf
[
WIDTH
*
2
]
U8G_NOCOMMON
;
u8g_pb_t
u8g_dev_uc1701_mini12864_2x_pb
=
{
{
16
,
HEIGHT
,
0
,
0
,
0
},
WIDTH
,
u8g_dev_uc1701_mini12864_2x_buf
};
u8g_dev_t
u8g_dev_uc1701_mini12864_2x_sw_spi
=
{
u8g_dev_uc1701_mini12864_2x_fn
,
&
u8g_dev_uc1701_mini12864_2x_pb
,
U8G_COM_SW_SPI
};
u8g_dev_t
u8g_dev_uc1701_mini12864_2x_hw_spi
=
{
u8g_dev_uc1701_mini12864_2x_fn
,
&
u8g_dev_uc1701_mini12864_2x_pb
,
U8G_COM_HW_SPI
};
app/u8glib/u8g_ellipse.c
deleted
100644 → 0
View file @
fd745e09
/*
u8g_ellipse.c
Utility to draw empty and filled ellipses.
Universal 8bit Graphics Library
Copyright (c) 2011, bjthom@gmail.com
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or other
materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Addition to the U8G Library as of 02/29/12
Adapted from Bresenham's Algorithm and the following websites:
http://free.pages.at/easyfilter/bresenham.html
http://homepage.smc.edu/kennedy_john/belipse.pdf
*/
#include "u8g.h"
#ifdef WORK_IN_PROGRESS
void
u8g_DrawEllipseRect
(
u8g_t
*
u8g
,
u8g_uint_t
x0
,
u8g_uint_t
y0
,
u8g_uint_t
x1
,
u8g_uint_t
y1
)
{
int
a
=
abs
(
x1
-
x0
);
int
b
=
abs
(
y1
-
y0
);
//get diameters
int
b1
=
b
&
1
;
long
dx
=
4
*
(
1
-
a
)
*
b
*
b
;
long
dy
=
4
*
(
b1
+
1
)
*
a
*
a
;
long
err
=
dx
+
dy
+
b1
*
a
*
a
;
long
e2
;
if
(
x0
>
x1
)
{
x0
=
x1
;
x1
+=
a
;
}
if
(
y0
>
y1
)
{
y0
=
y1
;
}
y0
+=
(
b
+
1
)
/
2
;
y1
=
y0
-
b1
;
a
*=
8
*
a
;
b1
=
8
*
b
*
b
;
do
{
u8g_DrawPixel
(
u8g
,
x1
,
y0
);
u8g_DrawPixel
(
u8g
,
x0
,
y0
);
u8g_DrawPixel
(
u8g
,
x0
,
y1
);
u8g_DrawPixel
(
u8g
,
x1
,
y1
);
e2
=
2
*
err
;
if
(
e2
>=
dx
)
{
x0
++
;
x1
--
;
err
+=
dx
+=
b1
;
}
if
(
e2
<=
dy
)
{
y0
++
;
y1
--
;
err
+=
dy
+=
a
;
}
}
while
(
x0
<=
x1
);
while
(
y0
-
y1
<
b
)
{
u8g_DrawPixel
(
u8g
,
x0
-
1
,
y0
);
u8g_DrawPixel
(
u8g
,
x1
+
1
,
y0
++
);
u8g_DrawPixel
(
u8g
,
x0
-
1
,
y1
);
u8g_DrawPixel
(
u8g
,
x1
+
1
,
y1
--
);
}
}
void
u8g_DrawEllipse
(
u8g_t
*
u8g
,
u8g_uint_t
x0
,
u8g_uint_t
y0
,
u8g_uint_t
xr
,
u8g_uint_t
yr
)
{
u8g_DrawPixel
(
u8g
,
x0
,
y0
+
yr
);
u8g_DrawPixel
(
u8g
,
x0
,
y0
-
yr
);
u8g_DrawPixel
(
u8g
,
x0
+
xr
,
y0
);
u8g_DrawPixel
(
u8g
,
x0
-
xr
,
y0
);
}
#endif
#if defined(U8G_16BIT)
typedef
int32_t
u8g_long_t
;
#else
typedef
int16_t
u8g_long_t
;
#endif
/*
Source:
ftp://pc.fk0.name/pub/books/programming/bezier-ellipse.pdf
Foley, Computer Graphics, p 90
*/
static
void
u8g_draw_ellipse_section
(
u8g_t
*
u8g
,
u8g_uint_t
x
,
u8g_uint_t
y
,
u8g_uint_t
x0
,
u8g_uint_t
y0
,
uint8_t
option
)
U8G_NOINLINE
;
static
void
u8g_draw_ellipse_section
(
u8g_t
*
u8g
,
u8g_uint_t
x
,
u8g_uint_t
y
,
u8g_uint_t
x0
,
u8g_uint_t
y0
,
uint8_t
option
)
{
/* upper right */
if
(
option
&
U8G_DRAW_UPPER_RIGHT
)
{
u8g_DrawPixel
(
u8g
,
x0
+
x
,
y0
-
y
);
}
/* upper left */
if
(
option
&
U8G_DRAW_UPPER_LEFT
)
{
u8g_DrawPixel
(
u8g
,
x0
-
x
,
y0
-
y
);
}
/* lower right */
if
(
option
&
U8G_DRAW_LOWER_RIGHT
)
{
u8g_DrawPixel
(
u8g
,
x0
+
x
,
y0
+
y
);
}
/* lower left */
if
(
option
&
U8G_DRAW_LOWER_LEFT
)
{
u8g_DrawPixel
(
u8g
,
x0
-
x
,
y0
+
y
);
}
}
void
u8g_draw_ellipse
(
u8g_t
*
u8g
,
u8g_uint_t
x0
,
u8g_uint_t
y0
,
u8g_uint_t
rx
,
u8g_uint_t
ry
,
uint8_t
option
)
{
u8g_uint_t
x
,
y
;
u8g_long_t
xchg
,
ychg
;
u8g_long_t
err
;
u8g_long_t
rxrx2
;
u8g_long_t
ryry2
;
u8g_long_t
stopx
,
stopy
;
rxrx2
=
rx
;
rxrx2
*=
rx
;
rxrx2
*=
2
;
ryry2
=
ry
;
ryry2
*=
ry
;
ryry2
*=
2
;
x
=
rx
;
y
=
0
;
xchg
=
1
;
xchg
-=
rx
;
xchg
-=
rx
;
xchg
*=
ry
;
xchg
*=
ry
;
ychg
=
rx
;
ychg
*=
rx
;
err
=
0
;
stopx
=
ryry2
;
stopx
*=
rx
;
stopy
=
0
;
while
(
stopx
>=
stopy
)
{
u8g_draw_ellipse_section
(
u8g
,
x
,
y
,
x0
,
y0
,
option
);
y
++
;
stopy
+=
rxrx2
;
err
+=
ychg
;
ychg
+=
rxrx2
;
if
(
2
*
err
+
xchg
>
0
)
{
x
--
;
stopx
-=
ryry2
;
err
+=
xchg
;
xchg
+=
ryry2
;
}
}
x
=
0
;
y
=
ry
;
xchg
=
ry
;
xchg
*=
ry
;
ychg
=
1
;
ychg
-=
ry
;
ychg
-=
ry
;
ychg
*=
rx
;
ychg
*=
rx
;
err
=
0
;
stopx
=
0
;
stopy
=
rxrx2
;
stopy
*=
ry
;
while
(
stopx
<=
stopy
)
{
u8g_draw_ellipse_section
(
u8g
,
x
,
y
,
x0
,
y0
,
option
);
x
++
;
stopx
+=
ryry2
;
err
+=
xchg
;
xchg
+=
ryry2
;
if
(
2
*
err
+
ychg
>
0
)
{
y
--
;
stopy
-=
rxrx2
;
err
+=
ychg
;
ychg
+=
rxrx2
;
}
}
}
void
u8g_DrawEllipse
(
u8g_t
*
u8g
,
u8g_uint_t
x0
,
u8g_uint_t
y0
,
u8g_uint_t
rx
,
u8g_uint_t
ry
,
uint8_t
option
)
{
/* check for bounding box */
{
u8g_uint_t
rxp
,
rxp2
;
u8g_uint_t
ryp
,
ryp2
;
rxp
=
rx
;
rxp
++
;
rxp2
=
rxp
;
rxp2
*=
2
;
ryp
=
ry
;
ryp
++
;
ryp2
=
ryp
;
ryp2
*=
2
;
if
(
u8g_IsBBXIntersection
(
u8g
,
x0
-
rxp
,
y0
-
ryp
,
rxp2
,
ryp2
)
==
0
)
return
;
}
u8g_draw_ellipse
(
u8g
,
x0
,
y0
,
rx
,
ry
,
option
);
}
static
void
u8g_draw_filled_ellipse_section
(
u8g_t
*
u8g
,
u8g_uint_t
x
,
u8g_uint_t
y
,
u8g_uint_t
x0
,
u8g_uint_t
y0
,
uint8_t
option
)
U8G_NOINLINE
;
static
void
u8g_draw_filled_ellipse_section
(
u8g_t
*
u8g
,
u8g_uint_t
x
,
u8g_uint_t
y
,
u8g_uint_t
x0
,
u8g_uint_t
y0
,
uint8_t
option
)
{
/* upper right */
if
(
option
&
U8G_DRAW_UPPER_RIGHT
)
{
u8g_DrawVLine
(
u8g
,
x0
+
x
,
y0
-
y
,
y
+
1
);
}
/* upper left */
if
(
option
&
U8G_DRAW_UPPER_LEFT
)
{
u8g_DrawVLine
(
u8g
,
x0
-
x
,
y0
-
y
,
y
+
1
);
}
/* lower right */
if
(
option
&
U8G_DRAW_LOWER_RIGHT
)
{
u8g_DrawVLine
(
u8g
,
x0
+
x
,
y0
,
y
+
1
);
}
/* lower left */
if
(
option
&
U8G_DRAW_LOWER_LEFT
)
{
u8g_DrawVLine
(
u8g
,
x0
-
x
,
y0
,
y
+
1
);
}
}
void
u8g_draw_filled_ellipse
(
u8g_t
*
u8g
,
u8g_uint_t
x0
,
u8g_uint_t
y0
,
u8g_uint_t
rx
,
u8g_uint_t
ry
,
uint8_t
option
)
{
u8g_uint_t
x
,
y
;
u8g_long_t
xchg
,
ychg
;
u8g_long_t
err
;
u8g_long_t
rxrx2
;
u8g_long_t
ryry2
;
u8g_long_t
stopx
,
stopy
;
rxrx2
=
rx
;
rxrx2
*=
rx
;
rxrx2
*=
2
;
ryry2
=
ry
;
ryry2
*=
ry
;
ryry2
*=
2
;
x
=
rx
;
y
=
0
;
xchg
=
1
;
xchg
-=
rx
;
xchg
-=
rx
;
xchg
*=
ry
;
xchg
*=
ry
;
ychg
=
rx
;
ychg
*=
rx
;
err
=
0
;
stopx
=
ryry2
;
stopx
*=
rx
;
stopy
=
0
;
while
(
stopx
>=
stopy
)
{
u8g_draw_filled_ellipse_section
(
u8g
,
x
,
y
,
x0
,
y0
,
option
);
y
++
;
stopy
+=
rxrx2
;
err
+=
ychg
;
ychg
+=
rxrx2
;
if
(
2
*
err
+
xchg
>
0
)
{
x
--
;
stopx
-=
ryry2
;
err
+=
xchg
;
xchg
+=
ryry2
;
}
}
x
=
0
;
y
=
ry
;
xchg
=
ry
;
xchg
*=
ry
;
ychg
=
1
;
ychg
-=
ry
;
ychg
-=
ry
;
ychg
*=
rx
;
ychg
*=
rx
;
err
=
0
;
stopx
=
0
;
stopy
=
rxrx2
;
stopy
*=
ry
;
while
(
stopx
<=
stopy
)
{
u8g_draw_filled_ellipse_section
(
u8g
,
x
,
y
,
x0
,
y0
,
option
);
x
++
;
stopx
+=
ryry2
;
err
+=
xchg
;
xchg
+=
ryry2
;
if
(
2
*
err
+
ychg
>
0
)
{
y
--
;
stopy
-=
rxrx2
;
err
+=
ychg
;
ychg
+=
rxrx2
;
}
}
}
void
u8g_DrawFilledEllipse
(
u8g_t
*
u8g
,
u8g_uint_t
x0
,
u8g_uint_t
y0
,
u8g_uint_t
rx
,
u8g_uint_t
ry
,
uint8_t
option
)
{
/* check for bounding box */
{
u8g_uint_t
rxp
,
rxp2
;
u8g_uint_t
ryp
,
ryp2
;
rxp
=
rx
;
rxp
++
;
rxp2
=
rxp
;
rxp2
*=
2
;
ryp
=
ry
;
ryp
++
;
ryp2
=
ryp
;
ryp2
*=
2
;
if
(
u8g_IsBBXIntersection
(
u8g
,
x0
-
rxp
,
y0
-
ryp
,
rxp2
,
ryp2
)
==
0
)
return
;
}
u8g_draw_filled_ellipse
(
u8g
,
x0
,
y0
,
rx
,
ry
,
option
);
}
app/u8glib/u8g_font.c
deleted
100644 → 0
View file @
fd745e09
/*
u8g_font.c
U8G Font High Level Interface
Universal 8bit Graphics Library
Copyright (c) 2011, olikraus@gmail.com
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or other
materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "u8g.h"
/* font api */
/* pointer to the start adress of the glyph, points to progmem area */
typedef
void
*
u8g_glyph_t
;
/* size of the font data structure, there is no struct or class... */
#define U8G_FONT_DATA_STRUCT_SIZE 17
/*
... instead the fields of the font data structure are accessed directly by offset
font information
offset
0 font format
1 FONTBOUNDINGBOX width unsigned
2 FONTBOUNDINGBOX height unsigned
3 FONTBOUNDINGBOX x-offset signed
4 FONTBOUNDINGBOX y-offset signed
5 capital A height unsigned
6 start 'A'
8 start 'a'
10 encoding start
11 encoding end
12 descent 'g' negative: below baseline
13 font max ascent
14 font min decent negative: below baseline
15 font xascent
16 font xdecent negative: below baseline
*/
/* use case: What is the width and the height of the minimal box into which string s fints? */
void
u8g_font_GetStrSize
(
const
void
*
font
,
const
char
*
s
,
u8g_uint_t
*
width
,
u8g_uint_t
*
height
);
void
u8g_font_GetStrSizeP
(
const
void
*
font
,
const
char
*
s
,
u8g_uint_t
*
width
,
u8g_uint_t
*
height
);
/* use case: lower left edge of a minimal box is known, what is the correct x, y position for the string draw procedure */
void
u8g_font_AdjustXYToDraw
(
const
void
*
font
,
const
char
*
s
,
u8g_uint_t
*
x
,
u8g_uint_t
*
y
);
void
u8g_font_AdjustXYToDrawP
(
const
void
*
font
,
const
char
*
s
,
u8g_uint_t
*
x
,
u8g_uint_t
*
y
);
/* use case: Baseline origin known, return minimal box */
void
u8g_font_GetStrMinBox
(
u8g_t
*
u8g
,
const
void
*
font
,
const
char
*
s
,
u8g_uint_t
*
x
,
u8g_uint_t
*
y
,
u8g_uint_t
*
width
,
u8g_uint_t
*
height
);
/* procedures */
/*========================================================================*/
/* low level byte and word access */
/* removed NOINLINE, because it leads to smaller code, might also be faster */
//static uint8_t u8g_font_get_byte(const u8g_fntpgm_uint8_t *font, uint8_t offset) U8G_NOINLINE;
static
uint8_t
u8g_font_get_byte
(
const
u8g_fntpgm_uint8_t
*
font
,
uint8_t
offset
)
{
font
+=
offset
;
return
u8g_pgm_read
(
(
u8g_pgm_uint8_t
*
)
font
);
}
static
uint16_t
u8g_font_get_word
(
const
u8g_fntpgm_uint8_t
*
font
,
uint8_t
offset
)
U8G_NOINLINE
;
static
uint16_t
u8g_font_get_word
(
const
u8g_fntpgm_uint8_t
*
font
,
uint8_t
offset
)
{
uint16_t
pos
;
font
+=
offset
;
pos
=
u8g_pgm_read
(
(
u8g_pgm_uint8_t
*
)
font
);
font
++
;
pos
<<=
8
;
pos
+=
u8g_pgm_read
(
(
u8g_pgm_uint8_t
*
)
font
);
return
pos
;
}
/*========================================================================*/
/* direct access on the font */
static
uint8_t
u8g_font_GetFormat
(
const
u8g_fntpgm_uint8_t
*
font
)
U8G_NOINLINE
;
static
uint8_t
u8g_font_GetFormat
(
const
u8g_fntpgm_uint8_t
*
font
)
{
return
u8g_font_get_byte
(
font
,
0
);
}
static
uint8_t
u8g_font_GetFontGlyphStructureSize
(
const
u8g_fntpgm_uint8_t
*
font
)
U8G_NOINLINE
;
static
uint8_t
u8g_font_GetFontGlyphStructureSize
(
const
u8g_fntpgm_uint8_t
*
font
)
{
switch
(
u8g_font_GetFormat
(
font
))
{
case
0
:
return
6
;
case
1
:
return
3
;
case
2
:
return
6
;
}
return
3
;
}
static
uint8_t
u8g_font_GetBBXWidth
(
const
void
*
font
)
{
return
u8g_font_get_byte
(
font
,
1
);
}
static
uint8_t
u8g_font_GetBBXHeight
(
const
void
*
font
)
{
return
u8g_font_get_byte
(
font
,
2
);
}
static
int8_t
u8g_font_GetBBXOffX
(
const
void
*
font
)
{
return
u8g_font_get_byte
(
font
,
3
);
}
static
int8_t
u8g_font_GetBBXOffY
(
const
void
*
font
)
{
return
u8g_font_get_byte
(
font
,
4
);
}
uint8_t
u8g_font_GetCapitalAHeight
(
const
void
*
font
)
{
return
u8g_font_get_byte
(
font
,
5
);
}
uint16_t
u8g_font_GetEncoding65Pos
(
const
void
*
font
)
U8G_NOINLINE
;
uint16_t
u8g_font_GetEncoding65Pos
(
const
void
*
font
)
{
return
u8g_font_get_word
(
font
,
6
);
}
uint16_t
u8g_font_GetEncoding97Pos
(
const
void
*
font
)
U8G_NOINLINE
;
uint16_t
u8g_font_GetEncoding97Pos
(
const
void
*
font
)
{
return
u8g_font_get_word
(
font
,
8
);
}
uint8_t
u8g_font_GetFontStartEncoding
(
const
void
*
font
)
{
return
u8g_font_get_byte
(
font
,
10
);
}
uint8_t
u8g_font_GetFontEndEncoding
(
const
void
*
font
)
{
return
u8g_font_get_byte
(
font
,
11
);
}
int8_t
u8g_font_GetLowerGDescent
(
const
void
*
font
)
{
return
u8g_font_get_byte
(
font
,
12
);
}
int8_t
u8g_font_GetFontAscent
(
const
void
*
font
)
{
return
u8g_font_get_byte
(
font
,
13
);
}
int8_t
u8g_font_GetFontDescent
(
const
void
*
font
)
{
return
u8g_font_get_byte
(
font
,
14
);
}
int8_t
u8g_font_GetFontXAscent
(
const
void
*
font
)
{
return
u8g_font_get_byte
(
font
,
15
);
}
int8_t
u8g_font_GetFontXDescent
(
const
void
*
font
)
{
return
u8g_font_get_byte
(
font
,
16
);
}
/* return the data start for a font and the glyph pointer */
static
uint8_t
*
u8g_font_GetGlyphDataStart
(
const
void
*
font
,
u8g_glyph_t
g
)
{
return
((
u8g_fntpgm_uint8_t
*
)
g
)
+
u8g_font_GetFontGlyphStructureSize
(
font
);
}
/* calculate the overall length of the font, only used to create the picture for the google wiki */
size_t
u8g_font_GetSize
(
const
void
*
font
)
{
uint8_t
*
p
=
(
uint8_t
*
)(
font
);
uint8_t
font_format
=
u8g_font_GetFormat
(
font
);
uint8_t
data_structure_size
=
u8g_font_GetFontGlyphStructureSize
(
font
);
uint8_t
start
,
end
;
uint8_t
i
;
uint8_t
mask
=
255
;
start
=
u8g_font_GetFontStartEncoding
(
font
);
end
=
u8g_font_GetFontEndEncoding
(
font
);
if
(
font_format
==
1
)
mask
=
15
;
p
+=
U8G_FONT_DATA_STRUCT_SIZE
;
/* skip font general information */
i
=
start
;
for
(;;)
{
if
(
u8g_pgm_read
((
u8g_pgm_uint8_t
*
)(
p
))
==
255
)
{
p
+=
1
;
}
else
{
p
+=
u8g_pgm_read
(
((
u8g_pgm_uint8_t
*
)(
p
))
+
2
)
&
mask
;
p
+=
data_structure_size
;
}
if
(
i
==
end
)
break
;
i
++
;
}
return
p
-
(
uint8_t
*
)
font
;
}
/*========================================================================*/
/* u8g interface, font access */
uint8_t
u8g_GetFontBBXWidth
(
u8g_t
*
u8g
)
{
return
u8g_font_GetBBXWidth
(
u8g
->
font
);
}
uint8_t
u8g_GetFontBBXHeight
(
u8g_t
*
u8g
)
{
return
u8g_font_GetBBXHeight
(
u8g
->
font
);
}
int8_t
u8g_GetFontBBXOffX
(
u8g_t
*
u8g
)
U8G_NOINLINE
;
int8_t
u8g_GetFontBBXOffX
(
u8g_t
*
u8g
)
{
return
u8g_font_GetBBXOffX
(
u8g
->
font
);
}
int8_t
u8g_GetFontBBXOffY
(
u8g_t
*
u8g
)
U8G_NOINLINE
;
int8_t
u8g_GetFontBBXOffY
(
u8g_t
*
u8g
)
{
return
u8g_font_GetBBXOffY
(
u8g
->
font
);
}
uint8_t
u8g_GetFontCapitalAHeight
(
u8g_t
*
u8g
)
U8G_NOINLINE
;
uint8_t
u8g_GetFontCapitalAHeight
(
u8g_t
*
u8g
)
{
return
u8g_font_GetCapitalAHeight
(
u8g
->
font
);
}
/*========================================================================*/
/* glyph handling */
static
void
u8g_CopyGlyphDataToCache
(
u8g_t
*
u8g
,
u8g_glyph_t
g
)
{
uint8_t
tmp
;
switch
(
u8g_font_GetFormat
(
u8g
->
font
)
)
{
case
0
:
case
2
:
/*
format 0
glyph information
offset
0 BBX width unsigned
1 BBX height unsigned
2 data size unsigned (BBX width + 7)/8 * BBX height
3 DWIDTH signed
4 BBX xoffset signed
5 BBX yoffset signed
byte 0 == 255 indicates empty glyph
*/
u8g
->
glyph_width
=
u8g_pgm_read
(
((
u8g_pgm_uint8_t
*
)
g
)
+
0
);
u8g
->
glyph_height
=
u8g_pgm_read
(
((
u8g_pgm_uint8_t
*
)
g
)
+
1
);
u8g
->
glyph_dx
=
u8g_pgm_read
(
((
u8g_pgm_uint8_t
*
)
g
)
+
3
);
u8g
->
glyph_x
=
u8g_pgm_read
(
((
u8g_pgm_uint8_t
*
)
g
)
+
4
);
u8g
->
glyph_y
=
u8g_pgm_read
(
((
u8g_pgm_uint8_t
*
)
g
)
+
5
);
break
;
case
1
:
default:
/*
format 1
0 BBX xoffset signed --> upper 4 Bit
0 BBX yoffset signed --> lower 4 Bit
1 BBX width unsigned --> upper 4 Bit
1 BBX height unsigned --> lower 4 Bit
2 data size unsigned -(BBX width + 7)/8 * BBX height --> lower 4 Bit
2 DWIDTH signed --> upper 4 Bit
byte 0 == 255 indicates empty glyph
*/
tmp
=
u8g_pgm_read
(
((
u8g_pgm_uint8_t
*
)
g
)
+
0
);
u8g
->
glyph_y
=
tmp
&
15
;
u8g
->
glyph_y
-=
2
;
tmp
>>=
4
;
u8g
->
glyph_x
=
tmp
;
tmp
=
u8g_pgm_read
(
((
u8g_pgm_uint8_t
*
)
g
)
+
1
);
u8g
->
glyph_height
=
tmp
&
15
;
tmp
>>=
4
;
u8g
->
glyph_width
=
tmp
;
tmp
=
u8g_pgm_read
(
((
u8g_pgm_uint8_t
*
)
g
)
+
2
);
tmp
>>=
4
;
u8g
->
glyph_dx
=
tmp
;
break
;
}
}
//void u8g_FillEmptyGlyphCache(u8g_t *u8g) U8G_NOINLINE;
static
void
u8g_FillEmptyGlyphCache
(
u8g_t
*
u8g
)
{
u8g
->
glyph_dx
=
0
;
u8g
->
glyph_width
=
0
;
u8g
->
glyph_height
=
0
;
u8g
->
glyph_x
=
0
;
u8g
->
glyph_y
=
0
;
}
/*
Find (with some speed optimization) and return a pointer to the glyph data structure
Also uncompress (format 1) and copy the content of the data structure to the u8g structure
*/
u8g_glyph_t
u8g_GetGlyph
(
u8g_t
*
u8g
,
uint8_t
requested_encoding
)
{
uint8_t
*
p
=
(
uint8_t
*
)(
u8g
->
font
);
uint8_t
font_format
=
u8g_font_GetFormat
(
u8g
->
font
);
uint8_t
data_structure_size
=
u8g_font_GetFontGlyphStructureSize
(
u8g
->
font
);
uint8_t
start
,
end
;
uint16_t
pos
;
uint8_t
i
;
uint8_t
mask
=
255
;
if
(
font_format
==
1
)
mask
=
15
;
start
=
u8g_font_GetFontStartEncoding
(
u8g
->
font
);
end
=
u8g_font_GetFontEndEncoding
(
u8g
->
font
);
pos
=
u8g_font_GetEncoding97Pos
(
u8g
->
font
);
if
(
requested_encoding
>=
97
&&
pos
>
0
)
{
p
+=
pos
;
start
=
97
;
}
else
{
pos
=
u8g_font_GetEncoding65Pos
(
u8g
->
font
);
if
(
requested_encoding
>=
65
&&
pos
>
0
)
{
p
+=
pos
;
start
=
65
;
}
else
p
+=
U8G_FONT_DATA_STRUCT_SIZE
;
/* skip font general information */
}
if
(
requested_encoding
>
end
)
{
u8g_FillEmptyGlyphCache
(
u8g
);
return
NULL
;
/* not found */
}
i
=
start
;
if
(
i
<=
end
)
{
for
(;;)
{
if
(
u8g_pgm_read
((
u8g_pgm_uint8_t
*
)(
p
))
==
255
)
{
p
+=
1
;
}
else
{
if
(
i
==
requested_encoding
)
{
u8g_CopyGlyphDataToCache
(
u8g
,
p
);
return
p
;
}
p
+=
u8g_pgm_read
(
((
u8g_pgm_uint8_t
*
)(
p
))
+
2
)
&
mask
;
p
+=
data_structure_size
;
}
if
(
i
==
end
)
break
;
i
++
;
}
}
u8g_FillEmptyGlyphCache
(
u8g
);
return
NULL
;
}
uint8_t
u8g_IsGlyph
(
u8g_t
*
u8g
,
uint8_t
requested_encoding
)
{
if
(
u8g_GetGlyph
(
u8g
,
requested_encoding
)
!=
NULL
)
return
1
;
return
0
;
}
int8_t
u8g_GetGlyphDeltaX
(
u8g_t
*
u8g
,
uint8_t
requested_encoding
)
{
if
(
u8g_GetGlyph
(
u8g
,
requested_encoding
)
==
NULL
)
return
0
;
/* should never happen, so return something */
return
u8g
->
glyph_dx
;
}
/*========================================================================*/
/* glyph drawing procedures */
#ifdef OBSOLETE
/*
Draw a glyph
x,y: left baseline position of the glyph
*/
int8_t
u8g_DrawGlyphDir
(
u8g_t
*
u8g
,
u8g_uint_t
x
,
u8g_uint_t
y
,
uint8_t
dir
,
uint8_t
encoding
)
{
u8g_glyph_t
g
;
uint8_t
w
,
h
,
i
,
j
;
const
u8g_pgm_uint8_t
*
data
;
uint8_t
bytes_per_line
;
u8g_uint_t
ix
,
iy
;
g
=
u8g_GetGlyph
(
u8g
,
encoding
);
if
(
g
==
NULL
)
return
0
;
w
=
u8g
->
glyph_width
;
h
=
u8g
->
glyph_height
;
bytes_per_line
=
w
;
bytes_per_line
+=
7
;
bytes_per_line
/=
8
;
data
=
u8g_font_GetGlyphDataStart
(
u8g
->
font
,
g
);
switch
(
dir
)
{
case
0
:
x
+=
u8g
->
glyph_x
;
y
-=
u8g
->
glyph_y
;
y
--
;
//u8g_DrawFrame(u8g, x, y-h+1, w, h);
if
(
u8g_IsBBXIntersection
(
u8g
,
x
,
y
-
h
+
1
,
w
,
h
)
==
0
)
return
u8g
->
glyph_dx
;
iy
=
y
;
iy
-=
h
;
iy
++
;
for
(
j
=
0
;
j
<
h
;
j
++
)
{
ix
=
x
;
for
(
i
=
0
;
i
<
bytes_per_line
;
i
++
)
{
u8g_Draw8Pixel
(
u8g
,
ix
,
iy
,
dir
,
u8g_pgm_read
(
data
));
data
++
;
ix
+=
8
;
}
iy
++
;
}
break
;
case
1
:
x
+=
u8g
->
glyph_y
;
x
++
;
y
+=
u8g
->
glyph_x
;
//printf("enc %d, dir %d, x %d, y %d, w %d, h %d\n", encoding, dir, x, y, w, h);
//u8g_DrawFrame(u8g, x, y, h, w);
if
(
u8g_IsBBXIntersection
(
u8g
,
x
,
y
,
h
,
w
)
==
0
)
return
u8g
->
glyph_dx
;
ix
=
x
;
ix
+=
h
;
ix
--
;
for
(
j
=
0
;
j
<
h
;
j
++
)
{
iy
=
y
;
for
(
i
=
0
;
i
<
bytes_per_line
;
i
++
)
{
u8g_Draw8Pixel
(
u8g
,
ix
,
iy
,
dir
,
u8g_pgm_read
(
data
));
data
++
;
iy
+=
8
;
}
ix
--
;
}
break
;
case
2
:
x
-=
u8g
->
glyph_x
;
y
+=
u8g
->
glyph_y
;
y
++
;
if
(
u8g_IsBBXIntersection
(
u8g
,
x
-
w
-
1
,
y
,
w
,
h
)
==
0
)
return
u8g
->
glyph_dx
;
iy
=
y
;
iy
+=
h
;
iy
--
;
for
(
j
=
0
;
j
<
h
;
j
++
)
{
ix
=
x
;
for
(
i
=
0
;
i
<
bytes_per_line
;
i
++
)
{
u8g_Draw8Pixel
(
u8g
,
ix
,
iy
,
dir
,
u8g_pgm_read
(
data
));
data
++
;
ix
-=
8
;
}
iy
--
;
}
break
;
case
3
:
x
-=
u8g
->
glyph_y
;
x
--
;
y
-=
u8g
->
glyph_x
;
if
(
u8g_IsBBXIntersection
(
u8g
,
x
-
h
-
1
,
y
-
w
-
1
,
h
,
w
)
==
0
)
return
u8g
->
glyph_dx
;
ix
=
x
;
ix
-=
h
;
ix
++
;
for
(
j
=
0
;
j
<
h
;
j
++
)
{
iy
=
y
;
for
(
i
=
0
;
i
<
bytes_per_line
;
i
++
)
{
u8g_Draw8Pixel
(
u8g
,
ix
,
iy
,
dir
,
u8g_pgm_read
(
data
));
data
++
;
iy
-=
8
;
}
ix
++
;
}
break
;
}
return
u8g
->
glyph_dx
;
}
#endif
int8_t
u8g_draw_glyph
(
u8g_t
*
u8g
,
u8g_uint_t
x
,
u8g_uint_t
y
,
uint8_t
encoding
)
{
const
u8g_pgm_uint8_t
*
data
;
uint8_t
w
,
h
;
uint8_t
i
,
j
;
u8g_uint_t
ix
,
iy
;
{
u8g_glyph_t
g
=
u8g_GetGlyph
(
u8g
,
encoding
);
if
(
g
==
NULL
)
return
0
;
data
=
u8g_font_GetGlyphDataStart
(
u8g
->
font
,
g
);
}
w
=
u8g
->
glyph_width
;
h
=
u8g
->
glyph_height
;
x
+=
u8g
->
glyph_x
;
y
-=
u8g
->
glyph_y
;
y
--
;
if
(
u8g_IsBBXIntersection
(
u8g
,
x
,
y
-
h
+
1
,
w
,
h
)
==
0
)
return
u8g
->
glyph_dx
;
/* now, w is reused as bytes per line */
w
+=
7
;
w
/=
8
;
iy
=
y
;
iy
-=
h
;
iy
++
;
for
(
j
=
0
;
j
<
h
;
j
++
)
{
ix
=
x
;
for
(
i
=
0
;
i
<
w
;
i
++
)
{
u8g_Draw8Pixel
(
u8g
,
ix
,
iy
,
0
,
u8g_pgm_read
(
data
));
data
++
;
ix
+=
8
;
}
iy
++
;
}
return
u8g
->
glyph_dx
;
}
int8_t
u8g_DrawGlyph
(
u8g_t
*
u8g
,
u8g_uint_t
x
,
u8g_uint_t
y
,
uint8_t
encoding
)
{
y
+=
u8g
->
font_calc_vref
(
u8g
);
return
u8g_draw_glyph
(
u8g
,
x
,
y
,
encoding
);
}
int8_t
u8g_draw_glyph90
(
u8g_t
*
u8g
,
u8g_uint_t
x
,
u8g_uint_t
y
,
uint8_t
encoding
)
{
const
u8g_pgm_uint8_t
*
data
;
uint8_t
w
,
h
;
uint8_t
i
,
j
;
u8g_uint_t
ix
,
iy
;
{
u8g_glyph_t
g
=
u8g_GetGlyph
(
u8g
,
encoding
);
if
(
g
==
NULL
)
return
0
;
data
=
u8g_font_GetGlyphDataStart
(
u8g
->
font
,
g
);
}
w
=
u8g
->
glyph_width
;
h
=
u8g
->
glyph_height
;
x
+=
u8g
->
glyph_y
;
x
++
;
y
+=
u8g
->
glyph_x
;
if
(
u8g_IsBBXIntersection
(
u8g
,
x
,
y
,
h
,
w
)
==
0
)
return
u8g
->
glyph_dx
;
/* now, w is reused as bytes per line */
w
+=
7
;
w
/=
8
;
ix
=
x
;
ix
+=
h
;
ix
--
;
for
(
j
=
0
;
j
<
h
;
j
++
)
{
iy
=
y
;
for
(
i
=
0
;
i
<
w
;
i
++
)
{
u8g_Draw8Pixel
(
u8g
,
ix
,
iy
,
1
,
u8g_pgm_read
(
data
));
data
++
;
iy
+=
8
;
}
ix
--
;
}
return
u8g
->
glyph_dx
;
}
int8_t
u8g_DrawGlyph90
(
u8g_t
*
u8g
,
u8g_uint_t
x
,
u8g_uint_t
y
,
uint8_t
encoding
)
{
x
-=
u8g
->
font_calc_vref
(
u8g
);
return
u8g_draw_glyph90
(
u8g
,
x
,
y
,
encoding
);
}
int8_t
u8g_draw_glyph180
(
u8g_t
*
u8g
,
u8g_uint_t
x
,
u8g_uint_t
y
,
uint8_t
encoding
)
{
const
u8g_pgm_uint8_t
*
data
;
uint8_t
w
,
h
;
uint8_t
i
,
j
;
u8g_uint_t
ix
,
iy
;
{
u8g_glyph_t
g
=
u8g_GetGlyph
(
u8g
,
encoding
);
if
(
g
==
NULL
)
return
0
;
data
=
u8g_font_GetGlyphDataStart
(
u8g
->
font
,
g
);
}
w
=
u8g
->
glyph_width
;
h
=
u8g
->
glyph_height
;
x
-=
u8g
->
glyph_x
;
y
+=
u8g
->
glyph_y
;
y
++
;
if
(
u8g_IsBBXIntersection
(
u8g
,
x
-
(
w
-
1
),
y
,
w
,
h
)
==
0
)
return
u8g
->
glyph_dx
;
/* now, w is reused as bytes per line */
w
+=
7
;
w
/=
8
;
iy
=
y
;
iy
+=
h
;
iy
--
;
for
(
j
=
0
;
j
<
h
;
j
++
)
{
ix
=
x
;
for
(
i
=
0
;
i
<
w
;
i
++
)
{
u8g_Draw8Pixel
(
u8g
,
ix
,
iy
,
2
,
u8g_pgm_read
(
data
));
data
++
;
ix
-=
8
;
}
iy
--
;
}
return
u8g
->
glyph_dx
;
}
int8_t
u8g_DrawGlyph180
(
u8g_t
*
u8g
,
u8g_uint_t
x
,
u8g_uint_t
y
,
uint8_t
encoding
)
{
y
-=
u8g
->
font_calc_vref
(
u8g
);
return
u8g_draw_glyph180
(
u8g
,
x
,
y
,
encoding
);
}
int8_t
u8g_draw_glyph270
(
u8g_t
*
u8g
,
u8g_uint_t
x
,
u8g_uint_t
y
,
uint8_t
encoding
)
{
const
u8g_pgm_uint8_t
*
data
;
uint8_t
w
,
h
;
uint8_t
i
,
j
;
u8g_uint_t
ix
,
iy
;
{
u8g_glyph_t
g
=
u8g_GetGlyph
(
u8g
,
encoding
);
if
(
g
==
NULL
)
return
0
;
data
=
u8g_font_GetGlyphDataStart
(
u8g
->
font
,
g
);
}
w
=
u8g
->
glyph_width
;
h
=
u8g
->
glyph_height
;
x
-=
u8g
->
glyph_y
;
x
--
;
y
-=
u8g
->
glyph_x
;
if
(
u8g_IsBBXIntersection
(
u8g
,
x
-
(
h
-
1
),
y
-
(
w
-
1
),
h
,
w
)
==
0
)
return
u8g
->
glyph_dx
;
/* now, w is reused as bytes per line */
w
+=
7
;
w
/=
8
;
ix
=
x
;
ix
-=
h
;
ix
++
;
for
(
j
=
0
;
j
<
h
;
j
++
)
{
iy
=
y
;
for
(
i
=
0
;
i
<
w
;
i
++
)
{
u8g_Draw8Pixel
(
u8g
,
ix
,
iy
,
3
,
u8g_pgm_read
(
data
));
data
++
;
iy
-=
8
;
}
ix
++
;
}
return
u8g
->
glyph_dx
;
}
int8_t
u8g_DrawGlyph270
(
u8g_t
*
u8g
,
u8g_uint_t
x
,
u8g_uint_t
y
,
uint8_t
encoding
)
{
x
+=
u8g
->
font_calc_vref
(
u8g
);
return
u8g_draw_glyph270
(
u8g
,
x
,
y
,
encoding
);
}
#ifdef OBSOLETE
/*
Draw a glyph
x,y: lower left corner of the font bounding box
*/
int8_t
u8g_DrawGlyphFontBBX
(
u8g_t
*
u8g
,
u8g_uint_t
x
,
u8g_uint_t
y
,
uint8_t
dir
,
uint8_t
encoding
)
{
/* TODO: apply "dir" */
x
-=
u8g_GetFontBBXOffX
(
u8g
);
y
+=
u8g_GetFontBBXOffY
(
u8g
);
return
u8g_DrawGlyphDir
(
u8g
,
x
,
y
,
dir
,
encoding
);
}
#endif
/*========================================================================*/
/* string drawing procedures */
u8g_uint_t
u8g_DrawStr
(
u8g_t
*
u8g
,
u8g_uint_t
x
,
u8g_uint_t
y
,
const
char
*
s
)
{
u8g_uint_t
t
=
0
;
int8_t
d
;
//u8g_uint_t u8g_GetStrWidth(u8g, s);
//u8g_font_GetFontAscent(u8g->font)-u8g_font_GetFontDescent(u8g->font);
y
+=
u8g
->
font_calc_vref
(
u8g
);
while
(
*
s
!=
'\0'
)
{
d
=
u8g_draw_glyph
(
u8g
,
x
,
y
,
*
s
);
x
+=
d
;
t
+=
d
;
s
++
;
}
return
t
;
}
u8g_uint_t
u8g_DrawStr90
(
u8g_t
*
u8g
,
u8g_uint_t
x
,
u8g_uint_t
y
,
const
char
*
s
)
{
u8g_uint_t
t
=
0
;
int8_t
d
;
x
-=
u8g
->
font_calc_vref
(
u8g
);
while
(
*
s
!=
'\0'
)
{
d
=
u8g_draw_glyph90
(
u8g
,
x
,
y
,
*
s
);
y
+=
d
;
t
+=
d
;
s
++
;
}
return
t
;
}
u8g_uint_t
u8g_DrawStr180
(
u8g_t
*
u8g
,
u8g_uint_t
x
,
u8g_uint_t
y
,
const
char
*
s
)
{
u8g_uint_t
t
=
0
;
int8_t
d
;
y
-=
u8g
->
font_calc_vref
(
u8g
);
while
(
*
s
!=
'\0'
)
{
d
=
u8g_draw_glyph180
(
u8g
,
x
,
y
,
*
s
);
x
-=
d
;
t
+=
d
;
s
++
;
}
return
t
;
}
u8g_uint_t
u8g_DrawStr270
(
u8g_t
*
u8g
,
u8g_uint_t
x
,
u8g_uint_t
y
,
const
char
*
s
)
{
u8g_uint_t
t
=
0
;
int8_t
d
;
x
+=
u8g
->
font_calc_vref
(
u8g
);
while
(
*
s
!=
'\0'
)
{
d
=
u8g_draw_glyph270
(
u8g
,
x
,
y
,
*
s
);
y
-=
d
;
t
+=
d
;
s
++
;
}
return
t
;
}
u8g_uint_t
u8g_DrawStrDir
(
u8g_t
*
u8g
,
u8g_uint_t
x
,
u8g_uint_t
y
,
uint8_t
dir
,
const
char
*
s
)
{
switch
(
dir
)
{
case
0
:
return
u8g_DrawStr
(
u8g
,
x
,
y
,
s
);
case
1
:
return
u8g_DrawStr90
(
u8g
,
x
,
y
,
s
);
case
2
:
return
u8g_DrawStr180
(
u8g
,
x
,
y
,
s
);
case
3
:
return
u8g_DrawStr270
(
u8g
,
x
,
y
,
s
);
}
return
0
;
}
u8g_uint_t
u8g_DrawStrP
(
u8g_t
*
u8g
,
u8g_uint_t
x
,
u8g_uint_t
y
,
const
u8g_pgm_uint8_t
*
s
)
{
u8g_uint_t
t
=
0
;
int8_t
d
;
uint8_t
c
;
y
+=
u8g
->
font_calc_vref
(
u8g
);
for
(;;)
{
c
=
u8g_pgm_read
(
s
);
if
(
c
==
'\0'
)
break
;
d
=
u8g_draw_glyph
(
u8g
,
x
,
y
,
c
);
x
+=
d
;
t
+=
d
;
s
++
;
}
return
t
;
}
u8g_uint_t
u8g_DrawStr90P
(
u8g_t
*
u8g
,
u8g_uint_t
x
,
u8g_uint_t
y
,
const
u8g_pgm_uint8_t
*
s
)
{
u8g_uint_t
t
=
0
;
int8_t
d
;
uint8_t
c
;
x
-=
u8g
->
font_calc_vref
(
u8g
);
for
(;;)
{
c
=
u8g_pgm_read
(
s
);
if
(
c
==
'\0'
)
break
;
d
=
u8g_DrawGlyph90
(
u8g
,
x
,
y
,
c
);
y
+=
d
;
t
+=
d
;
s
++
;
}
return
t
;
}
u8g_uint_t
u8g_DrawStr180P
(
u8g_t
*
u8g
,
u8g_uint_t
x
,
u8g_uint_t
y
,
const
u8g_pgm_uint8_t
*
s
)
{
u8g_uint_t
t
=
0
;
int8_t
d
;
uint8_t
c
;
y
-=
u8g
->
font_calc_vref
(
u8g
);
for
(;;)
{
c
=
u8g_pgm_read
(
s
);
if
(
c
==
'\0'
)
break
;
d
=
u8g_DrawGlyph180
(
u8g
,
x
,
y
,
c
);
x
-=
d
;
t
+=
d
;
s
++
;
}
return
t
;
}
u8g_uint_t
u8g_DrawStr270P
(
u8g_t
*
u8g
,
u8g_uint_t
x
,
u8g_uint_t
y
,
const
u8g_pgm_uint8_t
*
s
)
{
u8g_uint_t
t
=
0
;
int8_t
d
;
uint8_t
c
;
x
+=
u8g
->
font_calc_vref
(
u8g
);
for
(;;)
{
c
=
u8g_pgm_read
(
s
);
if
(
c
==
'\0'
)
break
;
d
=
u8g_DrawGlyph270
(
u8g
,
x
,
y
,
c
);
y
-=
d
;
t
+=
d
;
s
++
;
}
return
t
;
}
u8g_uint_t
u8g_DrawStrFontBBX
(
u8g_t
*
u8g
,
u8g_uint_t
x
,
u8g_uint_t
y
,
uint8_t
dir
,
const
char
*
s
)
{
x
-=
u8g_GetFontBBXOffX
(
u8g
);
y
+=
u8g_GetFontBBXOffY
(
u8g
);
return
u8g_DrawStrDir
(
u8g
,
x
,
y
,
dir
,
s
);
}
/* still used by picgen.c, dir argument is ignored */
int8_t
u8g_DrawGlyphFontBBX
(
u8g_t
*
u8g
,
u8g_uint_t
x
,
u8g_uint_t
y
,
uint8_t
dir
,
uint8_t
encoding
)
{
x
-=
u8g_GetFontBBXOffX
(
u8g
);
y
+=
u8g_GetFontBBXOffY
(
u8g
);
u8g_draw_glyph
(
u8g
,
x
,
y
,
encoding
);
return
0
;
}
/*========================================================================*/
/* set ascent/descent for reference point calculation */
void
u8g_UpdateRefHeight
(
u8g_t
*
u8g
)
{
uint16_t
ls
;
if
(
u8g
->
font
==
NULL
)
return
;
if
(
u8g
->
font_height_mode
==
U8G_FONT_HEIGHT_MODE_TEXT
)
{
u8g
->
font_ref_ascent
=
u8g_font_GetCapitalAHeight
(
u8g
->
font
);
u8g
->
font_ref_descent
=
u8g_font_GetLowerGDescent
(
u8g
->
font
);
}
else
if
(
u8g
->
font_height_mode
==
U8G_FONT_HEIGHT_MODE_XTEXT
)
{
u8g
->
font_ref_ascent
=
u8g_font_GetFontXAscent
(
u8g
->
font
);
u8g
->
font_ref_descent
=
u8g_font_GetFontXDescent
(
u8g
->
font
);
}
else
{
u8g
->
font_ref_ascent
=
u8g_font_GetFontAscent
(
u8g
->
font
);
u8g
->
font_ref_descent
=
u8g_font_GetFontDescent
(
u8g
->
font
);
}
ls
=
u8g
->
font_ref_ascent
-
u8g
->
font_ref_descent
;
if
(
u8g
->
font_line_spacing_factor
!=
64
)
{
ls
&=
255
;
ls
*=
u8g
->
font_line_spacing_factor
;
ls
>>=
6
;
}
u8g
->
line_spacing
=
ls
;
}
void
u8g_SetFontRefHeightText
(
u8g_t
*
u8g
)
{
u8g
->
font_height_mode
=
U8G_FONT_HEIGHT_MODE_TEXT
;
u8g_UpdateRefHeight
(
u8g
);
}
void
u8g_SetFontRefHeightExtendedText
(
u8g_t
*
u8g
)
{
u8g
->
font_height_mode
=
U8G_FONT_HEIGHT_MODE_XTEXT
;
u8g_UpdateRefHeight
(
u8g
);
}
void
u8g_SetFontRefHeightAll
(
u8g_t
*
u8g
)
{
u8g
->
font_height_mode
=
U8G_FONT_HEIGHT_MODE_ALL
;
u8g_UpdateRefHeight
(
u8g
);
}
/* factor = 64: linespaceing == ascent and descent */
void
u8g_SetFontLineSpacingFactor
(
u8g_t
*
u8g
,
uint8_t
factor
)
{
u8g
->
font_line_spacing_factor
=
factor
;
u8g_UpdateRefHeight
(
u8g
);
}
/*========================================================================*/
/* callback procedures to correct the y position */
u8g_uint_t
u8g_font_calc_vref_font
(
u8g_t
*
u8g
)
{
return
0
;
}
void
u8g_SetFontPosBaseline
(
u8g_t
*
u8g
)
{
u8g
->
font_calc_vref
=
u8g_font_calc_vref_font
;
}
u8g_uint_t
u8g_font_calc_vref_bottom
(
u8g_t
*
u8g
)
{
/* y += (u8g_uint_t)(u8g_int_t)(u8g->font_ref_descent); */
return
(
u8g_uint_t
)(
u8g_int_t
)(
u8g
->
font_ref_descent
);
}
void
u8g_SetFontPosBottom
(
u8g_t
*
u8g
)
{
u8g
->
font_calc_vref
=
u8g_font_calc_vref_bottom
;
}
u8g_uint_t
u8g_font_calc_vref_top
(
u8g_t
*
u8g
)
{
u8g_uint_t
tmp
;
/* reference pos is one pixel above the upper edge of the reference glyph */
/*
y += (u8g_uint_t)(u8g_int_t)(u8g->font_ref_ascent);
y++;
*/
tmp
=
(
u8g_uint_t
)(
u8g_int_t
)(
u8g
->
font_ref_ascent
);
tmp
++
;
return
tmp
;
}
void
u8g_SetFontPosTop
(
u8g_t
*
u8g
)
{
u8g
->
font_calc_vref
=
u8g_font_calc_vref_top
;
}
u8g_uint_t
u8g_font_calc_vref_center
(
u8g_t
*
u8g
)
{
int8_t
tmp
;
tmp
=
u8g
->
font_ref_ascent
;
tmp
-=
u8g
->
font_ref_descent
;
tmp
/=
2
;
tmp
+=
u8g
->
font_ref_descent
;
/* y += (u8g_uint_t)(u8g_int_t)(tmp); */
return
tmp
;
}
void
u8g_SetFontPosCenter
(
u8g_t
*
u8g
)
{
u8g
->
font_calc_vref
=
u8g_font_calc_vref_center
;
}
/*========================================================================*/
/* string pixel width calculation */
char
u8g_font_get_char
(
const
void
*
s
)
{
return
*
(
const
char
*
)(
s
);
}
char
u8g_font_get_charP
(
const
void
*
s
)
{
return
u8g_pgm_read
(
s
);
}
typedef
char
(
*
u8g_font_get_char_fn
)(
const
void
*
s
);
u8g_uint_t
u8g_font_calc_str_pixel_width
(
u8g_t
*
u8g
,
const
char
*
s
,
u8g_font_get_char_fn
get_char
)
{
u8g_uint_t
w
;
uint8_t
enc
;
/* reset the total minimal width to zero, this will be expanded during calculation */
w
=
0
;
enc
=
get_char
(
s
);
/* check for empty string, width is already 0 */
if
(
enc
==
'\0'
)
{
return
w
;
}
/* get the glyph information of the first char. This must be valid, because we already checked for the empty string */
/* if *s is not inside the font, then the cached parameters of the glyph are all zero */
u8g_GetGlyph
(
u8g
,
enc
);
/* strlen(s) == 1: width = width(s[0]) */
/* strlen(s) == 2: width = - offx(s[0]) + deltax(s[0]) + offx(s[1]) + width(s[1]) */
/* strlen(s) == 3: width = - offx(s[0]) + deltax(s[0]) + deltax(s[1]) + offx(s[2]) + width(s[2]) */
/* assume that the string has size 2 or more, than start with negative offset-x */
/* for string with size 1, this will be nullified after the loop */
w
=
-
u8g
->
glyph_x
;
for
(;;)
{
/* check and stop if the end of the string is reached */
s
++
;
if
(
get_char
(
s
)
==
'\0'
)
break
;
/* if there are still more characters, add the delta to the next glyph */
w
+=
u8g
->
glyph_dx
;
/* store the encoding in a local variable, used also after the for(;;) loop */
enc
=
get_char
(
s
);
/* load the next glyph information */
u8g_GetGlyph
(
u8g
,
enc
);
}
/* finally calculate the width of the last char */
/* here is another exception, if the last char is a black, use the dx value instead */
if
(
enc
!=
' '
)
{
/* if g was not updated in the for loop (strlen() == 1), then the initial offset x gets removed */
w
+=
u8g
->
glyph_width
;
w
+=
u8g
->
glyph_x
;
}
else
{
w
+=
u8g
->
glyph_dx
;
}
return
w
;
}
u8g_uint_t
u8g_GetStrPixelWidth
(
u8g_t
*
u8g
,
const
char
*
s
)
{
return
u8g_font_calc_str_pixel_width
(
u8g
,
s
,
u8g_font_get_char
);
}
u8g_uint_t
u8g_GetStrPixelWidthP
(
u8g_t
*
u8g
,
const
u8g_pgm_uint8_t
*
s
)
{
return
u8g_font_calc_str_pixel_width
(
u8g
,
(
const
char
*
)
s
,
u8g_font_get_charP
);
}
int8_t
u8g_GetStrX
(
u8g_t
*
u8g
,
const
char
*
s
)
{
u8g_GetGlyph
(
u8g
,
*
s
);
return
u8g
->
glyph_x
;
}
int8_t
u8g_GetStrXP
(
u8g_t
*
u8g
,
const
u8g_pgm_uint8_t
*
s
)
{
u8g_GetGlyph
(
u8g
,
u8g_pgm_read
(
s
));
return
u8g
->
glyph_x
;
}
/*========================================================================*/
/* string width calculation */
u8g_uint_t
u8g_GetStrWidth
(
u8g_t
*
u8g
,
const
char
*
s
)
{
u8g_uint_t
w
;
uint8_t
encoding
;
/* reset the total width to zero, this will be expanded during calculation */
w
=
0
;
for
(;;)
{
encoding
=
*
s
;
if
(
encoding
==
0
)
break
;
/* load glyph information */
u8g_GetGlyph
(
u8g
,
encoding
);
w
+=
u8g
->
glyph_dx
;
/* goto next char */
s
++
;
}
return
w
;
}
u8g_uint_t
u8g_GetStrWidthP
(
u8g_t
*
u8g
,
const
u8g_pgm_uint8_t
*
s
)
{
u8g_uint_t
w
;
uint8_t
encoding
;
/* reset the total width to zero, this will be expanded during calculation */
w
=
0
;
for
(;;)
{
encoding
=
u8g_pgm_read
(
s
);
if
(
encoding
==
0
)
break
;
/* load glyph information */
u8g_GetGlyph
(
u8g
,
encoding
);
w
+=
u8g
->
glyph_dx
;
/* goto next char */
s
++
;
}
return
w
;
}
/*========================================================================*/
/* calculation of font/glyph/string characteristics */
/*
Description:
Calculate parameter for the minimal bounding box on a given string
Output
buf->y_min extend of the lower left edge if the string below (y_min<0) or above (y_min>0) baseline (descent)
buf->y_max extend of the upper left edge if the string below (y_min<0) or above (y_min>0) baseline (ascent)
buf->w the width of the string
*/
struct
u8g_str_size_struct
{
int8_t
y_min
;
/* descent */
int8_t
y_max
;
/* ascent */
int8_t
x
,
y
;
/* the reference point of the font (negated!) */
u8g_uint_t
w
;
/* width of the overall string */
};
typedef
struct
u8g_str_size_struct
u8g_str_size_t
;
static
void
u8g_font_calc_str_min_box
(
u8g_t
*
u8g
,
const
char
*
s
,
u8g_str_size_t
*
buf
)
{
/* u8g_glyph_t g; */
int8_t
tmp
;
/* reset the total minimal width to zero, this will be expanded during calculation */
buf
->
w
=
0
;
/* check for empty string, width is already 0, but also reset y_min and y_max to 0 */
if
(
*
s
==
'\0'
)
{
buf
->
y_min
=
0
;
buf
->
y_max
=
0
;
buf
->
x
=
0
;
buf
->
y
=
0
;
return
;
}
/* reset y_min to the largest possible value. Later we search for the smallest value */
/* y_min contains the position [pixel] of the lower left edge of the glyph above (y_min>0) or below (y_min<0) baseline */
buf
->
y_min
=
127
;
/* reset y_max to the smallest possible value. Later we search for the highest value */
/* y_max contains the position [pixel] of the upper left edge of the glyph above (y_max>0) or below (y_max<0) baseline */
buf
->
y_max
=
-
128
;
/* get the glyph information of the first char. This must be valid, because we already checked for the empty string */
u8g_GetGlyph
(
u8g
,
*
s
);
/* strlen(s) == 1: width = width(s[0]) */
/* strlen(s) == 2: width = - offx(s[0]) + deltax(s[0]) + offx(s[1]) + width(s[1]) */
/* strlen(s) == 3: width = - offx(s[0]) + deltax(s[0]) + deltax(s[1]) + offx(s[2]) + width(s[2]) */
/* assume that the string has size 2 or more, than start with negative offset-x */
/* for string with size 1, this will be nullified after the loop */
// buf->w = - u8g_font_GetGlyphBBXOffX(u8g->font, g);
buf
->
w
=
-
u8g
->
glyph_x
;
/* Also copy the position of the first glyph. This is the reference point of the string (negated) */
buf
->
x
=
u8g
->
glyph_x
;
buf
->
y
=
u8g
->
glyph_y
;
for
(;;)
{
/* calculated y position of the upper left corner (y_max) and lower left corner (y_min) of the string */
/* relative to the base line */
tmp
=
u8g
->
glyph_y
;
if
(
buf
->
y_min
>
tmp
)
buf
->
y_min
=
tmp
;
tmp
+=
u8g
->
glyph_height
;
if
(
buf
->
y_max
<
tmp
)
buf
->
y_max
=
tmp
;
/* check and stop if the end of the string is reached */
s
++
;
if
(
*
s
==
'\0'
)
break
;
/* if there are still more characters, add the delta to the next glyph */
buf
->
w
+=
u8g
->
glyph_dx
;
/* load the next glyph information */
u8g_GetGlyph
(
u8g
,
*
s
);
}
/* finally calculate the width of the last char */
/* if g was not updated in the for loop (strlen() == 1), then the initial offset x gets removed */
buf
->
w
+=
u8g
->
glyph_width
;
// buf->w += u8g_font_GetGlyphBBXOffX(u8g->font, g);
buf
->
w
+=
u8g
->
glyph_x
;
}
/* calculate minimal box */
void
u8g_font_box_min
(
u8g_t
*
u8g
,
const
char
*
s
,
u8g_str_size_t
*
buf
)
{
u8g_font_calc_str_min_box
(
u8g
,
s
,
buf
);
}
/* calculate gA box, but do not calculate the overall width */
void
u8g_font_box_left_gA
(
u8g_t
*
u8g
,
const
char
*
s
,
u8g_str_size_t
*
buf
)
{
}
/* calculate gA box, including overall width */
void
u8g_font_box_all_gA
(
u8g_t
*
u8g
,
const
char
*
s
,
u8g_str_size_t
*
buf
)
{
}
static
void
u8g_font_get_str_box_fill_args
(
u8g_t
*
u8g
,
const
char
*
s
,
u8g_str_size_t
*
buf
,
u8g_uint_t
*
x
,
u8g_uint_t
*
y
,
u8g_uint_t
*
width
,
u8g_uint_t
*
height
)
{
/*
u8g_glyph_t g;
g =
*/
u8g_GetGlyph
(
u8g
,
*
s
);
*
x
+=
u8g
->
glyph_x
;
*
width
=
buf
->
w
;
*
y
-=
buf
->
y_max
;
/* +1 because y_max is a height, this compensates the next step */
//*y += 1;
/* because the reference point is one below the string, this compensates the previous step */
//*y -= 1;
*
height
=
buf
->
y_max
;
*
height
-=
buf
->
y_min
;
}
void
u8g_GetStrMinBox
(
u8g_t
*
u8g
,
const
char
*
s
,
u8g_uint_t
*
x
,
u8g_uint_t
*
y
,
u8g_uint_t
*
width
,
u8g_uint_t
*
height
)
{
u8g_str_size_t
buf
;
if
(
*
s
==
'\0'
)
{
*
width
=
0
;
*
height
=
0
;
return
;
}
u8g_font_calc_str_min_box
(
u8g
,
s
,
&
buf
);
u8g_font_get_str_box_fill_args
(
u8g
,
s
,
&
buf
,
x
,
y
,
width
,
height
);
}
void
u8g_GetStrAMinBox
(
u8g_t
*
u8g
,
const
char
*
s
,
u8g_uint_t
*
x
,
u8g_uint_t
*
y
,
u8g_uint_t
*
width
,
u8g_uint_t
*
height
)
{
u8g_str_size_t
buf
;
uint8_t
cap_a
;
if
(
*
s
==
'\0'
)
{
*
width
=
0
;
*
height
=
0
;
return
;
}
cap_a
=
u8g_font_GetCapitalAHeight
(
u8g
->
font
);
u8g_font_calc_str_min_box
(
u8g
,
s
,
&
buf
);
if
(
buf
.
y_max
<
cap_a
)
buf
.
y_max
=
cap_a
;
u8g_font_get_str_box_fill_args
(
u8g
,
s
,
&
buf
,
x
,
y
,
width
,
height
);
}
void
u8g_SetFont
(
u8g_t
*
u8g
,
const
u8g_fntpgm_uint8_t
*
font
)
{
if
(
u8g
->
font
!=
font
)
{
u8g
->
font
=
font
;
u8g_UpdateRefHeight
(
u8g
);
u8g_SetFontPosBaseline
(
u8g
);
}
}
/*========================================================================*/
/* anti aliasing fonts */
int8_t
u8g_draw_aa_glyph
(
u8g_t
*
u8g
,
u8g_uint_t
x
,
u8g_uint_t
y
,
uint8_t
encoding
)
{
const
u8g_pgm_uint8_t
*
data
;
uint8_t
w
,
h
;
uint8_t
i
,
j
;
u8g_uint_t
ix
,
iy
;
{
u8g_glyph_t
g
=
u8g_GetGlyph
(
u8g
,
encoding
);
if
(
g
==
NULL
)
return
0
;
data
=
u8g_font_GetGlyphDataStart
(
u8g
->
font
,
g
);
}
w
=
u8g
->
glyph_width
;
h
=
u8g
->
glyph_height
;
x
+=
u8g
->
glyph_x
;
y
-=
u8g
->
glyph_y
;
y
--
;
if
(
u8g_IsBBXIntersection
(
u8g
,
x
,
y
-
h
+
1
,
w
,
h
)
==
0
)
return
u8g
->
glyph_dx
;
/* now, w is reused as bytes per line */
w
+=
3
;
w
/=
4
;
iy
=
y
;
iy
-=
h
;
iy
++
;
for
(
j
=
0
;
j
<
h
;
j
++
)
{
ix
=
x
;
for
(
i
=
0
;
i
<
w
;
i
++
)
{
u8g_Draw4TPixel
(
u8g
,
ix
,
iy
,
0
,
u8g_pgm_read
(
data
));
data
++
;
ix
+=
4
;
}
iy
++
;
}
return
u8g
->
glyph_dx
;
}
int8_t
u8g_DrawAAGlyph
(
u8g_t
*
u8g
,
u8g_uint_t
x
,
u8g_uint_t
y
,
uint8_t
encoding
)
{
y
+=
u8g
->
font_calc_vref
(
u8g
);
return
u8g_draw_aa_glyph
(
u8g
,
x
,
y
,
encoding
);
}
u8g_uint_t
u8g_DrawAAStr
(
u8g_t
*
u8g
,
u8g_uint_t
x
,
u8g_uint_t
y
,
const
char
*
s
)
{
u8g_uint_t
t
=
0
;
int8_t
d
;
if
(
u8g_font_GetFormat
(
u8g
->
font
)
!=
2
)
return
0
;
//u8g_uint_t u8g_GetStrWidth(u8g, s);
//u8g_font_GetFontAscent(u8g->font)-u8g_font_GetFontDescent(u8g->font);
y
+=
u8g
->
font_calc_vref
(
u8g
);
while
(
*
s
!=
'\0'
)
{
d
=
u8g_draw_aa_glyph
(
u8g
,
x
,
y
,
*
s
);
x
+=
d
;
t
+=
d
;
s
++
;
}
return
t
;
}
app/u8glib/u8g_font_data.c
deleted
100644 → 0
View file @
fd745e09
This source diff could not be displayed because it is too large. You can
view the blob
instead.
app/u8glib/u8g_line.c
deleted
100644 → 0
View file @
fd745e09
/*
u8g_line.c
Universal 8bit Graphics Library
Copyright (c) 2012, olikraus@gmail.com
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or other
materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "u8g.h"
void
u8g_DrawLine
(
u8g_t
*
u8g
,
u8g_uint_t
x1
,
u8g_uint_t
y1
,
u8g_uint_t
x2
,
u8g_uint_t
y2
)
{
u8g_uint_t
tmp
;
u8g_uint_t
x
,
y
;
u8g_uint_t
dx
,
dy
;
u8g_int_t
err
;
u8g_int_t
ystep
;
uint8_t
swapxy
=
0
;
/* no BBX intersection check at the moment, should be added... */
if
(
x1
>
x2
)
dx
=
x1
-
x2
;
else
dx
=
x2
-
x1
;
if
(
y1
>
y2
)
dy
=
y1
-
y2
;
else
dy
=
y2
-
y1
;
if
(
dy
>
dx
)
{
swapxy
=
1
;
tmp
=
dx
;
dx
=
dy
;
dy
=
tmp
;
tmp
=
x1
;
x1
=
y1
;
y1
=
tmp
;
tmp
=
x2
;
x2
=
y2
;
y2
=
tmp
;
}
if
(
x1
>
x2
)
{
tmp
=
x1
;
x1
=
x2
;
x2
=
tmp
;
tmp
=
y1
;
y1
=
y2
;
y2
=
tmp
;
}
err
=
dx
>>
1
;
if
(
y2
>
y1
)
ystep
=
1
;
else
ystep
=
-
1
;
y
=
y1
;
#ifndef U8G_16BIT
if
(
x2
==
255
)
x2
--
;
#else
if
(
x2
==
0xffff
)
x2
--
;
#endif
for
(
x
=
x1
;
x
<=
x2
;
x
++
)
{
if
(
swapxy
==
0
)
u8g_DrawPixel
(
u8g
,
x
,
y
);
else
u8g_DrawPixel
(
u8g
,
y
,
x
);
err
-=
(
uint8_t
)
dy
;
if
(
err
<
0
)
{
y
+=
(
u8g_uint_t
)
ystep
;
err
+=
(
u8g_uint_t
)
dx
;
}
}
}
app/u8glib/u8g_ll_api.c
deleted
100644 → 0
View file @
fd745e09
/*
u8g_ll_api.c
low level api
Universal 8bit Graphics Library
Copyright (c) 2011, olikraus@gmail.com
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or other
materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stddef.h>
#include "u8g.h"
uint8_t
u8g_call_dev_fn
(
u8g_t
*
u8g
,
u8g_dev_t
*
dev
,
uint8_t
msg
,
void
*
arg
)
{
return
dev
->
dev_fn
(
u8g
,
dev
,
msg
,
arg
);
}
/*====================================================================*/
uint8_t
u8g_InitLL
(
u8g_t
*
u8g
,
u8g_dev_t
*
dev
)
{
uint8_t
r
;
u8g
->
state_cb
(
U8G_STATE_MSG_BACKUP_ENV
);
r
=
u8g_call_dev_fn
(
u8g
,
dev
,
U8G_DEV_MSG_INIT
,
NULL
);
u8g
->
state_cb
(
U8G_STATE_MSG_BACKUP_U8G
);
u8g
->
state_cb
(
U8G_STATE_MSG_RESTORE_ENV
);
return
r
;
}
void
u8g_FirstPageLL
(
u8g_t
*
u8g
,
u8g_dev_t
*
dev
)
{
u8g
->
state_cb
(
U8G_STATE_MSG_BACKUP_ENV
);
u8g
->
state_cb
(
U8G_STATE_MSG_RESTORE_U8G
);
u8g_call_dev_fn
(
u8g
,
dev
,
U8G_DEV_MSG_PAGE_FIRST
,
NULL
);
u8g_call_dev_fn
(
u8g
,
dev
,
U8G_DEV_MSG_GET_PAGE_BOX
,
&
(
u8g
->
current_page
));
u8g
->
state_cb
(
U8G_STATE_MSG_RESTORE_ENV
);
}
uint8_t
u8g_NextPageLL
(
u8g_t
*
u8g
,
u8g_dev_t
*
dev
)
{
uint8_t
r
;
u8g
->
state_cb
(
U8G_STATE_MSG_BACKUP_ENV
);
u8g
->
state_cb
(
U8G_STATE_MSG_RESTORE_U8G
);
r
=
u8g_call_dev_fn
(
u8g
,
dev
,
U8G_DEV_MSG_PAGE_NEXT
,
NULL
);
if
(
r
!=
0
)
{
u8g_call_dev_fn
(
u8g
,
dev
,
U8G_DEV_MSG_GET_PAGE_BOX
,
&
(
u8g
->
current_page
));
}
u8g
->
state_cb
(
U8G_STATE_MSG_RESTORE_ENV
);
return
r
;
}
uint8_t
u8g_SetContrastLL
(
u8g_t
*
u8g
,
u8g_dev_t
*
dev
,
uint8_t
contrast
)
{
return
u8g_call_dev_fn
(
u8g
,
dev
,
U8G_DEV_MSG_CONTRAST
,
&
contrast
);
}
void
u8g_DrawPixelLL
(
u8g_t
*
u8g
,
u8g_dev_t
*
dev
,
u8g_uint_t
x
,
u8g_uint_t
y
)
{
u8g_dev_arg_pixel_t
*
arg
=
&
(
u8g
->
arg_pixel
);
arg
->
x
=
x
;
arg
->
y
=
y
;
u8g_call_dev_fn
(
u8g
,
dev
,
U8G_DEV_MSG_SET_PIXEL
,
arg
);
}
void
u8g_Draw8PixelLL
(
u8g_t
*
u8g
,
u8g_dev_t
*
dev
,
u8g_uint_t
x
,
u8g_uint_t
y
,
uint8_t
dir
,
uint8_t
pixel
)
{
u8g_dev_arg_pixel_t
*
arg
=
&
(
u8g
->
arg_pixel
);
arg
->
x
=
x
;
arg
->
y
=
y
;
arg
->
dir
=
dir
;
arg
->
pixel
=
pixel
;
u8g_call_dev_fn
(
u8g
,
dev
,
U8G_DEV_MSG_SET_8PIXEL
,
arg
);
}
void
u8g_Draw4TPixelLL
(
u8g_t
*
u8g
,
u8g_dev_t
*
dev
,
u8g_uint_t
x
,
u8g_uint_t
y
,
uint8_t
dir
,
uint8_t
pixel
)
{
u8g_dev_arg_pixel_t
*
arg
=
&
(
u8g
->
arg_pixel
);
arg
->
x
=
x
;
arg
->
y
=
y
;
arg
->
dir
=
dir
;
arg
->
pixel
=
pixel
;
u8g_call_dev_fn
(
u8g
,
dev
,
U8G_DEV_MSG_SET_4TPIXEL
,
arg
);
}
#ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
uint8_t
u8g_IsBBXIntersectionLL
(
u8g_t
*
u8g
,
u8g_dev_t
*
dev
,
u8g_uint_t
x
,
u8g_uint_t
y
,
u8g_uint_t
w
,
u8g_uint_t
h
)
{
return
u8g_call_dev_fn
(
u8g
,
dev
,
U8G_DEV_MSG_IS_BBX_INTERSECTION
,
&
arg
);
}
#endif
u8g_uint_t
u8g_GetWidthLL
(
u8g_t
*
u8g
,
u8g_dev_t
*
dev
)
{
u8g_uint_t
r
;
u8g_call_dev_fn
(
u8g
,
dev
,
U8G_DEV_MSG_GET_WIDTH
,
&
r
);
return
r
;
}
u8g_uint_t
u8g_GetHeightLL
(
u8g_t
*
u8g
,
u8g_dev_t
*
dev
)
{
u8g_uint_t
r
;
u8g_call_dev_fn
(
u8g
,
dev
,
U8G_DEV_MSG_GET_HEIGHT
,
&
r
);
return
r
;
}
u8g_uint_t
u8g_GetModeLL
(
u8g_t
*
u8g
,
u8g_dev_t
*
dev
)
{
return
u8g_call_dev_fn
(
u8g
,
dev
,
U8G_DEV_MSG_GET_MODE
,
NULL
);
}
/*====================================================================*/
void
u8g_UpdateDimension
(
u8g_t
*
u8g
)
{
u8g
->
width
=
u8g_GetWidthLL
(
u8g
,
u8g
->
dev
);
u8g
->
height
=
u8g_GetHeightLL
(
u8g
,
u8g
->
dev
);
u8g
->
mode
=
u8g_GetModeLL
(
u8g
,
u8g
->
dev
);
/* 9 Dec 2012: u8g_scale.c requires update of current page */
u8g_call_dev_fn
(
u8g
,
u8g
->
dev
,
U8G_DEV_MSG_GET_PAGE_BOX
,
&
(
u8g
->
current_page
));
}
static
void
u8g_init_data
(
u8g_t
*
u8g
)
{
u8g
->
font
=
NULL
;
u8g
->
cursor_font
=
NULL
;
u8g
->
cursor_bg_color
=
0
;
u8g
->
cursor_fg_color
=
1
;
u8g
->
cursor_encoding
=
34
;
u8g
->
cursor_fn
=
(
u8g_draw_cursor_fn
)
0
;
#if defined(U8G_WITH_PINLIST)
{
uint8_t
i
;
for
(
i
=
0
;
i
<
U8G_PIN_LIST_LEN
;
i
++
)
u8g
->
pin_list
[
i
]
=
U8G_PIN_NONE
;
}
#endif
u8g_SetColorIndex
(
u8g
,
1
);
u8g_SetFontPosBaseline
(
u8g
);
u8g
->
font_height_mode
=
U8G_FONT_HEIGHT_MODE_XTEXT
;
u8g
->
font_ref_ascent
=
0
;
u8g
->
font_ref_descent
=
0
;
u8g
->
font_line_spacing_factor
=
64
;
/* 64 = 1.0, 77 = 1.2 line spacing factor */
u8g
->
line_spacing
=
0
;
u8g
->
state_cb
=
u8g_state_dummy_cb
;
}
uint8_t
u8g_Begin
(
u8g_t
*
u8g
)
{
/* call and init low level driver and com device */
if
(
u8g_InitLL
(
u8g
,
u8g
->
dev
)
==
0
)
return
0
;
/* fetch width and height from the low level */
u8g_UpdateDimension
(
u8g
);
return
1
;
}
uint8_t
u8g_Init
(
u8g_t
*
u8g
,
u8g_dev_t
*
dev
)
{
u8g_init_data
(
u8g
);
u8g
->
dev
=
dev
;
/* On the Arduino Environment this will lead to two calls to u8g_Begin(), the following line will be called first (by U8glib constructors) */
/* if - in future releases - this is removed, then still call u8g_UpdateDimension() */
/* if Arduino call u8g_UpdateDimension else u8g_Begin */
/* issue 146 */
return
u8g_Begin
(
u8g
);
}
/* special init for pure ARM systems */
uint8_t
u8g_InitComFn
(
u8g_t
*
u8g
,
u8g_dev_t
*
dev
,
u8g_com_fnptr
com_fn
)
{
u8g_init_data
(
u8g
);
#if defined(U8G_WITH_PINLIST)
{
uint8_t
i
;
for
(
i
=
0
;
i
<
U8G_PIN_LIST_LEN
;
i
++
)
u8g
->
pin_list
[
i
]
=
U8G_PIN_DUMMY
;
}
#endif
u8g
->
dev
=
dev
;
/* replace the device procedure with a custom communication procedure */
u8g
->
dev
->
com_fn
=
com_fn
;
/* On the Arduino Environment this will lead to two calls to u8g_Begin(), the following line will be called first (by U8glib constructors) */
/* if - in future releases - this is removed, then still call u8g_UpdateDimension() */
/* if Arduino call u8g_UpdateDimension else u8g_Begin */
/* issue 146 */
return
u8g_Begin
(
u8g
);
}
#if defined(U8G_WITH_PINLIST)
uint8_t
u8g_InitSPI
(
u8g_t
*
u8g
,
u8g_dev_t
*
dev
,
uint8_t
sck
,
uint8_t
mosi
,
uint8_t
cs
,
uint8_t
a0
,
uint8_t
reset
)
{
/* fill data structure with some suitable values */
u8g_init_data
(
u8g
);
u8g
->
dev
=
dev
;
/* assign user pins */
u8g
->
pin_list
[
U8G_PI_SCK
]
=
sck
;
u8g
->
pin_list
[
U8G_PI_MOSI
]
=
mosi
;
u8g
->
pin_list
[
U8G_PI_CS
]
=
cs
;
u8g
->
pin_list
[
U8G_PI_A0
]
=
a0
;
u8g
->
pin_list
[
U8G_PI_RESET
]
=
reset
;
/* On the Arduino Environment this will lead to two calls to u8g_Begin(), the following line will be called first (by U8glib constructors) */
/* if - in future releases - this is removed, then still call u8g_UpdateDimension() */
/* if Arduino call u8g_UpdateDimension else u8g_Begin */
/* issue 146 */
return
u8g_Begin
(
u8g
);
}
uint8_t
u8g_InitHWSPI
(
u8g_t
*
u8g
,
u8g_dev_t
*
dev
,
uint8_t
cs
,
uint8_t
a0
,
uint8_t
reset
)
{
/* fill data structure with some suitable values */
u8g_init_data
(
u8g
);
u8g
->
dev
=
dev
;
/* assign user pins */
u8g
->
pin_list
[
U8G_PI_CS
]
=
cs
;
u8g
->
pin_list
[
U8G_PI_A0
]
=
a0
;
u8g
->
pin_list
[
U8G_PI_RESET
]
=
reset
;
return
u8g_Begin
(
u8g
);
}
uint8_t
u8g_InitI2C
(
u8g_t
*
u8g
,
u8g_dev_t
*
dev
,
uint8_t
options
)
{
/* fill data structure with some suitable values */
u8g_init_data
(
u8g
);
u8g
->
dev
=
dev
;
u8g
->
pin_list
[
U8G_PI_I2C_OPTION
]
=
options
;
return
u8g_Begin
(
u8g
);
}
uint8_t
u8g_Init8BitFixedPort
(
u8g_t
*
u8g
,
u8g_dev_t
*
dev
,
uint8_t
en
,
uint8_t
cs
,
uint8_t
di
,
uint8_t
rw
,
uint8_t
reset
)
{
/* fill data structure with some suitable values */
u8g_init_data
(
u8g
);
u8g
->
dev
=
dev
;
/* assign user pins */
u8g
->
pin_list
[
U8G_PI_EN
]
=
en
;
u8g
->
pin_list
[
U8G_PI_CS
]
=
cs
;
u8g
->
pin_list
[
U8G_PI_DI
]
=
di
;
u8g
->
pin_list
[
U8G_PI_RW
]
=
rw
;
u8g
->
pin_list
[
U8G_PI_RESET
]
=
reset
;
return
u8g_Begin
(
u8g
);
}
uint8_t
u8g_Init8Bit
(
u8g_t
*
u8g
,
u8g_dev_t
*
dev
,
uint8_t
d0
,
uint8_t
d1
,
uint8_t
d2
,
uint8_t
d3
,
uint8_t
d4
,
uint8_t
d5
,
uint8_t
d6
,
uint8_t
d7
,
uint8_t
en
,
uint8_t
cs1
,
uint8_t
cs2
,
uint8_t
di
,
uint8_t
rw
,
uint8_t
reset
)
{
/* fill data structure with some suitable values */
u8g_init_data
(
u8g
);
u8g
->
dev
=
dev
;
/* assign user pins */
u8g
->
pin_list
[
U8G_PI_D0
]
=
d0
;
u8g
->
pin_list
[
U8G_PI_D1
]
=
d1
;
u8g
->
pin_list
[
U8G_PI_D2
]
=
d2
;
u8g
->
pin_list
[
U8G_PI_D3
]
=
d3
;
u8g
->
pin_list
[
U8G_PI_D4
]
=
d4
;
u8g
->
pin_list
[
U8G_PI_D5
]
=
d5
;
u8g
->
pin_list
[
U8G_PI_D6
]
=
d6
;
u8g
->
pin_list
[
U8G_PI_D7
]
=
d7
;
u8g
->
pin_list
[
U8G_PI_EN
]
=
en
;
u8g
->
pin_list
[
U8G_PI_CS1
]
=
cs1
;
u8g
->
pin_list
[
U8G_PI_CS2
]
=
cs2
;
u8g
->
pin_list
[
U8G_PI_DI
]
=
di
;
u8g
->
pin_list
[
U8G_PI_RW
]
=
rw
;
u8g
->
pin_list
[
U8G_PI_RESET
]
=
reset
;
return
u8g_Begin
(
u8g
);
}
/*
PIN_D0 8
PIN_D1 9
PIN_D2 10
PIN_D3 11
PIN_D4 4
PIN_D5 5
PIN_D6 6
PIN_D7 7
PIN_CS 14
PIN_A0 15
PIN_RESET 16
PIN_WR 17
PIN_RD 18
u8g_InitRW8Bit(u8g, dev, d0, d1, d2, d3, d4, d5, d6, d7, cs, a0, wr, rd, reset)
u8g_InitRW8Bit(u8g, dev, 8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16)
*/
uint8_t
u8g_InitRW8Bit
(
u8g_t
*
u8g
,
u8g_dev_t
*
dev
,
uint8_t
d0
,
uint8_t
d1
,
uint8_t
d2
,
uint8_t
d3
,
uint8_t
d4
,
uint8_t
d5
,
uint8_t
d6
,
uint8_t
d7
,
uint8_t
cs
,
uint8_t
a0
,
uint8_t
wr
,
uint8_t
rd
,
uint8_t
reset
)
{
/* fill data structure with some suitable values */
u8g_init_data
(
u8g
);
u8g
->
dev
=
dev
;
/* assign user pins */
u8g
->
pin_list
[
U8G_PI_D0
]
=
d0
;
u8g
->
pin_list
[
U8G_PI_D1
]
=
d1
;
u8g
->
pin_list
[
U8G_PI_D2
]
=
d2
;
u8g
->
pin_list
[
U8G_PI_D3
]
=
d3
;
u8g
->
pin_list
[
U8G_PI_D4
]
=
d4
;
u8g
->
pin_list
[
U8G_PI_D5
]
=
d5
;
u8g
->
pin_list
[
U8G_PI_D6
]
=
d6
;
u8g
->
pin_list
[
U8G_PI_D7
]
=
d7
;
u8g
->
pin_list
[
U8G_PI_CS
]
=
cs
;
u8g
->
pin_list
[
U8G_PI_A0
]
=
a0
;
u8g
->
pin_list
[
U8G_PI_WR
]
=
wr
;
u8g
->
pin_list
[
U8G_PI_RD
]
=
rd
;
u8g
->
pin_list
[
U8G_PI_RESET
]
=
reset
;
return
u8g_Begin
(
u8g
);
}
#endif
/* defined(U8G_WITH_PINLIST) */
void
u8g_FirstPage
(
u8g_t
*
u8g
)
{
u8g_FirstPageLL
(
u8g
,
u8g
->
dev
);
}
uint8_t
u8g_NextPage
(
u8g_t
*
u8g
)
{
if
(
u8g
->
cursor_fn
!=
(
u8g_draw_cursor_fn
)
0
)
{
u8g
->
cursor_fn
(
u8g
);
}
return
u8g_NextPageLL
(
u8g
,
u8g
->
dev
);
}
uint8_t
u8g_SetContrast
(
u8g_t
*
u8g
,
uint8_t
contrast
)
{
return
u8g_SetContrastLL
(
u8g
,
u8g
->
dev
,
contrast
);
}
void
u8g_SleepOn
(
u8g_t
*
u8g
)
{
u8g_call_dev_fn
(
u8g
,
u8g
->
dev
,
U8G_DEV_MSG_SLEEP_ON
,
NULL
);
}
void
u8g_SleepOff
(
u8g_t
*
u8g
)
{
u8g_call_dev_fn
(
u8g
,
u8g
->
dev
,
U8G_DEV_MSG_SLEEP_OFF
,
NULL
);
}
void
u8g_DrawPixel
(
u8g_t
*
u8g
,
u8g_uint_t
x
,
u8g_uint_t
y
)
{
u8g_DrawPixelLL
(
u8g
,
u8g
->
dev
,
x
,
y
);
}
void
u8g_Draw8Pixel
(
u8g_t
*
u8g
,
u8g_uint_t
x
,
u8g_uint_t
y
,
uint8_t
dir
,
uint8_t
pixel
)
{
u8g_Draw8PixelLL
(
u8g
,
u8g
->
dev
,
x
,
y
,
dir
,
pixel
);
}
void
u8g_Draw4TPixel
(
u8g_t
*
u8g
,
u8g_uint_t
x
,
u8g_uint_t
y
,
uint8_t
dir
,
uint8_t
pixel
)
{
u8g_Draw4TPixelLL
(
u8g
,
u8g
->
dev
,
x
,
y
,
dir
,
pixel
);
}
void
u8g_Draw8ColorPixel
(
u8g_t
*
u8g
,
u8g_uint_t
x
,
u8g_uint_t
y
,
uint8_t
colpixel
)
{
u8g_dev_arg_pixel_t
*
arg
=
&
(
u8g
->
arg_pixel
);
arg
->
x
=
x
;
arg
->
y
=
y
;
arg
->
dir
=
0
;
arg
->
pixel
=
0x80
;
arg
->
color
=
colpixel
;
u8g_call_dev_fn
(
u8g
,
u8g
->
dev
,
U8G_DEV_MSG_SET_8PIXEL
,
arg
);
}
/* u8g_IsBBXIntersection() has been moved to u8g_clip.c */
#ifdef OBSOLETE_CODE
uint8_t
u8g_IsBBXIntersection
(
u8g_t
*
u8g
,
u8g_uint_t
x
,
u8g_uint_t
y
,
u8g_uint_t
w
,
u8g_uint_t
h
)
{
/* new code */
u8g_dev_arg_bbx_t
arg
;
arg
.
x
=
x
;
arg
.
y
=
y
;
arg
.
w
=
w
;
arg
.
h
=
h
;
return
u8g_is_box_bbx_intersection
(
&
(
u8g
->
current_page
),
&
arg
);
/* old code */
//return u8g_IsBBXIntersectionLL(u8g, u8g->dev, x, y, w, h);
}
#endif
/*
idx: index for the palette entry (0..255)
r: value for red (0..255)
g: value for green (0..255)
b: value for blue (0..255)
*/
void
u8g_SetColorEntry
(
u8g_t
*
u8g
,
uint8_t
idx
,
uint8_t
r
,
uint8_t
g
,
uint8_t
b
)
{
u8g_dev_arg_irgb_t
irgb
;
irgb
.
idx
=
idx
;
irgb
.
r
=
r
;
irgb
.
g
=
g
;
irgb
.
b
=
b
;
u8g_call_dev_fn
(
u8g
,
u8g
->
dev
,
U8G_DEV_MSG_SET_COLOR_ENTRY
,
&
irgb
);
}
void
u8g_SetColorIndex
(
u8g_t
*
u8g
,
uint8_t
idx
)
{
u8g
->
arg_pixel
.
color
=
idx
;
/*u8g->color_index = idx; */
/* must be removed */
}
void
u8g_SetHiColor
(
u8g_t
*
u8g
,
uint16_t
rgb
)
{
u8g
->
arg_pixel
.
color
=
rgb
&
255
;
u8g
->
arg_pixel
.
hi_color
=
rgb
>>
8
;
/*u8g->color_index = idx; */
/* must be removed */
}
void
u8g_SetHiColorByRGB
(
u8g_t
*
u8g
,
uint8_t
r
,
uint8_t
g
,
uint8_t
b
)
{
r
&=
~
7
;
g
>>=
2
;
b
>>=
3
;
u8g
->
arg_pixel
.
color
=
b
;
u8g
->
arg_pixel
.
color
|=
(
g
&
7
)
<<
5
;
u8g
->
arg_pixel
.
hi_color
=
r
;
u8g
->
arg_pixel
.
hi_color
|=
(
g
>>
3
)
&
7
;
//u8g_SetHiColor(u8g, U8G_GET_HICOLOR_BY_RGB(r,g,b));
}
void
u8g_SetRGB
(
u8g_t
*
u8g
,
uint8_t
r
,
uint8_t
g
,
uint8_t
b
)
{
if
(
u8g
->
mode
==
U8G_MODE_R3G3B2
)
{
r
&=
0x0e0
;
g
&=
0x0e0
;
g
>>=
3
;
b
>>=
6
;
u8g
->
arg_pixel
.
color
=
r
|
g
|
b
;
}
else
if
(
u8g
->
mode
==
U8G_MODE_HICOLOR
)
{
u8g_SetHiColorByRGB
(
u8g
,
r
,
g
,
b
);
}
else
{
u8g
->
arg_pixel
.
color
=
r
;
u8g
->
arg_pixel
.
hi_color
=
g
;
u8g
->
arg_pixel
.
blue
=
b
;
}
}
uint8_t
u8g_GetColorIndex
(
u8g_t
*
u8g
)
{
return
u8g
->
arg_pixel
.
color
;
}
uint8_t
u8g_GetDefaultForegroundColor
(
u8g_t
*
u8g
)
{
uint8_t
mode
;
mode
=
u8g_GetMode
(
u8g
);
if
(
mode
==
U8G_MODE_R3G3B2
)
return
255
;
/* white */
else
if
(
u8g_GetMode
(
u8g
)
==
U8G_MODE_GRAY2BIT
)
return
3
;
/* max intensity */
/* if ( u8g.getMode() == U8G_MODE_BW ) */
return
1
;
/* pixel on */
}
void
u8g_SetDefaultForegroundColor
(
u8g_t
*
u8g
)
{
if
(
u8g
->
mode
==
U8G_MODE_HICOLOR
)
{
u8g
->
arg_pixel
.
color
=
0x0ff
;
u8g
->
arg_pixel
.
hi_color
=
0x0ff
;
}
else
{
u8g_SetColorIndex
(
u8g
,
u8g_GetDefaultForegroundColor
(
u8g
));
}
}
uint8_t
u8g_GetDefaultBackgroundColor
(
u8g_t
*
u8g
)
{
return
0
;
}
void
u8g_SetDefaultBackgroundColor
(
u8g_t
*
u8g
)
{
u8g_SetColorIndex
(
u8g
,
u8g_GetDefaultBackgroundColor
(
u8g
));
/* pixel on / black */
}
uint8_t
u8g_GetDefaultMidColor
(
u8g_t
*
u8g
)
{
uint8_t
mode
;
mode
=
u8g_GetMode
(
u8g
);
if
(
mode
==
U8G_MODE_R3G3B2
)
return
0x06d
;
/* gray: 01101101 */
else
if
(
mode
==
U8G_MODE_GRAY2BIT
)
return
1
;
/* low mid intensity */
/* if ( u8g.getMode() == U8G_MODE_BW ) */
return
1
;
/* pixel on */
}
void
u8g_SetDefaultMidColor
(
u8g_t
*
u8g
)
{
u8g_SetColorIndex
(
u8g
,
u8g_GetDefaultMidColor
(
u8g
));
}
app/u8glib/u8g_page.c
deleted
100644 → 0
View file @
fd745e09
/*
u8g_page.c
page helper functions, only called by the dev handler.
Universal 8bit Graphics Library
Copyright (c) 2011, olikraus@gmail.com
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or other
materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "u8g.h"
/*
setup page count structure
conditions: page_height <= total_height
*/
void
u8g_page_Init
(
u8g_page_t
*
p
,
u8g_uint_t
page_height
,
u8g_uint_t
total_height
)
{
p
->
page_height
=
page_height
;
p
->
total_height
=
total_height
;
p
->
page
=
0
;
u8g_page_First
(
p
);
}
void
u8g_page_First
(
u8g_page_t
*
p
)
{
p
->
page_y0
=
0
;
p
->
page_y1
=
p
->
page_height
;
p
->
page_y1
--
;
p
->
page
=
0
;
}
uint8_t
u8g_page_Next
(
u8g_page_t
*
p
)
{
register
u8g_uint_t
y1
;
p
->
page_y0
+=
p
->
page_height
;
if
(
p
->
page_y0
>=
p
->
total_height
)
return
0
;
p
->
page
++
;
y1
=
p
->
page_y1
;
y1
+=
p
->
page_height
;
if
(
y1
>=
p
->
total_height
)
{
y1
=
p
->
total_height
;
y1
--
;
}
p
->
page_y1
=
y1
;
return
1
;
}
app/u8glib/u8g_pb.c
deleted
100644 → 0
View file @
fd745e09
/*
u8g_pb.c
common procedures for the page buffer
Universal 8bit Graphics Library
Copyright (c) 2011, olikraus@gmail.com
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or other
materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "u8g.h"
void
u8g_pb_Clear
(
u8g_pb_t
*
b
)
{
uint8_t
*
ptr
=
(
uint8_t
*
)
b
->
buf
;
uint8_t
*
end_ptr
=
ptr
;
end_ptr
+=
b
->
width
;
do
{
*
ptr
++
=
0
;
}
while
(
ptr
!=
end_ptr
);
}
/* the following procedure does not work. why? Can be checked with descpic */
/*
void u8g_pb_Clear(u8g_pb_t *b)
{
uint8_t *ptr = (uint8_t *)b->buf;
uint8_t cnt = b->width;
do
{
*ptr++ = 0;
cnt--;
} while( cnt != 0 );
}
*/
/*
intersection assumptions:
a1 <= a2 is always true
*/
/*
minimized version
---1----0 1 b1 <= a2 && b1 > b2
-----1--0 1 b2 >= a1 && b1 > b2
---1-1--- 1 b1 <= a2 && b2 >= a1
*/
/*
uint8_t u8g_pb8v1_IsYIntersection___Old(u8g_pb_t *b, u8g_uint_t v0, u8g_uint_t v1)
{
uint8_t c0, c1, c;
c0 = v0 <= b->p.page_y1;
c1 = v1 >= b->p.page_y0;
c = v0 > v1;
if ( c0 && c1 ) return 1;
if ( c0 && c ) return 1;
if ( c1 && c ) return 1;
return 0;
}
*/
uint8_t
u8g_pb_IsYIntersection
(
u8g_pb_t
*
pb
,
u8g_uint_t
v0
,
u8g_uint_t
v1
)
{
uint8_t
c1
,
c2
,
c3
,
tmp
;
c1
=
v0
<=
pb
->
p
.
page_y1
;
c2
=
v1
>=
pb
->
p
.
page_y0
;
c3
=
v0
>
v1
;
/*
if ( c1 && c2 )
return 1;
if ( c1 && c3 )
return 1;
if ( c2 && c3 )
return 1;
return 0;
*/
tmp
=
c1
;
c1
&=
c2
;
c2
&=
c3
;
c3
&=
tmp
;
c1
|=
c2
;
c1
|=
c3
;
return
c1
&
1
;
}
uint8_t
u8g_pb_IsXIntersection
(
u8g_pb_t
*
b
,
u8g_uint_t
v0
,
u8g_uint_t
v1
)
{
uint8_t
/*c0, c1, */
c2
,
c3
;
/*
conditions: b->p.page_y0 < b->p.page_y1
there are no restriction on v0 and v1. If v0 > v1, then warp around unsigned is assumed
*/
/*
c0 = v0 < 0;
c1 = v1 < 0;
*/
c2
=
v0
>
b
->
width
;
c3
=
v1
>
b
->
width
;
/*if ( c0 && c1 ) return 0;*/
if
(
c2
&&
c3
)
return
0
;
/*if ( c1 && c2 ) return 0;*/
return
1
;
}
uint8_t
u8g_pb_IsIntersection
(
u8g_pb_t
*
pb
,
u8g_dev_arg_bbx_t
*
bbx
)
{
u8g_uint_t
tmp
;
tmp
=
bbx
->
y
;
tmp
+=
bbx
->
h
;
tmp
--
;
if
(
u8g_pb_IsYIntersection
(
pb
,
bbx
->
y
,
tmp
)
==
0
)
return
0
;
/* maybe this one can be skiped... probability is very high to have an intersection, so it would be ok to always return 1 */
tmp
=
bbx
->
x
;
tmp
+=
bbx
->
w
;
tmp
--
;
return
u8g_pb_IsXIntersection
(
pb
,
bbx
->
x
,
tmp
);
}
void
u8g_pb_GetPageBox
(
u8g_pb_t
*
pb
,
u8g_box_t
*
box
)
{
box
->
x0
=
0
;
box
->
y0
=
pb
->
p
.
page_y0
;
box
->
x1
=
pb
->
width
;
box
->
x1
--
;
box
->
y1
=
pb
->
p
.
page_y1
;
}
uint8_t
u8g_pb_Is8PixelVisible
(
u8g_pb_t
*
b
,
u8g_dev_arg_pixel_t
*
arg_pixel
)
{
u8g_uint_t
v0
,
v1
;
v0
=
arg_pixel
->
y
;
v1
=
v0
;
switch
(
arg_pixel
->
dir
)
{
case
0
:
break
;
case
1
:
v1
+=
8
;
/* this is independent from the page height */
break
;
case
2
:
break
;
case
3
:
v0
-=
8
;
break
;
}
return
u8g_pb_IsYIntersection
(
b
,
v0
,
v1
);
}
uint8_t
u8g_pb_WriteBuffer
(
u8g_pb_t
*
b
,
u8g_t
*
u8g
,
u8g_dev_t
*
dev
)
{
return
u8g_WriteSequence
(
u8g
,
dev
,
b
->
width
,
b
->
buf
);
}
app/u8glib/u8g_pb14v1.c
deleted
100644 → 0
View file @
fd745e09
/*
u8g_pb14v1.c
14bit height monochrom (1 bit) page buffer,
byte has vertical orientation, 7 bits per byte
Universal 8bit Graphics Library
Copyright (c) 2011, olikraus@gmail.com
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or other
materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "u8g.h"
#include <string.h>
void
u8g_pb14v1_Init
(
u8g_pb_t
*
b
,
void
*
buf
,
u8g_uint_t
width
)
U8G_NOINLINE
;
void
u8g_pb14v1_set_pixel
(
u8g_pb_t
*
b
,
u8g_uint_t
x
,
u8g_uint_t
y
,
uint8_t
color_index
)
U8G_NOINLINE
;
void
u8g_pb14v1_SetPixel
(
u8g_pb_t
*
b
,
const
u8g_dev_arg_pixel_t
*
const
arg_pixel
)
U8G_NOINLINE
;
void
u8g_pb14v1_Set8PixelStd
(
u8g_pb_t
*
b
,
u8g_dev_arg_pixel_t
*
arg_pixel
)
U8G_NOINLINE
;
void
u8g_pb14v1_Clear
(
u8g_pb_t
*
b
)
{
uint8_t
*
ptr
=
(
uint8_t
*
)
b
->
buf
;
uint8_t
*
end_ptr
=
ptr
;
end_ptr
+=
b
->
width
*
2
;
do
{
*
ptr
++
=
0
;
}
while
(
ptr
!=
end_ptr
);
}
/* Obsolete, usually set by the init of the structure */
void
u8g_pb14v1_Init
(
u8g_pb_t
*
b
,
void
*
buf
,
u8g_uint_t
width
)
{
b
->
buf
=
buf
;
b
->
width
=
width
;
u8g_pb14v1_Clear
(
b
);
}
void
u8g_pb14v1_set_pixel
(
u8g_pb_t
*
b
,
u8g_uint_t
x
,
u8g_uint_t
y
,
uint8_t
color_index
)
{
register
uint8_t
mask
;
uint8_t
*
ptr
=
b
->
buf
;
y
-=
b
->
p
.
page_y0
;
if
(
y
>=
7
)
{
ptr
+=
b
->
width
;
y
-=
7
;
}
mask
=
1
;
mask
<<=
y
;
ptr
+=
x
;
if
(
color_index
)
{
*
ptr
|=
mask
;
}
else
{
mask
^=
0xff
;
*
ptr
&=
mask
;
}
}
void
u8g_pb14v1_SetPixel
(
u8g_pb_t
*
b
,
const
u8g_dev_arg_pixel_t
*
const
arg_pixel
)
{
if
(
arg_pixel
->
y
<
b
->
p
.
page_y0
)
return
;
if
(
arg_pixel
->
y
>
b
->
p
.
page_y1
)
return
;
if
(
arg_pixel
->
x
>=
b
->
width
)
return
;
u8g_pb14v1_set_pixel
(
b
,
arg_pixel
->
x
,
arg_pixel
->
y
,
arg_pixel
->
color
);
}
void
u8g_pb14v1_Set8PixelStd
(
u8g_pb_t
*
b
,
u8g_dev_arg_pixel_t
*
arg_pixel
)
{
register
uint8_t
pixel
=
arg_pixel
->
pixel
;
do
{
if
(
pixel
&
128
)
{
u8g_pb14v1_SetPixel
(
b
,
arg_pixel
);
}
switch
(
arg_pixel
->
dir
)
{
case
0
:
arg_pixel
->
x
++
;
break
;
case
1
:
arg_pixel
->
y
++
;
break
;
case
2
:
arg_pixel
->
x
--
;
break
;
case
3
:
arg_pixel
->
y
--
;
break
;
}
pixel
<<=
1
;
}
while
(
pixel
!=
0
);
}
void
u8g_pb14v1_Set8PixelOpt2
(
u8g_pb_t
*
b
,
u8g_dev_arg_pixel_t
*
arg_pixel
)
{
register
uint8_t
pixel
=
arg_pixel
->
pixel
;
u8g_uint_t
dx
=
0
;
u8g_uint_t
dy
=
0
;
switch
(
arg_pixel
->
dir
)
{
case
0
:
dx
++
;
break
;
case
1
:
dy
++
;
break
;
case
2
:
dx
--
;
break
;
case
3
:
dy
--
;
break
;
}
do
{
if
(
pixel
&
128
)
u8g_pb14v1_SetPixel
(
b
,
arg_pixel
);
arg_pixel
->
x
+=
dx
;
arg_pixel
->
y
+=
dy
;
pixel
<<=
1
;
}
while
(
pixel
!=
0
);
}
uint8_t
u8g_dev_pb14v1_base_fn
(
u8g_t
*
u8g
,
u8g_dev_t
*
dev
,
uint8_t
msg
,
void
*
arg
)
{
u8g_pb_t
*
pb
=
(
u8g_pb_t
*
)(
dev
->
dev_mem
);
switch
(
msg
)
{
case
U8G_DEV_MSG_SET_8PIXEL
:
if
(
u8g_pb_Is8PixelVisible
(
pb
,
(
u8g_dev_arg_pixel_t
*
)
arg
)
)
u8g_pb14v1_Set8PixelOpt2
(
pb
,
(
u8g_dev_arg_pixel_t
*
)
arg
);
break
;
case
U8G_DEV_MSG_SET_PIXEL
:
u8g_pb14v1_SetPixel
(
pb
,
(
u8g_dev_arg_pixel_t
*
)
arg
);
break
;
case
U8G_DEV_MSG_INIT
:
break
;
case
U8G_DEV_MSG_STOP
:
break
;
case
U8G_DEV_MSG_PAGE_FIRST
:
u8g_pb14v1_Clear
(
pb
);
u8g_page_First
(
&
(
pb
->
p
));
break
;
case
U8G_DEV_MSG_PAGE_NEXT
:
if
(
u8g_page_Next
(
&
(
pb
->
p
))
==
0
)
return
0
;
u8g_pb14v1_Clear
(
pb
);
break
;
#ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
case
U8G_DEV_MSG_IS_BBX_INTERSECTION
:
return
u8g_pb_IsIntersection
(
pb
,
(
u8g_dev_arg_bbx_t
*
)
arg
);
#endif
case
U8G_DEV_MSG_GET_PAGE_BOX
:
u8g_pb_GetPageBox
(
pb
,
(
u8g_box_t
*
)
arg
);
break
;
case
U8G_DEV_MSG_GET_WIDTH
:
*
((
u8g_uint_t
*
)
arg
)
=
pb
->
width
;
break
;
case
U8G_DEV_MSG_GET_HEIGHT
:
*
((
u8g_uint_t
*
)
arg
)
=
pb
->
p
.
total_height
;
break
;
case
U8G_DEV_MSG_SET_COLOR_ENTRY
:
break
;
case
U8G_DEV_MSG_SET_XY_CB
:
break
;
case
U8G_DEV_MSG_GET_MODE
:
return
U8G_MODE_BW
;
}
return
1
;
}
app/u8glib/u8g_pb16h1.c
deleted
100644 → 0
View file @
fd745e09
/*
u8g_pb16h1.c
2x 8bit height monochrom (1 bit) page buffer
byte has horizontal orientation
Universal 8bit Graphics Library
Copyright (c) 2012, olikraus@gmail.com
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or other
materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
total buffer size is limited to 2*256 bytes because of the calculation inside the set pixel procedure
*/
#include "u8g.h"
#include <string.h>
void
u8g_pb16h1_Init
(
u8g_pb_t
*
b
,
void
*
buf
,
u8g_uint_t
width
)
U8G_NOINLINE
;
void
u8g_pb16h1_set_pixel
(
u8g_pb_t
*
b
,
u8g_uint_t
x
,
u8g_uint_t
y
,
uint8_t
color_index
)
U8G_NOINLINE
;
void
u8g_pb16h1_SetPixel
(
u8g_pb_t
*
b
,
const
u8g_dev_arg_pixel_t
*
const
arg_pixel
)
U8G_NOINLINE
;
void
u8g_pb16h1_Set8PixelStd
(
u8g_pb_t
*
b
,
u8g_dev_arg_pixel_t
*
arg_pixel
)
U8G_NOINLINE
;
uint8_t
u8g_dev_pb8h1_base_fn
(
u8g_t
*
u8g
,
u8g_dev_t
*
dev
,
uint8_t
msg
,
void
*
arg
);
void
u8g_pb16h1_Clear
(
u8g_pb_t
*
b
)
{
uint8_t
*
ptr
=
(
uint8_t
*
)
b
->
buf
;
uint8_t
*
end_ptr
=
ptr
;
end_ptr
+=
b
->
width
*
2
;
do
{
*
ptr
++
=
0
;
}
while
(
ptr
!=
end_ptr
);
}
void
u8g_pb16h1_Init
(
u8g_pb_t
*
b
,
void
*
buf
,
u8g_uint_t
width
)
{
b
->
buf
=
buf
;
b
->
width
=
width
;
u8g_pb16h1_Clear
(
b
);
}
/* limitation: total buffer must not exceed 2*256 bytes */
void
u8g_pb16h1_set_pixel
(
u8g_pb_t
*
b
,
u8g_uint_t
x
,
u8g_uint_t
y
,
uint8_t
color_index
)
{
register
uint8_t
mask
;
u8g_uint_t
tmp
;
uint8_t
*
ptr
=
b
->
buf
;
y
-=
b
->
p
.
page_y0
;
if
(
y
>=
8
)
{
ptr
+=
b
->
width
;
y
&=
0x07
;
}
tmp
=
b
->
width
;
tmp
>>=
3
;
tmp
*=
(
uint8_t
)
y
;
ptr
+=
tmp
;
mask
=
0x080
;
mask
>>=
x
&
7
;
x
>>=
3
;
ptr
+=
x
;
if
(
color_index
)
{
*
ptr
|=
mask
;
}
else
{
mask
^=
0xff
;
*
ptr
&=
mask
;
}
}
void
u8g_pb16h1_SetPixel
(
u8g_pb_t
*
b
,
const
u8g_dev_arg_pixel_t
*
const
arg_pixel
)
{
if
(
arg_pixel
->
y
<
b
->
p
.
page_y0
)
return
;
if
(
arg_pixel
->
y
>
b
->
p
.
page_y1
)
return
;
if
(
arg_pixel
->
x
>=
b
->
width
)
return
;
u8g_pb16h1_set_pixel
(
b
,
arg_pixel
->
x
,
arg_pixel
->
y
,
arg_pixel
->
color
);
}
void
u8g_pb16h1_Set8PixelStd
(
u8g_pb_t
*
b
,
u8g_dev_arg_pixel_t
*
arg_pixel
)
{
register
uint8_t
pixel
=
arg_pixel
->
pixel
;
do
{
if
(
pixel
&
128
)
{
u8g_pb16h1_SetPixel
(
b
,
arg_pixel
);
}
switch
(
arg_pixel
->
dir
)
{
case
0
:
arg_pixel
->
x
++
;
break
;
case
1
:
arg_pixel
->
y
++
;
break
;
case
2
:
arg_pixel
->
x
--
;
break
;
case
3
:
arg_pixel
->
y
--
;
break
;
}
pixel
<<=
1
;
}
while
(
pixel
!=
0
);
}
void
u8g_pb16h1_Set8PixelOpt2
(
u8g_pb_t
*
b
,
u8g_dev_arg_pixel_t
*
arg_pixel
)
{
register
uint8_t
pixel
=
arg_pixel
->
pixel
;
u8g_uint_t
dx
=
0
;
u8g_uint_t
dy
=
0
;
switch
(
arg_pixel
->
dir
)
{
case
0
:
dx
++
;
break
;
case
1
:
dy
++
;
break
;
case
2
:
dx
--
;
break
;
case
3
:
dy
--
;
break
;
}
do
{
if
(
pixel
&
128
)
u8g_pb16h1_SetPixel
(
b
,
arg_pixel
);
arg_pixel
->
x
+=
dx
;
arg_pixel
->
y
+=
dy
;
pixel
<<=
1
;
}
while
(
pixel
!=
0
);
}
uint8_t
u8g_dev_pb16h1_base_fn
(
u8g_t
*
u8g
,
u8g_dev_t
*
dev
,
uint8_t
msg
,
void
*
arg
)
{
u8g_pb_t
*
pb
=
(
u8g_pb_t
*
)(
dev
->
dev_mem
);
switch
(
msg
)
{
case
U8G_DEV_MSG_SET_8PIXEL
:
if
(
u8g_pb_Is8PixelVisible
(
pb
,
(
u8g_dev_arg_pixel_t
*
)
arg
)
)
u8g_pb16h1_Set8PixelOpt2
(
pb
,
(
u8g_dev_arg_pixel_t
*
)
arg
);
break
;
case
U8G_DEV_MSG_SET_PIXEL
:
u8g_pb16h1_SetPixel
(
pb
,
(
u8g_dev_arg_pixel_t
*
)
arg
);
break
;
case
U8G_DEV_MSG_INIT
:
break
;
case
U8G_DEV_MSG_STOP
:
break
;
case
U8G_DEV_MSG_PAGE_FIRST
:
u8g_pb16h1_Clear
(
pb
);
u8g_page_First
(
&
(
pb
->
p
));
break
;
case
U8G_DEV_MSG_PAGE_NEXT
:
if
(
u8g_page_Next
(
&
(
pb
->
p
))
==
0
)
return
0
;
u8g_pb16h1_Clear
(
pb
);
break
;
#ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
case
U8G_DEV_MSG_IS_BBX_INTERSECTION
:
return
u8g_pb_IsIntersection
(
pb
,
(
u8g_dev_arg_bbx_t
*
)
arg
);
#endif
case
U8G_DEV_MSG_GET_PAGE_BOX
:
u8g_pb_GetPageBox
(
pb
,
(
u8g_box_t
*
)
arg
);
break
;
case
U8G_DEV_MSG_GET_WIDTH
:
*
((
u8g_uint_t
*
)
arg
)
=
pb
->
width
;
break
;
case
U8G_DEV_MSG_GET_HEIGHT
:
*
((
u8g_uint_t
*
)
arg
)
=
pb
->
p
.
total_height
;
break
;
case
U8G_DEV_MSG_SET_COLOR_ENTRY
:
break
;
case
U8G_DEV_MSG_SET_XY_CB
:
break
;
case
U8G_DEV_MSG_GET_MODE
:
return
U8G_MODE_BW
;
}
return
1
;
}
Prev
1
2
3
4
5
6
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