Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LC7981 LCD 192X112 graph. #512

Open
wants to merge 126 commits into
base: revert-347-master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
126 commits
Select commit Hold shift + click to select a range
44f5e0a
Merge pull request #349 from olikraus/revert-347-master
olikraus Jul 4, 2015
277fbf9
readme update
olikraus Jul 4, 2015
70a6dd0
readme update
olikraus Jul 4, 2015
8bd07a2
readme update
olikraus Jul 4, 2015
42d4070
readme update
olikraus Jul 4, 2015
a72374b
readme update
olikraus Jul 4, 2015
a1bbd7c
issue 339
olikraus Jul 11, 2015
78e4e07
issue 326 (contrast setting)
olikraus Jul 11, 2015
7a7ecf2
ssd1306 64x48 support, new arduino lib format
olikraus Jul 12, 2015
f8e63a2
constructor updates for examples
olikraus Jul 12, 2015
cfc1195
link update
olikraus Jul 12, 2015
a9a7589
added INPUT_PULLUP, github issue #309
olikraus Jul 12, 2015
add401a
v1.18
olikraus Jul 14, 2015
df8b99b
v1.18.1
olikraus Jul 14, 2015
b37543e
lib manager
olikraus Jul 15, 2015
554c97c
github
olikraus Jul 15, 2015
6c133d3
change log
olikraus Aug 1, 2015
da22af6
ESP8266 header file fixes
olikraus Aug 1, 2015
a288d84
added 165 makefile
olikraus Aug 9, 2015
4143d9f
Merge branch 'master' of https://github.com/olikraus/u8glib
olikraus Aug 9, 2015
2259804
PSoC 5 support
christof65 Aug 11, 2015
0649138
Merge pull request #359 from christof65/master
olikraus Aug 12, 2015
036cd76
u8g2
olikraus Sep 1, 2015
49272be
gpio msg
olikraus Sep 2, 2015
149abdf
gpio init
olikraus Sep 2, 2015
a8716b0
gpio init
olikraus Sep 2, 2015
d82eab9
Merge branch 'master' of https://github.com/olikraus/u8glib
olikraus Sep 2, 2015
2b9c75c
msg simplification
olikraus Sep 2, 2015
49263d7
msg simplification
olikraus Sep 2, 2015
b1a8933
u8g2
olikraus Sep 12, 2015
7d0b86e
u8g2
olikraus Sep 12, 2015
8a71c78
u8g2
olikraus Sep 12, 2015
01e7ca2
u8g2
olikraus Sep 12, 2015
bf8865f
simplified cmd sequence
olikraus Sep 12, 2015
ba40863
simplified cmd sequence
olikraus Sep 12, 2015
1f491bf
simplified cmd sequence
olikraus Sep 12, 2015
f05765b
u8g2 optimization
olikraus Sep 12, 2015
549e460
u8g2 optimization
olikraus Sep 13, 2015
47b593c
ssd1306 for u8g2
olikraus Sep 14, 2015
39faa04
ssd1306
olikraus Sep 17, 2015
f330480
flip mode
olikraus Sep 19, 2015
7baf8ba
set contrast
olikraus Sep 20, 2015
f331500
spi cleanup
olikraus Sep 20, 2015
394ca02
sdl example
olikraus Sep 27, 2015
0d7ba3b
started hi level api
olikraus Oct 4, 2015
6b215ea
hi level interface
olikraus Oct 4, 2015
d0a110c
added first xmega support;
flo90 Oct 4, 2015
2852b64
added missing preprocessor statement;
flo90 Oct 4, 2015
0649b44
Merge pull request #364 from flo90/master
olikraus Oct 5, 2015
6f3a2b4
l90 cb struct
olikraus Oct 7, 2015
2e6a7d2
rename: u8g2 -> u8x8
olikraus Oct 10, 2015
4e206e7
rename
olikraus Oct 10, 2015
5eeb9f1
u8x8 renameing, optimized dogs102 loop
olikraus Oct 10, 2015
7974c43
LC7981 update
olikraus Oct 11, 2015
be0e6c0
u8g2 renaming
olikraus Oct 11, 2015
00fc6d3
u8g2x --> u8g2
olikraus Oct 11, 2015
3a37d2c
u8g2 / u8x8
olikraus Oct 14, 2015
201742c
sw architecture
olikraus Oct 17, 2015
995ebdb
u8g2 api
olikraus Oct 17, 2015
a0d3360
hvline clipping
olikraus Oct 17, 2015
c38465d
clipping
olikraus Oct 18, 2015
55b7479
more clipping
olikraus Oct 18, 2015
4aaa367
handling of more clipping cases
olikraus Oct 18, 2015
35b0aef
handling of more clipping cases
olikraus Oct 18, 2015
ebe7d18
Add support for Linux i2c-dev based devices
daniel-thompson Oct 20, 2015
c729213
Examples for the recently added i2c-dev driver
daniel-thompson Oct 20, 2015
5d94e38
Fix calls to u8g_DrawStr() (remove fourth argument)
daniel-thompson Oct 20, 2015
a7209c1
Increase the fonts compiled and linked.
daniel-thompson Oct 20, 2015
a2ab395
Merge pull request #368 from daniel-thompson/dev/linux-i2c-dev
olikraus Oct 20, 2015
991a8ab
l90
olikraus Oct 20, 2015
97ce164
include callback to hvline
olikraus Oct 21, 2015
31fe1a1
Merge branch 'master' of https://github.com/olikraus/u8glib
olikraus Oct 21, 2015
5a2e6d5
font preparation / cb call
olikraus Oct 21, 2015
5539f03
u8g2 font
olikraus Oct 21, 2015
2d1410e
text draw
olikraus Oct 24, 2015
3cc1e2f
buffer handling
olikraus Oct 24, 2015
aa9662f
added picture loop
olikraus Oct 24, 2015
91b966f
intersection (part 1)
olikraus Oct 25, 2015
5ca9e4c
180 degree rotation
olikraus Oct 25, 2015
e924452
optimized clipping
olikraus Oct 25, 2015
7a04c77
clip optimization
olikraus Oct 25, 2015
0f75d5f
font roation makro, code size optimization
olikraus Oct 25, 2015
df04a51
FONT_ROTATION macro
olikraus Oct 25, 2015
1287050
comments
olikraus Oct 26, 2015
26cfebd
fixed ssd1306 tile writing
olikraus Oct 26, 2015
3aee37d
Arduino u8g2 Example
olikraus Oct 27, 2015
a6d9027
hvline optimization
olikraus Oct 27, 2015
6191ca9
hvline optimization
olikraus Oct 27, 2015
3b53f4b
hv line optimization
olikraus Oct 27, 2015
1cffc7d
tga
olikraus Nov 6, 2015
e740446
h&v line
olikraus Jan 3, 2016
469a805
update
olikraus Feb 28, 2016
b85e668
issue 315
olikraus Apr 4, 2016
ff85d09
issue 353
olikraus Apr 4, 2016
3e7a30f
towards 1.19
olikraus Apr 5, 2016
1e1fea7
1.19.1
olikraus Apr 6, 2016
ce06a02
added comments
olikraus Apr 17, 2016
ec0acc2
added some asserts
olikraus Apr 17, 2016
4780f7c
LD7032 I2C
olikraus May 24, 2016
e1db9e9
Added hardware SPI support for atmega128 target.
getoffmyhack May 31, 2016
807fbd0
Added hardware SPI support for atmega128 target.
getoffmyhack May 31, 2016
3922dd8
Merge pull request #415 from getoffmyhack/master
olikraus May 31, 2016
c7cfb8a
Merge branch 'master' of https://github.com/olikraus/u8glib
olikraus Jun 1, 2016
77475f8
merge
olikraus Jun 1, 2016
b24a4a6
make pbm screen sizes less hardcoded
matthijskooijman Sep 2, 2016
6ee45b8
Merge pull request #424 from matthijskooijman/pbm-resize
olikraus Sep 4, 2016
aac33f7
Expose u8g_GetGlyphDeltaX through the C++ API
matthijskooijman Sep 8, 2016
0561a2c
Merge pull request #425 from matthijskooijman/deltax
olikraus Sep 10, 2016
221d2c4
Clean up ifdefs in ATmega hardware SPI code.
CruzR Sep 12, 2016
f552826
Disable I2C interface for ATmega32P/ATmega3290P.
CruzR Sep 12, 2016
2d29dda
Fix incorrect HW SPI pins for ATmega329P/ATmega3290P.
CruzR Sep 12, 2016
226ad0f
Adjust u8g_com_atmega_st7920_hw_spi to AVRs with different SPI pins.
CruzR Sep 12, 2016
e2d1009
Merge pull request #427 from CruzR/atmega329p
olikraus Sep 19, 2016
f29ac2b
Merge pull request #369 from daniel-thompson/fixes/stdout-build-fixes
olikraus Oct 1, 2016
c6bcb79
Update README.md
olikraus Nov 14, 2016
00609fe
Update README.md
olikraus Nov 14, 2016
f383617
update
olikraus Dec 2, 2016
151fa14
Merge branch 'master' of https://github.com/olikraus/u8glib
olikraus Dec 26, 2016
ee322ba
issue
olikraus Feb 14, 2017
99afbd1
Fix timeout handling for u8g_i2c_stop()
matthijskooijman Apr 7, 2017
f2e0c70
Merge pull request #458 from matthijskooijman/i2c-timeout-fix
olikraus Apr 8, 2017
4df725f
Merge branch 'master' of https://github.com/olikraus/u8glib
olikraus Jul 10, 2021
f3d1077
branch preparation
olikraus Jul 10, 2021
f1642c3
update
olikraus Jul 10, 2021
da4a56a
Add sleep support for st7920, mini12864, dogs102
luxflow Mar 21, 2022
4a491b4
Merge pull request #520 from luxflow/sleep
olikraus Mar 21, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,18 @@ u8glib ChangeLog
* 400KHz option for I2C with U8G_I2C_OPT_FAST available for Due and Uno (Issue 303)
* I2C support for Arduino Due. 100KHz/400KHz, TWI & TWI1, ACK will be ignored (issue 285)
* Unifont update (Issue 297)
2015-07-14 v1.18 Oliver Kraus <olikraus@gmail.com>
* Fixed contrast assignment for SSD1309 and UC1611
* Fixed bug in u8g_DrawLine(), Github issue 343
* Fixed bug in u8g_DrawStr90P(), Github issue 331
* Support for SSD1306 with 64x48 pixel
2016-04-05 v1.19 Oliver Kraus <olikraus@gmail.com>
* Fixed contrast (brightness) setting for SH1106 and SSD1306 devices
* Fixed compiler warnings
2016-05-24 v1.20 Oliver Kraus <olikraus@gmail.com>
* Experimental support for LD7032 I2C
* HW SPI Support for ATMega128






34 changes: 33 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,34 @@

# u8glib
# U8glib

Note: There will be no more development for U8glib. Please use [u8g2](https://github.com/olikraus/u8g2/wiki).

A graphics library with support for many different monochrome displays.

![nhd_oled180.jpg](https://github.com/olikraus/u8glib/wiki/otherpic/nhd_oled180.jpg) ![dogs102_180.jpg](https://github.com/olikraus/u8glib/wiki/otherpic/dogs102_180.jpg)

Left: NHD-2.7-12864 OLED (SSD1325), right: EA DOGS102 LCD (UC1701)

* [Gallery](https://github.com/olikraus/u8glib/wiki/gallery)
* Latest version of U8glib for Arduino is available in the Library Manager
* [Download Arduino Version from Github](https://github.com/olikraus/U8glib_Arduino/releases/latest)
* [Bintray](https://bintray.com/olikraus/u8glib) download links:
* [U8glib for Arduino](https://bintray.com/olikraus/u8glib/Arduino)
* [U8glib for AVR](https://bintray.com/olikraus/u8glib/AVR)
* [U8glib for ARM](https://bintray.com/olikraus/u8glib/ARM)
* Converter for BDF fonts: [bdf2u8g_101.exe on google drive](https://drive.google.com/folderview?id=0B5b6Dv0wCeCRLWJkYTh2TUlYVDg&usp=sharing).
* Supported environments:
* [Arduino (ATMEGA and ARM)](http://www.arduino.cc/)
* [AVR (ATMEGA)](https://github.com/olikraus/u8glib/wiki/avr)
* [ARM (with example for LPC1114)](https://github.com/olikraus/u8glib/wiki/lpc1114)
* Library for graphic LCDs and OLEDs
* [U8glib documentation and tutorials](https://github.com/olikraus/u8glib/wiki)
* Graphical user interface library (GUI) available: [M2tklib](http://code.google.com/p/m2tklib/)
* COM interfaces: Software SPI, Hardware SPI, 8Bit parallel
* Large number of [fonts](https://github.com/olikraus/u8glib/wiki/fontsize)
* Monospaced and proportional fonts
* Mouse-Cursor support
* Landscape and portrait mode
* Many supported [devices](https://github.com/olikraus/u8glib/wiki/device) (SSD1325, ST7565, ST7920, UC1608, UC1610, UC1701, PCD8544, PCF8812, KS0108, LC7981, SBN1661, SSD1306, SH1106, T6963, LD7032)
* Well-defined interface to the device subsystem

Empty file modified autoclean.sh
100755 → 100644
Empty file.
Empty file modified autogen.sh
100755 → 100644
Empty file.
33 changes: 33 additions & 0 deletions cppsrc/U8glib.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ class U8GLIB : public Print
u8g_uint_t getStrPixelWidthP(u8g_pgm_uint8_t *s) { return u8g_GetStrPixelWidthP(&u8g, s); }
u8g_uint_t getStrWidth(const char *s) { return u8g_GetStrWidth(&u8g, s); }
u8g_uint_t getStrWidthP(u8g_pgm_uint8_t *s) { return u8g_GetStrWidthP(&u8g, s); }
int8_t getGlyphDeltaX(uint8_t requested_encoding) { return u8g_GetGlyphDeltaX(&u8g, requested_encoding); }

void setHardwareBackup(u8g_state_cb backup_cb) { u8g_SetHardwareBackup(&u8g, backup_cb); }

Expand Down Expand Up @@ -968,6 +969,34 @@ class U8GLIB_SSD1306_128X32_2X : public U8GLIB
{ }
};

class U8GLIB_SSD1306_64X48 : public U8GLIB
{
public:
U8GLIB_SSD1306_64X48(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
: U8GLIB(&u8g_dev_ssd1306_64x48_sw_spi, sck, mosi, cs, a0, reset)
{ }
U8GLIB_SSD1306_64X48(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
: U8GLIB(&u8g_dev_ssd1306_64x48_hw_spi, cs, a0, reset)
{ }
U8GLIB_SSD1306_64X48(uint8_t options = U8G_I2C_OPT_NONE)
: U8GLIB(&u8g_dev_ssd1306_64x48_i2c, options)
{ }
};

class U8GLIB_SSD1306_64X48_2X : public U8GLIB
{
public:
U8GLIB_SSD1306_64X48_2X(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
: U8GLIB(&u8g_dev_ssd1306_64x48_2x_sw_spi, sck, mosi, cs, a0, reset)
{ }
U8GLIB_SSD1306_64X48_2X(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE)
: U8GLIB(&u8g_dev_ssd1306_64x48_2x_hw_spi, cs, a0, reset)
{ }
U8GLIB_SSD1306_64X48_2X(uint8_t options = U8G_I2C_OPT_NONE)
: U8GLIB(&u8g_dev_ssd1306_64x48_2x_i2c, options)
{ }
};


class U8GLIB_NHD27OLED_GR : public U8GLIB
{
Expand Down Expand Up @@ -1033,6 +1062,10 @@ class U8GLIB_LD7032_60x32 : public U8GLIB
uint8_t en, uint8_t cs1, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE)
: U8GLIB(&u8g_dev_ld7032_60x32_parallel, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, U8G_PIN_NONE, di, rw, reset)
{ }
U8GLIB_LD7032_60x32(uint8_t options = U8G_I2C_OPT_NONE)
: U8GLIB(&u8g_dev_ld7032_60x32_i2c, options)
{ }

};


Expand Down
62 changes: 53 additions & 9 deletions csrc/u8g.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,14 @@ extern "C" {
# if defined(__MSPGCC__)
/* mspgcc does not have .progmem sections. Use -fdata-sections. */
# define U8G_FONT_SECTION(name)
# endif
# endif
# if defined(__AVR__)
# define U8G_FONT_SECTION(name) U8G_SECTION(".progmem." name)
# endif
# if defined(__XTENSA__)
//# define U8G_FONT_SECTION(name) U8G_SECTION(".irom.text." name)
# define U8G_FONT_SECTION(name) U8G_SECTION(".irom0.text" )
# endif
#else
# define U8G_NOINLINE
# define U8G_PURE
Expand Down Expand Up @@ -120,16 +124,26 @@ typedef uint8_t PROGMEM u8g_pgm_uint8_t;
typedef uint8_t u8g_fntpgm_uint8_t;
#define u8g_pgm_read(adr) pgm_read_byte_near(adr)
#define U8G_PSTR(s) ((u8g_pgm_uint8_t *)PSTR(s))
#endif

#else

#define U8G_PROGMEM
#define PROGMEM
#if defined(__XTENSA__)
# ifndef PROGMEM
# define PROGMEM __attribute__ ((section (".irom0.text")))
# endif
# define U8G_PROGMEM PROGMEM
typedef uint8_t u8g_pgm_uint8_t;
typedef uint8_t u8g_fntpgm_uint8_t;
#define u8g_pgm_read(adr) (*(const u8g_pgm_uint8_t *)(adr))
#define U8G_PSTR(s) ((u8g_pgm_uint8_t *)(s))
# define u8g_pgm_read(adr) (*(const u8g_pgm_uint8_t *)(adr))
# define U8G_PSTR(s) ((u8g_pgm_uint8_t *)(s))
#endif

#ifndef U8G_PROGMEM
# define U8G_PROGMEM
# define PROGMEM
typedef uint8_t u8g_pgm_uint8_t;
typedef uint8_t u8g_fntpgm_uint8_t;
# define u8g_pgm_read(adr) (*(const u8g_pgm_uint8_t *)(adr))
# define U8G_PSTR(s) ((u8g_pgm_uint8_t *)(s))
#endif

/*===============================================================*/
Expand Down Expand Up @@ -401,6 +415,7 @@ extern u8g_dev_t u8g_dev_ssd1325_nhd27oled_bw_hw_spi;
extern u8g_dev_t u8g_dev_ssd1325_nhd27oled_bw_parallel;
extern u8g_dev_t u8g_dev_ssd1325_nhd27oled_gr_sw_spi;
extern u8g_dev_t u8g_dev_ssd1325_nhd27oled_gr_hw_spi;
extern u8g_dev_t u8g_dev_ssd1325_nhd27oled_gr_parallel;

extern u8g_dev_t u8g_dev_ssd1325_nhd27oled_2x_bw_sw_spi;
extern u8g_dev_t u8g_dev_ssd1325_nhd27oled_2x_bw_hw_spi;
Expand Down Expand Up @@ -466,10 +481,20 @@ extern u8g_dev_t u8g_dev_ssd1306_128x32_2x_sw_spi;
extern u8g_dev_t u8g_dev_ssd1306_128x32_2x_hw_spi;
extern u8g_dev_t u8g_dev_ssd1306_128x32_2x_i2c;

/* OLED 64x48 Display with SSD1306 Controller */
extern u8g_dev_t u8g_dev_ssd1306_64x48_sw_spi;
extern u8g_dev_t u8g_dev_ssd1306_64x48_hw_spi;
extern u8g_dev_t u8g_dev_ssd1306_64x48_i2c;

extern u8g_dev_t u8g_dev_ssd1306_64x48_2x_sw_spi;
extern u8g_dev_t u8g_dev_ssd1306_64x48_2x_hw_spi;
extern u8g_dev_t u8g_dev_ssd1306_64x48_2x_i2c;

/* OLED 60x32 Display with LD7032 Controller */
extern u8g_dev_t u8g_dev_ld7032_60x32_sw_spi;
extern u8g_dev_t u8g_dev_ld7032_60x32_hw_spi;
extern u8g_dev_t u8g_dev_ld7032_60x32_parallel;
extern u8g_dev_t u8g_dev_ld7032_60x32_i2c; /* not test and not sure of this works */

/* experimental 65K TFT with st7687 controller */
extern u8g_dev_t u8g_dev_st7687_c144mvgd_sw_spi;
Expand Down Expand Up @@ -675,11 +700,18 @@ uint8_t u8g_com_atmega_st7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val
uint8_t u8g_com_atmega_st7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
uint8_t u8g_com_atmega_parallel_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* u8g_com_atmega_parallel.c */

uint8_t u8g_com_atxmega_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* u8g_com_atxmega_hw_spi.c */
uint8_t u8g_com_atxmega_st7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* u8g_com_atxmega_st7920_spi.c */

uint8_t u8g_com_msp430_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* u8g_com_msp430_hw_spi.c */

uint8_t u8g_com_raspberrypi_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* u8g_com_rasperrypi_hw_spi.c */
uint8_t u8g_com_raspberrypi_ssd_i2c_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* u8g_com_raspberrypi_ssd_i2c.c */

uint8_t u8g_com_linux_ssd_i2c_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* u8g_com_linux_ssd_i2c.c */

uint8_t u8g_com_psoc5_ssd_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* u8g_com_psoc5_ssd_hw_spi.c */
uint8_t u8g_com_psoc5_ssd_hw_parallel_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); /* u8g_com_psoc5_ssd_hw_parallel.c */

/*
Translation of system specific com drives to generic com names
Expand Down Expand Up @@ -738,7 +770,10 @@ defined(__18CXX) || defined(__PIC32MX)
#endif
/* ==== HW SPI, not Arduino ====*/
#ifndef U8G_COM_HW_SPI
#if defined(__AVR__)
#if defined(__AVR_XMEGA__)
#define U8G_COM_HW_SPI u8g_com_atxmega_hw_spi_fn
#define U8G_COM_ST7920_HW_SPI u8g_com_atxmega_st7920_hw_spi_fn
#elif defined(__AVR__)
#define U8G_COM_HW_SPI u8g_com_atmega_hw_spi_fn
#define U8G_COM_ST7920_HW_SPI u8g_com_atmega_st7920_hw_spi_fn
#endif
Expand Down Expand Up @@ -833,6 +868,15 @@ defined(__18CXX) || defined(__PIC32MX)
#define U8G_COM_SSD_I2C u8g_com_raspberrypi_ssd_i2c_fn
#endif
#endif
#ifndef U8G_COM_SSD_I2C
#if defined(U8G_LINUX)
#define U8G_COM_SSD_I2C u8g_com_linux_ssd_i2c_fn
#endif
#endif
#if defined(U8G_CYPRESS_PSOC5)
#define U8G_COM_HW_SPI u8g_com_psoc5_ssd_hw_spi_fn
#define U8G_COM_FAST_PARALLEL u8g_com_psoc5_ssd_hw_parallel_fn
#endif

#ifndef U8G_COM_SSD_I2C
#define U8G_COM_SSD_I2C u8g_com_null_fn
Expand Down Expand Up @@ -1467,7 +1511,7 @@ void u8g_i2c_clear_error(void) U8G_NOINLINE;
uint8_t u8g_i2c_get_error(void) U8G_NOINLINE;
uint8_t u8g_i2c_get_err_pos(void) U8G_NOINLINE;
void u8g_i2c_init(uint8_t options) U8G_NOINLINE; /* use U8G_I2C_OPT_NONE as options */
uint8_t u8g_i2c_wait(uint8_t mask, uint8_t pos) U8G_NOINLINE;
uint8_t u8g_i2c_wait(uint8_t mask, uint8_t value, uint8_t pos) U8G_NOINLINE;
uint8_t u8g_i2c_start(uint8_t sla) U8G_NOINLINE;
uint8_t u8g_i2c_send_byte(uint8_t data) U8G_NOINLINE;
uint8_t u8g_i2c_send_mode(uint8_t mode) U8G_NOINLINE;
Expand Down
2 changes: 1 addition & 1 deletion csrc/u8g_clip.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
#define U8G_ALWAYS_INLINE __inline__ __attribute__((always_inline))
#else
#define U8G_ALWAYS_INLINE
#endif
#endif

/*
intersection assumptions:
Expand Down
41 changes: 24 additions & 17 deletions csrc/u8g_com_atmega_hw_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,7 @@
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


Assumes, that
MOSI is at PORTB, Pin 3
and
SCK is at PORTB, Pin 5


Update for ATOMIC operation done (01 Jun 2013)
U8G_ATOMIC_OR(ptr, val)
Expand All @@ -49,8 +44,8 @@

#include "u8g.h"


#if defined(__AVR__)
#if defined(__AVR_XMEGA__)
#elif defined(__AVR__)
#define U8G_ATMEGA_HW_SPI

/* remove the definition for attiny */
Expand All @@ -69,6 +64,18 @@
#include <avr/io.h>


/* Some AVR models assign the hardware SPI to different pins. */
#if defined(__AVR_ATmega128__) || defined(__AVR_ATmega329P__) || defined(__AVR_ATmega3290P__)
#define U8G_ATMEGA_HW_SPI_MOSI_PIN (_BV(2))
#define U8G_ATMEGA_HW_SPI_SCK_PIN (_BV(1))
#define U8G_ATMEGA_HW_SPI_SLAVE_SELECT_PIN (_BV(0))
#else
#define U8G_ATMEGA_HW_SPI_MOSI_PIN (_BV(3))
#define U8G_ATMEGA_HW_SPI_SCK_PIN (_BV(5))
#define U8G_ATMEGA_HW_SPI_SLAVE_SELECT_PIN (_BV(2))
#endif


static uint8_t u8g_atmega_spi_out(uint8_t data)
{
/* unsigned char x = 100; */
Expand Down Expand Up @@ -96,14 +103,14 @@ uint8_t u8g_com_atmega_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void
u8g_SetPIOutput(u8g, U8G_PI_RESET);

U8G_ATOMIC_START();
DDRB |= _BV(3); /* D0, MOSI */
DDRB |= _BV(5); /* SCK */
DDRB |= _BV(2); /* slave select */
PORTB &= ~_BV(3); /* D0, MOSI = 0 */
PORTB &= ~_BV(5); /* SCK = 0 */

DDRB |= U8G_ATMEGA_HW_SPI_MOSI_PIN;
DDRB |= U8G_ATMEGA_HW_SPI_SCK_PIN;
DDRB |= U8G_ATMEGA_HW_SPI_SLAVE_SELECT_PIN;

PORTB &= ~U8G_ATMEGA_HW_SPI_MOSI_PIN;
PORTB &= ~U8G_ATMEGA_HW_SPI_SCK_PIN;

U8G_ATOMIC_END();

u8g_SetPILevel(u8g, U8G_PI_CS, 1);
Expand Down Expand Up @@ -136,7 +143,7 @@ uint8_t u8g_com_atmega_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void
}
else
{
PORTB &= ~_BV(5); /* SCK = 0 */
PORTB &= ~U8G_ATMEGA_HW_SPI_SCK_PIN;
/* enable */
u8g_SetPILevel(u8g, U8G_PI_CS, 0); /* CS = 0 (low active) */
}
Expand Down
35 changes: 22 additions & 13 deletions csrc/u8g_com_atmega_st7920_hw_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@

A special SPI interface for ST7920 controller with HW SPI Support

Assumes, that
MOSI is at PORTB, Pin 3
and
SCK is at PORTB, Pin 5

Update for ATOMIC operation done (01 Jun 2013)
U8G_ATOMIC_OR(ptr, val)
U8G_ATOMIC_AND(ptr, val)
Expand All @@ -49,7 +44,8 @@

#include "u8g.h"

#if defined(__AVR__)
#if defined(__AVR_XMEGA__)
#elif defined(__AVR__)
#define U8G_ATMEGA_HW_SPI

/* remove the definition for attiny */
Expand All @@ -67,6 +63,19 @@
#include <avr/interrupt.h>
#include <avr/io.h>


/* Some AVR models assign the hardware SPI to different pins. */
#if defined(__AVR_ATmega128__) || defined(__AVR_ATmega329P__) || defined(__AVR_ATmega3290P__)
#define U8G_ATMEGA_HW_SPI_MOSI_PIN (_BV(2))
#define U8G_ATMEGA_HW_SPI_SCK_PIN (_BV(1))
#define U8G_ATMEGA_HW_SPI_SLAVE_SELECT_PIN (_BV(0))
#else
#define U8G_ATMEGA_HW_SPI_MOSI_PIN (_BV(3))
#define U8G_ATMEGA_HW_SPI_SCK_PIN (_BV(5))
#define U8G_ATMEGA_HW_SPI_SLAVE_SELECT_PIN (_BV(2))
#endif


static uint8_t u8g_atmega_st7920_hw_spi_shift_out(u8g_t *u8g, uint8_t val) U8G_NOINLINE;
static uint8_t u8g_atmega_st7920_hw_spi_shift_out(u8g_t *u8g, uint8_t val)
{
Expand Down Expand Up @@ -113,13 +122,13 @@ uint8_t u8g_com_atmega_st7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val
//u8g_SetPIOutput(u8g, U8G_PI_A0);

U8G_ATOMIC_START();
DDRB |= _BV(3); /* D0, MOSI */
DDRB |= _BV(5); /* SCK */
DDRB |= _BV(2); /* slave select */
PORTB &= ~_BV(3); /* D0, MOSI = 0 */
PORTB &= ~_BV(5); /* SCK = 0 */

DDRB |= U8G_ATMEGA_HW_SPI_MOSI_PIN;
DDRB |= U8G_ATMEGA_HW_SPI_SCK_PIN;
DDRB |= U8G_ATMEGA_HW_SPI_SLAVE_SELECT_PIN;

PORTB &= ~U8G_ATMEGA_HW_SPI_MOSI_PIN;
PORTB &= ~U8G_ATMEGA_HW_SPI_SCK_PIN;
U8G_ATOMIC_END();

u8g_SetPILevel(u8g, U8G_PI_CS, 1);
Expand Down
Loading