intoduced flipmode_x_offset, removed option to disable flipmode handling (it is now always enabled)
This commit is contained in:
parent
ad5ab4c921
commit
00b7d1337b
12
csrc/u8x8.h
12
csrc/u8x8.h
|
@ -92,11 +92,13 @@
|
|||
#define U8X8_WITH_SET_CONTRAST
|
||||
|
||||
/* Undefine this to remove u8x8_SetFlipMode function */
|
||||
#define U8X8_WITH_SET_FLIP_MODE
|
||||
/* 26 May 2016: Obsolete */
|
||||
//#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
|
||||
/* 26 May 2016: Obsolete */
|
||||
//#define U8X8_DEFAULT_FLIP_MODE 0
|
||||
|
||||
/*==========================================*/
|
||||
/* Includes */
|
||||
|
@ -122,11 +124,14 @@ extern "C" {
|
|||
|
||||
/* the following macro returns the first value for the normal mode */
|
||||
/* or the second argument for the flip mode */
|
||||
|
||||
/* 26 May 2016: Obsolete
|
||||
#if U8X8_DEFAULT_FLIP_MODE == 0
|
||||
#define U8X8_IF_DEFAULT_NORMAL_OR_FLIP(normal, flipmode) (normal)
|
||||
#else
|
||||
#define U8X8_IF_DEFAULT_NORMAL_OR_FLIP(normal, flipmode) (flipmode)
|
||||
#endif
|
||||
*/
|
||||
|
||||
#ifdef __GNUC__
|
||||
# define U8X8_NOINLINE __attribute__((noinline))
|
||||
|
@ -226,7 +231,8 @@ struct u8x8_display_info_struct
|
|||
uint8_t tile_width;
|
||||
uint8_t tile_height;
|
||||
|
||||
uint8_t default_x_offset; /* default x offset for the display */
|
||||
uint8_t default_x_offset; /* default x offset for the display */
|
||||
uint8_t flipmode_x_offset; /* x offset, if flip mode is enabled */
|
||||
|
||||
/* pixel width is not used by the u8x8 procedures */
|
||||
/* instead it will be used by the u8g2 procedures, because the pixel dimension can */
|
||||
|
|
|
@ -58,6 +58,7 @@ static const u8x8_display_info_t u8x8_ls013b7dh03_128x128_display_info =
|
|||
/* tile_width = */ 16,
|
||||
/* tile_hight = */ 16,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 128,
|
||||
/* pixel_height = */ 128
|
||||
};
|
||||
|
|
|
@ -52,13 +52,11 @@ static const uint8_t u8x8_d_ssd1306_128x32_univision_init_seq[] = {
|
|||
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
|
||||
// Flipmode
|
||||
// U8X8_C(0x0a0), /* segment remap a0/a1*/
|
||||
// U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
||||
|
||||
U8X8_CA(0x0da, 0x002), /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
|
||||
U8X8_CA(0x081, 0x08f), /* [2] set contrast control */
|
||||
|
@ -87,7 +85,6 @@ static const uint8_t u8x8_d_ssd1306_128x32_univision_powersave1_seq[] = {
|
|||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
|
||||
#ifdef U8X8_WITH_SET_FLIP_MODE
|
||||
static const uint8_t u8x8_d_ssd1306_128x32_univision_flip0_seq[] = {
|
||||
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
|
||||
U8X8_C(0x0a1), /* segment remap a0/a1*/
|
||||
|
@ -103,7 +100,6 @@ static const uint8_t u8x8_d_ssd1306_128x32_univision_flip1_seq[] = {
|
|||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
static uint8_t u8x8_d_ssd1306_128x32_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
|
@ -127,14 +123,18 @@ static uint8_t u8x8_d_ssd1306_128x32_generic(u8x8_t *u8x8, uint8_t msg, uint8_t
|
|||
else
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_128x32_univision_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_128x32_univision_flip0_seq);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_128x32_univision_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
|
@ -193,10 +193,11 @@ static const u8x8_display_info_t u8x8_ssd1306_128x32_univision_display_info =
|
|||
/* 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,
|
||||
/* tile_hight = */ 4,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 128,
|
||||
/* pixel_height = */ 64
|
||||
/* pixel_height = */ 32
|
||||
};
|
||||
|
||||
uint8_t u8x8_d_ssd1306_128x32_univision(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
|
|
|
@ -52,13 +52,11 @@ static const uint8_t u8x8_d_ssd1306_128x64_noname_init_seq[] = {
|
|||
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
|
||||
// Flipmode
|
||||
// U8X8_C(0x0a0), /* segment remap a0/a1*/
|
||||
// U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
|
||||
|
||||
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 */
|
||||
|
@ -87,7 +85,6 @@ static const uint8_t u8x8_d_ssd1306_128x64_noname_powersave1_seq[] = {
|
|||
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*/
|
||||
|
@ -103,7 +100,6 @@ static const uint8_t u8x8_d_ssd1306_128x64_noname_flip1_seq[] = {
|
|||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
static uint8_t u8x8_d_ssd1306_sh1106_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
|
@ -127,14 +123,18 @@ static uint8_t u8x8_d_ssd1306_sh1106_generic(u8x8_t *u8x8, uint8_t msg, uint8_t
|
|||
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);
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_128x64_noname_flip1_seq);
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
|
@ -195,6 +195,7 @@ static const u8x8_display_info_t u8x8_ssd1306_128x64_noname_display_info =
|
|||
/* tile_width = */ 16,
|
||||
/* tile_hight = */ 8,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 128,
|
||||
/* pixel_height = */ 64
|
||||
};
|
||||
|
@ -228,6 +229,7 @@ static const u8x8_display_info_t u8x8_sh1106_128x64_noname_display_info =
|
|||
/* tile_width = */ 16,
|
||||
/* tile_hight = */ 8,
|
||||
/* default_x_offset = */ 2,
|
||||
/* flipmode_x_offset = */ 2,
|
||||
/* pixel_width = */ 128,
|
||||
/* pixel_height = */ 64
|
||||
};
|
||||
|
|
|
@ -159,6 +159,7 @@ static const u8x8_display_info_t u8x8_st7920_192x32_display_info =
|
|||
/* tile_width = */ 24,
|
||||
/* tile_hight = */ 4,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 192,
|
||||
/* pixel_height = */ 32
|
||||
};
|
||||
|
@ -181,6 +182,7 @@ static const u8x8_display_info_t u8x8_st7920_128x64_display_info =
|
|||
/* tile_width = */ 16,
|
||||
/* tile_hight = */ 8,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 128,
|
||||
/* pixel_height = */ 64
|
||||
};
|
||||
|
|
|
@ -46,13 +46,11 @@ static const uint8_t u8x8_d_uc1701_dogs102_init_seq[] = {
|
|||
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
|
||||
// Flipmode
|
||||
//U8X8_C(0x0a0), /* ADC set to reverse */
|
||||
//U8X8_C(0x0c8), /* common output mode */
|
||||
|
||||
U8X8_C(0x0a6), /* display normal, bit val 0: LCD pixel off. */
|
||||
U8X8_C(0x0a2), /* LCD bias 1/9 */
|
||||
|
@ -81,7 +79,6 @@ static const uint8_t u8x8_d_uc1701_dogs102_powersave1_seq[] = {
|
|||
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*/
|
||||
|
@ -97,7 +94,6 @@ static const uint8_t u8x8_d_uc1701_dogs102_flip1_seq[] = {
|
|||
U8X8_END_TRANSFER(), /* disable chip */
|
||||
U8X8_END() /* end of sequence */
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_uc1701_display_info =
|
||||
|
@ -117,7 +113,8 @@ static const u8x8_display_info_t u8x8_uc1701_display_info =
|
|||
/* write_pulse_width_ns = */ 40,
|
||||
/* tile_width = */ 13, /* width of 13*8=104 pixel */
|
||||
/* tile_hight = */ 8,
|
||||
/* default_x_offset = */ U8X8_IF_DEFAULT_NORMAL_OR_FLIP(0, 30),
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 30,
|
||||
/* pixel_width = */ 102,
|
||||
/* pixel_height = */ 64
|
||||
};
|
||||
|
@ -141,20 +138,18 @@ uint8_t u8x8_d_uc1701_ea_dogs102(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, voi
|
|||
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;
|
||||
u8x8->x_offset = u8x8->display_info->default_x_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1701_dogs102_flip1_seq);
|
||||
u8x8->x_offset = 30;
|
||||
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
u8x8_cad_StartTransfer(u8x8);
|
||||
|
|
|
@ -0,0 +1,90 @@
|
|||
/*
|
||||
|
||||
HelloWorld.ino
|
||||
|
||||
"Hello World" version for U8x8 API
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
Copyright (c) 2016, olikraus@gmail.com
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <U8x8lib.h>
|
||||
|
||||
#ifdef U8X8_HAVE_HW_SPI
|
||||
#include <SPI.h>
|
||||
#endif
|
||||
|
||||
// Please UNCOMMENT one of the contructor lines below
|
||||
// U8x8 Contructor List
|
||||
// The complete list is available here: https://github.com/olikraus/u8g2/wiki/u8x8setupcpp
|
||||
// Please update the pin numbers according to your setup. Use U8X8_PIN_NONE if the reset pin is not connected
|
||||
//U8X8_SSD1306_128X64_NONAME_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
//U8X8_SSD1306_128X64_NONAME_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
//U8X8_SSD1306_128X64_NONAME_3W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8);
|
||||
//U8X8_SSD1306_128X64_NONAME_SW_I2C u8x8(/* clock=*/ 2, /* data=*/ 0, /* reset=*/ U8X8_PIN_NONE); /* Digispark ATTiny85 */
|
||||
//U8X8_SSD1306_128X64_NONAME_SW_I2C u8x8(/* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // OLEDs without Reset of the Display
|
||||
//U8X8_SSD1306_128X32_UNIVISION_SW_I2C u8x8(/* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather ESP8266/32u4 Boards + FeatherWing OLED
|
||||
//U8X8_SSD1306_128X32_UNIVISION_SW_I2C u8x8(/* clock=*/ 21, /* data=*/ 20, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather M0 Basic Proto + FeatherWing OLED
|
||||
//U8X8_SSD1306_128X32_UNIVISION_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); // Adafruit ESP8266/32u4/ARM Boards + FeatherWing OLED
|
||||
//U8X8_SSD1306_128X64_NONAME_6800 u8x8(13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8);
|
||||
//U8X8_SSD1306_128X64_NONAME_8080 u8x8(13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8);
|
||||
//U8X8_ST7920_192X32_8080 u8x8(8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ U8X8_PIN_NONE, /*dc=*/ 17, /*reset=*/ U8X8_PIN_NONE);
|
||||
//U8X8_ST7920_192X32_6800 u8x8(8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ U8X8_PIN_NONE, /*dc=*/ 17, /*reset=*/ U8X8_PIN_NONE);
|
||||
//U8X8_UC1701_EA_DOGS102_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
//U8X8_UC1701_EA_DOGS102_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
//U8X8_ST7565_EA_DOGM128_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
//U8X8_ST7565_EA_DOGM128_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
U8X8_ST7565_NHD_C12832_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
//U8X8_ST7565_NHD_C12832_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
|
||||
|
||||
// End of constructor list
|
||||
|
||||
void setup(void)
|
||||
{
|
||||
u8x8.begin();
|
||||
}
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
u8x8.setFont(u8x8_font_chroma48medium8_r);
|
||||
|
||||
u8x8.clear();
|
||||
u8x8.setFlipMode(0);
|
||||
u8x8.drawString(0,0,"FlipMode 0");
|
||||
delay(1500);
|
||||
|
||||
u8x8.clear();
|
||||
u8x8.setFlipMode(1);
|
||||
u8x8.drawString(0,0,"FlipMode 1");
|
||||
delay(1500);
|
||||
|
||||
}
|
|
@ -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 .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/Wire/
|
||||
EXTRA_DIRS+=$(ARDUINO_PATH)libraries/Wire/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)) $(U8G_CPP_PATH)
|
||||
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$(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 .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))
|
||||
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
GraphicsTest.ino
|
||||
|
||||
Some graphics/text output for U8x8 API
|
||||
Some graphics/text output for U8x8 API
|
||||
|
||||
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
|
||||
|
||||
|
@ -65,7 +65,7 @@
|
|||
//U8X8_UC1701_EA_DOGS102_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
//U8X8_ST7565_EA_DOGM128_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
//U8X8_ST7565_EA_DOGM128_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
//U8X8_ST7565_NHD_C12832_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
U8X8_ST7565_NHD_C12832_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
//U8X8_ST7565_NHD_C12832_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
|
||||
|
||||
|
||||
|
|
|
@ -200,11 +200,8 @@ static const u8x8_display_info_t u8x8_sdl_128x64_info =
|
|||
/* 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
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 128,
|
||||
/* pixel_height = */ 64
|
||||
};
|
||||
|
|
|
@ -207,11 +207,8 @@ static const u8x8_display_info_t u8x8_tga_desc_info =
|
|||
/* 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
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ (2*XOFFSET+DEFAULT_WIDTH),
|
||||
/* pixel_height = */ (2*YOFFSET+DEFAULT_HEIGHT)
|
||||
};
|
||||
|
|
|
@ -149,11 +149,8 @@ static const u8x8_display_info_t u8x8_utf8_info =
|
|||
/* write_pulse_width_ns = */ 0,
|
||||
/* tile_width = */ (CHGR_WIDTH+7)/8,
|
||||
/* tile_hight = */ (CHGR_HEIGHT+7)/8,
|
||||
#if U8X8_DEFAULT_FLIP_MODE == 0
|
||||
/* default_x_offset = */ 0,
|
||||
#else
|
||||
/* default_x_offset = */ 0,
|
||||
#endif
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ CHGR_WIDTH,
|
||||
/* pixel_height = */ CHGR_HEIGHT
|
||||
};
|
||||
|
|
|
@ -190,11 +190,10 @@ static const u8x8_display_info_t u8x8_tga_info =
|
|||
/* write_pulse_width_ns = */ 0,
|
||||
/* tile_width = */ (DEFAULT_WIDTH)/8,
|
||||
/* tile_hight = */ (DEFAULT_HEIGHT)/8,
|
||||
#if U8X8_DEFAULT_FLIP_MODE == 0
|
||||
/* default_x_offset = */ 0,
|
||||
#else
|
||||
/* default_x_offset = */ 0,
|
||||
#endif
|
||||
/* flipmode_x_offset = */ 0,
|
||||
DEFAULT_WIDTH,
|
||||
DEFAULT_HEIGHT
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue