olikraus / ucglib

Arduino True Color Library for TFTs and OLEDs
https://github.com/olikraus/ucglib/wiki
Other
267 stars 77 forks source link

Huge file with raspberry PICO #161

Closed nicoverduin closed 1 year ago

nicoverduin commented 1 year ago

I use the Respberry PICO and if I compile ucglib into a static library, I get a file of about 3.6 Megabytes. The if I create a simple project with ucglib I get an elf of 1.168 megabytes. Isn't that a bot large? I have attched the folowing files: a) ucglib_pico.h containing the the callback b) spi_pins.h containing SPI port and pin definitions c) main.c actual program d) CMakeLists.txt for the program e) CMakeLists.txt for the library

ucglib is built into a separate folder

ucglib_pico.h ' /**

// includes

include "hardware/spi.h"

include "hardware/gpio.h"

include "pico/time.h"

include "pico.h"

include "ucg.h" // ucglib interface

include "../../ucg_1/spi_pins.h" // shows the connections of the tft screen to SPI

                          // and SPI port used

/**

spi_pins.h /**

define SPI_PORT spi0 // we use SPI port 0

define TFT_CS 17 // chip select

define TFT_SCK 18 // Serial Clock

define TFT_MOSI 19 // Master out Slave in

define TFT_RST 21 // reset

define TFT_DC 20 // data / command

endif // SPI_PINS_H

main.c /**

// includes

include

include "pico/stdlib.h"

include "ucglib_pico.h" // interface between PICO and ucglib

/**

CmakeLists.txt for the program `add_executable(ucg_1 main.c ../ucglib/csrc/ucglib_pico.h spi_pins.h)

eventueel zoeken in ucglib

include_directories(../ucglib/csrc)

pull in common dependencies and additional spi hardware support

target_link_libraries(ucg_1 pico_stdlib hardware_spi hardware_gpio ucglib)

create map/bin/hex file etc.

pico_add_extra_outputs(ucg_1)

add url via pico_set_program_url

example_auto_set_url(ucg_1) `

CMakeLists.txt for the library `# We gaan hier de library maken voor ucglib add_library(ucglib csrc/ucg_bitmap.c csrc/ucg_box.c csrc/ucg_ccs.c csrc/ucg_circle.c csrc/ucg_clip.c csrc/ucg_com_msg_api.c csrc/ucg_dev_default_cb.c csrc/ucg_dev_ic_hx8352c.c csrc/ucg_dev_ic_ili9163.c csrc/ucg_dev_ic_ili9325.c csrc/ucg_dev_ic_ili9325_spi.c csrc/ucg_dev_ic_ili9341.c csrc/ucg_dev_ic_ili9486.c csrc/ucg_dev_ic_ld50t6160.c csrc/ucg_dev_ic_pcf8833.c csrc/ucg_dev_ic_seps225.c csrc/ucg_dev_ic_ssd1289.c csrc/ucg_dev_ic_ssd1331.c csrc/ucg_dev_ic_ssd1351.c csrc/ucg_dev_ic_st7735.c csrc/ucg_dev_msg_api.c csrc/ucg_dev_oled_128x128_ft.c csrc/ucg_dev_oled_128x128_ilsoft.c csrc/ucg_dev_oled_128x128_univision.c csrc/ucg_dev_oled_160x128_samsung.c csrc/ucg_dev_oled_96x64_univision.c csrc/ucg_dev_tft_128x128_ili9163.c csrc/ucg_dev_tft_128x160_st7735.c csrc/ucg_dev_tft_132x132_pcf8833.c csrc/ucg_dev_tft_240x320_ili9325_spi.c csrc/ucg_dev_tft_240x320_ili9341.c csrc/ucg_dev_tft_240x320_itdb02.c csrc/ucg_dev_tft_240x320_ssd1289.c csrc/ucg_dev_tft_240x400_hx8352c.c csrc/ucg_dev_tft_320x480_ili9486.c csrc/ucg_font.c csrc/ucg_init.c csrc/ucg_line.c csrc/ucg_pixel.c csrc/ucg_pixel_font_data.c csrc/ucg_polygon.c csrc/ucg_rotate.c csrc/ucg_scale.c csrc/ucg_vector_font_data.c )

`

nicoverduin commented 1 year ago

Seems like the linker just wants to add everything into the flash. Now I just made a link to the csrc folder and added the files in my CMakeLists.txt and it compiles fine. Now the programs are reduce to something like 50+ kbytes

My CMakeLists.xt `# @file CmakeLists.txt

@brief used to generate the correct makefiles including ucglib

@author Nico Verduin

@date 22-2-2023

if we use ucglib update the variable below with correct path

set (UCGLIB "../ucglib/csrc/")

give the project the root folder name

cmake_path(GET CMAKE_CURRENT_SOURCE_DIR FILENAME PROJECTNAME) string(REPLACE " " "" ProjectId ${PROJECT_NAME}) project(${PROJECT_NAME})

let's get all the sources

set(PROJECT_SOURCE_DIRS ".c .h")

if we use UCG lib add its folders as well

if (DEFINED UCGLIB)

add UCGLIB sources

set(PROJECT_SOURCE_DIRS ${PROJECT_SOURCE_DIRS} ${UCGLIB}*.c ${UCGLIB}*.h)
# search in folder
include_directories(${UCGLIB})

endif()

get all the sources and includes from current project dir and UCGLIB

file(GLOB PROJECT_SRC CONFIGURE_DEPENDS ${PROJECT_SOURCE_DIRS})

set dependencies for our firmware

add_executable(${PROJECT_NAME} main.c ${PROJECT_SRC} )

enable usb output, disable uart output

pico_enable_stdio_usb(${PROJECT_NAME} 1) pico_enable_stdio_uart(${PROJECT_NAME} 0)

pull in common dependencies and additional spi hardware support

target_link_libraries(${PROJECT_NAME} pico_stdlib hardware_spi hardware_gpio)

create map/bin/hex file etc.

pico_add_extra_outputs(${PROJECT_NAME})

add url via pico_set_program_url

example_auto_set_url(${PROJECT_NAME})

`