diff --git a/ChangeLog b/ChangeLog index 9bf4b34e..ad29b713 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 + * 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 + * Fixed contrast (brightness) setting for SH1106 and SSD1306 devices + * Fixed compiler warnings +2016-05-24 v1.20 Oliver Kraus + * Experimental support for LD7032 I2C + * HW SPI Support for ATMega128 - - \ No newline at end of file diff --git a/README.md b/README.md index 7dfdd455..38ef6c5c 100644 --- a/README.md +++ b/README.md @@ -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 + diff --git a/autoclean.sh b/autoclean.sh old mode 100755 new mode 100644 diff --git a/autogen.sh b/autogen.sh old mode 100755 new mode 100644 diff --git a/cppsrc/U8glib.h b/cppsrc/U8glib.h index 74b57756..f5de8a47 100644 --- a/cppsrc/U8glib.h +++ b/cppsrc/U8glib.h @@ -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); } @@ -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 { @@ -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) + { } + }; diff --git a/csrc/u8g.h b/csrc/u8g.h index 48f81e0c..e04197c2 100644 --- a/csrc/u8g.h +++ b/csrc/u8g.h @@ -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 @@ -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 /*===============================================================*/ @@ -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; @@ -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; @@ -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 @@ -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 @@ -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 @@ -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; diff --git a/csrc/u8g_clip.c b/csrc/u8g_clip.c index 1ca223e4..5f120971 100644 --- a/csrc/u8g_clip.c +++ b/csrc/u8g_clip.c @@ -62,7 +62,7 @@ #define U8G_ALWAYS_INLINE __inline__ __attribute__((always_inline)) #else #define U8G_ALWAYS_INLINE - #endif +#endif /* intersection assumptions: diff --git a/csrc/u8g_com_atmega_hw_spi.c b/csrc/u8g_com_atmega_hw_spi.c index 71e378b5..aedef745 100644 --- a/csrc/u8g_com_atmega_hw_spi.c +++ b/csrc/u8g_com_atmega_hw_spi.c @@ -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) @@ -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 */ @@ -69,6 +64,18 @@ #include +/* 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; */ @@ -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); @@ -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) */ } diff --git a/csrc/u8g_com_atmega_st7920_hw_spi.c b/csrc/u8g_com_atmega_st7920_hw_spi.c index dd0fd4e1..c4d2f996 100644 --- a/csrc/u8g_com_atmega_st7920_hw_spi.c +++ b/csrc/u8g_com_atmega_st7920_hw_spi.c @@ -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) @@ -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 */ @@ -67,6 +63,19 @@ #include #include + +/* 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) { @@ -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); diff --git a/csrc/u8g_com_atxmega_hw_spi.c b/csrc/u8g_com_atxmega_hw_spi.c new file mode 100644 index 00000000..4c2dfa27 --- /dev/null +++ b/csrc/u8g_com_atxmega_hw_spi.c @@ -0,0 +1,174 @@ +/* + + u8g_com_atxmega_hw_spi.c + + Universal 8bit Graphics Library + + Copyright (c) 2011, olikraus@gmail.com + Copyright (c) 2015, florianmenne@t-online.de + 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. + + 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) + U8G_ATOMIC_START() + U8G_ATOMIC_END() + + +*/ + +#include "u8g.h" + +#if defined(__AVR_XMEGA__) +#define U8G_ATXMEGA_HW_SPI +#endif + + +#if defined(U8G_ATXMEGA_HW_SPI) + +#include +#include + + +static uint8_t u8g_atxmega_spi_out(uint8_t data) +{ + /* send data */ + SPIC.DATA = data; + + /* wait for transmission */ + while(!(SPIC.STATUS & SPI_IF_bm)); + + /* clear the SPIF flag by reading SPDR */ + return SPIC.DATA; +} + + +uint8_t u8g_com_atxmega_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) +{ + switch(msg) + { + case U8G_COM_MSG_STOP: + break; + + case U8G_COM_MSG_INIT: + + u8g_SetPIOutput(u8g, U8G_PI_CS); + u8g_SetPIOutput(u8g, U8G_PI_A0); + u8g_SetPIOutput(u8g, U8G_PI_RESET); + + //U8G_ATOMIC_START(); + + PORTC.DIR |= PIN4_bm | PIN5_bm | PIN7_bm; + PORTC.DIR &= ~PIN6_bm; + + //U8G_ATOMIC_END(); + + u8g_SetPILevel(u8g, U8G_PI_CS, 1); + + SPIC.CTRL = 0; + SPIC.CTRL = SPI_PRESCALER_DIV4_gc | // SPI prescaler. + //SPI_CLK2X_bm | //SPI Clock double. + SPI_ENABLE_bm | //Enable SPI module. + //SPI_DORD_bm | //Data order. + SPI_MASTER_bm | //SPI master. + SPI_MODE_0_gc; // SPI mode. + +#ifdef U8G_HW_SPI_2X + SPIC.CTRL |= SPI_CLK2X_bm; /* double speed, issue 89 */ +#endif + + break; + + case U8G_COM_MSG_ADDRESS: /* define cmd (arg_val = 0) or data mode (arg_val = 1) */ + u8g_SetPILevel(u8g, U8G_PI_A0, arg_val); + break; + + case U8G_COM_MSG_CHIP_SELECT: + + if ( arg_val == 0 ) + { + /* disable */ + u8g_SetPILevel(u8g, U8G_PI_CS, 1); + } + else + { + //PORTB &= ~_BV(5); /* SCK = 0 */ + PORTC.OUT &= ~PIN7_bm; + /* enable */ + u8g_SetPILevel(u8g, U8G_PI_CS, 0); /* CS = 0 (low active) */ + } + + break; + + case U8G_COM_MSG_RESET: + u8g_SetPILevel(u8g, U8G_PI_RESET, arg_val); + break; + + case U8G_COM_MSG_WRITE_BYTE: + u8g_atxmega_spi_out(arg_val); + break; + + case U8G_COM_MSG_WRITE_SEQ: + { + register uint8_t *ptr = arg_ptr; + while( arg_val > 0 ) + { + u8g_atxmega_spi_out(*ptr++); + arg_val--; + } + } + break; + case U8G_COM_MSG_WRITE_SEQ_P: + { + register uint8_t *ptr = arg_ptr; + while( arg_val > 0 ) + { + u8g_atxmega_spi_out(u8g_pgm_read(ptr)); + ptr++; + arg_val--; + } + } + break; + } + return 1; +} + +#else + +uint8_t u8g_com_atxmega_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) +{ + return 1; +} + +#endif \ No newline at end of file diff --git a/csrc/u8g_com_atxmega_st7920_hw_spi.c b/csrc/u8g_com_atxmega_st7920_hw_spi.c new file mode 100644 index 00000000..4b82385d --- /dev/null +++ b/csrc/u8g_com_atxmega_st7920_hw_spi.c @@ -0,0 +1,202 @@ +/* + + u8g_com_atxmega_st7920_hw_spi.c + + Universal 8bit Graphics Library + + Copyright (c) 2011, olikraus@gmail.com + Copyright (c) 2015, florianmenne@t-online.de + 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. + + 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) + U8G_ATOMIC_START() + U8G_ATOMIC_END() + + +*/ + +#include "u8g.h" + +#if defined(__AVR_XMEGA__) +#define U8G_ATXMEGA_HW_SPI +#endif + +#if defined(U8G_ATXMEGA_HW_SPI) + +#include +#include + +static uint8_t u8g_atxmega_st7920_hw_spi_shift_out(u8g_t *u8g, uint8_t val) U8G_NOINLINE; +static uint8_t u8g_atxmega_st7920_hw_spi_shift_out(u8g_t *u8g, uint8_t val) +{ + /* send data */ + SPIC.DATA = val; + + /* wait for transmission */ + while(!(SPIC.STATUS & SPI_IF_bm)); + + /* clear the SPIF flag by reading SPDR */ + return SPIC.DATA; +} + + +static void u8g_com_atxmega_st7920_write_byte_hw_spi(u8g_t *u8g, uint8_t rs, uint8_t val) U8G_NOINLINE; +static void u8g_com_atxmega_st7920_write_byte_hw_spi(u8g_t *u8g, uint8_t rs, uint8_t val) +{ + uint8_t i; + + if ( rs == 0 ) + { + /* command */ + u8g_atxmega_st7920_hw_spi_shift_out(u8g, 0x0f8); + } + else if ( rs == 1 ) + { + /* data */ + u8g_atxmega_st7920_hw_spi_shift_out(u8g, 0x0fa); + } + + u8g_atxmega_st7920_hw_spi_shift_out(u8g, val & 0x0f0); + u8g_atxmega_st7920_hw_spi_shift_out(u8g, val << 4); + + for( i = 0; i < 4; i++ ) + u8g_10MicroDelay(); +} + + +uint8_t u8g_com_atxmega_st7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) +{ + switch(msg) + { + case U8G_COM_MSG_INIT: + u8g_SetPIOutput(u8g, U8G_PI_CS); + //u8g_SetPIOutput(u8g, U8G_PI_A0); + + //U8G_ATOMIC_START(); + + PORTC.DIR |= PIN4_bm | PIN5_bm | PIN7_bm; + PORTC.DIR &= ~PIN6_bm; + + //U8G_ATOMIC_END(); + + u8g_SetPILevel(u8g, U8G_PI_CS, 1); + + SPIC.CTRL = 0; + SPIC.CTRL = SPI_PRESCALER_DIV4_gc | // SPI prescaler. + //SPI_CLK2X_bm | //SPI Clock double. + SPI_ENABLE_bm | //Enable SPI module. + //SPI_DORD_bm | //Data order. + SPI_MASTER_bm | //SPI master. + SPI_MODE_0_gc; // SPI mode. + +#ifdef U8G_HW_SPI_2X + SPIC.CTRL |= SPI_CLK2X_bm; /* double speed, issue 89 */ +#endif + + u8g->pin_list[U8G_PI_A0_STATE] = 0; /* inital RS state: command mode */ + break; + + case U8G_COM_MSG_STOP: + break; + + case U8G_COM_MSG_RESET: + u8g_SetPILevel(u8g, U8G_PI_RESET, arg_val); + break; + + case U8G_COM_MSG_ADDRESS: /* define cmd (arg_val = 0) or data mode (arg_val = 1) */ + u8g->pin_list[U8G_PI_A0_STATE] = arg_val; + break; + + case U8G_COM_MSG_CHIP_SELECT: + if ( arg_val == 0 ) + { + /* disable, note: the st7920 has an active high chip select */ + u8g_SetPILevel(u8g, U8G_PI_CS, 0); + } + else + { + /* u8g_SetPILevel(u8g, U8G_PI_SCK, 0 ); */ + /* enable */ + u8g_SetPILevel(u8g, U8G_PI_CS, 1); /* CS = 1 (high active) */ + } + break; + + + case U8G_COM_MSG_WRITE_BYTE: + u8g_com_atxmega_st7920_write_byte_hw_spi(u8g, u8g->pin_list[U8G_PI_A0_STATE], arg_val); + //u8g->pin_list[U8G_PI_A0_STATE] = 2; + break; + + case U8G_COM_MSG_WRITE_SEQ: + { + register uint8_t *ptr = arg_ptr; + while( arg_val > 0 ) + { + u8g_com_atxmega_st7920_write_byte_hw_spi(u8g, u8g->pin_list[U8G_PI_A0_STATE], *ptr++); + //u8g->pin_list[U8G_PI_A0_STATE] = 2; + arg_val--; + } + } + break; + + case U8G_COM_MSG_WRITE_SEQ_P: + { + register uint8_t *ptr = arg_ptr; + while( arg_val > 0 ) + { + u8g_com_atxmega_st7920_write_byte_hw_spi(u8g, u8g->pin_list[U8G_PI_A0_STATE], u8g_pgm_read(ptr)); + //u8g->pin_list[U8G_PI_A0_STATE] = 2; + ptr++; + arg_val--; + } + } + break; + } + return 1; +} + +#else + + +uint8_t u8g_com_atxmega_st7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) +{ + return 1; +} + + +#endif + + \ No newline at end of file diff --git a/csrc/u8g_com_i2c.c b/csrc/u8g_com_i2c.c index 3c986efd..3cab7286 100644 --- a/csrc/u8g_com_i2c.c +++ b/csrc/u8g_com_i2c.c @@ -67,8 +67,8 @@ uint8_t u8g_i2c_get_err_pos(void) } - -#if defined(__AVR__) +#if defined(__AVR_XMEGA__) +#elif defined(__AVR__) static void u8g_i2c_set_error(uint8_t code, uint8_t pos) { @@ -87,6 +87,12 @@ static void u8g_i2c_set_error(uint8_t code, uint8_t pos) #if __AVR_ARCH__ == 25 #undef U8G_ATMEGA_HW_TWI #endif + +/* Some ATmegas also lack dedicated I2C hardware. */ +#if defined(__AVR_ATmega329P__) || defined(__AVR_ATmega3290P__) +#undef U8G_ATMEGA_HW_TWI +#endif + #endif #if defined(U8G_ATMEGA_HW_TWI) @@ -138,10 +144,10 @@ void u8g_i2c_init(uint8_t options) u8g_i2c_clear_error(); } -uint8_t u8g_i2c_wait(uint8_t mask, uint8_t pos) +uint8_t u8g_i2c_wait(uint8_t mask, uint8_t value, uint8_t pos) { volatile uint16_t cnt = 2000; /* timout value should be > 280 for 50KHz Bus and 16 Mhz CPU, however the start condition might need longer */ - while( !(TWCR & mask) ) + while( (TWCR & mask) != value ) { if ( cnt == 0 ) { @@ -169,7 +175,7 @@ uint8_t u8g_i2c_start(uint8_t sla) TWCR = _BV(TWINT) | _BV(TWSTA) | _BV(TWEN); /* wait */ - if ( u8g_i2c_wait(_BV(TWINT), 1) == 0 ) + if ( u8g_i2c_wait(_BV(TWINT), _BV(TWINT), 1) == 0 ) return 0; status = TW_STATUS; @@ -188,7 +194,7 @@ uint8_t u8g_i2c_start(uint8_t sla) TWCR = _BV(TWINT) | _BV(TWEN); /* wait */ - if ( u8g_i2c_wait(_BV(TWINT), 2) == 0 ) + if ( u8g_i2c_wait(_BV(TWINT), _BV(TWINT), 2) == 0 ) return 0; if ( u8g_i2c_opt & U8G_I2C_OPT_NO_ACK ) @@ -214,7 +220,7 @@ uint8_t u8g_i2c_send_byte(uint8_t data) register uint8_t status; TWDR = data; TWCR = _BV(TWINT) | _BV(TWEN); - if ( u8g_i2c_wait(_BV(TWINT), 3) == 0 ) + if ( u8g_i2c_wait(_BV(TWINT), _BV(TWINT), 3) == 0 ) return 0; if ( u8g_i2c_opt & U8G_I2C_OPT_NO_ACK ) @@ -240,7 +246,7 @@ void u8g_i2c_stop(void) TWCR = _BV(TWINT) | _BV(TWEN) | _BV(TWSTO); /* no error is checked for the stop condition */ - u8g_i2c_wait(_BV(TWSTO), 4); + u8g_i2c_wait(_BV(TWSTO), 0, 4); } @@ -606,7 +612,7 @@ uint8_t u8g_i2c_send_byte(uint8_t data) { return 1; } -uint8_t u8g_i2c_wait(uint8_t mask, uint8_t pos) +uint8_t u8g_i2c_wait(uint8_t mask, uint8_t value, uint8_t pos) { return 1; } @@ -620,7 +626,7 @@ void u8g_i2c_init(uint8_t options) u8g_i2c_clear_error(); } -uint8_t u8g_i2c_wait(uint8_t mask, uint8_t pos) +uint8_t u8g_i2c_wait(uint8_t mask, uint8_t value, uint8_t pos) { return 1; } diff --git a/csrc/u8g_com_io.c b/csrc/u8g_com_io.c index e1bc21a3..1ebd373d 100644 --- a/csrc/u8g_com_io.c +++ b/csrc/u8g_com_io.c @@ -65,6 +65,83 @@ uint8_t u8g_Pin(uint8_t port, uint8_t bitpos) return port; } +#if defined(__AVR_XMEGA__) + +const IO_PTR u8g_avr_ddr_P[] PROGMEM = { +#ifdef PORTA + &PORTA.DIR, +#else + 0, +#endif + &PORTB.DIR, +#ifdef PORTC + &PORTC.DIR, +#ifdef PORTD + &PORTD.DIR, +#ifdef PORTE + &PORTE.DIR, +#ifdef PORTF + &PORTF.DIR, +#ifdef PORTR + &PORTR.DIR, +#endif +#endif +#endif +#endif +#endif +}; + + +const IO_PTR u8g_avr_port_P[] PROGMEM = { +#ifdef PORTA + &PORTA.OUT, +#else + 0, +#endif + &PORTB.OUT, +#ifdef PORTC + &PORTC.OUT, +#ifdef PORTD + &PORTD.OUT, +#ifdef PORTE + &PORTE.OUT, +#ifdef PORTF + &PORTF.OUT, +#ifdef PORTR + &PORTR.OUT, +#endif +#endif +#endif +#endif +#endif +}; + +const IO_PTR u8g_avr_pin_P[] PROGMEM = { +#ifdef PORTA + &PORTA.IN, +#else + 0, +#endif + &PORTB.IN, +#ifdef PORTC + &PORTC.IN, +#ifdef PORTD + &PORTD.IN, +#ifdef PORTE + &PORTE.IN, +#ifdef PORTF + &PORTF.IN, +#ifdef PORTR + &PORTR.IN, +#endif +#endif +#endif +#endif +#endif +}; + + +#else const IO_PTR u8g_avr_ddr_P[] PROGMEM = { #ifdef DDRA &DDRA, @@ -146,6 +223,7 @@ const IO_PTR u8g_avr_pin_P[] PROGMEM = { #endif #endif }; +#endif static volatile uint8_t *u8g_get_avr_io_ptr(const IO_PTR *base, uint8_t offset) { diff --git a/csrc/u8g_com_linux_ssd_i2c.c b/csrc/u8g_com_linux_ssd_i2c.c new file mode 100644 index 00000000..bd5b735c --- /dev/null +++ b/csrc/u8g_com_linux_ssd_i2c.c @@ -0,0 +1,168 @@ +/* + + u8g_com_linux_ssd_i2c.c + + com interface for linux i2c-dev and the SSDxxxx chip (SOLOMON) variant + I2C protocol + + + Universal 8bit Graphics Library + + Copyright (c) 2012, olikraus@gmail.com + Copyright (c) 2015, daniel@redfelineninja.org.uk + 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" + +#if defined(U8G_LINUX) + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + + +#define I2C_SLA 0x3c +#define I2C_CMD_MODE 0x80 +#define I2C_DATA_MODE 0x40 +#define MAX_PACKET 64 + +#ifndef U8G_WITH_PINLIST +#error U8G_WITH_PINLIST is mandatory for this driver +#endif + +static void set_cmd_mode(u8g_t *u8g, bool cmd_mode) +{ + u8g->pin_list[U8G_PI_A0_STATE] = cmd_mode; +} + +static bool get_cmd_mode(u8g_t *u8g) +{ + return u8g->pin_list[U8G_PI_A0_STATE]; +} + +static uint8_t send_data_burst(u8g_t *u8g, int fd, uint8_t *buf, size_t buflen) +{ + uint8_t i2cbuf[2*MAX_PACKET]; + uint8_t i2clen; + int res; + + /* ignore bursts when there is no file open */ + if (fd < 0) + return 0; + + if (get_cmd_mode(u8g)) { + i2clen = 0; + while (buflen > 0) { + i2cbuf[i2clen++] = I2C_CMD_MODE; + i2cbuf[i2clen++] = *buf++; + buflen--; + } + } else { + i2cbuf[0] = I2C_DATA_MODE; + memcpy(i2cbuf+1, buf, buflen); + i2clen = buflen + 1; + } + + res = write(fd, i2cbuf, i2clen); + if (res < 0) + fprintf(stderr, "I2C write failed (%s)\n", strerror(errno)); + else if (res != i2clen) + fprintf(stderr, "Incomplete I2C write (%d of %d packet)\n", res, i2clen); + + return res == i2clen; +} + +uint8_t u8g_com_linux_ssd_i2c_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) +{ + static int fd = -1; + char dev[24]; + + switch(msg) + { + case U8G_COM_MSG_INIT: + sprintf(dev, "/dev/i2c-%d", u8g->pin_list[U8G_PI_I2C_OPTION]); + fd = open(dev, O_RDWR); + if (fd < 0) { + fprintf(stderr, "cannot open %s (%s)\n", dev, strerror(errno)); + return 0; + } + + if (ioctl(fd, I2C_SLAVE, I2C_SLA) < 0) { + fprintf(stderr, "cannot set slave address (%s)\n", strerror(errno)); + return 0; + } + + break; + + case U8G_COM_MSG_STOP: + /* ignored - i2c-dev will automatically stop between writes */ + break; + + case U8G_COM_MSG_RESET: + /* ignored - no obvious means to reset an SSD via I2C */ + break; + + case U8G_COM_MSG_CHIP_SELECT: + set_cmd_mode(u8g, true); + break; + + case U8G_COM_MSG_WRITE_BYTE: + send_data_burst(u8g, fd, &arg_val, 1); + break; + + case U8G_COM_MSG_WRITE_SEQ: + case U8G_COM_MSG_WRITE_SEQ_P: /* no progmem in Linux */ + while (arg_val > MAX_PACKET) { + send_data_burst(u8g, fd, arg_ptr, MAX_PACKET); + arg_ptr += MAX_PACKET; + arg_val -= MAX_PACKET; + } + send_data_burst(u8g, fd, arg_ptr, arg_val); + break; + + case U8G_COM_MSG_ADDRESS: + /* choose cmd (arg_val = 0) or data mode (arg_val = 1) */ + set_cmd_mode(u8g, !arg_val); + break; + } + + return 1; +} + +#endif /* U8G_LINUX */ diff --git a/csrc/u8g_com_psoc5_ssd_hw_parallel.c b/csrc/u8g_com_psoc5_ssd_hw_parallel.c new file mode 100644 index 00000000..668c61ba --- /dev/null +++ b/csrc/u8g_com_psoc5_ssd_hw_parallel.c @@ -0,0 +1,107 @@ +/* + + u8g_com_psoc5_ssd_hw_parallel.c + + com interface for Cypress PSoC5 and the SSDxxxx chip variant + I2C protocol + + Universal 8bit Graphics Library + + Copyright (c) 2015, olikraus@gmail.com, schmidt.ronny@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" + +#if defined(U8G_CYPRESS_PSOC5) + +#include + +static uint8 dc = 0; // need to store whether next write is data or command + +uint8_t u8g_com_psoc5_ssd_hw_parallel_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) +{ + switch(msg) + { + case U8G_COM_MSG_STOP: + // stop the device + GraphicLCDIntf_Stop(); + break; + + case U8G_COM_MSG_INIT: + // init hardware interfaces, timers, gpios, ... + GraphicLCDIntf_Init(); + break; + + case U8G_COM_MSG_ADDRESS: + // switch from cmd (arg_val = 0) to data mode (arg_val = 1) or vice versa + dc = arg_val; + break; + + case U8G_COM_MSG_CHIP_SELECT: + /* done by the hardware */ + break; + + case U8G_COM_MSG_RESET: + // toggle the reset pin of the display by value in arg_val + nRES_Write(0); + u8g_10MicroDelay(); + nRES_Write(1); + break; + + case U8G_COM_MSG_WRITE_BYTE: + // write byte to the device + GraphicLCDIntf_Write8(dc, arg_val); + break; + + case U8G_COM_MSG_WRITE_SEQ: + case U8G_COM_MSG_WRITE_SEQ_P: + { + // write a sequence of bytes to the device + register uint8_t *ptr = arg_ptr; + while (arg_val-- > 0) + { + GraphicLCDIntf_Write8(dc, *ptr++); + } + } + break; + + + } + return 1; +} + +#else + +uint8_t u8g_com_psoc5_ssd_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) +{ + return 1; +} + +#endif diff --git a/csrc/u8g_delay.c b/csrc/u8g_delay.c index d38e02a5..76137b27 100644 --- a/csrc/u8g_delay.c +++ b/csrc/u8g_delay.c @@ -52,6 +52,11 @@ # include # endif +/* issue 353 */ +#if defined(ARDUINO_ARCH_SAMD) +# include +#endif + # if defined(__AVR__) # define USE_AVR_DELAY # elif defined(__PIC32MX) @@ -71,6 +76,8 @@ # define USE_AVR_DELAY #elif defined(__18CXX) # define USE_PIC18_DELAY +#elif defined(U8G_CYPRESS_PSOC5) +#define USE_PSOC5_DELAY #elif defined(__arm__) /* do not define anything, all procedures are expected to be defined outside u8glib */ @@ -293,6 +300,12 @@ void u8g_10MicroDelay(void) __delay_cycles(F_CPU/100000UL); } #endif +#if defined USE_PSOC5_DELAY + #include + void u8g_Delay(uint16_t val) {CyDelay(val);}; + void u8g_MicroDelay(void) {CyDelay(1);}; + void u8g_10MicroDelay(void) {CyDelay(10);}; +#endif /*== Any other systems: Dummy Delay ==*/ diff --git a/csrc/u8g_dev_lc7981_160x80.c b/csrc/u8g_dev_lc7981_160x80.c index e05fa03a..3de20992 100644 --- a/csrc/u8g_dev_lc7981_160x80.c +++ b/csrc/u8g_dev_lc7981_160x80.c @@ -75,7 +75,7 @@ static const uint8_t u8g_dev_lc7981_160x80_init_seq[] PROGMEM = { U8G_ESC_ADR(1), /* instruction mode */ 0x003, /* time division */ U8G_ESC_ADR(0), /* data mode */ - 0x07f, /* */ + 0x050, /* Oct 2015: Changed from 7f to 50 (1/80 duty cycle) */ U8G_ESC_ADR(1), /* instruction mode */ 0x008, /* display start low */ diff --git a/csrc/u8g_dev_ld7032_60x32.c b/csrc/u8g_dev_ld7032_60x32.c index 596d9589..98833f7c 100644 --- a/csrc/u8g_dev_ld7032_60x32.c +++ b/csrc/u8g_dev_ld7032_60x32.c @@ -229,4 +229,5 @@ U8G_PB_DEV(u8g_dev_ld7032_60x32_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ld70 U8G_PB_DEV(u8g_dev_ld7032_60x32_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ld7032_60x32_fn, U8G_COM_HW_SPI); U8G_PB_DEV(u8g_dev_ld7032_60x32_parallel, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ld7032_60x32_fn, U8G_COM_PARALLEL); U8G_PB_DEV(u8g_dev_ld7032_60x32_hw_usart_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ld7032_60x32_fn, U8G_COM_HW_USART_SPI); +U8G_PB_DEV(u8g_dev_ld7032_60x32_i2c, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ld7032_60x32_fn, U8G_COM_SSD_I2C); diff --git a/csrc/u8g_dev_ssd1306_128x32.c b/csrc/u8g_dev_ssd1306_128x32.c index 3052d6bc..ff516ff6 100644 --- a/csrc/u8g_dev_ssd1306_128x32.c +++ b/csrc/u8g_dev_ssd1306_128x32.c @@ -230,6 +230,13 @@ uint8_t u8g_dev_ssd1306_128x32_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void 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) ); /* 11 Jul 2015: fixed contrast calculation */ + u8g_SetChipSelect(u8g, dev, 0); + return 1; case U8G_DEV_MSG_SLEEP_ON: u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on); return 1; @@ -268,6 +275,13 @@ uint8_t u8g_dev_ssd1306_128x32_2x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, vo 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) ); /* 11 Jul 2015: fixed contrast calculation */ + u8g_SetChipSelect(u8g, dev, 0); + return 1; case U8G_DEV_MSG_SLEEP_ON: u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on); return 1; diff --git a/csrc/u8g_dev_ssd1306_128x64.c b/csrc/u8g_dev_ssd1306_128x64.c index bd55e90e..1b67fbb4 100644 --- a/csrc/u8g_dev_ssd1306_128x64.c +++ b/csrc/u8g_dev_ssd1306_128x64.c @@ -240,6 +240,15 @@ uint8_t u8g_dev_ssd1306_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void case U8G_DEV_MSG_SLEEP_OFF: u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off); return 1; + case U8G_DEV_MSG_CONTRAST: + { + u8g_SetChipSelect(u8g, dev, 1); + u8g_SetAddress(u8g, dev, 0); /* instruction mode */ + u8g_WriteByte(u8g, dev, 0x81); + u8g_WriteByte(u8g, dev, *(uint8_t *) arg); + u8g_SetChipSelect(u8g, dev, 0); + return 1; + } } return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg); } @@ -271,6 +280,15 @@ uint8_t u8g_dev_ssd1306_adafruit_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t m case U8G_DEV_MSG_SLEEP_OFF: u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off); return 1; + case U8G_DEV_MSG_CONTRAST: + { + u8g_SetChipSelect(u8g, dev, 1); + u8g_SetAddress(u8g, dev, 0); /* instruction mode */ + u8g_WriteByte(u8g, dev, 0x81); + u8g_WriteByte(u8g, dev, *(uint8_t *) arg); + u8g_SetChipSelect(u8g, dev, 0); + return 1; + } } return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg); } @@ -302,6 +320,15 @@ uint8_t u8g_dev_sh1106_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void * case U8G_DEV_MSG_SLEEP_OFF: u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off); return 1; + case U8G_DEV_MSG_CONTRAST: + { + u8g_SetChipSelect(u8g, dev, 1); + u8g_SetAddress(u8g, dev, 0); /* instruction mode */ + u8g_WriteByte(u8g, dev, 0x81); + u8g_WriteByte(u8g, dev, *(uint8_t *) arg); + u8g_SetChipSelect(u8g, dev, 0); + return 1; + } } return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg); } @@ -340,6 +367,15 @@ uint8_t u8g_dev_ssd1306_128x64_2x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, vo case U8G_DEV_MSG_SLEEP_OFF: u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off); return 1; + case U8G_DEV_MSG_CONTRAST: + { + u8g_SetChipSelect(u8g, dev, 1); + u8g_SetAddress(u8g, dev, 0); /* instruction mode */ + u8g_WriteByte(u8g, dev, 0x81); + u8g_WriteByte(u8g, dev, *(uint8_t *) arg); + u8g_SetChipSelect(u8g, dev, 0); + return 1; + } } return u8g_dev_pb16v1_base_fn(u8g, dev, msg, arg); } @@ -377,6 +413,15 @@ uint8_t u8g_dev_sh1106_128x64_2x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, voi case U8G_DEV_MSG_SLEEP_OFF: u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off); return 1; + case U8G_DEV_MSG_CONTRAST: + { + u8g_SetChipSelect(u8g, dev, 1); + u8g_SetAddress(u8g, dev, 0); /* instruction mode */ + u8g_WriteByte(u8g, dev, 0x81); + u8g_WriteByte(u8g, dev, *(uint8_t *) arg); + u8g_SetChipSelect(u8g, dev, 0); + return 1; + } } return u8g_dev_pb16v1_base_fn(u8g, dev, msg, arg); } diff --git a/csrc/u8g_dev_ssd1306_64x48.c b/csrc/u8g_dev_ssd1306_64x48.c new file mode 100644 index 00000000..b9bdb1d1 --- /dev/null +++ b/csrc/u8g_dev_ssd1306_64x48.c @@ -0,0 +1,201 @@ +/* + + u8g_dev_ssd1306_64x48.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 64 +#define HEIGHT 48 +#define PAGE_HEIGHT 8 + + + +/* init sequence buydisplay.com 0.66" 64x48 OLED */ +/* http://www.buydisplay.com/download/manual/ER-OLED0.66-1_Series_Datasheet.pdf */ +static const uint8_t u8g_dev_ssd1306_64x48_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 */ + + 0x0ae, /* display off, sleep mode */ + 0x0d5, 0x080, /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */ + 0x0a8, 0x02f, /* Multiplex Ration, Jul 12, 2015: From 0.66" OLED datasheet */ + + 0x0d3, 0x000, /* */ + + 0x040, /* start line */ + + 0x08d, 0x014, /* charge pump setting (p62): 0x014 enable, 0x010 disable */ + + //0x020, 0x002, /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5), Feb 23, 2013: 64x48 OLED: 0x002, 64x48 OLED 0x012 */ + 0x0a1, /* segment remap a0/a1*/ + 0x0c8, /* c0: scan dir normal, c8: reverse */ + 0x0da, 0x012, /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5), Jul 12, 2015: From 0.66" OLED datasheet */ + 0x081, 0x0cf, /* set contrast control */ + 0x0d9, 0x022, /* pre-charge period 0x022/f1, from 0.66" OLED datasheet */ + 0x0db, 0x000, /* vcomh deselect level, from 0.66" OLED datasheet */ + + 0x02e, /* 2012-05-27: Deactivate scroll */ + 0x0a4, /* output ram to display */ + 0x0a6, /* none inverted normal display mode */ + 0x0af, /* display on */ + + U8G_ESC_CS(0), /* disable chip */ + U8G_ESC_END /* end of sequence */ +}; + + + + +static const uint8_t u8g_dev_ssd1306_64x48_data_start[] PROGMEM = { + U8G_ESC_ADR(0), /* instruction mode */ + U8G_ESC_CS(1), /* enable chip */ + 0x010+2, /* set upper 4 bit of the col adr. to 0, 0.66" OLED starts with offset 32 */ + 0x000, /* set lower 4 bit of the col adr. to 4 */ + U8G_ESC_END /* end of sequence */ +}; + +static const uint8_t u8g_dev_ssd13xx_sleep_on[] PROGMEM = { + U8G_ESC_ADR(0), /* instruction mode */ + U8G_ESC_CS(1), /* enable chip */ + 0x0ae, /* display off */ + U8G_ESC_CS(0), /* disable chip, bugfix 12 nov 2014 */ + U8G_ESC_END /* end of sequence */ +}; + +static const uint8_t u8g_dev_ssd13xx_sleep_off[] PROGMEM = { + U8G_ESC_ADR(0), /* instruction mode */ + U8G_ESC_CS(1), /* enable chip */ + 0x0af, /* display on */ + U8G_ESC_DLY(50), /* delay 50 ms */ + U8G_ESC_CS(0), /* disable chip, bugfix 12 nov 2014 */ + U8G_ESC_END /* end of sequence */ +}; + +uint8_t u8g_dev_ssd1306_64x48_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_ssd1306_64x48_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_ssd1306_64x48_data_start); + u8g_WriteByte(u8g, dev, 0x0b0 | pb->p.page); /* select current page (SSD1306) */ + 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) ); /* 11 Jul 2015: fixed contrast calculation */ + u8g_SetChipSelect(u8g, dev, 0); + return 1; + case U8G_DEV_MSG_SLEEP_ON: + u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on); + return 1; + case U8G_DEV_MSG_SLEEP_OFF: + u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off); + return 1; +} + + return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg); +} + +uint8_t u8g_dev_ssd1306_64x48_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_ssd1306_64x48_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_ssd1306_64x48_data_start); + u8g_WriteByte(u8g, dev, 0x0b0 | (pb->p.page*2)); /* select current page (SSD1306) */ + 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_ssd1306_64x48_data_start); + u8g_WriteByte(u8g, dev, 0x0b0 | (pb->p.page*2+1)); /* select current page (SSD1306) */ + 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) ); /* 11 Jul 2015: fixed contrast calculation */ + u8g_SetChipSelect(u8g, dev, 0); + return 1; + case U8G_DEV_MSG_SLEEP_ON: + u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on); + return 1; + case U8G_DEV_MSG_SLEEP_OFF: + u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off); + return 1; + } + return u8g_dev_pb16v1_base_fn(u8g, dev, msg, arg); +} + +U8G_PB_DEV(u8g_dev_ssd1306_64x48_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_64x48_fn, U8G_COM_SW_SPI); +U8G_PB_DEV(u8g_dev_ssd1306_64x48_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_64x48_fn, U8G_COM_HW_SPI); +U8G_PB_DEV(u8g_dev_ssd1306_64x48_i2c, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_64x48_fn, U8G_COM_SSD_I2C); + +uint8_t u8g_dev_ssd1306_64x48_2x_buf[WIDTH*2] U8G_NOCOMMON ; +u8g_pb_t u8g_dev_ssd1306_64x48_2x_pb = { {16, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_ssd1306_64x48_2x_buf}; +u8g_dev_t u8g_dev_ssd1306_64x48_2x_sw_spi = { u8g_dev_ssd1306_64x48_2x_fn, &u8g_dev_ssd1306_64x48_2x_pb, U8G_COM_SW_SPI }; +u8g_dev_t u8g_dev_ssd1306_64x48_2x_hw_spi = { u8g_dev_ssd1306_64x48_2x_fn, &u8g_dev_ssd1306_64x48_2x_pb, U8G_COM_HW_SPI }; +u8g_dev_t u8g_dev_ssd1306_64x48_2x_i2c = { u8g_dev_ssd1306_64x48_2x_fn, &u8g_dev_ssd1306_64x48_2x_pb, U8G_COM_SSD_I2C }; diff --git a/csrc/u8g_dev_ssd1309_128x64.c b/csrc/u8g_dev_ssd1309_128x64.c index 1c11b029..4893f82c 100644 --- a/csrc/u8g_dev_ssd1309_128x64.c +++ b/csrc/u8g_dev_ssd1309_128x64.c @@ -124,7 +124,7 @@ uint8_t u8g_dev_ssd1309_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void 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_WriteByte(u8g, dev, (*(uint8_t *)arg) ); /* 11 Jul 2015: fixed contrast calculation */ u8g_SetChipSelect(u8g, dev, 0); return 1; case U8G_DEV_MSG_SLEEP_ON: diff --git a/csrc/u8g_dev_ssd1325_nhd27oled_gr_new.c b/csrc/u8g_dev_ssd1325_nhd27oled_gr_new.c index 9ac51f2f..0667ca3c 100644 --- a/csrc/u8g_dev_ssd1325_nhd27oled_gr_new.c +++ b/csrc/u8g_dev_ssd1325_nhd27oled_gr_new.c @@ -220,6 +220,7 @@ static uint8_t u8g_dev_ssd1325_nhd27oled_2x_gr_fn(u8g_t *u8g, u8g_dev_t *dev, ui U8G_PB_DEV(u8g_dev_ssd1325_nhd27oled_gr_sw_spi , WIDTH, HEIGHT, 4, u8g_dev_ssd1325_nhd27oled_gr_fn, U8G_COM_SW_SPI); U8G_PB_DEV(u8g_dev_ssd1325_nhd27oled_gr_hw_spi , WIDTH, HEIGHT, 4, u8g_dev_ssd1325_nhd27oled_gr_fn, U8G_COM_HW_SPI); +U8G_PB_DEV(u8g_dev_ssd1325_nhd27oled_gr_parallel , WIDTH, HEIGHT, 4, u8g_dev_ssd1325_nhd27oled_gr_fn, U8G_COM_FAST_PARALLEL); uint8_t u8g_dev_ssd1325_nhd27oled_2x_buf[WIDTH*2] U8G_NOCOMMON ; u8g_pb_t u8g_dev_ssd1325_nhd27oled_2x_pb = { {8, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_ssd1325_nhd27oled_2x_buf}; diff --git a/csrc/u8g_dev_st7920_128x64.c b/csrc/u8g_dev_st7920_128x64.c index 29e63134..12084551 100644 --- a/csrc/u8g_dev_st7920_128x64.c +++ b/csrc/u8g_dev_st7920_128x64.c @@ -61,6 +61,26 @@ static const uint8_t u8g_dev_st7920_128x64_init_seq[] PROGMEM = { U8G_ESC_END /* end of sequence */ }; +static const uint8_t u8g_dev_st7920_128x64_sleep_on[] PROGMEM = { + U8G_ESC_ADR(0), /* instruction mode */ + U8G_ESC_CS(1), /* enable chip */ + 0x038, /* 8 Bit interface (DL=1), basic instruction set (RE=0) */ + 0x008, /* display off */ + 0x034, /* 8 Bit interface (DL=1), extended instruction set (RE=1) */ + 0x001, /* Standby mode */ + U8G_ESC_CS(0), /* disable chip */ + U8G_ESC_END /* end of sequence */ +}; + +static const uint8_t u8g_dev_st7920_128x64_sleep_off[] PROGMEM = { + U8G_ESC_ADR(0), /* instruction mode */ + U8G_ESC_CS(1), /* enable chip */ + 0x038, /* 8 Bit interface (DL=1), basic instruction set (RE=0) */ + 0x00c, /* display on, cursor & blink off */ + U8G_ESC_CS(0), /* disable chip */ + U8G_ESC_END /* end of sequence */ +}; + uint8_t u8g_dev_st7920_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg) { switch(msg) @@ -105,6 +125,12 @@ uint8_t u8g_dev_st7920_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void * u8g_SetChipSelect(u8g, dev, 0); } break; + case U8G_DEV_MSG_SLEEP_ON: + u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7920_128x64_sleep_on); + return 1; + case U8G_DEV_MSG_SLEEP_OFF: + u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7920_128x64_sleep_off); + return 1; } return u8g_dev_pb8h1_base_fn(u8g, dev, msg, arg); } @@ -153,6 +179,12 @@ uint8_t u8g_dev_st7920_128x64_4x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, voi u8g_SetChipSelect(u8g, dev, 0); } break; + case U8G_DEV_MSG_SLEEP_ON: + u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7920_128x64_sleep_on); + return 1; + case U8G_DEV_MSG_SLEEP_OFF: + u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7920_128x64_sleep_off); + return 1; } return u8g_dev_pb32h1_base_fn(u8g, dev, msg, arg); } diff --git a/csrc/u8g_dev_st7920_192x32.c b/csrc/u8g_dev_st7920_192x32.c index 736b0828..ade67367 100644 --- a/csrc/u8g_dev_st7920_192x32.c +++ b/csrc/u8g_dev_st7920_192x32.c @@ -60,6 +60,26 @@ static const uint8_t u8g_dev_st7920_192x32_init_seq[] PROGMEM = { U8G_ESC_END /* end of sequence */ }; +static const uint8_t u8g_dev_st7920_192x32_sleep_on[] PROGMEM = { + U8G_ESC_ADR(0), /* instruction mode */ + U8G_ESC_CS(1), /* enable chip */ + 0x038, /* 8 Bit interface (DL=1), basic instruction set (RE=0) */ + 0x008, /* display off */ + 0x034, /* 8 Bit interface (DL=1), extended instruction set (RE=1) */ + 0x001, /* Standby mode */ + U8G_ESC_CS(0), /* disable chip */ + U8G_ESC_END /* end of sequence */ +}; + +static const uint8_t u8g_dev_st7920_192x32_sleep_off[] PROGMEM = { + U8G_ESC_ADR(0), /* instruction mode */ + U8G_ESC_CS(1), /* enable chip */ + 0x038, /* 8 Bit interface (DL=1), basic instruction set (RE=0) */ + 0x00c, /* display on, cursor & blink off */ + U8G_ESC_CS(0), /* disable chip */ + U8G_ESC_END /* end of sequence */ +}; + uint8_t u8g_dev_st7920_192x32_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg) { switch(msg) @@ -94,6 +114,12 @@ uint8_t u8g_dev_st7920_192x32_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void * u8g_SetChipSelect(u8g, dev, 0); } break; + case U8G_DEV_MSG_SLEEP_ON: + u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7920_192x32_sleep_on); + return 1; + case U8G_DEV_MSG_SLEEP_OFF: + u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7920_192x32_sleep_off); + return 1; } return u8g_dev_pb8h1_base_fn(u8g, dev, msg, arg); } @@ -132,6 +158,12 @@ uint8_t u8g_dev_st7920_192x32_4x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, voi u8g_SetChipSelect(u8g, dev, 0); } break; + case U8G_DEV_MSG_SLEEP_ON: + u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7920_192x32_sleep_on); + return 1; + case U8G_DEV_MSG_SLEEP_OFF: + u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7920_192x32_sleep_off); + return 1; } return u8g_dev_pb32h1_base_fn(u8g, dev, msg, arg); } diff --git a/csrc/u8g_dev_st7920_202x32.c b/csrc/u8g_dev_st7920_202x32.c index b36b7abc..161368d5 100644 --- a/csrc/u8g_dev_st7920_202x32.c +++ b/csrc/u8g_dev_st7920_202x32.c @@ -63,6 +63,26 @@ static const uint8_t u8g_dev_st7920_202x32_init_seq[] PROGMEM = { U8G_ESC_END /* end of sequence */ }; +static const uint8_t u8g_dev_st7920_202x32_sleep_on[] PROGMEM = { + U8G_ESC_ADR(0), /* instruction mode */ + U8G_ESC_CS(1), /* enable chip */ + 0x038, /* 8 Bit interface (DL=1), basic instruction set (RE=0) */ + 0x008, /* display off */ + 0x034, /* 8 Bit interface (DL=1), extended instruction set (RE=1) */ + 0x001, /* Standby mode */ + U8G_ESC_CS(0), /* disable chip */ + U8G_ESC_END /* end of sequence */ +}; + +static const uint8_t u8g_dev_st7920_202x32_sleep_off[] PROGMEM = { + U8G_ESC_ADR(0), /* instruction mode */ + U8G_ESC_CS(1), /* enable chip */ + 0x038, /* 8 Bit interface (DL=1), basic instruction set (RE=0) */ + 0x00c, /* display on, cursor & blink off */ + U8G_ESC_CS(0), /* disable chip */ + U8G_ESC_END /* end of sequence */ +}; + uint8_t u8g_dev_st7920_202x32_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg) { switch(msg) @@ -97,6 +117,12 @@ uint8_t u8g_dev_st7920_202x32_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void * u8g_SetChipSelect(u8g, dev, 0); } break; + case U8G_DEV_MSG_SLEEP_ON: + u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7920_202x32_sleep_on); + return 1; + case U8G_DEV_MSG_SLEEP_OFF: + u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7920_202x32_sleep_off); + return 1; } return u8g_dev_pb8h1_base_fn(u8g, dev, msg, arg); } @@ -135,6 +161,12 @@ uint8_t u8g_dev_st7920_202x32_4x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, voi u8g_SetChipSelect(u8g, dev, 0); } break; + case U8G_DEV_MSG_SLEEP_ON: + u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7920_202x32_sleep_on); + return 1; + case U8G_DEV_MSG_SLEEP_OFF: + u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7920_202x32_sleep_off); + return 1; } return u8g_dev_pb32h1_base_fn(u8g, dev, msg, arg); } diff --git a/csrc/u8g_dev_uc1610_dogxl160.c b/csrc/u8g_dev_uc1610_dogxl160.c index 4f361664..8524b588 100644 --- a/csrc/u8g_dev_uc1610_dogxl160.c +++ b/csrc/u8g_dev_uc1610_dogxl160.c @@ -123,7 +123,7 @@ uint8_t u8g_dev_uc1610_dogxl160_bw_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, v 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_WriteByte(u8g, dev, u8g_dev_1to2( ((uint8_t *)(pb->buf))[i] >> 4 ) ); } u8g_SetChipSelect(u8g, dev, 0); diff --git a/csrc/u8g_dev_uc1611_dogm240.c b/csrc/u8g_dev_uc1611_dogm240.c index ce33dca5..e0f66091 100644 --- a/csrc/u8g_dev_uc1611_dogm240.c +++ b/csrc/u8g_dev_uc1611_dogm240.c @@ -43,8 +43,16 @@ static const uint8_t u8g_dev_uc1611_dogm240_init_seq[] PROGMEM = { - U8G_ESC_CS(1), // enable chip + 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 @@ -96,15 +104,16 @@ uint8_t u8g_dev_uc1611_dogm240_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void u8g_SetAddress(u8g, dev, 1); /* data mode */ if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 ) return 0; - u8g_SetChipSelect(u8g, dev, 1); + u8g_SetChipSelect(u8g, dev, 0); } break; case U8G_DEV_MSG_CONTRAST: - u8g_SetChipSelect(u8g, dev, 0); + u8g_SetChipSelect(u8g, dev, 1); u8g_SetAddress(u8g, dev, 0); /* instruction mode */ u8g_WriteByte(u8g, dev, 0x81); - u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2); /* set contrast from, keep gain at 0 */ - u8g_SetChipSelect(u8g, dev, 1); + /* 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); diff --git a/csrc/u8g_dev_uc1611_dogxl240.c b/csrc/u8g_dev_uc1611_dogxl240.c index 6e66ff1d..1eaa4570 100644 --- a/csrc/u8g_dev_uc1611_dogxl240.c +++ b/csrc/u8g_dev_uc1611_dogxl240.c @@ -43,8 +43,17 @@ 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 @@ -96,15 +105,16 @@ static uint8_t u8g_dev_uc1611_dogxl240_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t ms u8g_SetAddress(u8g, dev, 1); /* data mode */ if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 ) return 0; - u8g_SetChipSelect(u8g, dev, 1); + u8g_SetChipSelect(u8g, dev, 0); } break; case U8G_DEV_MSG_CONTRAST: - u8g_SetChipSelect(u8g, dev, 0); + u8g_SetChipSelect(u8g, dev, 1); u8g_SetAddress(u8g, dev, 0); /* instruction mode */ u8g_WriteByte(u8g, dev, 0x81); - u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2); /* set contrast from, keep gain at 0 */ - u8g_SetChipSelect(u8g, dev, 1); + /* 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); diff --git a/csrc/u8g_dev_uc1701_dogs102.c b/csrc/u8g_dev_uc1701_dogs102.c index 5161ef95..cf51f50c 100644 --- a/csrc/u8g_dev_uc1701_dogs102.c +++ b/csrc/u8g_dev_uc1701_dogs102.c @@ -77,6 +77,24 @@ static const uint8_t u8g_dev_dogs102_data_start[] PROGMEM = { U8G_ESC_END /* end of sequence */ }; +static const uint8_t u8g_dev_dogs102_sleep_on[] PROGMEM = { + U8G_ESC_ADR(0), /* instruction mode */ + U8G_ESC_CS(1), /* enable chip */ + 0x0ae, /* display off */ + 0x0a5, /* enter powersafe: all pixel on */ + U8G_ESC_CS(0), /* disable chip */ + U8G_ESC_END /* end of sequence */ +}; + +static const uint8_t u8g_dev_dogs102_sleep_off[] PROGMEM = { + U8G_ESC_ADR(0), /* instruction mode */ + U8G_ESC_CS(1), /* enable chip */ + 0x0a4, /* display on */ + 0x0af, /* all pixel off */ + U8G_ESC_CS(0), /* disable chip */ + 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) @@ -105,6 +123,12 @@ uint8_t u8g_dev_dogs102_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg) 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_dogs102_sleep_on); + return 1; + case U8G_DEV_MSG_SLEEP_OFF: + u8g_WriteEscSeqP(u8g, dev, u8g_dev_dogs102_sleep_off); + return 1; } return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg); } @@ -143,6 +167,12 @@ uint8_t u8g_dev_uc1701_dogs102_2x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, vo 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_dogs102_sleep_on); + return 1; + case U8G_DEV_MSG_SLEEP_OFF: + u8g_WriteEscSeqP(u8g, dev, u8g_dev_dogs102_sleep_off); + return 1; } return u8g_dev_pb16v1_base_fn(u8g, dev, msg, arg); } diff --git a/csrc/u8g_dev_uc1701_mini12864.c b/csrc/u8g_dev_uc1701_mini12864.c index 209a7b93..489c60ca 100644 --- a/csrc/u8g_dev_uc1701_mini12864.c +++ b/csrc/u8g_dev_uc1701_mini12864.c @@ -79,6 +79,24 @@ static const uint8_t u8g_dev_uc1701_mini12864_data_start[] PROGMEM = { U8G_ESC_END /* end of sequence */ }; +static const uint8_t u8g_dev_uc1701_mini12864_sleep_on[] PROGMEM = { + U8G_ESC_ADR(0), /* instruction mode */ + U8G_ESC_CS(1), /* enable chip */ + 0x0ae, /* display off */ + 0x0a5, /* enter powersafe: all pixel on */ + U8G_ESC_CS(0), /* disable chip */ + U8G_ESC_END /* end of sequence */ +}; + +static const uint8_t u8g_dev_uc1701_mini12864_sleep_off[] PROGMEM = { + U8G_ESC_ADR(0), /* instruction mode */ + U8G_ESC_CS(1), /* enable chip */ + 0x0a4, /* display on */ + 0x0af, /* all pixel off */ + U8G_ESC_CS(0), /* disable chip */ + 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) @@ -107,6 +125,12 @@ uint8_t u8g_dev_uc1701_mini12864_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, voi 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_uc1701_mini12864_sleep_on); + return 1; + case U8G_DEV_MSG_SLEEP_OFF: + u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1701_mini12864_sleep_off); + return 1; } return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg); } @@ -145,6 +169,12 @@ uint8_t u8g_dev_uc1701_mini12864_2x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, 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_uc1701_mini12864_sleep_on); + return 1; + case U8G_DEV_MSG_SLEEP_OFF: + u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1701_mini12864_sleep_off); + return 1; } return u8g_dev_pb16v1_base_fn(u8g, dev, msg, arg); } diff --git a/csrc/u8g_rot.c b/csrc/u8g_rot.c index 3791675b..6df32834 100644 --- a/csrc/u8g_rot.c +++ b/csrc/u8g_rot.c @@ -40,7 +40,7 @@ uint8_t u8g_dev_rot90_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg); uint8_t u8g_dev_rot180_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg); uint8_t u8g_dev_rot270_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg); -uint8_t u8g_dev_rot_dummy_fn(void *u8g, void *dev, uint8_t msg, void *arg) +uint8_t u8g_dev_rot_dummy_fn(u8g_t *u8g, u8g_dev_t*dev, uint8_t msg, void *arg) { return 0; } diff --git a/csrc/u8g_state.c b/csrc/u8g_state.c index 9573c8bf..3621d933 100644 --- a/csrc/u8g_state.c +++ b/csrc/u8g_state.c @@ -75,7 +75,8 @@ uint8_t global_SREG_backup; /*===============================================================*/ /* AVR */ -#if defined(__AVR__) +#if defined(__AVR_XMEGA__) +#elif defined(__AVR__) #define U8G_ATMEGA_HW_SPI /* remove the definition for attiny */ diff --git a/doc/do_device_wiki.sh b/doc/do_device_wiki.sh old mode 100755 new mode 100644 diff --git a/download/bdf2u8g_101.exe b/download/bdf2u8g_101.exe old mode 100644 new mode 100755 diff --git a/download/u8glib_arduino_v1.17pre6.zip b/download/u8glib_arduino_v1.17pre6.zip new file mode 100644 index 00000000..996c842f Binary files /dev/null and b/download/u8glib_arduino_v1.17pre6.zip differ diff --git a/sfntsrc/u8g_font_data.c b/sfntsrc/u8g_font_data.c index 09108089..55557fe9 100644 --- a/sfntsrc/u8g_font_data.c +++ b/sfntsrc/u8g_font_data.c @@ -18731,49 +18731,6 @@ const u8g_fntpgm_uint8_t u8g_font_fub20r[4022] U8G_FONT_SECTION("u8g_font_fub20r 192,15,0,30,0,30,0,30,0,30,0,30,0,30,0,30, 0,30,0,124,0,252,0,240,0,14,3,6,14,0,5,63, 156,127,248,225,240,255}; -/* - Fontname: -FreeType-FreeUniversal-Bold-R-Normal--27-270-72-72-P-136-ISO10646-1 - Copyright: FreeUniveral (c) Stephen Wilson 2009 Original Font Sil-Sophia Copyright (c) SIL International, 1994-2008. - Capital A Height: 0, '1' Height: 20 - Calculated Max Values w=14 h=20 x= 4 y= 0 dx=15 dy= 0 ascent=20 len=40 - Font Bounding box w=40 h=36 x=-2 y=-7 - Calculated Min Values x= 0 y= 0 dx= 0 dy= 0 - Pure Font ascent =20 descent= 0 - X Font ascent =20 descent= 0 - Max Font ascent =20 descent= 0 -*/ -#include "u8g.h" -const u8g_fntpgm_uint8_t u8g_font_fub20t[477] U8G_SECTION(".progmem.u8g_font_fub20t") = { - 0,40,36,254,249,20,0,0,0,0,48,58,0,20,0,20, - 0,14,20,40,15,1,0,15,128,31,224,60,240,120,112,112, - 56,240,56,240,56,240,60,240,60,240,60,240,60,240,60,240, - 60,240,56,240,56,112,56,120,120,60,240,31,224,15,128,8, - 20,20,15,3,0,15,63,127,255,239,207,15,15,15,15,15, - 15,15,15,15,15,15,15,15,15,14,20,40,15,1,0,7, - 192,31,240,63,248,124,120,120,60,120,60,0,60,0,120,0, - 120,0,240,1,240,3,224,7,192,15,128,31,0,124,0,248, - 0,255,252,255,252,255,252,13,20,40,15,1,0,15,128,63, - 224,127,240,248,240,240,120,0,120,0,120,0,240,15,224,15, - 128,15,224,0,240,0,120,0,120,240,120,240,120,248,240,127, - 240,63,224,31,128,14,20,40,15,1,0,1,240,3,240,3, - 240,7,240,7,240,14,240,30,240,28,240,60,240,56,240,120, - 240,112,240,240,240,255,252,255,252,255,252,0,240,0,240,0, - 240,0,240,13,20,40,15,1,0,255,240,255,240,255,240,240, - 0,240,0,240,0,240,0,247,192,255,224,253,240,240,120,240, - 120,0,120,0,120,0,120,240,120,240,240,127,240,63,224,31, - 128,13,20,40,15,1,0,15,192,31,224,63,240,120,120,120, - 120,112,0,240,0,247,192,239,224,253,240,248,120,240,120,240, - 120,240,120,240,120,112,120,120,240,63,240,63,224,15,128,13, - 20,40,15,1,0,255,248,255,248,255,248,0,120,0,120,0, - 240,0,240,1,224,1,224,1,224,3,192,3,192,7,128,7, - 128,15,128,15,0,31,0,30,0,30,0,62,0,14,20,40, - 15,1,0,31,192,63,240,127,240,120,248,240,120,240,120,240, - 120,120,240,63,224,31,192,63,240,120,120,240,56,240,60,240, - 60,240,60,248,120,127,248,63,240,31,192,13,20,40,15,1, - 0,15,128,63,192,127,224,120,240,240,112,240,120,240,120,240, - 120,240,120,120,248,127,184,63,56,0,120,0,120,0,112,240, - 240,120,240,127,224,63,192,15,128,4,14,14,9,4,0,240, - 240,240,240,0,0,0,0,0,0,240,240,240,240}; /* Fontname: -FreeType-FreeUniversal-Bold-R-Normal--34-340-72-72-P-170-ISO10646-1 Copyright: FreeUniveral (c) Stephen Wilson 2009 Original Font Sil-Sophia Copyright (c) SIL International, 1994-2008. @@ -45380,34 +45337,6 @@ const u8g_fntpgm_uint8_t u8g_font_helvR08[2687] U8G_FONT_SECTION("u8g_font_helvR 11,5,255,254,8,16,0,72,72,80,80,48,32,32,192,5, 10,10,6,0,254,128,128,176,200,136,136,200,176,128,128,5, 10,10,5,255,254,80,0,72,72,80,80,48,32,32,192}; -/* - Fontname: -Adobe-Helvetica-Medium-R-Normal--11-80-100-100-P-56-ISO10646-1 - Copyright: Copyright (c) 1984, 1987 Adobe Systems Incorporated. All Rights Reserved. Copyright (c) 1988, 1991 Digital Equipment Corporation. All Rights Reserved. - Capital A Height: 0, '1' Height: 8 - Calculated Max Values w= 5 h= 8 x= 1 y= 5 dx= 6 dy= 0 ascent= 8 len= 8 - Font Bounding box w=13 h=18 x=-2 y=-4 - Calculated Min Values x= 0 y=-2 dx= 0 dy= 0 - Pure Font ascent = 8 descent= 0 - X Font ascent = 8 descent= 0 - Max Font ascent = 8 descent=-2 -*/ -#include "u8g.h" -const u8g_fntpgm_uint8_t u8g_font_helvR08n[226] U8G_FONT_SECTION("u8g_font_helvR08n") = { - 0,13,18,254,252,8,0,0,0,0,42,58,0,8,254,8, - 0,3,3,3,4,0,5,160,64,160,5,5,5,6,0,1, - 32,32,248,32,32,2,3,3,3,0,254,64,64,128,3,1, - 1,4,0,3,224,1,1,1,3,1,0,128,3,8,8,3, - 0,0,32,32,64,64,64,64,128,128,5,8,8,6,0,0, - 112,136,136,136,136,136,136,112,2,8,8,6,1,0,64,192, - 64,64,64,64,64,64,5,8,8,6,0,0,112,136,8,8, - 48,64,128,248,5,8,8,6,0,0,112,136,8,48,8,8, - 136,112,5,8,8,6,0,0,16,48,80,80,144,248,16,16, - 5,8,8,6,0,0,120,64,64,112,8,8,136,112,5,8, - 8,6,0,0,112,136,128,240,136,136,136,112,5,8,8,6, - 0,0,248,8,16,32,32,64,64,64,5,8,8,6,0,0, - 112,136,136,112,136,136,136,112,5,8,8,6,0,0,112,136, - 136,136,120,8,136,112,1,6,6,3,1,0,128,0,0,0, - 0,128}; /* Fontname: -Adobe-Helvetica-Medium-R-Normal--11-80-100-100-P-56-ISO10646-1 Copyright: Copyright (c) 1984, 1987 Adobe Systems Incorporated. All Rights Reserved. Copyright (c) 1988, 1991 Digital Equipment Corporation. All Rights Reserved. @@ -45735,36 +45664,6 @@ const u8g_fntpgm_uint8_t u8g_font_helvR10[3527] U8G_FONT_SECTION("u8g_font_helvR 14,14,8,1,253,128,128,128,184,204,132,132,132,132,204,184, 128,128,128,7,14,14,7,0,253,36,36,0,130,194,68,68, 36,40,24,16,16,48,96}; -/* - Fontname: -Adobe-Helvetica-Medium-R-Normal--14-100-100-100-P-76-ISO10646-1 - Copyright: Copyright (c) 1984, 1987 Adobe Systems Incorporated. All Rights Reserved. Copyright (c) 1988, 1991 Digital Equipment Corporation. All Rights Reserved. - Capital A Height: 0, '1' Height: 11 - Calculated Max Values w= 7 h=11 x= 2 y= 6 dx= 9 dy= 0 ascent=11 len=11 - Font Bounding box w=17 h=22 x=-2 y=-5 - Calculated Min Values x= 0 y=-2 dx= 0 dy= 0 - Pure Font ascent =11 descent= 0 - X Font ascent =11 descent= 0 - Max Font ascent =11 descent=-2 -*/ -#include "u8g.h" -const u8g_fntpgm_uint8_t u8g_font_helvR10n[267] U8G_FONT_SECTION("u8g_font_helvR10n") = { - 0,17,22,254,251,11,0,0,0,0,42,58,0,11,254,11, - 0,5,5,5,7,1,6,32,168,112,168,32,7,7,7,9, - 1,1,16,16,16,254,16,16,16,2,4,4,3,0,254,64, - 64,64,128,3,1,1,4,0,4,224,1,2,2,3,1,0, - 128,128,4,11,11,4,0,0,16,16,32,32,32,64,64,64, - 128,128,128,6,11,11,8,1,0,120,132,132,132,132,132,132, - 132,132,132,120,3,11,11,8,2,0,32,224,32,32,32,32, - 32,32,32,32,32,6,11,11,8,1,0,120,132,132,4,8, - 16,32,64,128,128,252,6,11,11,8,1,0,120,132,132,4, - 4,56,4,4,132,132,120,7,11,11,8,1,0,4,12,20, - 36,68,132,132,254,4,4,4,6,11,11,8,1,0,252,128, - 128,128,248,4,4,4,132,132,120,6,11,11,8,1,0,120, - 132,128,128,184,196,132,132,132,132,120,6,11,11,8,1,0, - 252,4,8,8,16,16,32,32,64,64,64,6,11,11,8,1, - 0,120,132,132,132,132,120,132,132,132,132,120,6,11,11,8, - 1,0,120,132,132,132,132,124,4,4,132,132,120,1,8,8, - 3,1,0,128,128,0,0,0,0,128,128}; /* Fontname: -Adobe-Helvetica-Medium-R-Normal--14-100-100-100-P-76-ISO10646-1 Copyright: Copyright (c) 1984, 1987 Adobe Systems Incorporated. All Rights Reserved. Copyright (c) 1988, 1991 Digital Equipment Corporation. All Rights Reserved. @@ -46150,38 +46049,6 @@ const u8g_fntpgm_uint8_t u8g_font_helvR12[4077] U8G_FONT_SECTION("u8g_font_helvR 32,192,7,16,16,9,1,252,128,128,128,184,196,130,130,130, 130,130,196,184,128,128,128,128,7,15,15,8,0,253,40,40, 0,130,130,68,68,40,40,56,16,16,32,32,192}; -/* - Fontname: -Adobe-Helvetica-Medium-R-Normal--17-120-100-100-P-88-ISO10646-1 - Copyright: Copyright (c) 1984, 1987 Adobe Systems Incorporated. All Rights Reserved. Copyright (c) 1988, 1991 Digital Equipment Corporation. All Rights Reserved. - Capital A Height: 0, '1' Height: 12 - Calculated Max Values w= 9 h=12 x= 3 y= 7 dx=10 dy= 0 ascent=12 len=18 - Font Bounding box w=20 h=26 x=-2 y=-6 - Calculated Min Values x= 0 y=-2 dx= 0 dy= 0 - Pure Font ascent =12 descent= 0 - X Font ascent =12 descent= 0 - Max Font ascent =12 descent=-2 -*/ -#include "u8g.h" -const u8g_fntpgm_uint8_t u8g_font_helvR12n[290] U8G_FONT_SECTION("u8g_font_helvR12n") = { - 0,20,26,254,250,12,0,0,0,0,42,58,0,12,254,12, - 0,5,5,5,6,0,7,32,168,112,80,136,9,9,18,10, - 0,0,8,0,8,0,8,0,8,0,255,128,8,0,8,0, - 8,0,8,0,2,4,4,4,1,254,64,64,64,128,4,1, - 1,5,0,4,240,1,2,2,4,2,0,128,128,4,12,12, - 5,0,0,16,16,32,32,32,32,64,64,64,128,128,128,7, - 12,12,9,1,0,56,68,68,130,130,130,130,130,130,68,68, - 56,3,12,12,9,3,0,32,32,96,160,32,32,32,32,32, - 32,32,32,7,12,12,9,1,0,56,68,130,130,2,4,8, - 48,64,128,128,254,7,12,12,9,1,0,56,68,130,130,4, - 56,4,2,130,130,68,56,8,12,12,9,0,0,12,20,20, - 36,36,68,68,132,255,4,4,4,7,12,12,9,1,0,62, - 32,32,64,120,68,2,2,2,130,68,56,7,12,12,9,1, - 0,60,66,130,128,184,196,130,130,130,130,68,56,8,12,12, - 9,0,0,255,1,2,4,4,8,8,16,16,16,32,32,7, - 12,12,9,1,0,56,68,130,130,68,56,68,130,130,130,68, - 56,7,12,12,9,1,0,56,68,130,130,130,130,70,58,2, - 130,132,120,1,9,9,4,2,0,128,128,0,0,0,0,0, - 128,128}; /* Fontname: -Adobe-Helvetica-Medium-R-Normal--17-120-100-100-P-88-ISO10646-1 Copyright: Copyright (c) 1984, 1987 Adobe Systems Incorporated. All Rights Reserved. Copyright (c) 1988, 1991 Digital Equipment Corporation. All Rights Reserved. @@ -46636,39 +46503,6 @@ const u8g_fntpgm_uint8_t u8g_font_helvR14[4920] U8G_FONT_SECTION("u8g_font_helvR 193,128,227,0,255,0,222,0,192,0,192,0,192,0,192,0, 8,18,18,10,1,252,102,102,0,0,195,195,195,102,102,102, 36,60,24,24,24,24,112,112}; -/* - Fontname: -Adobe-Helvetica-Medium-R-Normal--20-140-100-100-P-100-ISO10646-1 - Copyright: Copyright (c) 1984, 1987 Adobe Systems Incorporated. All Rights Reserved. Copyright (c) 1988, 1991 Digital Equipment Corporation. All Rights Reserved. - Capital A Height: 0, '1' Height: 13 - Calculated Max Values w= 9 h=14 x= 2 y= 7 dx=10 dy= 0 ascent=14 len=26 - Font Bounding box w=22 h=29 x=-2 y=-7 - Calculated Min Values x= 0 y=-3 dx= 0 dy= 0 - Pure Font ascent =13 descent= 0 - X Font ascent =13 descent= 0 - Max Font ascent =14 descent=-3 -*/ -#include "u8g.h" -const u8g_fntpgm_uint8_t u8g_font_helvR14n[311] U8G_FONT_SECTION("u8g_font_helvR14n") = { - 0,22,29,254,249,13,0,0,0,0,42,58,0,14,253,13, - 0,5,7,7,7,1,7,32,168,248,32,248,168,32,8,10, - 10,10,1,0,24,24,24,24,255,255,24,24,24,24,2,5, - 5,5,1,253,192,192,64,64,128,5,1,1,6,0,5,248, - 2,2,2,5,1,0,192,192,5,14,14,5,0,0,24,24, - 24,24,48,48,48,96,96,96,192,192,192,192,8,13,13,10, - 1,0,60,126,102,195,195,195,195,195,195,195,102,126,60,5, - 13,13,10,2,0,24,248,248,24,24,24,24,24,24,24,24, - 24,24,8,13,13,10,1,0,60,254,195,3,7,14,28,56, - 112,224,192,255,255,8,13,13,10,1,0,62,127,195,195,6, - 28,30,7,3,195,199,126,60,9,13,26,10,0,0,3,0, - 7,0,15,0,27,0,51,0,51,0,99,0,195,0,255,128, - 255,128,3,0,3,0,3,0,8,13,13,10,1,0,254,254, - 192,192,252,254,199,3,3,195,199,254,124,8,13,13,10,1, - 0,60,127,99,192,192,220,254,195,195,195,227,126,60,8,13, - 13,10,1,0,255,255,3,6,12,12,24,24,48,48,96,96, - 96,8,13,13,10,1,0,60,126,231,195,195,102,126,231,195, - 195,231,126,60,8,13,13,10,1,0,60,126,199,195,195,195, - 127,59,3,3,198,254,124,2,10,10,5,1,0,192,192,0, - 0,0,0,0,0,192,192}; /* Fontname: -Adobe-Helvetica-Medium-R-Normal--20-140-100-100-P-100-ISO10646-1 Copyright: Copyright (c) 1984, 1987 Adobe Systems Incorporated. All Rights Reserved. Copyright (c) 1988, 1991 Digital Equipment Corporation. All Rights Reserved. @@ -47295,53 +47129,6 @@ const u8g_fntpgm_uint8_t u8g_font_helvR18[7307] U8G_FONT_SECTION("u8g_font_helvR 128,0,0,0,0,192,48,192,48,96,48,112,96,48,96,56, 224,24,192,24,192,13,128,13,128,7,128,7,0,3,0,3, 0,6,0,6,0,12,0,60,0,56,0}; -/* - Fontname: -Adobe-Helvetica-Medium-R-Normal--25-180-100-100-P-130-ISO10646-1 - Copyright: Copyright (c) 1984, 1987 Adobe Systems Incorporated. All Rights Reserved. Copyright (c) 1988, 1991 Digital Equipment Corporation. All Rights Reserved. - Capital A Height: 0, '1' Height: 18 - Calculated Max Values w=12 h=19 x= 2 y=12 dx=14 dy= 0 ascent=19 len=36 - Font Bounding box w=28 h=37 x=-3 y=-8 - Calculated Min Values x= 0 y=-3 dx= 0 dy= 0 - Pure Font ascent =18 descent= 0 - X Font ascent =18 descent= 0 - Max Font ascent =19 descent=-3 -*/ -#include "u8g.h" -const u8g_fntpgm_uint8_t u8g_font_helvR18n[536] U8G_FONT_SECTION("u8g_font_helvR18n") = { - 0,28,37,253,248,18,0,0,0,0,42,58,0,19,253,18, - 0,7,7,7,10,1,12,16,16,214,124,56,108,68,12,12, - 24,14,1,1,6,0,6,0,6,0,6,0,6,0,255,240, - 255,240,6,0,6,0,6,0,6,0,6,0,2,6,6,6, - 2,253,192,192,192,64,64,128,6,2,2,8,1,6,252,252, - 2,3,3,6,2,0,192,192,192,7,19,19,7,0,0,6, - 4,12,12,8,24,24,16,16,48,48,32,96,96,64,192,192, - 128,128,11,18,36,13,1,0,31,0,63,128,113,192,96,192, - 96,192,224,224,192,96,192,96,192,96,192,96,192,96,192,96, - 224,224,96,192,96,192,113,192,63,128,31,0,6,18,18,13, - 2,0,12,12,28,252,252,12,12,12,12,12,12,12,12,12, - 12,12,12,12,11,18,36,13,1,0,30,0,127,128,97,192, - 192,192,192,96,192,96,0,224,0,192,1,192,3,128,15,0, - 28,0,56,0,112,0,224,0,192,0,255,224,255,224,11,18, - 36,13,1,0,31,0,127,128,97,128,192,192,192,192,192,192, - 0,192,1,128,15,0,15,192,0,192,0,96,0,96,192,96, - 192,192,97,192,127,128,31,0,11,18,36,13,1,0,1,128, - 3,128,3,128,7,128,15,128,13,128,25,128,57,128,49,128, - 97,128,225,128,193,128,255,224,255,224,1,128,1,128,1,128, - 1,128,11,18,36,13,1,0,127,192,127,192,96,0,96,0, - 96,0,96,0,126,0,127,128,113,192,0,192,0,224,0,96, - 0,96,192,224,192,192,225,192,127,128,30,0,11,18,36,13, - 1,0,15,0,63,192,112,192,96,96,224,96,192,0,192,0, - 207,0,223,128,241,192,224,192,192,96,192,96,192,96,224,224, - 113,192,127,192,31,0,11,18,36,13,1,0,255,224,255,224, - 0,224,0,192,1,128,1,128,3,0,3,0,6,0,6,0, - 12,0,12,0,28,0,24,0,24,0,56,0,48,0,48,0, - 11,18,36,13,1,0,14,0,63,128,49,128,96,192,96,192, - 96,192,49,128,31,0,63,128,113,192,96,192,192,96,192,96, - 192,96,192,96,96,192,127,192,31,0,11,18,36,13,1,0, - 31,0,127,192,113,192,224,192,192,96,192,96,192,96,192,96, - 224,224,113,224,127,96,30,96,0,96,0,224,192,192,225,192, - 127,128,30,0,2,14,14,6,2,0,192,192,192,0,0,0, - 0,0,0,0,0,192,192,192}; /* Fontname: -Adobe-Helvetica-Medium-R-Normal--25-180-100-100-P-130-ISO10646-1 Copyright: Copyright (c) 1984, 1987 Adobe Systems Incorporated. All Rights Reserved. Copyright (c) 1988, 1991 Digital Equipment Corporation. All Rights Reserved. @@ -83974,557 +83761,6 @@ const u8g_fntpgm_uint8_t u8g_font_u8glib_4r[664] U8G_FONT_SECTION("u8g_font_u8gl 1,54,70,96,64,128,128,64,96,1,22,38,128,128,128,128, 128,128,1,54,70,192,64,32,32,64,192,5,66,82,80,160, 2,69,85,240,144,144,144,240}; -/* - Fontname: -gnu-unifont-medium-r-normal--16-160-75-75-c-80-iso10646-1 - Copyright: - Capital A Height: 10, '1' Height: 10 - Calculated Max Values w=16 h=16 x= 4 y=14 dx=16 dy= 0 ascent=14 len=32 - Font Bounding box w=16 h=16 x= 0 y=-2 - Calculated Min Values x= 0 y=-2 dx= 0 dy= 0 - Pure Font ascent =10 descent=-2 - X Font ascent =11 descent=-2 - Max Font ascent =14 descent=-2 -*/ -#include "u8g.h" -const u8g_fntpgm_uint8_t u8g_font_unifont_0_10[5136] U8G_FONT_SECTION("u8g_font_unifont_0_10") = { - 0,16,16,0,254,10,5,43,7,25,10,255,254,14,254,11, - 254,16,16,32,16,0,254,170,170,0,1,128,0,0,1,128, - 0,65,241,193,0,65,241,193,0,125,1,128,0,0,1,128, - 0,0,1,128,0,85,85,16,16,32,16,0,254,170,170,0, - 1,128,0,0,1,128,0,69,241,196,64,68,65,168,64,16, - 65,128,0,0,1,128,0,0,1,128,0,85,85,16,16,32, - 16,0,254,170,170,0,1,128,0,0,1,128,0,125,241,193, - 0,125,241,193,0,65,1,128,0,0,1,128,0,0,1,128, - 0,85,85,16,16,32,16,0,254,170,170,0,1,128,0,0, - 1,128,0,61,225,193,16,65,225,193,32,61,17,128,0,0, - 1,128,0,0,1,128,0,85,85,16,16,32,16,0,254,170, - 170,0,1,128,0,0,1,128,0,60,225,193,16,57,17,133, - 16,120,225,128,0,0,1,128,0,0,1,128,0,85,85,16, - 16,32,16,0,254,170,170,0,1,128,0,0,1,128,0,61, - 241,192,64,56,65,132,64,121,241,128,0,0,1,128,0,0, - 1,128,0,85,85,16,16,32,16,0,254,170,170,0,1,128, - 0,0,1,128,0,114,57,202,32,74,57,202,32,115,185,128, - 0,0,1,128,0,0,1,128,0,85,85,16,16,32,16,0, - 254,170,170,0,1,128,0,0,1,128,0,113,137,202,24,74, - 9,202,8,113,157,128,0,0,1,128,0,0,1,128,0,85, - 85,16,16,32,16,0,254,170,170,0,1,128,0,0,1,128, - 0,113,153,202,4,74,9,202,16,113,157,128,0,0,1,128, - 0,0,1,128,0,85,85,16,16,32,16,0,254,170,170,0, - 1,128,0,0,1,128,0,113,153,202,4,74,25,202,4,113, - 153,128,0,0,1,128,0,0,1,128,0,85,85,16,16,32, - 16,0,254,170,170,0,1,128,0,0,1,128,0,113,133,202, - 12,74,21,202,28,113,133,128,0,0,1,128,0,0,1,128, - 0,85,85,16,16,32,16,0,254,170,170,0,1,128,0,0, - 1,128,0,73,147,234,84,106,89,219,212,74,83,128,0,0, - 1,128,0,0,1,128,0,85,85,16,16,32,16,0,254,170, - 170,0,1,128,0,0,1,128,0,52,83,194,154,49,23,137, - 18,113,19,128,0,0,1,128,0,0,1,128,0,85,85,16, - 16,32,16,0,254,170,170,0,1,128,0,0,1,128,0,123, - 185,193,36,121,57,193,36,121,57,128,0,0,1,128,0,0, - 1,128,0,85,85,16,16,32,16,0,254,170,170,0,1,128, - 0,0,1,128,0,51,37,196,180,71,173,196,164,52,165,128, - 0,0,1,128,0,0,1,128,0,85,85,16,16,32,16,0, - 254,170,170,0,1,128,0,0,1,128,0,125,17,193,176,125, - 81,193,16,125,17,128,0,0,1,128,0,0,1,128,0,85, - 85,16,16,32,16,0,254,170,170,0,1,128,0,0,1,128, - 0,58,93,194,82,50,93,138,82,113,157,128,0,0,1,128, - 0,0,1,128,0,85,85,16,16,32,16,0,254,170,170,0, - 1,128,0,0,1,128,0,121,207,194,16,121,145,192,80,123, - 143,128,0,0,1,128,0,0,1,128,0,85,85,16,16,32, - 16,0,254,170,170,0,1,128,0,0,1,128,0,121,193,194, - 0,121,129,192,64,67,129,128,0,0,1,128,0,0,1,128, - 0,85,85,16,16,32,16,0,254,170,170,0,1,128,0,0, - 1,128,0,57,193,194,0,89,129,200,64,59,129,128,0,0, - 1,128,0,0,1,128,0,85,85,16,16,32,16,0,254,170, - 170,0,1,128,0,0,1,128,0,113,193,202,0,113,129,208, - 64,75,129,128,0,0,1,128,0,0,1,128,0,85,85,16, - 16,32,16,0,254,170,170,0,1,128,0,0,1,128,0,73, - 193,202,0,73,129,200,64,51,129,128,0,0,1,128,0,0, - 1,128,0,85,85,0,0,0,8,0,14,1,10,10,8,4, - 0,128,128,128,128,128,128,128,0,128,128,5,4,4,8,2, - 8,136,136,136,136,6,10,10,8,1,0,36,36,36,252,72, - 72,252,144,144,144,7,10,10,8,1,0,16,124,146,144,112, - 28,18,146,124,16,7,10,10,8,1,0,98,148,148,104,16, - 16,44,82,82,140,7,10,10,8,1,0,56,68,68,68,56, - 114,138,132,140,114,1,4,4,8,4,8,128,128,128,128,3, - 12,12,8,3,255,32,64,64,128,128,128,128,128,128,64,64, - 32,3,12,12,8,2,255,128,64,64,32,32,32,32,32,32, - 64,64,128,7,7,7,8,1,1,16,146,84,56,84,146,16, - 7,7,7,8,1,1,16,16,16,254,16,16,16,2,4,4, - 8,3,254,192,64,64,128,6,1,1,8,1,4,252,2,2, - 2,8,3,0,192,192,6,10,10,8,1,0,4,4,8,16, - 16,32,32,64,128,128,6,10,10,8,1,0,48,72,132,132, - 132,132,132,132,72,48,5,10,10,8,2,0,32,96,160,32, - 32,32,32,32,32,248,6,10,10,8,1,0,120,132,132,4, - 24,32,64,128,128,252,6,10,10,8,1,0,120,132,132,4, - 56,4,4,132,132,120,6,10,10,8,1,0,8,24,40,72, - 136,136,252,8,8,8,6,10,10,8,1,0,252,128,128,128, - 248,4,4,4,132,120,6,10,10,8,1,0,56,64,128,128, - 248,132,132,132,132,120,6,10,10,8,1,0,252,4,4,8, - 8,8,16,16,16,16,6,10,10,8,1,0,120,132,132,132, - 120,132,132,132,132,120,6,10,10,8,1,0,120,132,132,132, - 124,4,4,4,8,112,2,7,7,8,3,1,192,192,0,0, - 0,192,192,2,9,9,8,3,255,192,192,0,0,0,192,64, - 64,128,5,9,9,8,2,0,8,16,32,64,128,64,32,16, - 8,6,5,5,8,1,2,252,0,0,0,252,5,9,9,8, - 1,0,128,64,32,16,8,16,32,64,128,6,10,10,8,1, - 0,120,132,132,4,8,16,16,0,16,16,6,10,10,8,1, - 0,56,68,148,172,164,164,164,156,64,60,6,10,10,8,1, - 0,48,72,72,132,132,252,132,132,132,132,6,10,10,8,1, - 0,248,132,132,132,248,132,132,132,132,248,6,10,10,8,1, - 0,120,132,132,128,128,128,128,132,132,120,6,10,10,8,1, - 0,240,136,132,132,132,132,132,132,136,240,6,10,10,8,1, - 0,252,128,128,128,248,128,128,128,128,252,6,10,10,8,1, - 0,252,128,128,128,248,128,128,128,128,128,6,10,10,8,1, - 0,120,132,132,128,128,156,132,132,140,116,6,10,10,8,1, - 0,132,132,132,132,252,132,132,132,132,132,5,10,10,8,2, - 0,248,32,32,32,32,32,32,32,32,248,7,10,10,8,1, - 0,62,8,8,8,8,8,8,136,136,112,6,10,10,8,1, - 0,132,136,144,160,192,192,160,144,136,132,6,10,10,8,1, - 0,128,128,128,128,128,128,128,128,128,252,6,10,10,8,1, - 0,132,132,204,204,180,180,132,132,132,132,6,10,10,8,1, - 0,132,196,196,164,164,148,148,140,140,132,6,10,10,8,1, - 0,120,132,132,132,132,132,132,132,132,120,6,10,10,8,1, - 0,248,132,132,132,248,128,128,128,128,128,7,11,11,8,1, - 255,120,132,132,132,132,132,132,180,204,120,6,6,10,10,8, - 1,0,248,132,132,132,248,144,136,136,132,132,6,10,10,8, - 1,0,120,132,132,128,96,24,4,132,132,120,7,10,10,8, - 1,0,254,16,16,16,16,16,16,16,16,16,6,10,10,8, - 1,0,132,132,132,132,132,132,132,132,132,120,7,10,10,8, - 1,0,130,130,130,68,68,68,40,40,16,16,6,10,10,8, - 1,0,132,132,132,132,180,180,204,204,132,132,6,10,10,8, - 1,0,132,132,72,72,48,48,72,72,132,132,7,10,10,8, - 1,0,130,130,68,68,40,16,16,16,16,16,6,10,10,8, - 1,0,252,4,4,8,16,32,64,128,128,252,3,12,12,8, - 4,255,224,128,128,128,128,128,128,128,128,128,128,224,6,10, - 10,8,1,0,128,128,64,32,32,16,16,8,4,4,3,12, - 12,8,1,255,224,32,32,32,32,32,32,32,32,32,32,224, - 6,3,3,8,1,9,48,72,132,7,1,1,8,1,255,254, - 3,3,3,8,2,10,128,64,32,6,8,8,8,1,0,120, - 132,4,124,132,132,140,116,6,11,11,8,1,0,128,128,128, - 184,196,132,132,132,132,196,184,6,8,8,8,1,0,120,132, - 128,128,128,128,132,120,6,11,11,8,1,0,4,4,4,116, - 140,132,132,132,132,140,116,6,8,8,8,1,0,120,132,132, - 252,128,128,132,120,5,11,11,8,1,0,24,32,32,32,248, - 32,32,32,32,32,32,6,11,11,8,1,254,4,116,136,136, - 136,112,64,120,132,132,120,6,11,11,8,1,0,128,128,128, - 184,196,132,132,132,132,132,132,5,11,11,8,2,0,32,32, - 0,96,32,32,32,32,32,32,248,5,13,13,8,1,254,8, - 8,0,24,8,8,8,8,8,8,8,144,96,6,10,10,8, - 1,0,128,128,136,144,160,192,160,144,136,132,5,10,10,8, - 2,0,96,32,32,32,32,32,32,32,32,248,7,8,8,8, - 1,0,236,146,146,146,146,146,146,146,6,8,8,8,1,0, - 184,196,132,132,132,132,132,132,6,8,8,8,1,0,120,132, - 132,132,132,132,132,120,6,10,10,8,1,254,184,196,132,132, - 132,132,196,184,128,128,6,10,10,8,1,254,116,140,132,132, - 132,132,140,116,4,4,6,8,8,8,1,0,184,196,132,128, - 128,128,128,128,6,8,8,8,1,0,120,132,128,96,24,4, - 132,120,5,10,10,8,1,0,32,32,248,32,32,32,32,32, - 32,24,6,8,8,8,1,0,132,132,132,132,132,132,140,116, - 6,8,8,8,1,0,132,132,132,72,72,72,48,48,7,8, - 8,8,1,0,130,146,146,146,146,146,146,108,6,8,8,8, - 1,0,132,132,72,48,48,72,132,132,6,10,10,8,1,254, - 132,132,132,132,132,76,52,4,4,120,6,8,8,8,1,0, - 252,4,8,16,32,64,128,252,3,12,12,8,3,255,96,128, - 128,64,64,128,128,64,64,128,128,96,1,14,14,8,4,254, - 128,128,128,128,128,128,128,128,128,128,128,128,128,128,3,12, - 12,8,2,255,192,32,32,64,64,32,32,64,64,32,32,192, - 7,3,3,8,1,8,98,146,140,16,16,32,16,0,254,170, - 170,0,1,128,0,0,1,128,0,115,209,202,16,75,209,202, - 16,115,223,128,0,0,1,128,0,0,1,128,0,85,85,16, - 16,32,16,0,254,170,170,0,1,128,0,0,1,128,0,113, - 157,202,82,115,211,194,82,66,93,128,0,0,1,128,0,0, - 1,128,0,85,85,16,16,32,16,0,254,170,170,0,1,128, - 0,0,1,128,0,73,157,202,82,122,93,202,80,73,145,128, - 0,0,1,128,0,0,1,128,0,85,85,16,16,32,16,0, - 254,170,170,0,1,128,0,0,1,128,0,115,147,202,82,115, - 159,202,18,114,19,128,0,0,1,128,0,0,1,128,0,85, - 85,16,16,32,16,0,254,170,170,0,1,128,0,0,1,128, - 0,75,147,234,82,91,159,202,82,75,147,128,0,0,1,128, - 0,0,1,128,0,85,85,16,16,32,16,0,254,170,170,0, - 1,128,0,0,1,128,0,116,185,166,164,37,165,164,164,116, - 185,128,0,0,1,128,0,0,1,128,0,85,85,16,16,32, - 16,0,254,170,170,0,1,128,0,0,1,128,0,75,209,234, - 16,91,209,202,16,75,223,128,0,0,1,128,0,0,1,128, - 0,85,85,16,16,32,16,0,254,170,170,0,1,128,0,0, - 1,128,0,57,205,194,18,49,159,136,82,115,147,128,0,0, - 1,128,0,0,1,128,0,85,85,16,16,32,16,0,254,170, - 170,0,1,128,0,0,1,128,0,121,205,194,18,121,159,192, - 82,123,147,128,0,0,1,128,0,0,1,128,0,85,85,16, - 16,32,16,0,254,170,170,0,1,128,0,0,1,128,0,75, - 157,201,32,121,25,201,4,73,57,128,0,0,1,128,0,0, - 1,128,0,85,85,16,16,32,16,0,254,170,170,0,1,128, - 0,0,1,128,0,75,185,201,8,121,9,201,8,73,49,128, - 0,0,1,128,0,0,1,128,0,85,85,16,16,32,16,0, - 254,170,170,0,1,128,0,0,1,128,0,69,205,196,144,68, - 137,168,132,16,153,128,0,0,1,128,0,0,1,128,0,85, - 85,16,16,32,16,0,254,170,170,0,1,128,0,0,1,128, - 0,114,29,202,18,114,19,194,18,67,221,128,0,0,1,128, - 0,0,1,128,0,85,85,16,16,32,16,0,254,170,170,0, - 1,128,0,0,1,128,0,114,19,202,18,114,19,194,18,67, - 205,128,0,0,1,128,0,0,1,128,0,85,85,16,16,32, - 16,0,254,170,170,0,1,128,0,0,1,128,0,14,33,137, - 32,14,33,138,32,9,33,128,0,0,1,128,0,0,1,128, - 0,85,85,16,16,32,16,0,254,170,170,0,1,128,0,0, - 1,128,0,57,221,194,2,49,141,136,80,115,159,128,0,0, - 1,128,0,0,1,128,0,85,85,16,16,32,16,0,254,170, - 170,0,1,128,0,0,1,128,0,57,221,194,2,49,141,136, - 66,115,157,128,0,0,1,128,0,0,1,128,0,85,85,16, - 16,32,16,0,254,170,170,0,1,128,0,0,1,128,0,113, - 207,202,16,74,13,202,2,113,221,128,0,0,1,128,0,0, - 1,128,0,85,85,16,16,32,16,0,254,170,170,0,1,128, - 0,0,1,128,0,114,69,202,76,114,69,194,68,65,143,128, - 0,0,1,128,0,0,1,128,0,85,85,16,16,32,16,0, - 254,170,170,0,1,128,0,0,1,128,0,114,93,202,66,114, - 77,194,80,65,159,128,0,0,1,128,0,0,1,128,0,85, - 85,16,16,32,16,0,254,170,170,0,1,128,0,0,1,128, - 0,59,157,193,32,49,25,137,4,113,57,128,0,0,1,128, - 0,0,1,128,0,85,85,16,16,32,16,0,254,170,170,0, - 1,128,0,0,1,128,0,57,211,194,18,66,31,194,18,57, - 211,128,0,0,1,128,0,0,1,128,0,85,85,16,16,32, - 16,0,254,170,170,0,1,128,0,0,1,128,0,69,17,237, - 16,85,81,197,176,69,17,128,0,0,1,128,0,0,1,128, - 0,85,85,16,16,32,16,0,254,170,170,0,1,128,0,0, - 1,128,0,59,141,194,82,51,159,138,18,114,19,128,0,0, - 1,128,0,0,1,128,0,85,85,16,16,32,16,0,254,170, - 170,0,1,128,0,0,1,128,0,123,141,194,82,123,159,194, - 18,122,19,128,0,0,1,128,0,0,1,128,0,85,85,16, - 16,32,16,0,254,170,170,0,1,128,0,0,1,128,0,57, - 143,194,80,50,77,138,66,113,157,128,0,0,1,128,0,0, - 1,128,0,85,85,16,16,32,16,0,254,170,170,0,1,128, - 0,0,1,128,0,51,155,196,34,37,163,148,162,99,155,128, - 0,0,1,128,0,0,1,128,0,85,85,16,16,32,16,0, - 254,170,170,0,1,128,0,0,1,128,0,57,221,194,8,50, - 9,138,8,113,221,128,0,0,1,128,0,0,1,128,0,85, - 85,16,16,32,16,0,254,170,170,0,1,128,0,0,1,128, - 0,57,221,194,8,65,137,192,72,59,157,128,0,0,1,128, - 0,0,1,128,0,85,85,16,16,32,16,0,254,170,170,0, - 1,128,0,0,1,128,0,14,249,144,32,12,33,130,32,28, - 33,128,0,0,1,128,0,0,1,128,0,85,85,16,16,32, - 16,0,254,170,170,0,1,128,0,0,1,128,0,49,207,202, - 16,73,145,200,80,51,143,128,0,0,1,128,0,0,1,128, - 0,85,85,16,16,32,16,0,254,170,170,0,1,128,0,0, - 1,128,0,114,33,203,96,114,161,194,32,66,33,128,0,0, - 1,128,0,0,1,128,0,85,85,16,16,32,16,0,254,170, - 170,0,1,128,0,0,1,128,0,51,143,202,80,123,145,202, - 16,74,15,128,0,0,1,128,0,0,1,128,0,85,85,0, - 0,0,8,0,14,1,10,10,8,4,0,128,128,0,128,128, - 128,128,128,128,128,7,10,10,8,1,0,16,16,124,146,144, - 144,146,124,16,16,7,10,10,8,1,0,28,32,32,32,248, - 32,32,32,124,194,6,8,8,8,1,1,132,72,120,72,72, - 120,72,132,7,10,10,8,1,0,130,68,40,16,254,16,254, - 16,16,16,1,10,10,8,4,0,128,128,128,128,0,0,128, - 128,128,128,6,10,10,8,1,0,120,132,128,120,132,132,120, - 4,132,120,4,2,2,8,2,12,144,144,8,10,10,8,0, - 0,60,66,153,165,161,161,165,153,66,60,5,7,7,8,2, - 5,112,8,120,136,120,0,248,6,9,9,8,1,0,36,36, - 72,72,144,72,72,36,36,6,4,4,8,1,0,252,4,4, - 4,6,1,1,8,1,4,252,8,10,10,8,0,0,60,66, - 185,165,165,185,169,165,66,60,6,1,1,8,1,11,252,3, - 4,4,8,2,10,64,160,160,64,7,9,9,8,1,1,16, - 16,16,254,16,16,16,0,254,5,7,7,8,2,5,112,136, - 8,112,128,128,248,5,7,7,8,2,5,112,136,8,112,8, - 136,112,3,3,3,8,3,10,32,64,128,5,8,8,8,2, - 254,136,136,136,136,216,168,128,128,6,12,12,8,1,255,124, - 244,244,244,244,116,20,20,20,20,20,28,2,2,2,8,3, - 4,192,192,3,2,2,8,2,254,32,192,3,7,7,8,2, - 5,32,96,160,32,32,32,32,5,7,7,8,2,5,112,136, - 136,136,112,0,248,6,9,9,8,1,0,144,144,72,72,36, - 72,72,144,144,6,10,10,8,1,0,68,196,72,80,80,36, - 44,84,156,132,6,10,10,8,1,0,68,196,72,80,80,40, - 52,68,136,156,6,10,10,8,1,0,196,36,72,48,208,36, - 44,84,156,132,6,10,10,8,1,0,16,16,0,16,16,96, - 132,132,132,120,6,14,14,8,1,0,96,24,0,0,48,72, - 72,132,132,252,132,132,132,132,6,14,14,8,1,0,24,96, - 0,0,48,72,72,132,132,252,132,132,132,132,6,14,14,8, - 1,0,48,72,0,0,48,72,72,132,132,252,132,132,132,132, - 6,14,14,8,1,0,100,152,0,0,48,72,72,132,132,252, - 132,132,132,132,6,14,14,8,1,0,72,72,0,0,48,72, - 72,132,132,252,132,132,132,132,6,14,14,8,1,0,48,72, - 48,0,48,72,72,132,132,252,132,132,132,132,7,10,10,8, - 1,0,62,80,144,144,254,144,144,144,144,158,6,12,12,8, - 1,254,120,132,132,128,128,128,128,132,132,120,16,96,6,14, - 14,8,1,0,96,24,0,0,252,128,128,128,248,128,128,128, - 128,252,6,14,14,8,1,0,24,96,0,0,252,128,128,128, - 248,128,128,128,128,252,6,14,14,8,1,0,48,72,0,0, - 252,128,128,128,248,128,128,128,128,252,6,14,14,8,1,0, - 72,72,0,0,252,128,128,128,248,128,128,128,128,252,5,14, - 14,8,2,0,96,24,0,0,248,32,32,32,32,32,32,32, - 32,248,5,14,14,8,2,0,48,192,0,0,248,32,32,32, - 32,32,32,32,32,248,5,14,14,8,2,0,96,144,0,0, - 248,32,32,32,32,32,32,32,32,248,5,14,14,8,2,0, - 144,144,0,0,248,32,32,32,32,32,32,32,32,248,7,10, - 10,8,0,0,120,68,66,66,242,66,66,66,68,120,6,14, - 14,8,1,0,100,152,0,0,132,196,196,164,164,148,148,140, - 140,132,6,14,14,8,1,0,96,24,0,0,120,132,132,132, - 132,132,132,132,132,120,6,14,14,8,1,0,24,96,0,0, - 120,132,132,132,132,132,132,132,132,120,6,14,14,8,1,0, - 48,72,0,0,120,132,132,132,132,132,132,132,132,120,6,14, - 14,8,1,0,100,152,0,0,120,132,132,132,132,132,132,132, - 132,120,6,14,14,8,1,0,72,72,0,0,120,132,132,132, - 132,132,132,132,132,120,6,5,5,8,1,2,132,72,48,72, - 132,6,12,12,8,1,255,4,116,136,140,148,148,164,164,196, - 68,184,128,6,14,14,8,1,0,96,24,0,0,132,132,132, - 132,132,132,132,132,132,120,6,14,14,8,1,0,24,96,0, - 0,132,132,132,132,132,132,132,132,132,120,6,14,14,8,1, - 0,48,72,0,0,132,132,132,132,132,132,132,132,132,120,6, - 14,14,8,1,0,72,72,0,0,132,132,132,132,132,132,132, - 132,132,120,7,14,14,8,1,0,24,96,0,0,130,130,68, - 68,40,16,16,16,16,16,6,11,11,8,1,0,128,128,240, - 136,132,132,136,240,128,128,128,6,10,10,8,1,0,112,136, - 136,136,248,132,132,132,196,184,6,12,12,8,1,0,96,24, - 0,0,120,132,4,124,132,132,140,116,6,12,12,8,1,0, - 24,96,0,0,120,132,4,124,132,132,140,116,6,12,12,8, - 1,0,48,72,0,0,120,132,4,124,132,132,140,116,6,12, - 12,8,1,0,100,152,0,0,120,132,4,124,132,132,140,116, - 6,12,12,8,1,0,72,72,0,0,120,132,4,124,132,132, - 140,116,6,13,13,8,1,0,48,72,48,0,0,120,132,4, - 124,132,132,140,116,7,8,8,8,1,0,124,146,18,126,144, - 144,146,124,6,10,10,8,1,254,120,132,128,128,128,128,132, - 120,16,96,6,12,12,8,1,0,96,24,0,0,120,132,132, - 252,128,128,132,120,6,12,12,8,1,0,24,96,0,0,120, - 132,132,252,128,128,132,120,6,12,12,8,1,0,48,72,0, - 0,120,132,132,252,128,128,132,120,6,12,12,8,1,0,72, - 72,0,0,120,132,132,252,128,128,132,120,5,12,12,8,2, - 0,192,48,0,0,96,32,32,32,32,32,32,248,5,12,12, - 8,2,0,48,192,0,0,96,32,32,32,32,32,32,248,5, - 12,12,8,2,0,96,144,0,0,96,32,32,32,32,32,32, - 248,5,12,12,8,2,0,144,144,0,0,96,32,32,32,32, - 32,32,248,6,12,12,8,1,0,100,24,40,68,4,124,132, - 132,132,132,132,120,6,12,12,8,1,0,100,152,0,0,184, - 196,132,132,132,132,132,132,6,12,12,8,1,0,96,24,0, - 0,120,132,132,132,132,132,132,120,6,12,12,8,1,0,24, - 96,0,0,120,132,132,132,132,132,132,120,6,12,12,8,1, - 0,48,72,0,0,120,132,132,132,132,132,132,120,6,12,12, - 8,1,0,100,152,0,0,120,132,132,132,132,132,132,120,6, - 12,12,8,1,0,72,72,0,0,120,132,132,132,132,132,132, - 120,6,7,7,8,1,1,48,0,0,252,0,0,48,6,10, - 10,8,1,255,4,120,140,148,148,164,164,196,120,128,6,12, - 12,8,1,0,96,24,0,0,132,132,132,132,132,132,140,116, - 6,12,12,8,1,0,24,96,0,0,132,132,132,132,132,132, - 140,116,6,12,12,8,1,0,48,72,0,0,132,132,132,132, - 132,132,140,116,6,12,12,8,1,0,72,72,0,0,132,132, - 132,132,132,132,140,116,6,14,14,8,1,254,24,96,0,0, - 132,132,132,132,132,76,52,4,4,120,5,12,12,8,2,254, - 128,128,240,136,136,136,144,160,192,128,128,128,6,14,14,8, - 1,254,72,72,0,0,132,132,132,132,132,76,52,4,4,120 - }; -/* - Fontname: -gnu-unifont-medium-r-normal--16-160-75-75-c-80-iso10646-1 - Copyright: - Capital A Height: 10, '1' Height: 10 - Calculated Max Values w=16 h=16 x= 5 y=14 dx=16 dy= 0 ascent=14 len=32 - Font Bounding box w=16 h=16 x= 0 y=-2 - Calculated Min Values x= 0 y=-2 dx= 0 dy= 0 - Pure Font ascent =10 descent=-2 - X Font ascent =11 descent=-2 - Max Font ascent =14 descent=-2 -*/ -#include "u8g.h" -const u8g_fntpgm_uint8_t u8g_font_unifont_0_11[3240] U8G_FONT_SECTION("u8g_font_unifont_0_11") = { - 0,16,16,0,254,10,1,231,3,213,32,255,254,14,254,11, - 254,0,0,0,8,0,14,1,10,10,8,4,0,128,128,128, - 128,128,128,128,0,128,128,5,4,4,8,2,8,136,136,136, - 136,6,10,10,8,1,0,36,36,36,252,72,72,252,144,144, - 144,7,10,10,8,1,0,16,124,146,144,112,28,18,146,124, - 16,7,10,10,8,1,0,98,148,148,104,16,16,44,82,82, - 140,7,10,10,8,1,0,56,68,68,68,56,114,138,132,140, - 114,1,4,4,8,4,8,128,128,128,128,3,12,12,8,3, - 255,32,64,64,128,128,128,128,128,128,64,64,32,3,12,12, - 8,2,255,128,64,64,32,32,32,32,32,32,64,64,128,7, - 7,7,8,1,1,16,146,84,56,84,146,16,7,7,7,8, - 1,1,16,16,16,254,16,16,16,2,4,4,8,3,254,192, - 64,64,128,6,1,1,8,1,4,252,2,2,2,8,3,0, - 192,192,6,10,10,8,1,0,4,4,8,16,16,32,32,64, - 128,128,6,10,10,8,1,0,48,72,132,132,132,132,132,132, - 72,48,5,10,10,8,2,0,32,96,160,32,32,32,32,32, - 32,248,6,10,10,8,1,0,120,132,132,4,24,32,64,128, - 128,252,6,10,10,8,1,0,120,132,132,4,56,4,4,132, - 132,120,6,10,10,8,1,0,8,24,40,72,136,136,252,8, - 8,8,6,10,10,8,1,0,252,128,128,128,248,4,4,4, - 132,120,6,10,10,8,1,0,56,64,128,128,248,132,132,132, - 132,120,6,10,10,8,1,0,252,4,4,8,8,8,16,16, - 16,16,6,10,10,8,1,0,120,132,132,132,120,132,132,132, - 132,120,6,10,10,8,1,0,120,132,132,132,124,4,4,4, - 8,112,2,7,7,8,3,1,192,192,0,0,0,192,192,2, - 9,9,8,3,255,192,192,0,0,0,192,64,64,128,5,9, - 9,8,2,0,8,16,32,64,128,64,32,16,8,6,5,5, - 8,1,2,252,0,0,0,252,5,9,9,8,1,0,128,64, - 32,16,8,16,32,64,128,6,10,10,8,1,0,120,132,132, - 4,8,16,16,0,16,16,6,10,10,8,1,0,56,68,148, - 172,164,164,164,156,64,60,6,10,10,8,1,0,48,72,72, - 132,132,252,132,132,132,132,6,10,10,8,1,0,248,132,132, - 132,248,132,132,132,132,248,6,10,10,8,1,0,120,132,132, - 128,128,128,128,132,132,120,6,10,10,8,1,0,240,136,132, - 132,132,132,132,132,136,240,6,10,10,8,1,0,252,128,128, - 128,248,128,128,128,128,252,6,10,10,8,1,0,252,128,128, - 128,248,128,128,128,128,128,6,10,10,8,1,0,120,132,132, - 128,128,156,132,132,140,116,6,10,10,8,1,0,132,132,132, - 132,252,132,132,132,132,132,5,10,10,8,2,0,248,32,32, - 32,32,32,32,32,32,248,7,10,10,8,1,0,62,8,8, - 8,8,8,8,136,136,112,6,10,10,8,1,0,132,136,144, - 160,192,192,160,144,136,132,6,10,10,8,1,0,128,128,128, - 128,128,128,128,128,128,252,6,10,10,8,1,0,132,132,204, - 204,180,180,132,132,132,132,6,10,10,8,1,0,132,196,196, - 164,164,148,148,140,140,132,6,10,10,8,1,0,120,132,132, - 132,132,132,132,132,132,120,6,10,10,8,1,0,248,132,132, - 132,248,128,128,128,128,128,7,11,11,8,1,255,120,132,132, - 132,132,132,132,180,204,120,6,6,10,10,8,1,0,248,132, - 132,132,248,144,136,136,132,132,6,10,10,8,1,0,120,132, - 132,128,96,24,4,132,132,120,7,10,10,8,1,0,254,16, - 16,16,16,16,16,16,16,16,6,10,10,8,1,0,132,132, - 132,132,132,132,132,132,132,120,7,10,10,8,1,0,130,130, - 130,68,68,68,40,40,16,16,6,10,10,8,1,0,132,132, - 132,132,180,180,204,204,132,132,6,10,10,8,1,0,132,132, - 72,72,48,48,72,72,132,132,7,10,10,8,1,0,130,130, - 68,68,40,16,16,16,16,16,6,10,10,8,1,0,252,4, - 4,8,16,32,64,128,128,252,3,12,12,8,4,255,224,128, - 128,128,128,128,128,128,128,128,128,224,6,10,10,8,1,0, - 128,128,64,32,32,16,16,8,4,4,3,12,12,8,1,255, - 224,32,32,32,32,32,32,32,32,32,32,224,6,3,3,8, - 1,9,48,72,132,7,1,1,8,1,255,254,3,3,3,8, - 2,10,128,64,32,6,8,8,8,1,0,120,132,4,124,132, - 132,140,116,6,11,11,8,1,0,128,128,128,184,196,132,132, - 132,132,196,184,6,8,8,8,1,0,120,132,128,128,128,128, - 132,120,6,11,11,8,1,0,4,4,4,116,140,132,132,132, - 132,140,116,6,8,8,8,1,0,120,132,132,252,128,128,132, - 120,5,11,11,8,1,0,24,32,32,32,248,32,32,32,32, - 32,32,6,11,11,8,1,254,4,116,136,136,136,112,64,120, - 132,132,120,6,11,11,8,1,0,128,128,128,184,196,132,132, - 132,132,132,132,5,11,11,8,2,0,32,32,0,96,32,32, - 32,32,32,32,248,5,13,13,8,1,254,8,8,0,24,8, - 8,8,8,8,8,8,144,96,6,10,10,8,1,0,128,128, - 136,144,160,192,160,144,136,132,5,10,10,8,2,0,96,32, - 32,32,32,32,32,32,32,248,7,8,8,8,1,0,236,146, - 146,146,146,146,146,146,6,8,8,8,1,0,184,196,132,132, - 132,132,132,132,6,8,8,8,1,0,120,132,132,132,132,132, - 132,120,6,10,10,8,1,254,184,196,132,132,132,132,196,184, - 128,128,6,10,10,8,1,254,116,140,132,132,132,132,140,116, - 4,4,6,8,8,8,1,0,184,196,132,128,128,128,128,128, - 6,8,8,8,1,0,120,132,128,96,24,4,132,120,5,10, - 10,8,1,0,32,32,248,32,32,32,32,32,32,24,6,8, - 8,8,1,0,132,132,132,132,132,132,140,116,6,8,8,8, - 1,0,132,132,132,72,72,72,48,48,7,8,8,8,1,0, - 130,146,146,146,146,146,146,108,6,8,8,8,1,0,132,132, - 72,48,48,72,132,132,6,10,10,8,1,254,132,132,132,132, - 132,76,52,4,4,120,6,8,8,8,1,0,252,4,8,16, - 32,64,128,252,3,12,12,8,3,255,96,128,128,64,64,128, - 128,64,64,128,128,96,1,14,14,8,4,254,128,128,128,128, - 128,128,128,128,128,128,128,128,128,128,3,12,12,8,2,255, - 192,32,32,64,64,32,32,64,64,32,32,192,7,3,3,8, - 1,8,98,146,140,16,16,32,16,0,254,170,170,0,1,128, - 0,0,1,128,0,115,209,202,16,75,209,202,16,115,223,128, - 0,0,1,128,0,0,1,128,0,85,85,6,10,10,8,1, - 254,184,196,132,132,132,132,132,132,128,128,6,10,10,8,1, - 254,116,140,132,132,132,140,116,4,132,120,4,8,8,8,3, - 0,192,64,64,64,64,64,64,112,7,12,12,8,1,254,16, - 16,148,154,146,146,146,146,178,82,16,16,7,11,11,8,1, - 0,28,34,32,32,248,32,32,32,32,32,32,6,8,8,8, - 1,0,120,132,132,132,132,132,132,120,7,12,12,8,1,254, - 112,144,144,112,28,18,18,18,146,124,16,16,7,10,10,8, - 1,0,128,128,128,136,136,136,136,136,136,118,6,14,14,8, - 1,255,168,84,168,84,168,84,168,84,168,84,168,84,168,84, - 2,7,7,8,3,1,192,192,0,0,0,192,192,6,2,2, - 8,1,1,196,120,6,14,14,8,1,255,168,84,168,84,168, - 84,168,84,168,84,168,84,168,84,6,14,14,8,1,255,168, - 84,168,84,168,84,168,84,168,84,168,84,168,84,6,14,14, - 8,1,255,168,84,168,84,168,84,168,84,168,84,168,84,168, - 84,6,14,14,8,1,255,168,84,168,84,168,84,168,84,168, - 84,168,84,168,84,6,14,14,8,1,255,168,84,168,84,168, - 84,168,84,168,84,168,84,168,84,6,14,14,8,1,255,168, - 84,168,84,168,84,168,84,168,84,168,84,168,84,5,4,4, - 8,2,255,32,32,112,136,6,3,3,8,1,9,48,0,204, - 4,6,6,8,2,8,48,192,48,192,48,192,2,3,3,8, - 3,10,192,0,192,4,3,3,8,2,10,176,128,176,3,3, - 3,8,3,255,128,128,96,5,5,5,8,2,9,32,112,248, - 112,32,6,4,4,8,1,9,72,164,148,72,3,3,3,8, - 0,9,192,32,32,2,3,3,8,5,255,64,128,64,4,4, - 4,8,1,254,208,208,16,224,3,3,3,8,3,10,96,128, - 128,3,3,3,8,5,9,96,128,128,5,5,5,8,3,9, - 48,64,152,160,32,8,4,4,8,0,9,66,165,66,36,3, - 4,4,8,5,9,64,160,64,128,4,3,3,8,0,8,80, - 96,128,5,3,3,8,1,254,136,112,32,3,3,3,8,2, - 255,32,32,224,2,3,3,8,3,255,64,128,64,3,3,3, - 8,2,255,32,32,192,5,4,4,8,1,254,40,200,16,96, - 4,5,5,8,2,254,96,128,96,16,96,3,3,3,8,2, - 9,192,32,32,3,4,4,8,1,9,64,160,64,32,5,4, - 4,8,2,254,136,112,32,32,2,3,3,8,2,10,64,128, - 64,3,3,3,8,3,10,32,32,224,3,3,3,8,5,255, - 128,128,96,5,4,4,8,0,9,72,168,168,144,4,4,4, - 8,2,9,96,144,144,96,2,3,3,8,3,255,192,0,192, - 5,3,3,8,2,255,168,0,72,5,3,3,8,2,255,232, - 0,8,5,3,3,8,2,255,232,64,72,2,2,2,8,3, - 0,192,192,6,2,2,8,1,0,204,204,6,3,3,8,1, - 254,204,0,48,4,1,1,8,2,0,240,5,3,3,8,2, - 254,248,32,32,2,2,2,8,2,10,192,192,2,2,2,8, - 1,10,192,192,5,3,3,8,2,255,128,32,8,2,1,1, - 8,3,5,192,1,3,3,8,4,255,128,128,128,6,2,2, - 8,1,10,124,248,4,1,1,8,2,10,240,1,9,9,8, - 4,0,128,128,128,128,128,128,128,128,128,2,2,2,8,5, - 10,192,192,2,2,2,8,1,10,192,192,3,8,8,8,3, - 0,64,224,64,0,0,64,224,64,2,2,2,8,3,10,192, - 192,2,2,2,8,3,10,192,192,4,9,9,8,2,0,224, - 128,128,128,128,128,128,128,240,5,4,4,8,2,254,248,32, - 32,32,6,14,14,8,1,255,168,84,168,84,168,84,168,84, - 168,84,168,84,168,84,6,14,14,8,1,255,168,84,168,84, - 168,84,168,84,168,84,168,84,168,84,6,14,14,8,1,255, - 168,84,168,84,168,84,168,84,168,84,168,84,168,84,6,14, - 14,8,1,255,168,84,168,84,168,84,168,84,168,84,168,84, - 168,84,6,14,14,8,1,255,168,84,168,84,168,84,168,84, - 168,84,168,84,168,84,6,14,14,8,1,255,168,84,168,84, - 168,84,168,84,168,84,168,84,168,84,6,14,14,8,1,255, - 168,84,168,84,168,84,168,84,168,84,168,84,168,84,6,14, - 14,8,1,255,168,84,168,84,168,84,168,84,168,84,168,84, - 168,84,6,9,9,8,1,0,132,132,68,36,88,144,136,132, - 132,7,9,9,8,1,0,248,8,8,8,8,8,8,8,254, - 6,9,9,8,1,0,96,16,16,16,8,24,40,68,132,6, - 9,9,8,1,0,252,8,8,8,8,8,8,8,8,6,9, - 9,8,1,0,252,4,4,68,68,68,68,68,68,3,9,9, - 8,2,0,224,32,32,32,32,32,32,32,32,5,9,9,8, - 2,0,192,48,40,32,32,32,32,32,32,6,9,9,8,1, - 0,252,68,68,68,68,68,68,68,68,6,9,9,8,1,0, - 140,148,132,132,132,132,132,132,252,3,4,4,8,2,5,224, - 32,32,32,6,11,11,8,1,254,252,4,4,4,4,4,4, - 4,4,4,4,6,9,9,8,1,0,252,4,4,4,4,4, - 4,4,248,5,11,11,8,2,0,128,128,248,8,8,8,8, - 16,16,32,192,7,9,9,8,0,0,254,34,34,34,34,34, - 34,34,62,7,9,9,8,1,0,156,98,66,130,130,130,130, - 130,142,3,11,11,8,2,254,224,32,32,32,32,32,32,32, - 32,32,32,4,9,9,8,2,0,112,16,16,16,16,16,16, - 16,240,6,9,9,8,1,0,252,132,132,132,132,132,132,136, - 240,7,9,9,8,0,0,18,18,18,18,18,18,18,18,254, - 6,11,11,8,1,254,252,132,132,132,228,4,4,4,4,4, - 4,6,9,9,8,1,0,252,132,132,132,228,4,4,4,252, - 5,11,11,8,2,254,136,136,144,160,192,128,128,128,128,128, - 128,6,9,9,8,1,0,132,132,72,48,16,8,4,4,252, - 6,11,11,8,1,254,252,68,68,72,72,80,64,64,64,64, - 64,6,9,9,8,1,0,252,4,4,4,4,4,4,4,4, - 7,9,9,8,1,0,146,146,146,146,146,146,146,146,254,6, - 9,9,8,1,0,124,68,68,68,68,68,68,68,196,6,14, - 14,8,1,255,168,84,168,84,168,84,168,84,168,84,168,84, - 168,84,6,14,14,8,1,255,168,84,168,84,168,84,168,84, - 168,84,168,84,168,84,6,14,14,8,1,255,168,84,168,84, - 168,84,168,84,168,84,168,84,168,84,6,14,14,8,1,255, - 168,84,168,84,168,84,168,84,168,84,168,84,168,84,6,14, - 14,8,1,255,168,84,168,84,168,84,168,84,168,84,168,84, - 168,84,7,9,9,8,1,0,238,34,34,34,34,34,34,34, - 34,7,9,9,8,1,0,238,34,34,34,2,2,2,2,2, - 7,4,4,8,1,5,238,34,34,34,3,3,3,8,4,9, - 32,64,128,6,3,3,8,1,9,36,72,144,6,14,14,8, - 1,255,168,84,168,84,168,84,168,84,168,84,168,84,168,84, - 6,14,14,8,1,255,168,84,168,84,168,84,168,84,168,84, - 168,84,168,84,6,14,14,8,1,255,168,84,168,84,168,84, - 168,84,168,84,168,84,168,84,6,14,14,8,1,255,168,84, - 168,84,168,84,168,84,168,84,168,84,168,84,6,14,14,8, - 1,255,168,84,168,84,168,84,168,84,168,84,168,84,168,84, - 6,14,14,8,1,255,168,84,168,84,168,84,168,84,168,84, - 168,84,168,84,6,14,14,8,1,255,168,84,168,84,168,84, - 168,84,168,84,168,84,168,84,6,14,14,8,1,255,168,84, - 168,84,168,84,168,84,168,84,168,84,168,84,6,14,14,8, - 1,255,168,84,168,84,168,84,168,84,168,84,168,84,168,84, - 6,14,14,8,1,255,168,84,168,84,168,84,168,84,168,84, - 168,84,168,84,6,14,14,8,1,255,168,84,168,84,168,84, - 168,84,168,84,168,84,168,84}; /* Fontname: -gnu-Unifont-Medium-R-Normal-Sans-16-160-75-75-c-80-iso10646-1 Copyright: Copyright (C) 2014 Roman Czyborra, Paul Hardy, Qianqian Fang, Andrew Miller, et al. Licensed under the GNU General Public License; either version 2, or (at your option) a later version, with the GNU Font Embedding Exception. diff --git a/sys/arduino/A2Printer/A2Printer.pde b/sys/arduino/A2Printer/A2Printer.pde index d40bd791..96ddad00 100644 --- a/sys/arduino/A2Printer/A2Printer.pde +++ b/sys/arduino/A2Printer/A2Printer.pde @@ -5,7 +5,7 @@ Special example code for the A2 Mciro Printer (https://www.sparkfun.com/products/10438) - Universal 8bit Graphics Library, http://code.google.com/p/u8glib/ + Universal 8bit Graphics Library, https://github.com/olikraus/u8glib/ Copyright (c) 2013, olikraus@gmail.com All rights reserved. @@ -59,11 +59,11 @@ uint8_t u8g_com_uart(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) { //U8GLIB u8g(&u8g_dev_a2_micro_printer_192x120_ds, (u8g_com_fnptr)u8g_com_uart); // full resolution, requires to uncomment U8G_16BIT in u8g.h -//U8GLIB u8g(&u8g_dev_a2_micro_printer_384x240, (u8g_com_fnptr)u8g_com_uart); +U8GLIB u8g(&u8g_dev_a2_micro_printer_384x240, (u8g_com_fnptr)u8g_com_uart); // half resolution, extra log, requires to uncomment U8G_16BIT in u8g.h //U8GLIB u8g(&u8g_dev_a2_micro_printer_192x360_ds, (u8g_com_fnptr)u8g_com_uart); -U8GLIB u8g(&u8g_dev_a2_micro_printer_192x720_ds, (u8g_com_fnptr)u8g_com_uart); +//U8GLIB u8g(&u8g_dev_a2_micro_printer_192x720_ds, (u8g_com_fnptr)u8g_com_uart); diff --git a/sys/arduino/Bitmap/Bitmap.pde b/sys/arduino/Bitmap/Bitmap.pde index e9a30e2d..fbe18ce3 100644 --- a/sys/arduino/Bitmap/Bitmap.pde +++ b/sys/arduino/Bitmap/Bitmap.pde @@ -7,7 +7,7 @@ >>> Before compiling: Please remove comment from the constructor of the >>> connected graphics display (see below). - Universal 8bit Graphics Library, http://code.google.com/p/u8glib/ + Universal 8bit Graphics Library, https://github.com/olikraus/u8glib/ Copyright (c) 2011, olikraus@gmail.com All rights reserved. @@ -43,7 +43,7 @@ // setup u8g object, please remove comment from one of the following constructor calls // IMPORTANT NOTE: The following list is incomplete. The complete list of supported -// devices with all constructor calls is here: http://code.google.com/p/u8glib/wiki/device +// devices with all constructor calls is here: https://github.com/olikraus/u8glib/wiki/device //U8GLIB_NHD27OLED_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_NHD27OLED_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_NHD27OLED_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 @@ -95,6 +95,9 @@ //U8GLIB_SSD1306_128X32 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_SSD1306_128X32 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) //U8GLIB_SSD1306_128X32 u8g(U8G_I2C_OPT_NONE); // I2C / TWI +//U8GLIB_SSD1306_64X48 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 +//U8GLIB_SSD1306_64X48 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_SSD1306_64X48 u8g(U8G_I2C_OPT_NONE); // I2C / TWI //U8GLIB_SH1106_128X64 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_SH1106_128X64 u8g(4, 5, 6, 7); // SW SPI Com: SCK = 4, MOSI = 5, CS = 6, A0 = 7 (new blue HalTec OLED) //U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_NONE); // I2C / TWI @@ -106,9 +109,12 @@ //U8GLIB_UC1611_DOGM240 u8g(U8G_I2C_OPT_NONE); // I2C //U8GLIB_UC1611_DOGM240 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_UC1611_DOGM240 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_UC1611_DOGM240 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_UC1611_DOGM240 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 3, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=3, di/a0=17,rw=16 //U8GLIB_UC1611_DOGXL240 u8g(U8G_I2C_OPT_NONE); // I2C //U8GLIB_UC1611_DOGXL240 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_UC1611_DOGXL240 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_UC1611_DOGXL240 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 3, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=3, di/a0=17,rw=16 //U8GLIB_NHD_C12864 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 //U8GLIB_NHD_C12832 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 //U8GLIB_LD7032_60x32 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 diff --git a/sys/arduino/Chess/Chess.pde b/sys/arduino/Chess/Chess.pde index 716fe07a..bb6ab954 100644 --- a/sys/arduino/Chess/Chess.pde +++ b/sys/arduino/Chess/Chess.pde @@ -7,7 +7,7 @@ >>> Before compiling: Please remove comment from the constructor of the >>> connected graphics display (see below). - Universal 8bit Graphics Library, http://code.google.com/p/u8glib/ + Universal 8bit Graphics Library, https://github.com/olikraus/u8glib/ Copyright (c) 2012, olikraus@gmail.com All rights reserved. @@ -44,7 +44,7 @@ // setup u8g object, please remove comment from one of the following constructor calls // IMPORTANT NOTE: The following list is incomplete. The complete list of supported -// devices with all constructor calls is here: http://code.google.com/p/u8glib/wiki/device +// devices with all constructor calls is here: https://github.com/olikraus/u8glib/wiki/device //U8GLIB_NHD27OLED_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_NHD27OLED_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_NHD27OLED_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 @@ -96,6 +96,9 @@ //U8GLIB_SSD1306_128X32 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_SSD1306_128X32 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) //U8GLIB_SSD1306_128X32 u8g(U8G_I2C_OPT_NONE); // I2C / TWI +//U8GLIB_SSD1306_64X48 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 +//U8GLIB_SSD1306_64X48 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_SSD1306_64X48 u8g(U8G_I2C_OPT_NONE); // I2C / TWI //U8GLIB_SH1106_128X64 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_SH1106_128X64 u8g(4, 5, 6, 7); // SW SPI Com: SCK = 4, MOSI = 5, CS = 6, A0 = 7 (new blue HalTec OLED) //U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_NONE); // I2C / TWI @@ -107,9 +110,12 @@ //U8GLIB_UC1611_DOGM240 u8g(U8G_I2C_OPT_NONE); // I2C //U8GLIB_UC1611_DOGM240 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_UC1611_DOGM240 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_UC1611_DOGM240 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_UC1611_DOGM240 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 3, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=3, di/a0=17,rw=16 //U8GLIB_UC1611_DOGXL240 u8g(U8G_I2C_OPT_NONE); // I2C //U8GLIB_UC1611_DOGXL240 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_UC1611_DOGXL240 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_UC1611_DOGXL240 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 3, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=3, di/a0=17,rw=16 //U8GLIB_NHD_C12864 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 //U8GLIB_NHD_C12832 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 //U8GLIB_LD7032_60x32 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 @@ -135,20 +141,19 @@ //U8GLIB_SSD1351_128X128GH_332 u8g(8, 9, 7); // Arduino, HW SPI Com: SCK = 76, MOSI = 75, CS = 8, A0 = 9, RESET = 7 (Freetronics OLED) //U8GLIB_SSD1351_128X128GH_HICOLOR u8g(8, 9, 7); // Arduino, HW SPI Com: SCK = 76, MOSI = 75, CS = 8, A0 = 9, RESET = 7 (Freetronics OLED) -U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NO_ACK); // DOGS102 shield configuration values -uint8_t uiKeyPrev = 2; -uint8_t uiKeyNext = 4; -uint8_t uiKeySelect = 5; -uint8_t uiKeyBack = 3; +// uint8_t uiKeyPrev = 2; +// uint8_t uiKeyNext = 4; +// uint8_t uiKeySelect = 5; +// uint8_t uiKeyBack = 3; // DOGM128-Shield configuration values // DOGXL60-Shield configuration values -//uint8_t uiKeyPrev = 7; -//uint8_t uiKeyNext = 3; -//uint8_t uiKeySelect = 2; -//uint8_t uiKeyBack = 8; +uint8_t uiKeyPrev = 7; +uint8_t uiKeyNext = 3; +uint8_t uiKeySelect = 2; +uint8_t uiKeyBack = 8; uint8_t uiKeyCodeFirst = CHESS_KEY_NONE; uint8_t uiKeyCodeSecond = CHESS_KEY_NONE; @@ -158,14 +163,10 @@ uint8_t uiKeyCode = CHESS_KEY_NONE; void uiSetup(void) { // configure input keys #if defined(ARDUINO) - pinMode(uiKeyPrev, INPUT); // set pin to input - digitalWrite(uiKeyPrev, HIGH); // turn on pullup resistors - pinMode(uiKeyNext, INPUT); // set pin to input - digitalWrite(uiKeyNext, HIGH); // turn on pullup resistors - pinMode(uiKeySelect, INPUT); // set pin to input - digitalWrite(uiKeySelect, HIGH); // turn on pullup resistors - pinMode(uiKeyBack, INPUT); // set pin to input - digitalWrite(uiKeyBack, HIGH); // turn on pullup resistors + pinMode(uiKeyPrev, INPUT_PULLUP); // set pin to input + pinMode(uiKeyNext, INPUT_PULLUP); // set pin to input + pinMode(uiKeySelect, INPUT_PULLUP); // set pin to input + pinMode(uiKeyBack, INPUT_PULLUP); // set pin to input #endif } diff --git a/sys/arduino/Chess/Makefile.105.uno b/sys/arduino/Chess/Makefile.105.uno new file mode 100644 index 00000000..bbf951d8 --- /dev/null +++ b/sys/arduino/Chess/Makefile.105.uno @@ -0,0 +1,285 @@ + +# +# Arduino-1.0 Makefile +# +# written by olikraus@gmail.com +# +# Features: +# - boards.txt is used to derive parameters +# - All intermediate files are put into a separate directory (TMPDIRNAME) +# - Simple use: Copy Makefile into the same directory of the .pde file +# +# Limitations: +# - requires UNIX environment +# - TMPDIRNAME must be subdirectory of the current directory. +# +# Targets +# all build everything +# upload build and upload to arduino +# clean remove all temporary files (includes final hex file) +# +# History +# 001 28 Apr 2010 first release +# 002 05 Oct 2010 added 'uno' +# 003 06 Dec 2011 arduino 1.0 +# 004 11 Feb 2012 u8glib +# + +#=== user configuration === +# All ...PATH variables must have a '/' at the end + +# Board (and prozessor) information: see $(ARDUINO_PATH)hardware/arduino/boards.txt +# Some examples: +# BOARD DESCRIPTION +# uno Arduino Uno +# atmega328 Arduino Duemilanove or Nano w/ ATmega328 +# diecimila Arduino Diecimila, Duemilanove, or Nano w/ ATmega168 +# mega Arduino Mega +# mega2560 Arduino Mega2560 +# mini Arduino Mini +# lilypad328 LilyPad Arduino w/ ATmega328 +BOARD:=uno + +# additional definitions +#DEFS:=-DARDUINO=105 + + +U8G_PATH:=$(shell cd ../../.. && pwd)/csrc/ +U8G_CPP_PATH:=$(shell cd ../../.. && pwd)/cppsrc/ +U8G_FONT_PATH:=$(shell cd ../../.. && pwd)/sfntsrc/ + + +# The location where the avr tools (e.g. avr-gcc) are located. Requires a '/' at the end. +# Can be empty if all tools are accessable through the search path +AVR_TOOLS_PATH:=/usr/bin/ + +# Install path of the arduino software. Requires a '/' at the end. +ARDUINO_PATH:=/home/kraus/prg/arduino-1.0.5-u8glib/ + +# Install path for avrdude. Requires a '/' at the end. Can be empty if avrdude is in the search path. +AVRDUDE_PATH:=$(ARDUINO_PATH)hardware/tools/ + +# The unix device where we can reach the arduino board +# Uno: /dev/ttyACM0 +# Duemilanove: /dev/ttyUSB0 +AVRDUDE_PORT:=/dev/ttyACM0 + +# List of all libaries which should be included. +EXTRA_DIRS=$(ARDUINO_PATH)libraries/LiquidCrystal/ +EXTRA_DIRS+=$(ARDUINO_PATH)libraries/SD/ +EXTRA_DIRS+=$(ARDUINO_PATH)libraries/SD/utility/ +EXTRA_DIRS+=$(ARDUINO_PATH)libraries/SPI/ +#EXTRA_DIRS+=$(ARDUINO_PATH)libraries/.../ + +#=== fetch parameter from boards.txt processor parameter === +# the basic idea is to get most of the information from boards.txt + +BOARDS_TXT:=$(ARDUINO_PATH)hardware/arduino/boards.txt + +# get the MCU value from the $(BOARD).build.mcu variable. For the atmega328 board this is atmega328p +MCU:=$(shell sed -n -e "s/$(BOARD).build.mcu=\(.*\)/\1/p" $(BOARDS_TXT)) +# get the F_CPU value from the $(BOARD).build.f_cpu variable. For the atmega328 board this is 16000000 +F_CPU:=$(shell sed -n -e "s/$(BOARD).build.f_cpu=\(.*\)/\1/p" $(BOARDS_TXT)) +# get variant subfolder +VARIANT:=$(shell sed -n -e "s/$(BOARD).build.variant=\(.*\)/\1/p" $(BOARDS_TXT)) + + +# avrdude +# get the AVRDUDE_UPLOAD_RATE value from the $(BOARD).upload.speed variable. For the atmega328 board this is 57600 +AVRDUDE_UPLOAD_RATE:=$(shell sed -n -e "s/$(BOARD).upload.speed=\(.*\)/\1/p" $(BOARDS_TXT)) +# get the AVRDUDE_PROGRAMMER value from the $(BOARD).upload.protocol variable. For the atmega328 board this is stk500 +AVRDUDE_PROGRAMMER:=$(shell sed -n -e "s/$(BOARD).upload.protocol=\(.*\)/\1/p" $(BOARDS_TXT)) +# use stk500v1, because stk500 will default to stk500v2 +#AVRDUDE_PROGRAMMER:=stk500v1 + +#=== identify user files === +PDESRC:=$(shell ls *.pde) +TARGETNAME=$(basename $(PDESRC)) + +CDIRS:=$(EXTRA_DIRS) $(addsuffix utility/,$(EXTRA_DIRS)) +CDIRS:=*.c utility/*.c $(U8G_PATH)*.c $(U8G_FONT_PATH)*.c $(addsuffix *.c,$(CDIRS)) $(ARDUINO_PATH)hardware/arduino/cores/arduino/*.c +CSRC:=$(shell ls $(CDIRS) 2>/dev/null) + +CCSRC:=$(shell ls *.cc 2>/dev/null) + +CPPDIRS:=$(EXTRA_DIRS) $(addsuffix utility/,$(EXTRA_DIRS)) +CPPDIRS:=*.cpp utility/*.cpp $(addsuffix *.cpp,$(CPPDIRS)) $(U8G_CPP_PATH)/*.cpp $(ARDUINO_PATH)hardware/arduino/cores/arduino/*.cpp +CPPSRC:=$(shell ls $(CPPDIRS) 2>/dev/null) + +#=== build internal variables === + +# the name of the subdirectory where everything is stored +TMPDIRNAME:=tmp +TMPDIRPATH:=$(TMPDIRNAME)/ + +AVRTOOLSPATH:=$(AVR_TOOLS_PATH) + +OBJCOPY:=$(AVRTOOLSPATH)avr-objcopy +OBJDUMP:=$(AVRTOOLSPATH)avr-objdump +SIZE:=$(AVRTOOLSPATH)avr-size + +CPPSRC:=$(addprefix $(TMPDIRPATH),$(PDESRC:.pde=.cpp)) $(CPPSRC) + +COBJ:=$(CSRC:.c=.o) +CCOBJ:=$(CCSRC:.cc=.o) +CPPOBJ:=$(CPPSRC:.cpp=.o) + +OBJFILES:=$(COBJ) $(CCOBJ) $(CPPOBJ) +DIRS:= $(dir $(OBJFILES)) + +DEPFILES:=$(OBJFILES:.o=.d) +# assembler files from avr-gcc -S +ASSFILES:=$(OBJFILES:.o=.s) +# disassembled object files with avr-objdump -S +DISFILES:=$(OBJFILES:.o=.dis) + + +LIBNAME:=$(TMPDIRPATH)$(TARGETNAME).a +ELFNAME:=$(TMPDIRPATH)$(TARGETNAME).elf +HEXNAME:=$(TMPDIRPATH)$(TARGETNAME).hex + +AVRDUDE_FLAGS = -V -F +AVRDUDE_FLAGS += -C $(ARDUINO_PATH)/hardware/tools/avrdude.conf +AVRDUDE_FLAGS += -p $(MCU) +AVRDUDE_FLAGS += -P $(AVRDUDE_PORT) +AVRDUDE_FLAGS += -c $(AVRDUDE_PROGRAMMER) +AVRDUDE_FLAGS += -b $(AVRDUDE_UPLOAD_RATE) +AVRDUDE_FLAGS += -U flash:w:$(HEXNAME) + +AVRDUDE = $(AVRDUDE_PATH)avrdude + +#=== predefined variable override === +# use "make -p -f/dev/null" to see the default rules and definitions + +# Build C and C++ flags. Include path information must be placed here +COMMON_FLAGS = -DF_CPU=$(F_CPU) -mmcu=$(MCU) $(DEFS) -DARDUINO=100 +# COMMON_FLAGS += -gdwarf-2 +COMMON_FLAGS += -Os +COMMON_FLAGS += -Wall -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums +COMMON_FLAGS += -I. +COMMON_FLAGS += -I$(ARDUINO_PATH)hardware/arduino/cores/arduino +COMMON_FLAGS += -I$(ARDUINO_PATH)hardware/arduino/variants/$(VARIANT) +COMMON_FLAGS += -I. -I$(U8G_PATH) -I$(U8G_CPP_PATH) +COMMON_FLAGS += $(addprefix -I,$(EXTRA_DIRS)) +COMMON_FLAGS += -ffunction-sections -fdata-sections -Wl,--gc-sections +COMMON_FLAGS += -Wl,--Map=output.map +COMMON_FLAGS += -Wl,--relax +COMMON_FLAGS += -mcall-prologues + +CFLAGS = $(COMMON_FLAGS) -std=gnu99 -Wstrict-prototypes +CXXFLAGS = $(COMMON_FLAGS) + +# Replace standard build tools by avr tools +CC = $(AVRTOOLSPATH)avr-gcc +CXX = $(AVRTOOLSPATH)avr-g++ +AR = @$(AVRTOOLSPATH)avr-ar + + +# "rm" must be able to delete a directory tree +RM = rm -rf + +#=== rules === + +# add rules for the C/C++ files where the .o file is placed in the TMPDIRPATH +# reuse existing variables as far as possible + +$(TMPDIRPATH)%.o: %.c + @echo compile $< + @$(COMPILE.c) $(OUTPUT_OPTION) $< + +$(TMPDIRPATH)%.o: %.cc + @echo compile $< + @$(COMPILE.cc) $(OUTPUT_OPTION) $< + +$(TMPDIRPATH)%.o: %.cpp + @echo compile $< + @$(COMPILE.cpp) $(OUTPUT_OPTION) $< + +$(TMPDIRPATH)%.s: %.c + @$(COMPILE.c) $(OUTPUT_OPTION) -S $< + +$(TMPDIRPATH)%.s: %.cc + @$(COMPILE.cc) $(OUTPUT_OPTION) -S $< + +$(TMPDIRPATH)%.s: %.cpp + @$(COMPILE.cpp) $(OUTPUT_OPTION) -S $< + +$(TMPDIRPATH)%.dis: $(TMPDIRPATH)%.o + @$(OBJDUMP) -S $< > $@ + +.SUFFIXES: .elf .hex .pde + +.elf.hex: + @$(OBJCOPY) -O ihex -R .eeprom $< $@ + +$(TMPDIRPATH)%.cpp: %.pde + @cat $(ARDUINO_PATH)hardware/arduino/cores/arduino/main.cpp > $@ + @cat $< >> $@ + @echo >> $@ + @echo 'extern "C" void __cxa_pure_virtual() { while (1); }' >> $@ + + +.PHONY: all +all: tmpdir $(HEXNAME) assemblersource showsize + ls -al $(HEXNAME) $(ELFNAME) + +$(ELFNAME): $(LIBNAME)($(addprefix $(TMPDIRPATH),$(OBJFILES))) + $(LINK.o) $(COMMON_FLAGS) $(LIBNAME) $(LOADLIBES) $(LDLIBS) -o $@ + +$(LIBNAME)(): $(addprefix $(TMPDIRPATH),$(OBJFILES)) + +#=== create temp directory === +# not really required, because it will be also created during the dependency handling +.PHONY: tmpdir +tmpdir: + @test -d $(TMPDIRPATH) || mkdir $(TMPDIRPATH) + +#=== create assembler files for each C/C++ file === +.PHONY: assemblersource +assemblersource: $(addprefix $(TMPDIRPATH),$(ASSFILES)) $(addprefix $(TMPDIRPATH),$(DISFILES)) + + +#=== show the section sizes of the ELF file === +.PHONY: showsize +showsize: $(ELFNAME) + $(SIZE) $< + +#=== clean up target === +# this is simple: the TMPDIRPATH is removed +.PHONY: clean +clean: + $(RM) $(TMPDIRPATH) + +# Program the device. +# step 1: reset the arduino board with the stty command +# step 2: user avrdude to upload the software +.PHONY: upload +upload: $(HEXNAME) + stty -F $(AVRDUDE_PORT) hupcl + $(AVRDUDE) $(AVRDUDE_FLAGS) + + +# === dependency handling === +# From the gnu make manual (section 4.14, Generating Prerequisites Automatically) +# Additionally (because this will be the first executed rule) TMPDIRPATH is created here. +# Instead of "sed" the "echo" command is used +# cd $(TMPDIRPATH); mkdir -p $(DIRS) 2> /dev/null; cd .. +DEPACTION=test -d $(TMPDIRPATH) || mkdir $(TMPDIRPATH);\ +mkdir -p $(addprefix $(TMPDIRPATH),$(DIRS));\ +set -e; echo -n $@ $(dir $@) > $@; $(CC) -MM $(COMMON_FLAGS) $< >> $@ + + +$(TMPDIRPATH)%.d: %.c + @$(DEPACTION) + +$(TMPDIRPATH)%.d: %.cc + @$(DEPACTION) + +$(TMPDIRPATH)%.d: %.cpp + @$(DEPACTION) + +# Include dependency files. If a .d file is missing, a warning is created and the .d file is created +# This warning is not a problem (gnu make manual, section 3.3 Including Other Makefiles) +-include $(addprefix $(TMPDIRPATH),$(DEPFILES)) + + diff --git a/sys/arduino/ChessDogm/Chess.pde b/sys/arduino/ChessDogm/Chess.pde index f40e4a1d..10d7a443 100644 --- a/sys/arduino/ChessDogm/Chess.pde +++ b/sys/arduino/ChessDogm/Chess.pde @@ -7,7 +7,7 @@ >>> Before compiling: Please remove comment from the constructor of the >>> connected graphics display (see below). - Universal 8bit Graphics Library, http://code.google.com/p/u8glib/ + Universal 8bit Graphics Library, https://github.com/olikraus/u8glib/ Copyright (c) 2012, olikraus@gmail.com All rights reserved. diff --git a/sys/arduino/Color/Color.pde b/sys/arduino/Color/Color.pde index a389e322..e347cbd8 100644 --- a/sys/arduino/Color/Color.pde +++ b/sys/arduino/Color/Color.pde @@ -7,7 +7,7 @@ >>> Before compiling: Please remove comment from the constructor of the >>> connected graphics display (see below). - Universal 8bit Graphics Library, http://code.google.com/p/u8glib/ + Universal 8bit Graphics Library, https://github.com/olikraus/u8glib/ Copyright (c) 2012, olikraus@gmail.com All rights reserved. @@ -43,7 +43,7 @@ // setup u8g object, please remove comment from one of the following constructor calls // IMPORTANT NOTE: The following list is incomplete. The complete list of supported -// devices with all constructor calls is here: http://code.google.com/p/u8glib/wiki/device +// devices with all constructor calls is here: https://github.com/olikraus/u8glib/wiki/device //U8GLIB_NHD27OLED_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_NHD27OLED_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_NHD27OLED_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 diff --git a/sys/arduino/Console/Console.pde b/sys/arduino/Console/Console.pde index 70e0e2f0..b04274b3 100644 --- a/sys/arduino/Console/Console.pde +++ b/sys/arduino/Console/Console.pde @@ -7,7 +7,7 @@ >>> Before compiling: Please remove comment from the constructor of the >>> connected graphics display (see below). - Universal 8bit Graphics Library, http://code.google.com/p/u8glib/ + Universal 8bit Graphics Library, https://github.com/olikraus/u8glib/ Copyright (c) 2011, olikraus@gmail.com All rights reserved. @@ -43,7 +43,7 @@ // setup u8g object, please remove comment from one of the following constructor calls // IMPORTANT NOTE: The following list is incomplete. The complete list of supported -// devices with all constructor calls is here: http://code.google.com/p/u8glib/wiki/device +// devices with all constructor calls is here: https://github.com/olikraus/u8glib/wiki/device //U8GLIB_NHD27OLED_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_NHD27OLED_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_NHD27OLED_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 @@ -95,6 +95,9 @@ //U8GLIB_SSD1306_128X32 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_SSD1306_128X32 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) //U8GLIB_SSD1306_128X32 u8g(U8G_I2C_OPT_NONE); // I2C / TWI +//U8GLIB_SSD1306_64X48 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 +//U8GLIB_SSD1306_64X48 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_SSD1306_64X48 u8g(U8G_I2C_OPT_NONE); // I2C / TWI //U8GLIB_SH1106_128X64 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_SH1106_128X64 u8g(4, 5, 6, 7); // SW SPI Com: SCK = 4, MOSI = 5, CS = 6, A0 = 7 (new blue HalTec OLED) //U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_NONE); // I2C / TWI @@ -106,9 +109,12 @@ //U8GLIB_UC1611_DOGM240 u8g(U8G_I2C_OPT_NONE); // I2C //U8GLIB_UC1611_DOGM240 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_UC1611_DOGM240 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_UC1611_DOGM240 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_UC1611_DOGM240 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 3, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=3, di/a0=17,rw=16 //U8GLIB_UC1611_DOGXL240 u8g(U8G_I2C_OPT_NONE); // I2C //U8GLIB_UC1611_DOGXL240 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_UC1611_DOGXL240 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_UC1611_DOGXL240 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 3, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=3, di/a0=17,rw=16 //U8GLIB_NHD_C12864 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 //U8GLIB_NHD_C12832 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 //U8GLIB_LD7032_60x32 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 diff --git a/sys/arduino/Contrast/Contrast.pde b/sys/arduino/Contrast/Contrast.pde index 5e4197ce..e35429a4 100644 --- a/sys/arduino/Contrast/Contrast.pde +++ b/sys/arduino/Contrast/Contrast.pde @@ -7,7 +7,7 @@ >>> Before compiling: Please remove comment from the constructor of the >>> connected graphics display (see below). - Universal 8bit Graphics Library, http://code.google.com/p/u8glib/ + Universal 8bit Graphics Library, https://github.com/olikraus/u8glib/ Copyright (c) 2012, olikraus@gmail.com All rights reserved. @@ -43,7 +43,7 @@ // setup u8g object, please remove comment from one of the following constructor calls // IMPORTANT NOTE: The following list is incomplete. The complete list of supported -// devices with all constructor calls is here: http://code.google.com/p/u8glib/wiki/device +// devices with all constructor calls is here: https://github.com/olikraus/u8glib/wiki/device //U8GLIB_NHD27OLED_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_NHD27OLED_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_NHD27OLED_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 @@ -95,6 +95,9 @@ //U8GLIB_SSD1306_128X32 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_SSD1306_128X32 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) //U8GLIB_SSD1306_128X32 u8g(U8G_I2C_OPT_NONE); // I2C / TWI +//U8GLIB_SSD1306_64X48 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 +//U8GLIB_SSD1306_64X48 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_SSD1306_64X48 u8g(U8G_I2C_OPT_NONE); // I2C / TWI //U8GLIB_SH1106_128X64 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_SH1106_128X64 u8g(4, 5, 6, 7); // SW SPI Com: SCK = 4, MOSI = 5, CS = 6, A0 = 7 (new blue HalTec OLED) //U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_NONE); // I2C / TWI @@ -106,9 +109,12 @@ //U8GLIB_UC1611_DOGM240 u8g(U8G_I2C_OPT_NONE); // I2C //U8GLIB_UC1611_DOGM240 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_UC1611_DOGM240 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_UC1611_DOGM240 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_UC1611_DOGM240 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 3, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=3, di/a0=17,rw=16 //U8GLIB_UC1611_DOGXL240 u8g(U8G_I2C_OPT_NONE); // I2C //U8GLIB_UC1611_DOGXL240 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_UC1611_DOGXL240 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_UC1611_DOGXL240 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 3, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=3, di/a0=17,rw=16 //U8GLIB_NHD_C12864 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 //U8GLIB_NHD_C12832 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 //U8GLIB_LD7032_60x32 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 diff --git a/sys/arduino/F/F.pde b/sys/arduino/F/F.pde index 4393ddfe..d631dbac 100644 --- a/sys/arduino/F/F.pde +++ b/sys/arduino/F/F.pde @@ -9,7 +9,7 @@ >>> Before compiling: Please remove comment from the constructor of the >>> connected graphics display (see below). - Universal 8bit Graphics Library, http://code.google.com/p/u8glib/ + Universal 8bit Graphics Library, https://github.com/olikraus/u8glib/ Copyright (c) 2012, olikraus@gmail.com All rights reserved. @@ -45,7 +45,7 @@ // setup u8g object, please remove comment from one of the following constructor calls // IMPORTANT NOTE: The following list is incomplete. The complete list of supported -// devices with all constructor calls is here: http://code.google.com/p/u8glib/wiki/device +// devices with all constructor calls is here: https://github.com/olikraus/u8glib/wiki/device //U8GLIB_NHD27OLED_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_NHD27OLED_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_NHD27OLED_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 @@ -97,6 +97,9 @@ //U8GLIB_SSD1306_128X32 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_SSD1306_128X32 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) //U8GLIB_SSD1306_128X32 u8g(U8G_I2C_OPT_NONE); // I2C / TWI +//U8GLIB_SSD1306_64X48 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 +//U8GLIB_SSD1306_64X48 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_SSD1306_64X48 u8g(U8G_I2C_OPT_NONE); // I2C / TWI //U8GLIB_SH1106_128X64 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_SH1106_128X64 u8g(4, 5, 6, 7); // SW SPI Com: SCK = 4, MOSI = 5, CS = 6, A0 = 7 (new blue HalTec OLED) //U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_NONE); // I2C / TWI @@ -108,9 +111,12 @@ //U8GLIB_UC1611_DOGM240 u8g(U8G_I2C_OPT_NONE); // I2C //U8GLIB_UC1611_DOGM240 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_UC1611_DOGM240 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_UC1611_DOGM240 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_UC1611_DOGM240 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 3, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=3, di/a0=17,rw=16 //U8GLIB_UC1611_DOGXL240 u8g(U8G_I2C_OPT_NONE); // I2C //U8GLIB_UC1611_DOGXL240 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_UC1611_DOGXL240 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_UC1611_DOGXL240 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 3, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=3, di/a0=17,rw=16 //U8GLIB_NHD_C12864 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 //U8GLIB_NHD_C12832 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 //U8GLIB_LD7032_60x32 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 diff --git a/sys/arduino/FPS/FPS.pde b/sys/arduino/FPS/FPS.pde index bcf93cd5..ef91352a 100644 --- a/sys/arduino/FPS/FPS.pde +++ b/sys/arduino/FPS/FPS.pde @@ -5,7 +5,7 @@ >>> Before compiling: Please remove comment from the constructor of the >>> connected graphics display (see below). - Universal 8bit Graphics Library, http://code.google.com/p/u8glib/ + Universal 8bit Graphics Library, https://github.com/olikraus/u8glib/ Copyright (c) 2012, olikraus@gmail.com All rights reserved. @@ -116,6 +116,11 @@ Due NHD27OLED_GR u8g(10, 9) HW SPI FPS: Clip=34.1 Box=11.7 @=13.7 Pix=5.6 Due NHD27OLED_2X_GR u8g(10, 9) HW SPI FPS: Clip=38.1 Box=15.5 @=20.0 Pix=8.8 + + 28. Apr 2016 + Uno DOGS102 u8g(13, 11, 10, 9); SW SPI FPS: Clip=26.6 Box=6.1 @=8.5 Pix=2.8 11548 Bytes + Uno DOGS102 u8g(10, 9); HW SPI FPS: Clip=33.1 Box=6.4 @=9.1 Pix=2.9 11366 Bytes + */ @@ -123,7 +128,7 @@ // setup u8g object, please remove comment from one of the following constructor calls // IMPORTANT NOTE: The following list is incomplete. The complete list of supported -// devices with all constructor calls is here: http://code.google.com/p/u8glib/wiki/device +// devices with all constructor calls is here: https://github.com/olikraus/u8glib/wiki/device //U8GLIB_NHD27OLED_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_NHD27OLED_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_NHD27OLED_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 @@ -175,6 +180,9 @@ //U8GLIB_SSD1306_128X32 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_SSD1306_128X32 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) //U8GLIB_SSD1306_128X32 u8g(U8G_I2C_OPT_NONE); // I2C / TWI +//U8GLIB_SSD1306_64X48 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 +//U8GLIB_SSD1306_64X48 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_SSD1306_64X48 u8g(U8G_I2C_OPT_NONE); // I2C / TWI //U8GLIB_SH1106_128X64 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_SH1106_128X64 u8g(4, 5, 6, 7); // SW SPI Com: SCK = 4, MOSI = 5, CS = 6, A0 = 7 (new blue HalTec OLED) //U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_NONE); // I2C / TWI @@ -186,9 +194,12 @@ //U8GLIB_UC1611_DOGM240 u8g(U8G_I2C_OPT_NONE); // I2C //U8GLIB_UC1611_DOGM240 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_UC1611_DOGM240 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_UC1611_DOGM240 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_UC1611_DOGM240 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 3, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=3, di/a0=17,rw=16 //U8GLIB_UC1611_DOGXL240 u8g(U8G_I2C_OPT_NONE); // I2C //U8GLIB_UC1611_DOGXL240 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_UC1611_DOGXL240 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_UC1611_DOGXL240 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 3, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=3, di/a0=17,rw=16 //U8GLIB_NHD_C12864 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 //U8GLIB_NHD_C12832 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 //U8GLIB_LD7032_60x32 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 diff --git a/sys/arduino/FPS/Makefile.105.uno b/sys/arduino/FPS/Makefile.105.uno new file mode 100644 index 00000000..bbf951d8 --- /dev/null +++ b/sys/arduino/FPS/Makefile.105.uno @@ -0,0 +1,285 @@ + +# +# Arduino-1.0 Makefile +# +# written by olikraus@gmail.com +# +# Features: +# - boards.txt is used to derive parameters +# - All intermediate files are put into a separate directory (TMPDIRNAME) +# - Simple use: Copy Makefile into the same directory of the .pde file +# +# Limitations: +# - requires UNIX environment +# - TMPDIRNAME must be subdirectory of the current directory. +# +# Targets +# all build everything +# upload build and upload to arduino +# clean remove all temporary files (includes final hex file) +# +# History +# 001 28 Apr 2010 first release +# 002 05 Oct 2010 added 'uno' +# 003 06 Dec 2011 arduino 1.0 +# 004 11 Feb 2012 u8glib +# + +#=== user configuration === +# All ...PATH variables must have a '/' at the end + +# Board (and prozessor) information: see $(ARDUINO_PATH)hardware/arduino/boards.txt +# Some examples: +# BOARD DESCRIPTION +# uno Arduino Uno +# atmega328 Arduino Duemilanove or Nano w/ ATmega328 +# diecimila Arduino Diecimila, Duemilanove, or Nano w/ ATmega168 +# mega Arduino Mega +# mega2560 Arduino Mega2560 +# mini Arduino Mini +# lilypad328 LilyPad Arduino w/ ATmega328 +BOARD:=uno + +# additional definitions +#DEFS:=-DARDUINO=105 + + +U8G_PATH:=$(shell cd ../../.. && pwd)/csrc/ +U8G_CPP_PATH:=$(shell cd ../../.. && pwd)/cppsrc/ +U8G_FONT_PATH:=$(shell cd ../../.. && pwd)/sfntsrc/ + + +# The location where the avr tools (e.g. avr-gcc) are located. Requires a '/' at the end. +# Can be empty if all tools are accessable through the search path +AVR_TOOLS_PATH:=/usr/bin/ + +# Install path of the arduino software. Requires a '/' at the end. +ARDUINO_PATH:=/home/kraus/prg/arduino-1.0.5-u8glib/ + +# Install path for avrdude. Requires a '/' at the end. Can be empty if avrdude is in the search path. +AVRDUDE_PATH:=$(ARDUINO_PATH)hardware/tools/ + +# The unix device where we can reach the arduino board +# Uno: /dev/ttyACM0 +# Duemilanove: /dev/ttyUSB0 +AVRDUDE_PORT:=/dev/ttyACM0 + +# List of all libaries which should be included. +EXTRA_DIRS=$(ARDUINO_PATH)libraries/LiquidCrystal/ +EXTRA_DIRS+=$(ARDUINO_PATH)libraries/SD/ +EXTRA_DIRS+=$(ARDUINO_PATH)libraries/SD/utility/ +EXTRA_DIRS+=$(ARDUINO_PATH)libraries/SPI/ +#EXTRA_DIRS+=$(ARDUINO_PATH)libraries/.../ + +#=== fetch parameter from boards.txt processor parameter === +# the basic idea is to get most of the information from boards.txt + +BOARDS_TXT:=$(ARDUINO_PATH)hardware/arduino/boards.txt + +# get the MCU value from the $(BOARD).build.mcu variable. For the atmega328 board this is atmega328p +MCU:=$(shell sed -n -e "s/$(BOARD).build.mcu=\(.*\)/\1/p" $(BOARDS_TXT)) +# get the F_CPU value from the $(BOARD).build.f_cpu variable. For the atmega328 board this is 16000000 +F_CPU:=$(shell sed -n -e "s/$(BOARD).build.f_cpu=\(.*\)/\1/p" $(BOARDS_TXT)) +# get variant subfolder +VARIANT:=$(shell sed -n -e "s/$(BOARD).build.variant=\(.*\)/\1/p" $(BOARDS_TXT)) + + +# avrdude +# get the AVRDUDE_UPLOAD_RATE value from the $(BOARD).upload.speed variable. For the atmega328 board this is 57600 +AVRDUDE_UPLOAD_RATE:=$(shell sed -n -e "s/$(BOARD).upload.speed=\(.*\)/\1/p" $(BOARDS_TXT)) +# get the AVRDUDE_PROGRAMMER value from the $(BOARD).upload.protocol variable. For the atmega328 board this is stk500 +AVRDUDE_PROGRAMMER:=$(shell sed -n -e "s/$(BOARD).upload.protocol=\(.*\)/\1/p" $(BOARDS_TXT)) +# use stk500v1, because stk500 will default to stk500v2 +#AVRDUDE_PROGRAMMER:=stk500v1 + +#=== identify user files === +PDESRC:=$(shell ls *.pde) +TARGETNAME=$(basename $(PDESRC)) + +CDIRS:=$(EXTRA_DIRS) $(addsuffix utility/,$(EXTRA_DIRS)) +CDIRS:=*.c utility/*.c $(U8G_PATH)*.c $(U8G_FONT_PATH)*.c $(addsuffix *.c,$(CDIRS)) $(ARDUINO_PATH)hardware/arduino/cores/arduino/*.c +CSRC:=$(shell ls $(CDIRS) 2>/dev/null) + +CCSRC:=$(shell ls *.cc 2>/dev/null) + +CPPDIRS:=$(EXTRA_DIRS) $(addsuffix utility/,$(EXTRA_DIRS)) +CPPDIRS:=*.cpp utility/*.cpp $(addsuffix *.cpp,$(CPPDIRS)) $(U8G_CPP_PATH)/*.cpp $(ARDUINO_PATH)hardware/arduino/cores/arduino/*.cpp +CPPSRC:=$(shell ls $(CPPDIRS) 2>/dev/null) + +#=== build internal variables === + +# the name of the subdirectory where everything is stored +TMPDIRNAME:=tmp +TMPDIRPATH:=$(TMPDIRNAME)/ + +AVRTOOLSPATH:=$(AVR_TOOLS_PATH) + +OBJCOPY:=$(AVRTOOLSPATH)avr-objcopy +OBJDUMP:=$(AVRTOOLSPATH)avr-objdump +SIZE:=$(AVRTOOLSPATH)avr-size + +CPPSRC:=$(addprefix $(TMPDIRPATH),$(PDESRC:.pde=.cpp)) $(CPPSRC) + +COBJ:=$(CSRC:.c=.o) +CCOBJ:=$(CCSRC:.cc=.o) +CPPOBJ:=$(CPPSRC:.cpp=.o) + +OBJFILES:=$(COBJ) $(CCOBJ) $(CPPOBJ) +DIRS:= $(dir $(OBJFILES)) + +DEPFILES:=$(OBJFILES:.o=.d) +# assembler files from avr-gcc -S +ASSFILES:=$(OBJFILES:.o=.s) +# disassembled object files with avr-objdump -S +DISFILES:=$(OBJFILES:.o=.dis) + + +LIBNAME:=$(TMPDIRPATH)$(TARGETNAME).a +ELFNAME:=$(TMPDIRPATH)$(TARGETNAME).elf +HEXNAME:=$(TMPDIRPATH)$(TARGETNAME).hex + +AVRDUDE_FLAGS = -V -F +AVRDUDE_FLAGS += -C $(ARDUINO_PATH)/hardware/tools/avrdude.conf +AVRDUDE_FLAGS += -p $(MCU) +AVRDUDE_FLAGS += -P $(AVRDUDE_PORT) +AVRDUDE_FLAGS += -c $(AVRDUDE_PROGRAMMER) +AVRDUDE_FLAGS += -b $(AVRDUDE_UPLOAD_RATE) +AVRDUDE_FLAGS += -U flash:w:$(HEXNAME) + +AVRDUDE = $(AVRDUDE_PATH)avrdude + +#=== predefined variable override === +# use "make -p -f/dev/null" to see the default rules and definitions + +# Build C and C++ flags. Include path information must be placed here +COMMON_FLAGS = -DF_CPU=$(F_CPU) -mmcu=$(MCU) $(DEFS) -DARDUINO=100 +# COMMON_FLAGS += -gdwarf-2 +COMMON_FLAGS += -Os +COMMON_FLAGS += -Wall -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums +COMMON_FLAGS += -I. +COMMON_FLAGS += -I$(ARDUINO_PATH)hardware/arduino/cores/arduino +COMMON_FLAGS += -I$(ARDUINO_PATH)hardware/arduino/variants/$(VARIANT) +COMMON_FLAGS += -I. -I$(U8G_PATH) -I$(U8G_CPP_PATH) +COMMON_FLAGS += $(addprefix -I,$(EXTRA_DIRS)) +COMMON_FLAGS += -ffunction-sections -fdata-sections -Wl,--gc-sections +COMMON_FLAGS += -Wl,--Map=output.map +COMMON_FLAGS += -Wl,--relax +COMMON_FLAGS += -mcall-prologues + +CFLAGS = $(COMMON_FLAGS) -std=gnu99 -Wstrict-prototypes +CXXFLAGS = $(COMMON_FLAGS) + +# Replace standard build tools by avr tools +CC = $(AVRTOOLSPATH)avr-gcc +CXX = $(AVRTOOLSPATH)avr-g++ +AR = @$(AVRTOOLSPATH)avr-ar + + +# "rm" must be able to delete a directory tree +RM = rm -rf + +#=== rules === + +# add rules for the C/C++ files where the .o file is placed in the TMPDIRPATH +# reuse existing variables as far as possible + +$(TMPDIRPATH)%.o: %.c + @echo compile $< + @$(COMPILE.c) $(OUTPUT_OPTION) $< + +$(TMPDIRPATH)%.o: %.cc + @echo compile $< + @$(COMPILE.cc) $(OUTPUT_OPTION) $< + +$(TMPDIRPATH)%.o: %.cpp + @echo compile $< + @$(COMPILE.cpp) $(OUTPUT_OPTION) $< + +$(TMPDIRPATH)%.s: %.c + @$(COMPILE.c) $(OUTPUT_OPTION) -S $< + +$(TMPDIRPATH)%.s: %.cc + @$(COMPILE.cc) $(OUTPUT_OPTION) -S $< + +$(TMPDIRPATH)%.s: %.cpp + @$(COMPILE.cpp) $(OUTPUT_OPTION) -S $< + +$(TMPDIRPATH)%.dis: $(TMPDIRPATH)%.o + @$(OBJDUMP) -S $< > $@ + +.SUFFIXES: .elf .hex .pde + +.elf.hex: + @$(OBJCOPY) -O ihex -R .eeprom $< $@ + +$(TMPDIRPATH)%.cpp: %.pde + @cat $(ARDUINO_PATH)hardware/arduino/cores/arduino/main.cpp > $@ + @cat $< >> $@ + @echo >> $@ + @echo 'extern "C" void __cxa_pure_virtual() { while (1); }' >> $@ + + +.PHONY: all +all: tmpdir $(HEXNAME) assemblersource showsize + ls -al $(HEXNAME) $(ELFNAME) + +$(ELFNAME): $(LIBNAME)($(addprefix $(TMPDIRPATH),$(OBJFILES))) + $(LINK.o) $(COMMON_FLAGS) $(LIBNAME) $(LOADLIBES) $(LDLIBS) -o $@ + +$(LIBNAME)(): $(addprefix $(TMPDIRPATH),$(OBJFILES)) + +#=== create temp directory === +# not really required, because it will be also created during the dependency handling +.PHONY: tmpdir +tmpdir: + @test -d $(TMPDIRPATH) || mkdir $(TMPDIRPATH) + +#=== create assembler files for each C/C++ file === +.PHONY: assemblersource +assemblersource: $(addprefix $(TMPDIRPATH),$(ASSFILES)) $(addprefix $(TMPDIRPATH),$(DISFILES)) + + +#=== show the section sizes of the ELF file === +.PHONY: showsize +showsize: $(ELFNAME) + $(SIZE) $< + +#=== clean up target === +# this is simple: the TMPDIRPATH is removed +.PHONY: clean +clean: + $(RM) $(TMPDIRPATH) + +# Program the device. +# step 1: reset the arduino board with the stty command +# step 2: user avrdude to upload the software +.PHONY: upload +upload: $(HEXNAME) + stty -F $(AVRDUDE_PORT) hupcl + $(AVRDUDE) $(AVRDUDE_FLAGS) + + +# === dependency handling === +# From the gnu make manual (section 4.14, Generating Prerequisites Automatically) +# Additionally (because this will be the first executed rule) TMPDIRPATH is created here. +# Instead of "sed" the "echo" command is used +# cd $(TMPDIRPATH); mkdir -p $(DIRS) 2> /dev/null; cd .. +DEPACTION=test -d $(TMPDIRPATH) || mkdir $(TMPDIRPATH);\ +mkdir -p $(addprefix $(TMPDIRPATH),$(DIRS));\ +set -e; echo -n $@ $(dir $@) > $@; $(CC) -MM $(COMMON_FLAGS) $< >> $@ + + +$(TMPDIRPATH)%.d: %.c + @$(DEPACTION) + +$(TMPDIRPATH)%.d: %.cc + @$(DEPACTION) + +$(TMPDIRPATH)%.d: %.cpp + @$(DEPACTION) + +# Include dependency files. If a .d file is missing, a warning is created and the .d file is created +# This warning is not a problem (gnu make manual, section 3.3 Including Other Makefiles) +-include $(addprefix $(TMPDIRPATH),$(DEPFILES)) + + diff --git a/sys/arduino/GraphicsTest/GraphicsTest.pde b/sys/arduino/GraphicsTest/GraphicsTest.pde index fc1c82fc..4dfcfa22 100644 --- a/sys/arduino/GraphicsTest/GraphicsTest.pde +++ b/sys/arduino/GraphicsTest/GraphicsTest.pde @@ -5,7 +5,7 @@ >>> Before compiling: Please remove comment from the constructor of the >>> connected graphics display (see below). - Universal 8bit Graphics Library, http://code.google.com/p/u8glib/ + Universal 8bit Graphics Library, https://github.com/olikraus/u8glib/ Copyright (c) 2012, olikraus@gmail.com All rights reserved. @@ -42,12 +42,12 @@ // setup u8g object, please remove comment from one of the following constructor calls // IMPORTANT NOTE: The following list is incomplete. The complete list of supported -// devices with all constructor calls is here: http://code.google.com/p/u8glib/wiki/device +// devices with all constructor calls is here: https://github.com/olikraus/u8glib/wiki/device //U8GLIB_NHD27OLED_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_NHD27OLED_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_NHD27OLED_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_NHD27OLED_2X_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 -//U8GLIB_NHD31OLED_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 +//U8GLIB_NHD31OLED_BW u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_NHD31OLED_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_NHD31OLED_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_NHD31OLED_2X_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 @@ -78,12 +78,12 @@ //U8GLIB_PCD8544 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8 //U8GLIB_PCF8812 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8 //U8GLIB_KS0108_128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs1=14, cs2=15,di=17,rw=16 -//U8GLIB_LC7981_160X80 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16 +U8GLIB_LC7981_160X80 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16 //U8GLIB_LC7981_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16 //U8GLIB_LC7981_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16 //U8GLIB_ILI9325D_320x240 u8g(18,17,19,U8G_PIN_NONE,16 ); // 8Bit Com: D0..D7: 0,1,2,3,4,5,6,7 en=wr=18, cs=17, rs=19, rd=U8G_PIN_NONE, reset = 16 //U8GLIB_SBN1661_122X32 u8g(8,9,10,11,4,5,6,7,14,15, 17, U8G_PIN_NONE, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 cs1=14, cs2=15,di=17,rw=16,reset = 16 -//U8GLIB_SSD1306_128X64 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 +//U8GLIB_SSD1306_128X64 u8g(13, 11, 10, 9, 8); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_SSD1306_128X64 u8g(4, 5, 6, 7); // SW SPI Com: SCK = 4, MOSI = 5, CS = 6, A0 = 7 (new white HalTec OLED) //U8GLIB_SSD1306_128X64 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) //U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE|U8G_I2C_OPT_DEV_0); // I2C / TWI @@ -94,6 +94,9 @@ //U8GLIB_SSD1306_128X32 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_SSD1306_128X32 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) //U8GLIB_SSD1306_128X32 u8g(U8G_I2C_OPT_NONE); // I2C / TWI +//U8GLIB_SSD1306_64X48 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 +//U8GLIB_SSD1306_64X48 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_SSD1306_64X48 u8g(U8G_I2C_OPT_NONE); // I2C / TWI //U8GLIB_SH1106_128X64 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_SH1106_128X64 u8g(4, 5, 6, 7); // SW SPI Com: SCK = 4, MOSI = 5, CS = 6, A0 = 7 (new blue HalTec OLED) //U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_NONE); // I2C / TWI @@ -105,9 +108,12 @@ //U8GLIB_UC1611_DOGM240 u8g(U8G_I2C_OPT_NONE); // I2C //U8GLIB_UC1611_DOGM240 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_UC1611_DOGM240 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_UC1611_DOGM240 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_UC1611_DOGM240 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 3, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=3, di/a0=17,rw=16 //U8GLIB_UC1611_DOGXL240 u8g(U8G_I2C_OPT_NONE); // I2C //U8GLIB_UC1611_DOGXL240 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_UC1611_DOGXL240 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_UC1611_DOGXL240 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 3, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=3, di/a0=17,rw=16 //U8GLIB_NHD_C12864 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 //U8GLIB_NHD_C12832 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 //U8GLIB_LD7032_60x32 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 @@ -133,8 +139,6 @@ //U8GLIB_SSD1351_128X128GH_332 u8g(8, 9, 7); // Arduino, HW SPI Com: SCK = 76, MOSI = 75, CS = 8, A0 = 9, RESET = 7 (Freetronics OLED) //U8GLIB_SSD1351_128X128GH_HICOLOR u8g(8, 9, 7); // Arduino, HW SPI Com: SCK = 76, MOSI = 75, CS = 8, A0 = 9, RESET = 7 (Freetronics OLED) -U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NO_ACK); - void u8g_prepare(void) { u8g.setFont(u8g_font_6x10); u8g.setFontRefHeightExtendedText(); diff --git a/sys/arduino/GraphicsTest/Makefile.105.duemilanove b/sys/arduino/GraphicsTest/Makefile.105.duemilanove new file mode 100644 index 00000000..ea996947 --- /dev/null +++ b/sys/arduino/GraphicsTest/Makefile.105.duemilanove @@ -0,0 +1,285 @@ + +# +# Arduino-1.0 Makefile +# +# written by olikraus@gmail.com +# +# Features: +# - boards.txt is used to derive parameters +# - All intermediate files are put into a separate directory (TMPDIRNAME) +# - Simple use: Copy Makefile into the same directory of the .pde file +# +# Limitations: +# - requires UNIX environment +# - TMPDIRNAME must be subdirectory of the current directory. +# +# Targets +# all build everything +# upload build and upload to arduino +# clean remove all temporary files (includes final hex file) +# +# History +# 001 28 Apr 2010 first release +# 002 05 Oct 2010 added 'uno' +# 003 06 Dec 2011 arduino 1.0 +# 004 11 Feb 2012 u8glib +# + +#=== user configuration === +# All ...PATH variables must have a '/' at the end + +# Board (and prozessor) information: see $(ARDUINO_PATH)hardware/arduino/boards.txt +# Some examples: +# BOARD DESCRIPTION +# uno Arduino Uno +# atmega328 Arduino Duemilanove or Nano w/ ATmega328 +# diecimila Arduino Diecimila, Duemilanove, or Nano w/ ATmega168 +# mega Arduino Mega +# mega2560 Arduino Mega2560 +# mini Arduino Mini +# lilypad328 LilyPad Arduino w/ ATmega328 +BOARD:=atmega328 + +# additional definitions +#DEFS:=-DARDUINO=105 + + +U8G_PATH:=$(shell cd ../../.. && pwd)/csrc/ +U8G_CPP_PATH:=$(shell cd ../../.. && pwd)/cppsrc/ +U8G_FONT_PATH:=$(shell cd ../../.. && pwd)/sfntsrc/ + + +# The location where the avr tools (e.g. avr-gcc) are located. Requires a '/' at the end. +# Can be empty if all tools are accessable through the search path +AVR_TOOLS_PATH:=/usr/bin/ + +# Install path of the arduino software. Requires a '/' at the end. +ARDUINO_PATH:=/home/kraus/prg/arduino-1.0.5-u8glib/ + +# Install path for avrdude. Requires a '/' at the end. Can be empty if avrdude is in the search path. +AVRDUDE_PATH:=$(ARDUINO_PATH)hardware/tools/ + +# The unix device where we can reach the arduino board +# Uno: /dev/ttyACM0 +# Duemilanove: /dev/ttyUSB0 +AVRDUDE_PORT:=/dev/ttyUSB0 + +# List of all libaries which should be included. +EXTRA_DIRS=$(ARDUINO_PATH)libraries/LiquidCrystal/ +EXTRA_DIRS+=$(ARDUINO_PATH)libraries/SD/ +EXTRA_DIRS+=$(ARDUINO_PATH)libraries/SD/utility/ +EXTRA_DIRS+=$(ARDUINO_PATH)libraries/SPI/ +#EXTRA_DIRS+=$(ARDUINO_PATH)libraries/.../ + +#=== fetch parameter from boards.txt processor parameter === +# the basic idea is to get most of the information from boards.txt + +BOARDS_TXT:=$(ARDUINO_PATH)hardware/arduino/boards.txt + +# get the MCU value from the $(BOARD).build.mcu variable. For the atmega328 board this is atmega328p +MCU:=$(shell sed -n -e "s/$(BOARD).build.mcu=\(.*\)/\1/p" $(BOARDS_TXT)) +# get the F_CPU value from the $(BOARD).build.f_cpu variable. For the atmega328 board this is 16000000 +F_CPU:=$(shell sed -n -e "s/$(BOARD).build.f_cpu=\(.*\)/\1/p" $(BOARDS_TXT)) +# get variant subfolder +VARIANT:=$(shell sed -n -e "s/$(BOARD).build.variant=\(.*\)/\1/p" $(BOARDS_TXT)) + + +# avrdude +# get the AVRDUDE_UPLOAD_RATE value from the $(BOARD).upload.speed variable. For the atmega328 board this is 57600 +AVRDUDE_UPLOAD_RATE:=$(shell sed -n -e "s/$(BOARD).upload.speed=\(.*\)/\1/p" $(BOARDS_TXT)) +# get the AVRDUDE_PROGRAMMER value from the $(BOARD).upload.protocol variable. For the atmega328 board this is stk500 +AVRDUDE_PROGRAMMER:=$(shell sed -n -e "s/$(BOARD).upload.protocol=\(.*\)/\1/p" $(BOARDS_TXT)) +# use stk500v1, because stk500 will default to stk500v2 +#AVRDUDE_PROGRAMMER:=stk500v1 + +#=== identify user files === +PDESRC:=$(shell ls *.pde) +TARGETNAME=$(basename $(PDESRC)) + +CDIRS:=$(EXTRA_DIRS) $(addsuffix utility/,$(EXTRA_DIRS)) +CDIRS:=*.c utility/*.c $(U8G_PATH)*.c $(U8G_FONT_PATH)*.c $(addsuffix *.c,$(CDIRS)) $(ARDUINO_PATH)hardware/arduino/cores/arduino/*.c +CSRC:=$(shell ls $(CDIRS) 2>/dev/null) + +CCSRC:=$(shell ls *.cc 2>/dev/null) + +CPPDIRS:=$(EXTRA_DIRS) $(addsuffix utility/,$(EXTRA_DIRS)) +CPPDIRS:=*.cpp utility/*.cpp $(addsuffix *.cpp,$(CPPDIRS)) $(U8G_CPP_PATH)/*.cpp $(ARDUINO_PATH)hardware/arduino/cores/arduino/*.cpp +CPPSRC:=$(shell ls $(CPPDIRS) 2>/dev/null) + +#=== build internal variables === + +# the name of the subdirectory where everything is stored +TMPDIRNAME:=tmp +TMPDIRPATH:=$(TMPDIRNAME)/ + +AVRTOOLSPATH:=$(AVR_TOOLS_PATH) + +OBJCOPY:=$(AVRTOOLSPATH)avr-objcopy +OBJDUMP:=$(AVRTOOLSPATH)avr-objdump +SIZE:=$(AVRTOOLSPATH)avr-size + +CPPSRC:=$(addprefix $(TMPDIRPATH),$(PDESRC:.pde=.cpp)) $(CPPSRC) + +COBJ:=$(CSRC:.c=.o) +CCOBJ:=$(CCSRC:.cc=.o) +CPPOBJ:=$(CPPSRC:.cpp=.o) + +OBJFILES:=$(COBJ) $(CCOBJ) $(CPPOBJ) +DIRS:= $(dir $(OBJFILES)) + +DEPFILES:=$(OBJFILES:.o=.d) +# assembler files from avr-gcc -S +ASSFILES:=$(OBJFILES:.o=.s) +# disassembled object files with avr-objdump -S +DISFILES:=$(OBJFILES:.o=.dis) + + +LIBNAME:=$(TMPDIRPATH)$(TARGETNAME).a +ELFNAME:=$(TMPDIRPATH)$(TARGETNAME).elf +HEXNAME:=$(TMPDIRPATH)$(TARGETNAME).hex + +AVRDUDE_FLAGS = -V -F +AVRDUDE_FLAGS += -C $(ARDUINO_PATH)/hardware/tools/avrdude.conf +AVRDUDE_FLAGS += -p $(MCU) +AVRDUDE_FLAGS += -P $(AVRDUDE_PORT) +AVRDUDE_FLAGS += -c $(AVRDUDE_PROGRAMMER) +AVRDUDE_FLAGS += -b $(AVRDUDE_UPLOAD_RATE) +AVRDUDE_FLAGS += -U flash:w:$(HEXNAME) + +AVRDUDE = $(AVRDUDE_PATH)avrdude + +#=== predefined variable override === +# use "make -p -f/dev/null" to see the default rules and definitions + +# Build C and C++ flags. Include path information must be placed here +COMMON_FLAGS = -DF_CPU=$(F_CPU) -mmcu=$(MCU) $(DEFS) -DARDUINO=100 +# COMMON_FLAGS += -gdwarf-2 +COMMON_FLAGS += -Os +COMMON_FLAGS += -Wall -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums +COMMON_FLAGS += -I. +COMMON_FLAGS += -I$(ARDUINO_PATH)hardware/arduino/cores/arduino +COMMON_FLAGS += -I$(ARDUINO_PATH)hardware/arduino/variants/$(VARIANT) +COMMON_FLAGS += -I. -I$(U8G_PATH) -I$(U8G_CPP_PATH) +COMMON_FLAGS += $(addprefix -I,$(EXTRA_DIRS)) +COMMON_FLAGS += -ffunction-sections -fdata-sections -Wl,--gc-sections +COMMON_FLAGS += -Wl,--Map=output.map +COMMON_FLAGS += -Wl,--relax +COMMON_FLAGS += -mcall-prologues + +CFLAGS = $(COMMON_FLAGS) -std=gnu99 -Wstrict-prototypes +CXXFLAGS = $(COMMON_FLAGS) + +# Replace standard build tools by avr tools +CC = $(AVRTOOLSPATH)avr-gcc +CXX = $(AVRTOOLSPATH)avr-g++ +AR = @$(AVRTOOLSPATH)avr-ar + + +# "rm" must be able to delete a directory tree +RM = rm -rf + +#=== rules === + +# add rules for the C/C++ files where the .o file is placed in the TMPDIRPATH +# reuse existing variables as far as possible + +$(TMPDIRPATH)%.o: %.c + @echo compile $< + @$(COMPILE.c) $(OUTPUT_OPTION) $< + +$(TMPDIRPATH)%.o: %.cc + @echo compile $< + @$(COMPILE.cc) $(OUTPUT_OPTION) $< + +$(TMPDIRPATH)%.o: %.cpp + @echo compile $< + @$(COMPILE.cpp) $(OUTPUT_OPTION) $< + +$(TMPDIRPATH)%.s: %.c + @$(COMPILE.c) $(OUTPUT_OPTION) -S $< + +$(TMPDIRPATH)%.s: %.cc + @$(COMPILE.cc) $(OUTPUT_OPTION) -S $< + +$(TMPDIRPATH)%.s: %.cpp + @$(COMPILE.cpp) $(OUTPUT_OPTION) -S $< + +$(TMPDIRPATH)%.dis: $(TMPDIRPATH)%.o + @$(OBJDUMP) -S $< > $@ + +.SUFFIXES: .elf .hex .pde + +.elf.hex: + @$(OBJCOPY) -O ihex -R .eeprom $< $@ + +$(TMPDIRPATH)%.cpp: %.pde + @cat $(ARDUINO_PATH)hardware/arduino/cores/arduino/main.cpp > $@ + @cat $< >> $@ + @echo >> $@ + @echo 'extern "C" void __cxa_pure_virtual() { while (1); }' >> $@ + + +.PHONY: all +all: tmpdir $(HEXNAME) assemblersource showsize + ls -al $(HEXNAME) $(ELFNAME) + +$(ELFNAME): $(LIBNAME)($(addprefix $(TMPDIRPATH),$(OBJFILES))) + $(LINK.o) $(COMMON_FLAGS) $(LIBNAME) $(LOADLIBES) $(LDLIBS) -o $@ + +$(LIBNAME)(): $(addprefix $(TMPDIRPATH),$(OBJFILES)) + +#=== create temp directory === +# not really required, because it will be also created during the dependency handling +.PHONY: tmpdir +tmpdir: + @test -d $(TMPDIRPATH) || mkdir $(TMPDIRPATH) + +#=== create assembler files for each C/C++ file === +.PHONY: assemblersource +assemblersource: $(addprefix $(TMPDIRPATH),$(ASSFILES)) $(addprefix $(TMPDIRPATH),$(DISFILES)) + + +#=== show the section sizes of the ELF file === +.PHONY: showsize +showsize: $(ELFNAME) + $(SIZE) $< + +#=== clean up target === +# this is simple: the TMPDIRPATH is removed +.PHONY: clean +clean: + $(RM) $(TMPDIRPATH) + +# Program the device. +# step 1: reset the arduino board with the stty command +# step 2: user avrdude to upload the software +.PHONY: upload +upload: $(HEXNAME) + stty -F $(AVRDUDE_PORT) hupcl + $(AVRDUDE) $(AVRDUDE_FLAGS) + + +# === dependency handling === +# From the gnu make manual (section 4.14, Generating Prerequisites Automatically) +# Additionally (because this will be the first executed rule) TMPDIRPATH is created here. +# Instead of "sed" the "echo" command is used +# cd $(TMPDIRPATH); mkdir -p $(DIRS) 2> /dev/null; cd .. +DEPACTION=test -d $(TMPDIRPATH) || mkdir $(TMPDIRPATH);\ +mkdir -p $(addprefix $(TMPDIRPATH),$(DIRS));\ +set -e; echo -n $@ $(dir $@) > $@; $(CC) -MM $(COMMON_FLAGS) $< >> $@ + + +$(TMPDIRPATH)%.d: %.c + @$(DEPACTION) + +$(TMPDIRPATH)%.d: %.cc + @$(DEPACTION) + +$(TMPDIRPATH)%.d: %.cpp + @$(DEPACTION) + +# Include dependency files. If a .d file is missing, a warning is created and the .d file is created +# This warning is not a problem (gnu make manual, section 3.3 Including Other Makefiles) +-include $(addprefix $(TMPDIRPATH),$(DEPFILES)) + + diff --git a/sys/arduino/Hello0x0600/Hello0x0600.pde b/sys/arduino/Hello0x0600/Hello0x0600.pde index 4f4ebf0c..24a02603 100644 --- a/sys/arduino/Hello0x0600/Hello0x0600.pde +++ b/sys/arduino/Hello0x0600/Hello0x0600.pde @@ -7,7 +7,7 @@ >>> Before compiling: Please remove comment from the constructor of the >>> connected graphics display (see below). - Universal 8bit Graphics Library, http://code.google.com/p/u8glib/ + Universal 8bit Graphics Library, https://github.com/olikraus/u8glib/ Copyright (c) 2012, olikraus@gmail.com All rights reserved. @@ -42,7 +42,7 @@ #include "U8glib.h" // setup u8g object, please remove comment from one of the following constructor calls -// IMPORTANT NOTE: The complete list of supported devices is here: http://code.google.com/p/u8glib/wiki/device +// IMPORTANT NOTE: The complete list of supported devices is here: https://github.com/olikraus/u8glib/wiki/device //U8GLIB_NHD27OLED_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_NHD27OLED_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 diff --git a/sys/arduino/HelloWorld/HelloWorld.pde b/sys/arduino/HelloWorld/HelloWorld.pde index 3f5de1d2..032196f8 100644 --- a/sys/arduino/HelloWorld/HelloWorld.pde +++ b/sys/arduino/HelloWorld/HelloWorld.pde @@ -7,7 +7,7 @@ >>> Before compiling: Please remove comment from the constructor of the >>> connected graphics display (see below). - Universal 8bit Graphics Library, http://code.google.com/p/u8glib/ + Universal 8bit Graphics Library, https://github.com/olikraus/u8glib/ Copyright (c) 2012, olikraus@gmail.com All rights reserved. @@ -43,7 +43,7 @@ // setup u8g object, please remove comment from one of the following constructor calls // IMPORTANT NOTE: The following list is incomplete. The complete list of supported -// devices with all constructor calls is here: http://code.google.com/p/u8glib/wiki/device +// devices with all constructor calls is here: https://github.com/olikraus/u8glib/wiki/device //U8GLIB_NHD27OLED_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_NHD27OLED_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_NHD27OLED_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 @@ -84,6 +84,7 @@ //U8GLIB_LC7981_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16 //U8GLIB_ILI9325D_320x240 u8g(18,17,19,U8G_PIN_NONE,16 ); // 8Bit Com: D0..D7: 0,1,2,3,4,5,6,7 en=wr=18, cs=17, rs=19, rd=U8G_PIN_NONE, reset = 16 //U8GLIB_SBN1661_122X32 u8g(8,9,10,11,4,5,6,7,14,15, 17, U8G_PIN_NONE, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 cs1=14, cs2=15,di=17,rw=16,reset = 16 +//U8GLIB_SBN1661_122X32 u8g(8,9,10,11,4,5,6,7,A3,A2, A0, A1, A4); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 cs1=14, cs2=15,di=17,rw=16,reset = 16 //U8GLIB_SSD1306_128X64 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_SSD1306_128X64 u8g(4, 5, 6, 7); // SW SPI Com: SCK = 4, MOSI = 5, CS = 6, A0 = 7 (new white HalTec OLED) //U8GLIB_SSD1306_128X64 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) @@ -95,6 +96,9 @@ //U8GLIB_SSD1306_128X32 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_SSD1306_128X32 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) //U8GLIB_SSD1306_128X32 u8g(U8G_I2C_OPT_NONE); // I2C / TWI +//U8GLIB_SSD1306_64X48 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 +//U8GLIB_SSD1306_64X48 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_SSD1306_64X48 u8g(U8G_I2C_OPT_NONE); // I2C / TWI //U8GLIB_SH1106_128X64 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_SH1106_128X64 u8g(4, 5, 6, 7); // SW SPI Com: SCK = 4, MOSI = 5, CS = 6, A0 = 7 (new blue HalTec OLED) //U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_NONE); // I2C / TWI @@ -104,18 +108,19 @@ //U8GLIB_SSD1327_96X96_GR u8g(U8G_I2C_OPT_NONE); // I2C //U8GLIB_SSD1327_96X96_2X_GR u8g(U8G_I2C_OPT_NONE); // I2C //U8GLIB_UC1611_DOGM240 u8g(U8G_I2C_OPT_NONE); // I2C -//U8GLIB_UC1611_DOGM240 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 +//U8GLIB_UC1611_DOGM240 u8g(13, 11, 10, 9, 8); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 //U8GLIB_UC1611_DOGM240 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) //U8GLIB_UC1611_DOGM240 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) //U8GLIB_UC1611_DOGM240 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 3, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=3, di/a0=17,rw=16 //U8GLIB_UC1611_DOGXL240 u8g(U8G_I2C_OPT_NONE); // I2C -//U8GLIB_UC1611_DOGXL240 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 +//U8GLIB_UC1611_DOGXL240 u8g(13, 11, 10, 9, 8); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 //U8GLIB_UC1611_DOGXL240 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) //U8GLIB_UC1611_DOGXL240 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 3, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=3, di/a0=17,rw=16 //U8GLIB_NHD_C12864 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 //U8GLIB_NHD_C12832 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 //U8GLIB_LD7032_60x32 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 //U8GLIB_LD7032_60x32 u8g(11, 12, 9, 10, 8); // SPI Com: SCK = 11, MOSI = 12, CS = 9, A0 = 10, RST = 8 (SW SPI Nano Board) +//U8GLIB_LD7032_60x32 u8g(U8G_I2C_OPT_NONE); // I2C //U8GLIB_UC1608_240X64 u8g(13, 11, 10, 9, 8); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 //U8GLIB_UC1608_240X64_2X u8g(13, 11, 10, 9, 8); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 //U8GLIB_UC1608_240X64 u8g(10, 9, 8); // HW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 @@ -165,6 +170,8 @@ void setup(void) { else if ( u8g.getMode() == U8G_MODE_HICOLOR ) { u8g.setHiColorByRGB(255,255,255); } + + pinMode(8, OUTPUT); } void loop(void) { @@ -175,6 +182,6 @@ void loop(void) { } while( u8g.nextPage() ); // rebuild the picture after some delay - delay(50); + //delay(50); } diff --git a/sys/arduino/HelloWorld/Makefile.105.uno_ch341 b/sys/arduino/HelloWorld/Makefile.105.uno_ch341 new file mode 100644 index 00000000..4c52fa92 --- /dev/null +++ b/sys/arduino/HelloWorld/Makefile.105.uno_ch341 @@ -0,0 +1,286 @@ + +# +# Arduino-1.0 Makefile +# +# written by olikraus@gmail.com +# +# Features: +# - boards.txt is used to derive parameters +# - All intermediate files are put into a separate directory (TMPDIRNAME) +# - Simple use: Copy Makefile into the same directory of the .pde file +# +# Limitations: +# - requires UNIX environment +# - TMPDIRNAME must be subdirectory of the current directory. +# +# Targets +# all build everything +# upload build and upload to arduino +# clean remove all temporary files (includes final hex file) +# +# History +# 001 28 Apr 2010 first release +# 002 05 Oct 2010 added 'uno' +# 003 06 Dec 2011 arduino 1.0 +# 004 11 Feb 2012 u8glib +# + +#=== user configuration === +# All ...PATH variables must have a '/' at the end + +# Board (and prozessor) information: see $(ARDUINO_PATH)hardware/arduino/boards.txt +# Some examples: +# BOARD DESCRIPTION +# uno Arduino Uno +# atmega328 Arduino Duemilanove or Nano w/ ATmega328 +# diecimila Arduino Diecimila, Duemilanove, or Nano w/ ATmega168 +# mega Arduino Mega +# mega2560 Arduino Mega2560 +# mini Arduino Mini +# lilypad328 LilyPad Arduino w/ ATmega328 +BOARD:=uno + +# additional definitions +#DEFS:=-DARDUINO=105 + + +U8G_PATH:=$(shell cd ../../.. && pwd)/csrc/ +U8G_CPP_PATH:=$(shell cd ../../.. && pwd)/cppsrc/ +U8G_FONT_PATH:=$(shell cd ../../.. && pwd)/sfntsrc/ + + +# The location where the avr tools (e.g. avr-gcc) are located. Requires a '/' at the end. +# Can be empty if all tools are accessable through the search path +AVR_TOOLS_PATH:=/usr/bin/ + +# Install path of the arduino software. Requires a '/' at the end. +ARDUINO_PATH:=/home/kraus/prg/arduino-1.0.5-u8glib/ + +# Install path for avrdude. Requires a '/' at the end. Can be empty if avrdude is in the search path. +AVRDUDE_PATH:=$(ARDUINO_PATH)hardware/tools/ + +# The unix device where we can reach the arduino board +# Uno: /dev/ttyACM0 +# Duemilanove: /dev/ttyUSB0 +# AVRDUDE_PORT:=/dev/ttyACM0 +AVRDUDE_PORT:=/dev/ttyUSB0 + +# List of all libaries which should be included. +EXTRA_DIRS=$(ARDUINO_PATH)libraries/LiquidCrystal/ +EXTRA_DIRS+=$(ARDUINO_PATH)libraries/SD/ +EXTRA_DIRS+=$(ARDUINO_PATH)libraries/SD/utility/ +EXTRA_DIRS+=$(ARDUINO_PATH)libraries/SPI/ +#EXTRA_DIRS+=$(ARDUINO_PATH)libraries/.../ + +#=== fetch parameter from boards.txt processor parameter === +# the basic idea is to get most of the information from boards.txt + +BOARDS_TXT:=$(ARDUINO_PATH)hardware/arduino/boards.txt + +# get the MCU value from the $(BOARD).build.mcu variable. For the atmega328 board this is atmega328p +MCU:=$(shell sed -n -e "s/$(BOARD).build.mcu=\(.*\)/\1/p" $(BOARDS_TXT)) +# get the F_CPU value from the $(BOARD).build.f_cpu variable. For the atmega328 board this is 16000000 +F_CPU:=$(shell sed -n -e "s/$(BOARD).build.f_cpu=\(.*\)/\1/p" $(BOARDS_TXT)) +# get variant subfolder +VARIANT:=$(shell sed -n -e "s/$(BOARD).build.variant=\(.*\)/\1/p" $(BOARDS_TXT)) + + +# avrdude +# get the AVRDUDE_UPLOAD_RATE value from the $(BOARD).upload.speed variable. For the atmega328 board this is 57600 +AVRDUDE_UPLOAD_RATE:=$(shell sed -n -e "s/$(BOARD).upload.speed=\(.*\)/\1/p" $(BOARDS_TXT)) +# get the AVRDUDE_PROGRAMMER value from the $(BOARD).upload.protocol variable. For the atmega328 board this is stk500 +AVRDUDE_PROGRAMMER:=$(shell sed -n -e "s/$(BOARD).upload.protocol=\(.*\)/\1/p" $(BOARDS_TXT)) +# use stk500v1, because stk500 will default to stk500v2 +#AVRDUDE_PROGRAMMER:=stk500v1 + +#=== identify user files === +PDESRC:=$(shell ls *.pde) +TARGETNAME=$(basename $(PDESRC)) + +CDIRS:=$(EXTRA_DIRS) $(addsuffix utility/,$(EXTRA_DIRS)) +CDIRS:=*.c utility/*.c $(U8G_PATH)*.c $(U8G_FONT_PATH)*.c $(addsuffix *.c,$(CDIRS)) $(ARDUINO_PATH)hardware/arduino/cores/arduino/*.c +CSRC:=$(shell ls $(CDIRS) 2>/dev/null) + +CCSRC:=$(shell ls *.cc 2>/dev/null) + +CPPDIRS:=$(EXTRA_DIRS) $(addsuffix utility/,$(EXTRA_DIRS)) +CPPDIRS:=*.cpp utility/*.cpp $(addsuffix *.cpp,$(CPPDIRS)) $(U8G_CPP_PATH)/*.cpp $(ARDUINO_PATH)hardware/arduino/cores/arduino/*.cpp +CPPSRC:=$(shell ls $(CPPDIRS) 2>/dev/null) + +#=== build internal variables === + +# the name of the subdirectory where everything is stored +TMPDIRNAME:=tmp +TMPDIRPATH:=$(TMPDIRNAME)/ + +AVRTOOLSPATH:=$(AVR_TOOLS_PATH) + +OBJCOPY:=$(AVRTOOLSPATH)avr-objcopy +OBJDUMP:=$(AVRTOOLSPATH)avr-objdump +SIZE:=$(AVRTOOLSPATH)avr-size + +CPPSRC:=$(addprefix $(TMPDIRPATH),$(PDESRC:.pde=.cpp)) $(CPPSRC) + +COBJ:=$(CSRC:.c=.o) +CCOBJ:=$(CCSRC:.cc=.o) +CPPOBJ:=$(CPPSRC:.cpp=.o) + +OBJFILES:=$(COBJ) $(CCOBJ) $(CPPOBJ) +DIRS:= $(dir $(OBJFILES)) + +DEPFILES:=$(OBJFILES:.o=.d) +# assembler files from avr-gcc -S +ASSFILES:=$(OBJFILES:.o=.s) +# disassembled object files with avr-objdump -S +DISFILES:=$(OBJFILES:.o=.dis) + + +LIBNAME:=$(TMPDIRPATH)$(TARGETNAME).a +ELFNAME:=$(TMPDIRPATH)$(TARGETNAME).elf +HEXNAME:=$(TMPDIRPATH)$(TARGETNAME).hex + +AVRDUDE_FLAGS = -V -F +AVRDUDE_FLAGS += -C $(ARDUINO_PATH)/hardware/tools/avrdude.conf +AVRDUDE_FLAGS += -p $(MCU) +AVRDUDE_FLAGS += -P $(AVRDUDE_PORT) +AVRDUDE_FLAGS += -c $(AVRDUDE_PROGRAMMER) +AVRDUDE_FLAGS += -b $(AVRDUDE_UPLOAD_RATE) +AVRDUDE_FLAGS += -U flash:w:$(HEXNAME) + +AVRDUDE = $(AVRDUDE_PATH)avrdude + +#=== predefined variable override === +# use "make -p -f/dev/null" to see the default rules and definitions + +# Build C and C++ flags. Include path information must be placed here +COMMON_FLAGS = -DF_CPU=$(F_CPU) -mmcu=$(MCU) $(DEFS) -DARDUINO=100 +# COMMON_FLAGS += -gdwarf-2 +COMMON_FLAGS += -Os +COMMON_FLAGS += -Wall -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums +COMMON_FLAGS += -I. +COMMON_FLAGS += -I$(ARDUINO_PATH)hardware/arduino/cores/arduino +COMMON_FLAGS += -I$(ARDUINO_PATH)hardware/arduino/variants/$(VARIANT) +COMMON_FLAGS += -I. -I$(U8G_PATH) -I$(U8G_CPP_PATH) +COMMON_FLAGS += $(addprefix -I,$(EXTRA_DIRS)) +COMMON_FLAGS += -ffunction-sections -fdata-sections -Wl,--gc-sections +COMMON_FLAGS += -Wl,--Map=output.map +COMMON_FLAGS += -Wl,--relax +COMMON_FLAGS += -mcall-prologues + +CFLAGS = $(COMMON_FLAGS) -std=gnu99 -Wstrict-prototypes +CXXFLAGS = $(COMMON_FLAGS) + +# Replace standard build tools by avr tools +CC = $(AVRTOOLSPATH)avr-gcc +CXX = $(AVRTOOLSPATH)avr-g++ +AR = @$(AVRTOOLSPATH)avr-ar + + +# "rm" must be able to delete a directory tree +RM = rm -rf + +#=== rules === + +# add rules for the C/C++ files where the .o file is placed in the TMPDIRPATH +# reuse existing variables as far as possible + +$(TMPDIRPATH)%.o: %.c + @echo compile $< + @$(COMPILE.c) $(OUTPUT_OPTION) $< + +$(TMPDIRPATH)%.o: %.cc + @echo compile $< + @$(COMPILE.cc) $(OUTPUT_OPTION) $< + +$(TMPDIRPATH)%.o: %.cpp + @echo compile $< + @$(COMPILE.cpp) $(OUTPUT_OPTION) $< + +$(TMPDIRPATH)%.s: %.c + @$(COMPILE.c) $(OUTPUT_OPTION) -S $< + +$(TMPDIRPATH)%.s: %.cc + @$(COMPILE.cc) $(OUTPUT_OPTION) -S $< + +$(TMPDIRPATH)%.s: %.cpp + @$(COMPILE.cpp) $(OUTPUT_OPTION) -S $< + +$(TMPDIRPATH)%.dis: $(TMPDIRPATH)%.o + @$(OBJDUMP) -S $< > $@ + +.SUFFIXES: .elf .hex .pde + +.elf.hex: + @$(OBJCOPY) -O ihex -R .eeprom $< $@ + +$(TMPDIRPATH)%.cpp: %.pde + @cat $(ARDUINO_PATH)hardware/arduino/cores/arduino/main.cpp > $@ + @cat $< >> $@ + @echo >> $@ + @echo 'extern "C" void __cxa_pure_virtual() { while (1); }' >> $@ + + +.PHONY: all +all: tmpdir $(HEXNAME) assemblersource showsize + ls -al $(HEXNAME) $(ELFNAME) + +$(ELFNAME): $(LIBNAME)($(addprefix $(TMPDIRPATH),$(OBJFILES))) + $(LINK.o) $(COMMON_FLAGS) $(LIBNAME) $(LOADLIBES) $(LDLIBS) -o $@ + +$(LIBNAME)(): $(addprefix $(TMPDIRPATH),$(OBJFILES)) + +#=== create temp directory === +# not really required, because it will be also created during the dependency handling +.PHONY: tmpdir +tmpdir: + @test -d $(TMPDIRPATH) || mkdir $(TMPDIRPATH) + +#=== create assembler files for each C/C++ file === +.PHONY: assemblersource +assemblersource: $(addprefix $(TMPDIRPATH),$(ASSFILES)) $(addprefix $(TMPDIRPATH),$(DISFILES)) + + +#=== show the section sizes of the ELF file === +.PHONY: showsize +showsize: $(ELFNAME) + $(SIZE) $< + +#=== clean up target === +# this is simple: the TMPDIRPATH is removed +.PHONY: clean +clean: + $(RM) $(TMPDIRPATH) + +# Program the device. +# step 1: reset the arduino board with the stty command +# step 2: user avrdude to upload the software +.PHONY: upload +upload: $(HEXNAME) + stty -F $(AVRDUDE_PORT) hupcl + $(AVRDUDE) $(AVRDUDE_FLAGS) + + +# === dependency handling === +# From the gnu make manual (section 4.14, Generating Prerequisites Automatically) +# Additionally (because this will be the first executed rule) TMPDIRPATH is created here. +# Instead of "sed" the "echo" command is used +# cd $(TMPDIRPATH); mkdir -p $(DIRS) 2> /dev/null; cd .. +DEPACTION=test -d $(TMPDIRPATH) || mkdir $(TMPDIRPATH);\ +mkdir -p $(addprefix $(TMPDIRPATH),$(DIRS));\ +set -e; echo -n $@ $(dir $@) > $@; $(CC) -MM $(COMMON_FLAGS) $< >> $@ + + +$(TMPDIRPATH)%.d: %.c + @$(DEPACTION) + +$(TMPDIRPATH)%.d: %.cc + @$(DEPACTION) + +$(TMPDIRPATH)%.d: %.cpp + @$(DEPACTION) + +# Include dependency files. If a .d file is missing, a warning is created and the .d file is created +# This warning is not a problem (gnu make manual, section 3.3 Including Other Makefiles) +-include $(addprefix $(TMPDIRPATH),$(DEPFILES)) + + diff --git a/sys/arduino/HelloWorld/Makefile.165.uno b/sys/arduino/HelloWorld/Makefile.165.uno new file mode 100644 index 00000000..c10d6d52 --- /dev/null +++ b/sys/arduino/HelloWorld/Makefile.165.uno @@ -0,0 +1,286 @@ + +# +# Arduino-1.0 Makefile +# +# written by olikraus@gmail.com +# +# Features: +# - boards.txt is used to derive parameters +# - All intermediate files are put into a separate directory (TMPDIRNAME) +# - Simple use: Copy Makefile into the same directory of the .pde file +# +# Limitations: +# - requires UNIX environment +# - TMPDIRNAME must be subdirectory of the current directory. +# +# Targets +# all build everything +# upload build and upload to arduino +# clean remove all temporary files (includes final hex file) +# +# History +# 001 28 Apr 2010 first release +# 002 05 Oct 2010 added 'uno' +# 003 06 Dec 2011 arduino 1.0 +# 004 11 Feb 2012 u8glib +# 004 09 Aug 2015 Arduino 1.6.5 +# + +#=== user configuration === +# All ...PATH variables must have a '/' at the end + +# Board (and prozessor) information: see $(ARDUINO_PATH)hardware/arduino/avr/boards.txt +# Some examples: +# BOARD DESCRIPTION +# uno Arduino Uno +# atmega328 Arduino Duemilanove or Nano w/ ATmega328 +# diecimila Arduino Diecimila, Duemilanove, or Nano w/ ATmega168 +# mega Arduino Mega +# mega2560 Arduino Mega2560 +# mini Arduino Mini +# lilypad328 LilyPad Arduino w/ ATmega328 +BOARD:=uno + +# additional definitions +#DEFS:=-DARDUINO=165 + + +U8G_PATH:=$(shell cd ../../.. && pwd)/csrc/ +U8G_CPP_PATH:=$(shell cd ../../.. && pwd)/cppsrc/ +U8G_FONT_PATH:=$(shell cd ../../.. && pwd)/sfntsrc/ + + +# The location where the avr tools (e.g. avr-gcc) are located. Requires a '/' at the end. +# Can be empty if all tools are accessable through the search path +AVR_TOOLS_PATH:=/usr/bin/ + +# Install path of the arduino software. Requires a '/' at the end. +ARDUINO_PATH:=/home/kraus/prg/arduino-1.6.5/ + +# Install path for avrdude. Requires a '/' at the end. Can be empty if avrdude is in the search path. +AVRDUDE_PATH:=$(ARDUINO_PATH)hardware/tools/avr/bin/ + +# The unix device where we can reach the arduino board +# Uno: /dev/ttyACM0 +# Duemilanove: /dev/ttyUSB0 +AVRDUDE_PORT:=/dev/ttyACM0 + +# List of all libaries which should be included. +EXTRA_DIRS=$(ARDUINO_PATH)libraries/LiquidCrystal/ +EXTRA_DIRS+=$(ARDUINO_PATH)libraries/SD/ +EXTRA_DIRS+=$(ARDUINO_PATH)libraries/SD/utility/ +EXTRA_DIRS+=$(ARDUINO_PATH)libraries/SPI/ +#EXTRA_DIRS+=$(ARDUINO_PATH)libraries/.../ + +#=== fetch parameter from boards.txt processor parameter === +# the basic idea is to get most of the information from boards.txt + +BOARDS_TXT:=$(ARDUINO_PATH)hardware/arduino/avr/boards.txt + +# get the MCU value from the $(BOARD).build.mcu variable. For the atmega328 board this is atmega328p +MCU:=$(shell sed -n -e "s/$(BOARD).build.mcu=\(.*\)/\1/p" $(BOARDS_TXT)) +# get the F_CPU value from the $(BOARD).build.f_cpu variable. For the atmega328 board this is 16000000 +F_CPU:=$(shell sed -n -e "s/$(BOARD).build.f_cpu=\(.*\)/\1/p" $(BOARDS_TXT)) +# get variant subfolder +VARIANT:=$(shell sed -n -e "s/$(BOARD).build.variant=\(.*\)/\1/p" $(BOARDS_TXT)) + + +# avrdude +# get the AVRDUDE_UPLOAD_RATE value from the $(BOARD).upload.speed variable. For the atmega328 board this is 57600 +AVRDUDE_UPLOAD_RATE:=$(shell sed -n -e "s/$(BOARD).upload.speed=\(.*\)/\1/p" $(BOARDS_TXT)) +# get the AVRDUDE_PROGRAMMER value from the $(BOARD).upload.protocol variable. For the atmega328 board this is stk500 +AVRDUDE_PROGRAMMER:=$(shell sed -n -e "s/$(BOARD).upload.protocol=\(.*\)/\1/p" $(BOARDS_TXT)) +# use stk500v1, because stk500 will default to stk500v2 +#AVRDUDE_PROGRAMMER:=stk500v1 + +#=== identify user files === +PDESRC:=$(shell ls *.pde) +TARGETNAME=$(basename $(PDESRC)) + +CDIRS:=$(EXTRA_DIRS) $(addsuffix utility/,$(EXTRA_DIRS)) +CDIRS:=*.c utility/*.c $(U8G_PATH)*.c $(U8G_FONT_PATH)*.c $(addsuffix *.c,$(CDIRS)) $(ARDUINO_PATH)hardware/arduino/cores/arduino/*.c +CSRC:=$(shell ls $(CDIRS) 2>/dev/null) + +CCSRC:=$(shell ls *.cc 2>/dev/null) + +CPPDIRS:=$(EXTRA_DIRS) $(addsuffix utility/,$(EXTRA_DIRS)) +CPPDIRS:=*.cpp utility/*.cpp $(addsuffix *.cpp,$(CPPDIRS)) $(U8G_CPP_PATH)/*.cpp $(ARDUINO_PATH)hardware/arduino/cores/arduino/*.cpp +CPPSRC:=$(shell ls $(CPPDIRS) 2>/dev/null) + +#=== build internal variables === + +# the name of the subdirectory where everything is stored +TMPDIRNAME:=tmp +TMPDIRPATH:=$(TMPDIRNAME)/ + +AVRTOOLSPATH:=$(AVR_TOOLS_PATH) + +OBJCOPY:=$(AVRTOOLSPATH)avr-objcopy +OBJDUMP:=$(AVRTOOLSPATH)avr-objdump +SIZE:=$(AVRTOOLSPATH)avr-size + +CPPSRC:=$(addprefix $(TMPDIRPATH),$(PDESRC:.pde=.cpp)) $(CPPSRC) + +COBJ:=$(CSRC:.c=.o) +CCOBJ:=$(CCSRC:.cc=.o) +CPPOBJ:=$(CPPSRC:.cpp=.o) + +OBJFILES:=$(COBJ) $(CCOBJ) $(CPPOBJ) +DIRS:= $(dir $(OBJFILES)) + +DEPFILES:=$(OBJFILES:.o=.d) +# assembler files from avr-gcc -S +ASSFILES:=$(OBJFILES:.o=.s) +# disassembled object files with avr-objdump -S +DISFILES:=$(OBJFILES:.o=.dis) + + +LIBNAME:=$(TMPDIRPATH)$(TARGETNAME).a +ELFNAME:=$(TMPDIRPATH)$(TARGETNAME).elf +HEXNAME:=$(TMPDIRPATH)$(TARGETNAME).hex + +AVRDUDE_FLAGS = -V -F +AVRDUDE_FLAGS += -C $(ARDUINO_PATH)/hardware/tools/avrdude.conf +AVRDUDE_FLAGS += -p $(MCU) +AVRDUDE_FLAGS += -P $(AVRDUDE_PORT) +AVRDUDE_FLAGS += -c $(AVRDUDE_PROGRAMMER) +AVRDUDE_FLAGS += -b $(AVRDUDE_UPLOAD_RATE) +AVRDUDE_FLAGS += -U flash:w:$(HEXNAME) + +AVRDUDE = $(AVRDUDE_PATH)avrdude + +#=== predefined variable override === +# use "make -p -f/dev/null" to see the default rules and definitions + +# Build C and C++ flags. Include path information must be placed here +COMMON_FLAGS = -DF_CPU=$(F_CPU) -mmcu=$(MCU) $(DEFS) -DARDUINO=100 +# COMMON_FLAGS += -gdwarf-2 +COMMON_FLAGS += -Os +COMMON_FLAGS += -Wall -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums +COMMON_FLAGS += -I. +COMMON_FLAGS += -I$(ARDUINO_PATH)hardware/arduino/cores/arduino +COMMON_FLAGS += -I$(ARDUINO_PATH)hardware/arduino/variants/$(VARIANT) +COMMON_FLAGS += -I. -I$(U8G_PATH) -I$(U8G_CPP_PATH) +COMMON_FLAGS += $(addprefix -I,$(EXTRA_DIRS)) +COMMON_FLAGS += -ffunction-sections -fdata-sections -Wl,--gc-sections +COMMON_FLAGS += -Wl,--Map=output.map +COMMON_FLAGS += -Wl,--relax +COMMON_FLAGS += -mcall-prologues + +CFLAGS = $(COMMON_FLAGS) -std=gnu99 -Wstrict-prototypes +CXXFLAGS = $(COMMON_FLAGS) + +# Replace standard build tools by avr tools +CC = $(AVRTOOLSPATH)avr-gcc +CXX = $(AVRTOOLSPATH)avr-g++ +AR = @$(AVRTOOLSPATH)avr-ar + + +# "rm" must be able to delete a directory tree +RM = rm -rf + +#=== rules === + +# add rules for the C/C++ files where the .o file is placed in the TMPDIRPATH +# reuse existing variables as far as possible + +$(TMPDIRPATH)%.o: %.c + @echo compile $< + @$(COMPILE.c) $(OUTPUT_OPTION) $< + +$(TMPDIRPATH)%.o: %.cc + @echo compile $< + @$(COMPILE.cc) $(OUTPUT_OPTION) $< + +$(TMPDIRPATH)%.o: %.cpp + @echo compile $< + @$(COMPILE.cpp) $(OUTPUT_OPTION) $< + +$(TMPDIRPATH)%.s: %.c + @$(COMPILE.c) $(OUTPUT_OPTION) -S $< + +$(TMPDIRPATH)%.s: %.cc + @$(COMPILE.cc) $(OUTPUT_OPTION) -S $< + +$(TMPDIRPATH)%.s: %.cpp + @$(COMPILE.cpp) $(OUTPUT_OPTION) -S $< + +$(TMPDIRPATH)%.dis: $(TMPDIRPATH)%.o + @$(OBJDUMP) -S $< > $@ + +.SUFFIXES: .elf .hex .pde + +.elf.hex: + @$(OBJCOPY) -O ihex -R .eeprom $< $@ + +$(TMPDIRPATH)%.cpp: %.pde + @cat $(ARDUINO_PATH)hardware/arduino/cores/arduino/main.cpp > $@ + @cat $< >> $@ + @echo >> $@ + @echo 'extern "C" void __cxa_pure_virtual() { while (1); }' >> $@ + + +.PHONY: all +all: tmpdir $(HEXNAME) assemblersource showsize + ls -al $(HEXNAME) $(ELFNAME) + +$(ELFNAME): $(LIBNAME)($(addprefix $(TMPDIRPATH),$(OBJFILES))) + $(LINK.o) $(COMMON_FLAGS) $(LIBNAME) $(LOADLIBES) $(LDLIBS) -o $@ + +$(LIBNAME)(): $(addprefix $(TMPDIRPATH),$(OBJFILES)) + +#=== create temp directory === +# not really required, because it will be also created during the dependency handling +.PHONY: tmpdir +tmpdir: + @test -d $(TMPDIRPATH) || mkdir $(TMPDIRPATH) + +#=== create assembler files for each C/C++ file === +.PHONY: assemblersource +assemblersource: $(addprefix $(TMPDIRPATH),$(ASSFILES)) $(addprefix $(TMPDIRPATH),$(DISFILES)) + + +#=== show the section sizes of the ELF file === +.PHONY: showsize +showsize: $(ELFNAME) + $(SIZE) $< + +#=== clean up target === +# this is simple: the TMPDIRPATH is removed +.PHONY: clean +clean: + $(RM) $(TMPDIRPATH) + +# Program the device. +# step 1: reset the arduino board with the stty command +# step 2: user avrdude to upload the software +.PHONY: upload +upload: $(HEXNAME) + stty -F $(AVRDUDE_PORT) hupcl + $(AVRDUDE) $(AVRDUDE_FLAGS) + + +# === dependency handling === +# From the gnu make manual (section 4.14, Generating Prerequisites Automatically) +# Additionally (because this will be the first executed rule) TMPDIRPATH is created here. +# Instead of "sed" the "echo" command is used +# cd $(TMPDIRPATH); mkdir -p $(DIRS) 2> /dev/null; cd .. +DEPACTION=test -d $(TMPDIRPATH) || mkdir $(TMPDIRPATH);\ +mkdir -p $(addprefix $(TMPDIRPATH),$(DIRS));\ +set -e; echo -n $@ $(dir $@) > $@; $(CC) -MM $(COMMON_FLAGS) $< >> $@ + + +$(TMPDIRPATH)%.d: %.c + @$(DEPACTION) + +$(TMPDIRPATH)%.d: %.cc + @$(DEPACTION) + +$(TMPDIRPATH)%.d: %.cpp + @$(DEPACTION) + +# Include dependency files. If a .d file is missing, a warning is created and the .d file is created +# This warning is not a problem (gnu make manual, section 3.3 Including Other Makefiles) +-include $(addprefix $(TMPDIRPATH),$(DEPFILES)) + + diff --git a/sys/arduino/Menu/Makefile.105.uno b/sys/arduino/Menu/Makefile.105.uno new file mode 100644 index 00000000..bbf951d8 --- /dev/null +++ b/sys/arduino/Menu/Makefile.105.uno @@ -0,0 +1,285 @@ + +# +# Arduino-1.0 Makefile +# +# written by olikraus@gmail.com +# +# Features: +# - boards.txt is used to derive parameters +# - All intermediate files are put into a separate directory (TMPDIRNAME) +# - Simple use: Copy Makefile into the same directory of the .pde file +# +# Limitations: +# - requires UNIX environment +# - TMPDIRNAME must be subdirectory of the current directory. +# +# Targets +# all build everything +# upload build and upload to arduino +# clean remove all temporary files (includes final hex file) +# +# History +# 001 28 Apr 2010 first release +# 002 05 Oct 2010 added 'uno' +# 003 06 Dec 2011 arduino 1.0 +# 004 11 Feb 2012 u8glib +# + +#=== user configuration === +# All ...PATH variables must have a '/' at the end + +# Board (and prozessor) information: see $(ARDUINO_PATH)hardware/arduino/boards.txt +# Some examples: +# BOARD DESCRIPTION +# uno Arduino Uno +# atmega328 Arduino Duemilanove or Nano w/ ATmega328 +# diecimila Arduino Diecimila, Duemilanove, or Nano w/ ATmega168 +# mega Arduino Mega +# mega2560 Arduino Mega2560 +# mini Arduino Mini +# lilypad328 LilyPad Arduino w/ ATmega328 +BOARD:=uno + +# additional definitions +#DEFS:=-DARDUINO=105 + + +U8G_PATH:=$(shell cd ../../.. && pwd)/csrc/ +U8G_CPP_PATH:=$(shell cd ../../.. && pwd)/cppsrc/ +U8G_FONT_PATH:=$(shell cd ../../.. && pwd)/sfntsrc/ + + +# The location where the avr tools (e.g. avr-gcc) are located. Requires a '/' at the end. +# Can be empty if all tools are accessable through the search path +AVR_TOOLS_PATH:=/usr/bin/ + +# Install path of the arduino software. Requires a '/' at the end. +ARDUINO_PATH:=/home/kraus/prg/arduino-1.0.5-u8glib/ + +# Install path for avrdude. Requires a '/' at the end. Can be empty if avrdude is in the search path. +AVRDUDE_PATH:=$(ARDUINO_PATH)hardware/tools/ + +# The unix device where we can reach the arduino board +# Uno: /dev/ttyACM0 +# Duemilanove: /dev/ttyUSB0 +AVRDUDE_PORT:=/dev/ttyACM0 + +# List of all libaries which should be included. +EXTRA_DIRS=$(ARDUINO_PATH)libraries/LiquidCrystal/ +EXTRA_DIRS+=$(ARDUINO_PATH)libraries/SD/ +EXTRA_DIRS+=$(ARDUINO_PATH)libraries/SD/utility/ +EXTRA_DIRS+=$(ARDUINO_PATH)libraries/SPI/ +#EXTRA_DIRS+=$(ARDUINO_PATH)libraries/.../ + +#=== fetch parameter from boards.txt processor parameter === +# the basic idea is to get most of the information from boards.txt + +BOARDS_TXT:=$(ARDUINO_PATH)hardware/arduino/boards.txt + +# get the MCU value from the $(BOARD).build.mcu variable. For the atmega328 board this is atmega328p +MCU:=$(shell sed -n -e "s/$(BOARD).build.mcu=\(.*\)/\1/p" $(BOARDS_TXT)) +# get the F_CPU value from the $(BOARD).build.f_cpu variable. For the atmega328 board this is 16000000 +F_CPU:=$(shell sed -n -e "s/$(BOARD).build.f_cpu=\(.*\)/\1/p" $(BOARDS_TXT)) +# get variant subfolder +VARIANT:=$(shell sed -n -e "s/$(BOARD).build.variant=\(.*\)/\1/p" $(BOARDS_TXT)) + + +# avrdude +# get the AVRDUDE_UPLOAD_RATE value from the $(BOARD).upload.speed variable. For the atmega328 board this is 57600 +AVRDUDE_UPLOAD_RATE:=$(shell sed -n -e "s/$(BOARD).upload.speed=\(.*\)/\1/p" $(BOARDS_TXT)) +# get the AVRDUDE_PROGRAMMER value from the $(BOARD).upload.protocol variable. For the atmega328 board this is stk500 +AVRDUDE_PROGRAMMER:=$(shell sed -n -e "s/$(BOARD).upload.protocol=\(.*\)/\1/p" $(BOARDS_TXT)) +# use stk500v1, because stk500 will default to stk500v2 +#AVRDUDE_PROGRAMMER:=stk500v1 + +#=== identify user files === +PDESRC:=$(shell ls *.pde) +TARGETNAME=$(basename $(PDESRC)) + +CDIRS:=$(EXTRA_DIRS) $(addsuffix utility/,$(EXTRA_DIRS)) +CDIRS:=*.c utility/*.c $(U8G_PATH)*.c $(U8G_FONT_PATH)*.c $(addsuffix *.c,$(CDIRS)) $(ARDUINO_PATH)hardware/arduino/cores/arduino/*.c +CSRC:=$(shell ls $(CDIRS) 2>/dev/null) + +CCSRC:=$(shell ls *.cc 2>/dev/null) + +CPPDIRS:=$(EXTRA_DIRS) $(addsuffix utility/,$(EXTRA_DIRS)) +CPPDIRS:=*.cpp utility/*.cpp $(addsuffix *.cpp,$(CPPDIRS)) $(U8G_CPP_PATH)/*.cpp $(ARDUINO_PATH)hardware/arduino/cores/arduino/*.cpp +CPPSRC:=$(shell ls $(CPPDIRS) 2>/dev/null) + +#=== build internal variables === + +# the name of the subdirectory where everything is stored +TMPDIRNAME:=tmp +TMPDIRPATH:=$(TMPDIRNAME)/ + +AVRTOOLSPATH:=$(AVR_TOOLS_PATH) + +OBJCOPY:=$(AVRTOOLSPATH)avr-objcopy +OBJDUMP:=$(AVRTOOLSPATH)avr-objdump +SIZE:=$(AVRTOOLSPATH)avr-size + +CPPSRC:=$(addprefix $(TMPDIRPATH),$(PDESRC:.pde=.cpp)) $(CPPSRC) + +COBJ:=$(CSRC:.c=.o) +CCOBJ:=$(CCSRC:.cc=.o) +CPPOBJ:=$(CPPSRC:.cpp=.o) + +OBJFILES:=$(COBJ) $(CCOBJ) $(CPPOBJ) +DIRS:= $(dir $(OBJFILES)) + +DEPFILES:=$(OBJFILES:.o=.d) +# assembler files from avr-gcc -S +ASSFILES:=$(OBJFILES:.o=.s) +# disassembled object files with avr-objdump -S +DISFILES:=$(OBJFILES:.o=.dis) + + +LIBNAME:=$(TMPDIRPATH)$(TARGETNAME).a +ELFNAME:=$(TMPDIRPATH)$(TARGETNAME).elf +HEXNAME:=$(TMPDIRPATH)$(TARGETNAME).hex + +AVRDUDE_FLAGS = -V -F +AVRDUDE_FLAGS += -C $(ARDUINO_PATH)/hardware/tools/avrdude.conf +AVRDUDE_FLAGS += -p $(MCU) +AVRDUDE_FLAGS += -P $(AVRDUDE_PORT) +AVRDUDE_FLAGS += -c $(AVRDUDE_PROGRAMMER) +AVRDUDE_FLAGS += -b $(AVRDUDE_UPLOAD_RATE) +AVRDUDE_FLAGS += -U flash:w:$(HEXNAME) + +AVRDUDE = $(AVRDUDE_PATH)avrdude + +#=== predefined variable override === +# use "make -p -f/dev/null" to see the default rules and definitions + +# Build C and C++ flags. Include path information must be placed here +COMMON_FLAGS = -DF_CPU=$(F_CPU) -mmcu=$(MCU) $(DEFS) -DARDUINO=100 +# COMMON_FLAGS += -gdwarf-2 +COMMON_FLAGS += -Os +COMMON_FLAGS += -Wall -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums +COMMON_FLAGS += -I. +COMMON_FLAGS += -I$(ARDUINO_PATH)hardware/arduino/cores/arduino +COMMON_FLAGS += -I$(ARDUINO_PATH)hardware/arduino/variants/$(VARIANT) +COMMON_FLAGS += -I. -I$(U8G_PATH) -I$(U8G_CPP_PATH) +COMMON_FLAGS += $(addprefix -I,$(EXTRA_DIRS)) +COMMON_FLAGS += -ffunction-sections -fdata-sections -Wl,--gc-sections +COMMON_FLAGS += -Wl,--Map=output.map +COMMON_FLAGS += -Wl,--relax +COMMON_FLAGS += -mcall-prologues + +CFLAGS = $(COMMON_FLAGS) -std=gnu99 -Wstrict-prototypes +CXXFLAGS = $(COMMON_FLAGS) + +# Replace standard build tools by avr tools +CC = $(AVRTOOLSPATH)avr-gcc +CXX = $(AVRTOOLSPATH)avr-g++ +AR = @$(AVRTOOLSPATH)avr-ar + + +# "rm" must be able to delete a directory tree +RM = rm -rf + +#=== rules === + +# add rules for the C/C++ files where the .o file is placed in the TMPDIRPATH +# reuse existing variables as far as possible + +$(TMPDIRPATH)%.o: %.c + @echo compile $< + @$(COMPILE.c) $(OUTPUT_OPTION) $< + +$(TMPDIRPATH)%.o: %.cc + @echo compile $< + @$(COMPILE.cc) $(OUTPUT_OPTION) $< + +$(TMPDIRPATH)%.o: %.cpp + @echo compile $< + @$(COMPILE.cpp) $(OUTPUT_OPTION) $< + +$(TMPDIRPATH)%.s: %.c + @$(COMPILE.c) $(OUTPUT_OPTION) -S $< + +$(TMPDIRPATH)%.s: %.cc + @$(COMPILE.cc) $(OUTPUT_OPTION) -S $< + +$(TMPDIRPATH)%.s: %.cpp + @$(COMPILE.cpp) $(OUTPUT_OPTION) -S $< + +$(TMPDIRPATH)%.dis: $(TMPDIRPATH)%.o + @$(OBJDUMP) -S $< > $@ + +.SUFFIXES: .elf .hex .pde + +.elf.hex: + @$(OBJCOPY) -O ihex -R .eeprom $< $@ + +$(TMPDIRPATH)%.cpp: %.pde + @cat $(ARDUINO_PATH)hardware/arduino/cores/arduino/main.cpp > $@ + @cat $< >> $@ + @echo >> $@ + @echo 'extern "C" void __cxa_pure_virtual() { while (1); }' >> $@ + + +.PHONY: all +all: tmpdir $(HEXNAME) assemblersource showsize + ls -al $(HEXNAME) $(ELFNAME) + +$(ELFNAME): $(LIBNAME)($(addprefix $(TMPDIRPATH),$(OBJFILES))) + $(LINK.o) $(COMMON_FLAGS) $(LIBNAME) $(LOADLIBES) $(LDLIBS) -o $@ + +$(LIBNAME)(): $(addprefix $(TMPDIRPATH),$(OBJFILES)) + +#=== create temp directory === +# not really required, because it will be also created during the dependency handling +.PHONY: tmpdir +tmpdir: + @test -d $(TMPDIRPATH) || mkdir $(TMPDIRPATH) + +#=== create assembler files for each C/C++ file === +.PHONY: assemblersource +assemblersource: $(addprefix $(TMPDIRPATH),$(ASSFILES)) $(addprefix $(TMPDIRPATH),$(DISFILES)) + + +#=== show the section sizes of the ELF file === +.PHONY: showsize +showsize: $(ELFNAME) + $(SIZE) $< + +#=== clean up target === +# this is simple: the TMPDIRPATH is removed +.PHONY: clean +clean: + $(RM) $(TMPDIRPATH) + +# Program the device. +# step 1: reset the arduino board with the stty command +# step 2: user avrdude to upload the software +.PHONY: upload +upload: $(HEXNAME) + stty -F $(AVRDUDE_PORT) hupcl + $(AVRDUDE) $(AVRDUDE_FLAGS) + + +# === dependency handling === +# From the gnu make manual (section 4.14, Generating Prerequisites Automatically) +# Additionally (because this will be the first executed rule) TMPDIRPATH is created here. +# Instead of "sed" the "echo" command is used +# cd $(TMPDIRPATH); mkdir -p $(DIRS) 2> /dev/null; cd .. +DEPACTION=test -d $(TMPDIRPATH) || mkdir $(TMPDIRPATH);\ +mkdir -p $(addprefix $(TMPDIRPATH),$(DIRS));\ +set -e; echo -n $@ $(dir $@) > $@; $(CC) -MM $(COMMON_FLAGS) $< >> $@ + + +$(TMPDIRPATH)%.d: %.c + @$(DEPACTION) + +$(TMPDIRPATH)%.d: %.cc + @$(DEPACTION) + +$(TMPDIRPATH)%.d: %.cpp + @$(DEPACTION) + +# Include dependency files. If a .d file is missing, a warning is created and the .d file is created +# This warning is not a problem (gnu make manual, section 3.3 Including Other Makefiles) +-include $(addprefix $(TMPDIRPATH),$(DEPFILES)) + + diff --git a/sys/arduino/Menu/Menu.pde b/sys/arduino/Menu/Menu.pde index d8ab6f0d..edda1a0b 100644 --- a/sys/arduino/Menu/Menu.pde +++ b/sys/arduino/Menu/Menu.pde @@ -7,7 +7,7 @@ >>> Before compiling: Please remove comment from the constructor of the >>> connected graphics display (see below). - Universal 8bit Graphics Library, http://code.google.com/p/u8glib/ + Universal 8bit Graphics Library, https://github.com/olikraus/u8glib/ Copyright (c) 2012, olikraus@gmail.com All rights reserved. @@ -42,12 +42,9 @@ #include "U8glib.h" -// setup u8g object, please remove comment from one of the following constructor calls -// IMPORTANT NOTE: The complete list of supported devices is here: http://code.google.com/p/u8glib/wiki/device - // setup u8g object, please remove comment from one of the following constructor calls // IMPORTANT NOTE: The following list is incomplete. The complete list of supported -// devices with all constructor calls is here: http://code.google.com/p/u8glib/wiki/device +// devices with all constructor calls is here: https://github.com/olikraus/u8glib/wiki/device //U8GLIB_NHD27OLED_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_NHD27OLED_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_NHD27OLED_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 @@ -99,6 +96,9 @@ //U8GLIB_SSD1306_128X32 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_SSD1306_128X32 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) //U8GLIB_SSD1306_128X32 u8g(U8G_I2C_OPT_NONE); // I2C / TWI +//U8GLIB_SSD1306_64X48 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 +//U8GLIB_SSD1306_64X48 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_SSD1306_64X48 u8g(U8G_I2C_OPT_NONE); // I2C / TWI //U8GLIB_SH1106_128X64 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_SH1106_128X64 u8g(4, 5, 6, 7); // SW SPI Com: SCK = 4, MOSI = 5, CS = 6, A0 = 7 (new blue HalTec OLED) //U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_NONE); // I2C / TWI @@ -110,9 +110,12 @@ //U8GLIB_UC1611_DOGM240 u8g(U8G_I2C_OPT_NONE); // I2C //U8GLIB_UC1611_DOGM240 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_UC1611_DOGM240 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_UC1611_DOGM240 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_UC1611_DOGM240 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 3, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=3, di/a0=17,rw=16 //U8GLIB_UC1611_DOGXL240 u8g(U8G_I2C_OPT_NONE); // I2C //U8GLIB_UC1611_DOGXL240 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_UC1611_DOGXL240 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_UC1611_DOGXL240 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 3, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=3, di/a0=17,rw=16 //U8GLIB_NHD_C12864 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 //U8GLIB_NHD_C12832 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 //U8GLIB_LD7032_60x32 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 @@ -166,14 +169,10 @@ uint8_t uiKeyCode = KEY_NONE; void uiSetup(void) { // configure input keys - pinMode(uiKeyPrev, INPUT); // set pin to input - digitalWrite(uiKeyPrev, HIGH); // turn on pullup resistors - pinMode(uiKeyNext, INPUT); // set pin to input - digitalWrite(uiKeyNext, HIGH); // turn on pullup resistors - pinMode(uiKeySelect, INPUT); // set pin to input - digitalWrite(uiKeySelect, HIGH); // turn on pullup resistors - pinMode(uiKeyBack, INPUT); // set pin to input - digitalWrite(uiKeyBack, HIGH); // turn on pullup resistors + pinMode(uiKeyPrev, INPUT_PULLUP); // set pin to input with pullup + pinMode(uiKeyNext, INPUT_PULLUP); // set pin to input with pullup + pinMode(uiKeySelect, INPUT_PULLUP); // set pin to input with pullup + pinMode(uiKeyBack, INPUT_PULLUP); // set pin to input with pullup } void uiStep(void) { @@ -197,7 +196,7 @@ void uiStep(void) { #define MENU_ITEMS 4 -char *menu_strings[MENU_ITEMS] = { "First Line", "Second Item", "3333333", "abcdefg" }; +const char *menu_strings[MENU_ITEMS] = { "First Line", "Second Item", "3333333", "abcdefg" }; uint8_t menu_current = 0; uint8_t menu_redraw_required = 0; diff --git a/sys/arduino/PartialUpdate/PartialUpdate.pde b/sys/arduino/PartialUpdate/PartialUpdate.pde index 06e0e29d..87b9725d 100644 --- a/sys/arduino/PartialUpdate/PartialUpdate.pde +++ b/sys/arduino/PartialUpdate/PartialUpdate.pde @@ -9,7 +9,7 @@ U8GLIB_ST7920_128X64 u8g(18, 16, 17, U8G_PIN_NONE); // SPI Com: //U8GLIB_ST7920_192X32 u8g(18, 16, 17, U8G_PIN_NONE); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17 /* - the pb object is (usually) the device name from http://code.google.com/p/u8glib/wiki/device + the pb object is (usually) the device name from https://github.com/olikraus/u8glib/wiki/device with "_pb" added at the end. */ extern u8g_pb_t u8g_dev_st7920_192x32_sw_spi_pb; diff --git a/sys/arduino/PrintTest/PrintTest.pde b/sys/arduino/PrintTest/PrintTest.pde index edc9afa8..6a64b185 100644 --- a/sys/arduino/PrintTest/PrintTest.pde +++ b/sys/arduino/PrintTest/PrintTest.pde @@ -7,7 +7,7 @@ >>> Before compiling: Please remove comment from the constructor of the >>> connected graphics display (see below). - Universal 8bit Graphics Library, http://code.google.com/p/u8glib/ + Universal 8bit Graphics Library, https://github.com/olikraus/u8glib/ Copyright (c) 2012, olikraus@gmail.com All rights reserved. @@ -43,7 +43,7 @@ // setup u8g object, please remove comment from one of the following constructor calls // IMPORTANT NOTE: The following list is incomplete. The complete list of supported -// devices with all constructor calls is here: http://code.google.com/p/u8glib/wiki/device +// devices with all constructor calls is here: https://github.com/olikraus/u8glib/wiki/device //U8GLIB_NHD27OLED_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_NHD27OLED_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_NHD27OLED_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 diff --git a/sys/arduino/Rotation/Rotation.pde b/sys/arduino/Rotation/Rotation.pde index f4008138..2c885ef7 100644 --- a/sys/arduino/Rotation/Rotation.pde +++ b/sys/arduino/Rotation/Rotation.pde @@ -7,7 +7,7 @@ >>> Before compiling: Please remove comment from the constructor of the >>> connected graphics display (see below). - Universal 8bit Graphics Library, http://code.google.com/p/u8glib/ + Universal 8bit Graphics Library, https://github.com/olikraus/u8glib/ Copyright (c) 2012, olikraus@gmail.com All rights reserved. @@ -43,7 +43,7 @@ // setup u8g object, please remove comment from one of the following constructor calls // IMPORTANT NOTE: The following list is incomplete. The complete list of supported -// devices with all constructor calls is here: http://code.google.com/p/u8glib/wiki/device +// devices with all constructor calls is here: https://github.com/olikraus/u8glib/wiki/device //U8GLIB_NHD27OLED_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_NHD27OLED_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_NHD27OLED_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 @@ -95,6 +95,9 @@ //U8GLIB_SSD1306_128X32 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_SSD1306_128X32 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) //U8GLIB_SSD1306_128X32 u8g(U8G_I2C_OPT_NONE); // I2C / TWI +//U8GLIB_SSD1306_64X48 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 +//U8GLIB_SSD1306_64X48 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_SSD1306_64X48 u8g(U8G_I2C_OPT_NONE); // I2C / TWI //U8GLIB_SH1106_128X64 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_SH1106_128X64 u8g(4, 5, 6, 7); // SW SPI Com: SCK = 4, MOSI = 5, CS = 6, A0 = 7 (new blue HalTec OLED) //U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_NONE); // I2C / TWI @@ -106,9 +109,12 @@ //U8GLIB_UC1611_DOGM240 u8g(U8G_I2C_OPT_NONE); // I2C //U8GLIB_UC1611_DOGM240 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_UC1611_DOGM240 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_UC1611_DOGM240 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_UC1611_DOGM240 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 3, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=3, di/a0=17,rw=16 //U8GLIB_UC1611_DOGXL240 u8g(U8G_I2C_OPT_NONE); // I2C //U8GLIB_UC1611_DOGXL240 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_UC1611_DOGXL240 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_UC1611_DOGXL240 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 3, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=3, di/a0=17,rw=16 //U8GLIB_NHD_C12864 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 //U8GLIB_NHD_C12832 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 //U8GLIB_LD7032_60x32 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 diff --git a/sys/arduino/Scale/Scale.pde b/sys/arduino/Scale/Scale.pde index 5fc5d331..27e3944b 100644 --- a/sys/arduino/Scale/Scale.pde +++ b/sys/arduino/Scale/Scale.pde @@ -7,7 +7,7 @@ >>> Before compiling: Please remove comment from the constructor of the >>> connected graphics display (see below). - Universal 8bit Graphics Library, http://code.google.com/p/u8glib/ + Universal 8bit Graphics Library, https://github.com/olikraus/u8glib/ Copyright (c) 2012, olikraus@gmail.com All rights reserved. @@ -43,7 +43,7 @@ // setup u8g object, please remove comment from one of the following constructor calls // IMPORTANT NOTE: The following list is incomplete. The complete list of supported -// devices with all constructor calls is here: http://code.google.com/p/u8glib/wiki/device +// devices with all constructor calls is here: https://github.com/olikraus/u8glib/wiki/device //U8GLIB_NHD27OLED_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_NHD27OLED_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_NHD27OLED_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 @@ -95,6 +95,9 @@ //U8GLIB_SSD1306_128X32 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_SSD1306_128X32 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) //U8GLIB_SSD1306_128X32 u8g(U8G_I2C_OPT_NONE); // I2C / TWI +//U8GLIB_SSD1306_64X48 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 +//U8GLIB_SSD1306_64X48 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_SSD1306_64X48 u8g(U8G_I2C_OPT_NONE); // I2C / TWI //U8GLIB_SH1106_128X64 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_SH1106_128X64 u8g(4, 5, 6, 7); // SW SPI Com: SCK = 4, MOSI = 5, CS = 6, A0 = 7 (new blue HalTec OLED) //U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_NONE); // I2C / TWI @@ -106,9 +109,12 @@ //U8GLIB_UC1611_DOGM240 u8g(U8G_I2C_OPT_NONE); // I2C //U8GLIB_UC1611_DOGM240 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_UC1611_DOGM240 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_UC1611_DOGM240 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_UC1611_DOGM240 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 3, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=3, di/a0=17,rw=16 //U8GLIB_UC1611_DOGXL240 u8g(U8G_I2C_OPT_NONE); // I2C //U8GLIB_UC1611_DOGXL240 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_UC1611_DOGXL240 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_UC1611_DOGXL240 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 3, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=3, di/a0=17,rw=16 //U8GLIB_NHD_C12864 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 //U8GLIB_NHD_C12832 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 //U8GLIB_LD7032_60x32 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 diff --git a/sys/arduino/ShowTGA/ShowTGA.pde b/sys/arduino/ShowTGA/ShowTGA.pde index 92d07f99..0caac1c6 100644 --- a/sys/arduino/ShowTGA/ShowTGA.pde +++ b/sys/arduino/ShowTGA/ShowTGA.pde @@ -11,7 +11,7 @@ >>> Before compiling: Please remove comment from the constructor of the >>> connected graphics display (see below). - Universal 8bit Graphics Library, http://code.google.com/p/u8glib/ + Universal 8bit Graphics Library, https://github.com/olikraus/u8glib/ Copyright (c) 2012, olikraus@gmail.com All rights reserved. @@ -49,7 +49,7 @@ // setup u8g object, please remove comment from one of the following constructor calls // IMPORTANT NOTE: The following list is incomplete. The complete list of supported -// devices with all constructor calls is here: http://code.google.com/p/u8glib/wiki/device +// devices with all constructor calls is here: https://github.com/olikraus/u8glib/wiki/device //U8GLIB_NHD27OLED_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_NHD27OLED_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_NHD27OLED_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 diff --git a/sys/arduino/TextRotX/TextRotX.pde b/sys/arduino/TextRotX/TextRotX.pde index 35278082..5cec6a44 100644 --- a/sys/arduino/TextRotX/TextRotX.pde +++ b/sys/arduino/TextRotX/TextRotX.pde @@ -7,7 +7,7 @@ >>> Before compiling: Please remove comment from the constructor of the >>> connected graphics display (see below). - Universal 8bit Graphics Library, http://code.google.com/p/u8glib/ + Universal 8bit Graphics Library, https://github.com/olikraus/u8glib/ Copyright (c) 2012, olikraus@gmail.com All rights reserved. @@ -43,7 +43,7 @@ // setup u8g object, please remove comment from one of the following constructor calls // IMPORTANT NOTE: The following list is incomplete. The complete list of supported -// devices with all constructor calls is here: http://code.google.com/p/u8glib/wiki/device +// devices with all constructor calls is here: https://github.com/olikraus/u8glib/wiki/device //U8GLIB_NHD27OLED_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_NHD27OLED_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_NHD27OLED_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 @@ -95,6 +95,9 @@ //U8GLIB_SSD1306_128X32 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_SSD1306_128X32 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) //U8GLIB_SSD1306_128X32 u8g(U8G_I2C_OPT_NONE); // I2C / TWI +//U8GLIB_SSD1306_64X48 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 +//U8GLIB_SSD1306_64X48 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_SSD1306_64X48 u8g(U8G_I2C_OPT_NONE); // I2C / TWI //U8GLIB_SH1106_128X64 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_SH1106_128X64 u8g(4, 5, 6, 7); // SW SPI Com: SCK = 4, MOSI = 5, CS = 6, A0 = 7 (new blue HalTec OLED) //U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_NONE); // I2C / TWI @@ -106,9 +109,12 @@ //U8GLIB_UC1611_DOGM240 u8g(U8G_I2C_OPT_NONE); // I2C //U8GLIB_UC1611_DOGM240 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_UC1611_DOGM240 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_UC1611_DOGM240 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_UC1611_DOGM240 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 3, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=3, di/a0=17,rw=16 //U8GLIB_UC1611_DOGXL240 u8g(U8G_I2C_OPT_NONE); // I2C //U8GLIB_UC1611_DOGXL240 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_UC1611_DOGXL240 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_UC1611_DOGXL240 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 3, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=3, di/a0=17,rw=16 //U8GLIB_NHD_C12864 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 //U8GLIB_NHD_C12832 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 //U8GLIB_LD7032_60x32 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 diff --git a/sys/arduino/Touch4WSetup/Touch4WSetup.pde b/sys/arduino/Touch4WSetup/Touch4WSetup.pde index 9ce10e94..0f430419 100644 --- a/sys/arduino/Touch4WSetup/Touch4WSetup.pde +++ b/sys/arduino/Touch4WSetup/Touch4WSetup.pde @@ -8,7 +8,7 @@ >>> Before compiling: Please remove comment from the constructor of the >>> connected graphics display (see below). - Universal 8bit Graphics Library, http://code.google.com/p/u8glib/ + Universal 8bit Graphics Library, https://github.com/olikraus/u8glib/ Copyright (c) 2012, olikraus@gmail.com All rights reserved. @@ -44,7 +44,7 @@ // setup u8g object, please remove comment from one of the following constructor calls // IMPORTANT NOTE: The following list is incomplete. The complete list of supported -// devices with all constructor calls is here: http://code.google.com/p/u8glib/wiki/device +// devices with all constructor calls is here: https://github.com/olikraus/u8glib/wiki/device //U8GLIB_NHD27OLED_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_NHD27OLED_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_NHD27OLED_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 @@ -96,6 +96,9 @@ //U8GLIB_SSD1306_128X32 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_SSD1306_128X32 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) //U8GLIB_SSD1306_128X32 u8g(U8G_I2C_OPT_NONE); // I2C / TWI +//U8GLIB_SSD1306_64X48 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 +//U8GLIB_SSD1306_64X48 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_SSD1306_64X48 u8g(U8G_I2C_OPT_NONE); // I2C / TWI //U8GLIB_SH1106_128X64 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_SH1106_128X64 u8g(4, 5, 6, 7); // SW SPI Com: SCK = 4, MOSI = 5, CS = 6, A0 = 7 (new blue HalTec OLED) //U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_NONE); // I2C / TWI @@ -107,9 +110,12 @@ //U8GLIB_UC1611_DOGM240 u8g(U8G_I2C_OPT_NONE); // I2C //U8GLIB_UC1611_DOGM240 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_UC1611_DOGM240 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_UC1611_DOGM240 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_UC1611_DOGM240 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 3, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=3, di/a0=17,rw=16 //U8GLIB_UC1611_DOGXL240 u8g(U8G_I2C_OPT_NONE); // I2C //U8GLIB_UC1611_DOGXL240 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_UC1611_DOGXL240 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_UC1611_DOGXL240 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 3, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=3, di/a0=17,rw=16 //U8GLIB_NHD_C12864 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 //U8GLIB_NHD_C12832 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 //U8GLIB_LD7032_60x32 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 diff --git a/sys/arduino/Touch4WTest/Touch4WTest.pde b/sys/arduino/Touch4WTest/Touch4WTest.pde index ebe15838..b3f0c9fd 100644 --- a/sys/arduino/Touch4WTest/Touch4WTest.pde +++ b/sys/arduino/Touch4WTest/Touch4WTest.pde @@ -5,7 +5,7 @@ >>> Before compiling: Please remove comment from the constructor of the >>> connected graphics display (see below). - Universal 8bit Graphics Library, http://code.google.com/p/u8glib/ + Universal 8bit Graphics Library, https://github.com/olikraus/u8glib/ Copyright (c) 2012, olikraus@gmail.com All rights reserved. @@ -41,7 +41,7 @@ // setup u8g object, please remove comment from one of the following constructor calls // IMPORTANT NOTE: The following list is incomplete. The complete list of supported -// devices with all constructor calls is here: http://code.google.com/p/u8glib/wiki/device +// devices with all constructor calls is here: https://github.com/olikraus/u8glib/wiki/device //U8GLIB_NHD27OLED_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_NHD27OLED_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_NHD27OLED_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 @@ -93,6 +93,9 @@ //U8GLIB_SSD1306_128X32 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_SSD1306_128X32 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) //U8GLIB_SSD1306_128X32 u8g(U8G_I2C_OPT_NONE); // I2C / TWI +//U8GLIB_SSD1306_64X48 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 +//U8GLIB_SSD1306_64X48 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_SSD1306_64X48 u8g(U8G_I2C_OPT_NONE); // I2C / TWI //U8GLIB_SH1106_128X64 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_SH1106_128X64 u8g(4, 5, 6, 7); // SW SPI Com: SCK = 4, MOSI = 5, CS = 6, A0 = 7 (new blue HalTec OLED) //U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_NONE); // I2C / TWI @@ -104,9 +107,12 @@ //U8GLIB_UC1611_DOGM240 u8g(U8G_I2C_OPT_NONE); // I2C //U8GLIB_UC1611_DOGM240 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_UC1611_DOGM240 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_UC1611_DOGM240 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_UC1611_DOGM240 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 3, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=3, di/a0=17,rw=16 //U8GLIB_UC1611_DOGXL240 u8g(U8G_I2C_OPT_NONE); // I2C //U8GLIB_UC1611_DOGXL240 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_UC1611_DOGXL240 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_UC1611_DOGXL240 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 3, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=3, di/a0=17,rw=16 //U8GLIB_NHD_C12864 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 //U8GLIB_NHD_C12832 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 //U8GLIB_LD7032_60x32 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 diff --git a/sys/arduino/TouchPanel4W/TouchPanel4W.pde b/sys/arduino/TouchPanel4W/TouchPanel4W.pde index 5aa9a4b6..1795d49c 100644 --- a/sys/arduino/TouchPanel4W/TouchPanel4W.pde +++ b/sys/arduino/TouchPanel4W/TouchPanel4W.pde @@ -5,7 +5,7 @@ >>> Before compiling: Please remove comment from the constructor of the >>> connected graphics display (see below). - Universal 8bit Graphics Library, http://code.google.com/p/u8glib/ + Universal 8bit Graphics Library, https://github.com/olikraus/u8glib/ Copyright (c) 2012, olikraus@gmail.com All rights reserved. @@ -41,7 +41,7 @@ // setup u8g object, please remove comment from one of the following constructor calls // IMPORTANT NOTE: The following list is incomplete. The complete list of supported -// devices with all constructor calls is here: http://code.google.com/p/u8glib/wiki/device +// devices with all constructor calls is here: https://github.com/olikraus/u8glib/wiki/device //U8GLIB_NHD27OLED_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_NHD27OLED_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_NHD27OLED_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 diff --git a/sys/arduino/U8gLogo/Makefile.105.uno_ch341 b/sys/arduino/U8gLogo/Makefile.105.uno_ch341 new file mode 100644 index 00000000..4c52fa92 --- /dev/null +++ b/sys/arduino/U8gLogo/Makefile.105.uno_ch341 @@ -0,0 +1,286 @@ + +# +# Arduino-1.0 Makefile +# +# written by olikraus@gmail.com +# +# Features: +# - boards.txt is used to derive parameters +# - All intermediate files are put into a separate directory (TMPDIRNAME) +# - Simple use: Copy Makefile into the same directory of the .pde file +# +# Limitations: +# - requires UNIX environment +# - TMPDIRNAME must be subdirectory of the current directory. +# +# Targets +# all build everything +# upload build and upload to arduino +# clean remove all temporary files (includes final hex file) +# +# History +# 001 28 Apr 2010 first release +# 002 05 Oct 2010 added 'uno' +# 003 06 Dec 2011 arduino 1.0 +# 004 11 Feb 2012 u8glib +# + +#=== user configuration === +# All ...PATH variables must have a '/' at the end + +# Board (and prozessor) information: see $(ARDUINO_PATH)hardware/arduino/boards.txt +# Some examples: +# BOARD DESCRIPTION +# uno Arduino Uno +# atmega328 Arduino Duemilanove or Nano w/ ATmega328 +# diecimila Arduino Diecimila, Duemilanove, or Nano w/ ATmega168 +# mega Arduino Mega +# mega2560 Arduino Mega2560 +# mini Arduino Mini +# lilypad328 LilyPad Arduino w/ ATmega328 +BOARD:=uno + +# additional definitions +#DEFS:=-DARDUINO=105 + + +U8G_PATH:=$(shell cd ../../.. && pwd)/csrc/ +U8G_CPP_PATH:=$(shell cd ../../.. && pwd)/cppsrc/ +U8G_FONT_PATH:=$(shell cd ../../.. && pwd)/sfntsrc/ + + +# The location where the avr tools (e.g. avr-gcc) are located. Requires a '/' at the end. +# Can be empty if all tools are accessable through the search path +AVR_TOOLS_PATH:=/usr/bin/ + +# Install path of the arduino software. Requires a '/' at the end. +ARDUINO_PATH:=/home/kraus/prg/arduino-1.0.5-u8glib/ + +# Install path for avrdude. Requires a '/' at the end. Can be empty if avrdude is in the search path. +AVRDUDE_PATH:=$(ARDUINO_PATH)hardware/tools/ + +# The unix device where we can reach the arduino board +# Uno: /dev/ttyACM0 +# Duemilanove: /dev/ttyUSB0 +# AVRDUDE_PORT:=/dev/ttyACM0 +AVRDUDE_PORT:=/dev/ttyUSB0 + +# List of all libaries which should be included. +EXTRA_DIRS=$(ARDUINO_PATH)libraries/LiquidCrystal/ +EXTRA_DIRS+=$(ARDUINO_PATH)libraries/SD/ +EXTRA_DIRS+=$(ARDUINO_PATH)libraries/SD/utility/ +EXTRA_DIRS+=$(ARDUINO_PATH)libraries/SPI/ +#EXTRA_DIRS+=$(ARDUINO_PATH)libraries/.../ + +#=== fetch parameter from boards.txt processor parameter === +# the basic idea is to get most of the information from boards.txt + +BOARDS_TXT:=$(ARDUINO_PATH)hardware/arduino/boards.txt + +# get the MCU value from the $(BOARD).build.mcu variable. For the atmega328 board this is atmega328p +MCU:=$(shell sed -n -e "s/$(BOARD).build.mcu=\(.*\)/\1/p" $(BOARDS_TXT)) +# get the F_CPU value from the $(BOARD).build.f_cpu variable. For the atmega328 board this is 16000000 +F_CPU:=$(shell sed -n -e "s/$(BOARD).build.f_cpu=\(.*\)/\1/p" $(BOARDS_TXT)) +# get variant subfolder +VARIANT:=$(shell sed -n -e "s/$(BOARD).build.variant=\(.*\)/\1/p" $(BOARDS_TXT)) + + +# avrdude +# get the AVRDUDE_UPLOAD_RATE value from the $(BOARD).upload.speed variable. For the atmega328 board this is 57600 +AVRDUDE_UPLOAD_RATE:=$(shell sed -n -e "s/$(BOARD).upload.speed=\(.*\)/\1/p" $(BOARDS_TXT)) +# get the AVRDUDE_PROGRAMMER value from the $(BOARD).upload.protocol variable. For the atmega328 board this is stk500 +AVRDUDE_PROGRAMMER:=$(shell sed -n -e "s/$(BOARD).upload.protocol=\(.*\)/\1/p" $(BOARDS_TXT)) +# use stk500v1, because stk500 will default to stk500v2 +#AVRDUDE_PROGRAMMER:=stk500v1 + +#=== identify user files === +PDESRC:=$(shell ls *.pde) +TARGETNAME=$(basename $(PDESRC)) + +CDIRS:=$(EXTRA_DIRS) $(addsuffix utility/,$(EXTRA_DIRS)) +CDIRS:=*.c utility/*.c $(U8G_PATH)*.c $(U8G_FONT_PATH)*.c $(addsuffix *.c,$(CDIRS)) $(ARDUINO_PATH)hardware/arduino/cores/arduino/*.c +CSRC:=$(shell ls $(CDIRS) 2>/dev/null) + +CCSRC:=$(shell ls *.cc 2>/dev/null) + +CPPDIRS:=$(EXTRA_DIRS) $(addsuffix utility/,$(EXTRA_DIRS)) +CPPDIRS:=*.cpp utility/*.cpp $(addsuffix *.cpp,$(CPPDIRS)) $(U8G_CPP_PATH)/*.cpp $(ARDUINO_PATH)hardware/arduino/cores/arduino/*.cpp +CPPSRC:=$(shell ls $(CPPDIRS) 2>/dev/null) + +#=== build internal variables === + +# the name of the subdirectory where everything is stored +TMPDIRNAME:=tmp +TMPDIRPATH:=$(TMPDIRNAME)/ + +AVRTOOLSPATH:=$(AVR_TOOLS_PATH) + +OBJCOPY:=$(AVRTOOLSPATH)avr-objcopy +OBJDUMP:=$(AVRTOOLSPATH)avr-objdump +SIZE:=$(AVRTOOLSPATH)avr-size + +CPPSRC:=$(addprefix $(TMPDIRPATH),$(PDESRC:.pde=.cpp)) $(CPPSRC) + +COBJ:=$(CSRC:.c=.o) +CCOBJ:=$(CCSRC:.cc=.o) +CPPOBJ:=$(CPPSRC:.cpp=.o) + +OBJFILES:=$(COBJ) $(CCOBJ) $(CPPOBJ) +DIRS:= $(dir $(OBJFILES)) + +DEPFILES:=$(OBJFILES:.o=.d) +# assembler files from avr-gcc -S +ASSFILES:=$(OBJFILES:.o=.s) +# disassembled object files with avr-objdump -S +DISFILES:=$(OBJFILES:.o=.dis) + + +LIBNAME:=$(TMPDIRPATH)$(TARGETNAME).a +ELFNAME:=$(TMPDIRPATH)$(TARGETNAME).elf +HEXNAME:=$(TMPDIRPATH)$(TARGETNAME).hex + +AVRDUDE_FLAGS = -V -F +AVRDUDE_FLAGS += -C $(ARDUINO_PATH)/hardware/tools/avrdude.conf +AVRDUDE_FLAGS += -p $(MCU) +AVRDUDE_FLAGS += -P $(AVRDUDE_PORT) +AVRDUDE_FLAGS += -c $(AVRDUDE_PROGRAMMER) +AVRDUDE_FLAGS += -b $(AVRDUDE_UPLOAD_RATE) +AVRDUDE_FLAGS += -U flash:w:$(HEXNAME) + +AVRDUDE = $(AVRDUDE_PATH)avrdude + +#=== predefined variable override === +# use "make -p -f/dev/null" to see the default rules and definitions + +# Build C and C++ flags. Include path information must be placed here +COMMON_FLAGS = -DF_CPU=$(F_CPU) -mmcu=$(MCU) $(DEFS) -DARDUINO=100 +# COMMON_FLAGS += -gdwarf-2 +COMMON_FLAGS += -Os +COMMON_FLAGS += -Wall -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums +COMMON_FLAGS += -I. +COMMON_FLAGS += -I$(ARDUINO_PATH)hardware/arduino/cores/arduino +COMMON_FLAGS += -I$(ARDUINO_PATH)hardware/arduino/variants/$(VARIANT) +COMMON_FLAGS += -I. -I$(U8G_PATH) -I$(U8G_CPP_PATH) +COMMON_FLAGS += $(addprefix -I,$(EXTRA_DIRS)) +COMMON_FLAGS += -ffunction-sections -fdata-sections -Wl,--gc-sections +COMMON_FLAGS += -Wl,--Map=output.map +COMMON_FLAGS += -Wl,--relax +COMMON_FLAGS += -mcall-prologues + +CFLAGS = $(COMMON_FLAGS) -std=gnu99 -Wstrict-prototypes +CXXFLAGS = $(COMMON_FLAGS) + +# Replace standard build tools by avr tools +CC = $(AVRTOOLSPATH)avr-gcc +CXX = $(AVRTOOLSPATH)avr-g++ +AR = @$(AVRTOOLSPATH)avr-ar + + +# "rm" must be able to delete a directory tree +RM = rm -rf + +#=== rules === + +# add rules for the C/C++ files where the .o file is placed in the TMPDIRPATH +# reuse existing variables as far as possible + +$(TMPDIRPATH)%.o: %.c + @echo compile $< + @$(COMPILE.c) $(OUTPUT_OPTION) $< + +$(TMPDIRPATH)%.o: %.cc + @echo compile $< + @$(COMPILE.cc) $(OUTPUT_OPTION) $< + +$(TMPDIRPATH)%.o: %.cpp + @echo compile $< + @$(COMPILE.cpp) $(OUTPUT_OPTION) $< + +$(TMPDIRPATH)%.s: %.c + @$(COMPILE.c) $(OUTPUT_OPTION) -S $< + +$(TMPDIRPATH)%.s: %.cc + @$(COMPILE.cc) $(OUTPUT_OPTION) -S $< + +$(TMPDIRPATH)%.s: %.cpp + @$(COMPILE.cpp) $(OUTPUT_OPTION) -S $< + +$(TMPDIRPATH)%.dis: $(TMPDIRPATH)%.o + @$(OBJDUMP) -S $< > $@ + +.SUFFIXES: .elf .hex .pde + +.elf.hex: + @$(OBJCOPY) -O ihex -R .eeprom $< $@ + +$(TMPDIRPATH)%.cpp: %.pde + @cat $(ARDUINO_PATH)hardware/arduino/cores/arduino/main.cpp > $@ + @cat $< >> $@ + @echo >> $@ + @echo 'extern "C" void __cxa_pure_virtual() { while (1); }' >> $@ + + +.PHONY: all +all: tmpdir $(HEXNAME) assemblersource showsize + ls -al $(HEXNAME) $(ELFNAME) + +$(ELFNAME): $(LIBNAME)($(addprefix $(TMPDIRPATH),$(OBJFILES))) + $(LINK.o) $(COMMON_FLAGS) $(LIBNAME) $(LOADLIBES) $(LDLIBS) -o $@ + +$(LIBNAME)(): $(addprefix $(TMPDIRPATH),$(OBJFILES)) + +#=== create temp directory === +# not really required, because it will be also created during the dependency handling +.PHONY: tmpdir +tmpdir: + @test -d $(TMPDIRPATH) || mkdir $(TMPDIRPATH) + +#=== create assembler files for each C/C++ file === +.PHONY: assemblersource +assemblersource: $(addprefix $(TMPDIRPATH),$(ASSFILES)) $(addprefix $(TMPDIRPATH),$(DISFILES)) + + +#=== show the section sizes of the ELF file === +.PHONY: showsize +showsize: $(ELFNAME) + $(SIZE) $< + +#=== clean up target === +# this is simple: the TMPDIRPATH is removed +.PHONY: clean +clean: + $(RM) $(TMPDIRPATH) + +# Program the device. +# step 1: reset the arduino board with the stty command +# step 2: user avrdude to upload the software +.PHONY: upload +upload: $(HEXNAME) + stty -F $(AVRDUDE_PORT) hupcl + $(AVRDUDE) $(AVRDUDE_FLAGS) + + +# === dependency handling === +# From the gnu make manual (section 4.14, Generating Prerequisites Automatically) +# Additionally (because this will be the first executed rule) TMPDIRPATH is created here. +# Instead of "sed" the "echo" command is used +# cd $(TMPDIRPATH); mkdir -p $(DIRS) 2> /dev/null; cd .. +DEPACTION=test -d $(TMPDIRPATH) || mkdir $(TMPDIRPATH);\ +mkdir -p $(addprefix $(TMPDIRPATH),$(DIRS));\ +set -e; echo -n $@ $(dir $@) > $@; $(CC) -MM $(COMMON_FLAGS) $< >> $@ + + +$(TMPDIRPATH)%.d: %.c + @$(DEPACTION) + +$(TMPDIRPATH)%.d: %.cc + @$(DEPACTION) + +$(TMPDIRPATH)%.d: %.cpp + @$(DEPACTION) + +# Include dependency files. If a .d file is missing, a warning is created and the .d file is created +# This warning is not a problem (gnu make manual, section 3.3 Including Other Makefiles) +-include $(addprefix $(TMPDIRPATH),$(DEPFILES)) + + diff --git a/sys/arduino/U8gLogo/U8gLogo.pde b/sys/arduino/U8gLogo/U8gLogo.pde index 1c37f70e..41b3106f 100644 --- a/sys/arduino/U8gLogo/U8gLogo.pde +++ b/sys/arduino/U8gLogo/U8gLogo.pde @@ -7,7 +7,7 @@ >>> Before compiling: Please remove comment from the constructor of the >>> connected graphics display (see below). - Universal 8bit Graphics Library, http://code.google.com/p/u8glib/ + Universal 8bit Graphics Library, https://github.com/olikraus/u8glib/ Copyright (c) 2012, olikraus@gmail.com All rights reserved. @@ -43,7 +43,7 @@ // setup u8g object, please remove comment from one of the following constructor calls // IMPORTANT NOTE: The following list is incomplete. The complete list of supported -// devices with all constructor calls is here: http://code.google.com/p/u8glib/wiki/device +// devices with all constructor calls is here: https://github.com/olikraus/u8glib/wiki/device //U8GLIB_NHD27OLED_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_NHD27OLED_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_NHD27OLED_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 @@ -95,6 +95,9 @@ //U8GLIB_SSD1306_128X32 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_SSD1306_128X32 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) //U8GLIB_SSD1306_128X32 u8g(U8G_I2C_OPT_NONE); // I2C / TWI +//U8GLIB_SSD1306_64X48 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 +//U8GLIB_SSD1306_64X48 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_SSD1306_64X48 u8g(U8G_I2C_OPT_NONE); // I2C / TWI //U8GLIB_SH1106_128X64 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_SH1106_128X64 u8g(4, 5, 6, 7); // SW SPI Com: SCK = 4, MOSI = 5, CS = 6, A0 = 7 (new blue HalTec OLED) //U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_NONE); // I2C / TWI @@ -106,9 +109,12 @@ //U8GLIB_UC1611_DOGM240 u8g(U8G_I2C_OPT_NONE); // I2C //U8GLIB_UC1611_DOGM240 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_UC1611_DOGM240 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_UC1611_DOGM240 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_UC1611_DOGM240 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 3, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=3, di/a0=17,rw=16 //U8GLIB_UC1611_DOGXL240 u8g(U8G_I2C_OPT_NONE); // I2C //U8GLIB_UC1611_DOGXL240 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_UC1611_DOGXL240 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_UC1611_DOGXL240 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 3, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=3, di/a0=17,rw=16 //U8GLIB_NHD_C12864 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 //U8GLIB_NHD_C12832 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 //U8GLIB_LD7032_60x32 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 @@ -134,9 +140,6 @@ //U8GLIB_SSD1351_128X128GH_332 u8g(8, 9, 7); // Arduino, HW SPI Com: SCK = 76, MOSI = 75, CS = 8, A0 = 9, RESET = 7 (Freetronics OLED) //U8GLIB_SSD1351_128X128GH_HICOLOR u8g(8, 9, 7); // Arduino, HW SPI Com: SCK = 76, MOSI = 75, CS = 8, A0 = 9, RESET = 7 (Freetronics OLED) -//U8GLIB_SSD1306_128X64 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 -U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NO_ACK); - //#define MINI_LOGO diff --git a/sys/arduino/XBM/XBM.pde b/sys/arduino/XBM/XBM.pde index 65b18318..c0227c45 100644 --- a/sys/arduino/XBM/XBM.pde +++ b/sys/arduino/XBM/XBM.pde @@ -7,7 +7,7 @@ >>> Before compiling: Please remove comment from the constructor of the >>> connected graphics display (see below). - Universal 8bit Graphics Library, http://code.google.com/p/u8glib/ + Universal 8bit Graphics Library, https://github.com/olikraus/u8glib/ Copyright (c) 2012, olikraus@gmail.com All rights reserved. @@ -43,7 +43,7 @@ // setup u8g object, please remove comment from one of the following constructor calls // IMPORTANT NOTE: The following list is incomplete. The complete list of supported -// devices with all constructor calls is here: http://code.google.com/p/u8glib/wiki/device +// devices with all constructor calls is here: https://github.com/olikraus/u8glib/wiki/device //U8GLIB_NHD27OLED_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_NHD27OLED_2X_BW u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_NHD27OLED_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 @@ -95,6 +95,9 @@ //U8GLIB_SSD1306_128X32 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_SSD1306_128X32 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) //U8GLIB_SSD1306_128X32 u8g(U8G_I2C_OPT_NONE); // I2C / TWI +//U8GLIB_SSD1306_64X48 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 +//U8GLIB_SSD1306_64X48 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_SSD1306_64X48 u8g(U8G_I2C_OPT_NONE); // I2C / TWI //U8GLIB_SH1106_128X64 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_SH1106_128X64 u8g(4, 5, 6, 7); // SW SPI Com: SCK = 4, MOSI = 5, CS = 6, A0 = 7 (new blue HalTec OLED) //U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_NONE); // I2C / TWI @@ -106,9 +109,12 @@ //U8GLIB_UC1611_DOGM240 u8g(U8G_I2C_OPT_NONE); // I2C //U8GLIB_UC1611_DOGM240 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_UC1611_DOGM240 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_UC1611_DOGM240 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_UC1611_DOGM240 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 3, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=3, di/a0=17,rw=16 //U8GLIB_UC1611_DOGXL240 u8g(U8G_I2C_OPT_NONE); // I2C //U8GLIB_UC1611_DOGXL240 u8g(13, 11, 10, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 //U8GLIB_UC1611_DOGXL240 u8g(10, 9); // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are SCK = 13 and MOSI = 11) +//U8GLIB_UC1611_DOGXL240 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 3, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=3, di/a0=17,rw=16 //U8GLIB_NHD_C12864 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 //U8GLIB_NHD_C12832 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 //U8GLIB_LD7032_60x32 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 diff --git a/sys/arduino/issue231/issue231_ino.pde b/sys/arduino/issue231/issue231_ino.pde index 5d699a5f..877d5a86 100644 --- a/sys/arduino/issue231/issue231_ino.pde +++ b/sys/arduino/issue231/issue231_ino.pde @@ -2,7 +2,7 @@ // setup u8g object, please remove comment from one of the following constructor calls // IMPORTANT NOTE: The following list is incomplete. The complete list of supported -// devices with all constructor calls is here: http://code.google.com/p/u8glib/wiki/device +// devices with all constructor calls is here: https://github.com/olikraus/u8glib/wiki/device U8GLIB_DOGM128 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9 diff --git a/sys/i2cdev/chess/Makefile b/sys/i2cdev/chess/Makefile new file mode 100644 index 00000000..893cc67d --- /dev/null +++ b/sys/i2cdev/chess/Makefile @@ -0,0 +1 @@ +include ../common/linux.mk diff --git a/sys/i2cdev/chess/chess.c b/sys/i2cdev/chess/chess.c new file mode 100644 index 00000000..8b74a72f --- /dev/null +++ b/sys/i2cdev/chess/chess.c @@ -0,0 +1,86 @@ +#include +#include + +#include "u8g_linux.h" + + +uint8_t get_key_code(void) +{ + uint8_t chess_key = CHESS_KEY_NONE; + int ch = u8g_linux_getch(); + + switch ( ch ) { + case 'n': + case 274: // arrow down + case 275: // arrow right + chess_key = CHESS_KEY_NEXT; + break; + case 'p': + case 273: // arrow up + case 276: // arrow left + chess_key = CHESS_KEY_PREV; + break; + case ' ': + chess_key = CHESS_KEY_SELECT; + break; + case 'q': + exit(0); + break; + } + return chess_key; +} + +int main(int argc, const char *argv[]) +{ + + uint8_t keyCode = CHESS_KEY_NONE; + uint8_t is_redraw = 1; + + u8g_t u8g; + + u8g_linux_Init(&u8g, argc, argv); + u8g_FirstPage(&u8g); + chess_Init(&u8g, 0); + +#ifdef PERFTEST + chess_Step(CHESS_KEY_SELECT); + chess_Step(CHESS_KEY_NONE); + chess_Step(CHESS_KEY_NEXT); + chess_Step(CHESS_KEY_NONE); + chess_Step(CHESS_KEY_NEXT); + chess_Step(CHESS_KEY_NONE); +#endif + + for(;;) + { + + + if ( is_redraw != 0 ) + { +#ifdef PERFTEST + int i; + for( i = 0; i < 500; i++ ) + { +#endif + u8g_FirstPage(&u8g); + do { + chess_Draw(); + } while( u8g_NextPage(&u8g) ); +#ifdef PERFTEST + } +#endif + is_redraw--; + } +#ifdef PERFTEST + exit(0); +#endif + + keyCode = get_key_code(); + if ( keyCode != CHESS_KEY_NONE ) + { + is_redraw = 2; + chess_Step(keyCode); + } + chess_Step(CHESS_KEY_NONE); + } +} diff --git a/sys/i2cdev/common/getch.c b/sys/i2cdev/common/getch.c new file mode 100644 index 00000000..d138b00c --- /dev/null +++ b/sys/i2cdev/common/getch.c @@ -0,0 +1,20 @@ +#include "u8g_linux.h" + +#include +#include +#include + +int u8g_linux_getch( void ) +{ + int ch; + struct termios oldt, newt; + + tcgetattr ( STDIN_FILENO, &oldt ); + newt = oldt; + newt.c_lflag &= ~( ICANON | ECHO ); + tcsetattr ( STDIN_FILENO, TCSANOW, &newt ); + ch = getchar(); + tcsetattr ( STDIN_FILENO, TCSANOW, &oldt ); + + return ch; +} diff --git a/sys/i2cdev/common/init.c b/sys/i2cdev/common/init.c new file mode 100644 index 00000000..473836bd --- /dev/null +++ b/sys/i2cdev/common/init.c @@ -0,0 +1,51 @@ +/* + + >>> PLEASE UNCOMMENT DISPLAY TYPE IN THE INIT PROCEDURE <<< + +*/ + +#include "u8g_linux.h" + +#include +#include + +void u8g_linux_Init(u8g_t *u8g, int argc, const char *argv[]) +{ + uint8_t ok = 255; + uint8_t i2c_bus; + + if (argc <= 1) { + fprintf(stderr, "Usage: %s I2CBUS\n", argv[0]); + exit(1); + } + + i2c_bus = atoi(argv[1]); + + /* + Please uncomment one of the displays below + Notes: + - "2x": high speed version, which uses more RAM + */ + + // ok = u8g_InitI2C(u8g, &u8g_dev_ssd1306_128x32_2x_i2c, i2c_bus); + // ok = u8g_InitI2C(u8g, &u8g_dev_ssd1306_128x32_i2c, i2c_bus); + // ok = u8g_InitI2C(u8g, &u8g_dev_ssd1306_128x64_2x_i2c, i2c_bus); + // ok = u8g_InitI2C(u8g, &u8g_dev_ssd1306_128x64_i2c, i2c_bus); + // ok = u8g_InitI2C(u8g, &u8g_dev_ssd1306_64x48_2x_i2c, i2c_bus); + // ok = u8g_InitI2C(u8g, &u8g_dev_ssd1306_64x48_i2c, i2c_bus); + // ok = u8g_InitI2C(u8g, &u8g_dev_ssd1306_adafruit_128x64_i2c, i2c_bus); + // ok = u8g_InitI2C(u8g, &u8g_dev_ssd1309_128x64_i2c, i2c_bus); + // ok = u8g_InitI2C(u8g, &u8g_dev_ssd1327_96x96_2x_gr_i2c, i2c_bus); + // ok = u8g_InitI2C(u8g, &u8g_dev_ssd1327_96x96_gr_i2c, i2c_bus); + + /* flip screen, if required */ + // u8g_SetRot180(u8g); + + if (ok == 255) { + fprintf(stderr, "No display driver selected (see src/linux/common/init.c)\n"); + exit(2); + } + + if (!ok) + exit(3); +} diff --git a/sys/i2cdev/common/linux.mk b/sys/i2cdev/common/linux.mk new file mode 100644 index 00000000..85b0e862 --- /dev/null +++ b/sys/i2cdev/common/linux.mk @@ -0,0 +1,14 @@ +CC = gcc +CFLAGS = -g -Wall -I../../../csrc/. -I../common -DU8G_LINUX -DU8G_WITH_PINLIST + +APP = $(notdir $(shell pwd)) +SRC = $(wildcard ../../../csrc/*.c ../../../sfntsrc/*.c ../common/*.c) $(APP).c + +OBJ = $(SRC:.c=.o) + +$(APP): $(OBJ) + $(CC) $(CFLAGS) $(LDFLAGS) $(OBJ) -o $(APP) + +clean: + $(RM) $(OBJ) $(APP) + diff --git a/sys/i2cdev/common/u8g_linux.h b/sys/i2cdev/common/u8g_linux.h new file mode 100644 index 00000000..26c3442b --- /dev/null +++ b/sys/i2cdev/common/u8g_linux.h @@ -0,0 +1,8 @@ +#ifndef U8G_LINUX_H_ + +#include "u8g.h" + +void u8g_linux_Init(u8g_t *u8g, int argc, const char *argv[]); +int u8g_linux_getch(void); + +#endif /* U8G_LINUX_H_ */ diff --git a/sys/i2cdev/graphics_test/Makefile b/sys/i2cdev/graphics_test/Makefile new file mode 100644 index 00000000..893cc67d --- /dev/null +++ b/sys/i2cdev/graphics_test/Makefile @@ -0,0 +1 @@ +include ../common/linux.mk diff --git a/sys/i2cdev/graphics_test/graphics_test.c b/sys/i2cdev/graphics_test/graphics_test.c new file mode 100644 index 00000000..1ed50c03 --- /dev/null +++ b/sys/i2cdev/graphics_test/graphics_test.c @@ -0,0 +1,138 @@ +/* + + graphics_test.c + + Linux U8glib Example + + 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_linux.h" + + +/*========================================================================*/ +/* main */ + +u8g_t u8g; + +void u8g_prepare(void) { + u8g_SetFont(&u8g, u8g_font_6x10); + u8g_SetFontRefHeightExtendedText(&u8g); + u8g_SetDefaultForegroundColor(&u8g); + u8g_SetFontPosTop(&u8g); +} + +void u8g_box_frame(uint8_t a) { + u8g_DrawStr(&u8g, 0, 0, "drawBox"); + u8g_DrawBox(&u8g, 5,10,20,10); + u8g_DrawBox(&u8g, 10+a,15,30,7); + u8g_DrawStr(&u8g, 0, 30, "drawFrame"); + u8g_DrawFrame(&u8g, 5,10+30,20,10); + u8g_DrawFrame(&u8g, 10+a,15+30,30,7); +} + +void u8g_string(uint8_t a) { + u8g_DrawStr(&u8g, 30+a,31, " 0"); + u8g_DrawStr90(&u8g, 30,31+a, " 90"); + u8g_DrawStr180(&u8g, 30-a,31, " 180"); + u8g_DrawStr270(&u8g, 30,31-a, " 270"); +} + +void u8g_line(uint8_t a) { + u8g_DrawStr(&u8g, 0, 0, "drawLine"); + u8g_DrawLine(&u8g, 7+a, 10, 40, 55); + u8g_DrawLine(&u8g, 7+a*2, 10, 60, 55); + u8g_DrawLine(&u8g, 7+a*3, 10, 80, 55); + u8g_DrawLine(&u8g, 7+a*4, 10, 100, 55); +} + +void u8g_ascii_1(void) { + char s[2] = " "; + uint8_t x, y; + u8g_DrawStr(&u8g, 0, 0, "ASCII page 1"); + for( y = 0; y < 6; y++ ) { + for( x = 0; x < 16; x++ ) { + s[0] = y*16 + x + 32; + u8g_DrawStr(&u8g, x*7, y*10+10, s); + } + } +} + +void u8g_ascii_2(void) { + char s[2] = " "; + uint8_t x, y; + u8g_DrawStr(&u8g, 0, 0, "ASCII page 2"); + for( y = 0; y < 6; y++ ) { + for( x = 0; x < 16; x++ ) { + s[0] = y*16 + x + 160; + u8g_DrawStr(&u8g, x*7, y*10+10, s); + } + } +} + + +uint8_t draw_state = 0; + +void draw(void) { + u8g_prepare(); + switch(draw_state >> 3) { + case 0: u8g_box_frame(draw_state&7); break; + case 1: u8g_string(draw_state&7); break; + case 2: u8g_line(draw_state&7); break; + case 3: u8g_ascii_1(); break; + case 4: u8g_ascii_2(); break; + } +} + + +int main(int argc, const char *argv[]) +{ + u8g_linux_Init(&u8g, argc, argv); + + for(;;) + { + /* picture loop */ + u8g_FirstPage(&u8g); + do + { + draw(); + } while ( u8g_NextPage(&u8g) ); + + draw_state++; + if ( draw_state >= 5*8 ) + draw_state = 0; + + /* refresh screen after some delay */ + u8g_Delay(100); + + } +} + diff --git a/sys/i2cdev/helloworld/Makefile b/sys/i2cdev/helloworld/Makefile new file mode 100644 index 00000000..893cc67d --- /dev/null +++ b/sys/i2cdev/helloworld/Makefile @@ -0,0 +1 @@ +include ../common/linux.mk diff --git a/sys/i2cdev/helloworld/helloworld.c b/sys/i2cdev/helloworld/helloworld.c new file mode 100644 index 00000000..378d78d0 --- /dev/null +++ b/sys/i2cdev/helloworld/helloworld.c @@ -0,0 +1,18 @@ +#include "u8g_linux.h" + +int main(int argc, const char *argv[]) +{ + u8g_t u8g; + + u8g_linux_Init(&u8g, argc, argv); + u8g_FirstPage(&u8g); + + do + { + u8g_SetFont(&u8g, u8g_font_unifont); + u8g_DrawStr(&u8g, 0, 20, argc > 2 ? argv[2] : "Hello World!"); + } while( u8g_NextPage(&u8g) ); + + return 0; +} + diff --git a/sys/i2cdev/menu/Makefile b/sys/i2cdev/menu/Makefile new file mode 100644 index 00000000..893cc67d --- /dev/null +++ b/sys/i2cdev/menu/Makefile @@ -0,0 +1 @@ +include ../common/linux.mk diff --git a/sys/i2cdev/menu/menu.c b/sys/i2cdev/menu/menu.c new file mode 100644 index 00000000..b8495317 --- /dev/null +++ b/sys/i2cdev/menu/menu.c @@ -0,0 +1,85 @@ +#include +#include + +#include "u8g_linux.h" + +u8g_t u8g; + +#define MENU_ITEMS 4 +char *menu_strings[MENU_ITEMS] = { "First Line", "Second Item", "3333333", "abcdefg" }; + + +uint8_t menu_current = 0; +uint8_t menu_redraw_required = 0; + + +void draw_menu(void) +{ + uint8_t i, h; + u8g_uint_t w, d; + + u8g_SetFont(&u8g, u8g_font_6x13); + u8g_SetFontRefHeightText(&u8g); + u8g_SetFontPosTop(&u8g); + + h = u8g_GetFontAscent(&u8g)-u8g_GetFontDescent(&u8g); + w = u8g_GetWidth(&u8g); + for( i = 0; i < MENU_ITEMS; i++ ) + { + d = (w-u8g_GetStrWidth(&u8g, menu_strings[i]))/2; + u8g_SetDefaultForegroundColor(&u8g); + if ( i == menu_current ) + { + u8g_DrawBox(&u8g, 0, i*h+1, w, h); + u8g_SetDefaultBackgroundColor(&u8g); + } + u8g_DrawStr(&u8g, d, i*h, menu_strings[i]); + } +} + +void update_menu(void) +{ + switch ( u8g_linux_getch() ) + { + case 'n': + menu_current++; + if ( menu_current >= MENU_ITEMS ) + menu_current = 0; + menu_redraw_required = 1; + break; + case 'p': + if ( menu_current == 0 ) + menu_current = MENU_ITEMS; + menu_current--; + menu_redraw_required = 1; + break; + case 'q': + exit(0); + } +} + + +int main(int argc, const char *argv[]) +{ + u8g_linux_Init(&u8g, argc, argv); + + menu_redraw_required = 1; + + for(;;) + { + + if ( menu_redraw_required != 0 ) + { + u8g_FirstPage(&u8g); + do + { + draw_menu(); + } while( u8g_NextPage(&u8g) ); + menu_redraw_required = 0; + } + + update_menu(); + } + +} + diff --git a/sys/i2cdev/u8g_logo/Makefile b/sys/i2cdev/u8g_logo/Makefile new file mode 100644 index 00000000..893cc67d --- /dev/null +++ b/sys/i2cdev/u8g_logo/Makefile @@ -0,0 +1 @@ +include ../common/linux.mk diff --git a/sys/i2cdev/u8g_logo/u8g_logo.c b/sys/i2cdev/u8g_logo/u8g_logo.c new file mode 100644 index 00000000..c1eda919 --- /dev/null +++ b/sys/i2cdev/u8g_logo/u8g_logo.c @@ -0,0 +1,173 @@ +/* + + u8g_logo.c + + Linux U8glib Example + + 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_linux.h" + +u8g_t u8g; + +/* select, which color background to use */ +#define COLOR_BOX draw_color_box2 + +void draw_color_box1(void) +{ + u8g_uint_t w,h; + u8g_uint_t r, g, b; + + w = u8g_GetWidth(&u8g)/64; + h = u8g_GetHeight(&u8g)/32; + for( b = 0; b < 4; b++ ) + for( g = 0; g < 16; g++ ) + for( r = 0; r < 32; r++ ) + { + u8g_SetRGB(&u8g, r<<3, g<<4, b<<6); + u8g_DrawBox(&u8g, g*w + b*w*16, r*h, w, h); + + } +} + +void draw_color_box2(void) +{ + u8g_uint_t w,h; + u8g_uint_t r, g, b; + + b = 1; + + w = u8g_GetWidth(&u8g)/64; + h = u8g_GetHeight(&u8g)/32; + for( g = 0; g < 16; g++ ) + for( r = 0; r < 32; r++ ) + { + u8g_SetRGB(&u8g, r<<3, g<<4, b<<6); + u8g_DrawBox(&u8g, g*w + 0*w*16, r*h, w, h); + u8g_DrawBox(&u8g, (16-1-g)*w + 1*w*16, r*h, w, h); + u8g_DrawBox(&u8g, g*w + 2*w*16, r*h, w, h); + u8g_DrawBox(&u8g, (16-1-g)*w + 3*w*16, r*h, w, h); + + } +} + +void draw_color_box3(void) +{ + u8g_uint_t r, g, b; + /* assumes 128x128 display */ + for( b = 0; b < 4; b++ ) + { + for( g = 0; g < 32; g++ ) + { + for( r = 0; r < 32; r++ ) + { + u8g_SetRGB(&u8g, r<<3, g<<3, b<<4 ); + u8g_DrawPixel(&u8g, g + b*32, r); + u8g_SetRGB(&u8g, r<<3, g<<3, (b<<4)+64 ); + u8g_DrawPixel(&u8g, g + b*32, r+32); + u8g_SetRGB(&u8g, r<<3, g<<3, (b<<4)+128 ); + u8g_DrawPixel(&u8g, g + b*32, r+32+32); + u8g_SetRGB(&u8g, r<<3, g<<3, (b<<4)+128+64 ); + u8g_DrawPixel(&u8g, g + b*32, r+32+32+32); + } + } + } +} + + +void draw_logo(uint8_t d) +{ + u8g_SetFont(&u8g, u8g_font_gdr25r); + u8g_DrawStr(&u8g, 0+d, 30+d, "U"); + u8g_SetFont(&u8g, u8g_font_gdr30n); + u8g_DrawStr90(&u8g, 23+d,10+d,"8"); + u8g_SetFont(&u8g, u8g_font_gdr25r); + u8g_DrawStr(&u8g, 53+d,30+d,"g"); + + u8g_DrawHLine(&u8g, 2+d, 35+d, 47); + u8g_DrawVLine(&u8g, 45+d, 32+d, 12); +} + +void draw_url(void) +{ + u8g_SetFont(&u8g, u8g_font_4x6); + if ( u8g_GetHeight(&u8g) < 59 ) + { + u8g_DrawStr(&u8g, 53,9,"code.google.com"); + u8g_DrawStr(&u8g, 77,18,"/p/u8glib"); + } + else + { + u8g_DrawStr(&u8g, 1,54,"code.google.com/p/u8glib"); + } +} + + +void draw(void) +{ + if ( u8g_GetMode(&u8g) == U8G_MODE_HICOLOR || u8g_GetMode(&u8g) == U8G_MODE_R3G3B2) + { + COLOR_BOX(); + } + if ( u8g_GetMode(&u8g) == U8G_MODE_HICOLOR || u8g_GetMode(&u8g) == U8G_MODE_R3G3B2) + { + u8g_SetRGB(&u8g, 0x080, 0x040, 0); + draw_logo(2); + u8g_SetRGB(&u8g, 0x080, 0x080, 0); + draw_logo(1); + u8g_SetRGB(&u8g, 0x0ff, 0x0ff, 0); + } + else + { + u8g_SetColorIndex(&u8g, 1); + if ( U8G_MODE_GET_BITS_PER_PIXEL(u8g_GetMode(&u8g)) > 1 ) + { + draw_logo(2); + u8g_SetColorIndex(&u8g, 2); + draw_logo(1); + u8g_SetColorIndex(&u8g, 3); + } + } + draw_logo(0); + draw_url(); +} + +int main(int argc, const char *argv[]) +{ + u8g_linux_Init(&u8g, argc, argv); + u8g_FirstPage(&u8g); + do + { + draw(); + } while ( u8g_NextPage(&u8g) ); +} + diff --git a/sys/lpc11xx/gps/do b/sys/lpc11xx/gps/do old mode 100755 new mode 100644 diff --git a/sys/pbm/cliptest/Makefile b/sys/pbm/cliptest/Makefile old mode 100755 new mode 100644 diff --git a/sys/pbm/cliptest_gr/Makefile b/sys/pbm/cliptest_gr/Makefile old mode 100755 new mode 100644 diff --git a/sys/pbm/dev/u8g_dev_pbm.c b/sys/pbm/dev/u8g_dev_pbm.c index 70523852..6e2313fa 100644 --- a/sys/pbm/dev/u8g_dev_pbm.c +++ b/sys/pbm/dev/u8g_dev_pbm.c @@ -9,6 +9,12 @@ #include #include "u8g.h" +// These are default sizes. They can be changed without changing this +// file by modifying the corresponding parts of the ug8_dev_t struct. +// Changing the height and lowering the width is always possible. To +// increase the width, the page buffer (u8g_pb_dev_pbm below) should +// also be replaced by something bigger. The page height cannot be +// changed. #if defined(U8G_16BIT) #define WIDTH 1024 @@ -33,6 +39,8 @@ uint8_t u8g_dev_pbm_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg) { static FILE *fp; u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem); + u8g_uint_t width = ((u8g_pb_t*)dev->dev_mem)->width; + u8g_uint_t height = ((u8g_pb_t*)dev->dev_mem)->p.total_height; switch(msg) { @@ -40,7 +48,7 @@ uint8_t u8g_dev_pbm_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg) u8g_pb_Clear(pb); u8g_page_First(&(pb->p)); fp = fopen("u8g.pbm", "w"); - fprintf(fp, "P4\n%d %d\n", WIDTH, HEIGHT); + fprintf(fp, "P4\n%d %d\n", width, height); return 1; case U8G_DEV_MSG_PAGE_NEXT: { @@ -49,7 +57,7 @@ uint8_t u8g_dev_pbm_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg) for( j = 0; j < 8; j++ ) { b = 0; - for( i = 0; i < WIDTH; i++ ) + for( i = 0; i < width; i++ ) { b<<= 1; if ( (((uint8_t *)(pb->buf))[i] & (1<dev_mem); + u8g_uint_t width = ((u8g_pb_t*)dev->dev_mem)->width; + u8g_uint_t height = ((u8g_pb_t*)dev->dev_mem)->p.total_height; switch(msg) { @@ -49,7 +57,7 @@ uint8_t u8g_dev_pbm_8h2_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg) case U8G_DEV_MSG_PAGE_FIRST: #ifdef __unix__ u8g_buf_lower_limit = u8g_pb_dev_pbm_buf; - u8g_buf_upper_limit = u8g_pb_dev_pbm_buf + WIDTH; + u8g_buf_upper_limit = u8g_pb_dev_pbm_buf + width; #endif u8g_pb_Clear(pb); @@ -58,7 +66,7 @@ uint8_t u8g_dev_pbm_8h2_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg) if ( u8g_dev_pbm_h2_enable != 0 ) { fp = fopen("u8g.pbm", "w"); - fprintf(fp, "P4\n%d %d\n", WIDTH, HEIGHT); + fprintf(fp, "P4\n%d %d\n", width, height); } return 1; case U8G_DEV_MSG_PAGE_NEXT: @@ -74,7 +82,7 @@ uint8_t u8g_dev_pbm_8h2_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg) for(;;) { b1 = 0; - b = ((uint8_t *)(pb->buf))[i+j*(WIDTH/4)]; + b = ((uint8_t *)(pb->buf))[i+j*(width/4)]; for( k = 0; k < 4; k ++ ) { b1 >>= 1; @@ -84,7 +92,7 @@ uint8_t u8g_dev_pbm_8h2_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg) } i++; b2 = 0; - b = ((uint8_t *)(pb->buf))[i+j*(WIDTH/4)]; + b = ((uint8_t *)(pb->buf))[i+j*(width/4)]; for( k = 0; k < 4; k ++ ) { b2 >>= 1; @@ -94,7 +102,7 @@ uint8_t u8g_dev_pbm_8h2_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg) } i++; fprintf(fp, "%c", b1*16+b2); - if ( i >= WIDTH/4 ) + if ( i >= width/4 ) break; } } diff --git a/sys/pbm/dev/u8g_dev_pbm_h.c b/sys/pbm/dev/u8g_dev_pbm_h.c index 793ec34b..d7feecef 100644 --- a/sys/pbm/dev/u8g_dev_pbm_h.c +++ b/sys/pbm/dev/u8g_dev_pbm_h.c @@ -12,6 +12,12 @@ #include "u8g.h" +// These are default sizes. They can be changed without changing this +// file by modifying the corresponding parts of the ug8_dev_t struct. +// Changing the height and lowering the width is always possible. To +// increase the width, the page buffer (u8g_pb_dev_pbm below) should +// also be replaced by something bigger. The page height cannot be +// changed. #define WIDTH 128 #define HEIGHT 64 #define PAGE_HEIGHT 8 @@ -41,6 +47,8 @@ uint8_t u8g_dev_pbm_8h1_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg) { static FILE *fp; u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem); + u8g_uint_t width = ((u8g_pb_t*)dev->dev_mem)->width; + u8g_uint_t height = ((u8g_pb_t*)dev->dev_mem)->p.total_height; switch(msg) { @@ -48,7 +56,7 @@ uint8_t u8g_dev_pbm_8h1_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg) case U8G_DEV_MSG_PAGE_FIRST: #ifdef __unix__ u8g_buf_lower_limit = u8g_pb_dev_pbm_buf; - u8g_buf_upper_limit = u8g_pb_dev_pbm_buf + WIDTH; + u8g_buf_upper_limit = u8g_pb_dev_pbm_buf + width; #endif u8g_pb_Clear(pb); @@ -57,7 +65,7 @@ uint8_t u8g_dev_pbm_8h1_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg) if ( u8g_dev_pbm_h_enable != 0 ) { fp = fopen("u8g.pbm", "w"); - fprintf(fp, "P4\n%d %d\n", WIDTH, HEIGHT); + fprintf(fp, "P4\n%d %d\n", width, height); } return 1; case U8G_DEV_MSG_PAGE_NEXT: @@ -69,9 +77,9 @@ uint8_t u8g_dev_pbm_8h1_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg) for( j = 0; j < 8; j++ ) { b = 0; - for( i = 0; i < WIDTH/8; i++ ) + for( i = 0; i < width/8; i++ ) { - b = ((uint8_t *)(pb->buf))[i+j*(WIDTH/8)]; + b = ((uint8_t *)(pb->buf))[i+j*(width/8)]; fprintf(fp, "%c", b); } } diff --git a/sys/pbm/helloworld/Makefile b/sys/pbm/helloworld/Makefile old mode 100755 new mode 100644 diff --git a/sys/sdl/circle/main.c b/sys/sdl/circle/main.c index 22d0c1c1..20ea68cc 100644 --- a/sys/sdl/circle/main.c +++ b/sys/sdl/circle/main.c @@ -31,6 +31,11 @@ int main(void) u8g_DrawFilledEllipse(&u8g, 48, 35, 20, rad, U8G_DRAW_UPPER_LEFT); u8g_DrawFilledEllipse(&u8g, 48, 37, 20, rad, U8G_DRAW_LOWER_LEFT); + /* + u8g_DrawRFrame(&u8g, 5,0,25,5,2); + u8g_DrawRFrame(&u8g, 35,0,25,6,2); + */ + } while( u8g_NextPage(&u8g) ); while( u8g_sdl_get_key() < 0 ) diff --git a/sys/sdl/helloworld/main.c b/sys/sdl/helloworld/main.c index 7f236ec2..351ef1e6 100644 --- a/sys/sdl/helloworld/main.c +++ b/sys/sdl/helloworld/main.c @@ -62,6 +62,10 @@ int main(void) u8g_t u8g; u8g_Init(&u8g, &u8g_dev_sdl_1bit); u8g_FirstPage(&u8g); + + + printf("%d\n", ((u8g_pb_t *)(u8g.dev->dev_mem))->p.page_height); + printf("%d\n", ((u8g_pb_t *)(u8g.dev->dev_mem))->p.total_height); do { diff --git a/sys/stdout/flipdisk/Makefile b/sys/stdout/flipdisk/Makefile old mode 100755 new mode 100644 diff --git a/sys/stdout/flipdisk_vs/Makefile b/sys/stdout/flipdisk_vs/Makefile old mode 100755 new mode 100644 diff --git a/sys/stdout/helloworld/Makefile b/sys/stdout/helloworld/Makefile old mode 100755 new mode 100644 diff --git a/sys/stdout/helloworld/main.c b/sys/stdout/helloworld/main.c index 346a353f..6c62c66e 100644 --- a/sys/stdout/helloworld/main.c +++ b/sys/stdout/helloworld/main.c @@ -18,7 +18,7 @@ int main(void) u8g_SetFont(&u8g, u8g_font_10x20); w = u8g_GetFontBBXWidth(&u8g); h = u8g_GetFontBBXHeight(&u8g); - u8g_DrawStr(&u8g, 0, h, 0, "ABCgdef"); + u8g_DrawStr(&u8g, 0, h, "ABCgdef"); //u8g_DrawStr(&u8g, 0, 5, 0, "g"); //u8g_DrawStr(&u8g, 10, 7, 0, "g"); //u8g_DrawStr(&u8g, 20, 9, 0, "g"); diff --git a/sys/stdout/rotation/Makefile b/sys/stdout/rotation/Makefile old mode 100755 new mode 100644 index dd204f5d..387c2b19 --- a/sys/stdout/rotation/Makefile +++ b/sys/stdout/rotation/Makefile @@ -2,7 +2,7 @@ CFLAGS = -g -Wall -I../../../csrc/. -DU8G_16BIT #CFLAGS = -g -Wall -I../../../src/. -SRC = $(shell ls ../../../csrc/*.c) $(shell ls ../../../fntsrc/u8g_font_10x20*.c) $(shell ls ../dev/u8g*.c) main.c +SRC = $(shell ls ../../../csrc/*.c) $(shell ls ../../../fntsrc/*.c) $(shell ls ../dev/u8g*.c) main.c OBJ = $(SRC:.c=.o) diff --git a/sys/stdout/rotation/main.c b/sys/stdout/rotation/main.c index 2899ec17..2aef616f 100644 --- a/sys/stdout/rotation/main.c +++ b/sys/stdout/rotation/main.c @@ -18,8 +18,8 @@ int main(void) u8g_SetFont(&u8g, u8g_font_10x20); w = u8g_GetFontBBXWidth(&u8g); h = u8g_GetFontBBXHeight(&u8g); - u8g_DrawStr(&u8g, 0, h, 0, "A"); - u8g_DrawStr(&u8g, 10, h, 1, "B"); + u8g_DrawStr(&u8g, 0, h, "A"); + u8g_DrawStr(&u8g, 10, h, "B"); u8g_DrawFrame(&u8g, 2, 2, 9, 3); u8g_DrawFrame(&u8g, 0, 0, 13, 7); diff --git a/tools/descpic/Makefile b/tools/descpic/Makefile old mode 100755 new mode 100644 diff --git a/tools/descpic/copy_to_wiki.sh b/tools/descpic/copy_to_wiki.sh old mode 100755 new mode 100644 diff --git a/tools/font/bdf/u8glib_4.bdf b/tools/font/bdf/u8glib_4.bdf old mode 100755 new mode 100644 diff --git a/tools/font/bdf2u8g/bdf2u8g.exe b/tools/font/bdf2u8g/bdf2u8g.exe old mode 100644 new mode 100755 diff --git a/tools/font/build/do_clean.sh b/tools/font/build/do_clean.sh old mode 100755 new mode 100644 diff --git a/tools/font/build/do_u8g_fonts.sh b/tools/font/build/do_u8g_fonts.sh old mode 100755 new mode 100644 diff --git a/tools/font/build/do_u8g_fontsize.sh b/tools/font/build/do_u8g_fontsize.sh old mode 100755 new mode 100644 diff --git a/tools/font/build/do_u8g_fontsize_a.sh b/tools/font/build/do_u8g_fontsize_a.sh old mode 100755 new mode 100644 diff --git a/tools/font/build/do_u8g_fontsize_a_n.sh b/tools/font/build/do_u8g_fontsize_a_n.sh old mode 100755 new mode 100644 diff --git a/tools/font/build/do_u8g_fontsize_f1.sh b/tools/font/build/do_u8g_fontsize_f1.sh old mode 100755 new mode 100644 diff --git a/tools/font/build/do_u8g_fontsize_n.sh b/tools/font/build/do_u8g_fontsize_n.sh old mode 100755 new mode 100644 diff --git a/tools/font/otf2bdf/configure b/tools/font/otf2bdf/configure old mode 100755 new mode 100644 diff --git a/tools/font/overview/Makefile b/tools/font/overview/Makefile old mode 100755 new mode 100644 diff --git a/tools/font/sfnt/do_sfntsrc.sh b/tools/font/sfnt/do_sfntsrc.sh old mode 100755 new mode 100644 diff --git a/tools/font/u8g/u8glib_4.bdf b/tools/font/u8g/u8glib_4.bdf old mode 100755 new mode 100644 diff --git a/tools/intersection/intersection.c b/tools/intersection/intersection.c index 34458dee..efdf3213 100644 --- a/tools/intersection/intersection.c +++ b/tools/intersection/intersection.c @@ -1,8 +1,15 @@ +/* + + intersection.c + + coverage: gcc -fprofile-arcs -ftest-coverage intersection.c +*/ #include #include #include +#include uint8_t array[256]; @@ -243,7 +250,7 @@ void check(uint8_t b1, uint8_t b2) clear(); line(a1, a2, 1); line(b1, b2, 2); - show(); + //show(); intersection = is_array_intersection(); p = conditionpattern(b1, b2); pla[p] |= intersection+1; @@ -288,7 +295,7 @@ void check_size(uint8_t size) void check_all(void) { uint8_t size; - for( size =1; size < 255; size++ ) + for( size =0; size < 255; size++ ) { printf("size=%d\n", size); check_size(size); @@ -297,6 +304,11 @@ void check_all(void) void main(void) { + assert( u8g_is_intersection_decision_tree(4, 6, 7, 9) == 0 ); + assert( u8g_is_intersection_decision_tree(4, 6, 6, 9) != 0 ); + assert( u8g_is_intersection_decision_tree(6, 9, 4, 6) != 0 ); + assert( u8g_is_intersection_decision_tree(7, 9, 4, 6) == 0 ); + conditioninit(); check_all(); /* diff --git a/tools/pic/png/do_resize.sh b/tools/pic/png/do_resize.sh old mode 100755 new mode 100644 diff --git a/tools/pic/png/do_xbm.sh b/tools/pic/png/do_xbm.sh old mode 100755 new mode 100644 diff --git a/tools/polygon/do.sh b/tools/polygon/do.sh old mode 100755 new mode 100644 diff --git a/tools/release/arduino/create_release.sh b/tools/release/arduino/create_release.sh old mode 100755 new mode 100644 diff --git a/tools/release/arduino_new_lib_format/INSTALL.TXT b/tools/release/arduino_new_lib_format/INSTALL.TXT new file mode 100644 index 00000000..efcedd03 --- /dev/null +++ b/tools/release/arduino_new_lib_format/INSTALL.TXT @@ -0,0 +1,26 @@ + +U8GLIB +http://code.google.com/p/u8glib/ + +Install instructions for the Arduino environment. + + 1. Start Arduino IDE + 2. In the Arduino IDE, import the library from the "Add Library" Menu. + +Alternative install instructions for the Arduino environment. + + 1. Unzip u8glib_arduino_vX.XX.zip into the "libraries" folder of the + Arduino install directory + 2. Start Arduino IDE + +Install instructions for the Chipkit (Arduino) environment. + + 1. cd /libraries + 2. unzip u8glib_arduino_vX.XX.zip + 3. cd ///hardware/pic32/libraries + 4. again: u8glib_arduino_vX.XX.zip + 5. Open hardware/pic32/cores/pic32/Print.h + Remove line + #define BYTE 0 + from the file, use PRINT_BYTE instead of BYTE. + \ No newline at end of file diff --git a/tools/release/arduino_new_lib_format/create_release.sh b/tools/release/arduino_new_lib_format/create_release.sh new file mode 100644 index 00000000..a6e5d178 --- /dev/null +++ b/tools/release/arduino_new_lib_format/create_release.sh @@ -0,0 +1,69 @@ +mkdir ../../../../U8glib_Arduino/examples/HelloWorld +mkdir ../../../../U8glib_Arduino/examples/Bitmap +mkdir ../../../../U8glib_Arduino/examples/Console +#mkdir ../../../../U8glib_Arduino/examples/Color +mkdir ../../../../U8glib_Arduino/examples/U8gLogo +mkdir ../../../../U8glib_Arduino/examples/Rotation +mkdir ../../../../U8glib_Arduino/examples/PrintTest +mkdir ../../../../U8glib_Arduino/examples/F +mkdir ../../../../U8glib_Arduino/examples/FPS +mkdir ../../../../U8glib_Arduino/examples/TextRotX +mkdir ../../../../U8glib_Arduino/examples/XBM +mkdir ../../../../U8glib_Arduino/examples/Chess +mkdir ../../../../U8glib_Arduino/examples/GraphicsTest +mkdir ../../../../U8glib_Arduino/examples/Menu +mkdir ../../../../U8glib_Arduino/examples/Scale +mkdir ../../../../U8glib_Arduino/examples/Touch4WSetup +mkdir ../../../../U8glib_Arduino/examples/Touch4WTest +mkdir ../../../../U8glib_Arduino/examples/A2Printer +#mkdir ../../../../U8glib_Arduino/utility +cp ../../../ChangeLog ./../../../../U8glib_Arduino/extras/. +# cp ../../../license.txt ./../../../../U8glib_Arduino/. +cp INSTALL.TXT ./../../../../U8glib_Arduino/extras/. +cp library.properties ../../../../U8glib_Arduino/. +cp ../../../cppsrc/*.cpp ./../../../../U8glib_Arduino/src/. +cp ../../../cppsrc/*.h ./../../../../U8glib_Arduino/src/. +sed -i 's|u8g.h|clib/u8g.h|g' ./../../../../U8glib_Arduino/src/U8glib.h +cp ../../../csrc/*.c ./../../../../U8glib_Arduino/src/clib/. +cp ../../../csrc/*.h ./../../../../U8glib_Arduino/src/clib/. +cp ../../../sfntsrc/*.c ./../../../../U8glib_Arduino/src/clib/. +cp ../../../sys/arduino/HelloWorld/HelloWorld.pde ./../../../../U8glib_Arduino/examples/HelloWorld/HelloWorld.ino +cp ../../../sys/arduino/Bitmap/Bitmap.pde ./../../../../U8glib_Arduino/examples/Bitmap/Bitmap.ino +cp ../../../sys/arduino/Console/Console.pde ./../../../../U8glib_Arduino/examples/Console/Console.ino +# cp ../../../sys/arduino/Color/*.pde ./../../../../U8glib_Arduino/examples/Color/. +cp ../../../sys/arduino/U8gLogo/U8gLogo.pde ./../../../../U8glib_Arduino/examples/U8gLogo/U8gLogo.ino +cp ../../../sys/arduino/Rotation/Rotation.pde ./../../../../U8glib_Arduino/examples/Rotation/Rotation.ino +cp ../../../sys/arduino/PrintTest/PrintTest.pde ./../../../../U8glib_Arduino/examples/PrintTest/PrintTest.ino +cp ../../../sys/arduino/F/F.pde ./../../../../U8glib_Arduino/examples/F/F.ino +cp ../../../sys/arduino/FPS/FPS.pde ./../../../../U8glib_Arduino/examples/FPS/FPS.ino +cp ../../../sys/arduino/TextRotX/TextRotX.pde ./../../../../U8glib_Arduino/examples/TextRotX/TextRotX.ino +cp ../../../sys/arduino/XBM/XBM.pde ./../../../../U8glib_Arduino/examples/XBM/XBM.ino +cp ../../../sys/arduino/Chess/Chess.pde ./../../../../U8glib_Arduino/examples/Chess/Chess.ino +cp ../../../sys/arduino/GraphicsTest/GraphicsTest.pde ./../../../../U8glib_Arduino/examples/GraphicsTest/GraphicsTest.ino +cp ../../../sys/arduino/Menu/Menu.pde ./../../../../U8glib_Arduino/examples/Menu/Menu.ino +cp ../../../sys/arduino/Scale/Scale.pde ./../../../../U8glib_Arduino/examples/Scale/Scale.ino +cp ../../../sys/arduino/Touch4WSetup/Touch4WSetup.pde ./../../../../U8glib_Arduino/examples/Touch4WSetup/Touch4WSetup.ino +cp ../../../sys/arduino/Touch4WTest/Touch4WTest.pde ./../../../../U8glib_Arduino/examples/Touch4WTest/Touch4WTest.ino +cp ../../../sys/arduino/A2Printer/A2Printer.pde ./../../../../U8glib_Arduino/examples/A2Printer/A2Printer.ino +# sed -i 's|U8glib.h|utility/U8glib.h|g' ./../../../../U8glib_Arduino/examples/HelloWorld/*.pde + + +# rename to .ino +# find . -name "*.pde" -exec /bin/sh -c 'f={}; mv ${f} ${f%.*}.ino' \; + +cd ../../../../U8glib_Arduino + +ver=`../u8glib/tools/release/print_release.sh` + +sed -i -e "s/version=.*/version=${ver}/" library.properties + + +git commit -a -m `../u8glib/tools/release/print_release.sh` +git push + +echo now create a release in gitub for U8glib_Arduino, tag/name = ${ver} +# Relases in github: +# Tag: 1.02pre3 +# Release name: 1.02pre3 + + diff --git a/tools/release/arduino_new_lib_format/library.properties b/tools/release/arduino_new_lib_format/library.properties new file mode 100644 index 00000000..b1249b64 --- /dev/null +++ b/tools/release/arduino_new_lib_format/library.properties @@ -0,0 +1,9 @@ +name=U8glib +version=1.18 +author=oliver +maintainer=oliver +sentence=A library for monochrome TFTs and OLEDs +paragraph=Supported display controller: SSD1306, SSD1309, SSD1322, SSD1325, SSD1327, SH1106, UC1601, UC1610, UC1611, UC1701, ST7565, ST7920, KS0108, LC7981, PCD8544, PCF8812, SBN1661, TLS8204, T6963. +category=Display +url=https://github.com/olikraus/u8glib +architectures=avr,sam \ No newline at end of file diff --git a/tools/release/arm/create_release.sh b/tools/release/arm/create_release.sh old mode 100755 new mode 100644 diff --git a/tools/release/arm/sub_create.sh b/tools/release/arm/sub_create.sh old mode 100755 new mode 100644 diff --git a/tools/release/avr/create_release.sh b/tools/release/avr/create_release.sh old mode 100755 new mode 100644 diff --git a/tools/release/botmat/create_release.sh b/tools/release/botmat/create_release.sh old mode 100755 new mode 100644 diff --git a/tools/release/msp430/create_release.sh b/tools/release/msp430/create_release.sh old mode 100755 new mode 100644 diff --git a/tools/release/pic18/create_release.sh b/tools/release/pic18/create_release.sh old mode 100755 new mode 100644 diff --git a/tools/release/print_release.sh b/tools/release/print_release.sh old mode 100755 new mode 100644 index 68932f89..a86f7ce9 --- a/tools/release/print_release.sh +++ b/tools/release/print_release.sh @@ -1 +1,2 @@ -echo -n "v1.18pre1" +# without 'v' prefix +echo -n "1.20.0" diff --git a/u8g2/csrc/u8g2.h b/u8g2/csrc/u8g2.h new file mode 100644 index 00000000..44e4e5a3 --- /dev/null +++ b/u8g2/csrc/u8g2.h @@ -0,0 +1,282 @@ +/* + + u8g2.h + + call sequence + + u8g2_Setup_XYZ + u8x8_Setup_XYZ + u8x8_SetupDefaults(u8g2); + assign u8x8 callbacks + u8x8->display_cb(u8x8, U8X8_MSG_DISPLAY_SETUP, 0, NULL); + setup tile buffer + + + Arduino Uno Text Example +> FONT_ROTATION INTERSECTION CLIPPING text data bss dec hex +> 8700 +> x x x 7450 104 1116 8670 21de +> - x x 7132 104 1115 8351 209f +> x - x 7230 104 1116 8450 2102 +> - - x 7010 104 1115 8229 2025 +> - - - 6880 104 1115 8099 1fa3 + + +*/ + + +#ifndef _U8G2_H +#define _U8G2_H + +#include "u8x8.h" + +/* + The following macro enables the HVLine speed optimization. + It will consume about 40 bytes more in flash memory of the AVR. +*/ +#define U8G2_HVLINE_SPEED_OPTIMIZATION + +/* + The following macro enables all four drawing directions for glyphs and strings. + If this macro is not defined, than a string can be drawn only in horizontal direction. +*/ +#define U8G2_WITH_FONT_ROTATION + +/* + The following macro activates the early intersection check with the current visible area. + Clipping (and low level intersection calculation) may still happen and is controlled by U8G2_WITH_CLIPPING. + This early intersection check mainly improves speed for the picture loop (u8g2_FirstPage/NextPage). + With a full framebuffer in RAM and if most graphical elements are drawn within the visible area, then this + macro can be commented to reduce code size. +*/ +#define U8G2_WITH_INTERSECTION + +/* + Internal performance test for the effect of enabling U8G2_WITH_INTERSECTION + Should not be defined for production code +*/ +//#define U8G2_WITH_HVLINE_COUNT + +/* + Defining the following variable adds the clipping and check procedures agains the display boundaries. + Clipping procedures are mandatory for the picture loop (u8g2_FirstPage/NextPage). + Clipping procedures will also allow strings to exceed the display boundaries. + On the other side, without clipping, all the setting of pixels must happen within the display boundaries. + + WARNING: Adding a comment in front of the following macro or removing the following line + may lead to memory faults if you write any pixel outside the display boundary. +*/ +#define U8G2_WITH_CLIPPING + +/*==========================================*/ + + +#ifdef __GNUC__ +# define U8G2_NOINLINE __attribute__((noinline)) +#else +# define U8G2_NOINLINE +#endif + +/*==========================================*/ +/* C++ compatible */ + +#ifdef __cplusplus +extern "C" { +#endif + +/*==========================================*/ + +typedef uint16_t u8g2_uint_t; /* for pixel position only */ + +typedef struct u8g2_struct u8g2_t; +typedef struct u8g2_cb_struct u8g2_cb_t; + +typedef void (*u8g2_update_dimension_cb)(u8g2_t *u8g2); +typedef void (*u8g2_draw_l90_cb)(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir); + + + +/* from ucglib... */ +struct _u8g2_font_info_t +{ + /* offset 0 */ + uint8_t glyph_cnt; + uint8_t bbx_mode; + uint8_t bits_per_0; + uint8_t bits_per_1; + + /* offset 4 */ + uint8_t bits_per_char_width; + uint8_t bits_per_char_height; + uint8_t bits_per_char_x; + uint8_t bits_per_char_y; + uint8_t bits_per_delta_x; + + /* offset 9 */ + int8_t max_char_width; + int8_t max_char_height; /* overall height, NOT ascent. Instead ascent = max_char_height + y_offset */ + int8_t x_offset; + int8_t y_offset; + + /* offset 13 */ + int8_t ascent_A; + int8_t descent_g; + int8_t ascent_para; + int8_t descent_para; + + /* offset 17 */ + uint16_t start_pos_upper_A; + uint16_t start_pos_lower_a; +}; +typedef struct _u8g2_font_info_t u8g2_font_info_t; + +/* from ucglib... */ +struct _u8g2_font_decode_t +{ + const uint8_t *decode_ptr; /* pointer to the compressed data */ + + u8g2_uint_t target_x; + u8g2_uint_t target_y; + + int8_t x; /* local coordinates, (0,0) is upper left */ + int8_t y; + int8_t glyph_width; + int8_t glyph_height; + + uint8_t decode_bit_pos; /* bitpos inside a byte of the compressed data */ + uint8_t is_transparent; +#ifdef U8G2_WITH_FONT_ROTATION + uint8_t dir; /* direction */ +#endif +}; +typedef struct _u8g2_font_decode_t u8g2_font_decode_t; + + +struct u8g2_cb_struct +{ + u8g2_update_dimension_cb update; + u8g2_draw_l90_cb draw_l90; +}; + +typedef u8g2_uint_t (*u8g2_font_calc_vref_fnptr)(u8g2_t *u8g2); + + +struct u8g2_struct +{ + u8x8_t u8x8; + const u8g2_cb_t *cb; /* callback drawprocedures, can be replaced for rotation */ + + /* the following variables must be assigned during u8g2 setup */ + uint8_t *tile_buf_ptr; /* ptr to memory area with u8g2.display_info->tile_width * 8 * tile_buf_height bytes */ + uint8_t tile_buf_height; /* height of the tile memory area in tile rows */ + uint8_t tile_curr_row; /* current row for picture loop */ + + /* dimension of the buffer in pixel */ + u8g2_uint_t pixel_buf_width; /* equal to tile_buf_height*8 */ + u8g2_uint_t pixel_buf_height; /* u8g2.display_info->tile_width*8 */ + u8g2_uint_t pixel_curr_row; /* u8g2.tile_curr_row*8 */ + + /* the following variables are set by the update dimension callback */ + /* this is clipbox after rotation for the hvline procedures */ + //u8g2_uint_t buf_x0; /* left corner of the buffer */ + //u8g2_uint_t buf_x1; /* right corner of the buffer (excluded) */ + u8g2_uint_t buf_y0; + u8g2_uint_t buf_y1; + + /* display dimensions in pixel for the user, calculated inu8g2_update_dimension_common(), used in u8g2_draw_hv_line_2dir() */ + u8g2_uint_t width; + u8g2_uint_t height; + + /* ths is the clip box for the user to check if a specific box has an intersection */ + u8g2_uint_t user_x0; /* left corner of the buffer */ + u8g2_uint_t user_x1; /* right corner of the buffer (excluded) */ + u8g2_uint_t user_y0; + u8g2_uint_t user_y1; + + /* information about the current font */ + const uint8_t *font; /* current font for all text procedures */ + u8g2_font_calc_vref_fnptr font_calc_vref; + u8g2_font_decode_t font_decode; /* new font decode structure */ + u8g2_font_info_t font_info; /* new font info structure */ + + uint8_t font_height_mode; + int8_t font_ref_ascent; + int8_t font_ref_descent; + + uint8_t draw_color; /* 0: clear pixel, 1: set pixel */ + +#ifdef U8G2_WITH_HVLINE_COUNT + unsigned long hv_cnt; +#endif /* U8G2_WITH_HVLINE_COUNT */ +}; + +#define u8g2_GetU8x8(u8g2) ((u8x8_t *)(u8g2)) + +/*==========================================*/ +/* u8g2_setup.c */ + +extern const u8g2_cb_t u8g2_cb_r0; +extern const u8g2_cb_t u8g2_cb_r1; +extern const u8g2_cb_t u8g2_cb_r2; +extern const u8g2_cb_t u8g2_cb_r3; + +void u8g2_Setup(u8g2_t *u8g2, uint8_t *buf, uint8_t tile_buf_height, const u8g2_cb_t *u8g2_cb); + + + +/*==========================================*/ +/* u8g2_buffer.c */ + +void u8g2_SendBuffer(u8g2_t *u8g2); +void u8g2_ClearBuffer(u8g2_t *u8g2); + +void u8g2_FirstPage(u8g2_t *u8g2); +uint8_t u8g2_NextPage(u8g2_t *u8g2); + + +/*==========================================*/ +/* u8g2_hvline.c */ +void u8g2_DrawHVLine(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir); + + + +/*==========================================*/ +/* u8g2_intersection.c */ +#ifdef U8G2_WITH_INTERSECTION +uint8_t u8g2_IsIntersection(u8g2_t *u8g2, u8g2_uint_t x0, u8g2_uint_t y0, u8g2_uint_t x1, u8g2_uint_t y1); +#endif /* U8G2_WITH_INTERSECTION */ + + +/*==========================================*/ +/* u8g2_font.c */ + + +#define U8G2_FONT_HEIGHT_MODE_TEXT 0 +#define U8G2_FONT_HEIGHT_MODE_XTEXT 1 +#define U8G2_FONT_HEIGHT_MODE_ALL 2 + +void u8g2_SetFont(u8g2_t *u8g2, const uint8_t *font); +void u8g2_SetFontDirection(u8g2_t *u8g2, uint8_t dir); +u8g2_uint_t u8g2_DrawString(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, const char *str); + +/*==========================================*/ +/* u8x8_d_sdl_128x64.c */ +void u8g2_Setup_SDL_128x64(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb); +void u8g2_Setup_SDL_128x64_4(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb); + +/*==========================================*/ +/* u8x8_d_tga.c */ +void u8g2_Setup_TGA_DESC(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb); +void u8g2_Setup_TGA_LCD(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb); + + +/*==========================================*/ +/* C++ compatible */ + +#ifdef __cplusplus +} +#endif + + +#endif + diff --git a/u8g2/csrc/u8g2_buffer.c b/u8g2/csrc/u8g2_buffer.c new file mode 100644 index 00000000..b59af500 --- /dev/null +++ b/u8g2/csrc/u8g2_buffer.c @@ -0,0 +1,78 @@ +/* + + u8g2_buffer.c + +*/ + +#include "u8g2.h" +#include + +/*============================================*/ +void u8g2_ClearBuffer(u8g2_t *u8g2) +{ + size_t cnt; + cnt = u8g2_GetU8x8(u8g2)->display_info->tile_width; + cnt *= u8g2->tile_buf_height; + cnt *= 8; + memset(u8g2->tile_buf_ptr, 0, cnt); +} + +/*============================================*/ + +static void u8g2_send_tile_row(u8g2_t *u8g2, uint8_t src_tile_row, uint8_t dest_tile_row) +{ + uint8_t *ptr; + uint16_t offset; + uint8_t w; + + w = u8g2_GetU8x8(u8g2)->display_info->tile_width; + offset = src_tile_row; + ptr = u8g2->tile_buf_ptr; + offset *= w; + offset *= 8; + ptr += offset; + + u8x8_display_DrawTile(u8g2_GetU8x8(u8g2), 0, dest_tile_row, w, ptr); +} + +void u8g2_SendBuffer(u8g2_t *u8g2) +{ + uint8_t src_row; + uint8_t src_max; + uint8_t dest_row; + uint8_t dest_max; + + src_row = 0; + src_max = u8g2->tile_buf_height; + dest_row = u8g2->tile_curr_row; + dest_max = u8g2_GetU8x8(u8g2)->display_info->tile_height; + + do + { + u8g2_send_tile_row(u8g2, src_row, dest_row); + src_row++; + dest_row++; + } while( src_row < src_max && dest_row < dest_max ); +} + +/*============================================*/ +void u8g2_FirstPage(u8g2_t *u8g2) +{ + u8g2_ClearBuffer(u8g2); + u8g2->tile_curr_row = 0; + u8g2->cb->update(u8g2); +} + +uint8_t u8g2_NextPage(u8g2_t *u8g2) +{ + uint8_t row; + u8g2_SendBuffer(u8g2); + row = u8g2->tile_curr_row; + row += u8g2->tile_buf_height; + if ( row >= u8g2_GetU8x8(u8g2)->display_info->tile_height ) + return 0; + u8g2_ClearBuffer(u8g2); + u8g2->tile_curr_row = row; + u8g2->cb->update(u8g2); + return 1; +} diff --git a/u8g2/csrc/u8g2_font.c b/u8g2/csrc/u8g2_font.c new file mode 100644 index 00000000..c4a17c7a --- /dev/null +++ b/u8g2/csrc/u8g2_font.c @@ -0,0 +1,803 @@ +/* + + u8g2_font.c + +*/ + +#include "u8g2.h" + +/* size of the font data structure, there is no struct or class... */ +/* this is the size for the new font format */ +#define U8G2_FONT_DATA_STRUCT_SIZE 21 + +/* + font data: + + offset bytes description + 0 1 glyph_cnt number of glyphs + 1 1 bbx_mode 0: proportional, 1: common height, 2: monospace, 3: multiple of 8 + 2 1 bits_per_0 glyph rle parameter + 3 1 bits_per_1 glyph rle parameter + + 4 1 bits_per_char_width glyph rle parameter + 5 1 bits_per_char_height glyph rle parameter + 6 1 bits_per_char_x glyph rle parameter + 7 1 bits_per_char_y glyph rle parameter + 8 1 bits_per_delta_x glyph rle parameter + + 9 1 max_char_width + 10 1 max_char_height + 11 1 x offset + 12 1 y offset (descent) + + 13 1 ascent (capital A) + 14 1 descent (lower g) + 15 1 ascent '(' + 16 1 descent ')' + + 17 1 start pos 'A' high byte + 18 1 start pos 'A' low byte + + 19 1 start pos 'a' high byte + 20 1 start pos 'a' low byte + + Font build mode, 0: proportional, 1: common height, 2: monospace, 3: multiple of 8 + + Font build mode 0: + - "t" + - Ref height mode: U8G2_FONT_HEIGHT_MODE_TEXT, U8G2_FONT_HEIGHT_MODE_XTEXT or U8G2_FONT_HEIGHT_MODE_ALL + - use in transparent mode only (does not look good in solid mode) + - most compact format + - different font heights possible + + Font build mode 1: + - "h" + - Ref height mode: U8G2_FONT_HEIGHT_MODE_ALL + - transparent or solid mode + - The height of the glyphs depend on the largest glyph in the font. This means font height depends on postfix "r", "f" and "n". + +*/ + +/* use case: What is the width and the height of the minimal box into which string s fints? */ +void u8g2_font_GetStrSize(const void *font, const char *s, u8g2_uint_t *width, u8g2_uint_t *height); +void u8g2_font_GetStrSizeP(const void *font, const char *s, u8g2_uint_t *width, u8g2_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 u8g2_font_AdjustXYToDraw(const void *font, const char *s, u8g2_uint_t *x, u8g2_uint_t *y); +void u8g2_font_AdjustXYToDrawP(const void *font, const char *s, u8g2_uint_t *x, u8g2_uint_t *y); + +/* use case: Baseline origin known, return minimal box */ +void u8g2_font_GetStrMinBox(u8g2_t *u8g2, const void *font, const char *s, u8g2_uint_t *x, u8g2_uint_t *y, u8g2_uint_t *width, u8g2_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 u8g2_font_get_byte(const uint8_t *font, uint8_t offset) U8G2_NOINLINE; +static uint8_t u8g2_font_get_byte(const uint8_t *font, uint8_t offset) +{ + font += offset; + return u8x8_pgm_read( (uint8_t *)font ); +} + +static uint16_t u8g2_font_get_word(const uint8_t *font, uint8_t offset) U8G2_NOINLINE; +static uint16_t u8g2_font_get_word(const uint8_t *font, uint8_t offset) +{ + uint16_t pos; + font += offset; + pos = u8x8_pgm_read( (uint8_t *)font ); + font++; + pos <<= 8; + pos += u8x8_pgm_read( (uint8_t *)font); + return pos; +} + +/*========================================================================*/ +/* new font format */ +void u8g2_read_font_info(u8g2_font_info_t *font_info, const uint8_t *font) +{ + /* offset 0 */ + font_info->glyph_cnt = u8g2_font_get_byte(font, 0); + font_info->bbx_mode = u8g2_font_get_byte(font, 1); + font_info->bits_per_0 = u8g2_font_get_byte(font, 2); + font_info->bits_per_1 = u8g2_font_get_byte(font, 3); + + /* offset 4 */ + font_info->bits_per_char_width = u8g2_font_get_byte(font, 4); + font_info->bits_per_char_height = u8g2_font_get_byte(font, 5); + font_info->bits_per_char_x = u8g2_font_get_byte(font, 6); + font_info->bits_per_char_y = u8g2_font_get_byte(font, 7); + font_info->bits_per_delta_x = u8g2_font_get_byte(font, 8); + + /* offset 9 */ + font_info->max_char_width = u8g2_font_get_byte(font, 9); + font_info->max_char_height = u8g2_font_get_byte(font, 10); + font_info->x_offset = u8g2_font_get_byte(font, 11); + font_info->y_offset = u8g2_font_get_byte(font, 12); + + /* offset 13 */ + font_info->ascent_A = u8g2_font_get_byte(font, 13); + font_info->descent_g = u8g2_font_get_byte(font, 14); + font_info->ascent_para = u8g2_font_get_byte(font, 15); + font_info->descent_para = u8g2_font_get_byte(font, 16); + + /* offset 17 */ + font_info->start_pos_upper_A = u8g2_font_get_word(font, 17); + font_info->start_pos_lower_a = u8g2_font_get_word(font, 19); +} + + +/* calculate the overall length of the font, only used to create the picture for the google wiki */ +size_t u8g2_font_GetSize(const void *font_arg) +{ + const uint8_t *font = font_arg; + font += U8G2_FONT_DATA_STRUCT_SIZE; + + for(;;) + { + if ( u8x8_pgm_read( ((uint8_t *)font) + 1 ) == 0 ) + break; + font += u8x8_pgm_read( ((uint8_t *)font) + 1 ); + } + + return (font - (const uint8_t *)font_arg) + 2; + +} + +/*========================================================================*/ +/* u8g2 interface, font access */ + +uint8_t u8g2_GetFontBBXWidth(u8g2_t *u8g2) +{ + return u8g2->font_info.max_char_width; /* new font info structure */ +} + +uint8_t u8g2_GetFontBBXHeight(u8g2_t *u8g2) +{ + return u8g2->font_info.max_char_height; /* new font info structure */ +} + +int8_t u8g_GetFontBBXOffX(u8g2_t *u8g2) U8G2_NOINLINE; +int8_t u8g_GetFontBBXOffX(u8g2_t *u8g2) +{ + return u8g2->font_info.x_offset; /* new font info structure */ +} + +int8_t u8g2_GetFontBBXOffY(u8g2_t *u8g2) U8G2_NOINLINE; +int8_t u8g2_GetFontBBXOffY(u8g2_t *u8g2) +{ + return u8g2->font_info.y_offset; /* new font info structure */ +} + +uint8_t u8g2_GetFontCapitalAHeight(u8g2_t *u8g2) U8G2_NOINLINE; +uint8_t u8g2_GetFontCapitalAHeight(u8g2_t *u8g2) +{ + return u8g2->font_info.ascent_A; /* new font info structure */ +} + +/*========================================================================*/ +/* glyph handling */ + +/* optimized */ +uint8_t u8g2_font_decode_get_unsigned_bits(u8g2_font_decode_t *f, uint8_t cnt) +{ + uint8_t val; + uint8_t bit_pos = f->decode_bit_pos; + uint8_t bit_pos_plus_cnt; + + //val = *(f->decode_ptr); + val = u8x8_pgm_read( (uint8_t *)(f->decode_ptr) ); + + val >>= bit_pos; + bit_pos_plus_cnt = bit_pos; + bit_pos_plus_cnt += cnt; + if ( bit_pos_plus_cnt >= 8 ) + { + uint8_t s = 8; + s -= bit_pos; + f->decode_ptr++; + //val |= *(f->decode_ptr) << (8-bit_pos); + val |= u8x8_pgm_read( (uint8_t *)(f->decode_ptr) ) << (s); + //bit_pos -= 8; + bit_pos_plus_cnt -= 8; + } + val &= (1U<decode_bit_pos = bit_pos_plus_cnt; + return val; +} + + +/* + 2 bit --> cnt = 2 + -2,-1,0. 1 + + 3 bit --> cnt = 3 + -2,-1,0. 1 + -4,-3,-2,-1,0,1,2,3 + + if ( x < 0 ) + r = bits(x-1)+1; + else + r = bits(x)+1; + +*/ +/* optimized */ +int8_t u8g2_font_decode_get_signed_bits(u8g2_font_decode_t *f, uint8_t cnt) +{ + int8_t v, d; + v = (int8_t)u8g2_font_decode_get_unsigned_bits(f, cnt); + d = 1; + cnt--; + d <<= cnt; + v -= d; + return v; + //return (int8_t)u8g2_font_decode_get_unsigned_bits(f, cnt) - ((1<>1); +} + + +#ifdef U8G2_WITH_FONT_ROTATION +static u8g2_uint_t u8g2_add_vector_y(u8g2_uint_t dy, int8_t x, int8_t y, uint8_t dir) U8G2_NOINLINE; +static u8g2_uint_t u8g2_add_vector_y(u8g2_uint_t dy, int8_t x, int8_t y, uint8_t dir) +{ + switch(dir) + { + case 0: + dy += y; + break; + case 1: + dy += x; + break; + case 2: + dy -= y; + break; + default: + dy -= x; + break; + } + return dy; +} + +static u8g2_uint_t u8g2_add_vector_x(u8g2_uint_t dx, int8_t x, int8_t y, uint8_t dir) U8G2_NOINLINE; +static u8g2_uint_t u8g2_add_vector_x(u8g2_uint_t dx, int8_t x, int8_t y, uint8_t dir) +{ + switch(dir) + { + case 0: + dx += x; + break; + case 1: + dx -= y; + break; + case 2: + dx -= x; + break; + default: + dx += y; + break; + } + return dx; +} +#endif + + + +/* + Description: + Draw a run-length area of the glyph. "len" can have any size and the line + length has to be wrapped at the glyph border. + Args: + len: Length of the line + is_foreground foreground/background? + u8g2->font_decode.target_x X position + u8g2->font_decode.target_y Y position + u8g2->font_decode.is_transparent Transparent mode + Return: + - + Calls: + u8g2_Draw90Line() + Called by: + u8g2_font_decode_glyph() +*/ +/* optimized */ +void u8g2_font_decode_len(u8g2_t *u8g2, uint8_t len, uint8_t is_foreground) +{ + uint8_t cnt; /* total number of remaining pixels, which have to be drawn */ + uint8_t rem; /* remaining pixel to the right edge of the glyph */ + uint8_t current; /* number of pixels, which need to be drawn for the draw procedure */ + /* current is either equal to cnt or equal to rem */ + + /* local coordinates of the glyph */ + uint8_t lx,ly; + + /* target position on the screen */ + u8g2_uint_t x, y; + + u8g2_font_decode_t *decode = &(u8g2->font_decode); + + cnt = len; + + /* get the local position */ + lx = decode->x; + ly = decode->y; + + for(;;) + { + /* calculate the number of pixel to the right edge of the glyph */ + rem = decode->glyph_width; + rem -= lx; + + /* calculate how many pixel to draw. This is either to the right edge */ + /* or lesser, if not enough pixel are left */ + current = rem; + if ( cnt < rem ) + current = cnt; + + + /* now draw the line, but apply the rotation around the glyph target position */ + //u8g2_font_decode_draw_pixel(u8g2, lx,ly,current, is_foreground); + + /* get target position */ + x = decode->target_x; + y = decode->target_y; + + /* apply rotation */ +#ifdef U8G2_WITH_FONT_ROTATION + x = u8g2_add_vector_x(x, lx, ly, decode->dir); + y = u8g2_add_vector_y(y, lx, ly, decode->dir); +#else + x += lx; + y += ly; +#endif + + /* draw foreground and background (if required) */ + if ( is_foreground ) + { + u8g2->draw_color = 1; /* Fix me: Must be the glyph color (additional variable) */ + u8g2_DrawHVLine(u8g2, + x, + y, + current, +#ifdef U8G2_WITH_FONT_ROTATION + /* dir */ decode->dir +#else + 0 +#endif + ); + } + else if ( decode->is_transparent == 0 ) + { + u8g2->draw_color = 0; /* Fix me: Must be the complement of the glyph color (additional variable) */ + u8g2_DrawHVLine(u8g2, + x, + y, + current, +#ifdef U8G2_WITH_FONT_ROTATION + /* dir */ decode->dir +#else + 0 +#endif + ); + } + + /* check, whether the end of the run length code has been reached */ + if ( cnt < rem ) + break; + cnt -= rem; + lx = 0; + ly++; + } + lx += cnt; + + decode->x = lx; + decode->y = ly; + +} + +static void u8g2_font_setup_decode(u8g2_t *u8g2, const uint8_t *glyph_data) +{ + u8g2_font_decode_t *decode = &(u8g2->font_decode); + decode->decode_ptr = glyph_data; + decode->decode_bit_pos = 0; + + decode->decode_ptr += 1; + decode->decode_ptr += 1; + + decode->glyph_width = u8g2_font_decode_get_unsigned_bits(decode, u8g2->font_info.bits_per_char_width); + decode->glyph_height = u8g2_font_decode_get_unsigned_bits(decode,u8g2->font_info.bits_per_char_height); +} + + +/* + Description: + Decode and draw a glyph. + Args: + glyph_data: Pointer to the compressed glyph data of the font + u8g2->font_decode.target_x X position + u8g2->font_decode.target_y Y position + u8g2->font_decode.is_transparent Transparent mode + Return: + Width (delta x advance) of the glyph. + Calls: + u8g2_font_decode_len() +*/ +/* optimized */ +int8_t u8g2_font_decode_glyph(u8g2_t *u8g2, const uint8_t *glyph_data) +{ + uint8_t a, b; + int8_t x, y; + int8_t d; + int8_t h; + u8g2_font_decode_t *decode = &(u8g2->font_decode); + + u8g2_font_setup_decode(u8g2, glyph_data); + h = u8g2->font_decode.glyph_height; + + x = u8g2_font_decode_get_signed_bits(decode, u8g2->font_info.bits_per_char_x); + y = u8g2_font_decode_get_signed_bits(decode, u8g2->font_info.bits_per_char_y); + d = u8g2_font_decode_get_signed_bits(decode, u8g2->font_info.bits_per_delta_x); + + if ( decode->glyph_width > 0 ) + { +#ifdef U8G2_WITH_FONT_ROTATION + decode->target_x = u8g2_add_vector_x(decode->target_x, x, -(h+y), decode->dir); + decode->target_y = u8g2_add_vector_y(decode->target_y, x, -(h+y), decode->dir); +#else + decode->target_x += x; + decode->target_y -= h+y; +#endif + //u8g2_add_vector(&(decode->target_x), &(decode->target_y), x, -(h+y), decode->dir); + +#ifdef U8G2_WITH_INTERSECTION + { + u8g2_uint_t x0, x1, y0, y1; + x0 = decode->target_x; + y0 = decode->target_y; + x1 = x0; + y1 = y0; + +#ifdef U8G2_WITH_FONT_ROTATION + switch(decode->dir) + { + case 0: + x1 += decode->glyph_width; + y1 += h; + break; + case 1: + x0 -= h; + y1 += decode->glyph_width; + break; + case 2: + x0 -= decode->glyph_width; + y0 -= h; + break; + case 3: + x1 += h; + y0 -= decode->glyph_width; + break; + } +#else /* U8G2_WITH_FONT_ROTATION */ + x1 += decode->glyph_width; + y1 += h; +#endif + + if ( u8g2_IsIntersection(u8g2, x0, y0, x1, y1) == 0 ) + return d; + } +#endif /* U8G2_WITH_INTERSECTION */ + + /* reset local x/y position */ + decode->x = 0; + decode->y = 0; + + /* decode glyph */ + for(;;) + { + a = u8g2_font_decode_get_unsigned_bits(decode, u8g2->font_info.bits_per_0); + b = u8g2_font_decode_get_unsigned_bits(decode, u8g2->font_info.bits_per_1); + do + { + u8g2_font_decode_len(u8g2, a, 0); + u8g2_font_decode_len(u8g2, b, 1); + } while( u8g2_font_decode_get_unsigned_bits(decode, 1) != 0 ); + + if ( decode->y >= h ) + break; + } + } + return d; +} + +/* + Description: + Find the starting point of the glyph data. + Args: + encoding: Encoding (ASCII code) of the glyph + Return: + Address of the glyph data or NULL, if the encoding is not avialable in the font. +*/ +const uint8_t *u8g2_font_get_glyph_data(u8g2_t *u8g2, uint8_t encoding) +{ + const uint8_t *font = u8g2->font; + font += U8G2_FONT_DATA_STRUCT_SIZE; + + if ( encoding >= 'a' ) + { + font += u8g2->font_info.start_pos_lower_a; + } + else if ( encoding >= 'A' ) + { + font += u8g2->font_info.start_pos_upper_A; + } + + for(;;) + { + if ( u8x8_pgm_read( ((uint8_t *)font) + 1 ) == 0 ) + break; + if ( u8x8_pgm_read( (uint8_t *)font ) == encoding ) + { + return font; + } + font += u8x8_pgm_read( ((uint8_t *)font) + 1 ); + } + return NULL; +} + +static u8g2_uint_t u8g2_font_draw_glyph(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, uint8_t encoding) +{ + u8g2_uint_t dx = 0; + u8g2->font_decode.target_x = x; + u8g2->font_decode.target_y = y; + //u8g2->font_decode.is_transparent = is_transparent; this is already set + //u8g2->font_decode.dir = dir; + const uint8_t *glyph_data = u8g2_font_get_glyph_data(u8g2, encoding); + if ( glyph_data != NULL ) + { + dx = u8g2_font_decode_glyph(u8g2, glyph_data); + } + return dx; +} + + + +uint8_t u8g2_IsGlyph(u8g2_t *u8g2, uint8_t requested_encoding) +{ + /* updated to new code */ + if ( u8g2_font_get_glyph_data(u8g2, requested_encoding) != NULL ) + return 1; + return 0; +} + +int8_t u8g2_GetGlyphWidth(u8g2_t *u8g2, uint8_t requested_encoding) +{ + const uint8_t *glyph_data = u8g2_font_get_glyph_data(u8g2, requested_encoding); + if ( glyph_data == NULL ) + return 0; + + u8g2_font_setup_decode(u8g2, glyph_data); + u8g2_font_decode_get_signed_bits(&(u8g2->font_decode), u8g2->font_info.bits_per_char_x); + u8g2_font_decode_get_signed_bits(&(u8g2->font_decode), u8g2->font_info.bits_per_char_y); + + return u8g2_font_decode_get_signed_bits(&(u8g2->font_decode), u8g2->font_info.bits_per_delta_x); +} + + +/* + set one of: + U8G2_FONT_MODE_TRANSPARENT + U8G2_FONT_MODE_SOLID + U8G2_FONT_MODE_NONE + This has been changed for the new font procedures +*/ +void u8g2_SetFontMode(u8g2_t *u8g2, uint8_t is_transparent) +{ + u8g2->font_decode.is_transparent = is_transparent; // new font procedures +} + +u8g2_uint_t u8g2_DrawGlyph(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, uint8_t encoding) +{ +#ifdef U8G2_WITH_FONT_ROTATION + switch(u8g2->font_decode.dir) + { + case 0: + y += u8g2->font_calc_vref(u8g2); + break; + case 1: + x -= u8g2->font_calc_vref(u8g2); + break; + case 2: + y -= u8g2->font_calc_vref(u8g2); + break; + case 3: + x += u8g2->font_calc_vref(u8g2); + break; + } +#else + y += u8g2->font_calc_vref(u8g2); +#endif + return u8g2_font_draw_glyph(u8g2, x, y, encoding); +} + +u8g2_uint_t u8g2_DrawString(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, const char *str) +{ + u8g2_uint_t delta, sum; + sum = 0; + while( *str != '\0' ) + { + delta = u8g2_DrawGlyph(u8g2, x, y, (uint8_t)*str); + +#ifdef U8G2_WITH_FONT_ROTATION + switch(u8g2->font_decode.dir) + { + case 0: + x += delta; + break; + case 1: + y += delta; + break; + case 2: + x -= delta; + break; + case 3: + y -= delta; + break; + } +#else + x += delta; +#endif + sum += delta; + str++; + } + return sum; +} + + +/*===============================================*/ + +/* set ascent/descent for reference point calculation */ + +void u8g2_UpdateRefHeight(u8g2_t *u8g2) +{ + if ( u8g2->font == NULL ) + return; + u8g2->font_ref_ascent = u8g2->font_info.ascent_A; + u8g2->font_ref_descent = u8g2->font_info.descent_g; + if ( u8g2->font_height_mode == U8G2_FONT_HEIGHT_MODE_TEXT ) + { + } + else if ( u8g2->font_height_mode == U8G2_FONT_HEIGHT_MODE_XTEXT ) + { + if ( u8g2->font_ref_ascent < u8g2->font_info.ascent_para ) + u8g2->font_ref_ascent = u8g2->font_info.ascent_para; + if ( u8g2->font_ref_descent > u8g2->font_info.descent_para ) + u8g2->font_ref_descent = u8g2->font_info.descent_para; + } + else + { + if ( u8g2->font_ref_ascent < u8g2->font_info.max_char_height+u8g2->font_info.y_offset ) + u8g2->font_ref_ascent = u8g2->font_info.max_char_height+u8g2->font_info.y_offset; + if ( u8g2->font_ref_descent > u8g2->font_info.y_offset ) + u8g2->font_ref_descent = u8g2->font_info.y_offset; + } +} + +void u8g2_SetFontRefHeightText(u8g2_t *u8g2) +{ + u8g2->font_height_mode = U8G2_FONT_HEIGHT_MODE_TEXT; + u8g2_UpdateRefHeight(u8g2); +} + +void u8g2_SetFontRefHeightExtendedText(u8g2_t *u8g2) +{ + u8g2->font_height_mode = U8G2_FONT_HEIGHT_MODE_XTEXT; + u8g2_UpdateRefHeight(u8g2); +} + +void u8g2_SetFontRefHeightAll(u8g2_t *u8g2) +{ + u8g2->font_height_mode = U8G2_FONT_HEIGHT_MODE_ALL; + u8g2_UpdateRefHeight(u8g2); +} + +/*===============================================*/ +/* callback procedures to correct the y position */ + +u8g2_uint_t u8g2_font_calc_vref_font(u8g2_t *u8g2) +{ + return 0; +} + +void u8g2_SetFontPosBaseline(u8g2_t *u8g2) +{ + u8g2->font_calc_vref = u8g2_font_calc_vref_font; +} + + +u8g2_uint_t u8g2_font_calc_vref_bottom(u8g2_t *u8g2) +{ + return (u8g2_uint_t)(u8g2->font_ref_descent); +} + +void u8g2_SetFontPosBottom(u8g2_t *u8g2) +{ + u8g2->font_calc_vref = u8g2_font_calc_vref_bottom; +} + +u8g2_uint_t u8g2_font_calc_vref_top(u8g2_t *u8g2) +{ + u8g2_uint_t tmp; + /* reference pos is one pixel above the upper edge of the reference glyph */ + tmp = (u8g2_uint_t)(u8g2->font_ref_ascent); + tmp++; + return tmp; +} + +void u8g2_SetFontPosTop(u8g2_t *u8g2) +{ + u8g2->font_calc_vref = u8g2_font_calc_vref_top; +} + +u8g2_uint_t u8g2_font_calc_vref_center(u8g2_t *u8g2) +{ + int8_t tmp; + tmp = u8g2->font_ref_ascent; + tmp -= u8g2->font_ref_descent; + tmp /= 2; + tmp += u8g2->font_ref_descent; + return tmp; +} + +void u8g2_SetFontPosCenter(u8g2_t *u8g2) +{ + u8g2->font_calc_vref = u8g2_font_calc_vref_center; +} + +/*===============================================*/ + +void u8g2_SetFont(u8g2_t *u8g2, const uint8_t *font) +{ + if ( u8g2->font != font ) + { + u8g2->font = font; + u8g2_read_font_info(&(u8g2->font_info), font); + u8g2_UpdateRefHeight(u8g2); + u8g2_SetFontPosBaseline(u8g2); + } +} + +/*===============================================*/ + +u8g2_uint_t u8g2_GetStrWidth(u8g2_t *u8g2, const char *s) +{ + u8g2_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 */ + + // replaced by this: + w += u8g2_GetGlyphWidth(u8g2, encoding); + + /* goto next char */ + s++; + } + return w; +} + +void u8g2_SetFontDirection(u8g2_t *u8g2, uint8_t dir) +{ +#ifdef U8G2_WITH_FONT_ROTATION + u8g2->font_decode.dir = dir; +#endif +} \ No newline at end of file diff --git a/u8g2/csrc/u8g2_hvline.c b/u8g2/csrc/u8g2_hvline.c new file mode 100644 index 00000000..be75d71b --- /dev/null +++ b/u8g2/csrc/u8g2_hvline.c @@ -0,0 +1,522 @@ +/* + + u8g2_hvline.c + + + Calltree + void u8g2_DrawHVLine(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir) + u8g2->cb->draw_l90 + void u8g2_draw_hv_line_4dir(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir) + void u8g2_draw_hv_line_2dir(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir) + void u8g2_unsafe_draw_hv_line(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir) + void u8g2_draw_pixel(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y) + +*/ + +#include "u8g2.h" +#include + +#ifdef _REALY_FAST_VERSION +static uint8_t *u8g2_get_buffer_ptr(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y) U8G2_NOINLINE; +static uint8_t *u8g2_get_buffer_ptr(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y) +{ + uint8_t *ptr; + uint16_t offset; + + y &= ~7; /* zero the lowest 3 bits, y is tile-row * 8 from now on */ + offset = y; /* y might be 8 or 16 bit, but we need 16 bit, so use a 16 bit variable */ + offset *= u8g2_GetU8x8(u8g2)->display_info->tile_width; + ptr = u8g2->tile_buf_ptr; + ptr += offset; + ptr += x; + + return ptr; +} + +static void u8g2_draw_hline(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len) +{ + uint8_t *ptr; + uint8_t bit_pos, mask; + + //assert(x >= u8g2->buf_x0); + assert(x < u8g2_GetU8x8(u8g2)->display_info->tile_width*8); + //assert(y >= u8g2->buf_y0); + assert(y < u8g2_GetU8x8(u8g2)->display_info->tile_height*8); + + /* bytes are vertical, lsb on top (y=0), msb at bottom (y=7) */ + bit_pos = y; /* overflow truncate is ok here... */ + bit_pos &= 7; /* ... because only the lowest 3 bits are needed */ + + ptr = u8g2_get_buffer_ptr(u8g2, x, y); + + mask = 1; + mask <<= bit_pos; + if ( u8g2->draw_color != 0 ) + { + do + { + *ptr |= mask; + len--; + ptr++; + } while( len > 0 ); + } + else + { + mask ^= 255; + do + { + *ptr &= mask; + len--; + ptr++; + } while( len > 0 ); + } +} + +/* + bitpos0 = y & 7 + remaining len = len - (8 - bitpos0) + (len)/8 --> count intermediate bytes + if ( bitpos2 != 0 ) + +*/ + +static void u8g2_draw_vline(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len) +{ + uint8_t *ptr; + uint16_t offset; + uint8_t bit_pos0, bit_pos2; + uint8_t mask0, mask1, mask2; + u8g2_uint_t cnt; + + //assert(x >= u8g2->buf_x0); + assert(x < u8g2_GetU8x8(u8g2)->display_info->tile_width*8); + //assert(y >= u8g2->buf_y0); + assert(y < u8g2_GetU8x8(u8g2)->display_info->tile_height*8); + + /* bytes are vertical, lsb on top (y=0), msb at bottom (y=7) */ + bit_pos0 = y; /* overflow truncate is ok here... */ + bit_pos2 = y; /* overflow truncate is ok here... */ + bit_pos2 += (uint8_t)len; /* overflow truncate is also ok here... */ + bit_pos0 &= 7; /* ... because only the lowest 3 bits are needed */ + bit_pos2 &= 7; /* ... because only the lowest 3 bits are needed */ + + ptr = u8g2_get_buffer_ptr(u8g2, x, y); + + mask0 = 255; + mask0 <<= bit_pos0; + + mask2 = 255; + mask2 <<= bit_pos2; + + cnt = (len - (8 - bit_pos0)); + cnt >>= 3; + + if ( u8g2->draw_color != 0 ) + { + mask1 = 255; + mask2 ^= 255; + if ( (len <= 7) && (bit_pos0 < bit_pos2 ) ) + { + mask0 &= mask2; + *ptr |= mask0; + } + else + { + *ptr |= mask0; + while( cnt > 0 ) + { + ptr+=u8g2->width; + *ptr = mask1; + cnt--; + } + if ( bit_pos2 != 0 ) + { + ptr+=u8g2->width; + *ptr |= mask2; + } + } + } + else + { + mask0 ^= 255; + mask1 = 0; + if ( (len <= 7) && (bit_pos0 < bit_pos2 ) ) + { + mask0 |= mask2; + *ptr &= mask0; + } + else + { + *ptr &= mask0; + while( cnt > 0 ) + { + ptr+=u8g2->width; + *ptr = mask1; + cnt--; + } + if ( bit_pos2 != 0 ) + { + ptr+=u8g2->width; + *ptr &= mask2; + } + } + + } +} + +/* + x,y Upper left position of the line within the local buffer (not the display!) + len length of the line in pixel, len must not be 0 + dir 0: horizontal line (left to right) + 1: vertical line (top to bottom) + asumption: + all clipping done +*/ +static void u8g2_unsafe_draw_hv_line(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir) +{ + if ( dir == 0 ) + { + u8g2_draw_hline(u8g2, x, y, len); + } + else + { + u8g2_draw_vline(u8g2, x, y, len); + } +} + +#endif /* really fast version */ + +#ifdef U8G2_HVLINE_SPEED_OPTIMIZATION + +/* + x,y Upper left position of the line within the local buffer (not the display!) + len length of the line in pixel, len must not be 0 + dir 0: horizontal line (left to right) + 1: vertical line (top to bottom) + asumption: + all clipping done +*/ +static void u8g2_unsafe_draw_hv_line(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir) +{ + uint16_t offset; + uint8_t *ptr; + uint8_t bit_pos, mask; + + //assert(x >= u8g2->buf_x0); + assert(x < u8g2_GetU8x8(u8g2)->display_info->tile_width*8); + //assert(y >= u8g2->buf_y0); + assert(y < u8g2_GetU8x8(u8g2)->display_info->tile_height*8); + + /* bytes are vertical, lsb on top (y=0), msb at bottom (y=7) */ + bit_pos = y; /* overflow truncate is ok here... */ + bit_pos &= 7; /* ... because only the lowest 3 bits are needed */ + mask = 1; + mask <<= bit_pos; + + offset = y; /* y might be 8 or 16 bit, but we need 16 bit, so use a 16 bit variable */ + offset &= ~7; + offset *= u8g2_GetU8x8(u8g2)->display_info->tile_width; + ptr = u8g2->tile_buf_ptr; + ptr += offset; + ptr += x; + + if ( dir == 0 ) + { + if ( u8g2->draw_color != 0 ) + { + do + { + *ptr |= mask; + ptr++; + len--; + } while( len != 0 ); + } + else + { + mask = ~mask; + do + { + *ptr &= mask; + ptr++; + len--; + } while( len != 0 ); + } + } + else + { + do + { + if ( u8g2->draw_color != 0 ) + { + *ptr |= mask; + } + else + { + *ptr &= ~mask; + } + + bit_pos++; + bit_pos &= 7; + + len--; + + if ( bit_pos == 0 ) + { + ptr+=u8g2->width; + + /* another speed optimization, but requires about 60 bytes on AVR */ + /* + while( len >= 8 ) + { + if ( u8g2->draw_color != 0 ) + { + *ptr = 255; + } + else + { + *ptr = 0; + } + len -= 8; + ptr+=u8g2->width; + } + */ + + mask = 1; + } + else + { + mask <<= 1; + } + } while( len != 0 ); + } +} + + + +#else /* U8G2_HVLINE_SPEED_OPTIMIZATION */ + +/* + x,y position within the buffer +*/ +static void u8g2_draw_pixel(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y) +{ + uint16_t offset; + uint8_t *ptr; + uint8_t bit_pos, mask; + + //assert(x >= u8g2->buf_x0); + assert(x < u8g2_GetU8x8(u8g2)->display_info->tile_width*8); + //assert(y >= u8g2->buf_y0); + assert(y < u8g2_GetU8x8(u8g2)->display_info->tile_height*8); + + /* bytes are vertical, lsb on top (y=0), msb at bottom (y=7) */ + bit_pos = y; /* overflow truncate is ok here... */ + bit_pos &= 7; /* ... because only the lowest 3 bits are needed */ + mask = 1; + mask <<= bit_pos; + + offset = y; /* y might be 8 or 16 bit, but we need 16 bit, so use a 16 bit variable */ + offset &= ~7; + offset *= u8g2_GetU8x8(u8g2)->display_info->tile_width; + ptr = u8g2->tile_buf_ptr; + ptr += offset; + ptr += x; + + + if ( u8g2->draw_color != 0 ) + { + *ptr |= mask; + } + else + { + mask ^= 255; + *ptr &= mask; + } +} + +/* + x,y Upper left position of the line within the local buffer (not the display!) + len length of the line in pixel, len must not be 0 + dir 0: horizontal line (left to right) + 1: vertical line (top to bottom) + asumption: + all clipping done +*/ +static void u8g2_unsafe_draw_hv_line(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir) +{ + if ( dir == 0 ) + { + do + { + u8g2_draw_pixel(u8g2, x, y); + x++; + len--; + } while( len != 0 ); + } + else + { + do + { + u8g2_draw_pixel(u8g2, x, y); + y++; + len--; + } while( len != 0 ); + } +} + + + +#endif /* U8G2_HVLINE_SPEED_OPTIMIZATION */ + + + +#ifdef U8G2_WITH_CLIPPING + +/* + Description: + clip range from a (included) to b (excluded) agains c (included) to d (excluded) + Assumptions: + a <= b (this is checked and handled correctly) + c <= d (this is not checked) + will return 0 if there is no intersection and if a > b + + optimized clipping: c is set to 0 +*/ +//static uint8_t u8g2_clip_intersection(u8g2_uint_t *ap, u8g2_uint_t *bp, u8g2_uint_t c, u8g2_uint_t d) +static uint8_t u8g2_clip_intersection(u8g2_uint_t *ap, u8g2_uint_t *bp, u8g2_uint_t d) +{ + u8g2_uint_t a = *ap; + u8g2_uint_t b = *bp; + + /* handle the a>b case correctly. If code and time is critical, this could */ + /* be removed completly (be aware about memory curruption for wrong */ + /* arguments) or return 0 for a>b (will lead to skipped lines for wrong */ + /* arguments) */ + + /* removing the following if clause completly may lead to memory corruption of a>b */ + if ( a > b ) + { + /* replacing this if with a simple "return 0;" will not handle the case with negative a */ + if ( a < d ) + { + b = d; + b--; + *bp = b; + } + else + { + a = 0; + *ap = a; + } + } + + /* from now on, the asumption a <= b is ok */ + + if ( a >= d ) + return 0; + if ( b <= 0 ) // was b <= c, could be replaced with b == 0 + return 0; + //if ( a < c ) // never true with c == 0 + // *ap = c; + if ( b > d ) + *bp = d; + + return 1; +} + + + +/* + x,y Upper left position of the line + len length of the line in pixel, len must not be 0 + dir 0: horizontal line (left to right) + 1: vertical line (top to bottom) + This function first adjusts the y position to the local buffer. Then it + will clip the line and call u8g2_unsafe_draw_hv_line() + +*/ +static void u8g2_draw_hv_line_2dir(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir) +{ + u8g2_uint_t a; + register u8g2_uint_t w, h; + + y -= u8g2->tile_curr_row*8; + + h = u8g2->pixel_buf_height; + w = u8g2->pixel_buf_width; + + if ( dir == 0 ) + { + if ( y >= h ) + return; + a = x; + a += len; + if ( u8g2_clip_intersection(&x, &a, w) == 0 ) + return; + len = a; + len -= x; + } + else + { + if ( x >= w ) + return; + a = y; + a += len; + if ( u8g2_clip_intersection(&y, &a, h) == 0 ) + return; + len = a; + len -= y; + } + + u8g2_unsafe_draw_hv_line(u8g2, x, y, len, dir); +} + +#endif + +/* + x,y Upper left position of the line + len length of the line in pixel, len must not be 0 + dir 0: horizontal line (left to right) + 1: vertical line (top to bottom) + 2: horizontal line (right to left) + 3: vertical line (bottom to top) + + This function will remove directions 2 and 3. Instead 0 and 1 are used. + +*/ +void u8g2_draw_hv_line_4dir(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir) +{ +#ifdef U8G2_WITH_HVLINE_COUNT + u8g2->hv_cnt++; +#endif /* U8G2_WITH_HVLINE_COUNT */ + + if ( dir == 2 ) + { + x -= len; + x++; + } + else if ( dir == 3 ) + { + y -= len; + y++; + } + dir &= 1; +#ifdef U8G2_WITH_CLIPPING + u8g2_draw_hv_line_2dir(u8g2, x, y, len, dir); +#else + u8g2_unsafe_draw_hv_line(u8g2, x, y, len, dir); +#endif +} + +/* + This is the toplevel function for the hv line draw procedures. + This function should be called by the user. +*/ +void u8g2_DrawHVLine(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir) +{ + /* Make a call the the callback function. The callback may rotate the hv line */ + /* after rotation this will call u8g2_draw_hv_line_4dir() */ + if ( len != 0 ) + u8g2->cb->draw_l90(u8g2, x, y, len, dir); +} + diff --git a/u8g2/csrc/u8g2_intersection.c b/u8g2/csrc/u8g2_intersection.c new file mode 100644 index 00000000..db36784e --- /dev/null +++ b/u8g2/csrc/u8g2_intersection.c @@ -0,0 +1,84 @@ +/* + + u8g2_intersection.c + + code taken from u8g_clip.c + +*/ + +#include "u8g2.h" + +#ifdef __GNUC__ +#define U8G2_ALWAYS_INLINE __inline__ __attribute__((always_inline)) +#else +#define U8G2_ALWAYS_INLINE +#endif + + +#ifdef U8G2_WITH_INTERSECTION + + +/* + 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 + */ + + +//static uint8_t U8G2_ALWAYS_INLINE u8g2_is_intersection_decision_tree(u8g_uint_t a0, u8g_uint_t a1, u8g_uint_t v0, u8g_uint_t v1) +static uint8_t u8g2_is_intersection_decision_tree(u8g2_uint_t a0, u8g2_uint_t a1, u8g2_uint_t v0, u8g2_uint_t v1) +{ + if ( v0 <= a1 ) + { + if ( v1 >= a0 ) + { + return 1; + } + else + { + if ( v0 > v1 ) + { + return 1; + } + else + { + return 0; + } + } + } + else + { + if ( v1 >= a0 ) + { + if ( v0 > v1 ) + { + return 1; + } + else + { + return 0; + } + } + else + { + return 0; + } + } +} + + +uint8_t u8g2_IsIntersection(u8g2_t *u8g2, u8g2_uint_t x0, u8g2_uint_t y0, u8g2_uint_t x1, u8g2_uint_t y1) +{ + if ( u8g2_is_intersection_decision_tree(u8g2->user_y0, u8g2->user_y1, y0, y1) == 0 ) + return 0; + + return u8g2_is_intersection_decision_tree(u8g2->user_x0, u8g2->user_x1, x0, x1); +} + + +#endif /* U8G2_WITH_INTERSECTION */ + diff --git a/u8g2/csrc/u8g2_setup.c b/u8g2/csrc/u8g2_setup.c new file mode 100644 index 00000000..34b0600c --- /dev/null +++ b/u8g2/csrc/u8g2_setup.c @@ -0,0 +1,201 @@ +/* + + u8g2_setup.c + +*/ + +#include "u8g2.h" +#include + +/*============================================*/ + +void u8g2_Setup(u8g2_t *u8g2, uint8_t *buf, uint8_t tile_buf_height, const u8g2_cb_t *u8g2_cb) +{ + u8g2->tile_buf_ptr = buf; + u8g2->tile_buf_height = tile_buf_height; + + u8g2->tile_curr_row = 0; + u8g2->draw_color = 1; + + u8g2->cb = u8g2_cb; + u8g2->cb->update(u8g2); + +#ifdef U8G2_WITH_FONT_ROTATION + u8g2->font_decode.dir = 0; +#endif +} + + +/*============================================*/ +/* + update dimension: + calculate the following variables: + u8g2_uint_t buf_x0; left corner of the buffer + u8g2_uint_t buf_x1; right corner of the buffer (excluded) + u8g2_uint_t buf_y0; + u8g2_uint_t buf_y1; +*/ + +static void u8g2_update_dimension_common(u8g2_t *u8g2) +{ + u8g2_uint_t t; + + t = u8g2->tile_buf_height; + t *= 8; + u8g2->pixel_buf_height = t; + + t = u8g2_GetU8x8(u8g2)->display_info->tile_width; + t *= 8; + u8g2->pixel_buf_width = t; + + t = u8g2->tile_curr_row; + t *= 8; + u8g2->pixel_curr_row = t; + + t = u8g2->tile_buf_height; + /* handle the case, where the buffer is larger than the (remaining) part of the display */ + if ( t + u8g2->tile_curr_row > u8g2_GetU8x8(u8g2)->display_info->tile_height ) + t = u8g2_GetU8x8(u8g2)->display_info->tile_height - u8g2->tile_curr_row; + t *= 8; + + u8g2->buf_y0 = u8g2->pixel_curr_row; + u8g2->buf_y1 = u8g2->buf_y0; + u8g2->buf_y1 += t; + + u8g2->width = u8g2->pixel_buf_width; + t = u8g2_GetU8x8(u8g2)->display_info->tile_height; + t *= 8; + u8g2->height = t; +} + +void u8g2_update_dimension_r0(u8g2_t *u8g2) +{ + u8g2_update_dimension_common(u8g2); + + u8g2->user_x0 = 0; + u8g2->user_x1 = u8g2->pixel_buf_width; + + u8g2->user_y0 = u8g2->buf_y0; + u8g2->user_y1 = u8g2->buf_y1; + +// printf("x0=%d x1=%d y0=%d y1=%d\n", +// u8g2->user_x0, u8g2->user_x1, u8g2->user_y0, u8g2->user_y1); +} + +void u8g2_update_dimension_r1(u8g2_t *u8g2) +{ + u8g2_update_dimension_common(u8g2); + + u8g2->width = u8g2->height; + u8g2->height = u8g2->pixel_buf_width; + + u8g2->user_x0 = u8g2->buf_y0; + u8g2->user_x1 = u8g2->buf_y1; + + u8g2->user_y0 = 0; + u8g2->user_y1 = u8g2->pixel_buf_width; + +// printf("x0=%d x1=%d y0=%d y1=%d\n", +// u8g2->user_x0, u8g2->user_x1, u8g2->user_y0, u8g2->user_y1); +} + +void u8g2_update_dimension_r2(u8g2_t *u8g2) +{ + u8g2_update_dimension_common(u8g2); + + u8g2->user_x0 = 0; + u8g2->user_x1 = u8g2->pixel_buf_width; + + u8g2->user_y0 = u8g2->height - u8g2->buf_y1; + u8g2->user_y1 = u8g2->height - u8g2->buf_y0; + +// printf("x0=%d x1=%d y0=%d y1=%d\n", +// u8g2->user_x0, u8g2->user_x1, u8g2->user_y0, u8g2->user_y1); +} + +void u8g2_update_dimension_r3(u8g2_t *u8g2) +{ + u8g2_update_dimension_common(u8g2); + + u8g2->width = u8g2->height; + u8g2->height = u8g2->pixel_buf_width; + + u8g2->user_x0 = u8g2->height - u8g2->buf_y1; + u8g2->user_x1 = u8g2->height - u8g2->buf_y0; + + u8g2->user_y0 = 0; + u8g2->user_y1 = u8g2->pixel_buf_width; + +// printf("x0=%d x1=%d y0=%d y1=%d\n", +// u8g2->user_x0, u8g2->user_x1, u8g2->user_y0, u8g2->user_y1); +} + +/*============================================*/ +extern void u8g2_draw_hv_line_4dir(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir); + + +void u8g2_draw_l90_r0(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir) +{ + u8g2_draw_hv_line_4dir(u8g2, x, y, len, dir); +} + +void u8g2_draw_l90_r1(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir) +{ + u8g2_uint_t xx, yy; + + yy = x; + + xx = u8g2->height; + xx -= y; + xx--; + + dir ++; + dir &= 3; + u8g2_draw_hv_line_4dir(u8g2, xx, yy, len, dir); +} + +void u8g2_draw_l90_r2(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir) +{ + u8g2_uint_t xx, yy; + + yy = u8g2->height; + yy -= y; + yy--; + + xx = u8g2->width; + xx -= x; + xx--; + + dir +=2; + dir &= 3; + u8g2_draw_hv_line_4dir(u8g2, xx, yy, len, dir); +} + +void u8g2_draw_l90_r3(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir) +{ + u8g2_uint_t xx, yy; + + xx = y; + + yy = u8g2->height; + yy -= x; + yy--; + + dir +=3; + dir &= 3; + u8g2_draw_hv_line_4dir(u8g2, xx, yy, len, dir); +} + + + +/*============================================*/ +const u8g2_cb_t u8g2_cb_r0 = { u8g2_update_dimension_r0, u8g2_draw_l90_r0 }; +const u8g2_cb_t u8g2_cb_r1 = { u8g2_update_dimension_r1, u8g2_draw_l90_r1 }; +const u8g2_cb_t u8g2_cb_r2 = { u8g2_update_dimension_r2, u8g2_draw_l90_r2 }; +const u8g2_cb_t u8g2_cb_r3 = { u8g2_update_dimension_r3, u8g2_draw_l90_r3 }; + + + + + + \ No newline at end of file diff --git a/u8g2/csrc/u8x8.h b/u8g2/csrc/u8x8.h new file mode 100644 index 00000000..415691d3 --- /dev/null +++ b/u8g2/csrc/u8x8.h @@ -0,0 +1,468 @@ +/* + u8x8.h + + + + + U8glib has several layers. Each layer is implemented with a callback function. + This callback function handels the messages for the layer. + + The topmost level is the display layer. It includes the following messages: + + U8X8_MSG_DISPLAY_SETUP no communicaation with the display, setup memory ony + U8X8_MSG_DISPLAY_INIT + U8X8_MSG_DISPLAY_SET_FLIP_MODE + U8X8_MSG_DISPLAY_SET_POWER_SAVE + U8X8_MSG_DISPLAY_SET_CONTRAST + U8X8_MSG_DISPLAY_DRAW_TILE + + A display driver may decided to breakdown these messages to a lower level interface or + implement this functionality directly. + + + One layer is the Command/Arg/Data interface. It can be used by the display layer + to communicate with the display hardware. + This layer only deals with data, commands and arguments. D/C line is unknown. + U8X8_MSG_CAD_INIT + U8X8_MSG_CAD_SET_I2C_ADR + U8X8_MSG_CAD_SET_DEVICE + U8X8_MSG_CAD_START_TRANSFER + U8X8_MSG_CAD_SEND_CMD + U8X8_MSG_CAD_SEND_ARG + U8X8_MSG_CAD_SEND_DATA + U8X8_MSG_CAD_END_TRANSFER + + The byte interface is there to send 1 byte (8 bits) to the display hardware. + This layer depends on the hardware of a microcontroller, if a specific hardware + should be used (I2C or SPI). + If this interface is implemented via software, it may use the GPIO level for sending + bytes. + U8X8_MSG_BYTE_INIT + U8X8_MSG_BYTE_SEND 30 + U8X8_MSG_BYTE_SET_DC 31 + U8X8_MSG_BYTE_START_TRANSFER + U8X8_MSG_BYTE_END_TRANSFER + U8X8_MSG_BYTE_SET_I2C_ADR + U8X8_MSG_BYTE_SET_DEVICE + + GPIO and Delay + U8X8_MSG_GPIO_INIT + U8X8_MSG_DELAY_MILLI + U8X8_MSG_DELAY_10MICRO + U8X8_MSG_DELAY_100NANO + +*/ + +#ifndef _U8X8_H +#define _U8X8_H + +/*==========================================*/ +/* Global Defines */ + +/* Undefine this to remove u8x8_display_SetContrast function */ +#define U8X8_WITH_SET_CONTRAST + +/* Undefine this to remove u8x8_display_SetFlipMode function */ +#define U8X8_WITH_SET_FLIP_MODE + +/* Select 0 or 1 for the default flip mode. This is not affected by U8X8_WITH_FLIP_MODE */ +/* Note: Not all display types support a mirror functon for the frame buffer */ +#define U8X8_DEFAULT_FLIP_MODE 0 + +/*==========================================*/ +/* Includes */ + + +#include +#include + +#if defined(__GNUC__) && defined(__AVR__) +#include +#endif + +/*==========================================*/ +/* C++ compatible */ + +#ifdef __cplusplus +extern "C" { +#endif + + +/*==========================================*/ +/* U8G2 internal defines */ + + +#ifdef __GNUC__ +# define U8X8_NOINLINE __attribute__((noinline)) +#else +# define U8X8_NOINLINE +#endif + +#if defined(__GNUC__) && defined(__AVR__) +# define U8X8_SECTION(name) __attribute__ ((section (name))) +# define U8X8_FONT_SECTION(name) U8X8_SECTION(".progmem." name) +# define u8x8_pgm_read(adr) pgm_read_byte_near(adr) +#endif + +#ifndef U8X8_SECTION +# define U8X8_SECTION(name) __attribute__ ((section (name))) +# define U8X8_FONT_SECTION(name) +# define u8x8_pgm_read(adr) (*(const uint8_t *)(adr)) +#endif + +/*==========================================*/ +/* U8X8 typedefs and data structures */ + + +typedef struct u8x8_struct u8x8_t; +typedef struct u8x8_display_info_struct u8x8_display_info_t; +typedef struct u8x8_tile_struct u8x8_tile_t; + +typedef uint8_t (*u8x8_msg_cb)(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); + + +//struct u8x8_mcd_struct +//{ +// u8x8_msg_cb cb; /* current callback function */ +// u8x8_t *u8g2; /* pointer to the u8g2 parent to minimize the number of args */ +// u8x8_mcd_t *next; +//}; + +struct u8x8_tile_struct +{ + uint8_t *tile_ptr; /* pointer to one or more tiles */ + uint8_t cnt; /* number of tiles */ + uint8_t x_pos; /* tile x position */ + uint8_t y_pos; /* tile x position */ +}; + + +struct u8x8_display_info_struct +{ + /* == general == */ + + uint8_t chip_enable_level; /* UC1601: 0 */ + uint8_t chip_disable_level; /* opposite of chip_enable_level */ + + uint8_t post_chip_enable_wait_ns; /* UC1601: 5ns */ + uint8_t pre_chip_disable_wait_ns; /* UC1601: 5ns */ + uint8_t reset_pulse_width_ms; /* UC1601: 0.003ms --> 1ms */ + uint8_t post_reset_wait_ms; /* UC1601: 6ms */ + + + /* == SPI interface == */ + + /* after SDA has been applied, wait this much time for the SCK data takeover edge */ + /* if this is smaller than sck_pulse_width_ns, then use the value from sck_pulse_width_ns */ + uint8_t sda_setup_time_ns; /* UC1601: 12ns */ + /* the pulse width of the the clock signal, cycle time is twice this value */ + /* max freq is 1/(2*sck_pulse_width_ns) */ + uint8_t sck_pulse_width_ns; /* UC1601: 15ns */ + + /* data takeover edge: 0=falling edge, 1=rising edge*/ + /* initial default value for sck is low (0) for falling edge and high for rising edge */ + /* this means, default value is identical to sck_takeover_edge */ + uint8_t sck_takeover_edge; /* UC1601: rising edge (1) */ + + /* == I2C == */ + uint8_t i2c_bus_clock_100kHz; /* UC1601: 1000000000/275 = 37 *100k */ + + + /* == 8 bit interface == */ + + /* how long to wait after all data line are set */ + uint8_t data_setup_time_ns; /* UC1601: 30ns */ + /* write enable pulse width */ + uint8_t write_pulse_width_ns; /* UC1601: 40ns */ + + /* == layout == */ + uint8_t tile_width; + uint8_t tile_height; + + uint8_t default_x_offset; /* default x offset for the display */ +}; + +struct u8x8_struct +{ + const u8x8_display_info_t *display_info; + u8x8_msg_cb display_cb; + u8x8_msg_cb cad_cb; + u8x8_msg_cb byte_cb; + u8x8_msg_cb gpio_and_delay_cb; + const uint8_t *font; + uint8_t x_offset; /* copied from info struct, can be modified in flip mode */ +}; + + + +/*==========================================*/ + +/* helper functions */ +void u8x8_d_helper_display_setup(u8x8_t *u8x8, const u8x8_display_info_t *display_info); +void u8x8_d_helper_display_init(u8x8_t *u8g2); + +/* Display Interface */ + +/* + Name: U8X8_MSG_DISPLAY_SETUP + Args: None + Tasks: + 1) setup u8g2->display_info + copy u8g2->display_info->default_x_offset to u8g2->x_offset +*/ +#define U8X8_MSG_DISPLAY_SETUP 9 + +/* + Name: U8X8_MSG_DISPLAY_INIT + Args: None + Tasks: + + 2) put interface into default state: + execute u8x8_gpio_Init for port directions + execute u8x8_cad_Init for default port levels + 3) set CS status (not clear, may be done in cad/byte interface + 4) execute display reset (gpio interface) + 5) send setup sequence to display, do not activate display, disable "power save" will follow +*/ +#define U8X8_MSG_DISPLAY_INIT 10 + +/* + Name: U8X8_MSG_DISPLAY_SET_POWER_SAVE + Args: arg_int: 0: normal mode (RAM is visible on the display), 1: nothing is shown + Tasks: + Depending on arg_int, put the display into normal or power save mode. + Send the corresponding sequence to the display. + In power save mode, it must be possible to modify the RAM content. +*/ +#define U8X8_MSG_DISPLAY_SET_POWER_SAVE 11 + +/* + Name: U8X8_MSG_DISPLAY_SET_FLIP_MODE + Args: arg_int: 0: normal mode, 1: flipped HW screen (180 degree) + Tasks: + Reprogramms the display controller to rotate the display by + 180 degree (arg_int = 1) or not (arg_int = 0) + This may change u8g2->x_offset if the display is smaller than the controller ram + This message should only be supported if U8X8_WITH_FLIP_MODE is defined. +*/ +#define U8X8_MSG_DISPLAY_SET_FLIP_MODE 13 + +/* arg_int: 0..255 contrast value */ +#define U8X8_MSG_DISPLAY_SET_CONTRAST 14 + +/* + Name: U8X8_MSG_DISPLAY_DRAW_TILE + Args: + arg_int: How often to repeat this tile pattern + arg_ptr: pointer to u8x8_tile_t + uint8_t *tile_ptr; pointer to one or more tiles (number is "cnt") + uint8_t cnt; number of tiles + uint8_t x_pos; first tile x position + uint8_t y_pos; first tile y position + Tasks: + One tile has exactly 8 bytes (8x8 pixel monochrome bitmap). + The lowest bit of the first byte is the upper left corner + The highest bit of the first byte is the lower left corner + The lowest bit of the last byte is the upper right corner + The highest bit of the last byte is the lower left corner + "tile_ptr" is the address of a memory area, which contains + one or more tiles. "cnt" will contain the exact number of + tiles in the memory areay. The size of the memory area is 8*cnt; + Multiple tiles in the memory area form a horizontal sequence, this + means the first tile is drawn at x_pos/y_pos, the second tile is drawn + at x_pos+1/y_pos, third at x_pos+2/y_pos. + "arg_int" tells how often the tile sequence should be repeated: + For example if "cnt" is two and tile_ptr points to tiles A and B, + then for arg_int = 3, the following tile sequence will be drawn: + ABABAB. Totally, cnt*arg_int tiles will be drawn. + +*/ +#define U8X8_MSG_DISPLAY_DRAW_TILE 15 + +/* arg_ptr: layout struct */ +//#define U8X8_MSG_DISPLAY_GET_LAYOUT 16 + +/* u8x8_display.c */ +uint8_t u8x8_display_DrawTile(u8x8_t *u8x8, uint8_t x, uint8_t y, uint8_t cnt, uint8_t *tile_ptr); + +/* setup display memory structures */ +void u8x8_display_Setup(u8x8_t *u8x8); +/* Init display, but keep display in power save mode. Usually this command must be followed by u8x8_display_SetPowerSave() */ +void u8x8_display_Init(u8x8_t *u8x8); +/* wake up display from power save mode */ +void u8x8_display_SetPowerSave(u8x8_t *u8x8, uint8_t is_enable); +void u8x8_display_SetFlipMode(u8x8_t *u8x8, uint8_t mode); +void u8x8_display_SetContrast(u8x8_t *u8x8, uint8_t value); +void u8x8_display_ClearScreen(u8x8_t *u8x8); + + + +/*==========================================*/ +/* Command Arg Data (CAD) Interface */ + +/* + U8X8_MSG_CAD_INIT + no args + call U8X8_MSG_BYTE_INIT + setup default values for the I/O lines +*/ +#define U8X8_MSG_CAD_INIT 20 + + +#define U8X8_MSG_CAD_SEND_CMD 21 +/* arg_int: cmd byte */ +#define U8X8_MSG_CAD_SEND_ARG 22 +/* arg_int: arg byte */ +#define U8X8_MSG_CAD_SEND_DATA 23 +/* arg_int: expected cs level after processing this msg */ +#define U8X8_MSG_CAD_START_TRANSFER 24 +/* arg_int: expected cs level after processing this msg */ +#define U8X8_MSG_CAD_END_TRANSFER 25 +/* arg_int = 0: disable chip, arg_int = 1: enable chip */ +#define U8X8_MSG_CAD_SET_I2C_ADR 26 +#define U8X8_MSG_CAD_SET_DEVICE 27 + + + +/* u8g_cad.c */ + +#define u8x8_cad_Init(u8x8) ((u8x8)->cad_cb((u8x8), U8X8_MSG_CAD_INIT, 0, NULL )) + +uint8_t u8x8_cad_SendCmd(u8x8_t *u8x8, uint8_t cmd) U8X8_NOINLINE; +uint8_t u8x8_cad_SendArg(u8x8_t *u8x8, uint8_t arg) U8X8_NOINLINE; +uint8_t u8x8_cad_SendData(u8x8_t *u8x8, uint8_t cnt, uint8_t *data) U8X8_NOINLINE; +uint8_t u8x8_cad_StartTransfer(u8x8_t *u8x8) U8X8_NOINLINE; +uint8_t u8x8_cad_EndTransfer(u8x8_t *u8x8) U8X8_NOINLINE; + +/* +#define U8X8_C(c0) (0x04), (c0) +#define U8X8_CA(c0,a0) (0x05), (c0), (a0) +#define U8X8_CAA(c0,a0,a1) (0x06), (c0), (a0), (a1) +#define U8X8_DATA() (0x10) +#define U8X8_D1(d0) (0x11), (d0) +*/ + +#define U8X8_C(c0) (U8X8_MSG_CAD_SEND_CMD), (c0) +#define U8X8_CA(c0,a0) (U8X8_MSG_CAD_SEND_CMD), (c0), (U8X8_MSG_CAD_SEND_ARG), (a0) +#define U8X8_CAA(c0,a0,a1) (U8X8_MSG_CAD_SEND_CMD), (c0), (U8X8_MSG_CAD_SEND_ARG), (a0), (U8X8_MSG_CAD_SEND_ARG), (a1) +#define U8X8_D1(d0) (U8X8_MSG_CAD_SEND_DATA), (d0) + + +#define U8X8_START_TRANSFER() (U8X8_MSG_CAD_START_TRANSFER) +#define U8X8_END_TRANSFER() (U8X8_MSG_CAD_END_TRANSFER) +#define U8X8_DLY(m) (0xfe),(m) +#define U8X8_END() (0xff) + +void u8x8_cad_SendSequence(u8x8_t *u8x8, uint8_t const *data); +uint8_t u8x8_cad_110(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); +uint8_t u8x8_cad_001(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); + + +/*==========================================*/ +/* Byte Interface */ + +#define U8X8_MSG_BYTE_INIT U8X8_MSG_CAD_INIT +#define U8X8_MSG_BYTE_SET_DC 32 + +#define U8X8_MSG_BYTE_SEND U8X8_MSG_CAD_SEND_DATA + +#define U8X8_MSG_BYTE_START_TRANSFER U8X8_MSG_CAD_START_TRANSFER +#define U8X8_MSG_BYTE_END_TRANSFER U8X8_MSG_CAD_END_TRANSFER + +#define U8X8_MSG_BYTE_SET_I2C_ADR U8X8_MSG_CAD_SET_I2C_ADR +#define U8X8_MSG_BYTE_SET_DEVICE U8X8_MSG_CAD_SET_DEVICE + + +uint8_t u8x8_byte_SetDC(u8x8_t *u8x8, uint8_t dc) U8X8_NOINLINE; +uint8_t u8x8_byte_SendByte(u8x8_t *u8x8, uint8_t byte) U8X8_NOINLINE; +uint8_t u8x8_byte_SendBytes(u8x8_t *u8x8, uint8_t cnt, uint8_t *data) U8X8_NOINLINE; + +uint8_t u8x8_byte_8bit_sw_spi(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); + + +/*==========================================*/ +/* GPIO Interface */ + + +/* + U8X8_MSG_GPIO_AND_DELAY_INIT + no args + setup port directions, do not set IO levels, this is done with BYTE/CAD_INIT +*/ +#define U8X8_MSG_GPIO_AND_DELAY_INIT 40 + +/* arg_int: milliseconds */ +#define U8X8_MSG_DELAY_MILLI 41 + +#define U8X8_MSG_DELAY_10MICRO 42 +#define U8X8_MSG_DELAY_100NANO 43 +#define U8X8_MSG_DELAY_NANO 44 + +#define U8X8_MSG_GPIO_DC 45 +#define U8X8_MSG_GPIO_CS 46 +#define U8X8_MSG_GPIO_RESET 47 +#define U8X8_MSG_GPIO_CLOCK 48 +#define U8X8_MSG_GPIO_DATA 49 + +#define u8x8_gpio_Init(u8x8) ((u8x8)->gpio_and_delay_cb((u8x8), U8X8_MSG_GPIO_AND_DELAY_INIT, 0, NULL )) + +/* +#define u8x8_gpio_SetDC(u8x8, v) ((u8x8)->gpio_and_delay_cb((u8x8), U8X8_MSG_GPIO_DC, (v), NULL )) +#define u8x8_gpio_SetCS(u8x8, v) ((u8x8)->gpio_and_delay_cb((u8x8), U8X8_MSG_GPIO_CS, (v), NULL )) +#define u8x8_gpio_SetReset(u8x8, v) ((u8x8)->gpio_and_delay_cb((u8x8), U8X8_MSG_GPIO_RESET, (v), NULL )) +*/ + +#define u8x8_gpio_SetDC(u8x8, v) u8x8_gpio_call(u8x8, U8X8_MSG_GPIO_DC, (v)) +#define u8x8_gpio_SetCS(u8x8, v) u8x8_gpio_call(u8x8, U8X8_MSG_GPIO_CS, (v)) +#define u8x8_gpio_SetReset(u8x8, v) u8x8_gpio_call(u8x8, U8X8_MSG_GPIO_CS, (v)) +#define u8x8_gpio_SetClock(u8x8, v) u8x8_gpio_call(u8x8, U8X8_MSG_GPIO_CLOCK, (v)) +#define u8x8_gpio_SetData(u8x8, v) u8x8_gpio_call(u8x8, U8X8_MSG_GPIO_DATA, (v)) + +void u8x8_gpio_call(u8x8_t *u8x8, uint8_t msg, uint8_t arg) U8X8_NOINLINE; + +#define u8x8_gpio_Delay(u8x8, msg, dly) u8x8_gpio_call((u8x8), (msg), (dly)) +//void u8x8_gpio_Delay(u8x8_t *u8x8, uint8_t msg, uint8_t dly) U8X8_NOINLINE; + + +/*==========================================*/ +/* u8x8_setup.c */ +void u8x8_SetupDefaults(u8x8_t *u8x8); + + +/*==========================================*/ +/* u8x8_d_stdio.c */ +void u8x8_SetupStdio(u8x8_t *u8x8); + +/*==========================================*/ +/* u8x8_d_sdl_128x64.c */ +void u8x8_Setup_SDL_128x64(u8x8_t *u8x8); +int u8g_sdl_get_key(void); + +/*==========================================*/ +/* u8x8_d_tga.c */ +void u8x8_Setup_TGA_DESC(u8x8_t *u8x8); +void u8x8_Setup_TGA_LCD(u8x8_t *u8x8); +void tga_save(const char *name); + +/*==========================================*/ +/* u8x8_d_uc1701_dogs102.c */ +uint8_t u8x8_d_uc1701_dogs102(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); + +/*==========================================*/ +/* u8x8_d_ssd1306_128x64_noname.c */ +uint8_t u8x8_d_ssd1306_128x64_noname(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); + +/*==========================================*/ +/* u8x8_8x8.c */ +void u8x8_Set8x8Font(u8x8_t *u8x8, const uint8_t *font_8x8); +void u8x8_Draw8x8Glyph(u8x8_t *u8x8, uint8_t x, uint8_t y, uint8_t encoding); +void u8x8_Draw8x8String(u8x8_t *u8x8, uint8_t x, uint8_t y, const char *s); + + +#ifdef __cplusplus +} +#endif + + +#endif /* _U8X8_H */ + diff --git a/u8g2/csrc/u8x8_8x8.c b/u8g2/csrc/u8x8_8x8.c new file mode 100644 index 00000000..fd53d8c2 --- /dev/null +++ b/u8g2/csrc/u8x8_8x8.c @@ -0,0 +1,55 @@ +/* + + u8x8_8x8.c + + font procedures, directly interfaces display procedures + +*/ + +#include "u8x8.h" + +void u8x8_Set8x8Font(u8x8_t *u8x8, const uint8_t *font_8x8) +{ + u8x8->font = font_8x8; +} + +void u8x8_Draw8x8Glyph(u8x8_t *u8x8, uint8_t x, uint8_t y, uint8_t encoding) +{ + uint8_t first, last, i; + uint8_t buf[8]; + uint16_t offset; + first = u8x8_pgm_read(u8x8->font+0); + last = u8x8_pgm_read(u8x8->font+1); + + if ( first <= encoding && encoding <= last ) + { + offset = encoding; + offset -= first; + offset *= 8; + offset +=2; + for( i = 0; i < 8; i++ ) + { + buf[i] = u8x8_pgm_read(u8x8->font+offset); + offset++; + } + } + else + { + for( i = 0; i < 8; i++ ) + { + buf[i] = 0; + } + } + u8x8_display_DrawTile(u8x8, x, y, 1, buf); +} + +void u8x8_Draw8x8String(u8x8_t *u8x8, uint8_t x, uint8_t y, const char *s) +{ + while( *s != '\0' ) + { + u8x8_Draw8x8Glyph(u8x8, x, y, (uint8_t)*s); + s++; + x++; + } +} + diff --git a/u8g2/csrc/u8x8_byte.c b/u8g2/csrc/u8x8_byte.c new file mode 100644 index 00000000..37ea230c --- /dev/null +++ b/u8g2/csrc/u8x8_byte.c @@ -0,0 +1,110 @@ +/* + + u8x8_byte.c + +*/ + +#include "u8x8.h" + +uint8_t u8x8_byte_SetDC(u8x8_t *u8x8, uint8_t dc) +{ + return u8x8->byte_cb(u8x8, U8X8_MSG_BYTE_SET_DC, dc, NULL); +} + +uint8_t u8x8_byte_SendBytes(u8x8_t *u8x8, uint8_t cnt, uint8_t *data) +{ + return u8x8->byte_cb(u8x8, U8X8_MSG_BYTE_SEND, cnt, (void *)data); +} + +uint8_t u8x8_byte_SendByte(u8x8_t *u8x8, uint8_t byte) +{ + return u8x8_byte_SendBytes(u8x8, 1, &byte); +} + + + +/* + Uses: + u8x8->display_info->sda_setup_time_ns + u8x8->display_info->sck_pulse_width_ns + u8x8->display_info->sck_takeover_edge + u8x8->display_info->chip_disable_level + u8x8->display_info->chip_enable_level + u8x8->display_info->post_chip_enable_wait_ns + u8x8->display_info->pre_chip_disable_wait_ns + Calls to GPIO and DELAY: + U8X8_MSG_DELAY_NANO + U8X8_MSG_GPIO_DC + U8X8_MSG_GPIO_CS + U8X8_MSG_GPIO_CLOCK + U8X8_MSG_GPIO_DATA + Handles: + U8X8_MSG_BYTE_INIT + U8X8_MSG_BYTE_SEND + U8X8_MSG_BYTE_SET_DC + U8X8_MSG_BYTE_START_TRANSFER + U8X8_MSG_BYTE_END_TRANSFER + U8X8_MSG_BYTE_SET_I2C_ADR (ignored) + U8X8_MSG_BYTE_SET_DEVICE (ignored) +*/ +uint8_t u8x8_byte_8bit_sw_spi(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) +{ + uint8_t i, b; + uint8_t *data; + uint8_t takeover_edge = u8x8->display_info->sck_takeover_edge; + uint8_t not_takeover_edge = 1 - takeover_edge; + + switch(msg) + { + case U8X8_MSG_BYTE_SEND: + data = (uint8_t *)arg_ptr; + while( arg_int > 0 ) + { + b = *data; + data++; + arg_int--; + for( i = 0; i < 8; i++ ) + { + if ( b & 128 ) + u8x8_gpio_SetData(u8x8, 1); + else + u8x8_gpio_SetData(u8x8, 0); + b <<= 1; + + u8x8_gpio_SetClock(u8x8, not_takeover_edge); + u8x8_gpio_Delay(u8x8, U8X8_MSG_DELAY_NANO, u8x8->display_info->sda_setup_time_ns); + u8x8_gpio_SetClock(u8x8, takeover_edge); + u8x8_gpio_Delay(u8x8, U8X8_MSG_DELAY_NANO, u8x8->display_info->sck_pulse_width_ns); + } + } + break; + + case U8X8_MSG_BYTE_INIT: + /* disable chipselect */ + u8x8_gpio_SetCS(u8x8, u8x8->display_info->chip_disable_level); + /* no wait required here */ + + /* for SPI: setup correct level of the clock signal */ + u8x8_gpio_SetClock(u8x8, u8x8->display_info->sck_takeover_edge); + break; + case U8X8_MSG_BYTE_SET_DC: + u8x8_gpio_SetDC(u8x8, arg_int); + break; + case U8X8_MSG_BYTE_START_TRANSFER: + u8x8_gpio_SetCS(u8x8, u8x8->display_info->chip_enable_level); + u8x8->gpio_and_delay_cb(u8x8, U8X8_MSG_DELAY_NANO, u8x8->display_info->post_chip_enable_wait_ns, NULL); + break; + case U8X8_MSG_BYTE_END_TRANSFER: + u8x8->gpio_and_delay_cb(u8x8, U8X8_MSG_DELAY_NANO, u8x8->display_info->pre_chip_disable_wait_ns, NULL); + u8x8_gpio_SetCS(u8x8, u8x8->display_info->chip_disable_level); + break; + case U8X8_MSG_BYTE_SET_I2C_ADR: + break; + case U8X8_MSG_BYTE_SET_DEVICE: + break; + default: + return 0; + } + return 1; +} + diff --git a/u8g2/csrc/u8x8_cad.c b/u8g2/csrc/u8x8_cad.c new file mode 100644 index 00000000..048fe367 --- /dev/null +++ b/u8g2/csrc/u8x8_cad.c @@ -0,0 +1,202 @@ +/* + + u8x8_cad.c + + "command arg data" interface to the graphics controller + + The following sequence must be used for any data, which is set to the display: + + + uint8_t u8x8_cad_StartTransfer(u8x8_t *u8x8) + + any of the following calls + uint8_t u8x8_cad_SendCmd(u8x8_t *u8x8, uint8_t cmd) + uint8_t u8x8_cad_SendArg(u8x8_t *u8x8, uint8_t arg) + uint8_t u8x8_cad_SendData(u8x8_t *u8x8, uint8_t cnt, uint8_t *data) + + uint8_t u8x8_cad_EndTransfer(u8x8_t *u8x8) + + + +*/ +/* +uint8_t u8x8_cad_template(u8x8_t *u8x8, uint8_t msg, uint16_t arg_int, void *arg_ptr) +{ + uint8_t i; + + switch(msg) + { + case U8X8_MSG_CAD_SEND_CMD: + u8x8_mcd_byte_SetDC(mcd->next, 1); + u8x8_mcd_byte_Send(mcd->next, arg_int); + break; + case U8X8_MSG_CAD_SEND_ARG: + u8x8_mcd_byte_SetDC(mcd->next, 1); + u8x8_mcd_byte_Send(mcd->next, arg_int); + break; + case U8X8_MSG_CAD_SEND_DATA: + u8x8_mcd_byte_SetDC(mcd->next, 0); + for( i = 0; i < 8; i++ ) + u8x8_mcd_byte_Send(mcd->next, ((uint8_t *)arg_ptr)[i]); + break; + case U8X8_MSG_CAD_RESET: + return mcd->next->cb(mcd->next, msg, arg_int, arg_ptr); + case U8X8_MSG_CAD_START_TRANSFER: + return mcd->next->cb(mcd->next, msg, arg_int, arg_ptr); + case U8X8_MSG_CAD_END_TRANSFER: + return mcd->next->cb(mcd->next, msg, arg_int, arg_ptr); + case U8X8_MSG_CAD_SET_I2C_ADR: + return mcd->next->cb(mcd->next, msg, arg_int, arg_ptr); + case U8X8_MSG_CAD_SET_DEVICE: + return mcd->next->cb(mcd->next, msg, arg_int, arg_ptr); + default: + break; + } + return 1; +} + +*/ + +#include "u8x8.h" + +uint8_t u8x8_cad_SendCmd(u8x8_t *u8x8, uint8_t cmd) +{ + return u8x8->cad_cb(u8x8, U8X8_MSG_CAD_SEND_CMD, cmd, NULL); +} + +uint8_t u8x8_cad_SendArg(u8x8_t *u8x8, uint8_t arg) +{ + return u8x8->cad_cb(u8x8, U8X8_MSG_CAD_SEND_ARG, arg, NULL); +} + +uint8_t u8x8_cad_SendData(u8x8_t *u8x8, uint8_t cnt, uint8_t *data) +{ + return u8x8->cad_cb(u8x8, U8X8_MSG_CAD_SEND_DATA, cnt, data); +} + +uint8_t u8x8_cad_StartTransfer(u8x8_t *u8x8) +{ + return u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 0, NULL); +} + +uint8_t u8x8_cad_EndTransfer(u8x8_t *u8x8) +{ + return u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 0, NULL); +} + +/* + 0000ccaa command arg combination, aa = no of args, cc = no of commands + 0001dddd data sequence + 11110000 CS Off + 11110001 CS On + 11111110 xxxxxxxx delay in millis + 11111111 End of sequence + +*/ + +void u8x8_cad_SendSequence(u8x8_t *u8x8, uint8_t const *data) +{ + uint8_t cmd; + uint8_t v; + + for(;;) + { + cmd = *data; + data++; + switch( cmd ) + { + case U8X8_MSG_CAD_SEND_CMD: + case U8X8_MSG_CAD_SEND_ARG: + v = *data; + u8x8->cad_cb(u8x8, cmd, v, NULL); + data++; + break; + case U8X8_MSG_CAD_SEND_DATA: + v = *data; + u8x8_cad_SendData(u8x8, 1, &v); + data++; + break; + case U8X8_MSG_CAD_START_TRANSFER: + case U8X8_MSG_CAD_END_TRANSFER: + u8x8->cad_cb(u8x8, cmd, 0, NULL); + break; + case 0x0fe: + v = *data; + u8x8_gpio_Delay(u8x8, U8X8_MSG_DELAY_MILLI, v); + data++; + break; + default: + return; + } + } +} + + +/* + convert to bytes by using + dc = 1 for commands and args and + dc = 0 for data +*/ +uint8_t u8x8_cad_110(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) +{ + switch(msg) + { + case U8X8_MSG_CAD_SEND_CMD: + u8x8_byte_SetDC(u8x8, 1); + u8x8_byte_SendByte(u8x8, arg_int); + break; + case U8X8_MSG_CAD_SEND_ARG: + u8x8_byte_SetDC(u8x8, 1); + u8x8_byte_SendByte(u8x8, arg_int); + break; + case U8X8_MSG_CAD_SEND_DATA: + u8x8_byte_SetDC(u8x8, 0); + //u8x8_byte_SendBytes(u8x8, arg_int, arg_ptr); + //break; + /* fall through */ + case U8X8_MSG_CAD_INIT: + case U8X8_MSG_CAD_START_TRANSFER: + case U8X8_MSG_CAD_END_TRANSFER: + case U8X8_MSG_CAD_SET_I2C_ADR: + case U8X8_MSG_CAD_SET_DEVICE: + return u8x8->byte_cb(u8x8, msg, arg_int, arg_ptr); + default: + return 0; + } + return 1; +} + +/* + convert to bytes by using + dc = 0 for commands and args and + dc = 1 for data +*/ +uint8_t u8x8_cad_001(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) +{ + switch(msg) + { + case U8X8_MSG_CAD_SEND_CMD: + u8x8_byte_SetDC(u8x8, 0); + u8x8_byte_SendByte(u8x8, arg_int); + break; + case U8X8_MSG_CAD_SEND_ARG: + u8x8_byte_SetDC(u8x8, 0); + u8x8_byte_SendByte(u8x8, arg_int); + break; + case U8X8_MSG_CAD_SEND_DATA: + u8x8_byte_SetDC(u8x8, 1); + //u8x8_byte_SendBytes(u8x8, arg_int, arg_ptr); + //break; + /* fall through */ + case U8X8_MSG_CAD_INIT: + case U8X8_MSG_CAD_START_TRANSFER: + case U8X8_MSG_CAD_END_TRANSFER: + case U8X8_MSG_CAD_SET_I2C_ADR: + case U8X8_MSG_CAD_SET_DEVICE: + return u8x8->byte_cb(u8x8, msg, arg_int, arg_ptr); + default: + return 0; + } + return 1; +} + diff --git a/u8g2/csrc/u8x8_d_ssd1306_128x64_noname.c b/u8g2/csrc/u8x8_d_ssd1306_128x64_noname.c new file mode 100644 index 00000000..90d70b39 --- /dev/null +++ b/u8g2/csrc/u8x8_d_ssd1306_128x64_noname.c @@ -0,0 +1,161 @@ + +#include "u8x8.h" + + + + +static const uint8_t u8x8_d_ssd1306_128x64_noname_init_seq[] = { + + U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ + + + U8X8_C(0x0ae), /* display off */ + U8X8_CA(0x0d5, 0x080), /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */ + U8X8_CA(0x0a8, 0x03f), /* multiplex ratio */ + U8X8_CA(0x0d3, 0x000), /* display offset */ + U8X8_C(0x040), /* set display start line to 0 */ + U8X8_CA(0x08d, 0x014), /* [2] charge pump setting (p62): 0x014 enable, 0x010 disable */ + U8X8_CA(0x020, 0x000), /* page addressing mode */ + +#if U8X8_DEFAULT_FLIP_MODE == 0 + U8X8_C(0x0a1), /* segment remap a0/a1*/ + U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */ +#else + U8X8_C(0x0a0), /* segment remap a0/a1*/ + U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */ +#endif + + U8X8_CA(0x0da, 0x012), /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */ + U8X8_CA(0x081, 0x0cf), /* [2] set contrast control */ + U8X8_CA(0x0d9, 0x0f1), /* [2] pre-charge period 0x022/f1*/ + U8X8_CA(0x0db, 0x040), /* vcomh deselect level */ + + U8X8_C(0x02e), /* Deactivate scroll */ + U8X8_C(0x0a4), /* output ram to display */ + U8X8_C(0x0a6), /* none inverted normal display mode */ + + U8X8_END_TRANSFER(), /* disable chip */ + U8X8_END() /* end of sequence */ +}; + +static const uint8_t u8x8_d_ssd1306_128x64_noname_powersave0_seq[] = { + U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ + U8X8_C(0x0af), /* display on */ + U8X8_END_TRANSFER(), /* disable chip */ + U8X8_END() /* end of sequence */ +}; + +static const uint8_t u8x8_d_ssd1306_128x64_noname_powersave1_seq[] = { + U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ + U8X8_C(0x0ae), /* display off */ + U8X8_END_TRANSFER(), /* disable chip */ + U8X8_END() /* end of sequence */ +}; + +#ifdef U8X8_WITH_SET_FLIP_MODE +static const uint8_t u8x8_d_ssd1306_128x64_noname_flip0_seq[] = { + U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ + U8X8_C(0x0a1), /* segment remap a0/a1*/ + U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */ + U8X8_END_TRANSFER(), /* disable chip */ + U8X8_END() /* end of sequence */ +}; + +static const uint8_t u8x8_d_ssd1306_128x64_noname_flip1_seq[] = { + U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ + U8X8_C(0x0a0), /* segment remap a0/a1*/ + U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */ + U8X8_END_TRANSFER(), /* disable chip */ + U8X8_END() /* end of sequence */ +}; +#endif + +static const u8x8_display_info_t u8x8_ssd1306_128x64_noname_display_info = +{ + /* chip_enable_level = */ 0, + /* chip_disable_level = */ 1, + + /* post_chip_enable_wait_ns = */ 20, + /* pre_chip_disable_wait_ns = */ 10, + /* reset_pulse_width_ms = */ 100, /* SSD1306: 3 us */ + /* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */ + /* sda_setup_time_ns = */ 50, /* SSD1306: 15ns, but cycle time is 100ns, so use 100/2 */ + /* sck_pulse_width_ns = */ 50, /* SSD1306: 20ns, but cycle time is 100ns, so use 100/2 */ + /* sck_takeover_edge = */ 1, /* rising edge */ + /* i2c_bus_clock_100kHz = */ 4, + /* data_setup_time_ns = */ 40, + /* write_pulse_width_ns = */ 150, /* SSD1306: cycle time is 300ns, so use 300/2 = 150 */ + /* tile_width = */ 16, + /* tile_hight = */ 8, + /* default_x_offset = */ 0 +}; + +uint8_t u8x8_d_ssd1306_128x64_noname(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) +{ + uint8_t x, c; + uint8_t *ptr; + switch(msg) + { + case U8X8_MSG_DISPLAY_SETUP: + u8x8_d_helper_display_setup(u8x8, &u8x8_ssd1306_128x64_noname_display_info); + break; + case U8X8_MSG_DISPLAY_INIT: + u8x8_d_helper_display_init(u8x8); + u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_128x64_noname_init_seq); + break; + case U8X8_MSG_DISPLAY_SET_POWER_SAVE: + if ( arg_int == 0 ) + u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_128x64_noname_powersave0_seq); + else + u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_128x64_noname_powersave1_seq); + break; +#ifdef U8X8_WITH_SET_FLIP_MODE + case U8X8_MSG_DISPLAY_SET_FLIP_MODE: + if ( arg_int == 0 ) + u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_128x64_noname_flip0_seq); + else + u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_128x64_noname_flip1_seq); + break; +#endif +#ifdef U8X8_WITH_SET_CONTRAST + case U8X8_MSG_DISPLAY_SET_CONTRAST: + u8x8_cad_StartTransfer(u8x8); + u8x8_cad_SendCmd(u8x8, 0x081 ); + u8x8_cad_SendArg(u8x8, arg_int ); /* ssd1306 has range from 0 to 255 */ + u8x8_cad_EndTransfer(u8x8); + break; +#endif + case U8X8_MSG_DISPLAY_DRAW_TILE: + u8x8_cad_StartTransfer(u8x8); + x = ((u8x8_tile_t *)arg_ptr)->x_pos; + x *= 8; + x += u8x8->x_offset; + u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) ); + u8x8_cad_SendCmd(u8x8, 0x000 | ((x&15))); + u8x8_cad_SendCmd(u8x8, 0x0b0 | (((u8x8_tile_t *)arg_ptr)->y_pos)); + + do + { + c = ((u8x8_tile_t *)arg_ptr)->cnt; + ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr; + u8x8_cad_SendData(u8x8, c*8, ptr); /* note: SendData can not handle more than 255 bytes */ + /* + do + { + u8x8_cad_SendData(u8x8, 8, ptr); + ptr += 8; + c--; + } while( c > 0 ); + */ + arg_int--; + } while( arg_int > 0 ); + + u8x8_cad_EndTransfer(u8x8); + break; + default: + return 0; + } + return 1; +} + + diff --git a/u8g2/csrc/u8x8_d_stdio.c b/u8g2/csrc/u8x8_d_stdio.c new file mode 100644 index 00000000..4da80010 --- /dev/null +++ b/u8g2/csrc/u8x8_d_stdio.c @@ -0,0 +1,67 @@ + +#include "u8x8.h" + +#include + +#define W 8 +#define H 2 + +uint8_t bitmap[W*H*8]; + +void bitmap_place_tile(uint8_t x, uint8_t y, uint8_t *tile) +{ + uint8_t i; + for(i = 0; i < 8; i++ ) + bitmap[x*8+y*W*8+i] = tile[i]; +} + +void bitmap_show(void) +{ + int x, y; + for( y = 0; y < H*8; y++ ) + { + for( x = 0; x < W*8; x++ ) + { + if ( (bitmap[x+(y/8)*W*8] & (1<<((y&7)))) != 0 ) + { + printf("*"); + } + else + { + printf("."); + } + } + printf("\n"); + } +} + + +uint8_t u8x8_d_stdio(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) +{ + switch(msg) + { + case U8X8_MSG_DISPLAY_INIT: + break; + case U8X8_MSG_DISPLAY_SET_POWER_SAVE: + if ( arg_int == 0 ) + bitmap_show(); + break; + case U8X8_MSG_DISPLAY_SET_CONTRAST: + break; + case U8X8_MSG_DISPLAY_DRAW_TILE: + bitmap_place_tile(((u8x8_tile_t *)arg_ptr)->x_pos, ((u8x8_tile_t *)arg_ptr)->y_pos, ((u8x8_tile_t *)arg_ptr)->tile_ptr); + break; + default: + break; + } + return 1; +} + + + +void u8x8_SetupStdio(u8x8_t *u8x8) +{ + u8x8_SetupDefaults(u8x8); + u8x8->display_cb = u8x8_d_stdio; +} + diff --git a/u8g2/csrc/u8x8_d_uc1701_dogs102.c b/u8g2/csrc/u8x8_d_uc1701_dogs102.c new file mode 100644 index 00000000..524c70e3 --- /dev/null +++ b/u8g2/csrc/u8x8_d_uc1701_dogs102.c @@ -0,0 +1,160 @@ + +#include "u8x8.h" + + + + +static const uint8_t u8x8_d_uc1701_dogs102_init_seq[] = { + + U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ + + U8X8_C(0x0e2), /* soft reset */ + U8X8_C(0x0ae), /* display off */ + U8X8_C(0x040), /* set display start line to 0 */ + +#if U8X8_DEFAULT_FLIP_MODE == 0 + U8X8_C(0x0a1), /* ADC set to reverse */ + U8X8_C(0x0c0), /* common output mode */ +#else + U8X8_C(0x0a0), /* ADC set to reverse */ + U8X8_C(0x0c8), /* common output mode */ +#endif + + U8X8_C(0x0a6), /* display normal, bit val 0: LCD pixel off. */ + U8X8_C(0x0a2), /* LCD bias 1/9 */ + U8X8_C(0x02f), /* all power control circuits on */ + U8X8_C(0x027), /* regulator, booster and follower */ + U8X8_CA(0x081, 0x00e), /* set contrast, contrast value, EA default: 0x010, previous value for S102: 0x0e */ + U8X8_C(0x0fa), /* Set Temp compensation */ + U8X8_C(0x090), /* 0.11 deg/c WP Off WC Off*/ + U8X8_C(0x0a4), /* normal display */ + + U8X8_END_TRANSFER(), /* disable chip */ + U8X8_END() /* end of sequence */ +}; + +static const uint8_t u8x8_d_uc1701_dogs102_powersave0_seq[] = { + U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ + U8X8_C(0x0af), /* display on */ + U8X8_END_TRANSFER(), /* disable chip */ + U8X8_END() /* end of sequence */ +}; + +static const uint8_t u8x8_d_uc1701_dogs102_powersave1_seq[] = { + U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ + U8X8_C(0x0ae), /* display off */ + U8X8_END_TRANSFER(), /* disable chip */ + U8X8_END() /* end of sequence */ +}; + +#ifdef U8X8_WITH_SET_FLIP_MODE +static const uint8_t u8x8_d_uc1701_dogs102_flip0_seq[] = { + U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ + U8X8_C(0x0a1), /* segment remap a0/a1*/ + U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */ + U8X8_END_TRANSFER(), /* disable chip */ + U8X8_END() /* end of sequence */ +}; + +static const uint8_t u8x8_d_uc1701_dogs102_flip1_seq[] = { + U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ + U8X8_C(0x0a0), /* segment remap a0/a1*/ + U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */ + U8X8_END_TRANSFER(), /* disable chip */ + U8X8_END() /* end of sequence */ +}; +#endif + + +static const u8x8_display_info_t u8x8_uc1701_display_info = +{ + /* chip_enable_level = */ 0, + /* chip_disable_level = */ 1, + + /* post_chip_enable_wait_ns = */ 5, + /* pre_chip_disable_wait_ns = */ 5, + /* reset_pulse_width_ms = */ 1, + /* post_reset_wait_ms = */ 6, + /* sda_setup_time_ns = */ 15, /* if this is smaller than sck_pulse_width_ns, use sck_pulse_width_ns, so use 15 instead of 12*/ + /* sck_pulse_width_ns = */ 15, + /* sck_takeover_edge = */ 1, /* rising edge */ + /* i2c_bus_clock_100kHz = */ 37, + /* data_setup_time_ns = */ 30, + /* write_pulse_width_ns = */ 40, + /* tile_width = */ 13, + /* tile_hight = */ 8, +#if U8X8_DEFAULT_FLIP_MODE == 0 + /* default_x_offset = */ 0, +#else + /* default_x_offset = */ 30, +#endif +}; + +uint8_t u8x8_d_uc1701_dogs102(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) +{ + uint8_t x, c; + uint8_t *ptr; + switch(msg) + { + case U8X8_MSG_DISPLAY_SETUP: + u8x8_d_helper_display_setup(u8x8, &u8x8_uc1701_display_info); + break; + case U8X8_MSG_DISPLAY_INIT: + u8x8_d_helper_display_init(u8x8); + u8x8_cad_SendSequence(u8x8, u8x8_d_uc1701_dogs102_init_seq); + break; + case U8X8_MSG_DISPLAY_SET_POWER_SAVE: + if ( arg_int == 0 ) + u8x8_cad_SendSequence(u8x8, u8x8_d_uc1701_dogs102_powersave0_seq); + else + u8x8_cad_SendSequence(u8x8, u8x8_d_uc1701_dogs102_powersave1_seq); + break; + #ifdef U8X8_WITH_SET_FLIP_MODE + case U8X8_MSG_DISPLAY_SET_FLIP_MODE: + if ( arg_int == 0 ) + { + u8x8_cad_SendSequence(u8x8, u8x8_d_uc1701_dogs102_flip0_seq); + u8x8->x_offset = 0; + } + else + { + u8x8_cad_SendSequence(u8x8, u8x8_d_uc1701_dogs102_flip1_seq); + u8x8->x_offset = 30; + } + break; +#endif +#ifdef U8X8_WITH_SET_CONTRAST + case U8X8_MSG_DISPLAY_SET_CONTRAST: + u8x8_cad_StartTransfer(u8x8); + u8x8_cad_SendCmd(u8x8, 0x081 ); + u8x8_cad_SendArg(u8x8, arg_int >> 2 ); /* uc1701 has range from 0 to 63 */ + u8x8_cad_EndTransfer(u8x8); + break; +#endif + case U8X8_MSG_DISPLAY_DRAW_TILE: + u8x8_cad_StartTransfer(u8x8); + + x = ((u8x8_tile_t *)arg_ptr)->x_pos; + x *= 8; + x += u8x8->x_offset; + u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) ); + u8x8_cad_SendCmd(u8x8, 0x000 | ((x&15))); + u8x8_cad_SendCmd(u8x8, 0x0b0 | (((u8x8_tile_t *)arg_ptr)->y_pos)); + + do + { + c = ((u8x8_tile_t *)arg_ptr)->cnt; + ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr; + u8x8_cad_SendData(u8x8, c*8, ptr); /* note: SendData can not handle more than 255 bytes */ + arg_int--; + } while( arg_int > 0 ); + + u8x8_cad_EndTransfer(u8x8); + break; + default: + return 0; + } + return 1; +} + + diff --git a/u8g2/csrc/u8x8_display.c b/u8g2/csrc/u8x8_display.c new file mode 100644 index 00000000..dc3d74dd --- /dev/null +++ b/u8g2/csrc/u8x8_display.c @@ -0,0 +1,107 @@ +/* + + u8x8_display.c + + Abstraction layer for the graphics controller. + Main goal is the placement of a 8x8 pixel block (tile) on the display. + +*/ + + +#include "u8x8.h" + + +/*==========================================*/ +/* internal library function */ + +/* + this is a helper function for the U8X8_MSG_DISPLAY_SETUP function. + It can be called within the display callback function to carry out the usual standard tasks. + +*/ +void u8x8_d_helper_display_setup(u8x8_t *u8x8, const u8x8_display_info_t *display_info) +{ + /* 1) set display info struct */ + u8x8->display_info = display_info; + u8x8->x_offset = u8x8->display_info->default_x_offset; +} + +/* + this is a helper function for the U8X8_MSG_DISPLAY_INIT function. + It can be called within the display callback function to carry out the usual standard tasks. + +*/ +void u8x8_d_helper_display_init(u8x8_t *u8x8) +{ + /* 2) apply port directions to the GPIO lines and apply default values for the IO lines*/ + u8x8_gpio_Init(u8x8); + u8x8_cad_Init(u8x8); + + /* 3) do reset */ + u8x8_gpio_SetReset(u8x8, 1); + u8x8_gpio_Delay(u8x8, U8X8_MSG_DELAY_MILLI, u8x8->display_info->reset_pulse_width_ms); + u8x8_gpio_SetReset(u8x8, 0); + u8x8_gpio_Delay(u8x8, U8X8_MSG_DELAY_MILLI, u8x8->display_info->reset_pulse_width_ms); + u8x8_gpio_SetReset(u8x8, 1); + u8x8_gpio_Delay(u8x8, U8X8_MSG_DELAY_MILLI, u8x8->display_info->post_reset_wait_ms); +} + +/*==========================================*/ +/* official functions */ + +uint8_t u8x8_display_DrawTile(u8x8_t *u8x8, uint8_t x, uint8_t y, uint8_t cnt, uint8_t *tile_ptr) +{ + u8x8_tile_t tile; + tile.x_pos = x; + tile.y_pos = y; + tile.cnt = cnt; + tile.tile_ptr = tile_ptr; + return u8x8->display_cb(u8x8, U8X8_MSG_DISPLAY_DRAW_TILE, 1, (void *)&tile); +} + +/* should be implemented as macro */ +void u8x8_display_Setup(u8x8_t *u8x8) +{ + u8x8->display_cb(u8x8, U8X8_MSG_DISPLAY_SETUP, 0, NULL); +} + +void u8x8_display_Init(u8x8_t *u8x8) +{ + u8x8->display_cb(u8x8, U8X8_MSG_DISPLAY_INIT, 0, NULL); +} + +void u8x8_display_SetPowerSave(u8x8_t *u8x8, uint8_t is_enable) +{ + u8x8->display_cb(u8x8, U8X8_MSG_DISPLAY_SET_POWER_SAVE, is_enable, NULL); +} + +void u8x8_display_SetFlipMode(u8x8_t *u8x8, uint8_t mode) +{ + u8x8->display_cb(u8x8, U8X8_MSG_DISPLAY_SET_FLIP_MODE, mode, NULL); +} + +void u8x8_display_SetContrast(u8x8_t *u8x8, uint8_t value) +{ + u8x8->display_cb(u8x8, U8X8_MSG_DISPLAY_SET_CONTRAST, value, NULL); +} + + +void u8x8_display_ClearScreen(u8x8_t *u8x8) +{ + uint8_t buf[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; + u8x8_tile_t tile; + uint8_t h; + + tile.x_pos = 0; + tile.cnt = 1; + tile.tile_ptr = buf; + + h = u8x8->display_info->tile_height; + tile.y_pos = 0; + do + { + u8x8->display_cb(u8x8, U8X8_MSG_DISPLAY_DRAW_TILE, u8x8->display_info->tile_width, (void *)&tile); + tile.y_pos++; + } while( tile.y_pos < h ); +} + diff --git a/u8g2/csrc/u8x8_gpio.c b/u8g2/csrc/u8x8_gpio.c new file mode 100644 index 00000000..5f17d5a2 --- /dev/null +++ b/u8g2/csrc/u8x8_gpio.c @@ -0,0 +1,15 @@ + +#include "u8x8.h" + + +void u8x8_gpio_call(u8x8_t *u8x8, uint8_t msg, uint8_t arg) +{ + u8x8->gpio_and_delay_cb(u8x8, msg, arg, NULL); +} + +/* +void u8x8_gpio_Delay(u8x8_t *u8x8, uint8_t msg, uint8_t dly) +{ + u8x8->gpio_and_delay_cb(u8x8, msg, dly, NULL); +} +*/ \ No newline at end of file diff --git a/u8g2/csrc/u8x8_setup.c b/u8g2/csrc/u8x8_setup.c new file mode 100644 index 00000000..8f3f8871 --- /dev/null +++ b/u8g2/csrc/u8x8_setup.c @@ -0,0 +1,32 @@ +/* + + u8x8_setup.c + +*/ + + +#include "u8x8.h" + +uint8_t u8x8_dummy_cb(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) +{ + /* the dummy callback will not handle any message and will fail for all messages */ + return 0; +} + + +/* + Description: + Setup u8x8 + Args: + u8x8 An empty u8x8 structure +*/ +void u8x8_SetupDefaults(u8x8_t *u8x8) +{ + u8x8->display_info = NULL; + u8x8->display_cb = u8x8_dummy_cb; + u8x8->cad_cb = u8x8_dummy_cb; + u8x8->byte_cb = u8x8_dummy_cb; + u8x8->gpio_and_delay_cb = u8x8_dummy_cb; +} + + diff --git a/u8g2/doc/u8g2_software_architecture.odg b/u8g2/doc/u8g2_software_architecture.odg new file mode 100644 index 00000000..3b467fb2 Binary files /dev/null and b/u8g2/doc/u8g2_software_architecture.odg differ diff --git a/u8g2/sys/arduino/test/Makefile.165.uno b/u8g2/sys/arduino/test/Makefile.165.uno new file mode 100644 index 00000000..ff49fd87 --- /dev/null +++ b/u8g2/sys/arduino/test/Makefile.165.uno @@ -0,0 +1,285 @@ + +# +# Arduino-1.0 Makefile +# +# written by olikraus@gmail.com +# +# Features: +# - boards.txt is used to derive parameters +# - All intermediate files are put into a separate directory (TMPDIRNAME) +# - Simple use: Copy Makefile into the same directory of the .ino file +# +# Limitations: +# - requires UNIX environment +# - TMPDIRNAME must be subdirectory of the current directory. +# +# Targets +# all build everything +# upload build and upload to arduino +# clean remove all temporary files (includes final hex file) +# +# History +# 001 28 Apr 2010 first release +# 002 05 Oct 2010 added 'uno' +# 003 06 Dec 2011 arduino 1.0 +# 004 11 Feb 2012 u8glib +# + +#=== user configuration === +# All ...PATH variables must have a '/' at the end + +# Board (and prozessor) information: see $(ARDUINO_PATH)hardware/arduino/boards.txt +# Some examples: +# BOARD DESCRIPTION +# uno Arduino Uno +# atmega328 Arduino Duemilanove or Nano w/ ATmega328 +# diecimila Arduino Diecimila, Duemilanove, or Nano w/ ATmega168 +# mega Arduino Mega +# mega2560 Arduino Mega2560 +# mini Arduino Mini +# lilypad328 LilyPad Arduino w/ ATmega328 +BOARD:=uno + +# additional definitions +#DEFS:=-DARDUINO=105 + + +U8G_PATH:=$(shell cd ../../.. && pwd)/csrc/ +#U8G_CPP_PATH:=$(shell cd ../../.. && pwd)/cppsrc/ +#U8G_FONT_PATH:=$(shell cd ../../.. && pwd)/sfntsrc/ + + +# The location where the avr tools (e.g. avr-gcc) are located. Requires a '/' at the end. +# Can be empty if all tools are accessable through the search path +AVR_TOOLS_PATH:=/usr/bin/ + +# Install path of the arduino software. Requires a '/' at the end. +ARDUINO_PATH:=/home/kraus/prg/arduino-1.0.5-u8glib/ + +# Install path for avrdude. Requires a '/' at the end. Can be empty if avrdude is in the search path. +AVRDUDE_PATH:=$(ARDUINO_PATH)hardware/tools/ + +# The unix device where we can reach the arduino board +# Uno: /dev/ttyACM0 +# Duemilanove: /dev/ttyUSB0 +AVRDUDE_PORT:=/dev/ttyACM0 + +# List of all libaries which should be included. +EXTRA_DIRS=$(ARDUINO_PATH)libraries/LiquidCrystal/ +EXTRA_DIRS+=$(ARDUINO_PATH)libraries/SD/ +EXTRA_DIRS+=$(ARDUINO_PATH)libraries/SD/utility/ +EXTRA_DIRS+=$(ARDUINO_PATH)libraries/SPI/ +#EXTRA_DIRS+=$(ARDUINO_PATH)libraries/.../ + +#=== fetch parameter from boards.txt processor parameter === +# the basic idea is to get most of the information from boards.txt + +BOARDS_TXT:=$(ARDUINO_PATH)hardware/arduino/boards.txt + +# get the MCU value from the $(BOARD).build.mcu variable. For the atmega328 board this is atmega328p +MCU:=$(shell sed -n -e "s/$(BOARD).build.mcu=\(.*\)/\1/p" $(BOARDS_TXT)) +# get the F_CPU value from the $(BOARD).build.f_cpu variable. For the atmega328 board this is 16000000 +F_CPU:=$(shell sed -n -e "s/$(BOARD).build.f_cpu=\(.*\)/\1/p" $(BOARDS_TXT)) +# get variant subfolder +VARIANT:=$(shell sed -n -e "s/$(BOARD).build.variant=\(.*\)/\1/p" $(BOARDS_TXT)) + + +# avrdude +# get the AVRDUDE_UPLOAD_RATE value from the $(BOARD).upload.speed variable. For the atmega328 board this is 57600 +AVRDUDE_UPLOAD_RATE:=$(shell sed -n -e "s/$(BOARD).upload.speed=\(.*\)/\1/p" $(BOARDS_TXT)) +# get the AVRDUDE_PROGRAMMER value from the $(BOARD).upload.protocol variable. For the atmega328 board this is stk500 +AVRDUDE_PROGRAMMER:=$(shell sed -n -e "s/$(BOARD).upload.protocol=\(.*\)/\1/p" $(BOARDS_TXT)) +# use stk500v1, because stk500 will default to stk500v2 +#AVRDUDE_PROGRAMMER:=stk500v1 + +#=== identify user files === +INOSRC:=$(shell ls *.ino) +TARGETNAME=$(basename $(INOSRC)) + +CDIRS:=$(EXTRA_DIRS) $(addsuffix utility/,$(EXTRA_DIRS)) +CDIRS:=*.c utility/*.c $(U8G_PATH)*.c $(addsuffix *.c,$(CDIRS)) $(ARDUINO_PATH)hardware/arduino/cores/arduino/*.c +CSRC:=$(shell ls $(CDIRS) 2>/dev/null) + +CCSRC:=$(shell ls *.cc 2>/dev/null) + +CPPDIRS:=$(EXTRA_DIRS) $(addsuffix utility/,$(EXTRA_DIRS)) +CPPDIRS:=*.cpp utility/*.cpp $(addsuffix *.cpp,$(CPPDIRS)) $(ARDUINO_PATH)hardware/arduino/cores/arduino/*.cpp +CPPSRC:=$(shell ls $(CPPDIRS) 2>/dev/null) + +#=== build internal variables === + +# the name of the subdirectory where everything is stored +TMPDIRNAME:=tmp +TMPDIRPATH:=$(TMPDIRNAME)/ + +AVRTOOLSPATH:=$(AVR_TOOLS_PATH) + +OBJCOPY:=$(AVRTOOLSPATH)avr-objcopy +OBJDUMP:=$(AVRTOOLSPATH)avr-objdump +SIZE:=$(AVRTOOLSPATH)avr-size + +CPPSRC:=$(addprefix $(TMPDIRPATH),$(INOSRC:.ino=.cpp)) $(CPPSRC) + +COBJ:=$(CSRC:.c=.o) +CCOBJ:=$(CCSRC:.cc=.o) +CPPOBJ:=$(CPPSRC:.cpp=.o) + +OBJFILES:=$(COBJ) $(CCOBJ) $(CPPOBJ) +DIRS:= $(dir $(OBJFILES)) + +DEPFILES:=$(OBJFILES:.o=.d) +# assembler files from avr-gcc -S +ASSFILES:=$(OBJFILES:.o=.s) +# disassembled object files with avr-objdump -S +DISFILES:=$(OBJFILES:.o=.dis) + + +LIBNAME:=$(TMPDIRPATH)$(TARGETNAME).a +ELFNAME:=$(TMPDIRPATH)$(TARGETNAME).elf +HEXNAME:=$(TMPDIRPATH)$(TARGETNAME).hex + +AVRDUDE_FLAGS = -V -F +AVRDUDE_FLAGS += -C $(ARDUINO_PATH)/hardware/tools/avrdude.conf +AVRDUDE_FLAGS += -p $(MCU) +AVRDUDE_FLAGS += -P $(AVRDUDE_PORT) +AVRDUDE_FLAGS += -c $(AVRDUDE_PROGRAMMER) +AVRDUDE_FLAGS += -b $(AVRDUDE_UPLOAD_RATE) +AVRDUDE_FLAGS += -U flash:w:$(HEXNAME) + +AVRDUDE = $(AVRDUDE_PATH)avrdude + +#=== predefined variable override === +# use "make -p -f/dev/null" to see the default rules and definitions + +# Build C and C++ flags. Include path information must be placed here +COMMON_FLAGS = -DF_CPU=$(F_CPU) -mmcu=$(MCU) $(DEFS) -DARDUINO=100 +# COMMON_FLAGS += -gdwarf-2 +COMMON_FLAGS += -Os +COMMON_FLAGS += -Wall -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums +COMMON_FLAGS += -I. +COMMON_FLAGS += -I$(ARDUINO_PATH)hardware/arduino/cores/arduino +COMMON_FLAGS += -I$(ARDUINO_PATH)hardware/arduino/variants/$(VARIANT) +COMMON_FLAGS += -I. -I$(U8G_PATH) +COMMON_FLAGS += $(addprefix -I,$(EXTRA_DIRS)) +COMMON_FLAGS += -ffunction-sections -fdata-sections -Wl,--gc-sections +COMMON_FLAGS += -Wl,--Map=output.map +COMMON_FLAGS += -Wl,--relax +COMMON_FLAGS += -mcall-prologues + +CFLAGS = $(COMMON_FLAGS) -std=gnu99 -Wstrict-prototypes +CXXFLAGS = $(COMMON_FLAGS) + +# Replace standard build tools by avr tools +CC = $(AVRTOOLSPATH)avr-gcc +CXX = $(AVRTOOLSPATH)avr-g++ +AR = @$(AVRTOOLSPATH)avr-ar + + +# "rm" must be able to delete a directory tree +RM = rm -rf + +#=== rules === + +# add rules for the C/C++ files where the .o file is placed in the TMPDIRPATH +# reuse existing variables as far as possible + +$(TMPDIRPATH)%.o: %.c + @echo compile $< + @$(COMPILE.c) $(OUTPUT_OPTION) $< + +$(TMPDIRPATH)%.o: %.cc + @echo compile $< + @$(COMPILE.cc) $(OUTPUT_OPTION) $< + +$(TMPDIRPATH)%.o: %.cpp + @echo compile $< + @$(COMPILE.cpp) $(OUTPUT_OPTION) $< + +$(TMPDIRPATH)%.s: %.c + @$(COMPILE.c) $(OUTPUT_OPTION) -S $< + +$(TMPDIRPATH)%.s: %.cc + @$(COMPILE.cc) $(OUTPUT_OPTION) -S $< + +$(TMPDIRPATH)%.s: %.cpp + @$(COMPILE.cpp) $(OUTPUT_OPTION) -S $< + +$(TMPDIRPATH)%.dis: $(TMPDIRPATH)%.o + @$(OBJDUMP) -S $< > $@ + +.SUFFIXES: .elf .hex .ino + +.elf.hex: + @$(OBJCOPY) -O ihex -R .eeprom $< $@ + +$(TMPDIRPATH)%.cpp: %.ino + @cat $(ARDUINO_PATH)hardware/arduino/cores/arduino/main.cpp > $@ + @cat $< >> $@ + @echo >> $@ + @echo 'extern "C" void __cxa_pure_virtual() { while (1); }' >> $@ + + +.PHONY: all +all: tmpdir $(HEXNAME) assemblersource showsize + ls -al $(HEXNAME) $(ELFNAME) + +$(ELFNAME): $(LIBNAME)($(addprefix $(TMPDIRPATH),$(OBJFILES))) + $(LINK.o) $(COMMON_FLAGS) $(LIBNAME) $(LOADLIBES) $(LDLIBS) -o $@ + +$(LIBNAME)(): $(addprefix $(TMPDIRPATH),$(OBJFILES)) + +#=== create temp directory === +# not really required, because it will be also created during the dependency handling +.PHONY: tmpdir +tmpdir: + @test -d $(TMPDIRPATH) || mkdir $(TMPDIRPATH) + +#=== create assembler files for each C/C++ file === +.PHONY: assemblersource +assemblersource: $(addprefix $(TMPDIRPATH),$(ASSFILES)) $(addprefix $(TMPDIRPATH),$(DISFILES)) + + +#=== show the section sizes of the ELF file === +.PHONY: showsize +showsize: $(ELFNAME) + $(SIZE) $< + +#=== clean up target === +# this is simple: the TMPDIRPATH is removed +.PHONY: clean +clean: + $(RM) $(TMPDIRPATH) + +# Program the device. +# step 1: reset the arduino board with the stty command +# step 2: user avrdude to upload the software +.PHONY: upload +upload: $(HEXNAME) + stty -F $(AVRDUDE_PORT) hupcl + $(AVRDUDE) $(AVRDUDE_FLAGS) + + +# === dependency handling === +# From the gnu make manual (section 4.14, Generating Prerequisites Automatically) +# Additionally (because this will be the first executed rule) TMPDIRPATH is created here. +# Instead of "sed" the "echo" command is used +# cd $(TMPDIRPATH); mkdir -p $(DIRS) 2> /dev/null; cd .. +DEPACTION=test -d $(TMPDIRPATH) || mkdir $(TMPDIRPATH);\ +mkdir -p $(addprefix $(TMPDIRPATH),$(DIRS));\ +set -e; echo -n $@ $(dir $@) > $@; $(CC) -MM $(COMMON_FLAGS) $< >> $@ + + +$(TMPDIRPATH)%.d: %.c + @$(DEPACTION) + +$(TMPDIRPATH)%.d: %.cc + @$(DEPACTION) + +$(TMPDIRPATH)%.d: %.cpp + @$(DEPACTION) + +# Include dependency files. If a .d file is missing, a warning is created and the .d file is created +# This warning is not a problem (gnu make manual, section 3.3 Including Other Makefiles) +-include $(addprefix $(TMPDIRPATH),$(DEPFILES)) + + diff --git a/u8g2/sys/arduino/test/test.ino b/u8g2/sys/arduino/test/test.ino new file mode 100644 index 00000000..b7b3878c --- /dev/null +++ b/u8g2/sys/arduino/test/test.ino @@ -0,0 +1,232 @@ + + + +#include +#include +#include "u8x8.h" + +/* + Fontname: FreeType-Amstrad CPC extended-Medium-R-Normal--8-80-72-72-P-64-ISO10646-1 + Copyright: Copyright ruboku 2008 + Glyphs: 95/196 + BBX Build Mode: 3 +*/ +//#include "u8x2.h" + +const uint8_t bdf_font[762] U8X8_FONT_SECTION("bdf_font") = { + 32,126,0,0,0,0,0,0,0,0,0,0,0,95,95,0, + 0,0,0,7,7,0,7,7,0,0,20,127,127,28,127,127, + 20,0,0,36,42,127,127,42,18,0,70,102,48,24,12,102, + 98,0,48,122,79,93,55,122,72,0,0,0,0,7,7,0, + 0,0,0,0,28,62,99,65,0,0,0,0,65,99,62,28, + 0,0,0,0,0,0,0,0,0,0,0,8,8,62,62,8, + 8,0,0,0,128,224,96,0,0,0,0,8,8,8,8,8, + 8,0,0,0,0,96,96,0,0,0,96,48,24,12,6,3, + 1,0,62,127,81,73,69,127,62,0,0,64,66,127,127,64, + 64,0,0,114,123,73,73,111,102,0,0,34,97,73,73,127, + 54,0,24,20,82,127,127,80,16,0,0,39,111,73,73,121, + 51,0,0,62,127,73,73,123,50,0,0,3,1,113,125,15, + 7,0,0,54,127,73,73,127,54,0,0,38,111,73,73,127, + 62,0,0,0,0,108,108,0,0,0,0,0,128,236,108,0, + 0,0,0,8,28,54,99,65,0,0,0,36,36,36,36,36, + 36,0,0,65,99,54,28,8,0,0,0,2,3,81,89,15, + 6,0,62,127,65,93,93,95,30,0,0,124,126,19,19,126, + 124,0,65,127,127,73,73,127,54,0,28,62,99,65,65,99, + 34,0,65,127,127,65,99,62,28,0,65,127,127,73,93,65, + 99,0,65,127,127,73,29,1,3,0,60,126,67,65,81,115, + 114,0,0,127,127,8,8,127,127,0,0,65,65,127,127,65, + 65,0,48,112,64,65,127,63,1,0,65,127,127,8,28,119, + 99,0,65,127,127,65,64,96,112,0,127,127,14,28,14,127, + 127,0,127,127,6,12,24,127,127,0,28,62,99,65,99,62, + 28,0,65,127,127,73,9,7,6,0,60,126,67,81,51,110, + 92,0,65,127,127,9,25,63,102,0,0,38,111,73,73,123, + 50,0,0,3,65,127,127,65,3,0,0,63,127,64,64,127, + 63,0,0,31,63,96,96,63,31,0,127,127,48,24,48,127, + 127,0,97,115,30,12,30,115,97,0,0,7,79,120,120,79, + 7,0,71,99,113,89,77,103,115,0,0,0,127,127,65,65, + 0,0,1,3,6,12,24,48,96,0,0,0,65,65,127,127, + 0,0,8,12,6,3,6,12,8,0,0,0,0,0,0,0, + 0,0,0,0,2,6,12,8,0,0,32,116,84,84,60,120, + 64,0,67,63,127,68,68,124,56,0,0,56,124,68,68,108, + 40,0,56,124,68,69,63,127,64,0,0,56,124,84,84,92, + 24,0,0,72,126,127,73,3,2,0,0,152,188,164,164,252, + 124,0,65,127,127,8,4,124,120,0,0,0,68,125,125,64, + 0,0,0,96,224,128,132,252,125,0,65,127,127,16,56,108, + 68,0,0,0,65,127,127,64,0,0,120,124,12,56,12,124, + 120,0,4,124,120,4,4,120,120,0,0,56,124,68,68,124, + 56,0,132,252,248,164,36,60,24,0,24,60,36,164,248,252, + 132,0,68,124,120,68,12,8,0,0,0,72,92,84,84,116, + 32,0,0,4,63,127,68,100,32,0,0,60,124,64,64,124, + 124,0,0,28,60,96,96,60,28,0,60,124,96,56,96,124, + 60,0,68,108,56,16,56,108,68,0,0,156,188,160,160,252, + 124,0,0,76,100,116,92,76,68,0,0,65,65,119,62,8, + 8,0,0,0,0,127,127,0,0,0,0,8,8,62,119,65, + 65,0,2,3,1,3,2,1,1,0}; + + + +uint8_t u8x8_gpio_and_delay_arduino(u8x8_t *u8g2, uint8_t msg, uint8_t arg_int, void *arg_ptr) +{ + switch(msg) + { + case U8X8_MSG_GPIO_AND_DELAY_INIT: + pinMode(8, OUTPUT); + pinMode(9, OUTPUT); + pinMode(10, OUTPUT); + pinMode(11, OUTPUT); + pinMode(13, OUTPUT); + break; + + case U8X8_MSG_DELAY_MILLI: + delay(arg_int); + break; + + case U8X8_MSG_GPIO_DC: + digitalWrite(9, arg_int); + break; + + case U8X8_MSG_GPIO_CS: + digitalWrite(10, arg_int); + break; + + case U8X8_MSG_GPIO_RESET: + digitalWrite(8, arg_int); + break; + + case U8X8_MSG_GPIO_CLOCK: + digitalWrite(13, arg_int); + break; + + case U8X8_MSG_GPIO_DATA: + digitalWrite(11, arg_int); + break; + + default: + return 0; + } + return 1; +} + + + +uint8_t u8x8_byte_arduino_hw_spi(u8x8_t *u8g2, uint8_t msg, uint8_t arg_int, void *arg_ptr) +{ + uint8_t *data; + + switch(msg) + { + case U8X8_MSG_BYTE_SEND: + + data = (uint8_t *)arg_ptr; + while( arg_int > 0 ) + { + SPI.transfer((uint8_t)*data); + data++; + arg_int--; + } + break; + case U8X8_MSG_BYTE_INIT: + /* disable chipselect */ + u8x8_gpio_SetCS(u8g2, u8g2->display_info->chip_disable_level); + /* no wait required here */ + + /* for SPI: setup correct level of the clock signal */ + digitalWrite(13, u8g2->display_info->sck_takeover_edge); + break; + case U8X8_MSG_BYTE_SET_DC: + u8x8_gpio_SetDC(u8g2, arg_int); + break; + case U8X8_MSG_BYTE_START_TRANSFER: + SPI.begin(); + SPI.setClockDivider( SPI_CLOCK_DIV2 ); + SPI.setDataMode(SPI_MODE0); + SPI.setBitOrder(MSBFIRST); + + u8x8_gpio_SetCS(u8g2, u8g2->display_info->chip_enable_level); + u8g2->gpio_and_delay_cb(u8g2, U8X8_MSG_DELAY_NANO, u8g2->display_info->post_chip_enable_wait_ns, NULL); + break; + case U8X8_MSG_BYTE_END_TRANSFER: + u8g2->gpio_and_delay_cb(u8g2, U8X8_MSG_DELAY_NANO, u8g2->display_info->pre_chip_disable_wait_ns, NULL); + u8x8_gpio_SetCS(u8g2, u8g2->display_info->chip_disable_level); + SPI.end(); + break; + case U8X8_MSG_BYTE_SET_I2C_ADR: + break; + case U8X8_MSG_BYTE_SET_DEVICE: + break; + default: + return 0; + } + return 1; +} + +void u8x8_Setup_UC1701_DOGS102(u8x8_t *u8x8) +{ + /* setup defaults */ + u8x8_SetupDefaults(u8x8); + + /* setup specific callbacks */ + u8x8->display_cb = u8x8_d_uc1701_dogs102; + u8x8->cad_cb = u8x8_cad_001; + u8x8->byte_cb = u8x8_byte_8bit_sw_spi; + u8x8->gpio_and_delay_cb = u8x8_gpio_and_delay_arduino; + + /* setup display info */ + u8x8_display_Setup(u8x8); +} + +void u8x8_Setup_SSD1306_128x64_NONAME(u8x8_t *u8x8) +{ + /* setup defaults */ + u8x8_SetupDefaults(u8x8); + + /* setup specific callbacks */ + u8x8->display_cb = u8x8_d_ssd1306_128x64_noname; + u8x8->cad_cb = u8x8_cad_001; + u8x8->byte_cb = u8x8_byte_arduino_hw_spi; + //u8x8->byte_cb = u8x8_byte_8bit_sw_spi; + u8x8->gpio_and_delay_cb = u8x8_gpio_and_delay_arduino; + + /* setup display info */ + u8x8_display_Setup(u8x8); +} + + +u8x8_t u8g2; +uint8_t tile[8] = { 0x0f, 0x0f, 0x0f, 0x0f, 0xf0, 0xf0, 0xf0, 0xf0 }; + +void setup(void) +{ + //u8x8_Setup_UC1701_DOGS102(&u8g2); + u8x8_Setup_SSD1306_128x64_NONAME(&u8g2); +} + +void loop(void) +{ + u8x8_display_Init(&u8g2); + //u8x8_display_SetFlipMode(&u8g2, 1); + + + for(;;) + { + u8x8_display_ClearScreen(&u8g2); + u8x8_display_SetPowerSave(&u8g2, 0); + //u8x8_display_SetContrast(&u8g2, 10); + + delay(500); + + u8x8_Set8x8Font(&u8g2, bdf_font); + u8x8_Draw8x8String(&u8g2, 0, 0, "Hello gAjByCD"); + u8x8_Draw8x8String(&u8g2, 3, 1, "World B"); + + u8x8_display_DrawTile(&u8g2, 1, 1, 1, tile); + u8x8_display_DrawTile(&u8g2, 2, 2, 1, tile); + u8x8_display_DrawTile(&u8g2, 3, 3, 1, tile); + u8x8_display_DrawTile(&u8g2, 4, 4, 1, tile); + u8x8_display_DrawTile(&u8g2, 5, 5, 1, tile); + u8x8_display_DrawTile(&u8g2, 6, 6, 1, tile); + + delay(2000); + } +} + diff --git a/u8g2/sys/arduino/text/Makefile.165.uno b/u8g2/sys/arduino/text/Makefile.165.uno new file mode 100644 index 00000000..ff49fd87 --- /dev/null +++ b/u8g2/sys/arduino/text/Makefile.165.uno @@ -0,0 +1,285 @@ + +# +# Arduino-1.0 Makefile +# +# written by olikraus@gmail.com +# +# Features: +# - boards.txt is used to derive parameters +# - All intermediate files are put into a separate directory (TMPDIRNAME) +# - Simple use: Copy Makefile into the same directory of the .ino file +# +# Limitations: +# - requires UNIX environment +# - TMPDIRNAME must be subdirectory of the current directory. +# +# Targets +# all build everything +# upload build and upload to arduino +# clean remove all temporary files (includes final hex file) +# +# History +# 001 28 Apr 2010 first release +# 002 05 Oct 2010 added 'uno' +# 003 06 Dec 2011 arduino 1.0 +# 004 11 Feb 2012 u8glib +# + +#=== user configuration === +# All ...PATH variables must have a '/' at the end + +# Board (and prozessor) information: see $(ARDUINO_PATH)hardware/arduino/boards.txt +# Some examples: +# BOARD DESCRIPTION +# uno Arduino Uno +# atmega328 Arduino Duemilanove or Nano w/ ATmega328 +# diecimila Arduino Diecimila, Duemilanove, or Nano w/ ATmega168 +# mega Arduino Mega +# mega2560 Arduino Mega2560 +# mini Arduino Mini +# lilypad328 LilyPad Arduino w/ ATmega328 +BOARD:=uno + +# additional definitions +#DEFS:=-DARDUINO=105 + + +U8G_PATH:=$(shell cd ../../.. && pwd)/csrc/ +#U8G_CPP_PATH:=$(shell cd ../../.. && pwd)/cppsrc/ +#U8G_FONT_PATH:=$(shell cd ../../.. && pwd)/sfntsrc/ + + +# The location where the avr tools (e.g. avr-gcc) are located. Requires a '/' at the end. +# Can be empty if all tools are accessable through the search path +AVR_TOOLS_PATH:=/usr/bin/ + +# Install path of the arduino software. Requires a '/' at the end. +ARDUINO_PATH:=/home/kraus/prg/arduino-1.0.5-u8glib/ + +# Install path for avrdude. Requires a '/' at the end. Can be empty if avrdude is in the search path. +AVRDUDE_PATH:=$(ARDUINO_PATH)hardware/tools/ + +# The unix device where we can reach the arduino board +# Uno: /dev/ttyACM0 +# Duemilanove: /dev/ttyUSB0 +AVRDUDE_PORT:=/dev/ttyACM0 + +# List of all libaries which should be included. +EXTRA_DIRS=$(ARDUINO_PATH)libraries/LiquidCrystal/ +EXTRA_DIRS+=$(ARDUINO_PATH)libraries/SD/ +EXTRA_DIRS+=$(ARDUINO_PATH)libraries/SD/utility/ +EXTRA_DIRS+=$(ARDUINO_PATH)libraries/SPI/ +#EXTRA_DIRS+=$(ARDUINO_PATH)libraries/.../ + +#=== fetch parameter from boards.txt processor parameter === +# the basic idea is to get most of the information from boards.txt + +BOARDS_TXT:=$(ARDUINO_PATH)hardware/arduino/boards.txt + +# get the MCU value from the $(BOARD).build.mcu variable. For the atmega328 board this is atmega328p +MCU:=$(shell sed -n -e "s/$(BOARD).build.mcu=\(.*\)/\1/p" $(BOARDS_TXT)) +# get the F_CPU value from the $(BOARD).build.f_cpu variable. For the atmega328 board this is 16000000 +F_CPU:=$(shell sed -n -e "s/$(BOARD).build.f_cpu=\(.*\)/\1/p" $(BOARDS_TXT)) +# get variant subfolder +VARIANT:=$(shell sed -n -e "s/$(BOARD).build.variant=\(.*\)/\1/p" $(BOARDS_TXT)) + + +# avrdude +# get the AVRDUDE_UPLOAD_RATE value from the $(BOARD).upload.speed variable. For the atmega328 board this is 57600 +AVRDUDE_UPLOAD_RATE:=$(shell sed -n -e "s/$(BOARD).upload.speed=\(.*\)/\1/p" $(BOARDS_TXT)) +# get the AVRDUDE_PROGRAMMER value from the $(BOARD).upload.protocol variable. For the atmega328 board this is stk500 +AVRDUDE_PROGRAMMER:=$(shell sed -n -e "s/$(BOARD).upload.protocol=\(.*\)/\1/p" $(BOARDS_TXT)) +# use stk500v1, because stk500 will default to stk500v2 +#AVRDUDE_PROGRAMMER:=stk500v1 + +#=== identify user files === +INOSRC:=$(shell ls *.ino) +TARGETNAME=$(basename $(INOSRC)) + +CDIRS:=$(EXTRA_DIRS) $(addsuffix utility/,$(EXTRA_DIRS)) +CDIRS:=*.c utility/*.c $(U8G_PATH)*.c $(addsuffix *.c,$(CDIRS)) $(ARDUINO_PATH)hardware/arduino/cores/arduino/*.c +CSRC:=$(shell ls $(CDIRS) 2>/dev/null) + +CCSRC:=$(shell ls *.cc 2>/dev/null) + +CPPDIRS:=$(EXTRA_DIRS) $(addsuffix utility/,$(EXTRA_DIRS)) +CPPDIRS:=*.cpp utility/*.cpp $(addsuffix *.cpp,$(CPPDIRS)) $(ARDUINO_PATH)hardware/arduino/cores/arduino/*.cpp +CPPSRC:=$(shell ls $(CPPDIRS) 2>/dev/null) + +#=== build internal variables === + +# the name of the subdirectory where everything is stored +TMPDIRNAME:=tmp +TMPDIRPATH:=$(TMPDIRNAME)/ + +AVRTOOLSPATH:=$(AVR_TOOLS_PATH) + +OBJCOPY:=$(AVRTOOLSPATH)avr-objcopy +OBJDUMP:=$(AVRTOOLSPATH)avr-objdump +SIZE:=$(AVRTOOLSPATH)avr-size + +CPPSRC:=$(addprefix $(TMPDIRPATH),$(INOSRC:.ino=.cpp)) $(CPPSRC) + +COBJ:=$(CSRC:.c=.o) +CCOBJ:=$(CCSRC:.cc=.o) +CPPOBJ:=$(CPPSRC:.cpp=.o) + +OBJFILES:=$(COBJ) $(CCOBJ) $(CPPOBJ) +DIRS:= $(dir $(OBJFILES)) + +DEPFILES:=$(OBJFILES:.o=.d) +# assembler files from avr-gcc -S +ASSFILES:=$(OBJFILES:.o=.s) +# disassembled object files with avr-objdump -S +DISFILES:=$(OBJFILES:.o=.dis) + + +LIBNAME:=$(TMPDIRPATH)$(TARGETNAME).a +ELFNAME:=$(TMPDIRPATH)$(TARGETNAME).elf +HEXNAME:=$(TMPDIRPATH)$(TARGETNAME).hex + +AVRDUDE_FLAGS = -V -F +AVRDUDE_FLAGS += -C $(ARDUINO_PATH)/hardware/tools/avrdude.conf +AVRDUDE_FLAGS += -p $(MCU) +AVRDUDE_FLAGS += -P $(AVRDUDE_PORT) +AVRDUDE_FLAGS += -c $(AVRDUDE_PROGRAMMER) +AVRDUDE_FLAGS += -b $(AVRDUDE_UPLOAD_RATE) +AVRDUDE_FLAGS += -U flash:w:$(HEXNAME) + +AVRDUDE = $(AVRDUDE_PATH)avrdude + +#=== predefined variable override === +# use "make -p -f/dev/null" to see the default rules and definitions + +# Build C and C++ flags. Include path information must be placed here +COMMON_FLAGS = -DF_CPU=$(F_CPU) -mmcu=$(MCU) $(DEFS) -DARDUINO=100 +# COMMON_FLAGS += -gdwarf-2 +COMMON_FLAGS += -Os +COMMON_FLAGS += -Wall -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums +COMMON_FLAGS += -I. +COMMON_FLAGS += -I$(ARDUINO_PATH)hardware/arduino/cores/arduino +COMMON_FLAGS += -I$(ARDUINO_PATH)hardware/arduino/variants/$(VARIANT) +COMMON_FLAGS += -I. -I$(U8G_PATH) +COMMON_FLAGS += $(addprefix -I,$(EXTRA_DIRS)) +COMMON_FLAGS += -ffunction-sections -fdata-sections -Wl,--gc-sections +COMMON_FLAGS += -Wl,--Map=output.map +COMMON_FLAGS += -Wl,--relax +COMMON_FLAGS += -mcall-prologues + +CFLAGS = $(COMMON_FLAGS) -std=gnu99 -Wstrict-prototypes +CXXFLAGS = $(COMMON_FLAGS) + +# Replace standard build tools by avr tools +CC = $(AVRTOOLSPATH)avr-gcc +CXX = $(AVRTOOLSPATH)avr-g++ +AR = @$(AVRTOOLSPATH)avr-ar + + +# "rm" must be able to delete a directory tree +RM = rm -rf + +#=== rules === + +# add rules for the C/C++ files where the .o file is placed in the TMPDIRPATH +# reuse existing variables as far as possible + +$(TMPDIRPATH)%.o: %.c + @echo compile $< + @$(COMPILE.c) $(OUTPUT_OPTION) $< + +$(TMPDIRPATH)%.o: %.cc + @echo compile $< + @$(COMPILE.cc) $(OUTPUT_OPTION) $< + +$(TMPDIRPATH)%.o: %.cpp + @echo compile $< + @$(COMPILE.cpp) $(OUTPUT_OPTION) $< + +$(TMPDIRPATH)%.s: %.c + @$(COMPILE.c) $(OUTPUT_OPTION) -S $< + +$(TMPDIRPATH)%.s: %.cc + @$(COMPILE.cc) $(OUTPUT_OPTION) -S $< + +$(TMPDIRPATH)%.s: %.cpp + @$(COMPILE.cpp) $(OUTPUT_OPTION) -S $< + +$(TMPDIRPATH)%.dis: $(TMPDIRPATH)%.o + @$(OBJDUMP) -S $< > $@ + +.SUFFIXES: .elf .hex .ino + +.elf.hex: + @$(OBJCOPY) -O ihex -R .eeprom $< $@ + +$(TMPDIRPATH)%.cpp: %.ino + @cat $(ARDUINO_PATH)hardware/arduino/cores/arduino/main.cpp > $@ + @cat $< >> $@ + @echo >> $@ + @echo 'extern "C" void __cxa_pure_virtual() { while (1); }' >> $@ + + +.PHONY: all +all: tmpdir $(HEXNAME) assemblersource showsize + ls -al $(HEXNAME) $(ELFNAME) + +$(ELFNAME): $(LIBNAME)($(addprefix $(TMPDIRPATH),$(OBJFILES))) + $(LINK.o) $(COMMON_FLAGS) $(LIBNAME) $(LOADLIBES) $(LDLIBS) -o $@ + +$(LIBNAME)(): $(addprefix $(TMPDIRPATH),$(OBJFILES)) + +#=== create temp directory === +# not really required, because it will be also created during the dependency handling +.PHONY: tmpdir +tmpdir: + @test -d $(TMPDIRPATH) || mkdir $(TMPDIRPATH) + +#=== create assembler files for each C/C++ file === +.PHONY: assemblersource +assemblersource: $(addprefix $(TMPDIRPATH),$(ASSFILES)) $(addprefix $(TMPDIRPATH),$(DISFILES)) + + +#=== show the section sizes of the ELF file === +.PHONY: showsize +showsize: $(ELFNAME) + $(SIZE) $< + +#=== clean up target === +# this is simple: the TMPDIRPATH is removed +.PHONY: clean +clean: + $(RM) $(TMPDIRPATH) + +# Program the device. +# step 1: reset the arduino board with the stty command +# step 2: user avrdude to upload the software +.PHONY: upload +upload: $(HEXNAME) + stty -F $(AVRDUDE_PORT) hupcl + $(AVRDUDE) $(AVRDUDE_FLAGS) + + +# === dependency handling === +# From the gnu make manual (section 4.14, Generating Prerequisites Automatically) +# Additionally (because this will be the first executed rule) TMPDIRPATH is created here. +# Instead of "sed" the "echo" command is used +# cd $(TMPDIRPATH); mkdir -p $(DIRS) 2> /dev/null; cd .. +DEPACTION=test -d $(TMPDIRPATH) || mkdir $(TMPDIRPATH);\ +mkdir -p $(addprefix $(TMPDIRPATH),$(DIRS));\ +set -e; echo -n $@ $(dir $@) > $@; $(CC) -MM $(COMMON_FLAGS) $< >> $@ + + +$(TMPDIRPATH)%.d: %.c + @$(DEPACTION) + +$(TMPDIRPATH)%.d: %.cc + @$(DEPACTION) + +$(TMPDIRPATH)%.d: %.cpp + @$(DEPACTION) + +# Include dependency files. If a .d file is missing, a warning is created and the .d file is created +# This warning is not a problem (gnu make manual, section 3.3 Including Other Makefiles) +-include $(addprefix $(TMPDIRPATH),$(DEPFILES)) + + diff --git a/u8g2/sys/arduino/text/text.ino b/u8g2/sys/arduino/text/text.ino new file mode 100644 index 00000000..171d7945 --- /dev/null +++ b/u8g2/sys/arduino/text/text.ino @@ -0,0 +1,408 @@ + + + +#include +#include +#include "u8g2.h" + +/* + Fontname: FreeType-Amstrad CPC extended-Medium-R-Normal--8-80-72-72-P-64-ISO10646-1 + Copyright: Copyright ruboku 2008 + Glyphs: 95/196 + BBX Build Mode: 3 +*/ +//#include "u8x2.h" + +const uint8_t bdf_font[762] U8X8_FONT_SECTION("bdf_font") = { + 32,126,0,0,0,0,0,0,0,0,0,0,0,95,95,0, + 0,0,0,7,7,0,7,7,0,0,20,127,127,28,127,127, + 20,0,0,36,42,127,127,42,18,0,70,102,48,24,12,102, + 98,0,48,122,79,93,55,122,72,0,0,0,0,7,7,0, + 0,0,0,0,28,62,99,65,0,0,0,0,65,99,62,28, + 0,0,0,0,0,0,0,0,0,0,0,8,8,62,62,8, + 8,0,0,0,128,224,96,0,0,0,0,8,8,8,8,8, + 8,0,0,0,0,96,96,0,0,0,96,48,24,12,6,3, + 1,0,62,127,81,73,69,127,62,0,0,64,66,127,127,64, + 64,0,0,114,123,73,73,111,102,0,0,34,97,73,73,127, + 54,0,24,20,82,127,127,80,16,0,0,39,111,73,73,121, + 51,0,0,62,127,73,73,123,50,0,0,3,1,113,125,15, + 7,0,0,54,127,73,73,127,54,0,0,38,111,73,73,127, + 62,0,0,0,0,108,108,0,0,0,0,0,128,236,108,0, + 0,0,0,8,28,54,99,65,0,0,0,36,36,36,36,36, + 36,0,0,65,99,54,28,8,0,0,0,2,3,81,89,15, + 6,0,62,127,65,93,93,95,30,0,0,124,126,19,19,126, + 124,0,65,127,127,73,73,127,54,0,28,62,99,65,65,99, + 34,0,65,127,127,65,99,62,28,0,65,127,127,73,93,65, + 99,0,65,127,127,73,29,1,3,0,60,126,67,65,81,115, + 114,0,0,127,127,8,8,127,127,0,0,65,65,127,127,65, + 65,0,48,112,64,65,127,63,1,0,65,127,127,8,28,119, + 99,0,65,127,127,65,64,96,112,0,127,127,14,28,14,127, + 127,0,127,127,6,12,24,127,127,0,28,62,99,65,99,62, + 28,0,65,127,127,73,9,7,6,0,60,126,67,81,51,110, + 92,0,65,127,127,9,25,63,102,0,0,38,111,73,73,123, + 50,0,0,3,65,127,127,65,3,0,0,63,127,64,64,127, + 63,0,0,31,63,96,96,63,31,0,127,127,48,24,48,127, + 127,0,97,115,30,12,30,115,97,0,0,7,79,120,120,79, + 7,0,71,99,113,89,77,103,115,0,0,0,127,127,65,65, + 0,0,1,3,6,12,24,48,96,0,0,0,65,65,127,127, + 0,0,8,12,6,3,6,12,8,0,0,0,0,0,0,0, + 0,0,0,0,2,6,12,8,0,0,32,116,84,84,60,120, + 64,0,67,63,127,68,68,124,56,0,0,56,124,68,68,108, + 40,0,56,124,68,69,63,127,64,0,0,56,124,84,84,92, + 24,0,0,72,126,127,73,3,2,0,0,152,188,164,164,252, + 124,0,65,127,127,8,4,124,120,0,0,0,68,125,125,64, + 0,0,0,96,224,128,132,252,125,0,65,127,127,16,56,108, + 68,0,0,0,65,127,127,64,0,0,120,124,12,56,12,124, + 120,0,4,124,120,4,4,120,120,0,0,56,124,68,68,124, + 56,0,132,252,248,164,36,60,24,0,24,60,36,164,248,252, + 132,0,68,124,120,68,12,8,0,0,0,72,92,84,84,116, + 32,0,0,4,63,127,68,100,32,0,0,60,124,64,64,124, + 124,0,0,28,60,96,96,60,28,0,60,124,96,56,96,124, + 60,0,68,108,56,16,56,108,68,0,0,156,188,160,160,252, + 124,0,0,76,100,116,92,76,68,0,0,65,65,119,62,8, + 8,0,0,0,0,127,127,0,0,0,0,8,8,62,119,65, + 65,0,2,3,1,3,2,1,1,0}; + +const uint8_t u8g2_font_helvB18_tr[2245] U8X8_FONT_SECTION("u8g2_font_helvB18_tr") = { + 95,0,4,3,5,5,3,5,6,23,24,0,251,19,251,19, + 251,2,234,6,37,32,6,0,48,154,0,33,10,99,26,158, + 240,23,234,14,4,34,11,197,184,167,32,193,139,145,8,0, + 35,42,76,22,186,36,34,38,34,38,34,38,34,38,34,115, + 64,113,64,35,34,38,34,38,34,38,34,115,64,113,64,35, + 34,38,34,38,34,38,34,38,34,4,36,39,172,210,181,37, + 119,116,48,65,33,177,68,196,68,228,66,204,174,146,178,206, + 76,226,68,196,68,196,68,228,66,130,226,96,232,78,84,10, + 0,37,49,85,18,218,61,87,54,118,52,54,179,76,74,100, + 78,74,100,110,102,98,242,100,180,100,30,102,30,100,166,116, + 228,112,100,102,110,68,74,108,70,74,108,102,213,212,217,88, + 9,0,38,38,80,22,202,84,122,72,65,55,51,55,51,55, + 51,56,49,218,244,100,134,130,98,102,230,100,170,102,108,104, + 170,134,230,129,200,144,209,0,39,8,194,184,155,112,64,1, + 40,22,6,119,161,36,51,50,51,50,51,35,179,255,72,104, + 102,104,102,104,72,0,41,22,6,119,161,32,180,102,104,102, + 72,104,102,255,70,102,201,204,200,140,16,0,42,16,232,148, + 171,35,38,35,33,113,48,66,35,162,5,0,43,14,140,53, + 190,37,170,171,131,7,83,162,186,2,44,10,195,184,157,112, + 32,33,65,1,45,7,103,208,162,240,1,46,7,99,24,158, + 112,32,47,18,103,22,162,165,145,148,34,41,141,164,20,73, + 41,146,82,5,48,27,76,18,182,99,117,16,67,66,50,52, + 50,52,49,230,159,77,12,141,12,141,176,57,136,178,1,49, + 12,71,26,182,180,230,224,128,104,255,15,50,27,76,18,182, + 83,117,32,51,67,49,53,49,102,54,57,56,72,199,172,140, + 142,225,228,193,131,1,51,31,76,18,182,83,117,32,179,100, + 106,98,106,98,106,114,112,172,238,114,116,210,204,138,98,134, + 228,96,200,6,0,52,27,76,18,182,55,200,174,153,196,212, + 196,148,200,144,204,54,66,35,67,35,7,15,230,38,55,1, + 53,30,76,18,182,113,48,114,48,50,185,229,65,208,129,204, + 12,229,232,228,164,153,213,65,12,201,129,148,13,0,54,32, + 76,18,182,84,117,32,66,51,50,101,102,185,130,232,96,164, + 132,130,104,98,204,217,196,208,8,155,131,40,27,0,55,24, + 76,18,182,240,193,32,225,202,193,201,193,201,193,201,65,194, + 201,65,194,201,57,0,56,35,76,18,182,68,118,16,52,50, + 51,52,50,52,50,52,50,52,51,50,101,117,16,51,52,49, + 230,217,196,208,200,193,144,13,0,57,32,76,18,182,99,116, + 32,67,66,65,52,49,230,217,17,5,73,197,1,77,197,228, + 164,213,4,73,201,129,84,17,0,58,10,195,25,158,112,32, + 15,121,32,59,13,35,186,157,112,32,15,121,32,33,65,1, + 60,14,141,49,190,58,88,214,25,37,109,105,167,3,61,11, + 170,184,186,240,192,244,224,192,0,62,13,141,53,186,48,218, + 91,74,178,30,142,2,63,24,107,26,190,99,115,32,66,114, + 16,100,101,68,55,71,70,183,112,123,4,131,139,0,64,65, + 214,150,225,119,32,123,96,88,86,69,74,67,60,66,84,33, + 50,49,116,32,114,179,198,102,104,198,70,104,200,100,104,102, + 98,100,72,104,98,100,102,201,154,37,51,35,19,52,36,7, + 85,51,21,115,244,64,244,64,85,163,7,197,7,129,0,65, + 37,112,22,202,70,76,107,106,57,34,57,50,56,50,55,52, + 54,52,54,52,53,54,52,54,116,80,115,112,50,56,50,56, + 49,234,116,0,66,37,111,26,202,112,64,116,96,50,70,50, + 56,49,56,49,56,49,56,49,55,114,80,115,96,50,56,49, + 233,195,179,138,3,147,3,34,0,67,29,112,22,202,117,119, + 64,84,83,66,71,49,121,60,189,175,41,39,38,39,232,72, + 106,138,14,232,142,0,68,30,112,26,206,112,64,117,96,51, + 86,50,72,49,57,49,121,234,95,94,78,12,82,140,149,28, + 216,28,80,1,69,22,109,26,194,112,80,113,80,49,186,167, + 7,36,7,36,163,251,244,224,65,1,70,17,108,26,190,240, + 129,229,94,30,80,28,80,76,238,47,1,71,35,113,22,206, + 117,120,64,85,83,67,71,50,57,65,61,190,217,1,217,1, + 173,237,233,196,36,5,93,73,205,131,137,169,147,1,72,14, + 111,26,206,48,233,95,30,252,32,210,127,57,73,8,99,26, + 158,240,63,8,74,17,107,22,186,184,255,161,149,87,19,51, + 20,7,50,39,0,75,39,110,26,202,48,119,70,49,69,50, + 68,51,67,52,66,53,65,118,247,32,140,130,106,102,106,104, + 17,205,212,204,216,200,24,197,220,196,28,1,76,12,108,26, + 190,48,185,255,191,60,120,48,77,50,115,26,222,48,125,123, + 16,123,32,121,48,121,64,119,32,33,39,97,49,53,97,34, + 37,98,50,51,98,50,51,98,163,198,102,98,198,102,98,198, + 168,200,168,200,106,202,106,202,106,1,78,39,111,26,206,48, + 121,248,32,238,32,238,64,204,98,202,98,202,100,200,102,198, + 102,198,104,196,74,196,106,194,236,64,238,32,238,32,240,114, + 0,79,29,113,22,206,117,120,64,85,83,67,71,50,57,65, + 121,235,111,47,41,38,71,232,104,90,29,16,94,1,80,23, + 110,26,198,112,64,115,96,49,55,49,232,187,137,3,139,131, + 146,217,253,45,0,81,35,145,246,205,117,120,64,85,83,67, + 71,50,57,65,121,235,111,207,66,40,166,38,70,168,108,138, + 168,14,234,46,230,1,66,0,82,26,110,26,198,112,64,115, + 96,49,55,49,232,187,137,3,139,131,146,49,138,185,137,65, + 127,56,83,32,110,26,198,100,118,48,67,83,65,54,49,55, + 49,75,91,122,16,121,90,75,107,232,238,64,166,228,128,234, + 8,0,84,13,111,18,190,240,3,177,225,253,255,25,0,85, + 19,111,26,206,48,233,255,151,119,20,115,35,53,53,7,100, + 71,0,86,36,112,22,202,48,106,122,72,49,56,66,70,51, + 54,52,54,196,106,104,108,104,140,132,110,100,112,100,112,100, + 210,212,150,152,25,0,87,62,117,22,222,48,54,102,54,102, + 54,102,182,98,168,104,100,168,104,100,72,66,104,100,102,98, + 102,70,102,98,70,104,100,98,100,104,68,70,100,104,98,102, + 98,74,98,102,66,76,98,102,66,172,170,172,170,110,225,220, + 224,220,16,0,88,37,112,22,202,48,122,72,65,70,51,54, + 53,52,55,50,120,16,105,75,76,107,121,16,56,50,55,52, + 69,68,52,54,51,56,65,120,58,89,30,111,22,198,48,121, + 56,49,55,66,54,51,53,68,52,53,51,54,51,55,49,56, + 49,89,90,59,188,207,0,90,21,110,22,194,240,83,74,78, + 41,153,82,50,165,36,29,165,36,61,248,0,91,13,5,119, + 161,112,96,178,255,255,201,193,0,92,18,103,18,162,32,165, + 76,74,153,148,102,82,202,164,148,73,41,93,13,5,123,161, + 112,48,178,255,255,201,129,1,94,19,43,85,187,52,56,87, + 38,33,53,49,179,100,102,98,202,106,0,95,7,78,112,185, + 240,3,96,8,134,244,163,48,180,1,97,30,204,21,186,99, + 117,16,51,67,50,52,57,102,115,32,82,50,65,52,49,53, + 49,68,65,82,114,64,82,50,98,26,108,26,190,48,185,23, + 53,7,35,37,20,68,19,99,126,118,52,81,66,113,48,50, + 81,3,99,21,203,21,182,99,116,16,194,98,200,112,47,135, + 38,72,72,14,130,76,0,100,25,108,22,190,185,55,21,35, + 7,19,36,21,67,103,126,54,49,68,65,82,114,48,83,49, + 101,27,204,21,186,68,118,16,67,66,50,52,49,102,118,240, + 129,228,232,212,4,13,201,129,84,13,0,102,16,103,22,166, + 67,82,50,180,228,224,100,104,255,19,0,103,31,108,118,189, + 83,49,114,48,65,82,49,116,230,103,19,67,20,36,37,7, + 51,21,147,102,71,35,7,67,54,0,104,17,107,26,190,48, + 184,23,52,7,19,52,19,83,254,175,6,105,10,99,26,158, + 112,32,118,240,7,106,13,5,115,157,178,241,200,254,127,114, + 80,1,107,31,107,26,186,48,184,71,19,51,20,35,36,19, + 52,71,86,71,19,52,35,51,35,36,51,20,67,19,67,87, + 3,108,8,99,26,158,240,63,8,109,36,209,25,214,48,65, + 82,114,112,32,65,82,114,52,100,52,100,52,100,52,100,52, + 100,52,100,52,100,52,100,52,100,52,100,180,0,110,16,203, + 25,190,48,81,114,48,65,51,49,229,255,106,0,111,23,204, + 21,186,68,118,16,67,66,50,52,49,230,103,19,67,35,108, + 14,194,136,0,112,27,108,122,189,48,81,115,48,82,66,65, + 52,49,230,103,71,19,37,20,7,35,19,53,147,187,4,113, + 25,108,118,189,83,49,114,48,65,82,49,116,230,103,19,67, + 20,36,37,7,51,21,147,123,114,13,199,25,170,48,113,240, + 102,104,255,8,0,115,25,203,21,182,98,116,16,194,98,104, + 98,208,236,32,204,240,202,234,134,226,64,230,4,0,116,15, + 71,22,166,50,180,201,193,201,208,254,81,13,1,117,16,203, + 25,190,48,229,255,136,98,164,194,98,102,100,0,118,26,204, + 21,186,48,230,108,98,104,100,104,100,104,102,100,104,100,104, + 100,202,204,142,144,17,0,119,43,211,17,206,48,53,101,181, + 66,106,74,100,166,102,100,166,102,70,133,140,144,200,196,136, + 208,196,86,18,50,18,98,53,101,53,117,83,131,83,131,83, + 67,0,120,26,203,21,182,48,117,67,49,179,98,232,170,110, + 174,172,106,98,134,130,100,102,130,230,106,0,121,32,109,118, + 189,48,103,55,49,54,65,52,51,52,67,66,52,50,53,50, + 102,103,88,72,186,114,116,114,176,144,14,0,122,19,203,21, + 182,240,65,220,58,50,186,57,50,186,117,116,7,15,2,123, + 15,7,119,169,52,179,104,191,89,52,181,104,191,90,124,8, + 2,127,157,240,15,12,125,16,7,123,169,48,181,104,191,90, + 52,179,104,191,89,4,126,13,139,180,186,65,115,48,97,113, + 48,67,1,0,0}; + + +uint8_t u8x8_gpio_and_delay_arduino(u8x8_t *u8g2, uint8_t msg, uint8_t arg_int, void *arg_ptr) +{ + switch(msg) + { + case U8X8_MSG_GPIO_AND_DELAY_INIT: + pinMode(8, OUTPUT); + pinMode(9, OUTPUT); + pinMode(10, OUTPUT); + pinMode(11, OUTPUT); + pinMode(13, OUTPUT); + break; + + case U8X8_MSG_DELAY_MILLI: + delay(arg_int); + break; + + case U8X8_MSG_GPIO_DC: + digitalWrite(9, arg_int); + break; + + case U8X8_MSG_GPIO_CS: + digitalWrite(10, arg_int); + break; + + case U8X8_MSG_GPIO_RESET: + digitalWrite(8, arg_int); + break; + + case U8X8_MSG_GPIO_CLOCK: + digitalWrite(13, arg_int); + break; + + case U8X8_MSG_GPIO_DATA: + digitalWrite(11, arg_int); + break; + + default: + return 0; + } + return 1; +} + + + +uint8_t u8x8_byte_arduino_hw_spi(u8x8_t *u8g2, uint8_t msg, uint8_t arg_int, void *arg_ptr) +{ + uint8_t *data; + + switch(msg) + { + case U8X8_MSG_BYTE_SEND: + + data = (uint8_t *)arg_ptr; + while( arg_int > 0 ) + { + SPI.transfer((uint8_t)*data); + data++; + arg_int--; + } + break; + case U8X8_MSG_BYTE_INIT: + /* disable chipselect */ + u8x8_gpio_SetCS(u8g2, u8g2->display_info->chip_disable_level); + /* no wait required here */ + + /* for SPI: setup correct level of the clock signal */ + digitalWrite(13, u8g2->display_info->sck_takeover_edge); + break; + case U8X8_MSG_BYTE_SET_DC: + u8x8_gpio_SetDC(u8g2, arg_int); + break; + case U8X8_MSG_BYTE_START_TRANSFER: + SPI.begin(); + SPI.setClockDivider( SPI_CLOCK_DIV2 ); + SPI.setDataMode(SPI_MODE0); + SPI.setBitOrder(MSBFIRST); + + u8x8_gpio_SetCS(u8g2, u8g2->display_info->chip_enable_level); + u8g2->gpio_and_delay_cb(u8g2, U8X8_MSG_DELAY_NANO, u8g2->display_info->post_chip_enable_wait_ns, NULL); + break; + case U8X8_MSG_BYTE_END_TRANSFER: + u8g2->gpio_and_delay_cb(u8g2, U8X8_MSG_DELAY_NANO, u8g2->display_info->pre_chip_disable_wait_ns, NULL); + u8x8_gpio_SetCS(u8g2, u8g2->display_info->chip_disable_level); + SPI.end(); + break; + case U8X8_MSG_BYTE_SET_I2C_ADR: + break; + case U8X8_MSG_BYTE_SET_DEVICE: + break; + default: + return 0; + } + return 1; +} + +void u8x8_Setup_UC1701_DOGS102(u8x8_t *u8x8) +{ + /* setup defaults */ + u8x8_SetupDefaults(u8x8); + + /* setup specific callbacks */ + u8x8->display_cb = u8x8_d_uc1701_dogs102; + u8x8->cad_cb = u8x8_cad_001; + u8x8->byte_cb = u8x8_byte_8bit_sw_spi; + u8x8->gpio_and_delay_cb = u8x8_gpio_and_delay_arduino; + + /* setup display info */ + u8x8_display_Setup(u8x8); +} + +void u8x8_Setup_SSD1306_128x64_NONAME(u8x8_t *u8x8) +{ + /* setup defaults */ + u8x8_SetupDefaults(u8x8); + + /* setup specific callbacks */ + u8x8->display_cb = u8x8_d_ssd1306_128x64_noname; + u8x8->cad_cb = u8x8_cad_001; + u8x8->byte_cb = u8x8_byte_arduino_hw_spi; + //u8x8->byte_cb = u8x8_byte_8bit_sw_spi; + u8x8->gpio_and_delay_cb = u8x8_gpio_and_delay_arduino; + + /* setup display info */ + u8x8_display_Setup(u8x8); +} + +void u8g2_Setup_SSD1306_128x64_NONAME_1(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb) +{ + + static uint8_t buf[128*8]; + + u8x8_Setup_SSD1306_128x64_NONAME(u8g2_GetU8x8(u8g2)); + u8g2_Setup(u8g2, buf, 1, u8g2_cb); +} + + + +u8g2_t u8g2; +uint8_t tile[8] = { 0x0f, 0x0f, 0x0f, 0x0f, 0xf0, 0xf0, 0xf0, 0xf0 }; + +void setup(void) +{ + //u8x8_Setup_UC1701_DOGS102(&u8g2); + u8g2_Setup_SSD1306_128x64_NONAME_1(&u8g2, &u8g2_cb_r0); + u8x8_display_Init(u8g2_GetU8x8(&u8g2)); + u8x8_display_SetPowerSave(u8g2_GetU8x8(&u8g2), 0); + u8g2_SetFont(&u8g2, u8g2_font_helvB18_tr); +} + +void loop(void) +{ + static u8g2_uint_t x = 50; + static u8g2_uint_t y = 30; + uint8_t i; + + //u8x8_display_Init(&u8g2); + //u8x8_display_SetFlipMode(&u8g2, 1); + + + for(;;) + { + //u8x8_display_ClearScreen(&u8g2); + //u8x8_display_SetPowerSave(&u8g2, 0); + //u8x8_display_SetContrast(&u8g2, 10); + + delay(500); + + //u8x8_Set8x8Font(&u8g2, bdf_font); + //u8x8_Draw8x8String(&u8g2, 0, 0, "Hello gAjByCD"); + u8g2_FirstPage(&u8g2); + i = 0; + do + { + u8g2_SetFontDirection(&u8g2, 0); + u8g2_DrawString(&u8g2, x, y, "ABC"); + u8g2_SetFontDirection(&u8g2, 1); + u8g2_DrawString(&u8g2, x, y, "abc"); + u8g2_SetFontDirection(&u8g2, 2); + u8g2_DrawString(&u8g2, x, y, "abc"); + u8g2_SetFontDirection(&u8g2, 3); + u8g2_DrawString(&u8g2, x, y, "abc"); + if ( i == 1 ) + { + u8g2_DrawHVLine(&u8g2, u8g2.user_x0, u8g2.user_y0, 1, 0); + u8g2_DrawHVLine(&u8g2, u8g2.user_x0, u8g2.user_y1-1, 1, 0); + u8g2_DrawHVLine(&u8g2, u8g2.user_x1-1, u8g2.user_y1-1, 1, 0); + u8g2_DrawHVLine(&u8g2, u8g2.user_x1-1, u8g2.user_y0, 1, 0); + + } + + i++; + + + } while( u8g2_NextPage(&u8g2) ); + + delay(2000); + } +} + diff --git a/u8g2/sys/sdl/common/u8x8_d_sdl_128x64.c b/u8g2/sys/sdl/common/u8x8_d_sdl_128x64.c new file mode 100644 index 00000000..40f700b6 --- /dev/null +++ b/u8g2/sys/sdl/common/u8x8_d_sdl_128x64.c @@ -0,0 +1,290 @@ +/* + u8x8_d_sdl_128x64.c +*/ + +#include "u8g2.h" +#include "SDL.h" +#include "SDL_video.h" +#include + +#define HEIGHT (64) +#define WIDTH 128 + +SDL_Surface *u8g_sdl_screen; +int u8g_sdl_multiple = 2; +Uint32 u8g_sdl_color[256]; + +void u8g_sdl_set_pixel(int x, int y, int idx) +{ + Uint32 *ptr; + Uint32 offset; + int i, j; + + if ( y >= HEIGHT ) + return; + if ( y < 0 ) + return; + if ( x >= WIDTH ) + return; + if ( x < 0 ) + return; + + for( i = 0; i < u8g_sdl_multiple; i++ ) + for( j = 0; j < u8g_sdl_multiple; j++ ) + { + offset = + (y * u8g_sdl_multiple + j) * u8g_sdl_screen->w * u8g_sdl_screen->format->BytesPerPixel + + (x * u8g_sdl_multiple + i) * u8g_sdl_screen->format->BytesPerPixel; + assert( offset < u8g_sdl_screen->w * u8g_sdl_screen->h * u8g_sdl_screen->format->BytesPerPixel ); + ptr = u8g_sdl_screen->pixels + offset; + *ptr = u8g_sdl_color[idx]; + } +} + +void u8g_sdl_set_8pixel(int x, int y, uint8_t pixel) +{ + int cnt = 8; + while( cnt > 0 ) + { + if ( (pixel & 1) == 0 ) + { + u8g_sdl_set_pixel(x,y,0); + } + else + { + u8g_sdl_set_pixel(x,y,3); + } + pixel >>= 1; + y++; + cnt--; + } +} + +void u8g_sdl_set_multiple_8pixel(int x, int y, int cnt, uint8_t *pixel) +{ + uint8_t b; + while( cnt > 0 ) + { + b = *pixel; + u8g_sdl_set_8pixel(x, y, b); + x++; + pixel++; + cnt--; + } +} + + +#define W(x,w) (((x)*(w))/100) + +void u8g_sdl_init(void) +{ + if (SDL_Init(SDL_INIT_VIDEO) != 0) + { + printf("Unable to initialize SDL: %s\n", SDL_GetError()); + exit(1); + } + + /* http://www.libsdl.org/cgi/docwiki.cgi/SDL_SetVideoMode */ + u8g_sdl_screen = SDL_SetVideoMode(WIDTH*u8g_sdl_multiple,HEIGHT*u8g_sdl_multiple,32,SDL_SWSURFACE|SDL_ANYFORMAT); + if ( u8g_sdl_screen == NULL ) + { + printf("Couldn't set video mode: %s\n", SDL_GetError()); + exit(1); + } + //printf("%d bits-per-pixel mode\n", u8g_sdl_screen->format->BitsPerPixel); + //printf("%d bytes-per-pixel mode\n", u8g_sdl_screen->format->BytesPerPixel); + + u8g_sdl_color[0] = SDL_MapRGB( u8g_sdl_screen->format, 0, 0, 0 ); + u8g_sdl_color[1] = SDL_MapRGB( u8g_sdl_screen->format, W(100, 50), W(255,50), 0 ); + u8g_sdl_color[2] = SDL_MapRGB( u8g_sdl_screen->format, W(100, 80), W(255,80), 0 ); + u8g_sdl_color[3] = SDL_MapRGB( u8g_sdl_screen->format, 100, 255, 0 ); + + /* + u8g_sdl_set_pixel(0,0); + u8g_sdl_set_pixel(1,1); + u8g_sdl_set_pixel(2,2); + */ + + /* update all */ + /* http://www.libsdl.org/cgi/docwiki.cgi/SDL_UpdateRect */ + SDL_UpdateRect(u8g_sdl_screen, 0,0,0,0); + + atexit(SDL_Quit); + return; +} + +/* return ascii key value or -1 */ +int u8g_sdl_get_key(void) +{ + SDL_Event event; + /* http://www.libsdl.org/cgi/docwiki.cgi/SDL_PollEvent */ + if ( SDL_PollEvent(&event) != 0 ) + { + switch (event.type) + { + case SDL_QUIT: + exit(0); + break; + case SDL_KEYDOWN: + switch( event.key.keysym.sym ) + { + /* /usr/include/SDL/SDL_keysym.h */ + case SDLK_a: return 'a'; + case SDLK_b: return 'b'; + case SDLK_c: return 'c'; + case SDLK_d: return 'd'; + case SDLK_e: return 'e'; + case SDLK_f: return 'f'; + case SDLK_g: return 'g'; + case SDLK_h: return 'h'; + case SDLK_i: return 'i'; + case SDLK_j: return 'j'; + case SDLK_k: return 'k'; + case SDLK_l: return 'l'; + case SDLK_m: return 'm'; + case SDLK_n: return 'n'; + case SDLK_o: return 'o'; + case SDLK_p: return 'p'; + case SDLK_q: return 'q'; + case SDLK_r: return 'r'; + case SDLK_s: return 's'; + case SDLK_t: return 't'; + case SDLK_u: return 'u'; + case SDLK_v: return 'v'; + case SDLK_w: return 'w'; + case SDLK_x: return 'x'; + case SDLK_y: return 'y'; + case SDLK_z: return 'z'; + case SDLK_SPACE: return ' '; + case SDLK_UP: return 273; + case SDLK_DOWN: return 274; + case SDLK_RIGHT: return 275; + case SDLK_LEFT: return 276; + + default: return 0; + } + } + } + return -1; +} + + +/* +void main(void) +{ + u8g_sdl_init(); + u8g_sdl_set_pixel(0,0,3); + u8g_sdl_set_pixel(0,1,3); + u8g_sdl_set_pixel(0,2,3); + u8g_sdl_set_pixel(1,1,3); + u8g_sdl_set_pixel(2,2,3); + while( u8g_sdl_get_key() < 0 ) + ; +} +*/ + +static const u8x8_display_info_t u8x8_sdl_128x64_info = +{ + /* chip_enable_level = */ 0, + /* chip_disable_level = */ 1, + + /* post_chip_enable_wait_ns = */ 0, + /* pre_chip_disable_wait_ns = */ 0, + /* reset_pulse_width_ms = */ 0, + /* post_reset_wait_ms = */ 0, + /* sda_setup_time_ns = */ 0, + /* sck_pulse_width_ns = */ 0, + /* sck_takeover_edge = */ 1, + /* i2c_bus_clock_100kHz = */ 0, + /* data_setup_time_ns = */ 0, + /* write_pulse_width_ns = */ 0, + /* tile_width = */ 16, + /* tile_hight = */ 8, +#if U8X8_DEFAULT_FLIP_MODE == 0 + /* default_x_offset = */ 0, +#else + /* default_x_offset = */ 0, +#endif +}; + + +uint8_t u8x8_d_sdl(u8x8_t *u8g2, uint8_t msg, uint8_t arg_int, void *arg_ptr) +{ + uint8_t x, y, c; + uint8_t *ptr; + switch(msg) + { + case U8X8_MSG_DISPLAY_SETUP: + u8x8_d_helper_display_setup(u8g2, &u8x8_sdl_128x64_info); + break; + case U8X8_MSG_DISPLAY_INIT: + u8x8_d_helper_display_init(u8g2); + u8g_sdl_init(); + break; + case U8X8_MSG_DISPLAY_SET_POWER_SAVE: + break; + case U8X8_MSG_DISPLAY_SET_FLIP_MODE: + break; + case U8X8_MSG_DISPLAY_SET_CONTRAST: + break; + case U8X8_MSG_DISPLAY_DRAW_TILE: + x = ((u8x8_tile_t *)arg_ptr)->x_pos; + x *= 8; + x += u8g2->x_offset; + + y = ((u8x8_tile_t *)arg_ptr)->y_pos; + y *= 8; + + do + { + c = ((u8x8_tile_t *)arg_ptr)->cnt; + ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr; + u8g_sdl_set_multiple_8pixel(x, y, c*8, ptr); + arg_int--; + } while( arg_int > 0 ); + + /* update all */ + /* http://www.libsdl.org/cgi/docwiki.cgi/SDL_UpdateRect */ + SDL_UpdateRect(u8g_sdl_screen, 0,0,0,0); + + break; + default: + return 0; + } + return 1; +} + + +void u8x8_Setup_SDL_128x64(u8x8_t *u8x8) +{ + /* setup defaults */ + u8x8_SetupDefaults(u8x8); + + /* setup specific callbacks */ + u8x8->display_cb = u8x8_d_sdl; + + /* setup display info */ + u8x8_display_Setup(u8x8); +} + +void u8g2_Setup_SDL_128x64(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb) +{ + + static uint8_t buf[128*8]; + + u8x8_Setup_SDL_128x64(u8g2_GetU8x8(u8g2)); + u8g2_Setup(u8g2, buf, 8, u8g2_cb); +} + + +void u8g2_Setup_SDL_128x64_4(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb) +{ + + static uint8_t buf[128*3]; + + u8x8_Setup_SDL_128x64(u8g2_GetU8x8(u8g2)); + u8g2_Setup(u8g2, buf, 3, u8g2_cb); +} + + + diff --git a/u8g2/sys/sdl/hello_world_8x8/Makefile b/u8g2/sys/sdl/hello_world_8x8/Makefile new file mode 100644 index 00000000..9f409a66 --- /dev/null +++ b/u8g2/sys/sdl/hello_world_8x8/Makefile @@ -0,0 +1,12 @@ +CFLAGS = -g -Wall -I../../../csrc/. `sdl-config --cflags` + +SRC = $(shell ls ../../../csrc/*.c) $(shell ls ../common/*.c ) main.c + +OBJ = $(SRC:.c=.o) + +helloworld: $(OBJ) + $(CC) $(CFLAGS) $(LDFLAGS) $(OBJ) `sdl-config --libs` -o u8g2_sdl + +clean: + -rm $(OBJ) u8g2_sdl + diff --git a/u8g2/sys/sdl/hello_world_8x8/main.c b/u8g2/sys/sdl/hello_world_8x8/main.c new file mode 100644 index 00000000..19192023 --- /dev/null +++ b/u8g2/sys/sdl/hello_world_8x8/main.c @@ -0,0 +1,69 @@ + +#include "u8x8.h" + +u8x8_t u8g2; + +const uint8_t bdf_font[762] U8X8_FONT_SECTION("bdf_font") = { + 32,126,0,0,0,0,0,0,0,0,0,0,0,95,95,0, + 0,0,0,7,7,0,7,7,0,0,20,127,127,28,127,127, + 20,0,0,36,42,127,127,42,18,0,70,102,48,24,12,102, + 98,0,48,122,79,93,55,122,72,0,0,0,0,7,7,0, + 0,0,0,0,28,62,99,65,0,0,0,0,65,99,62,28, + 0,0,0,0,0,0,0,0,0,0,0,8,8,62,62,8, + 8,0,0,0,128,224,96,0,0,0,0,8,8,8,8,8, + 8,0,0,0,0,96,96,0,0,0,96,48,24,12,6,3, + 1,0,62,127,81,73,69,127,62,0,0,64,66,127,127,64, + 64,0,0,114,123,73,73,111,102,0,0,34,97,73,73,127, + 54,0,24,20,82,127,127,80,16,0,0,39,111,73,73,121, + 51,0,0,62,127,73,73,123,50,0,0,3,1,113,125,15, + 7,0,0,54,127,73,73,127,54,0,0,38,111,73,73,127, + 62,0,0,0,0,108,108,0,0,0,0,0,128,236,108,0, + 0,0,0,8,28,54,99,65,0,0,0,36,36,36,36,36, + 36,0,0,65,99,54,28,8,0,0,0,2,3,81,89,15, + 6,0,62,127,65,93,93,95,30,0,0,124,126,19,19,126, + 124,0,65,127,127,73,73,127,54,0,28,62,99,65,65,99, + 34,0,65,127,127,65,99,62,28,0,65,127,127,73,93,65, + 99,0,65,127,127,73,29,1,3,0,60,126,67,65,81,115, + 114,0,0,127,127,8,8,127,127,0,0,65,65,127,127,65, + 65,0,48,112,64,65,127,63,1,0,65,127,127,8,28,119, + 99,0,65,127,127,65,64,96,112,0,127,127,14,28,14,127, + 127,0,127,127,6,12,24,127,127,0,28,62,99,65,99,62, + 28,0,65,127,127,73,9,7,6,0,60,126,67,81,51,110, + 92,0,65,127,127,9,25,63,102,0,0,38,111,73,73,123, + 50,0,0,3,65,127,127,65,3,0,0,63,127,64,64,127, + 63,0,0,31,63,96,96,63,31,0,127,127,48,24,48,127, + 127,0,97,115,30,12,30,115,97,0,0,7,79,120,120,79, + 7,0,71,99,113,89,77,103,115,0,0,0,127,127,65,65, + 0,0,1,3,6,12,24,48,96,0,0,0,65,65,127,127, + 0,0,8,12,6,3,6,12,8,0,0,0,0,0,0,0, + 0,0,0,0,2,6,12,8,0,0,32,116,84,84,60,120, + 64,0,67,63,127,68,68,124,56,0,0,56,124,68,68,108, + 40,0,56,124,68,69,63,127,64,0,0,56,124,84,84,92, + 24,0,0,72,126,127,73,3,2,0,0,152,188,164,164,252, + 124,0,65,127,127,8,4,124,120,0,0,0,68,125,125,64, + 0,0,0,96,224,128,132,252,125,0,65,127,127,16,56,108, + 68,0,0,0,65,127,127,64,0,0,120,124,12,56,12,124, + 120,0,4,124,120,4,4,120,120,0,0,56,124,68,68,124, + 56,0,132,252,248,164,36,60,24,0,24,60,36,164,248,252, + 132,0,68,124,120,68,12,8,0,0,0,72,92,84,84,116, + 32,0,0,4,63,127,68,100,32,0,0,60,124,64,64,124, + 124,0,0,28,60,96,96,60,28,0,60,124,96,56,96,124, + 60,0,68,108,56,16,56,108,68,0,0,156,188,160,160,252, + 124,0,0,76,100,116,92,76,68,0,0,65,65,119,62,8, + 8,0,0,0,0,127,127,0,0,0,0,8,8,62,119,65, + 65,0,2,3,1,3,2,1,1,0}; + + +int main(void) +{ + u8x8_Setup_SDL_128x64(&u8g2); + u8x8_display_Init(&u8g2); + + u8x8_Set8x8Font(&u8g2, bdf_font); + u8x8_Draw8x8String(&u8g2, 0, 0, "Hello World!"); + + while( u8g_sdl_get_key() < 0 ) + ; + return 0; +} + diff --git a/u8g2/sys/sdl/hvline/Makefile b/u8g2/sys/sdl/hvline/Makefile new file mode 100644 index 00000000..9f409a66 --- /dev/null +++ b/u8g2/sys/sdl/hvline/Makefile @@ -0,0 +1,12 @@ +CFLAGS = -g -Wall -I../../../csrc/. `sdl-config --cflags` + +SRC = $(shell ls ../../../csrc/*.c) $(shell ls ../common/*.c ) main.c + +OBJ = $(SRC:.c=.o) + +helloworld: $(OBJ) + $(CC) $(CFLAGS) $(LDFLAGS) $(OBJ) `sdl-config --libs` -o u8g2_sdl + +clean: + -rm $(OBJ) u8g2_sdl + diff --git a/u8g2/sys/sdl/hvline/main.c b/u8g2/sys/sdl/hvline/main.c new file mode 100644 index 00000000..e8937ba6 --- /dev/null +++ b/u8g2/sys/sdl/hvline/main.c @@ -0,0 +1,105 @@ + +#include "u8x8.h" + + +const uint8_t bdf_font[762] U8X8_FONT_SECTION("bdf_font") = { + 32,126,0,0,0,0,0,0,0,0,0,0,0,95,95,0, + 0,0,0,7,7,0,7,7,0,0,20,127,127,28,127,127, + 20,0,0,36,42,127,127,42,18,0,70,102,48,24,12,102, + 98,0,48,122,79,93,55,122,72,0,0,0,0,7,7,0, + 0,0,0,0,28,62,99,65,0,0,0,0,65,99,62,28, + 0,0,0,0,0,0,0,0,0,0,0,8,8,62,62,8, + 8,0,0,0,128,224,96,0,0,0,0,8,8,8,8,8, + 8,0,0,0,0,96,96,0,0,0,96,48,24,12,6,3, + 1,0,62,127,81,73,69,127,62,0,0,64,66,127,127,64, + 64,0,0,114,123,73,73,111,102,0,0,34,97,73,73,127, + 54,0,24,20,82,127,127,80,16,0,0,39,111,73,73,121, + 51,0,0,62,127,73,73,123,50,0,0,3,1,113,125,15, + 7,0,0,54,127,73,73,127,54,0,0,38,111,73,73,127, + 62,0,0,0,0,108,108,0,0,0,0,0,128,236,108,0, + 0,0,0,8,28,54,99,65,0,0,0,36,36,36,36,36, + 36,0,0,65,99,54,28,8,0,0,0,2,3,81,89,15, + 6,0,62,127,65,93,93,95,30,0,0,124,126,19,19,126, + 124,0,65,127,127,73,73,127,54,0,28,62,99,65,65,99, + 34,0,65,127,127,65,99,62,28,0,65,127,127,73,93,65, + 99,0,65,127,127,73,29,1,3,0,60,126,67,65,81,115, + 114,0,0,127,127,8,8,127,127,0,0,65,65,127,127,65, + 65,0,48,112,64,65,127,63,1,0,65,127,127,8,28,119, + 99,0,65,127,127,65,64,96,112,0,127,127,14,28,14,127, + 127,0,127,127,6,12,24,127,127,0,28,62,99,65,99,62, + 28,0,65,127,127,73,9,7,6,0,60,126,67,81,51,110, + 92,0,65,127,127,9,25,63,102,0,0,38,111,73,73,123, + 50,0,0,3,65,127,127,65,3,0,0,63,127,64,64,127, + 63,0,0,31,63,96,96,63,31,0,127,127,48,24,48,127, + 127,0,97,115,30,12,30,115,97,0,0,7,79,120,120,79, + 7,0,71,99,113,89,77,103,115,0,0,0,127,127,65,65, + 0,0,1,3,6,12,24,48,96,0,0,0,65,65,127,127, + 0,0,8,12,6,3,6,12,8,0,0,0,0,0,0,0, + 0,0,0,0,2,6,12,8,0,0,32,116,84,84,60,120, + 64,0,67,63,127,68,68,124,56,0,0,56,124,68,68,108, + 40,0,56,124,68,69,63,127,64,0,0,56,124,84,84,92, + 24,0,0,72,126,127,73,3,2,0,0,152,188,164,164,252, + 124,0,65,127,127,8,4,124,120,0,0,0,68,125,125,64, + 0,0,0,96,224,128,132,252,125,0,65,127,127,16,56,108, + 68,0,0,0,65,127,127,64,0,0,120,124,12,56,12,124, + 120,0,4,124,120,4,4,120,120,0,0,56,124,68,68,124, + 56,0,132,252,248,164,36,60,24,0,24,60,36,164,248,252, + 132,0,68,124,120,68,12,8,0,0,0,72,92,84,84,116, + 32,0,0,4,63,127,68,100,32,0,0,60,124,64,64,124, + 124,0,0,28,60,96,96,60,28,0,60,124,96,56,96,124, + 60,0,68,108,56,16,56,108,68,0,0,156,188,160,160,252, + 124,0,0,76,100,116,92,76,68,0,0,65,65,119,62,8, + 8,0,0,0,0,127,127,0,0,0,0,8,8,62,119,65, + 65,0,2,3,1,3,2,1,1,0}; + +u8g2_t u8g2; + +int main(void) +{ + u8g2_Setup_SDL_128x64(&u8g2, &u8g2_cb_r0); + + u8x8_display_Init(u8g2_GetU8x8(&u8g2)); + u8x8_display_SetPowerSave(u8g2_GetU8x8(&u8g2), 0); + + + u8g2_DrawHVLine(&u8g2, 5, 20, 40, 0); + u8g2_DrawHVLine(&u8g2, 5, 22, 40, 0); + u8g2_DrawHVLine(&u8g2, 5, 24, 40, 0); + + u8g2_DrawHVLine(&u8g2, 5, 24, 40, 1); + + /* clipping tests */ + u8g2_DrawHVLine(&u8g2, 60000, 10000, 39, 0); + u8g2_DrawHVLine(&u8g2, 140, 40, 40, 0); + u8g2_DrawHVLine(&u8g2, 120, 41, 40, 0); + u8g2_DrawHVLine(&u8g2, 120, 42, 0xff8f, 0); /* rare case */ + u8g2_DrawHVLine(&u8g2, 120, 43, 6, 0); + + u8g2_DrawHVLine(&u8g2, 0, 40, 10, 0); + u8g2_DrawHVLine(&u8g2, -2, 41, 5, 0); + u8g2_DrawHVLine(&u8g2, -3, 42, 5, 0); + u8g2_DrawHVLine(&u8g2, -8, 43, 5, 0); + u8g2_DrawHVLine(&u8g2, 0, 44, 10, 0); + + + + u8g2_DrawHVLine(&u8g2, 99, 70, 40, 1); + u8g2_DrawHVLine(&u8g2, 98, 60, 40, 1); + u8g2_DrawHVLine(&u8g2, 97, 60, 0xfff0, 1); /* rare case */ + u8g2_DrawHVLine(&u8g2, 96, 60, 3, 1); + + + u8g2_SendBuffer(&u8g2); + + + u8x8_Set8x8Font(u8g2_GetU8x8(&u8g2), bdf_font); + u8x8_Draw8x8String(u8g2_GetU8x8(&u8g2), 0, 0, "Hello World!"); + + + + + while( u8g_sdl_get_key() < 0 ) + ; + return 0; +} + diff --git a/u8g2/sys/sdl/text_full_buffer/Makefile b/u8g2/sys/sdl/text_full_buffer/Makefile new file mode 100644 index 00000000..9f409a66 --- /dev/null +++ b/u8g2/sys/sdl/text_full_buffer/Makefile @@ -0,0 +1,12 @@ +CFLAGS = -g -Wall -I../../../csrc/. `sdl-config --cflags` + +SRC = $(shell ls ../../../csrc/*.c) $(shell ls ../common/*.c ) main.c + +OBJ = $(SRC:.c=.o) + +helloworld: $(OBJ) + $(CC) $(CFLAGS) $(LDFLAGS) $(OBJ) `sdl-config --libs` -o u8g2_sdl + +clean: + -rm $(OBJ) u8g2_sdl + diff --git a/u8g2/sys/sdl/text_full_buffer/main.c b/u8g2/sys/sdl/text_full_buffer/main.c new file mode 100644 index 00000000..6a2054c5 --- /dev/null +++ b/u8g2/sys/sdl/text_full_buffer/main.c @@ -0,0 +1,296 @@ + +#include "u8g2.h" +#include + +const uint8_t bdf_font[762] U8X8_FONT_SECTION("bdf_font") = { + 32,126,0,0,0,0,0,0,0,0,0,0,0,95,95,0, + 0,0,0,7,7,0,7,7,0,0,20,127,127,28,127,127, + 20,0,0,36,42,127,127,42,18,0,70,102,48,24,12,102, + 98,0,48,122,79,93,55,122,72,0,0,0,0,7,7,0, + 0,0,0,0,28,62,99,65,0,0,0,0,65,99,62,28, + 0,0,0,0,0,0,0,0,0,0,0,8,8,62,62,8, + 8,0,0,0,128,224,96,0,0,0,0,8,8,8,8,8, + 8,0,0,0,0,96,96,0,0,0,96,48,24,12,6,3, + 1,0,62,127,81,73,69,127,62,0,0,64,66,127,127,64, + 64,0,0,114,123,73,73,111,102,0,0,34,97,73,73,127, + 54,0,24,20,82,127,127,80,16,0,0,39,111,73,73,121, + 51,0,0,62,127,73,73,123,50,0,0,3,1,113,125,15, + 7,0,0,54,127,73,73,127,54,0,0,38,111,73,73,127, + 62,0,0,0,0,108,108,0,0,0,0,0,128,236,108,0, + 0,0,0,8,28,54,99,65,0,0,0,36,36,36,36,36, + 36,0,0,65,99,54,28,8,0,0,0,2,3,81,89,15, + 6,0,62,127,65,93,93,95,30,0,0,124,126,19,19,126, + 124,0,65,127,127,73,73,127,54,0,28,62,99,65,65,99, + 34,0,65,127,127,65,99,62,28,0,65,127,127,73,93,65, + 99,0,65,127,127,73,29,1,3,0,60,126,67,65,81,115, + 114,0,0,127,127,8,8,127,127,0,0,65,65,127,127,65, + 65,0,48,112,64,65,127,63,1,0,65,127,127,8,28,119, + 99,0,65,127,127,65,64,96,112,0,127,127,14,28,14,127, + 127,0,127,127,6,12,24,127,127,0,28,62,99,65,99,62, + 28,0,65,127,127,73,9,7,6,0,60,126,67,81,51,110, + 92,0,65,127,127,9,25,63,102,0,0,38,111,73,73,123, + 50,0,0,3,65,127,127,65,3,0,0,63,127,64,64,127, + 63,0,0,31,63,96,96,63,31,0,127,127,48,24,48,127, + 127,0,97,115,30,12,30,115,97,0,0,7,79,120,120,79, + 7,0,71,99,113,89,77,103,115,0,0,0,127,127,65,65, + 0,0,1,3,6,12,24,48,96,0,0,0,65,65,127,127, + 0,0,8,12,6,3,6,12,8,0,0,0,0,0,0,0, + 0,0,0,0,2,6,12,8,0,0,32,116,84,84,60,120, + 64,0,67,63,127,68,68,124,56,0,0,56,124,68,68,108, + 40,0,56,124,68,69,63,127,64,0,0,56,124,84,84,92, + 24,0,0,72,126,127,73,3,2,0,0,152,188,164,164,252, + 124,0,65,127,127,8,4,124,120,0,0,0,68,125,125,64, + 0,0,0,96,224,128,132,252,125,0,65,127,127,16,56,108, + 68,0,0,0,65,127,127,64,0,0,120,124,12,56,12,124, + 120,0,4,124,120,4,4,120,120,0,0,56,124,68,68,124, + 56,0,132,252,248,164,36,60,24,0,24,60,36,164,248,252, + 132,0,68,124,120,68,12,8,0,0,0,72,92,84,84,116, + 32,0,0,4,63,127,68,100,32,0,0,60,124,64,64,124, + 124,0,0,28,60,96,96,60,28,0,60,124,96,56,96,124, + 60,0,68,108,56,16,56,108,68,0,0,156,188,160,160,252, + 124,0,0,76,100,116,92,76,68,0,0,65,65,119,62,8, + 8,0,0,0,0,127,127,0,0,0,0,8,8,62,119,65, + 65,0,2,3,1,3,2,1,1,0}; + +const uint8_t u8g2_font_helvB18_tr[2245] U8X8_FONT_SECTION("u8g2_font_helvB18_tr") = { + 95,0,4,3,5,5,3,5,6,23,24,0,251,19,251,19, + 251,2,234,6,37,32,6,0,48,154,0,33,10,99,26,158, + 240,23,234,14,4,34,11,197,184,167,32,193,139,145,8,0, + 35,42,76,22,186,36,34,38,34,38,34,38,34,38,34,115, + 64,113,64,35,34,38,34,38,34,38,34,115,64,113,64,35, + 34,38,34,38,34,38,34,38,34,4,36,39,172,210,181,37, + 119,116,48,65,33,177,68,196,68,228,66,204,174,146,178,206, + 76,226,68,196,68,196,68,228,66,130,226,96,232,78,84,10, + 0,37,49,85,18,218,61,87,54,118,52,54,179,76,74,100, + 78,74,100,110,102,98,242,100,180,100,30,102,30,100,166,116, + 228,112,100,102,110,68,74,108,70,74,108,102,213,212,217,88, + 9,0,38,38,80,22,202,84,122,72,65,55,51,55,51,55, + 51,56,49,218,244,100,134,130,98,102,230,100,170,102,108,104, + 170,134,230,129,200,144,209,0,39,8,194,184,155,112,64,1, + 40,22,6,119,161,36,51,50,51,50,51,35,179,255,72,104, + 102,104,102,104,72,0,41,22,6,119,161,32,180,102,104,102, + 72,104,102,255,70,102,201,204,200,140,16,0,42,16,232,148, + 171,35,38,35,33,113,48,66,35,162,5,0,43,14,140,53, + 190,37,170,171,131,7,83,162,186,2,44,10,195,184,157,112, + 32,33,65,1,45,7,103,208,162,240,1,46,7,99,24,158, + 112,32,47,18,103,22,162,165,145,148,34,41,141,164,20,73, + 41,146,82,5,48,27,76,18,182,99,117,16,67,66,50,52, + 50,52,49,230,159,77,12,141,12,141,176,57,136,178,1,49, + 12,71,26,182,180,230,224,128,104,255,15,50,27,76,18,182, + 83,117,32,51,67,49,53,49,102,54,57,56,72,199,172,140, + 142,225,228,193,131,1,51,31,76,18,182,83,117,32,179,100, + 106,98,106,98,106,114,112,172,238,114,116,210,204,138,98,134, + 228,96,200,6,0,52,27,76,18,182,55,200,174,153,196,212, + 196,148,200,144,204,54,66,35,67,35,7,15,230,38,55,1, + 53,30,76,18,182,113,48,114,48,50,185,229,65,208,129,204, + 12,229,232,228,164,153,213,65,12,201,129,148,13,0,54,32, + 76,18,182,84,117,32,66,51,50,101,102,185,130,232,96,164, + 132,130,104,98,204,217,196,208,8,155,131,40,27,0,55,24, + 76,18,182,240,193,32,225,202,193,201,193,201,193,201,65,194, + 201,65,194,201,57,0,56,35,76,18,182,68,118,16,52,50, + 51,52,50,52,50,52,50,52,51,50,101,117,16,51,52,49, + 230,217,196,208,200,193,144,13,0,57,32,76,18,182,99,116, + 32,67,66,65,52,49,230,217,17,5,73,197,1,77,197,228, + 164,213,4,73,201,129,84,17,0,58,10,195,25,158,112,32, + 15,121,32,59,13,35,186,157,112,32,15,121,32,33,65,1, + 60,14,141,49,190,58,88,214,25,37,109,105,167,3,61,11, + 170,184,186,240,192,244,224,192,0,62,13,141,53,186,48,218, + 91,74,178,30,142,2,63,24,107,26,190,99,115,32,66,114, + 16,100,101,68,55,71,70,183,112,123,4,131,139,0,64,65, + 214,150,225,119,32,123,96,88,86,69,74,67,60,66,84,33, + 50,49,116,32,114,179,198,102,104,198,70,104,200,100,104,102, + 98,100,72,104,98,100,102,201,154,37,51,35,19,52,36,7, + 85,51,21,115,244,64,244,64,85,163,7,197,7,129,0,65, + 37,112,22,202,70,76,107,106,57,34,57,50,56,50,55,52, + 54,52,54,52,53,54,52,54,116,80,115,112,50,56,50,56, + 49,234,116,0,66,37,111,26,202,112,64,116,96,50,70,50, + 56,49,56,49,56,49,56,49,55,114,80,115,96,50,56,49, + 233,195,179,138,3,147,3,34,0,67,29,112,22,202,117,119, + 64,84,83,66,71,49,121,60,189,175,41,39,38,39,232,72, + 106,138,14,232,142,0,68,30,112,26,206,112,64,117,96,51, + 86,50,72,49,57,49,121,234,95,94,78,12,82,140,149,28, + 216,28,80,1,69,22,109,26,194,112,80,113,80,49,186,167, + 7,36,7,36,163,251,244,224,65,1,70,17,108,26,190,240, + 129,229,94,30,80,28,80,76,238,47,1,71,35,113,22,206, + 117,120,64,85,83,67,71,50,57,65,61,190,217,1,217,1, + 173,237,233,196,36,5,93,73,205,131,137,169,147,1,72,14, + 111,26,206,48,233,95,30,252,32,210,127,57,73,8,99,26, + 158,240,63,8,74,17,107,22,186,184,255,161,149,87,19,51, + 20,7,50,39,0,75,39,110,26,202,48,119,70,49,69,50, + 68,51,67,52,66,53,65,118,247,32,140,130,106,102,106,104, + 17,205,212,204,216,200,24,197,220,196,28,1,76,12,108,26, + 190,48,185,255,191,60,120,48,77,50,115,26,222,48,125,123, + 16,123,32,121,48,121,64,119,32,33,39,97,49,53,97,34, + 37,98,50,51,98,50,51,98,163,198,102,98,198,102,98,198, + 168,200,168,200,106,202,106,202,106,1,78,39,111,26,206,48, + 121,248,32,238,32,238,64,204,98,202,98,202,100,200,102,198, + 102,198,104,196,74,196,106,194,236,64,238,32,238,32,240,114, + 0,79,29,113,22,206,117,120,64,85,83,67,71,50,57,65, + 121,235,111,47,41,38,71,232,104,90,29,16,94,1,80,23, + 110,26,198,112,64,115,96,49,55,49,232,187,137,3,139,131, + 146,217,253,45,0,81,35,145,246,205,117,120,64,85,83,67, + 71,50,57,65,121,235,111,207,66,40,166,38,70,168,108,138, + 168,14,234,46,230,1,66,0,82,26,110,26,198,112,64,115, + 96,49,55,49,232,187,137,3,139,131,146,49,138,185,137,65, + 127,56,83,32,110,26,198,100,118,48,67,83,65,54,49,55, + 49,75,91,122,16,121,90,75,107,232,238,64,166,228,128,234, + 8,0,84,13,111,18,190,240,3,177,225,253,255,25,0,85, + 19,111,26,206,48,233,255,151,119,20,115,35,53,53,7,100, + 71,0,86,36,112,22,202,48,106,122,72,49,56,66,70,51, + 54,52,54,196,106,104,108,104,140,132,110,100,112,100,112,100, + 210,212,150,152,25,0,87,62,117,22,222,48,54,102,54,102, + 54,102,182,98,168,104,100,168,104,100,72,66,104,100,102,98, + 102,70,102,98,70,104,100,98,100,104,68,70,100,104,98,102, + 98,74,98,102,66,76,98,102,66,172,170,172,170,110,225,220, + 224,220,16,0,88,37,112,22,202,48,122,72,65,70,51,54, + 53,52,55,50,120,16,105,75,76,107,121,16,56,50,55,52, + 69,68,52,54,51,56,65,120,58,89,30,111,22,198,48,121, + 56,49,55,66,54,51,53,68,52,53,51,54,51,55,49,56, + 49,89,90,59,188,207,0,90,21,110,22,194,240,83,74,78, + 41,153,82,50,165,36,29,165,36,61,248,0,91,13,5,119, + 161,112,96,178,255,255,201,193,0,92,18,103,18,162,32,165, + 76,74,153,148,102,82,202,164,148,73,41,93,13,5,123,161, + 112,48,178,255,255,201,129,1,94,19,43,85,187,52,56,87, + 38,33,53,49,179,100,102,98,202,106,0,95,7,78,112,185, + 240,3,96,8,134,244,163,48,180,1,97,30,204,21,186,99, + 117,16,51,67,50,52,57,102,115,32,82,50,65,52,49,53, + 49,68,65,82,114,64,82,50,98,26,108,26,190,48,185,23, + 53,7,35,37,20,68,19,99,126,118,52,81,66,113,48,50, + 81,3,99,21,203,21,182,99,116,16,194,98,200,112,47,135, + 38,72,72,14,130,76,0,100,25,108,22,190,185,55,21,35, + 7,19,36,21,67,103,126,54,49,68,65,82,114,48,83,49, + 101,27,204,21,186,68,118,16,67,66,50,52,49,102,118,240, + 129,228,232,212,4,13,201,129,84,13,0,102,16,103,22,166, + 67,82,50,180,228,224,100,104,255,19,0,103,31,108,118,189, + 83,49,114,48,65,82,49,116,230,103,19,67,20,36,37,7, + 51,21,147,102,71,35,7,67,54,0,104,17,107,26,190,48, + 184,23,52,7,19,52,19,83,254,175,6,105,10,99,26,158, + 112,32,118,240,7,106,13,5,115,157,178,241,200,254,127,114, + 80,1,107,31,107,26,186,48,184,71,19,51,20,35,36,19, + 52,71,86,71,19,52,35,51,35,36,51,20,67,19,67,87, + 3,108,8,99,26,158,240,63,8,109,36,209,25,214,48,65, + 82,114,112,32,65,82,114,52,100,52,100,52,100,52,100,52, + 100,52,100,52,100,52,100,52,100,52,100,180,0,110,16,203, + 25,190,48,81,114,48,65,51,49,229,255,106,0,111,23,204, + 21,186,68,118,16,67,66,50,52,49,230,103,19,67,35,108, + 14,194,136,0,112,27,108,122,189,48,81,115,48,82,66,65, + 52,49,230,103,71,19,37,20,7,35,19,53,147,187,4,113, + 25,108,118,189,83,49,114,48,65,82,49,116,230,103,19,67, + 20,36,37,7,51,21,147,123,114,13,199,25,170,48,113,240, + 102,104,255,8,0,115,25,203,21,182,98,116,16,194,98,104, + 98,208,236,32,204,240,202,234,134,226,64,230,4,0,116,15, + 71,22,166,50,180,201,193,201,208,254,81,13,1,117,16,203, + 25,190,48,229,255,136,98,164,194,98,102,100,0,118,26,204, + 21,186,48,230,108,98,104,100,104,100,104,102,100,104,100,104, + 100,202,204,142,144,17,0,119,43,211,17,206,48,53,101,181, + 66,106,74,100,166,102,100,166,102,70,133,140,144,200,196,136, + 208,196,86,18,50,18,98,53,101,53,117,83,131,83,131,83, + 67,0,120,26,203,21,182,48,117,67,49,179,98,232,170,110, + 174,172,106,98,134,130,100,102,130,230,106,0,121,32,109,118, + 189,48,103,55,49,54,65,52,51,52,67,66,52,50,53,50, + 102,103,88,72,186,114,116,114,176,144,14,0,122,19,203,21, + 182,240,65,220,58,50,186,57,50,186,117,116,7,15,2,123, + 15,7,119,169,52,179,104,191,89,52,181,104,191,90,124,8, + 2,127,157,240,15,12,125,16,7,123,169,48,181,104,191,90, + 52,179,104,191,89,4,126,13,139,180,186,65,115,48,97,113, + 48,67,1,0,0}; + +u8g2_t u8g2; + +int main(void) +{ + int x, y; + int k; + + u8g2_Setup_SDL_128x64(&u8g2, &u8g2_cb_r0); + u8x8_display_Init(u8g2_GetU8x8(&u8g2)); + u8x8_display_SetPowerSave(u8g2_GetU8x8(&u8g2), 0); + u8g2_SetFont(&u8g2, u8g2_font_helvB18_tr); + + x = 50; + y = 30; + + + for(;;) + { +#ifdef U8G2_WITH_HVLINE_COUNT + u8g2.hv_cnt = 0UL; +#endif /* U8G2_WITH_HVLINE_COUNT */ + + u8g2_ClearBuffer(&u8g2); + + u8g2_SetFontDirection(&u8g2, 0); + u8g2_DrawString(&u8g2, x, y, "A"); + u8g2_SetFontDirection(&u8g2, 1); + u8g2_DrawString(&u8g2, x, y, "a"); + u8g2_SetFontDirection(&u8g2, 2); + u8g2_DrawString(&u8g2, x, y, "a"); + u8g2_SetFontDirection(&u8g2, 3); + u8g2_DrawString(&u8g2, x, y, "a"); + + u8g2_DrawHVLine(&u8g2, u8g2.user_x0, u8g2.user_y0, 1, 0); + u8g2_DrawHVLine(&u8g2, u8g2.user_x0, u8g2.user_y1-1, 1, 0); + u8g2_DrawHVLine(&u8g2, u8g2.user_x1-1, u8g2.user_y1-1, 1, 0); + u8g2_DrawHVLine(&u8g2, u8g2.user_x1-1, u8g2.user_y0, 1, 0); + + u8g2_SendBuffer(&u8g2); +/* + u8g2_FirstPage(&u8g2); + i = 0; + do + { + u8g2_SetFontDirection(&u8g2, 0); + u8g2_DrawString(&u8g2, x, y, "ABC"); + u8g2_SetFontDirection(&u8g2, 1); + u8g2_DrawString(&u8g2, x, y, "abc"); + u8g2_SetFontDirection(&u8g2, 2); + u8g2_DrawString(&u8g2, x, y, "abc"); + u8g2_SetFontDirection(&u8g2, 3); + u8g2_DrawString(&u8g2, x, y, "abc"); + if ( i == 1 ) + { + u8g2_DrawHVLine(&u8g2, u8g2.user_x0, u8g2.user_y0, 1, 0); + u8g2_DrawHVLine(&u8g2, u8g2.user_x0, u8g2.user_y1-1, 1, 0); + u8g2_DrawHVLine(&u8g2, u8g2.user_x1-1, u8g2.user_y1-1, 1, 0); + u8g2_DrawHVLine(&u8g2, u8g2.user_x1-1, u8g2.user_y0, 1, 0); + + } + + i++; + + + } while( u8g2_NextPage(&u8g2) ); +*/ +#ifdef U8G2_WITH_HVLINE_COUNT + printf("hv cnt: %ld\n", u8g2.hv_cnt); +#endif /* U8G2_WITH_HVLINE_COUNT */ + + do + { + k = u8g_sdl_get_key(); + } while( k < 0 ); + + if ( k == 273 ) y -= 7; + if ( k == 274 ) y += 7; + if ( k == 276 ) x -= 7; + if ( k == 275 ) x += 7; + + if ( k == 'e' ) y -= 1; + if ( k == 'x' ) y += 1; + if ( k == 's' ) x -= 1; + if ( k == 'd' ) x += 1; + if ( k == 'q' ) break; + + } + + //u8x8_Set8x8Font(u8g2_GetU8x8(&u8g2), bdf_font); + //u8x8_Draw8x8String(u8g2_GetU8x8(&u8g2), 0, 0, "Hello World!"); + + + + + + + return 0; +} + diff --git a/u8g2/sys/sdl/text_picture_loop/Makefile b/u8g2/sys/sdl/text_picture_loop/Makefile new file mode 100644 index 00000000..9f409a66 --- /dev/null +++ b/u8g2/sys/sdl/text_picture_loop/Makefile @@ -0,0 +1,12 @@ +CFLAGS = -g -Wall -I../../../csrc/. `sdl-config --cflags` + +SRC = $(shell ls ../../../csrc/*.c) $(shell ls ../common/*.c ) main.c + +OBJ = $(SRC:.c=.o) + +helloworld: $(OBJ) + $(CC) $(CFLAGS) $(LDFLAGS) $(OBJ) `sdl-config --libs` -o u8g2_sdl + +clean: + -rm $(OBJ) u8g2_sdl + diff --git a/u8g2/sys/sdl/text_picture_loop/main.c b/u8g2/sys/sdl/text_picture_loop/main.c new file mode 100644 index 00000000..b54411ef --- /dev/null +++ b/u8g2/sys/sdl/text_picture_loop/main.c @@ -0,0 +1,293 @@ + +#include "u8g2.h" +#include + +const uint8_t bdf_font[762] U8X8_FONT_SECTION("bdf_font") = { + 32,126,0,0,0,0,0,0,0,0,0,0,0,95,95,0, + 0,0,0,7,7,0,7,7,0,0,20,127,127,28,127,127, + 20,0,0,36,42,127,127,42,18,0,70,102,48,24,12,102, + 98,0,48,122,79,93,55,122,72,0,0,0,0,7,7,0, + 0,0,0,0,28,62,99,65,0,0,0,0,65,99,62,28, + 0,0,0,0,0,0,0,0,0,0,0,8,8,62,62,8, + 8,0,0,0,128,224,96,0,0,0,0,8,8,8,8,8, + 8,0,0,0,0,96,96,0,0,0,96,48,24,12,6,3, + 1,0,62,127,81,73,69,127,62,0,0,64,66,127,127,64, + 64,0,0,114,123,73,73,111,102,0,0,34,97,73,73,127, + 54,0,24,20,82,127,127,80,16,0,0,39,111,73,73,121, + 51,0,0,62,127,73,73,123,50,0,0,3,1,113,125,15, + 7,0,0,54,127,73,73,127,54,0,0,38,111,73,73,127, + 62,0,0,0,0,108,108,0,0,0,0,0,128,236,108,0, + 0,0,0,8,28,54,99,65,0,0,0,36,36,36,36,36, + 36,0,0,65,99,54,28,8,0,0,0,2,3,81,89,15, + 6,0,62,127,65,93,93,95,30,0,0,124,126,19,19,126, + 124,0,65,127,127,73,73,127,54,0,28,62,99,65,65,99, + 34,0,65,127,127,65,99,62,28,0,65,127,127,73,93,65, + 99,0,65,127,127,73,29,1,3,0,60,126,67,65,81,115, + 114,0,0,127,127,8,8,127,127,0,0,65,65,127,127,65, + 65,0,48,112,64,65,127,63,1,0,65,127,127,8,28,119, + 99,0,65,127,127,65,64,96,112,0,127,127,14,28,14,127, + 127,0,127,127,6,12,24,127,127,0,28,62,99,65,99,62, + 28,0,65,127,127,73,9,7,6,0,60,126,67,81,51,110, + 92,0,65,127,127,9,25,63,102,0,0,38,111,73,73,123, + 50,0,0,3,65,127,127,65,3,0,0,63,127,64,64,127, + 63,0,0,31,63,96,96,63,31,0,127,127,48,24,48,127, + 127,0,97,115,30,12,30,115,97,0,0,7,79,120,120,79, + 7,0,71,99,113,89,77,103,115,0,0,0,127,127,65,65, + 0,0,1,3,6,12,24,48,96,0,0,0,65,65,127,127, + 0,0,8,12,6,3,6,12,8,0,0,0,0,0,0,0, + 0,0,0,0,2,6,12,8,0,0,32,116,84,84,60,120, + 64,0,67,63,127,68,68,124,56,0,0,56,124,68,68,108, + 40,0,56,124,68,69,63,127,64,0,0,56,124,84,84,92, + 24,0,0,72,126,127,73,3,2,0,0,152,188,164,164,252, + 124,0,65,127,127,8,4,124,120,0,0,0,68,125,125,64, + 0,0,0,96,224,128,132,252,125,0,65,127,127,16,56,108, + 68,0,0,0,65,127,127,64,0,0,120,124,12,56,12,124, + 120,0,4,124,120,4,4,120,120,0,0,56,124,68,68,124, + 56,0,132,252,248,164,36,60,24,0,24,60,36,164,248,252, + 132,0,68,124,120,68,12,8,0,0,0,72,92,84,84,116, + 32,0,0,4,63,127,68,100,32,0,0,60,124,64,64,124, + 124,0,0,28,60,96,96,60,28,0,60,124,96,56,96,124, + 60,0,68,108,56,16,56,108,68,0,0,156,188,160,160,252, + 124,0,0,76,100,116,92,76,68,0,0,65,65,119,62,8, + 8,0,0,0,0,127,127,0,0,0,0,8,8,62,119,65, + 65,0,2,3,1,3,2,1,1,0}; + +const uint8_t u8g2_font_helvB18_tr[2245] U8X8_FONT_SECTION("u8g2_font_helvB18_tr") = { + 95,0,4,3,5,5,3,5,6,23,24,0,251,19,251,19, + 251,2,234,6,37,32,6,0,48,154,0,33,10,99,26,158, + 240,23,234,14,4,34,11,197,184,167,32,193,139,145,8,0, + 35,42,76,22,186,36,34,38,34,38,34,38,34,38,34,115, + 64,113,64,35,34,38,34,38,34,38,34,115,64,113,64,35, + 34,38,34,38,34,38,34,38,34,4,36,39,172,210,181,37, + 119,116,48,65,33,177,68,196,68,228,66,204,174,146,178,206, + 76,226,68,196,68,196,68,228,66,130,226,96,232,78,84,10, + 0,37,49,85,18,218,61,87,54,118,52,54,179,76,74,100, + 78,74,100,110,102,98,242,100,180,100,30,102,30,100,166,116, + 228,112,100,102,110,68,74,108,70,74,108,102,213,212,217,88, + 9,0,38,38,80,22,202,84,122,72,65,55,51,55,51,55, + 51,56,49,218,244,100,134,130,98,102,230,100,170,102,108,104, + 170,134,230,129,200,144,209,0,39,8,194,184,155,112,64,1, + 40,22,6,119,161,36,51,50,51,50,51,35,179,255,72,104, + 102,104,102,104,72,0,41,22,6,119,161,32,180,102,104,102, + 72,104,102,255,70,102,201,204,200,140,16,0,42,16,232,148, + 171,35,38,35,33,113,48,66,35,162,5,0,43,14,140,53, + 190,37,170,171,131,7,83,162,186,2,44,10,195,184,157,112, + 32,33,65,1,45,7,103,208,162,240,1,46,7,99,24,158, + 112,32,47,18,103,22,162,165,145,148,34,41,141,164,20,73, + 41,146,82,5,48,27,76,18,182,99,117,16,67,66,50,52, + 50,52,49,230,159,77,12,141,12,141,176,57,136,178,1,49, + 12,71,26,182,180,230,224,128,104,255,15,50,27,76,18,182, + 83,117,32,51,67,49,53,49,102,54,57,56,72,199,172,140, + 142,225,228,193,131,1,51,31,76,18,182,83,117,32,179,100, + 106,98,106,98,106,114,112,172,238,114,116,210,204,138,98,134, + 228,96,200,6,0,52,27,76,18,182,55,200,174,153,196,212, + 196,148,200,144,204,54,66,35,67,35,7,15,230,38,55,1, + 53,30,76,18,182,113,48,114,48,50,185,229,65,208,129,204, + 12,229,232,228,164,153,213,65,12,201,129,148,13,0,54,32, + 76,18,182,84,117,32,66,51,50,101,102,185,130,232,96,164, + 132,130,104,98,204,217,196,208,8,155,131,40,27,0,55,24, + 76,18,182,240,193,32,225,202,193,201,193,201,193,201,65,194, + 201,65,194,201,57,0,56,35,76,18,182,68,118,16,52,50, + 51,52,50,52,50,52,50,52,51,50,101,117,16,51,52,49, + 230,217,196,208,200,193,144,13,0,57,32,76,18,182,99,116, + 32,67,66,65,52,49,230,217,17,5,73,197,1,77,197,228, + 164,213,4,73,201,129,84,17,0,58,10,195,25,158,112,32, + 15,121,32,59,13,35,186,157,112,32,15,121,32,33,65,1, + 60,14,141,49,190,58,88,214,25,37,109,105,167,3,61,11, + 170,184,186,240,192,244,224,192,0,62,13,141,53,186,48,218, + 91,74,178,30,142,2,63,24,107,26,190,99,115,32,66,114, + 16,100,101,68,55,71,70,183,112,123,4,131,139,0,64,65, + 214,150,225,119,32,123,96,88,86,69,74,67,60,66,84,33, + 50,49,116,32,114,179,198,102,104,198,70,104,200,100,104,102, + 98,100,72,104,98,100,102,201,154,37,51,35,19,52,36,7, + 85,51,21,115,244,64,244,64,85,163,7,197,7,129,0,65, + 37,112,22,202,70,76,107,106,57,34,57,50,56,50,55,52, + 54,52,54,52,53,54,52,54,116,80,115,112,50,56,50,56, + 49,234,116,0,66,37,111,26,202,112,64,116,96,50,70,50, + 56,49,56,49,56,49,56,49,55,114,80,115,96,50,56,49, + 233,195,179,138,3,147,3,34,0,67,29,112,22,202,117,119, + 64,84,83,66,71,49,121,60,189,175,41,39,38,39,232,72, + 106,138,14,232,142,0,68,30,112,26,206,112,64,117,96,51, + 86,50,72,49,57,49,121,234,95,94,78,12,82,140,149,28, + 216,28,80,1,69,22,109,26,194,112,80,113,80,49,186,167, + 7,36,7,36,163,251,244,224,65,1,70,17,108,26,190,240, + 129,229,94,30,80,28,80,76,238,47,1,71,35,113,22,206, + 117,120,64,85,83,67,71,50,57,65,61,190,217,1,217,1, + 173,237,233,196,36,5,93,73,205,131,137,169,147,1,72,14, + 111,26,206,48,233,95,30,252,32,210,127,57,73,8,99,26, + 158,240,63,8,74,17,107,22,186,184,255,161,149,87,19,51, + 20,7,50,39,0,75,39,110,26,202,48,119,70,49,69,50, + 68,51,67,52,66,53,65,118,247,32,140,130,106,102,106,104, + 17,205,212,204,216,200,24,197,220,196,28,1,76,12,108,26, + 190,48,185,255,191,60,120,48,77,50,115,26,222,48,125,123, + 16,123,32,121,48,121,64,119,32,33,39,97,49,53,97,34, + 37,98,50,51,98,50,51,98,163,198,102,98,198,102,98,198, + 168,200,168,200,106,202,106,202,106,1,78,39,111,26,206,48, + 121,248,32,238,32,238,64,204,98,202,98,202,100,200,102,198, + 102,198,104,196,74,196,106,194,236,64,238,32,238,32,240,114, + 0,79,29,113,22,206,117,120,64,85,83,67,71,50,57,65, + 121,235,111,47,41,38,71,232,104,90,29,16,94,1,80,23, + 110,26,198,112,64,115,96,49,55,49,232,187,137,3,139,131, + 146,217,253,45,0,81,35,145,246,205,117,120,64,85,83,67, + 71,50,57,65,121,235,111,207,66,40,166,38,70,168,108,138, + 168,14,234,46,230,1,66,0,82,26,110,26,198,112,64,115, + 96,49,55,49,232,187,137,3,139,131,146,49,138,185,137,65, + 127,56,83,32,110,26,198,100,118,48,67,83,65,54,49,55, + 49,75,91,122,16,121,90,75,107,232,238,64,166,228,128,234, + 8,0,84,13,111,18,190,240,3,177,225,253,255,25,0,85, + 19,111,26,206,48,233,255,151,119,20,115,35,53,53,7,100, + 71,0,86,36,112,22,202,48,106,122,72,49,56,66,70,51, + 54,52,54,196,106,104,108,104,140,132,110,100,112,100,112,100, + 210,212,150,152,25,0,87,62,117,22,222,48,54,102,54,102, + 54,102,182,98,168,104,100,168,104,100,72,66,104,100,102,98, + 102,70,102,98,70,104,100,98,100,104,68,70,100,104,98,102, + 98,74,98,102,66,76,98,102,66,172,170,172,170,110,225,220, + 224,220,16,0,88,37,112,22,202,48,122,72,65,70,51,54, + 53,52,55,50,120,16,105,75,76,107,121,16,56,50,55,52, + 69,68,52,54,51,56,65,120,58,89,30,111,22,198,48,121, + 56,49,55,66,54,51,53,68,52,53,51,54,51,55,49,56, + 49,89,90,59,188,207,0,90,21,110,22,194,240,83,74,78, + 41,153,82,50,165,36,29,165,36,61,248,0,91,13,5,119, + 161,112,96,178,255,255,201,193,0,92,18,103,18,162,32,165, + 76,74,153,148,102,82,202,164,148,73,41,93,13,5,123,161, + 112,48,178,255,255,201,129,1,94,19,43,85,187,52,56,87, + 38,33,53,49,179,100,102,98,202,106,0,95,7,78,112,185, + 240,3,96,8,134,244,163,48,180,1,97,30,204,21,186,99, + 117,16,51,67,50,52,57,102,115,32,82,50,65,52,49,53, + 49,68,65,82,114,64,82,50,98,26,108,26,190,48,185,23, + 53,7,35,37,20,68,19,99,126,118,52,81,66,113,48,50, + 81,3,99,21,203,21,182,99,116,16,194,98,200,112,47,135, + 38,72,72,14,130,76,0,100,25,108,22,190,185,55,21,35, + 7,19,36,21,67,103,126,54,49,68,65,82,114,48,83,49, + 101,27,204,21,186,68,118,16,67,66,50,52,49,102,118,240, + 129,228,232,212,4,13,201,129,84,13,0,102,16,103,22,166, + 67,82,50,180,228,224,100,104,255,19,0,103,31,108,118,189, + 83,49,114,48,65,82,49,116,230,103,19,67,20,36,37,7, + 51,21,147,102,71,35,7,67,54,0,104,17,107,26,190,48, + 184,23,52,7,19,52,19,83,254,175,6,105,10,99,26,158, + 112,32,118,240,7,106,13,5,115,157,178,241,200,254,127,114, + 80,1,107,31,107,26,186,48,184,71,19,51,20,35,36,19, + 52,71,86,71,19,52,35,51,35,36,51,20,67,19,67,87, + 3,108,8,99,26,158,240,63,8,109,36,209,25,214,48,65, + 82,114,112,32,65,82,114,52,100,52,100,52,100,52,100,52, + 100,52,100,52,100,52,100,52,100,52,100,180,0,110,16,203, + 25,190,48,81,114,48,65,51,49,229,255,106,0,111,23,204, + 21,186,68,118,16,67,66,50,52,49,230,103,19,67,35,108, + 14,194,136,0,112,27,108,122,189,48,81,115,48,82,66,65, + 52,49,230,103,71,19,37,20,7,35,19,53,147,187,4,113, + 25,108,118,189,83,49,114,48,65,82,49,116,230,103,19,67, + 20,36,37,7,51,21,147,123,114,13,199,25,170,48,113,240, + 102,104,255,8,0,115,25,203,21,182,98,116,16,194,98,104, + 98,208,236,32,204,240,202,234,134,226,64,230,4,0,116,15, + 71,22,166,50,180,201,193,201,208,254,81,13,1,117,16,203, + 25,190,48,229,255,136,98,164,194,98,102,100,0,118,26,204, + 21,186,48,230,108,98,104,100,104,100,104,102,100,104,100,104, + 100,202,204,142,144,17,0,119,43,211,17,206,48,53,101,181, + 66,106,74,100,166,102,100,166,102,70,133,140,144,200,196,136, + 208,196,86,18,50,18,98,53,101,53,117,83,131,83,131,83, + 67,0,120,26,203,21,182,48,117,67,49,179,98,232,170,110, + 174,172,106,98,134,130,100,102,130,230,106,0,121,32,109,118, + 189,48,103,55,49,54,65,52,51,52,67,66,52,50,53,50, + 102,103,88,72,186,114,116,114,176,144,14,0,122,19,203,21, + 182,240,65,220,58,50,186,57,50,186,117,116,7,15,2,123, + 15,7,119,169,52,179,104,191,89,52,181,104,191,90,124,8, + 2,127,157,240,15,12,125,16,7,123,169,48,181,104,191,90, + 52,179,104,191,89,4,126,13,139,180,186,65,115,48,97,113, + 48,67,1,0,0}; + +u8g2_t u8g2; + +int main(void) +{ + int x, y; + int k; + int i; + + u8g2_Setup_SDL_128x64_4(&u8g2, &u8g2_cb_r0); + u8x8_display_Init(u8g2_GetU8x8(&u8g2)); + u8x8_display_SetPowerSave(u8g2_GetU8x8(&u8g2), 0); + u8g2_SetFont(&u8g2, u8g2_font_helvB18_tr); + + x = 50; + y = 30; + + + for(;;) + { +#ifdef U8G2_WITH_HVLINE_COUNT + u8g2.hv_cnt = 0UL; +#endif /* U8G2_WITH_HVLINE_COUNT */ + + /* + u8g2_ClearBuffer(&u8g2); + + u8g2_SetFontDirection(&u8g2, 0); + u8g2_DrawString(&u8g2, x, y, "ABC"); + u8g2_SetFontDirection(&u8g2, 1); + u8g2_DrawString(&u8g2, x, y, "abc"); + u8g2_SetFontDirection(&u8g2, 2); + u8g2_DrawString(&u8g2, x, y, "abc"); + u8g2_SetFontDirection(&u8g2, 3); + u8g2_DrawString(&u8g2, x, y, "abc"); + + u8g2_SendBuffer(&u8g2); + */ + + u8g2_FirstPage(&u8g2); + i = 0; + do + { + u8g2_SetFontDirection(&u8g2, 0); + u8g2_DrawString(&u8g2, x, y, "ABC"); + u8g2_SetFontDirection(&u8g2, 1); + u8g2_DrawString(&u8g2, x, y, "abc"); + u8g2_SetFontDirection(&u8g2, 2); + u8g2_DrawString(&u8g2, x, y, "abc"); + u8g2_SetFontDirection(&u8g2, 3); + u8g2_DrawString(&u8g2, x, y, "abc"); + if ( i == 1 ) + { + u8g2_DrawHVLine(&u8g2, u8g2.user_x0, u8g2.user_y0, 1, 0); + u8g2_DrawHVLine(&u8g2, u8g2.user_x0, u8g2.user_y1-1, 1, 0); + u8g2_DrawHVLine(&u8g2, u8g2.user_x1-1, u8g2.user_y1-1, 1, 0); + u8g2_DrawHVLine(&u8g2, u8g2.user_x1-1, u8g2.user_y0, 1, 0); + + } + + i++; + + + } while( u8g2_NextPage(&u8g2) ); +#ifdef U8G2_WITH_HVLINE_COUNT + printf("hv cnt: %ld\n", u8g2.hv_cnt); +#endif /* U8G2_WITH_HVLINE_COUNT */ + + do + { + k = u8g_sdl_get_key(); + } while( k < 0 ); + + if ( k == 273 ) y -= 7; + if ( k == 274 ) y += 7; + if ( k == 276 ) x -= 7; + if ( k == 275 ) x += 7; + + if ( k == 'e' ) y -= 1; + if ( k == 'x' ) y += 1; + if ( k == 's' ) x -= 1; + if ( k == 'd' ) x += 1; + if ( k == 'q' ) break; + + } + + //u8x8_Set8x8Font(u8g2_GetU8x8(&u8g2), bdf_font); + //u8x8_Draw8x8String(u8g2_GetU8x8(&u8g2), 0, 0, "Hello World!"); + + + + + + + return 0; +} + diff --git a/u8g2/sys/stdio/Makefile b/u8g2/sys/stdio/Makefile new file mode 100644 index 00000000..5470f6cf --- /dev/null +++ b/u8g2/sys/stdio/Makefile @@ -0,0 +1,15 @@ +CFLAGS = -I../../csrc -g -Wall +#CFLAGS = -O4 -Wall + +SRC = $(shell ls ../../csrc/*.c 2>/dev/null) test.c + +OBJ = $(SRC:.c=.o) + +stdio: $(OBJ) + $(CC) $(CFLAGS) $(LDFLAGS) $(OBJ) -o stdio + +clean: + -rm $(OBJ) stdio + +test: + ./stdio \ No newline at end of file diff --git a/u8g2/sys/stdio/test.c b/u8g2/sys/stdio/test.c new file mode 100644 index 00000000..3a49fa57 --- /dev/null +++ b/u8g2/sys/stdio/test.c @@ -0,0 +1,73 @@ + + + +#include "u8g2.h" + +u8g2_t u8g2; + +const uint8_t bdf_font[762] U8G2_FONT_SECTION("bdf_font") = { + 32,126,0,0,0,0,0,0,0,0,0,0,0,95,95,0, + 0,0,0,7,7,0,7,7,0,0,20,127,127,28,127,127, + 20,0,0,36,42,127,127,42,18,0,70,102,48,24,12,102, + 98,0,48,122,79,93,55,122,72,0,0,0,0,7,7,0, + 0,0,0,0,28,62,99,65,0,0,0,0,65,99,62,28, + 0,0,0,0,0,0,0,0,0,0,0,8,8,62,62,8, + 8,0,0,0,128,224,96,0,0,0,0,8,8,8,8,8, + 8,0,0,0,0,96,96,0,0,0,96,48,24,12,6,3, + 1,0,62,127,81,73,69,127,62,0,0,64,66,127,127,64, + 64,0,0,114,123,73,73,111,102,0,0,34,97,73,73,127, + 54,0,24,20,82,127,127,80,16,0,0,39,111,73,73,121, + 51,0,0,62,127,73,73,123,50,0,0,3,1,113,125,15, + 7,0,0,54,127,73,73,127,54,0,0,38,111,73,73,127, + 62,0,0,0,0,108,108,0,0,0,0,0,128,236,108,0, + 0,0,0,8,28,54,99,65,0,0,0,36,36,36,36,36, + 36,0,0,65,99,54,28,8,0,0,0,2,3,81,89,15, + 6,0,62,127,65,93,93,95,30,0,0,124,126,19,19,126, + 124,0,65,127,127,73,73,127,54,0,28,62,99,65,65,99, + 34,0,65,127,127,65,99,62,28,0,65,127,127,73,93,65, + 99,0,65,127,127,73,29,1,3,0,60,126,67,65,81,115, + 114,0,0,127,127,8,8,127,127,0,0,65,65,127,127,65, + 65,0,48,112,64,65,127,63,1,0,65,127,127,8,28,119, + 99,0,65,127,127,65,64,96,112,0,127,127,14,28,14,127, + 127,0,127,127,6,12,24,127,127,0,28,62,99,65,99,62, + 28,0,65,127,127,73,9,7,6,0,60,126,67,81,51,110, + 92,0,65,127,127,9,25,63,102,0,0,38,111,73,73,123, + 50,0,0,3,65,127,127,65,3,0,0,63,127,64,64,127, + 63,0,0,31,63,96,96,63,31,0,127,127,48,24,48,127, + 127,0,97,115,30,12,30,115,97,0,0,7,79,120,120,79, + 7,0,71,99,113,89,77,103,115,0,0,0,127,127,65,65, + 0,0,1,3,6,12,24,48,96,0,0,0,65,65,127,127, + 0,0,8,12,6,3,6,12,8,0,0,0,0,0,0,0, + 0,0,0,0,2,6,12,8,0,0,32,116,84,84,60,120, + 64,0,67,63,127,68,68,124,56,0,0,56,124,68,68,108, + 40,0,56,124,68,69,63,127,64,0,0,56,124,84,84,92, + 24,0,0,72,126,127,73,3,2,0,0,152,188,164,164,252, + 124,0,65,127,127,8,4,124,120,0,0,0,68,125,125,64, + 0,0,0,96,224,128,132,252,125,0,65,127,127,16,56,108, + 68,0,0,0,65,127,127,64,0,0,120,124,12,56,12,124, + 120,0,4,124,120,4,4,120,120,0,0,56,124,68,68,124, + 56,0,132,252,248,164,36,60,24,0,24,60,36,164,248,252, + 132,0,68,124,120,68,12,8,0,0,0,72,92,84,84,116, + 32,0,0,4,63,127,68,100,32,0,0,60,124,64,64,124, + 124,0,0,28,60,96,96,60,28,0,60,124,96,56,96,124, + 60,0,68,108,56,16,56,108,68,0,0,156,188,160,160,252, + 124,0,0,76,100,116,92,76,68,0,0,65,65,119,62,8, + 8,0,0,0,0,127,127,0,0,0,0,8,8,62,119,65, + 65,0,2,3,1,3,2,1,1,0}; + +int main(void) +{ + uint8_t tile[8] = { 0x0f, 0x0f, 0x0f, 0x0f, 0xf0, 0xf0, 0xf0, 0xf0 }; + u8g2_SetupStdio(&u8g2); + + u8g2_display_Init(&u8g2); + u8g2_display_PowerUp(&u8g2); + + u8g2_Set8x8Font(&u8g2, bdf_font); + u8g2_Draw8x8String(&u8g2, 0, 0, "Hello"); + + u8g2_display_DrawTile(&u8g2, 1, 1, 1, tile); + u8g2_display_PowerUp(&u8g2); + + return 0; +} \ No newline at end of file diff --git a/u8g2/sys/tga/common/u8x8_d_tga.c b/u8g2/sys/tga/common/u8x8_d_tga.c new file mode 100644 index 00000000..caa9ebe6 --- /dev/null +++ b/u8g2/sys/tga/common/u8x8_d_tga.c @@ -0,0 +1,360 @@ + +#include "u8g2.h" +#include +#include +#include + +#define FACTOR 3 +#define XOFFSET (FACTOR*32) +#define YOFFSET (FACTOR*32) +#define DEFAULT_WIDTH (FACTOR*128) +#define DEFAULT_HEIGHT (FACTOR*64) + + +static uint16_t tga_width; +static uint16_t tga_height; +static uint8_t *tga_data = NULL; +uint8_t tga_r = 0; +uint8_t tga_g = 0; +uint8_t tga_b = 0; + +uint8_t tga_desc_r = 0; +uint8_t tga_desc_g = 0; +uint8_t tga_desc_b = 255; + +int tga_init(uint16_t w, uint16_t h) +{ + tga_width = 0; + tga_height = 0; + if ( tga_data != NULL ) + free(tga_data); + tga_data = (uint8_t *)malloc(w*h*3); + if ( tga_data == NULL ) + return 0; + tga_width = w; + tga_height = h; + memset(tga_data, 255, tga_width*tga_height*3); + return 1; +} + +void tga_set_pixel(uint16_t x, uint16_t y, uint16_t f) +{ + uint8_t *p; + uint16_t xx,yy; + for( yy = y; yy < y+f; yy++ ) + { + for( xx = x; xx < x+f; xx++ ) + { + if ( yy < tga_height && xx < tga_width ) + { + //printf ("(%d %d) ", xx, yy); + p = tga_data + (tga_height-yy-1)*tga_width*3 + xx*3; + *p++ = tga_b; + *p++ = tga_g; + *p++ = tga_r; + } + } + } +} + +void tga_clr_pixel(uint16_t x, uint16_t y, uint16_t f) +{ + uint8_t *p; + uint16_t xx,yy; + for( yy = y; yy < y+f; yy++ ) + { + for( xx = x; xx < x+f; xx++ ) + { + + p = tga_data + (tga_height-yy-1)*tga_width*3 + xx*3; + *p++ = 255; + *p++ = 255; + *p++ = 255; + } + } +} + +void tga_set_8pixel(int x, int y, uint8_t pixel, uint16_t f) +{ + int cnt = 8; + while( cnt > 0 ) + { + if ( (pixel & 1) != 0 ) + { + tga_set_pixel(x,y, f); + } + else + { + tga_clr_pixel(x,y, f); + } + pixel >>= 1; + y+=f; + cnt--; + } +} + +void tga_set_multiple_8pixel(int x, int y, int cnt, uint8_t *pixel, uint16_t f) +{ + uint8_t b; + while( cnt > 0 ) + { + b = *pixel; + tga_set_8pixel(x, y, b, f); + x+=f; + pixel++; + cnt--; + } +} + + + +void tga_write_byte(FILE *fp, uint8_t byte) +{ + fputc(byte, fp); +} + +void tga_write_word(FILE *fp, uint16_t word) +{ + tga_write_byte(fp, word&255); + tga_write_byte(fp, word>>8); +} + +void tga_save(const char *name) +{ + FILE *fp; + if ( tga_data == NULL ) + return; + + printf("tga_save: File %s with %dx%d pixel\n", name, tga_width, tga_height); + + fp = fopen(name, "wb"); + if ( fp != NULL ) + { + tga_write_byte(fp, 0); /* no ID */ + tga_write_byte(fp, 0); /* no color map */ + tga_write_byte(fp, 2); /* uncompressed true color */ + tga_write_word(fp, 0); + tga_write_word(fp, 0); + tga_write_byte(fp, 0); + tga_write_word(fp, 0); /* x origin */ + tga_write_word(fp, 0); /* y origin */ + tga_write_word(fp, tga_width); /* width */ + tga_write_word(fp, tga_height); /* height */ + tga_write_byte(fp, 24); /* color depth */ + tga_write_byte(fp, 0); + fwrite(tga_data, tga_width*tga_height*3, 1, fp); + tga_write_word(fp, 0); + tga_write_word(fp, 0); + tga_write_word(fp, 0); + tga_write_word(fp, 0); + fwrite("TRUEVISION-XFILE.", 18, 1, fp); + fclose(fp); + } +} + +/*==========================================*/ +/* tga description procedures */ + + +static const u8x8_display_info_t u8x8_tga_desc_info = +{ + /* chip_enable_level = */ 0, + /* chip_disable_level = */ 1, + + /* post_chip_enable_wait_ns = */ 0, + /* pre_chip_disable_wait_ns = */ 0, + /* reset_pulse_width_ms = */ 0, + /* post_reset_wait_ms = */ 0, + /* sda_setup_time_ns = */ 0, + /* sck_pulse_width_ns = */ 0, + /* sck_takeover_edge = */ 1, + /* i2c_bus_clock_100kHz = */ 0, + /* data_setup_time_ns = */ 0, + /* write_pulse_width_ns = */ 0, + /* tile_width = */ (2*XOFFSET+DEFAULT_WIDTH)/8, + /* tile_hight = */ (2*YOFFSET+DEFAULT_HEIGHT)/8, +#if U8X8_DEFAULT_FLIP_MODE == 0 + /* default_x_offset = */ 0, +#else + /* default_x_offset = */ 0, +#endif +}; + + +uint8_t u8x8_d_tga_desc(u8x8_t *u8g2, uint8_t msg, uint8_t arg_int, void *arg_ptr) +{ + u8g2_uint_t x, y, c; + uint8_t *ptr; + switch(msg) + { + case U8X8_MSG_DISPLAY_SETUP: + u8x8_d_helper_display_setup(u8g2, &u8x8_tga_desc_info); + break; + case U8X8_MSG_DISPLAY_INIT: + u8x8_d_helper_display_init(u8g2); + if ( tga_data == NULL ) + tga_init(2*XOFFSET+DEFAULT_WIDTH, 2*YOFFSET+DEFAULT_HEIGHT); + break; + case U8X8_MSG_DISPLAY_SET_POWER_SAVE: + break; + case U8X8_MSG_DISPLAY_SET_FLIP_MODE: + break; + case U8X8_MSG_DISPLAY_SET_CONTRAST: + break; + case U8X8_MSG_DISPLAY_DRAW_TILE: + + tga_r = tga_desc_r; + tga_g = tga_desc_g; + tga_b = tga_desc_b; + + x = ((u8x8_tile_t *)arg_ptr)->x_pos; + //printf("U8X8_MSG_DISPLAY_DRAW_TILE x=%d, ", x); + x *= 8; + x += u8g2->x_offset; + + y = ((u8x8_tile_t *)arg_ptr)->y_pos; + //printf("y=%d, c=%d\n", y, ((u8x8_tile_t *)arg_ptr)->cnt); + y *= 8; + + do + { + c = ((u8x8_tile_t *)arg_ptr)->cnt; + ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr; + tga_set_multiple_8pixel(x, y, c*8, ptr, 1); + arg_int--; + } while( arg_int > 0 ); + + break; + default: + return 0; + } + return 1; +} + + +void u8x8_Setup_TGA_DESC(u8x8_t *u8x8) +{ + /* setup defaults */ + u8x8_SetupDefaults(u8x8); + + /* setup specific callbacks */ + u8x8->display_cb = u8x8_d_tga_desc; + + /* setup display info */ + u8x8_display_Setup(u8x8); +} + +void u8g2_Setup_TGA_DESC(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb) +{ + static uint8_t buf[(XOFFSET+DEFAULT_WIDTH)*8]; + + u8x8_Setup_TGA_DESC(u8g2_GetU8x8(u8g2)); + u8g2_Setup(u8g2, buf, 1, u8g2_cb); +} + +/*==========================================*/ +/* tga LCD procedures */ + + +static const u8x8_display_info_t u8x8_tga_lcd_info = +{ + /* chip_enable_level = */ 0, + /* chip_disable_level = */ 1, + + /* post_chip_enable_wait_ns = */ 0, + /* pre_chip_disable_wait_ns = */ 0, + /* reset_pulse_width_ms = */ 0, + /* post_reset_wait_ms = */ 0, + /* sda_setup_time_ns = */ 0, + /* sck_pulse_width_ns = */ 0, + /* sck_takeover_edge = */ 1, + /* i2c_bus_clock_100kHz = */ 0, + /* data_setup_time_ns = */ 0, + /* write_pulse_width_ns = */ 0, + /* tile_width = */ (DEFAULT_WIDTH)/FACTOR/8, + /* tile_hight = */ (DEFAULT_HEIGHT)/FACTOR/8, +#if U8X8_DEFAULT_FLIP_MODE == 0 + /* default_x_offset = */ 0, +#else + /* default_x_offset = */ 0, +#endif +}; + + +uint8_t u8x8_d_tga_lcd(u8x8_t *u8g2, uint8_t msg, uint8_t arg_int, void *arg_ptr) +{ + u8g2_uint_t x, y, c; + uint8_t *ptr; + switch(msg) + { + case U8X8_MSG_DISPLAY_SETUP: + u8x8_d_helper_display_setup(u8g2, &u8x8_tga_lcd_info); + break; + case U8X8_MSG_DISPLAY_INIT: + u8x8_d_helper_display_init(u8g2); + if ( tga_data == NULL ) + tga_init(2*XOFFSET+DEFAULT_WIDTH, 2*YOFFSET+DEFAULT_HEIGHT); + break; + case U8X8_MSG_DISPLAY_SET_POWER_SAVE: + break; + case U8X8_MSG_DISPLAY_SET_FLIP_MODE: + break; + case U8X8_MSG_DISPLAY_SET_CONTRAST: + break; + case U8X8_MSG_DISPLAY_DRAW_TILE: + + tga_r = 0; + tga_g = 0; + tga_b = 0; + + x = ((u8x8_tile_t *)arg_ptr)->x_pos; + //printf("U8X8_MSG_DISPLAY_DRAW_TILE x=%d, ", x); + x *= 8; + x += u8g2->x_offset; + x *= FACTOR; + x += XOFFSET; + + y = ((u8x8_tile_t *)arg_ptr)->y_pos; + //printf("y=%d, c=%d\n", y, ((u8x8_tile_t *)arg_ptr)->cnt); + y *= 8; + y *= FACTOR; + y += YOFFSET; + + do + { + c = ((u8x8_tile_t *)arg_ptr)->cnt; + ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr; + tga_set_multiple_8pixel(x, y, c*8, ptr, FACTOR); + arg_int--; + } while( arg_int > 0 ); + + break; + default: + return 0; + } + return 1; +} + + +void u8x8_Setup_TGA_LCD(u8x8_t *u8x8) +{ + /* setup defaults */ + u8x8_SetupDefaults(u8x8); + + /* setup specific callbacks */ + u8x8->display_cb = u8x8_d_tga_lcd; + + /* setup display info */ + u8x8_display_Setup(u8x8); +} + +void u8g2_Setup_TGA_LCD(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb) +{ + static uint8_t buf[(DEFAULT_WIDTH/FACTOR)*8]; + + u8x8_Setup_TGA_LCD(u8g2_GetU8x8(u8g2)); + u8g2_Setup(u8g2, buf, 1, u8g2_cb); +} + + + diff --git a/u8g2/sys/tga/hello_world_8x8/Makefile b/u8g2/sys/tga/hello_world_8x8/Makefile new file mode 100644 index 00000000..92cd9e27 --- /dev/null +++ b/u8g2/sys/tga/hello_world_8x8/Makefile @@ -0,0 +1,12 @@ +CFLAGS = -g -Wall -I../../../csrc/. `sdl-config --cflags` + +SRC = $(shell ls ../../../csrc/*.c) $(shell ls ../common/*.c ) main.c + +OBJ = $(SRC:.c=.o) + +u8g2_tga: $(OBJ) + $(CC) $(CFLAGS) $(LDFLAGS) $(OBJ) `sdl-config --libs` -o u8g2_tga + +clean: + -rm $(OBJ) u8g2_tga + diff --git a/u8g2/sys/tga/hello_world_8x8/main.c b/u8g2/sys/tga/hello_world_8x8/main.c new file mode 100644 index 00000000..9490a578 --- /dev/null +++ b/u8g2/sys/tga/hello_world_8x8/main.c @@ -0,0 +1,69 @@ + +#include "u8x8.h" + +const uint8_t bdf_font[762] U8X8_FONT_SECTION("bdf_font") = { + 32,126,0,0,0,0,0,0,0,0,0,0,0,95,95,0, + 0,0,0,7,7,0,7,7,0,0,20,127,127,28,127,127, + 20,0,0,36,42,127,127,42,18,0,70,102,48,24,12,102, + 98,0,48,122,79,93,55,122,72,0,0,0,0,7,7,0, + 0,0,0,0,28,62,99,65,0,0,0,0,65,99,62,28, + 0,0,0,0,0,0,0,0,0,0,0,8,8,62,62,8, + 8,0,0,0,128,224,96,0,0,0,0,8,8,8,8,8, + 8,0,0,0,0,96,96,0,0,0,96,48,24,12,6,3, + 1,0,62,127,81,73,69,127,62,0,0,64,66,127,127,64, + 64,0,0,114,123,73,73,111,102,0,0,34,97,73,73,127, + 54,0,24,20,82,127,127,80,16,0,0,39,111,73,73,121, + 51,0,0,62,127,73,73,123,50,0,0,3,1,113,125,15, + 7,0,0,54,127,73,73,127,54,0,0,38,111,73,73,127, + 62,0,0,0,0,108,108,0,0,0,0,0,128,236,108,0, + 0,0,0,8,28,54,99,65,0,0,0,36,36,36,36,36, + 36,0,0,65,99,54,28,8,0,0,0,2,3,81,89,15, + 6,0,62,127,65,93,93,95,30,0,0,124,126,19,19,126, + 124,0,65,127,127,73,73,127,54,0,28,62,99,65,65,99, + 34,0,65,127,127,65,99,62,28,0,65,127,127,73,93,65, + 99,0,65,127,127,73,29,1,3,0,60,126,67,65,81,115, + 114,0,0,127,127,8,8,127,127,0,0,65,65,127,127,65, + 65,0,48,112,64,65,127,63,1,0,65,127,127,8,28,119, + 99,0,65,127,127,65,64,96,112,0,127,127,14,28,14,127, + 127,0,127,127,6,12,24,127,127,0,28,62,99,65,99,62, + 28,0,65,127,127,73,9,7,6,0,60,126,67,81,51,110, + 92,0,65,127,127,9,25,63,102,0,0,38,111,73,73,123, + 50,0,0,3,65,127,127,65,3,0,0,63,127,64,64,127, + 63,0,0,31,63,96,96,63,31,0,127,127,48,24,48,127, + 127,0,97,115,30,12,30,115,97,0,0,7,79,120,120,79, + 7,0,71,99,113,89,77,103,115,0,0,0,127,127,65,65, + 0,0,1,3,6,12,24,48,96,0,0,0,65,65,127,127, + 0,0,8,12,6,3,6,12,8,0,0,0,0,0,0,0, + 0,0,0,0,2,6,12,8,0,0,32,116,84,84,60,120, + 64,0,67,63,127,68,68,124,56,0,0,56,124,68,68,108, + 40,0,56,124,68,69,63,127,64,0,0,56,124,84,84,92, + 24,0,0,72,126,127,73,3,2,0,0,152,188,164,164,252, + 124,0,65,127,127,8,4,124,120,0,0,0,68,125,125,64, + 0,0,0,96,224,128,132,252,125,0,65,127,127,16,56,108, + 68,0,0,0,65,127,127,64,0,0,120,124,12,56,12,124, + 120,0,4,124,120,4,4,120,120,0,0,56,124,68,68,124, + 56,0,132,252,248,164,36,60,24,0,24,60,36,164,248,252, + 132,0,68,124,120,68,12,8,0,0,0,72,92,84,84,116, + 32,0,0,4,63,127,68,100,32,0,0,60,124,64,64,124, + 124,0,0,28,60,96,96,60,28,0,60,124,96,56,96,124, + 60,0,68,108,56,16,56,108,68,0,0,156,188,160,160,252, + 124,0,0,76,100,116,92,76,68,0,0,65,65,119,62,8, + 8,0,0,0,0,127,127,0,0,0,0,8,8,62,119,65, + 65,0,2,3,1,3,2,1,1,0}; + +u8x8_t u8x8; + + +int main(void) +{ + u8x8_Setup_TGA_DESC(&u8x8); + u8x8_display_Init(&u8x8); + u8x8_display_SetPowerSave(&u8x8, 0); + + u8x8_Set8x8Font(&u8x8, bdf_font); + u8x8_Draw8x8String(&u8x8, 0, 0, "Hello World!"); + + tga_save("u8x8.tga"); + return 0; +} + diff --git a/u8g2/sys/tga/text_picture_loop/Makefile b/u8g2/sys/tga/text_picture_loop/Makefile new file mode 100644 index 00000000..92cd9e27 --- /dev/null +++ b/u8g2/sys/tga/text_picture_loop/Makefile @@ -0,0 +1,12 @@ +CFLAGS = -g -Wall -I../../../csrc/. `sdl-config --cflags` + +SRC = $(shell ls ../../../csrc/*.c) $(shell ls ../common/*.c ) main.c + +OBJ = $(SRC:.c=.o) + +u8g2_tga: $(OBJ) + $(CC) $(CFLAGS) $(LDFLAGS) $(OBJ) `sdl-config --libs` -o u8g2_tga + +clean: + -rm $(OBJ) u8g2_tga + diff --git a/u8g2/sys/tga/text_picture_loop/main.c b/u8g2/sys/tga/text_picture_loop/main.c new file mode 100644 index 00000000..c8a31de4 --- /dev/null +++ b/u8g2/sys/tga/text_picture_loop/main.c @@ -0,0 +1,267 @@ + +#include "u8g2.h" +#include + +const uint8_t bdf_font[762] U8X8_FONT_SECTION("bdf_font") = { + 32,126,0,0,0,0,0,0,0,0,0,0,0,95,95,0, + 0,0,0,7,7,0,7,7,0,0,20,127,127,28,127,127, + 20,0,0,36,42,127,127,42,18,0,70,102,48,24,12,102, + 98,0,48,122,79,93,55,122,72,0,0,0,0,7,7,0, + 0,0,0,0,28,62,99,65,0,0,0,0,65,99,62,28, + 0,0,0,0,0,0,0,0,0,0,0,8,8,62,62,8, + 8,0,0,0,128,224,96,0,0,0,0,8,8,8,8,8, + 8,0,0,0,0,96,96,0,0,0,96,48,24,12,6,3, + 1,0,62,127,81,73,69,127,62,0,0,64,66,127,127,64, + 64,0,0,114,123,73,73,111,102,0,0,34,97,73,73,127, + 54,0,24,20,82,127,127,80,16,0,0,39,111,73,73,121, + 51,0,0,62,127,73,73,123,50,0,0,3,1,113,125,15, + 7,0,0,54,127,73,73,127,54,0,0,38,111,73,73,127, + 62,0,0,0,0,108,108,0,0,0,0,0,128,236,108,0, + 0,0,0,8,28,54,99,65,0,0,0,36,36,36,36,36, + 36,0,0,65,99,54,28,8,0,0,0,2,3,81,89,15, + 6,0,62,127,65,93,93,95,30,0,0,124,126,19,19,126, + 124,0,65,127,127,73,73,127,54,0,28,62,99,65,65,99, + 34,0,65,127,127,65,99,62,28,0,65,127,127,73,93,65, + 99,0,65,127,127,73,29,1,3,0,60,126,67,65,81,115, + 114,0,0,127,127,8,8,127,127,0,0,65,65,127,127,65, + 65,0,48,112,64,65,127,63,1,0,65,127,127,8,28,119, + 99,0,65,127,127,65,64,96,112,0,127,127,14,28,14,127, + 127,0,127,127,6,12,24,127,127,0,28,62,99,65,99,62, + 28,0,65,127,127,73,9,7,6,0,60,126,67,81,51,110, + 92,0,65,127,127,9,25,63,102,0,0,38,111,73,73,123, + 50,0,0,3,65,127,127,65,3,0,0,63,127,64,64,127, + 63,0,0,31,63,96,96,63,31,0,127,127,48,24,48,127, + 127,0,97,115,30,12,30,115,97,0,0,7,79,120,120,79, + 7,0,71,99,113,89,77,103,115,0,0,0,127,127,65,65, + 0,0,1,3,6,12,24,48,96,0,0,0,65,65,127,127, + 0,0,8,12,6,3,6,12,8,0,0,0,0,0,0,0, + 0,0,0,0,2,6,12,8,0,0,32,116,84,84,60,120, + 64,0,67,63,127,68,68,124,56,0,0,56,124,68,68,108, + 40,0,56,124,68,69,63,127,64,0,0,56,124,84,84,92, + 24,0,0,72,126,127,73,3,2,0,0,152,188,164,164,252, + 124,0,65,127,127,8,4,124,120,0,0,0,68,125,125,64, + 0,0,0,96,224,128,132,252,125,0,65,127,127,16,56,108, + 68,0,0,0,65,127,127,64,0,0,120,124,12,56,12,124, + 120,0,4,124,120,4,4,120,120,0,0,56,124,68,68,124, + 56,0,132,252,248,164,36,60,24,0,24,60,36,164,248,252, + 132,0,68,124,120,68,12,8,0,0,0,72,92,84,84,116, + 32,0,0,4,63,127,68,100,32,0,0,60,124,64,64,124, + 124,0,0,28,60,96,96,60,28,0,60,124,96,56,96,124, + 60,0,68,108,56,16,56,108,68,0,0,156,188,160,160,252, + 124,0,0,76,100,116,92,76,68,0,0,65,65,119,62,8, + 8,0,0,0,0,127,127,0,0,0,0,8,8,62,119,65, + 65,0,2,3,1,3,2,1,1,0}; + +const uint8_t u8g2_font_helvB18_tr[2245] U8X8_FONT_SECTION("u8g2_font_helvB18_tr") = { + 95,0,4,3,5,5,3,5,6,23,24,0,251,19,251,19, + 251,2,234,6,37,32,6,0,48,154,0,33,10,99,26,158, + 240,23,234,14,4,34,11,197,184,167,32,193,139,145,8,0, + 35,42,76,22,186,36,34,38,34,38,34,38,34,38,34,115, + 64,113,64,35,34,38,34,38,34,38,34,115,64,113,64,35, + 34,38,34,38,34,38,34,38,34,4,36,39,172,210,181,37, + 119,116,48,65,33,177,68,196,68,228,66,204,174,146,178,206, + 76,226,68,196,68,196,68,228,66,130,226,96,232,78,84,10, + 0,37,49,85,18,218,61,87,54,118,52,54,179,76,74,100, + 78,74,100,110,102,98,242,100,180,100,30,102,30,100,166,116, + 228,112,100,102,110,68,74,108,70,74,108,102,213,212,217,88, + 9,0,38,38,80,22,202,84,122,72,65,55,51,55,51,55, + 51,56,49,218,244,100,134,130,98,102,230,100,170,102,108,104, + 170,134,230,129,200,144,209,0,39,8,194,184,155,112,64,1, + 40,22,6,119,161,36,51,50,51,50,51,35,179,255,72,104, + 102,104,102,104,72,0,41,22,6,119,161,32,180,102,104,102, + 72,104,102,255,70,102,201,204,200,140,16,0,42,16,232,148, + 171,35,38,35,33,113,48,66,35,162,5,0,43,14,140,53, + 190,37,170,171,131,7,83,162,186,2,44,10,195,184,157,112, + 32,33,65,1,45,7,103,208,162,240,1,46,7,99,24,158, + 112,32,47,18,103,22,162,165,145,148,34,41,141,164,20,73, + 41,146,82,5,48,27,76,18,182,99,117,16,67,66,50,52, + 50,52,49,230,159,77,12,141,12,141,176,57,136,178,1,49, + 12,71,26,182,180,230,224,128,104,255,15,50,27,76,18,182, + 83,117,32,51,67,49,53,49,102,54,57,56,72,199,172,140, + 142,225,228,193,131,1,51,31,76,18,182,83,117,32,179,100, + 106,98,106,98,106,114,112,172,238,114,116,210,204,138,98,134, + 228,96,200,6,0,52,27,76,18,182,55,200,174,153,196,212, + 196,148,200,144,204,54,66,35,67,35,7,15,230,38,55,1, + 53,30,76,18,182,113,48,114,48,50,185,229,65,208,129,204, + 12,229,232,228,164,153,213,65,12,201,129,148,13,0,54,32, + 76,18,182,84,117,32,66,51,50,101,102,185,130,232,96,164, + 132,130,104,98,204,217,196,208,8,155,131,40,27,0,55,24, + 76,18,182,240,193,32,225,202,193,201,193,201,193,201,65,194, + 201,65,194,201,57,0,56,35,76,18,182,68,118,16,52,50, + 51,52,50,52,50,52,50,52,51,50,101,117,16,51,52,49, + 230,217,196,208,200,193,144,13,0,57,32,76,18,182,99,116, + 32,67,66,65,52,49,230,217,17,5,73,197,1,77,197,228, + 164,213,4,73,201,129,84,17,0,58,10,195,25,158,112,32, + 15,121,32,59,13,35,186,157,112,32,15,121,32,33,65,1, + 60,14,141,49,190,58,88,214,25,37,109,105,167,3,61,11, + 170,184,186,240,192,244,224,192,0,62,13,141,53,186,48,218, + 91,74,178,30,142,2,63,24,107,26,190,99,115,32,66,114, + 16,100,101,68,55,71,70,183,112,123,4,131,139,0,64,65, + 214,150,225,119,32,123,96,88,86,69,74,67,60,66,84,33, + 50,49,116,32,114,179,198,102,104,198,70,104,200,100,104,102, + 98,100,72,104,98,100,102,201,154,37,51,35,19,52,36,7, + 85,51,21,115,244,64,244,64,85,163,7,197,7,129,0,65, + 37,112,22,202,70,76,107,106,57,34,57,50,56,50,55,52, + 54,52,54,52,53,54,52,54,116,80,115,112,50,56,50,56, + 49,234,116,0,66,37,111,26,202,112,64,116,96,50,70,50, + 56,49,56,49,56,49,56,49,55,114,80,115,96,50,56,49, + 233,195,179,138,3,147,3,34,0,67,29,112,22,202,117,119, + 64,84,83,66,71,49,121,60,189,175,41,39,38,39,232,72, + 106,138,14,232,142,0,68,30,112,26,206,112,64,117,96,51, + 86,50,72,49,57,49,121,234,95,94,78,12,82,140,149,28, + 216,28,80,1,69,22,109,26,194,112,80,113,80,49,186,167, + 7,36,7,36,163,251,244,224,65,1,70,17,108,26,190,240, + 129,229,94,30,80,28,80,76,238,47,1,71,35,113,22,206, + 117,120,64,85,83,67,71,50,57,65,61,190,217,1,217,1, + 173,237,233,196,36,5,93,73,205,131,137,169,147,1,72,14, + 111,26,206,48,233,95,30,252,32,210,127,57,73,8,99,26, + 158,240,63,8,74,17,107,22,186,184,255,161,149,87,19,51, + 20,7,50,39,0,75,39,110,26,202,48,119,70,49,69,50, + 68,51,67,52,66,53,65,118,247,32,140,130,106,102,106,104, + 17,205,212,204,216,200,24,197,220,196,28,1,76,12,108,26, + 190,48,185,255,191,60,120,48,77,50,115,26,222,48,125,123, + 16,123,32,121,48,121,64,119,32,33,39,97,49,53,97,34, + 37,98,50,51,98,50,51,98,163,198,102,98,198,102,98,198, + 168,200,168,200,106,202,106,202,106,1,78,39,111,26,206,48, + 121,248,32,238,32,238,64,204,98,202,98,202,100,200,102,198, + 102,198,104,196,74,196,106,194,236,64,238,32,238,32,240,114, + 0,79,29,113,22,206,117,120,64,85,83,67,71,50,57,65, + 121,235,111,47,41,38,71,232,104,90,29,16,94,1,80,23, + 110,26,198,112,64,115,96,49,55,49,232,187,137,3,139,131, + 146,217,253,45,0,81,35,145,246,205,117,120,64,85,83,67, + 71,50,57,65,121,235,111,207,66,40,166,38,70,168,108,138, + 168,14,234,46,230,1,66,0,82,26,110,26,198,112,64,115, + 96,49,55,49,232,187,137,3,139,131,146,49,138,185,137,65, + 127,56,83,32,110,26,198,100,118,48,67,83,65,54,49,55, + 49,75,91,122,16,121,90,75,107,232,238,64,166,228,128,234, + 8,0,84,13,111,18,190,240,3,177,225,253,255,25,0,85, + 19,111,26,206,48,233,255,151,119,20,115,35,53,53,7,100, + 71,0,86,36,112,22,202,48,106,122,72,49,56,66,70,51, + 54,52,54,196,106,104,108,104,140,132,110,100,112,100,112,100, + 210,212,150,152,25,0,87,62,117,22,222,48,54,102,54,102, + 54,102,182,98,168,104,100,168,104,100,72,66,104,100,102,98, + 102,70,102,98,70,104,100,98,100,104,68,70,100,104,98,102, + 98,74,98,102,66,76,98,102,66,172,170,172,170,110,225,220, + 224,220,16,0,88,37,112,22,202,48,122,72,65,70,51,54, + 53,52,55,50,120,16,105,75,76,107,121,16,56,50,55,52, + 69,68,52,54,51,56,65,120,58,89,30,111,22,198,48,121, + 56,49,55,66,54,51,53,68,52,53,51,54,51,55,49,56, + 49,89,90,59,188,207,0,90,21,110,22,194,240,83,74,78, + 41,153,82,50,165,36,29,165,36,61,248,0,91,13,5,119, + 161,112,96,178,255,255,201,193,0,92,18,103,18,162,32,165, + 76,74,153,148,102,82,202,164,148,73,41,93,13,5,123,161, + 112,48,178,255,255,201,129,1,94,19,43,85,187,52,56,87, + 38,33,53,49,179,100,102,98,202,106,0,95,7,78,112,185, + 240,3,96,8,134,244,163,48,180,1,97,30,204,21,186,99, + 117,16,51,67,50,52,57,102,115,32,82,50,65,52,49,53, + 49,68,65,82,114,64,82,50,98,26,108,26,190,48,185,23, + 53,7,35,37,20,68,19,99,126,118,52,81,66,113,48,50, + 81,3,99,21,203,21,182,99,116,16,194,98,200,112,47,135, + 38,72,72,14,130,76,0,100,25,108,22,190,185,55,21,35, + 7,19,36,21,67,103,126,54,49,68,65,82,114,48,83,49, + 101,27,204,21,186,68,118,16,67,66,50,52,49,102,118,240, + 129,228,232,212,4,13,201,129,84,13,0,102,16,103,22,166, + 67,82,50,180,228,224,100,104,255,19,0,103,31,108,118,189, + 83,49,114,48,65,82,49,116,230,103,19,67,20,36,37,7, + 51,21,147,102,71,35,7,67,54,0,104,17,107,26,190,48, + 184,23,52,7,19,52,19,83,254,175,6,105,10,99,26,158, + 112,32,118,240,7,106,13,5,115,157,178,241,200,254,127,114, + 80,1,107,31,107,26,186,48,184,71,19,51,20,35,36,19, + 52,71,86,71,19,52,35,51,35,36,51,20,67,19,67,87, + 3,108,8,99,26,158,240,63,8,109,36,209,25,214,48,65, + 82,114,112,32,65,82,114,52,100,52,100,52,100,52,100,52, + 100,52,100,52,100,52,100,52,100,52,100,180,0,110,16,203, + 25,190,48,81,114,48,65,51,49,229,255,106,0,111,23,204, + 21,186,68,118,16,67,66,50,52,49,230,103,19,67,35,108, + 14,194,136,0,112,27,108,122,189,48,81,115,48,82,66,65, + 52,49,230,103,71,19,37,20,7,35,19,53,147,187,4,113, + 25,108,118,189,83,49,114,48,65,82,49,116,230,103,19,67, + 20,36,37,7,51,21,147,123,114,13,199,25,170,48,113,240, + 102,104,255,8,0,115,25,203,21,182,98,116,16,194,98,104, + 98,208,236,32,204,240,202,234,134,226,64,230,4,0,116,15, + 71,22,166,50,180,201,193,201,208,254,81,13,1,117,16,203, + 25,190,48,229,255,136,98,164,194,98,102,100,0,118,26,204, + 21,186,48,230,108,98,104,100,104,100,104,102,100,104,100,104, + 100,202,204,142,144,17,0,119,43,211,17,206,48,53,101,181, + 66,106,74,100,166,102,100,166,102,70,133,140,144,200,196,136, + 208,196,86,18,50,18,98,53,101,53,117,83,131,83,131,83, + 67,0,120,26,203,21,182,48,117,67,49,179,98,232,170,110, + 174,172,106,98,134,130,100,102,130,230,106,0,121,32,109,118, + 189,48,103,55,49,54,65,52,51,52,67,66,52,50,53,50, + 102,103,88,72,186,114,116,114,176,144,14,0,122,19,203,21, + 182,240,65,220,58,50,186,57,50,186,117,116,7,15,2,123, + 15,7,119,169,52,179,104,191,89,52,181,104,191,90,124,8, + 2,127,157,240,15,12,125,16,7,123,169,48,181,104,191,90, + 52,179,104,191,89,4,126,13,139,180,186,65,115,48,97,113, + 48,67,1,0,0}; + +u8g2_t u8g2; + +int main(void) +{ + int x, y; + int k; + int i; + + u8g2_Setup_TGA_DESC(&u8g2, &u8g2_cb_r0); + u8x8_display_Init(u8g2_GetU8x8(&u8g2)); + u8x8_display_SetPowerSave(u8g2_GetU8x8(&u8g2), 0); + u8g2_SetFont(&u8g2, u8g2_font_helvB18_tr); + + x = 50; + y = 30+0; + + +#ifdef U8G2_WITH_HVLINE_COUNT + u8g2.hv_cnt = 0UL; +#endif /* U8G2_WITH_HVLINE_COUNT */ + + /* + u8g2_ClearBuffer(&u8g2); + + u8g2_SetFontDirection(&u8g2, 0); + u8g2_DrawString(&u8g2, x, y, "ABC"); + u8g2_SetFontDirection(&u8g2, 1); + u8g2_DrawString(&u8g2, x, y, "abc"); + u8g2_SetFontDirection(&u8g2, 2); + u8g2_DrawString(&u8g2, x, y, "abc"); + u8g2_SetFontDirection(&u8g2, 3); + u8g2_DrawString(&u8g2, x, y, "abc"); + + u8g2_SendBuffer(&u8g2); + */ + + u8g2_FirstPage(&u8g2); + i = 0; + do + { + u8g2_SetFontDirection(&u8g2, 0); + u8g2_DrawString(&u8g2, x, y, "ABC"); + u8g2_SetFontDirection(&u8g2, 1); + u8g2_DrawString(&u8g2, x, y, "abc"); + u8g2_SetFontDirection(&u8g2, 2); + u8g2_DrawString(&u8g2, x, y, "abc"); + u8g2_SetFontDirection(&u8g2, 3); + u8g2_DrawString(&u8g2, x, y, "abc"); + if ( i == 1 ) + { + u8g2_DrawHVLine(&u8g2, u8g2.user_x0, u8g2.user_y0, 1, 0); + u8g2_DrawHVLine(&u8g2, u8g2.user_x0, u8g2.user_y1-1, 1, 0); + u8g2_DrawHVLine(&u8g2, u8g2.user_x1-1, u8g2.user_y1-1, 1, 0); + u8g2_DrawHVLine(&u8g2, u8g2.user_x1-1, u8g2.user_y0, 1, 0); + + } + + i++; + + + } while( u8g2_NextPage(&u8g2) ); +#ifdef U8G2_WITH_HVLINE_COUNT + printf("hv cnt: %ld\n", u8g2.hv_cnt); +#endif /* U8G2_WITH_HVLINE_COUNT */ + + tga_save("u8g2.tga"); + + return 0; +} +